Lines Matching full:ocelot
2 /* Microsemi Ocelot PTP clock driver
9 #include <soc/mscc/ocelot.h>
13 struct ocelot *ocelot = container_of(ptp, struct ocelot, ptp_info); in ocelot_ptp_gettime64() local
19 spin_lock_irqsave(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_gettime64()
21 val = ocelot_read_rix(ocelot, PTP_PIN_CFG, TOD_ACC_PIN); in ocelot_ptp_gettime64()
24 ocelot_write_rix(ocelot, val, PTP_PIN_CFG, TOD_ACC_PIN); in ocelot_ptp_gettime64()
26 s = ocelot_read_rix(ocelot, PTP_PIN_TOD_SEC_MSB, TOD_ACC_PIN) & 0xffff; in ocelot_ptp_gettime64()
28 s += ocelot_read_rix(ocelot, PTP_PIN_TOD_SEC_LSB, TOD_ACC_PIN); in ocelot_ptp_gettime64()
29 ns = ocelot_read_rix(ocelot, PTP_PIN_TOD_NSEC, TOD_ACC_PIN); in ocelot_ptp_gettime64()
31 spin_unlock_irqrestore(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_gettime64()
48 struct ocelot *ocelot = container_of(ptp, struct ocelot, ptp_info); in ocelot_ptp_settime64() local
52 spin_lock_irqsave(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_settime64()
54 val = ocelot_read_rix(ocelot, PTP_PIN_CFG, TOD_ACC_PIN); in ocelot_ptp_settime64()
58 ocelot_write_rix(ocelot, val, PTP_PIN_CFG, TOD_ACC_PIN); in ocelot_ptp_settime64()
60 ocelot_write_rix(ocelot, lower_32_bits(ts->tv_sec), PTP_PIN_TOD_SEC_LSB, in ocelot_ptp_settime64()
62 ocelot_write_rix(ocelot, upper_32_bits(ts->tv_sec), PTP_PIN_TOD_SEC_MSB, in ocelot_ptp_settime64()
64 ocelot_write_rix(ocelot, ts->tv_nsec, PTP_PIN_TOD_NSEC, TOD_ACC_PIN); in ocelot_ptp_settime64()
66 val = ocelot_read_rix(ocelot, PTP_PIN_CFG, TOD_ACC_PIN); in ocelot_ptp_settime64()
70 ocelot_write_rix(ocelot, val, PTP_PIN_CFG, TOD_ACC_PIN); in ocelot_ptp_settime64()
72 spin_unlock_irqrestore(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_settime64()
80 struct ocelot *ocelot = container_of(ptp, struct ocelot, in ocelot_ptp_adjtime() local
85 spin_lock_irqsave(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_adjtime()
87 val = ocelot_read_rix(ocelot, PTP_PIN_CFG, TOD_ACC_PIN); in ocelot_ptp_adjtime()
92 ocelot_write_rix(ocelot, val, PTP_PIN_CFG, TOD_ACC_PIN); in ocelot_ptp_adjtime()
94 ocelot_write_rix(ocelot, 0, PTP_PIN_TOD_SEC_LSB, TOD_ACC_PIN); in ocelot_ptp_adjtime()
95 ocelot_write_rix(ocelot, 0, PTP_PIN_TOD_SEC_MSB, TOD_ACC_PIN); in ocelot_ptp_adjtime()
96 ocelot_write_rix(ocelot, delta, PTP_PIN_TOD_NSEC, TOD_ACC_PIN); in ocelot_ptp_adjtime()
98 val = ocelot_read_rix(ocelot, PTP_PIN_CFG, TOD_ACC_PIN); in ocelot_ptp_adjtime()
103 ocelot_write_rix(ocelot, val, PTP_PIN_CFG, TOD_ACC_PIN); in ocelot_ptp_adjtime()
105 spin_unlock_irqrestore(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_adjtime()
124 struct ocelot *ocelot = container_of(ptp, struct ocelot, ptp_info); in ocelot_ptp_adjfine() local
129 spin_lock_irqsave(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_adjfine()
153 ocelot_write(ocelot, unit | adj, PTP_CLK_CFG_ADJ_FREQ); in ocelot_ptp_adjfine()
154 ocelot_write(ocelot, PTP_CFG_CLK_ADJ_CFG_ENA | direction, in ocelot_ptp_adjfine()
157 spin_unlock_irqrestore(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_adjfine()
161 ocelot_write(ocelot, 0, PTP_CLK_CFG_ADJ_CFG); in ocelot_ptp_adjfine()
163 spin_unlock_irqrestore(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_adjfine()
186 struct ocelot *ocelot = container_of(ptp, struct ocelot, ptp_info); in ocelot_ptp_enable() local
203 pin = ptp_find_pin(ocelot->ptp_clock, PTP_PF_PEROUT, in ocelot_ptp_enable()
224 spin_lock_irqsave(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_enable()
226 ocelot_write_rix(ocelot, val, PTP_PIN_CFG, ptp_pin); in ocelot_ptp_enable()
227 spin_unlock_irqrestore(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_enable()
240 dev_warn(ocelot->dev, in ocelot_ptp_enable()
242 dev_warn(ocelot->dev, in ocelot_ptp_enable()
269 spin_lock_irqsave(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_enable()
270 ocelot_write_rix(ocelot, ts_phase.tv_nsec, in ocelot_ptp_enable()
272 ocelot_write_rix(ocelot, wf_high, in ocelot_ptp_enable()
276 ocelot_write_rix(ocelot, val, PTP_PIN_CFG, ptp_pin); in ocelot_ptp_enable()
277 spin_unlock_irqrestore(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_enable()
287 spin_lock_irqsave(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_enable()
288 ocelot_write_rix(ocelot, wf_low, PTP_PIN_WF_LOW_PERIOD, in ocelot_ptp_enable()
290 ocelot_write_rix(ocelot, wf_high, PTP_PIN_WF_HIGH_PERIOD, in ocelot_ptp_enable()
293 ocelot_write_rix(ocelot, val, PTP_PIN_CFG, ptp_pin); in ocelot_ptp_enable()
294 spin_unlock_irqrestore(&ocelot->ptp_clock_lock, flags); in ocelot_ptp_enable()
303 int ocelot_init_timestamp(struct ocelot *ocelot, in ocelot_init_timestamp() argument
309 ocelot->ptp_info = *info; in ocelot_init_timestamp()
312 struct ptp_pin_desc *p = &ocelot->ptp_pins[i]; in ocelot_init_timestamp()
319 ocelot->ptp_info.pin_config = &ocelot->ptp_pins[0]; in ocelot_init_timestamp()
321 ptp_clock = ptp_clock_register(&ocelot->ptp_info, ocelot->dev); in ocelot_init_timestamp()
328 ocelot->ptp_clock = ptp_clock; in ocelot_init_timestamp()
330 ocelot_write(ocelot, SYS_PTP_CFG_PTP_STAMP_WID(30), SYS_PTP_CFG); in ocelot_init_timestamp()
331 ocelot_write(ocelot, 0xffffffff, ANA_TABLES_PTP_ID_LOW); in ocelot_init_timestamp()
332 ocelot_write(ocelot, 0xffffffff, ANA_TABLES_PTP_ID_HIGH); in ocelot_init_timestamp()
334 ocelot_write(ocelot, PTP_CFG_MISC_PTP_EN, PTP_CFG_MISC); in ocelot_init_timestamp()
339 ocelot->hwtstamp_config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; in ocelot_init_timestamp()
345 int ocelot_deinit_timestamp(struct ocelot *ocelot) in ocelot_deinit_timestamp() argument
347 if (ocelot->ptp_clock) in ocelot_deinit_timestamp()
348 ptp_clock_unregister(ocelot->ptp_clock); in ocelot_deinit_timestamp()