ptp.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Marvell 88E6xxx Switch PTP support
  4. *
  5. * Copyright (c) 2008 Marvell Semiconductor
  6. *
  7. * Copyright (c) 2017 National Instruments
  8. * Erik Hons <[email protected]>
  9. * Brandon Streiff <[email protected]>
  10. * Dane Wagner <[email protected]>
  11. */
  12. #include "chip.h"
  13. #include "global2.h"
  14. #include "hwtstamp.h"
  15. #include "ptp.h"
  16. #define MV88E6XXX_MAX_ADJ_PPB 1000000
  17. /* Family MV88E6250:
  18. * Raw timestamps are in units of 10-ns clock periods.
  19. *
  20. * clkadj = scaled_ppm * 10*2^28 / (10^6 * 2^16)
  21. * simplifies to
  22. * clkadj = scaled_ppm * 2^7 / 5^5
  23. */
  24. #define MV88E6250_CC_SHIFT 28
  25. #define MV88E6250_CC_MULT (10 << MV88E6250_CC_SHIFT)
  26. #define MV88E6250_CC_MULT_NUM (1 << 7)
  27. #define MV88E6250_CC_MULT_DEM 3125ULL
  28. /* Other families:
  29. * Raw timestamps are in units of 8-ns clock periods.
  30. *
  31. * clkadj = scaled_ppm * 8*2^28 / (10^6 * 2^16)
  32. * simplifies to
  33. * clkadj = scaled_ppm * 2^9 / 5^6
  34. */
  35. #define MV88E6XXX_CC_SHIFT 28
  36. #define MV88E6XXX_CC_MULT (8 << MV88E6XXX_CC_SHIFT)
  37. #define MV88E6XXX_CC_MULT_NUM (1 << 9)
  38. #define MV88E6XXX_CC_MULT_DEM 15625ULL
  39. #define TAI_EVENT_WORK_INTERVAL msecs_to_jiffies(100)
  40. #define cc_to_chip(cc) container_of(cc, struct mv88e6xxx_chip, tstamp_cc)
  41. #define dw_overflow_to_chip(dw) container_of(dw, struct mv88e6xxx_chip, \
  42. overflow_work)
  43. #define dw_tai_event_to_chip(dw) container_of(dw, struct mv88e6xxx_chip, \
  44. tai_event_work)
  45. static int mv88e6xxx_tai_read(struct mv88e6xxx_chip *chip, int addr,
  46. u16 *data, int len)
  47. {
  48. if (!chip->info->ops->avb_ops->tai_read)
  49. return -EOPNOTSUPP;
  50. return chip->info->ops->avb_ops->tai_read(chip, addr, data, len);
  51. }
  52. static int mv88e6xxx_tai_write(struct mv88e6xxx_chip *chip, int addr, u16 data)
  53. {
  54. if (!chip->info->ops->avb_ops->tai_write)
  55. return -EOPNOTSUPP;
  56. return chip->info->ops->avb_ops->tai_write(chip, addr, data);
  57. }
  58. /* TODO: places where this are called should be using pinctrl */
  59. static int mv88e6352_set_gpio_func(struct mv88e6xxx_chip *chip, int pin,
  60. int func, int input)
  61. {
  62. int err;
  63. if (!chip->info->ops->gpio_ops)
  64. return -EOPNOTSUPP;
  65. err = chip->info->ops->gpio_ops->set_dir(chip, pin, input);
  66. if (err)
  67. return err;
  68. return chip->info->ops->gpio_ops->set_pctl(chip, pin, func);
  69. }
  70. static u64 mv88e6352_ptp_clock_read(const struct cyclecounter *cc)
  71. {
  72. struct mv88e6xxx_chip *chip = cc_to_chip(cc);
  73. u16 phc_time[2];
  74. int err;
  75. err = mv88e6xxx_tai_read(chip, MV88E6XXX_TAI_TIME_LO, phc_time,
  76. ARRAY_SIZE(phc_time));
  77. if (err)
  78. return 0;
  79. else
  80. return ((u32)phc_time[1] << 16) | phc_time[0];
  81. }
  82. static u64 mv88e6165_ptp_clock_read(const struct cyclecounter *cc)
  83. {
  84. struct mv88e6xxx_chip *chip = cc_to_chip(cc);
  85. u16 phc_time[2];
  86. int err;
  87. err = mv88e6xxx_tai_read(chip, MV88E6XXX_PTP_GC_TIME_LO, phc_time,
  88. ARRAY_SIZE(phc_time));
  89. if (err)
  90. return 0;
  91. else
  92. return ((u32)phc_time[1] << 16) | phc_time[0];
  93. }
  94. /* mv88e6352_config_eventcap - configure TAI event capture
  95. * @event: PTP_CLOCK_PPS (internal) or PTP_CLOCK_EXTTS (external)
  96. * @rising: zero for falling-edge trigger, else rising-edge trigger
  97. *
  98. * This will also reset the capture sequence counter.
  99. */
  100. static int mv88e6352_config_eventcap(struct mv88e6xxx_chip *chip, int event,
  101. int rising)
  102. {
  103. u16 global_config;
  104. u16 cap_config;
  105. int err;
  106. chip->evcap_config = MV88E6XXX_TAI_CFG_CAP_OVERWRITE |
  107. MV88E6XXX_TAI_CFG_CAP_CTR_START;
  108. if (!rising)
  109. chip->evcap_config |= MV88E6XXX_TAI_CFG_EVREQ_FALLING;
  110. global_config = (chip->evcap_config | chip->trig_config);
  111. err = mv88e6xxx_tai_write(chip, MV88E6XXX_TAI_CFG, global_config);
  112. if (err)
  113. return err;
  114. if (event == PTP_CLOCK_PPS) {
  115. cap_config = MV88E6XXX_TAI_EVENT_STATUS_CAP_TRIG;
  116. } else if (event == PTP_CLOCK_EXTTS) {
  117. /* if STATUS_CAP_TRIG is unset we capture PTP_EVREQ events */
  118. cap_config = 0;
  119. } else {
  120. return -EINVAL;
  121. }
  122. /* Write the capture config; this also clears the capture counter */
  123. err = mv88e6xxx_tai_write(chip, MV88E6XXX_TAI_EVENT_STATUS,
  124. cap_config);
  125. return err;
  126. }
  127. static void mv88e6352_tai_event_work(struct work_struct *ugly)
  128. {
  129. struct delayed_work *dw = to_delayed_work(ugly);
  130. struct mv88e6xxx_chip *chip = dw_tai_event_to_chip(dw);
  131. struct ptp_clock_event ev;
  132. u16 status[4];
  133. u32 raw_ts;
  134. int err;
  135. mv88e6xxx_reg_lock(chip);
  136. err = mv88e6xxx_tai_read(chip, MV88E6XXX_TAI_EVENT_STATUS,
  137. status, ARRAY_SIZE(status));
  138. mv88e6xxx_reg_unlock(chip);
  139. if (err) {
  140. dev_err(chip->dev, "failed to read TAI status register\n");
  141. return;
  142. }
  143. if (status[0] & MV88E6XXX_TAI_EVENT_STATUS_ERROR) {
  144. dev_warn(chip->dev, "missed event capture\n");
  145. return;
  146. }
  147. if (!(status[0] & MV88E6XXX_TAI_EVENT_STATUS_VALID))
  148. goto out;
  149. raw_ts = ((u32)status[2] << 16) | status[1];
  150. /* Clear the valid bit so the next timestamp can come in */
  151. status[0] &= ~MV88E6XXX_TAI_EVENT_STATUS_VALID;
  152. mv88e6xxx_reg_lock(chip);
  153. err = mv88e6xxx_tai_write(chip, MV88E6XXX_TAI_EVENT_STATUS, status[0]);
  154. mv88e6xxx_reg_unlock(chip);
  155. /* This is an external timestamp */
  156. ev.type = PTP_CLOCK_EXTTS;
  157. /* We only have one timestamping channel. */
  158. ev.index = 0;
  159. mv88e6xxx_reg_lock(chip);
  160. ev.timestamp = timecounter_cyc2time(&chip->tstamp_tc, raw_ts);
  161. mv88e6xxx_reg_unlock(chip);
  162. ptp_clock_event(chip->ptp_clock, &ev);
  163. out:
  164. schedule_delayed_work(&chip->tai_event_work, TAI_EVENT_WORK_INTERVAL);
  165. }
  166. static int mv88e6xxx_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
  167. {
  168. struct mv88e6xxx_chip *chip = ptp_to_chip(ptp);
  169. const struct mv88e6xxx_ptp_ops *ptp_ops = chip->info->ops->ptp_ops;
  170. int neg_adj = 0;
  171. u32 diff, mult;
  172. u64 adj;
  173. if (scaled_ppm < 0) {
  174. neg_adj = 1;
  175. scaled_ppm = -scaled_ppm;
  176. }
  177. mult = ptp_ops->cc_mult;
  178. adj = ptp_ops->cc_mult_num;
  179. adj *= scaled_ppm;
  180. diff = div_u64(adj, ptp_ops->cc_mult_dem);
  181. mv88e6xxx_reg_lock(chip);
  182. timecounter_read(&chip->tstamp_tc);
  183. chip->tstamp_cc.mult = neg_adj ? mult - diff : mult + diff;
  184. mv88e6xxx_reg_unlock(chip);
  185. return 0;
  186. }
  187. static int mv88e6xxx_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
  188. {
  189. struct mv88e6xxx_chip *chip = ptp_to_chip(ptp);
  190. mv88e6xxx_reg_lock(chip);
  191. timecounter_adjtime(&chip->tstamp_tc, delta);
  192. mv88e6xxx_reg_unlock(chip);
  193. return 0;
  194. }
  195. static int mv88e6xxx_ptp_gettime(struct ptp_clock_info *ptp,
  196. struct timespec64 *ts)
  197. {
  198. struct mv88e6xxx_chip *chip = ptp_to_chip(ptp);
  199. u64 ns;
  200. mv88e6xxx_reg_lock(chip);
  201. ns = timecounter_read(&chip->tstamp_tc);
  202. mv88e6xxx_reg_unlock(chip);
  203. *ts = ns_to_timespec64(ns);
  204. return 0;
  205. }
  206. static int mv88e6xxx_ptp_settime(struct ptp_clock_info *ptp,
  207. const struct timespec64 *ts)
  208. {
  209. struct mv88e6xxx_chip *chip = ptp_to_chip(ptp);
  210. u64 ns;
  211. ns = timespec64_to_ns(ts);
  212. mv88e6xxx_reg_lock(chip);
  213. timecounter_init(&chip->tstamp_tc, &chip->tstamp_cc, ns);
  214. mv88e6xxx_reg_unlock(chip);
  215. return 0;
  216. }
  217. static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip,
  218. struct ptp_clock_request *rq, int on)
  219. {
  220. int rising = (rq->extts.flags & PTP_RISING_EDGE);
  221. int func;
  222. int pin;
  223. int err;
  224. /* Reject requests with unsupported flags */
  225. if (rq->extts.flags & ~(PTP_ENABLE_FEATURE |
  226. PTP_RISING_EDGE |
  227. PTP_FALLING_EDGE |
  228. PTP_STRICT_FLAGS))
  229. return -EOPNOTSUPP;
  230. /* Reject requests to enable time stamping on both edges. */
  231. if ((rq->extts.flags & PTP_STRICT_FLAGS) &&
  232. (rq->extts.flags & PTP_ENABLE_FEATURE) &&
  233. (rq->extts.flags & PTP_EXTTS_EDGES) == PTP_EXTTS_EDGES)
  234. return -EOPNOTSUPP;
  235. pin = ptp_find_pin(chip->ptp_clock, PTP_PF_EXTTS, rq->extts.index);
  236. if (pin < 0)
  237. return -EBUSY;
  238. mv88e6xxx_reg_lock(chip);
  239. if (on) {
  240. func = MV88E6352_G2_SCRATCH_GPIO_PCTL_EVREQ;
  241. err = mv88e6352_set_gpio_func(chip, pin, func, true);
  242. if (err)
  243. goto out;
  244. schedule_delayed_work(&chip->tai_event_work,
  245. TAI_EVENT_WORK_INTERVAL);
  246. err = mv88e6352_config_eventcap(chip, PTP_CLOCK_EXTTS, rising);
  247. } else {
  248. func = MV88E6352_G2_SCRATCH_GPIO_PCTL_GPIO;
  249. err = mv88e6352_set_gpio_func(chip, pin, func, true);
  250. cancel_delayed_work_sync(&chip->tai_event_work);
  251. }
  252. out:
  253. mv88e6xxx_reg_unlock(chip);
  254. return err;
  255. }
  256. static int mv88e6352_ptp_enable(struct ptp_clock_info *ptp,
  257. struct ptp_clock_request *rq, int on)
  258. {
  259. struct mv88e6xxx_chip *chip = ptp_to_chip(ptp);
  260. switch (rq->type) {
  261. case PTP_CLK_REQ_EXTTS:
  262. return mv88e6352_ptp_enable_extts(chip, rq, on);
  263. default:
  264. return -EOPNOTSUPP;
  265. }
  266. }
  267. static int mv88e6352_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,
  268. enum ptp_pin_function func, unsigned int chan)
  269. {
  270. switch (func) {
  271. case PTP_PF_NONE:
  272. case PTP_PF_EXTTS:
  273. break;
  274. case PTP_PF_PEROUT:
  275. case PTP_PF_PHYSYNC:
  276. return -EOPNOTSUPP;
  277. }
  278. return 0;
  279. }
  280. const struct mv88e6xxx_ptp_ops mv88e6165_ptp_ops = {
  281. .clock_read = mv88e6165_ptp_clock_read,
  282. .global_enable = mv88e6165_global_enable,
  283. .global_disable = mv88e6165_global_disable,
  284. .arr0_sts_reg = MV88E6165_PORT_PTP_ARR0_STS,
  285. .arr1_sts_reg = MV88E6165_PORT_PTP_ARR1_STS,
  286. .dep_sts_reg = MV88E6165_PORT_PTP_DEP_STS,
  287. .rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
  288. (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
  289. (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
  290. (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
  291. (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
  292. (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
  293. (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ),
  294. .cc_shift = MV88E6XXX_CC_SHIFT,
  295. .cc_mult = MV88E6XXX_CC_MULT,
  296. .cc_mult_num = MV88E6XXX_CC_MULT_NUM,
  297. .cc_mult_dem = MV88E6XXX_CC_MULT_DEM,
  298. };
  299. const struct mv88e6xxx_ptp_ops mv88e6250_ptp_ops = {
  300. .clock_read = mv88e6352_ptp_clock_read,
  301. .ptp_enable = mv88e6352_ptp_enable,
  302. .ptp_verify = mv88e6352_ptp_verify,
  303. .event_work = mv88e6352_tai_event_work,
  304. .port_enable = mv88e6352_hwtstamp_port_enable,
  305. .port_disable = mv88e6352_hwtstamp_port_disable,
  306. .n_ext_ts = 1,
  307. .arr0_sts_reg = MV88E6XXX_PORT_PTP_ARR0_STS,
  308. .arr1_sts_reg = MV88E6XXX_PORT_PTP_ARR1_STS,
  309. .dep_sts_reg = MV88E6XXX_PORT_PTP_DEP_STS,
  310. .rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
  311. (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
  312. (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
  313. (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
  314. (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
  315. (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
  316. (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
  317. (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
  318. (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
  319. (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ),
  320. .cc_shift = MV88E6250_CC_SHIFT,
  321. .cc_mult = MV88E6250_CC_MULT,
  322. .cc_mult_num = MV88E6250_CC_MULT_NUM,
  323. .cc_mult_dem = MV88E6250_CC_MULT_DEM,
  324. };
  325. const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops = {
  326. .clock_read = mv88e6352_ptp_clock_read,
  327. .ptp_enable = mv88e6352_ptp_enable,
  328. .ptp_verify = mv88e6352_ptp_verify,
  329. .event_work = mv88e6352_tai_event_work,
  330. .port_enable = mv88e6352_hwtstamp_port_enable,
  331. .port_disable = mv88e6352_hwtstamp_port_disable,
  332. .n_ext_ts = 1,
  333. .arr0_sts_reg = MV88E6XXX_PORT_PTP_ARR0_STS,
  334. .arr1_sts_reg = MV88E6XXX_PORT_PTP_ARR1_STS,
  335. .dep_sts_reg = MV88E6XXX_PORT_PTP_DEP_STS,
  336. .rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
  337. (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
  338. (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
  339. (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
  340. (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
  341. (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
  342. (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
  343. (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
  344. (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
  345. (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ),
  346. .cc_shift = MV88E6XXX_CC_SHIFT,
  347. .cc_mult = MV88E6XXX_CC_MULT,
  348. .cc_mult_num = MV88E6XXX_CC_MULT_NUM,
  349. .cc_mult_dem = MV88E6XXX_CC_MULT_DEM,
  350. };
  351. static u64 mv88e6xxx_ptp_clock_read(const struct cyclecounter *cc)
  352. {
  353. struct mv88e6xxx_chip *chip = cc_to_chip(cc);
  354. if (chip->info->ops->ptp_ops->clock_read)
  355. return chip->info->ops->ptp_ops->clock_read(cc);
  356. return 0;
  357. }
  358. /* With a 125MHz input clock, the 32-bit timestamp counter overflows in ~34.3
  359. * seconds; this task forces periodic reads so that we don't miss any.
  360. */
  361. #define MV88E6XXX_TAI_OVERFLOW_PERIOD (HZ * 16)
  362. static void mv88e6xxx_ptp_overflow_check(struct work_struct *work)
  363. {
  364. struct delayed_work *dw = to_delayed_work(work);
  365. struct mv88e6xxx_chip *chip = dw_overflow_to_chip(dw);
  366. struct timespec64 ts;
  367. mv88e6xxx_ptp_gettime(&chip->ptp_clock_info, &ts);
  368. schedule_delayed_work(&chip->overflow_work,
  369. MV88E6XXX_TAI_OVERFLOW_PERIOD);
  370. }
  371. int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip)
  372. {
  373. const struct mv88e6xxx_ptp_ops *ptp_ops = chip->info->ops->ptp_ops;
  374. int i;
  375. /* Set up the cycle counter */
  376. memset(&chip->tstamp_cc, 0, sizeof(chip->tstamp_cc));
  377. chip->tstamp_cc.read = mv88e6xxx_ptp_clock_read;
  378. chip->tstamp_cc.mask = CYCLECOUNTER_MASK(32);
  379. chip->tstamp_cc.mult = ptp_ops->cc_mult;
  380. chip->tstamp_cc.shift = ptp_ops->cc_shift;
  381. timecounter_init(&chip->tstamp_tc, &chip->tstamp_cc,
  382. ktime_to_ns(ktime_get_real()));
  383. INIT_DELAYED_WORK(&chip->overflow_work, mv88e6xxx_ptp_overflow_check);
  384. if (ptp_ops->event_work)
  385. INIT_DELAYED_WORK(&chip->tai_event_work, ptp_ops->event_work);
  386. chip->ptp_clock_info.owner = THIS_MODULE;
  387. snprintf(chip->ptp_clock_info.name, sizeof(chip->ptp_clock_info.name),
  388. "%s", dev_name(chip->dev));
  389. chip->ptp_clock_info.n_ext_ts = ptp_ops->n_ext_ts;
  390. chip->ptp_clock_info.n_per_out = 0;
  391. chip->ptp_clock_info.n_pins = mv88e6xxx_num_gpio(chip);
  392. chip->ptp_clock_info.pps = 0;
  393. for (i = 0; i < chip->ptp_clock_info.n_pins; ++i) {
  394. struct ptp_pin_desc *ppd = &chip->pin_config[i];
  395. snprintf(ppd->name, sizeof(ppd->name), "mv88e6xxx_gpio%d", i);
  396. ppd->index = i;
  397. ppd->func = PTP_PF_NONE;
  398. }
  399. chip->ptp_clock_info.pin_config = chip->pin_config;
  400. chip->ptp_clock_info.max_adj = MV88E6XXX_MAX_ADJ_PPB;
  401. chip->ptp_clock_info.adjfine = mv88e6xxx_ptp_adjfine;
  402. chip->ptp_clock_info.adjtime = mv88e6xxx_ptp_adjtime;
  403. chip->ptp_clock_info.gettime64 = mv88e6xxx_ptp_gettime;
  404. chip->ptp_clock_info.settime64 = mv88e6xxx_ptp_settime;
  405. chip->ptp_clock_info.enable = ptp_ops->ptp_enable;
  406. chip->ptp_clock_info.verify = ptp_ops->ptp_verify;
  407. chip->ptp_clock_info.do_aux_work = mv88e6xxx_hwtstamp_work;
  408. chip->ptp_clock = ptp_clock_register(&chip->ptp_clock_info, chip->dev);
  409. if (IS_ERR(chip->ptp_clock))
  410. return PTR_ERR(chip->ptp_clock);
  411. schedule_delayed_work(&chip->overflow_work,
  412. MV88E6XXX_TAI_OVERFLOW_PERIOD);
  413. return 0;
  414. }
  415. void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip)
  416. {
  417. if (chip->ptp_clock) {
  418. cancel_delayed_work_sync(&chip->overflow_work);
  419. if (chip->info->ops->ptp_ops->event_work)
  420. cancel_delayed_work_sync(&chip->tai_event_work);
  421. ptp_clock_unregister(chip->ptp_clock);
  422. chip->ptp_clock = NULL;
  423. }
  424. }