Lines Matching +full:tcsr +full:- +full:reg
1 // SPDX-License-Identifier: GPL-2.0
12 * field will be performed - whether it is a set, increment, decrement
16 * - PTP_PULSE_OUT (PTP_EVENT_REQ MPP)
22 * - PTP_CLK_OUT (PTP_TRIG_GEN MPP)
25 * initially, but if you specify a non-round second interval, it won't,
27 * - PTP_PCLK_OUT
66 static void mvpp2_tai_modify(void __iomem *reg, u32 mask, u32 set) in mvpp2_tai_modify() argument
70 val = readl_relaxed(reg) & ~mask; in mvpp2_tai_modify()
72 writel(val, reg); in mvpp2_tai_modify()
75 static void mvpp2_tai_write(u32 val, void __iomem *reg) in mvpp2_tai_write() argument
77 writel_relaxed(val & 0xffff, reg); in mvpp2_tai_write()
80 static u32 mvpp2_tai_read(void __iomem *reg) in mvpp2_tai_read() argument
82 return readl_relaxed(reg) & 0xffff; in mvpp2_tai_read()
92 ts->tv_sec = (u64)mvpp2_tai_read(base + 0) << 32 | in mvpp22_tai_read_ts()
96 ts->tv_nsec = mvpp2_tai_read(base + 12) << 16 | in mvpp22_tai_read_ts()
107 mvpp2_tai_write(ts->tv_sec >> 32, base + MVPP22_TAI_TLV_SEC_HIGH); in mvpp2_tai_write_tlv()
108 mvpp2_tai_write(ts->tv_sec >> 16, base + MVPP22_TAI_TLV_SEC_MED); in mvpp2_tai_write_tlv()
109 mvpp2_tai_write(ts->tv_sec, base + MVPP22_TAI_TLV_SEC_LOW); in mvpp2_tai_write_tlv()
110 mvpp2_tai_write(ts->tv_nsec >> 16, base + MVPP22_TAI_TLV_NANO_HIGH); in mvpp2_tai_write_tlv()
111 mvpp2_tai_write(ts->tv_nsec, base + MVPP22_TAI_TLV_NANO_LOW); in mvpp2_tai_write_tlv()
128 /* The adjustment has a range of +0.5ns to -0.5ns in 2^32 steps, so has units
129 * of 2^-32 ns.
136 * freq_delta = freq_adjusted - freq_nominal => positive = faster
137 * freq_delta = freq_nominal * (1 + fractional) - freq_nominal
142 * period_delta = period_nominal - period_adjusted => positive = faster
154 u64 val = tai->period * abs_scaled_ppm >> 4; in mvpp22_calc_frac_ppm()
175 scaled_ppm = -scaled_ppm; in mvpp22_tai_adjfine()
179 /* Convert to a signed 32-bit adjustment */ in mvpp22_tai_adjfine()
181 /* -S32_MIN warns, -val < S32_MIN fails, so go for the easy in mvpp22_tai_adjfine()
185 return -ERANGE; in mvpp22_tai_adjfine()
187 frac = -val; in mvpp22_tai_adjfine()
190 return -ERANGE; in mvpp22_tai_adjfine()
195 base = tai->base; in mvpp22_tai_adjfine()
196 spin_lock_irqsave(&tai->lock, flags); in mvpp22_tai_adjfine()
200 spin_unlock_irqrestore(&tai->lock, flags); in mvpp22_tai_adjfine()
215 return -ERANGE; in mvpp22_tai_adjtime()
218 delta = -delta; in mvpp22_tai_adjtime()
226 base = tai->base; in mvpp22_tai_adjtime()
227 spin_lock_irqsave(&tai->lock, flags); in mvpp22_tai_adjtime()
230 spin_unlock_irqrestore(&tai->lock, flags); in mvpp22_tai_adjtime()
242 u32 tcsr; in mvpp22_tai_gettimex64() local
245 base = tai->base; in mvpp22_tai_gettimex64()
246 spin_lock_irqsave(&tai->lock, flags); in mvpp22_tai_gettimex64()
260 tcsr = readl(base + MVPP22_TAI_TCSR); in mvpp22_tai_gettimex64()
261 if (tcsr & TCSR_CAPTURE_1_VALID) { in mvpp22_tai_gettimex64()
264 } else if (tcsr & TCSR_CAPTURE_0_VALID) { in mvpp22_tai_gettimex64()
269 ret = -EBUSY; in mvpp22_tai_gettimex64()
271 spin_unlock_irqrestore(&tai->lock, flags); in mvpp22_tai_gettimex64()
283 base = tai->base; in mvpp22_tai_settime64()
284 spin_lock_irqsave(&tai->lock, flags); in mvpp22_tai_settime64()
297 spin_unlock_irqrestore(&tai->lock, flags); in mvpp22_tai_settime64()
306 mvpp22_tai_gettimex64(ptp, &tai->stamp, NULL); in mvpp22_tai_aux_work()
313 void __iomem *base = tai->base; in mvpp22_tai_set_step()
316 nano = upper_32_bits(tai->period); in mvpp22_tai_set_step()
317 frac = lower_32_bits(tai->period); in mvpp22_tai_set_step()
332 void __iomem *base = tai->base; in mvpp22_tai_init()
342 return ptp_clock_index(tai->ptp_clock); in mvpp22_tai_ptp_clock_index()
352 * We use our stored timestamp (tai->stamp) to form a full timestamp, in mvpp22_tai_tstamp()
355 ts.tv_sec = READ_ONCE(tai->stamp.tv_sec); in mvpp22_tai_tstamp()
362 delta = ((tstamp >> 30) - (ts.tv_sec & 3)) & 3; in mvpp22_tai_tstamp()
364 delta -= 4; in mvpp22_tai_tstamp()
368 hwtstamp->hwtstamp = timespec64_to_ktime(ts); in mvpp22_tai_tstamp()
375 delay = mvpp22_tai_aux_work(&tai->caps); in mvpp22_tai_start()
377 ptp_schedule_worker(tai->ptp_clock, delay); in mvpp22_tai_start()
382 ptp_cancel_worker_sync(tai->ptp_clock); in mvpp22_tai_stop()
389 if (!IS_ERR(tai->ptp_clock)) in mvpp22_tai_remove()
390 ptp_clock_unregister(tai->ptp_clock); in mvpp22_tai_remove()
400 return -ENOMEM; in mvpp22_tai_probe()
402 spin_lock_init(&tai->lock); in mvpp22_tai_probe()
404 tai->base = priv->iface_base; in mvpp22_tai_probe()
406 /* The step size consists of three registers - a 16-bit nanosecond step in mvpp22_tai_probe()
407 * size, and a 32-bit fractional nanosecond step size split over two in mvpp22_tai_probe()
408 * registers. The fractional nanosecond step size has units of 2^-32ns. in mvpp22_tai_probe()
411 * (10^9 + freq / 2) / (freq * 2^-32) in mvpp22_tai_probe()
428 * the above gives an error of 13*2^-32ns. in mvpp22_tai_probe()
433 tai->period = 3ULL << 32; in mvpp22_tai_probe()
437 tai->caps.owner = THIS_MODULE; in mvpp22_tai_probe()
438 strscpy(tai->caps.name, "Marvell PP2.2", sizeof(tai->caps.name)); in mvpp22_tai_probe()
439 tai->caps.max_adj = mvpp22_calc_max_adj(tai); in mvpp22_tai_probe()
440 tai->caps.adjfine = mvpp22_tai_adjfine; in mvpp22_tai_probe()
441 tai->caps.adjtime = mvpp22_tai_adjtime; in mvpp22_tai_probe()
442 tai->caps.gettimex64 = mvpp22_tai_gettimex64; in mvpp22_tai_probe()
443 tai->caps.settime64 = mvpp22_tai_settime64; in mvpp22_tai_probe()
444 tai->caps.do_aux_work = mvpp22_tai_aux_work; in mvpp22_tai_probe()
450 tai->ptp_clock = ptp_clock_register(&tai->caps, dev); in mvpp22_tai_probe()
451 if (IS_ERR(tai->ptp_clock)) in mvpp22_tai_probe()
452 return PTR_ERR(tai->ptp_clock); in mvpp22_tai_probe()
454 priv->tai = tai; in mvpp22_tai_probe()