• Home
  • Raw
  • Download

Lines Matching refs:ptp

49 	struct bnxt_ptp_cfg *ptp = container_of(ptp_info, struct bnxt_ptp_cfg,  in bnxt_ptp_settime()  local
53 spin_lock_bh(&ptp->ptp_lock); in bnxt_ptp_settime()
54 timecounter_init(&ptp->tc, &ptp->cc, ns); in bnxt_ptp_settime()
55 spin_unlock_bh(&ptp->ptp_lock); in bnxt_ptp_settime()
63 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_refclk_read() local
69 high_before = readl(bp->bar0 + ptp->refclk_mapped_regs[1]); in bnxt_refclk_read()
71 low = readl(bp->bar0 + ptp->refclk_mapped_regs[0]); in bnxt_refclk_read()
73 high_now = readl(bp->bar0 + ptp->refclk_mapped_regs[1]); in bnxt_refclk_read()
76 low = readl(bp->bar0 + ptp->refclk_mapped_regs[0]); in bnxt_refclk_read()
86 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_get_current_time() local
88 if (!ptp) in bnxt_ptp_get_current_time()
90 spin_lock_bh(&ptp->ptp_lock); in bnxt_ptp_get_current_time()
91 WRITE_ONCE(ptp->old_time, ptp->current_time); in bnxt_ptp_get_current_time()
92 bnxt_refclk_read(bp, NULL, &ptp->current_time); in bnxt_ptp_get_current_time()
93 spin_unlock_bh(&ptp->ptp_lock); in bnxt_ptp_get_current_time()
127 struct bnxt_ptp_cfg *ptp = container_of(ptp_info, struct bnxt_ptp_cfg, in bnxt_ptp_gettimex() local
132 spin_lock_bh(&ptp->ptp_lock); in bnxt_ptp_gettimex()
133 rc = bnxt_refclk_read(ptp->bp, sts, &cycles); in bnxt_ptp_gettimex()
135 spin_unlock_bh(&ptp->ptp_lock); in bnxt_ptp_gettimex()
138 ns = timecounter_cyc2time(&ptp->tc, cycles); in bnxt_ptp_gettimex()
139 spin_unlock_bh(&ptp->ptp_lock); in bnxt_ptp_gettimex()
147 struct bnxt_ptp_cfg *ptp = container_of(ptp_info, struct bnxt_ptp_cfg, in bnxt_ptp_adjtime() local
150 spin_lock_bh(&ptp->ptp_lock); in bnxt_ptp_adjtime()
151 timecounter_adjtime(&ptp->tc, delta); in bnxt_ptp_adjtime()
152 spin_unlock_bh(&ptp->ptp_lock); in bnxt_ptp_adjtime()
158 struct bnxt_ptp_cfg *ptp = container_of(ptp_info, struct bnxt_ptp_cfg, in bnxt_ptp_adjfreq() local
161 struct bnxt *bp = ptp->bp; in bnxt_ptp_adjfreq()
170 rc = hwrm_req_send(ptp->bp, req); in bnxt_ptp_adjfreq()
172 netdev_err(ptp->bp->dev, in bnxt_ptp_adjfreq()
179 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_pps_event() local
184 spin_lock_bh(&ptp->ptp_lock); in bnxt_ptp_pps_event()
185 ns = timecounter_cyc2time(&ptp->tc, pps_ts); in bnxt_ptp_pps_event()
186 spin_unlock_bh(&ptp->ptp_lock); in bnxt_ptp_pps_event()
207 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_cfg_pin() local
214 netdev_err(ptp->bp->dev, "1PPS: Invalid pin. Check pin-function configuration\n"); in bnxt_ptp_cfg_pin()
218 rc = hwrm_req_init(ptp->bp, req, HWRM_FUNC_PTP_PIN_CFG); in bnxt_ptp_cfg_pin()
232 rc = hwrm_req_send(ptp->bp, req); in bnxt_ptp_cfg_pin()
236 ptp->pps_info.pins[pin].usage = usage; in bnxt_ptp_cfg_pin()
237 ptp->pps_info.pins[pin].state = state; in bnxt_ptp_cfg_pin()
258 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_reapply_pps() local
263 if (!ptp || !(bp->fw_cap & BNXT_FW_CAP_PTP_PPS) || in bnxt_ptp_reapply_pps()
264 !(ptp->ptp_info.pin_config)) in bnxt_ptp_reapply_pps()
266 pps = &ptp->pps_info; in bnxt_ptp_reapply_pps()
280 static int bnxt_get_target_cycles(struct bnxt_ptp_cfg *ptp, u64 target_ns, in bnxt_get_target_cycles() argument
287 spin_lock_bh(&ptp->ptp_lock); in bnxt_get_target_cycles()
288 rc = bnxt_refclk_read(ptp->bp, NULL, &cycles_now); in bnxt_get_target_cycles()
290 spin_unlock_bh(&ptp->ptp_lock); in bnxt_get_target_cycles()
293 nsec_now = timecounter_cyc2time(&ptp->tc, cycles_now); in bnxt_get_target_cycles()
294 spin_unlock_bh(&ptp->ptp_lock); in bnxt_get_target_cycles()
297 *cycles_delta = div64_u64(nsec_delta << ptp->cc.shift, ptp->cc.mult); in bnxt_get_target_cycles()
301 static int bnxt_ptp_perout_cfg(struct bnxt_ptp_cfg *ptp, in bnxt_ptp_perout_cfg() argument
305 struct bnxt *bp = ptp->bp; in bnxt_ptp_perout_cfg()
315 rc = bnxt_get_target_cycles(ptp, target_ns, &delta); in bnxt_ptp_perout_cfg()
340 struct bnxt_ptp_cfg *ptp = container_of(ptp_info, struct bnxt_ptp_cfg, in bnxt_ptp_enable() local
342 struct bnxt *bp = ptp->bp; in bnxt_ptp_enable()
349 pin_id = ptp_find_pin(ptp->ptp_clock, PTP_PF_EXTTS, in bnxt_ptp_enable()
360 ptp->pps_info.pins[pin_id].event = BNXT_PPS_EVENT_EXTERNAL; in bnxt_ptp_enable()
364 pin_id = ptp_find_pin(ptp->ptp_clock, PTP_PF_PEROUT, in bnxt_ptp_enable()
373 rc = bnxt_ptp_perout_cfg(ptp, rq); in bnxt_ptp_enable()
383 ptp->pps_info.pins[0].event = BNXT_PPS_EVENT_INTERNAL; in bnxt_ptp_enable()
386 netdev_err(ptp->bp->dev, "Unrecognized PIN function\n"); in bnxt_ptp_enable()
395 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_hwrm_ptp_cfg() local
404 if (ptp->rx_filter) in bnxt_hwrm_ptp_cfg()
408 if (ptp->tx_tstamp_en) in bnxt_hwrm_ptp_cfg()
414 req->rx_ts_capture_ptp_msg_type = cpu_to_le16(ptp->rxctl); in bnxt_hwrm_ptp_cfg()
423 struct bnxt_ptp_cfg *ptp; in bnxt_hwtstamp_set() local
428 ptp = bp->ptp_cfg; in bnxt_hwtstamp_set()
429 if (!ptp) in bnxt_hwtstamp_set()
442 old_rx_filter = ptp->rx_filter; in bnxt_hwtstamp_set()
443 old_rxctl = ptp->rxctl; in bnxt_hwtstamp_set()
444 old_tx_tstamp_en = ptp->tx_tstamp_en; in bnxt_hwtstamp_set()
447 ptp->rxctl = 0; in bnxt_hwtstamp_set()
448 ptp->rx_filter = HWTSTAMP_FILTER_NONE; in bnxt_hwtstamp_set()
453 ptp->rxctl = BNXT_PTP_MSG_EVENTS; in bnxt_hwtstamp_set()
454 ptp->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; in bnxt_hwtstamp_set()
459 ptp->rxctl = BNXT_PTP_MSG_SYNC; in bnxt_hwtstamp_set()
460 ptp->rx_filter = HWTSTAMP_FILTER_PTP_V2_SYNC; in bnxt_hwtstamp_set()
465 ptp->rxctl = BNXT_PTP_MSG_DELAY_REQ; in bnxt_hwtstamp_set()
466 ptp->rx_filter = HWTSTAMP_FILTER_PTP_V2_DELAY_REQ; in bnxt_hwtstamp_set()
473 ptp->tx_tstamp_en = 1; in bnxt_hwtstamp_set()
475 ptp->tx_tstamp_en = 0; in bnxt_hwtstamp_set()
481 stmpconf.rx_filter = ptp->rx_filter; in bnxt_hwtstamp_set()
486 ptp->rx_filter = old_rx_filter; in bnxt_hwtstamp_set()
487 ptp->rxctl = old_rxctl; in bnxt_hwtstamp_set()
488 ptp->tx_tstamp_en = old_tx_tstamp_en; in bnxt_hwtstamp_set()
496 struct bnxt_ptp_cfg *ptp; in bnxt_hwtstamp_get() local
498 ptp = bp->ptp_cfg; in bnxt_hwtstamp_get()
499 if (!ptp) in bnxt_hwtstamp_get()
503 stmpconf.tx_type = ptp->tx_tstamp_en ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; in bnxt_hwtstamp_get()
505 stmpconf.rx_filter = ptp->rx_filter; in bnxt_hwtstamp_get()
527 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_map_ptp_regs() local
531 reg_arr = ptp->refclk_regs; in bnxt_map_ptp_regs()
537 ptp->refclk_mapped_regs[i] = BNXT_PTP_GRC_WIN_BASE + in bnxt_map_ptp_regs()
538 (ptp->refclk_regs[i] & BNXT_GRC_OFFSET_MASK); in bnxt_map_ptp_regs()
552 struct bnxt_ptp_cfg *ptp = container_of(cc, struct bnxt_ptp_cfg, cc); in bnxt_cc_read() local
555 bnxt_refclk_read(ptp->bp, NULL, &ns); in bnxt_cc_read()
561 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_stamp_tx_skb() local
569 spin_lock_bh(&ptp->ptp_lock); in bnxt_stamp_tx_skb()
570 ns = timecounter_cyc2time(&ptp->tc, ts); in bnxt_stamp_tx_skb()
571 spin_unlock_bh(&ptp->ptp_lock); in bnxt_stamp_tx_skb()
573 skb_tstamp_tx(ptp->tx_skb, &timestamp); in bnxt_stamp_tx_skb()
579 dev_kfree_skb_any(ptp->tx_skb); in bnxt_stamp_tx_skb()
580 ptp->tx_skb = NULL; in bnxt_stamp_tx_skb()
581 atomic_inc(&ptp->tx_avail); in bnxt_stamp_tx_skb()
586 struct bnxt_ptp_cfg *ptp = container_of(ptp_info, struct bnxt_ptp_cfg, in bnxt_ptp_ts_aux_work() local
589 struct bnxt *bp = ptp->bp; in bnxt_ptp_ts_aux_work()
591 if (ptp->tx_skb) in bnxt_ptp_ts_aux_work()
592 bnxt_stamp_tx_skb(bp, ptp->tx_skb); in bnxt_ptp_ts_aux_work()
594 if (!time_after_eq(now, ptp->next_period)) in bnxt_ptp_ts_aux_work()
595 return ptp->next_period - now; in bnxt_ptp_ts_aux_work()
598 ptp->next_period = now + HZ; in bnxt_ptp_ts_aux_work()
599 if (time_after_eq(now, ptp->next_overflow_check)) { in bnxt_ptp_ts_aux_work()
600 spin_lock_bh(&ptp->ptp_lock); in bnxt_ptp_ts_aux_work()
601 timecounter_read(&ptp->tc); in bnxt_ptp_ts_aux_work()
602 spin_unlock_bh(&ptp->ptp_lock); in bnxt_ptp_ts_aux_work()
603 ptp->next_overflow_check = now + BNXT_PHC_OVERFLOW_PERIOD; in bnxt_ptp_ts_aux_work()
610 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_get_tx_ts_p5() local
612 if (ptp->tx_skb) { in bnxt_get_tx_ts_p5()
616 ptp->tx_skb = skb; in bnxt_get_tx_ts_p5()
617 ptp_schedule_worker(ptp->ptp_clock, 0); in bnxt_get_tx_ts_p5()
623 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_get_rx_ts_p5() local
626 if (!ptp) in bnxt_get_rx_ts_p5()
629 BNXT_READ_TIME64(ptp, time, ptp->old_time); in bnxt_get_rx_ts_p5()
657 struct bnxt_ptp_cfg *ptp = container_of(ptp_info, struct bnxt_ptp_cfg, in bnxt_ptp_verify() local
660 if (ptp->pps_info.pins[pin].usage <= BNXT_PPS_PIN_PPS_OUT && in bnxt_ptp_verify()
671 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_pps_init() local
689 ptp_info = &ptp->ptp_info; in bnxt_ptp_pps_init()
690 pps_info = &ptp->pps_info; in bnxt_ptp_pps_init()
730 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_pps_config_ok() local
732 return !(bp->fw_cap & BNXT_FW_CAP_PTP_PPS) == !ptp->ptp_info.pin_config; in bnxt_pps_config_ok()
737 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_init() local
740 if (!ptp) in bnxt_ptp_init()
747 if (ptp->ptp_clock && bnxt_pps_config_ok(bp)) in bnxt_ptp_init()
750 if (ptp->ptp_clock) { in bnxt_ptp_init()
751 ptp_clock_unregister(ptp->ptp_clock); in bnxt_ptp_init()
752 ptp->ptp_clock = NULL; in bnxt_ptp_init()
753 kfree(ptp->ptp_info.pin_config); in bnxt_ptp_init()
754 ptp->ptp_info.pin_config = NULL; in bnxt_ptp_init()
756 atomic_set(&ptp->tx_avail, BNXT_MAX_TX_TS); in bnxt_ptp_init()
757 spin_lock_init(&ptp->ptp_lock); in bnxt_ptp_init()
759 memset(&ptp->cc, 0, sizeof(ptp->cc)); in bnxt_ptp_init()
760 ptp->cc.read = bnxt_cc_read; in bnxt_ptp_init()
761 ptp->cc.mask = CYCLECOUNTER_MASK(48); in bnxt_ptp_init()
762 ptp->cc.shift = 0; in bnxt_ptp_init()
763 ptp->cc.mult = 1; in bnxt_ptp_init()
765 ptp->next_overflow_check = jiffies + BNXT_PHC_OVERFLOW_PERIOD; in bnxt_ptp_init()
766 timecounter_init(&ptp->tc, &ptp->cc, ktime_to_ns(ktime_get_real())); in bnxt_ptp_init()
768 ptp->ptp_info = bnxt_ptp_caps; in bnxt_ptp_init()
773 ptp->ptp_clock = ptp_clock_register(&ptp->ptp_info, &bp->pdev->dev); in bnxt_ptp_init()
774 if (IS_ERR(ptp->ptp_clock)) { in bnxt_ptp_init()
775 int err = PTR_ERR(ptp->ptp_clock); in bnxt_ptp_init()
777 ptp->ptp_clock = NULL; in bnxt_ptp_init()
782 spin_lock_bh(&ptp->ptp_lock); in bnxt_ptp_init()
783 bnxt_refclk_read(bp, NULL, &ptp->current_time); in bnxt_ptp_init()
784 WRITE_ONCE(ptp->old_time, ptp->current_time); in bnxt_ptp_init()
785 spin_unlock_bh(&ptp->ptp_lock); in bnxt_ptp_init()
786 ptp_schedule_worker(ptp->ptp_clock, 0); in bnxt_ptp_init()
793 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_clear() local
795 if (!ptp) in bnxt_ptp_clear()
798 if (ptp->ptp_clock) in bnxt_ptp_clear()
799 ptp_clock_unregister(ptp->ptp_clock); in bnxt_ptp_clear()
801 ptp->ptp_clock = NULL; in bnxt_ptp_clear()
802 kfree(ptp->ptp_info.pin_config); in bnxt_ptp_clear()
803 ptp->ptp_info.pin_config = NULL; in bnxt_ptp_clear()
805 if (ptp->tx_skb) { in bnxt_ptp_clear()
806 dev_kfree_skb_any(ptp->tx_skb); in bnxt_ptp_clear()
807 ptp->tx_skb = NULL; in bnxt_ptp_clear()