Lines Matching refs:sparx5
27 static u64 sparx5_ptp_get_1ppm(struct sparx5 *sparx5) in sparx5_ptp_get_1ppm() argument
37 switch (sparx5->coreclock) { in sparx5_ptp_get_1ppm()
55 static u64 sparx5_ptp_get_nominal_value(struct sparx5 *sparx5) in sparx5_ptp_get_nominal_value() argument
59 switch (sparx5->coreclock) { in sparx5_ptp_get_nominal_value()
81 struct sparx5 *sparx5 = port->sparx5; in sparx5_ptp_hwtstamp_set() local
89 if (test_bit(port->portno, sparx5->bridge_mask)) in sparx5_ptp_hwtstamp_set()
130 mutex_lock(&sparx5->ptp_lock); in sparx5_ptp_hwtstamp_set()
131 phc = &sparx5->phc[SPARX5_PHC_PORT]; in sparx5_ptp_hwtstamp_set()
133 mutex_unlock(&sparx5->ptp_lock); in sparx5_ptp_hwtstamp_set()
141 struct sparx5 *sparx5 = port->sparx5; in sparx5_ptp_hwtstamp_get() local
144 phc = &sparx5->phc[SPARX5_PHC_PORT]; in sparx5_ptp_hwtstamp_get()
223 struct sparx5 *sparx5 = port->sparx5; in sparx5_ptp_txtstamp_request() local
237 spin_lock_irqsave(&sparx5->ptp_ts_id_lock, flags); in sparx5_ptp_txtstamp_request()
238 if (sparx5->ptp_skbs == SPARX5_MAX_PTP_ID) { in sparx5_ptp_txtstamp_request()
239 spin_unlock_irqrestore(&sparx5->ptp_ts_id_lock, flags); in sparx5_ptp_txtstamp_request()
249 sparx5->ptp_skbs++; in sparx5_ptp_txtstamp_request()
254 spin_unlock_irqrestore(&sparx5->ptp_ts_id_lock, flags); in sparx5_ptp_txtstamp_request()
262 struct sparx5 *sparx5 = port->sparx5; in sparx5_ptp_txtstamp_release() local
265 spin_lock_irqsave(&sparx5->ptp_ts_id_lock, flags); in sparx5_ptp_txtstamp_release()
267 sparx5->ptp_skbs--; in sparx5_ptp_txtstamp_release()
269 spin_unlock_irqrestore(&sparx5->ptp_ts_id_lock, flags); in sparx5_ptp_txtstamp_release()
272 static void sparx5_get_hwtimestamp(struct sparx5 *sparx5, in sparx5_get_hwtimestamp() argument
280 spin_lock_irqsave(&sparx5->ptp_clock_lock, flags); in sparx5_get_hwtimestamp()
288 sparx5, PTP_PTP_PIN_CFG(TOD_ACC_PIN)); in sparx5_get_hwtimestamp()
290 ts->tv_sec = spx5_rd(sparx5, PTP_PTP_TOD_SEC_LSB(TOD_ACC_PIN)); in sparx5_get_hwtimestamp()
291 curr_nsec = spx5_rd(sparx5, PTP_PTP_TOD_NSEC(TOD_ACC_PIN)); in sparx5_get_hwtimestamp()
299 spin_unlock_irqrestore(&sparx5->ptp_clock_lock, flags); in sparx5_get_hwtimestamp()
305 struct sparx5 *sparx5 = args; in sparx5_ptp_irq_handler() local
316 val = spx5_rd(sparx5, REW_PTP_TWOSTEP_CTRL); in sparx5_ptp_irq_handler()
331 port = sparx5->ports[txport]; in sparx5_ptp_irq_handler()
334 delay = spx5_rd(sparx5, REW_PTP_TWOSTEP_STAMP); in sparx5_ptp_irq_handler()
342 sparx5, REW_PTP_TWOSTEP_CTRL); in sparx5_ptp_irq_handler()
344 val = spx5_rd(sparx5, REW_PTP_TWOSTEP_CTRL); in sparx5_ptp_irq_handler()
351 id = spx5_rd(sparx5, REW_PTP_TWOSTEP_STAMP); in sparx5_ptp_irq_handler()
353 id |= spx5_rd(sparx5, REW_PTP_TWOSTEP_STAMP_SUBNS); in sparx5_ptp_irq_handler()
369 sparx5, REW_PTP_TWOSTEP_CTRL); in sparx5_ptp_irq_handler()
374 spin_lock(&sparx5->ptp_ts_id_lock); in sparx5_ptp_irq_handler()
375 sparx5->ptp_skbs--; in sparx5_ptp_irq_handler()
376 spin_unlock(&sparx5->ptp_ts_id_lock); in sparx5_ptp_irq_handler()
379 sparx5_get_hwtimestamp(sparx5, &ts, delay); in sparx5_ptp_irq_handler()
394 struct sparx5 *sparx5 = phc->sparx5; in sparx5_ptp_adjfine() local
408 tod_inc = sparx5_ptp_get_nominal_value(sparx5); in sparx5_ptp_adjfine()
414 ref = sparx5_ptp_get_1ppm(sparx5) * (scaled_ppm >> 16); in sparx5_ptp_adjfine()
415 ref += (sparx5_ptp_get_1ppm(sparx5) * (0xffff & scaled_ppm)) >> 16; in sparx5_ptp_adjfine()
418 spin_lock_irqsave(&sparx5->ptp_clock_lock, flags); in sparx5_ptp_adjfine()
422 sparx5, PTP_PTP_DOM_CFG); in sparx5_ptp_adjfine()
424 spx5_wr((u32)tod_inc & 0xFFFFFFFF, sparx5, in sparx5_ptp_adjfine()
426 spx5_wr((u32)(tod_inc >> 32), sparx5, in sparx5_ptp_adjfine()
430 PTP_PTP_DOM_CFG_PTP_CLKCFG_DIS, sparx5, in sparx5_ptp_adjfine()
433 spin_unlock_irqrestore(&sparx5->ptp_clock_lock, flags); in sparx5_ptp_adjfine()
442 struct sparx5 *sparx5 = phc->sparx5; in sparx5_ptp_settime64() local
445 spin_lock_irqsave(&sparx5->ptp_clock_lock, flags); in sparx5_ptp_settime64()
454 sparx5, PTP_PTP_PIN_CFG(TOD_ACC_PIN)); in sparx5_ptp_settime64()
458 sparx5, PTP_PTP_TOD_SEC_MSB(TOD_ACC_PIN)); in sparx5_ptp_settime64()
460 sparx5, PTP_PTP_TOD_SEC_LSB(TOD_ACC_PIN)); in sparx5_ptp_settime64()
461 spx5_wr(ts->tv_nsec, sparx5, PTP_PTP_TOD_NSEC(TOD_ACC_PIN)); in sparx5_ptp_settime64()
470 sparx5, PTP_PTP_PIN_CFG(TOD_ACC_PIN)); in sparx5_ptp_settime64()
472 spin_unlock_irqrestore(&sparx5->ptp_clock_lock, flags); in sparx5_ptp_settime64()
480 struct sparx5 *sparx5 = phc->sparx5; in sparx5_ptp_gettime64() local
485 spin_lock_irqsave(&sparx5->ptp_clock_lock, flags); in sparx5_ptp_gettime64()
493 sparx5, PTP_PTP_PIN_CFG(TOD_ACC_PIN)); in sparx5_ptp_gettime64()
495 s = spx5_rd(sparx5, PTP_PTP_TOD_SEC_MSB(TOD_ACC_PIN)); in sparx5_ptp_gettime64()
497 s |= spx5_rd(sparx5, PTP_PTP_TOD_SEC_LSB(TOD_ACC_PIN)); in sparx5_ptp_gettime64()
498 ns = spx5_rd(sparx5, PTP_PTP_TOD_NSEC(TOD_ACC_PIN)); in sparx5_ptp_gettime64()
501 spin_unlock_irqrestore(&sparx5->ptp_clock_lock, flags); in sparx5_ptp_gettime64()
517 struct sparx5 *sparx5 = phc->sparx5; in sparx5_ptp_adjtime() local
522 spin_lock_irqsave(&sparx5->ptp_clock_lock, flags); in sparx5_ptp_adjtime()
531 sparx5, PTP_PTP_PIN_CFG(TOD_ACC_PIN)); in sparx5_ptp_adjtime()
534 sparx5, PTP_PTP_TOD_NSEC(TOD_ACC_PIN)); in sparx5_ptp_adjtime()
543 sparx5, PTP_PTP_PIN_CFG(TOD_ACC_PIN)); in sparx5_ptp_adjtime()
545 spin_unlock_irqrestore(&sparx5->ptp_clock_lock, flags); in sparx5_ptp_adjtime()
572 static int sparx5_ptp_phc_init(struct sparx5 *sparx5, in sparx5_ptp_phc_init() argument
576 struct sparx5_phc *phc = &sparx5->phc[index]; in sparx5_ptp_phc_init()
579 phc->clock = ptp_clock_register(&phc->info, sparx5->dev); in sparx5_ptp_phc_init()
584 phc->sparx5 = sparx5; in sparx5_ptp_phc_init()
592 int sparx5_ptp_init(struct sparx5 *sparx5) in sparx5_ptp_init() argument
594 u64 tod_adj = sparx5_ptp_get_nominal_value(sparx5); in sparx5_ptp_init()
598 if (!sparx5->ptp) in sparx5_ptp_init()
602 err = sparx5_ptp_phc_init(sparx5, i, &sparx5_ptp_clock_info); in sparx5_ptp_init()
607 spin_lock_init(&sparx5->ptp_clock_lock); in sparx5_ptp_init()
608 spin_lock_init(&sparx5->ptp_ts_id_lock); in sparx5_ptp_init()
609 mutex_init(&sparx5->ptp_lock); in sparx5_ptp_init()
612 spx5_wr(PTP_PTP_DOM_CFG_PTP_ENA_SET(0), sparx5, PTP_PTP_DOM_CFG); in sparx5_ptp_init()
617 sparx5, PTP_PTP_DOM_CFG); in sparx5_ptp_init()
620 spx5_wr((u32)tod_adj & 0xFFFFFFFF, sparx5, in sparx5_ptp_init()
622 spx5_wr((u32)(tod_adj >> 32), sparx5, in sparx5_ptp_init()
628 sparx5, PTP_PTP_DOM_CFG); in sparx5_ptp_init()
631 spx5_wr(PTP_PTP_DOM_CFG_PTP_ENA_SET(0x7), sparx5, PTP_PTP_DOM_CFG); in sparx5_ptp_init()
634 port = sparx5->ports[i]; in sparx5_ptp_init()
644 void sparx5_ptp_deinit(struct sparx5 *sparx5) in sparx5_ptp_deinit() argument
650 port = sparx5->ports[i]; in sparx5_ptp_deinit()
658 ptp_clock_unregister(sparx5->phc[i].clock); in sparx5_ptp_deinit()
661 void sparx5_ptp_rxtstamp(struct sparx5 *sparx5, struct sk_buff *skb, in sparx5_ptp_rxtstamp() argument
669 if (!sparx5->ptp) in sparx5_ptp_rxtstamp()
672 phc = &sparx5->phc[SPARX5_PHC_PORT]; in sparx5_ptp_rxtstamp()