Lines Matching refs:tai

152 static u64 mvpp22_calc_frac_ppm(struct mvpp2_tai *tai, long abs_scaled_ppm)  in mvpp22_calc_frac_ppm()  argument
154 u64 val = tai->period * abs_scaled_ppm >> 4; in mvpp22_calc_frac_ppm()
159 static s32 mvpp22_calc_max_adj(struct mvpp2_tai *tai) in mvpp22_calc_max_adj() argument
166 struct mvpp2_tai *tai = ptp_to_tai(ptp); in mvpp22_tai_adjfine() local
177 val = mvpp22_calc_frac_ppm(tai, scaled_ppm); 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()
207 struct mvpp2_tai *tai = ptp_to_tai(ptp); in mvpp22_tai_adjtime() local
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()
239 struct mvpp2_tai *tai = ptp_to_tai(ptp); in mvpp22_tai_gettimex64() local
245 base = tai->base; in mvpp22_tai_gettimex64()
246 spin_lock_irqsave(&tai->lock, flags); in mvpp22_tai_gettimex64()
271 spin_unlock_irqrestore(&tai->lock, flags); in mvpp22_tai_gettimex64()
279 struct mvpp2_tai *tai = ptp_to_tai(ptp); in mvpp22_tai_settime64() local
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()
304 struct mvpp2_tai *tai = ptp_to_tai(ptp); in mvpp22_tai_aux_work() local
306 mvpp22_tai_gettimex64(ptp, &tai->stamp, NULL); in mvpp22_tai_aux_work()
311 static void mvpp22_tai_set_step(struct mvpp2_tai *tai) in mvpp22_tai_set_step() argument
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()
330 static void mvpp22_tai_init(struct mvpp2_tai *tai) in mvpp22_tai_init() argument
332 void __iomem *base = tai->base; in mvpp22_tai_init()
334 mvpp22_tai_set_step(tai); in mvpp22_tai_init()
340 int mvpp22_tai_ptp_clock_index(struct mvpp2_tai *tai) in mvpp22_tai_ptp_clock_index() argument
342 return ptp_clock_index(tai->ptp_clock); in mvpp22_tai_ptp_clock_index()
345 void mvpp22_tai_tstamp(struct mvpp2_tai *tai, u32 tstamp, in mvpp22_tai_tstamp() argument
355 ts.tv_sec = READ_ONCE(tai->stamp.tv_sec); in mvpp22_tai_tstamp()
371 void mvpp22_tai_start(struct mvpp2_tai *tai) in mvpp22_tai_start() argument
375 delay = mvpp22_tai_aux_work(&tai->caps); in mvpp22_tai_start()
377 ptp_schedule_worker(tai->ptp_clock, delay); in mvpp22_tai_start()
380 void mvpp22_tai_stop(struct mvpp2_tai *tai) in mvpp22_tai_stop() argument
382 ptp_cancel_worker_sync(tai->ptp_clock); in mvpp22_tai_stop()
387 struct mvpp2_tai *tai = priv; in mvpp22_tai_remove() local
389 if (!IS_ERR(tai->ptp_clock)) in mvpp22_tai_remove()
390 ptp_clock_unregister(tai->ptp_clock); in mvpp22_tai_remove()
395 struct mvpp2_tai *tai; in mvpp22_tai_probe() local
398 tai = devm_kzalloc(dev, sizeof(*tai), GFP_KERNEL); in mvpp22_tai_probe()
399 if (!tai) in mvpp22_tai_probe()
402 spin_lock_init(&tai->lock); in mvpp22_tai_probe()
404 tai->base = priv->iface_base; in mvpp22_tai_probe()
433 tai->period = 3ULL << 32; in mvpp22_tai_probe()
435 mvpp22_tai_init(tai); 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()
446 ret = devm_add_action(dev, mvpp22_tai_remove, tai); 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()