Lines Matching +full:direction +full:- +full:duty +full:- +full:cycle +full:- +full:ns
1 // SPDX-License-Identifier: GPL-2.0
24 /* Sub-nanoseconds-adj,max * sub-nanoseconds / 40ns * 1ns
25 * = (2^30-1) * (2 ^ 32) / 40 ns * 1 ns = 6249999
30 #define KSZ_PTP_INC_NS 40ULL /* HW clock is incremented every 40 ns (by 40) */
75 /* Clear reset and set GPIO direction */ in ksz_ptp_tou_reset()
85 return -EINVAL; in ksz_ptp_tou_pulse_verify()
89 return -ERANGE; in ksz_ptp_tou_pulse_verify()
100 if ((ts->tv_sec & 0xffffffff) != ts->tv_sec) in ksz_ptp_tou_target_time_set()
101 return -EINVAL; in ksz_ptp_tou_target_time_set()
103 ret = ksz_write32(dev, REG_TRIG_TARGET_NANOSEC, ts->tv_nsec); in ksz_ptp_tou_target_time_set()
107 ret = ksz_write32(dev, REG_TRIG_TARGET_SEC, ts->tv_sec); in ksz_ptp_tou_target_time_set()
124 * - the ACTIVE flag is NOT cleared an error! in ksz_ptp_tou_start()
131 dev_err(dev->dev, "%s: Trigger unit%d error!\n", __func__, in ksz_ptp_tou_start()
133 ret = -EIO; in ksz_ptp_tou_start()
160 /* Set cycle count 0 - Infinite */ in ksz_ptp_configure_perout()
181 struct ksz_ptp_data *ptp_data = &dev->ptp_data; in ksz_ptp_enable_perout()
189 if (request->flags & ~PTP_PEROUT_DUTY_CYCLE) in ksz_ptp_enable_perout()
190 return -EOPNOTSUPP; in ksz_ptp_enable_perout()
192 if (ptp_data->tou_mode != KSZ_PTP_TOU_PEROUT && in ksz_ptp_enable_perout()
193 ptp_data->tou_mode != KSZ_PTP_TOU_IDLE) in ksz_ptp_enable_perout()
194 return -EBUSY; in ksz_ptp_enable_perout()
196 pin = ptp_find_pin(ptp_data->clock, PTP_PF_PEROUT, request->index); in ksz_ptp_enable_perout()
198 return -EINVAL; in ksz_ptp_enable_perout()
201 FIELD_PREP(PTP_TOU_INDEX, request->index); in ksz_ptp_enable_perout()
207 ret = ksz_ptp_tou_reset(dev, request->index); in ksz_ptp_enable_perout()
212 ptp_data->tou_mode = KSZ_PTP_TOU_IDLE; in ksz_ptp_enable_perout()
216 ptp_data->perout_target_time_first.tv_sec = request->start.sec; in ksz_ptp_enable_perout()
217 ptp_data->perout_target_time_first.tv_nsec = request->start.nsec; in ksz_ptp_enable_perout()
219 ptp_data->perout_period.tv_sec = request->period.sec; in ksz_ptp_enable_perout()
220 ptp_data->perout_period.tv_nsec = request->period.nsec; in ksz_ptp_enable_perout()
222 cycle_width_ns = timespec64_to_ns(&ptp_data->perout_period); in ksz_ptp_enable_perout()
224 return -EINVAL; in ksz_ptp_enable_perout()
226 if (request->flags & PTP_PEROUT_DUTY_CYCLE) { in ksz_ptp_enable_perout()
227 pulse_width_ns = request->on.sec * NSEC_PER_SEC + in ksz_ptp_enable_perout()
228 request->on.nsec; in ksz_ptp_enable_perout()
230 /* Use a duty cycle of 50%. Maximum pulse width supported by the in ksz_ptp_enable_perout()
233 req_pulse_width_ns = (request->period.sec * NSEC_PER_SEC + in ksz_ptp_enable_perout()
234 request->period.nsec) / 2; in ksz_ptp_enable_perout()
244 &ptp_data->perout_target_time_first, in ksz_ptp_enable_perout()
253 ret = ksz_ptp_tou_start(dev, request->index); in ksz_ptp_enable_perout()
257 ptp_data->tou_mode = KSZ_PTP_TOU_PEROUT; in ksz_ptp_enable_perout()
264 struct ksz_tagger_data *tagger_data = ksz_tagger_data(dev->ds); in ksz_ptp_enable_mode()
265 struct ksz_ptp_data *ptp_data = &dev->ptp_data; in ksz_ptp_enable_mode()
270 dsa_switch_for_each_user_port(dp, dev->ds) { in ksz_ptp_enable_mode()
271 prt = &dev->ports[dp->index]; in ksz_ptp_enable_mode()
272 if (prt->hwts_tx_en || prt->hwts_rx_en) { in ksz_ptp_enable_mode()
279 ptp_schedule_worker(ptp_data->clock, 0); in ksz_ptp_enable_mode()
281 ptp_cancel_worker_sync(ptp_data->clock); in ksz_ptp_enable_mode()
284 tagger_data->hwtstamp_set_state(dev->ds, tag_en); in ksz_ptp_enable_mode()
291 * requested through ethtool -T <interface> utility
295 struct ksz_device *dev = ds->priv; in ksz_get_ts_info()
298 ptp_data = &dev->ptp_data; in ksz_get_ts_info()
300 if (!ptp_data->clock) in ksz_get_ts_info()
301 return -ENODEV; in ksz_get_ts_info()
303 ts->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | in ksz_get_ts_info()
307 ts->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ONESTEP_P2P); in ksz_get_ts_info()
310 ts->tx_types |= BIT(HWTSTAMP_TX_ON); in ksz_get_ts_info()
312 ts->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | in ksz_get_ts_info()
317 ts->phc_index = ptp_clock_index(ptp_data->clock); in ksz_get_ts_info()
324 struct ksz_device *dev = ds->priv; in ksz_hwtstamp_get()
328 prt = &dev->ports[port]; in ksz_hwtstamp_get()
329 config = &prt->tstamp_config; in ksz_hwtstamp_get()
331 return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ? in ksz_hwtstamp_get()
332 -EFAULT : 0; in ksz_hwtstamp_get()
341 if (config->flags) in ksz_set_hwtstamp_config()
342 return -EINVAL; in ksz_set_hwtstamp_config()
344 switch (config->tx_type) { in ksz_set_hwtstamp_config()
346 prt->ptpmsg_irq[KSZ_SYNC_MSG].ts_en = false; in ksz_set_hwtstamp_config()
347 prt->ptpmsg_irq[KSZ_XDREQ_MSG].ts_en = false; in ksz_set_hwtstamp_config()
348 prt->ptpmsg_irq[KSZ_PDRES_MSG].ts_en = false; in ksz_set_hwtstamp_config()
349 prt->hwts_tx_en = false; in ksz_set_hwtstamp_config()
352 prt->ptpmsg_irq[KSZ_SYNC_MSG].ts_en = false; in ksz_set_hwtstamp_config()
353 prt->ptpmsg_irq[KSZ_XDREQ_MSG].ts_en = true; in ksz_set_hwtstamp_config()
354 prt->ptpmsg_irq[KSZ_PDRES_MSG].ts_en = false; in ksz_set_hwtstamp_config()
355 prt->hwts_tx_en = true; in ksz_set_hwtstamp_config()
364 return -ERANGE; in ksz_set_hwtstamp_config()
366 prt->ptpmsg_irq[KSZ_SYNC_MSG].ts_en = true; in ksz_set_hwtstamp_config()
367 prt->ptpmsg_irq[KSZ_XDREQ_MSG].ts_en = true; in ksz_set_hwtstamp_config()
368 prt->ptpmsg_irq[KSZ_PDRES_MSG].ts_en = true; in ksz_set_hwtstamp_config()
369 prt->hwts_tx_en = true; in ksz_set_hwtstamp_config()
377 return -ERANGE; in ksz_set_hwtstamp_config()
380 switch (config->rx_filter) { in ksz_set_hwtstamp_config()
382 prt->hwts_rx_en = false; in ksz_set_hwtstamp_config()
386 config->rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT; in ksz_set_hwtstamp_config()
387 prt->hwts_rx_en = true; in ksz_set_hwtstamp_config()
391 config->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; in ksz_set_hwtstamp_config()
392 prt->hwts_rx_en = true; in ksz_set_hwtstamp_config()
396 config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; in ksz_set_hwtstamp_config()
397 prt->hwts_rx_en = true; in ksz_set_hwtstamp_config()
400 config->rx_filter = HWTSTAMP_FILTER_NONE; in ksz_set_hwtstamp_config()
401 return -ERANGE; in ksz_set_hwtstamp_config()
409 struct ksz_device *dev = ds->priv; in ksz_hwtstamp_set()
414 prt = &dev->ports[port]; in ksz_hwtstamp_set()
416 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) in ksz_hwtstamp_set()
417 return -EFAULT; in ksz_hwtstamp_set()
423 memcpy(&prt->tstamp_config, &config, sizeof(config)); in ksz_hwtstamp_set()
425 if (copy_to_user(ifr->ifr_data, &config, sizeof(config))) in ksz_hwtstamp_set()
426 return -EFAULT; in ksz_hwtstamp_set()
438 ptp_data = &dev->ptp_data; in ksz_tstamp_reconstruct()
441 spin_lock_bh(&ptp_data->clock_lock); in ksz_tstamp_reconstruct()
442 ptp_clock_time = ptp_data->clock_time; in ksz_tstamp_reconstruct()
443 spin_unlock_bh(&ptp_data->clock_lock); in ksz_tstamp_reconstruct()
451 ts.tv_sec -= 4; in ksz_tstamp_reconstruct()
452 else if (diff.tv_sec < -2) in ksz_tstamp_reconstruct()
462 struct ksz_device *dev = ds->priv; in ksz_port_rxtstamp()
469 prt = &dev->ports[port]; in ksz_port_rxtstamp()
471 tstamp = KSZ_SKB_CB(skb)->tstamp; in ksz_port_rxtstamp()
473 hwtstamps->hwtstamp = ksz_tstamp_reconstruct(dev, tstamp); in ksz_port_rxtstamp()
475 if (prt->tstamp_config.tx_type != HWTSTAMP_TX_ONESTEP_P2P) in ksz_port_rxtstamp()
491 correction = (s64)get_unaligned_be64(&ptp_hdr->correction); in ksz_port_rxtstamp()
492 correction -= ktime_to_ns(tstamp) << 16; in ksz_port_rxtstamp()
502 struct ksz_device *dev = ds->priv; in ksz_port_txtstamp()
509 prt = &dev->ports[port]; in ksz_port_txtstamp()
511 if (!prt->hwts_tx_en) in ksz_port_txtstamp()
526 if (prt->tstamp_config.tx_type == HWTSTAMP_TX_ONESTEP_P2P) in ksz_port_txtstamp()
532 if (prt->tstamp_config.tx_type == HWTSTAMP_TX_ONESTEP_P2P) { in ksz_port_txtstamp()
533 KSZ_SKB_CB(skb)->ptp_type = type; in ksz_port_txtstamp()
534 KSZ_SKB_CB(skb)->update_correction = true; in ksz_port_txtstamp()
548 KSZ_SKB_CB(skb)->clone = clone; in ksz_port_txtstamp()
560 ret = wait_for_completion_timeout(&prt->tstamp_msg_comp, in ksz_ptp_txtstamp_skb()
565 hwtstamps.hwtstamp = prt->tstamp_msg; in ksz_ptp_txtstamp_skb()
572 struct sk_buff *clone, *skb = xmit_work->skb; in ksz_port_deferred_xmit()
573 struct dsa_switch *ds = xmit_work->dp->ds; in ksz_port_deferred_xmit()
574 struct ksz_device *dev = ds->priv; in ksz_port_deferred_xmit()
577 prt = &dev->ports[xmit_work->dp->index]; in ksz_port_deferred_xmit()
579 clone = KSZ_SKB_CB(skb)->clone; in ksz_port_deferred_xmit()
581 skb_shinfo(clone)->tx_flags |= SKBTX_IN_PROGRESS; in ksz_port_deferred_xmit()
583 reinit_completion(&prt->tstamp_msg_comp); in ksz_port_deferred_xmit()
585 dsa_enqueue_skb(skb, skb->dev); in ksz_port_deferred_xmit()
616 ts->tv_sec = seconds; in _ksz_ptp_gettime()
617 ts->tv_nsec = nanoseconds + phase * 8; in _ksz_ptp_gettime()
628 mutex_lock(&ptp_data->lock); in ksz_ptp_gettime()
630 mutex_unlock(&ptp_data->lock); in ksz_ptp_gettime()
637 struct ksz_ptp_data *ptp_data = &dev->ptp_data; in ksz_ptp_restart_perout()
645 dev_info(dev->dev, "Restarting periodic output signal\n"); in ksz_ptp_restart_perout()
652 first_ns = timespec64_to_ns(&ptp_data->perout_target_time_first); in ksz_ptp_restart_perout()
655 period_ns = timespec64_to_ns(&ptp_data->perout_period); in ksz_ptp_restart_perout()
658 count = div_u64(now_ns - first_ns, period_ns); in ksz_ptp_restart_perout()
672 request.period.sec = ptp_data->perout_period.tv_sec; in ksz_ptp_restart_perout()
673 request.period.nsec = ptp_data->perout_period.tv_nsec; in ksz_ptp_restart_perout()
687 mutex_lock(&ptp_data->lock); in ksz_ptp_settime()
694 ret = ksz_write32(dev, REG_PTP_RTC_NANOSEC, ts->tv_nsec); in ksz_ptp_settime()
698 ret = ksz_write32(dev, REG_PTP_RTC_SEC, ts->tv_sec); in ksz_ptp_settime()
706 switch (ptp_data->tou_mode) { in ksz_ptp_settime()
718 spin_lock_bh(&ptp_data->clock_lock); in ksz_ptp_settime()
719 ptp_data->clock_time = *ts; in ksz_ptp_settime()
720 spin_unlock_bh(&ptp_data->clock_lock); in ksz_ptp_settime()
723 mutex_unlock(&ptp_data->lock); in ksz_ptp_settime()
737 mutex_lock(&ptp_data->lock); in ksz_ptp_adjfine()
763 mutex_unlock(&ptp_data->lock); in ksz_ptp_adjfine()
776 mutex_lock(&ptp_data->lock); in ksz_ptp_adjtime()
797 /* PTP_STEP_DIR -- 0: subtract, 1: add */ in ksz_ptp_adjtime()
807 switch (ptp_data->tou_mode) { in ksz_ptp_adjtime()
819 spin_lock_bh(&ptp_data->clock_lock); in ksz_ptp_adjtime()
820 ptp_data->clock_time = timespec64_add(ptp_data->clock_time, delta64); in ksz_ptp_adjtime()
821 spin_unlock_bh(&ptp_data->clock_lock); in ksz_ptp_adjtime()
824 mutex_unlock(&ptp_data->lock); in ksz_ptp_adjtime()
835 switch (req->type) { in ksz_ptp_enable()
837 mutex_lock(&ptp_data->lock); in ksz_ptp_enable()
838 ret = ksz_ptp_enable_perout(dev, &req->perout, on); in ksz_ptp_enable()
839 mutex_unlock(&ptp_data->lock); in ksz_ptp_enable()
842 return -EOPNOTSUPP; in ksz_ptp_enable()
858 ret = -1; in ksz_ptp_verify_pin()
873 mutex_lock(&ptp_data->lock); in ksz_ptp_do_aux_work()
878 spin_lock_bh(&ptp_data->clock_lock); in ksz_ptp_do_aux_work()
879 ptp_data->clock_time = ts; in ksz_ptp_do_aux_work()
880 spin_unlock_bh(&ptp_data->clock_lock); in ksz_ptp_do_aux_work()
883 mutex_unlock(&ptp_data->lock); in ksz_ptp_do_aux_work()
890 struct ksz_ptp_data *ptp_data = &dev->ptp_data; in ksz_ptp_start_clock()
897 ptp_data->clock_time.tv_sec = 0; in ksz_ptp_start_clock()
898 ptp_data->clock_time.tv_nsec = 0; in ksz_ptp_start_clock()
905 struct ksz_device *dev = ds->priv; in ksz_ptp_clock_register()
910 ptp_data = &dev->ptp_data; in ksz_ptp_clock_register()
911 mutex_init(&ptp_data->lock); in ksz_ptp_clock_register()
912 spin_lock_init(&ptp_data->clock_lock); in ksz_ptp_clock_register()
914 ptp_data->caps.owner = THIS_MODULE; in ksz_ptp_clock_register()
915 snprintf(ptp_data->caps.name, 16, "Microchip Clock"); in ksz_ptp_clock_register()
916 ptp_data->caps.max_adj = KSZ_MAX_DRIFT_CORR; in ksz_ptp_clock_register()
917 ptp_data->caps.gettime64 = ksz_ptp_gettime; in ksz_ptp_clock_register()
918 ptp_data->caps.settime64 = ksz_ptp_settime; in ksz_ptp_clock_register()
919 ptp_data->caps.adjfine = ksz_ptp_adjfine; in ksz_ptp_clock_register()
920 ptp_data->caps.adjtime = ksz_ptp_adjtime; in ksz_ptp_clock_register()
921 ptp_data->caps.do_aux_work = ksz_ptp_do_aux_work; in ksz_ptp_clock_register()
922 ptp_data->caps.enable = ksz_ptp_enable; in ksz_ptp_clock_register()
923 ptp_data->caps.verify = ksz_ptp_verify_pin; in ksz_ptp_clock_register()
924 ptp_data->caps.n_pins = KSZ_PTP_N_GPIO; in ksz_ptp_clock_register()
925 ptp_data->caps.n_per_out = 3; in ksz_ptp_clock_register()
932 struct ptp_pin_desc *ptp_pin = &ptp_data->pin_config[i]; in ksz_ptp_clock_register()
934 snprintf(ptp_pin->name, in ksz_ptp_clock_register()
935 sizeof(ptp_pin->name), "ksz_ptp_pin_%02d", i); in ksz_ptp_clock_register()
936 ptp_pin->index = i; in ksz_ptp_clock_register()
937 ptp_pin->func = PTP_PF_NONE; in ksz_ptp_clock_register()
940 ptp_data->caps.pin_config = ptp_data->pin_config; in ksz_ptp_clock_register()
950 ptp_data->clock = ptp_clock_register(&ptp_data->caps, dev->dev); in ksz_ptp_clock_register()
951 if (IS_ERR_OR_NULL(ptp_data->clock)) in ksz_ptp_clock_register()
952 return PTR_ERR(ptp_data->clock); in ksz_ptp_clock_register()
959 struct ksz_device *dev = ds->priv; in ksz_ptp_clock_unregister()
962 ptp_data = &dev->ptp_data; in ksz_ptp_clock_unregister()
964 if (ptp_data->clock) in ksz_ptp_clock_unregister()
965 ptp_clock_unregister(ptp_data->clock); in ksz_ptp_clock_unregister()
977 port = ptpmsg_irq->port; in ksz_ptp_msg_thread_fn()
978 dev = port->ksz_dev; in ksz_ptp_msg_thread_fn()
980 if (ptpmsg_irq->ts_en) { in ksz_ptp_msg_thread_fn()
981 ret = ksz_read32(dev, ptpmsg_irq->ts_reg, &tstamp_raw); in ksz_ptp_msg_thread_fn()
987 port->tstamp_msg = ksz_tstamp_reconstruct(dev, tstamp); in ksz_ptp_msg_thread_fn()
989 complete(&port->tstamp_msg_comp); in ksz_ptp_msg_thread_fn()
1005 dev = ptpirq->dev; in ksz_ptp_irq_thread_fn()
1007 ret = ksz_read16(dev, ptpirq->reg_status, &data); in ksz_ptp_irq_thread_fn()
1012 ret = ksz_write16(dev, ptpirq->reg_status, data); in ksz_ptp_irq_thread_fn()
1016 for (n = 0; n < ptpirq->nirqs; ++n) { in ksz_ptp_irq_thread_fn()
1018 sub_irq = irq_find_mapping(ptpirq->domain, n); in ksz_ptp_irq_thread_fn()
1032 kirq->masked &= ~BIT(d->hwirq + KSZ_PTP_INT_START); in ksz_ptp_irq_mask()
1039 kirq->masked |= BIT(d->hwirq + KSZ_PTP_INT_START); in ksz_ptp_irq_unmask()
1046 mutex_lock(&kirq->dev->lock_irq); in ksz_ptp_irq_bus_lock()
1052 struct ksz_device *dev = kirq->dev; in ksz_ptp_irq_bus_sync_unlock()
1055 ret = ksz_write16(dev, kirq->reg_mask, kirq->masked); in ksz_ptp_irq_bus_sync_unlock()
1057 dev_err(dev->dev, "failed to change IRQ mask\n"); in ksz_ptp_irq_bus_sync_unlock()
1059 mutex_unlock(&dev->lock_irq); in ksz_ptp_irq_bus_sync_unlock()
1063 .name = "ksz-irq",
1073 irq_set_chip_data(irq, d->host_data); in ksz_ptp_irq_domain_map()
1089 ptpmsg_irq = &port->ptpmsg_irq[n]; in ksz_ptp_msg_irq_free()
1091 free_irq(ptpmsg_irq->num, ptpmsg_irq); in ksz_ptp_msg_irq_free()
1092 irq_dispose_mapping(ptpmsg_irq->num); in ksz_ptp_msg_irq_free()
1099 static const char * const name[] = {"pdresp-msg", "xdreq-msg", in ksz_ptp_msg_irq_setup()
1100 "sync-msg"}; in ksz_ptp_msg_irq_setup()
1101 const struct ksz_dev_ops *ops = port->ksz_dev->dev_ops; in ksz_ptp_msg_irq_setup()
1104 ptpmsg_irq = &port->ptpmsg_irq[n]; in ksz_ptp_msg_irq_setup()
1106 ptpmsg_irq->port = port; in ksz_ptp_msg_irq_setup()
1107 ptpmsg_irq->ts_reg = ops->get_port_addr(port->num, ts_reg[n]); in ksz_ptp_msg_irq_setup()
1109 snprintf(ptpmsg_irq->name, sizeof(ptpmsg_irq->name), name[n]); in ksz_ptp_msg_irq_setup()
1111 ptpmsg_irq->num = irq_find_mapping(port->ptpirq.domain, n); in ksz_ptp_msg_irq_setup()
1112 if (ptpmsg_irq->num < 0) in ksz_ptp_msg_irq_setup()
1113 return ptpmsg_irq->num; in ksz_ptp_msg_irq_setup()
1115 return request_threaded_irq(ptpmsg_irq->num, NULL, in ksz_ptp_msg_irq_setup()
1117 ptpmsg_irq->name, ptpmsg_irq); in ksz_ptp_msg_irq_setup()
1122 struct ksz_device *dev = ds->priv; in ksz_ptp_irq_setup()
1123 const struct ksz_dev_ops *ops = dev->dev_ops; in ksz_ptp_irq_setup()
1124 struct ksz_port *port = &dev->ports[p]; in ksz_ptp_irq_setup()
1125 struct ksz_irq *ptpirq = &port->ptpirq; in ksz_ptp_irq_setup()
1129 ptpirq->dev = dev; in ksz_ptp_irq_setup()
1130 ptpirq->masked = 0; in ksz_ptp_irq_setup()
1131 ptpirq->nirqs = 3; in ksz_ptp_irq_setup()
1132 ptpirq->reg_mask = ops->get_port_addr(p, REG_PTP_PORT_TX_INT_ENABLE__2); in ksz_ptp_irq_setup()
1133 ptpirq->reg_status = ops->get_port_addr(p, in ksz_ptp_irq_setup()
1135 snprintf(ptpirq->name, sizeof(ptpirq->name), "ptp-irq-%d", p); in ksz_ptp_irq_setup()
1137 init_completion(&port->tstamp_msg_comp); in ksz_ptp_irq_setup()
1139 ptpirq->domain = irq_domain_add_linear(dev->dev->of_node, ptpirq->nirqs, in ksz_ptp_irq_setup()
1141 if (!ptpirq->domain) in ksz_ptp_irq_setup()
1142 return -ENOMEM; in ksz_ptp_irq_setup()
1144 for (irq = 0; irq < ptpirq->nirqs; irq++) in ksz_ptp_irq_setup()
1145 irq_create_mapping(ptpirq->domain, irq); in ksz_ptp_irq_setup()
1147 ptpirq->irq_num = irq_find_mapping(port->pirq.domain, PORT_SRC_PTP_INT); in ksz_ptp_irq_setup()
1148 if (ptpirq->irq_num < 0) { in ksz_ptp_irq_setup()
1149 ret = ptpirq->irq_num; in ksz_ptp_irq_setup()
1153 ret = request_threaded_irq(ptpirq->irq_num, NULL, ksz_ptp_irq_thread_fn, in ksz_ptp_irq_setup()
1154 IRQF_ONESHOT, ptpirq->name, ptpirq); in ksz_ptp_irq_setup()
1158 for (irq = 0; irq < ptpirq->nirqs; irq++) { in ksz_ptp_irq_setup()
1167 free_irq(ptpirq->irq_num, ptpirq); in ksz_ptp_irq_setup()
1168 while (irq--) in ksz_ptp_irq_setup()
1169 free_irq(port->ptpmsg_irq[irq].num, &port->ptpmsg_irq[irq]); in ksz_ptp_irq_setup()
1171 for (irq = 0; irq < ptpirq->nirqs; irq++) in ksz_ptp_irq_setup()
1172 irq_dispose_mapping(port->ptpmsg_irq[irq].num); in ksz_ptp_irq_setup()
1174 irq_domain_remove(ptpirq->domain); in ksz_ptp_irq_setup()
1181 struct ksz_device *dev = ds->priv; in ksz_ptp_irq_free()
1182 struct ksz_port *port = &dev->ports[p]; in ksz_ptp_irq_free()
1183 struct ksz_irq *ptpirq = &port->ptpirq; in ksz_ptp_irq_free()
1186 for (n = 0; n < ptpirq->nirqs; n++) in ksz_ptp_irq_free()
1189 free_irq(ptpirq->irq_num, ptpirq); in ksz_ptp_irq_free()
1190 irq_dispose_mapping(ptpirq->irq_num); in ksz_ptp_irq_free()
1192 irq_domain_remove(ptpirq->domain); in ksz_ptp_irq_free()