Lines Matching full:lan966x
57 struct lan966x *lan966x = port->lan966x; in lan966x_ptp_add_trap() local
61 vrule = vcap_get_rule(lan966x->vcap_ctrl, rule_id); in lan966x_ptp_add_trap()
76 vrule = vcap_alloc_rule(lan966x->vcap_ctrl, port->dev, in lan966x_ptp_add_trap()
103 struct lan966x *lan966x = port->lan966x; in lan966x_ptp_del_trap() local
108 vrule = vcap_get_rule(lan966x->vcap_ctrl, rule_id); in lan966x_ptp_del_trap()
116 if (mask == GENMASK(lan966x->num_phys_ports, 0)) { in lan966x_ptp_del_trap()
117 err = vcap_del_rule(lan966x->vcap_ctrl, port->dev, rule_id); in lan966x_ptp_del_trap()
264 struct lan966x *lan966x = port->lan966x; in lan966x_ptp_hwtstamp_set() local
307 mutex_lock(&lan966x->ptp_lock); in lan966x_ptp_hwtstamp_set()
308 phc = &lan966x->phc[LAN966X_PHC_PORT]; in lan966x_ptp_hwtstamp_set()
310 mutex_unlock(&lan966x->ptp_lock); in lan966x_ptp_hwtstamp_set()
318 struct lan966x *lan966x = port->lan966x; in lan966x_ptp_hwtstamp_get() local
321 phc = &lan966x->phc[LAN966X_PHC_PORT]; in lan966x_ptp_hwtstamp_get()
375 struct lan966x *lan966x = port->lan966x; in lan966x_ptp_txtstamp_request() local
387 spin_lock_irqsave(&lan966x->ptp_ts_id_lock, flags); in lan966x_ptp_txtstamp_request()
388 if (lan966x->ptp_skbs == LAN966X_MAX_PTP_ID) { in lan966x_ptp_txtstamp_request()
389 spin_unlock_irqrestore(&lan966x->ptp_ts_id_lock, flags); in lan966x_ptp_txtstamp_request()
399 lan966x->ptp_skbs++; in lan966x_ptp_txtstamp_request()
404 spin_unlock_irqrestore(&lan966x->ptp_ts_id_lock, flags); in lan966x_ptp_txtstamp_request()
412 struct lan966x *lan966x = port->lan966x; in lan966x_ptp_txtstamp_release() local
415 spin_lock_irqsave(&lan966x->ptp_ts_id_lock, flags); in lan966x_ptp_txtstamp_release()
417 lan966x->ptp_skbs--; in lan966x_ptp_txtstamp_release()
419 spin_unlock_irqrestore(&lan966x->ptp_ts_id_lock, flags); in lan966x_ptp_txtstamp_release()
422 static void lan966x_get_hwtimestamp(struct lan966x *lan966x, in lan966x_get_hwtimestamp() argument
430 spin_lock_irqsave(&lan966x->ptp_clock_lock, flags); in lan966x_get_hwtimestamp()
438 lan966x, PTP_PIN_CFG(TOD_ACC_PIN)); in lan966x_get_hwtimestamp()
440 ts->tv_sec = lan_rd(lan966x, PTP_TOD_SEC_LSB(TOD_ACC_PIN)); in lan966x_get_hwtimestamp()
441 curr_nsec = lan_rd(lan966x, PTP_TOD_NSEC(TOD_ACC_PIN)); in lan966x_get_hwtimestamp()
449 spin_unlock_irqrestore(&lan966x->ptp_clock_lock, flags); in lan966x_get_hwtimestamp()
455 struct lan966x *lan966x = args; in lan966x_ptp_irq_handler() local
466 val = lan_rd(lan966x, PTP_TWOSTEP_CTRL); in lan966x_ptp_irq_handler()
481 port = lan966x->ports[txport]; in lan966x_ptp_irq_handler()
484 delay = lan_rd(lan966x, PTP_TWOSTEP_STAMP); in lan966x_ptp_irq_handler()
492 lan966x, PTP_TWOSTEP_CTRL); in lan966x_ptp_irq_handler()
494 val = lan_rd(lan966x, PTP_TWOSTEP_CTRL); in lan966x_ptp_irq_handler()
501 id = lan_rd(lan966x, PTP_TWOSTEP_STAMP); in lan966x_ptp_irq_handler()
517 lan966x, PTP_TWOSTEP_CTRL); in lan966x_ptp_irq_handler()
522 spin_lock_irqsave(&lan966x->ptp_ts_id_lock, flags); in lan966x_ptp_irq_handler()
523 lan966x->ptp_skbs--; in lan966x_ptp_irq_handler()
524 spin_unlock_irqrestore(&lan966x->ptp_ts_id_lock, flags); in lan966x_ptp_irq_handler()
527 lan966x_get_hwtimestamp(lan966x, &ts, delay); in lan966x_ptp_irq_handler()
541 struct lan966x *lan966x = args; in lan966x_ptp_ext_irq_handler() local
549 if (!(lan_rd(lan966x, PTP_PIN_INTR))) in lan966x_ptp_ext_irq_handler()
556 phc = &lan966x->phc[i]; in lan966x_ptp_ext_irq_handler()
561 if (!(lan_rd(lan966x, PTP_PIN_INTR) & BIT(pin))) in lan966x_ptp_ext_irq_handler()
564 spin_lock_irqsave(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_ext_irq_handler()
569 lan_wr(BIT(pin), lan966x, PTP_PIN_INTR); in lan966x_ptp_ext_irq_handler()
572 s = lan_rd(lan966x, PTP_TOD_SEC_MSB(pin)); in lan966x_ptp_ext_irq_handler()
574 s |= lan_rd(lan966x, PTP_TOD_SEC_LSB(pin)); in lan966x_ptp_ext_irq_handler()
575 ns = lan_rd(lan966x, PTP_TOD_NSEC(pin)); in lan966x_ptp_ext_irq_handler()
578 spin_unlock_irqrestore(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_ext_irq_handler()
599 struct lan966x *lan966x = phc->lan966x; in lan966x_ptp_adjfine() local
623 spin_lock_irqsave(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_adjfine()
627 lan966x, PTP_DOM_CFG); in lan966x_ptp_adjfine()
629 lan_wr((u32)tod_inc & 0xFFFFFFFF, lan966x, in lan966x_ptp_adjfine()
631 lan_wr((u32)(tod_inc >> 32), lan966x, in lan966x_ptp_adjfine()
636 lan966x, PTP_DOM_CFG); in lan966x_ptp_adjfine()
638 spin_unlock_irqrestore(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_adjfine()
647 struct lan966x *lan966x = phc->lan966x; in lan966x_ptp_settime64() local
650 spin_lock_irqsave(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_settime64()
659 lan966x, PTP_PIN_CFG(TOD_ACC_PIN)); in lan966x_ptp_settime64()
663 lan966x, PTP_TOD_SEC_MSB(TOD_ACC_PIN)); in lan966x_ptp_settime64()
665 lan966x, PTP_TOD_SEC_LSB(TOD_ACC_PIN)); in lan966x_ptp_settime64()
666 lan_wr(ts->tv_nsec, lan966x, PTP_TOD_NSEC(TOD_ACC_PIN)); in lan966x_ptp_settime64()
675 lan966x, PTP_PIN_CFG(TOD_ACC_PIN)); in lan966x_ptp_settime64()
677 spin_unlock_irqrestore(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_settime64()
685 struct lan966x *lan966x = phc->lan966x; in lan966x_ptp_gettime64() local
690 spin_lock_irqsave(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_gettime64()
698 lan966x, PTP_PIN_CFG(TOD_ACC_PIN)); in lan966x_ptp_gettime64()
700 s = lan_rd(lan966x, PTP_TOD_SEC_MSB(TOD_ACC_PIN)); in lan966x_ptp_gettime64()
702 s |= lan_rd(lan966x, PTP_TOD_SEC_LSB(TOD_ACC_PIN)); in lan966x_ptp_gettime64()
703 ns = lan_rd(lan966x, PTP_TOD_NSEC(TOD_ACC_PIN)); in lan966x_ptp_gettime64()
706 spin_unlock_irqrestore(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_gettime64()
722 struct lan966x *lan966x = phc->lan966x; in lan966x_ptp_adjtime() local
727 spin_lock_irqsave(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_adjtime()
736 lan966x, PTP_PIN_CFG(TOD_ACC_PIN)); in lan966x_ptp_adjtime()
739 lan966x, PTP_TOD_NSEC(TOD_ACC_PIN)); in lan966x_ptp_adjtime()
748 lan966x, PTP_PIN_CFG(TOD_ACC_PIN)); in lan966x_ptp_adjtime()
750 spin_unlock_irqrestore(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_adjtime()
771 struct lan966x *lan966x = phc->lan966x; in lan966x_ptp_verify() local
793 info = &lan966x->phc[i].info; in lan966x_ptp_verify()
811 struct lan966x *lan966x = phc->lan966x; in lan966x_ptp_perout() local
827 spin_lock_irqsave(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_perout()
834 lan966x, PTP_PIN_CFG(pin)); in lan966x_ptp_perout()
835 spin_unlock_irqrestore(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_perout()
852 dev_warn(lan966x->dev, in lan966x_ptp_perout()
869 spin_lock_irqsave(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_perout()
871 lan966x, PTP_WF_LOW_PERIOD(pin)); in lan966x_ptp_perout()
873 lan966x, PTP_WF_HIGH_PERIOD(pin)); in lan966x_ptp_perout()
880 lan966x, PTP_PIN_CFG(pin)); in lan966x_ptp_perout()
881 spin_unlock_irqrestore(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_perout()
891 spin_lock_irqsave(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_perout()
893 lan966x, PTP_WF_LOW_PERIOD(pin)); in lan966x_ptp_perout()
895 lan966x, PTP_WF_HIGH_PERIOD(pin)); in lan966x_ptp_perout()
902 lan966x, PTP_PIN_CFG(pin)); in lan966x_ptp_perout()
903 spin_unlock_irqrestore(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_perout()
912 struct lan966x *lan966x = phc->lan966x; in lan966x_ptp_extts() local
917 if (lan966x->ptp_ext_irq <= 0) in lan966x_ptp_extts()
930 spin_lock_irqsave(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_extts()
939 lan966x, PTP_PIN_CFG(pin)); in lan966x_ptp_extts()
941 val = lan_rd(lan966x, PTP_PIN_INTR_ENA); in lan966x_ptp_extts()
946 lan_wr(val, lan966x, PTP_PIN_INTR_ENA); in lan966x_ptp_extts()
948 spin_unlock_irqrestore(&lan966x->ptp_clock_lock, flags); in lan966x_ptp_extts()
970 .name = "lan966x ptp",
983 static int lan966x_ptp_phc_init(struct lan966x *lan966x, in lan966x_ptp_phc_init() argument
987 struct lan966x_phc *phc = &lan966x->phc[index]; in lan966x_ptp_phc_init()
1001 phc->clock = ptp_clock_register(&phc->info, lan966x->dev); in lan966x_ptp_phc_init()
1006 phc->lan966x = lan966x; in lan966x_ptp_phc_init()
1011 int lan966x_ptp_init(struct lan966x *lan966x) in lan966x_ptp_init() argument
1017 if (!lan966x->ptp) in lan966x_ptp_init()
1021 err = lan966x_ptp_phc_init(lan966x, i, &lan966x_ptp_clock_info); in lan966x_ptp_init()
1026 spin_lock_init(&lan966x->ptp_clock_lock); in lan966x_ptp_init()
1027 spin_lock_init(&lan966x->ptp_ts_id_lock); in lan966x_ptp_init()
1028 mutex_init(&lan966x->ptp_lock); in lan966x_ptp_init()
1031 lan_wr(PTP_DOM_CFG_ENA_SET(0), lan966x, PTP_DOM_CFG); in lan966x_ptp_init()
1036 lan966x, PTP_DOM_CFG); in lan966x_ptp_init()
1039 lan_wr((u32)tod_adj & 0xFFFFFFFF, lan966x, in lan966x_ptp_init()
1041 lan_wr((u32)(tod_adj >> 32), lan966x, in lan966x_ptp_init()
1047 lan966x, PTP_DOM_CFG); in lan966x_ptp_init()
1050 lan_wr(PTP_DOM_CFG_ENA_SET(0x7), lan966x, PTP_DOM_CFG); in lan966x_ptp_init()
1052 for (i = 0; i < lan966x->num_phys_ports; i++) { in lan966x_ptp_init()
1053 port = lan966x->ports[i]; in lan966x_ptp_init()
1063 void lan966x_ptp_deinit(struct lan966x *lan966x) in lan966x_ptp_deinit() argument
1068 if (!lan966x->ptp) in lan966x_ptp_deinit()
1071 for (i = 0; i < lan966x->num_phys_ports; i++) { in lan966x_ptp_deinit()
1072 port = lan966x->ports[i]; in lan966x_ptp_deinit()
1080 ptp_clock_unregister(lan966x->phc[i].clock); in lan966x_ptp_deinit()
1083 void lan966x_ptp_rxtstamp(struct lan966x *lan966x, struct sk_buff *skb, in lan966x_ptp_rxtstamp() argument
1091 if (!lan966x->ptp || in lan966x_ptp_rxtstamp()
1092 !lan966x->ports[src_port]->ptp_rx_cmd) in lan966x_ptp_rxtstamp()
1095 phc = &lan966x->phc[LAN966X_PHC_PORT]; in lan966x_ptp_rxtstamp()