Searched refs:etsects (Results 1 - 1 of 1) sorted by relevance

/linux-4.1.27/drivers/net/ethernet/freescale/
H A Dgianfar_ptp.c135 struct etsects { struct
156 /* Caller must hold etsects->lock. */ tmr_cnt_read()
157 static u64 tmr_cnt_read(struct etsects *etsects) tmr_cnt_read() argument
162 lo = gfar_read(&etsects->regs->tmr_cnt_l); tmr_cnt_read()
163 hi = gfar_read(&etsects->regs->tmr_cnt_h); tmr_cnt_read()
169 /* Caller must hold etsects->lock. */ tmr_cnt_write()
170 static void tmr_cnt_write(struct etsects *etsects, u64 ns) tmr_cnt_write() argument
175 gfar_write(&etsects->regs->tmr_cnt_l, lo); tmr_cnt_write()
176 gfar_write(&etsects->regs->tmr_cnt_h, hi); tmr_cnt_write()
179 /* Caller must hold etsects->lock. */ set_alarm()
180 static void set_alarm(struct etsects *etsects) set_alarm() argument
185 ns = tmr_cnt_read(etsects) + 1500000000ULL; set_alarm()
187 ns -= etsects->tclk_period; set_alarm()
190 gfar_write(&etsects->regs->tmr_alarm1_l, lo); set_alarm()
191 gfar_write(&etsects->regs->tmr_alarm1_h, hi); set_alarm()
194 /* Caller must hold etsects->lock. */ set_fipers()
195 static void set_fipers(struct etsects *etsects) set_fipers() argument
197 set_alarm(etsects); set_fipers()
198 gfar_write(&etsects->regs->tmr_fiper1, etsects->tmr_fiper1); set_fipers()
199 gfar_write(&etsects->regs->tmr_fiper2, etsects->tmr_fiper2); set_fipers()
208 struct etsects *etsects = priv; isr() local
213 val = gfar_read(&etsects->regs->tmr_tevent); isr()
217 hi = gfar_read(&etsects->regs->tmr_etts1_h); isr()
218 lo = gfar_read(&etsects->regs->tmr_etts1_l); isr()
223 ptp_clock_event(etsects->clock, &event); isr()
228 hi = gfar_read(&etsects->regs->tmr_etts2_h); isr()
229 lo = gfar_read(&etsects->regs->tmr_etts2_l); isr()
234 ptp_clock_event(etsects->clock, &event); isr()
239 if (etsects->alarm_value) { isr()
242 event.timestamp = etsects->alarm_value; isr()
243 ptp_clock_event(etsects->clock, &event); isr()
245 if (etsects->alarm_interval) { isr()
246 ns = etsects->alarm_value + etsects->alarm_interval; isr()
249 spin_lock(&etsects->lock); isr()
250 gfar_write(&etsects->regs->tmr_alarm2_l, lo); isr()
251 gfar_write(&etsects->regs->tmr_alarm2_h, hi); isr()
252 spin_unlock(&etsects->lock); isr()
253 etsects->alarm_value = ns; isr()
255 gfar_write(&etsects->regs->tmr_tevent, ALM2); isr()
256 spin_lock(&etsects->lock); isr()
257 mask = gfar_read(&etsects->regs->tmr_temask); isr()
259 gfar_write(&etsects->regs->tmr_temask, mask); isr()
260 spin_unlock(&etsects->lock); isr()
261 etsects->alarm_value = 0; isr()
262 etsects->alarm_interval = 0; isr()
269 ptp_clock_event(etsects->clock, &event); isr()
273 gfar_write(&etsects->regs->tmr_tevent, ack); isr()
288 struct etsects *etsects = container_of(ptp, struct etsects, caps); ptp_gianfar_adjfreq() local
294 tmr_add = etsects->tmr_add; ptp_gianfar_adjfreq()
301 gfar_write(&etsects->regs->tmr_add, tmr_add); ptp_gianfar_adjfreq()
310 struct etsects *etsects = container_of(ptp, struct etsects, caps); ptp_gianfar_adjtime() local
312 spin_lock_irqsave(&etsects->lock, flags); ptp_gianfar_adjtime()
314 now = tmr_cnt_read(etsects); ptp_gianfar_adjtime()
316 tmr_cnt_write(etsects, now); ptp_gianfar_adjtime()
318 spin_unlock_irqrestore(&etsects->lock, flags); ptp_gianfar_adjtime()
320 set_fipers(etsects); ptp_gianfar_adjtime()
330 struct etsects *etsects = container_of(ptp, struct etsects, caps); ptp_gianfar_gettime() local
332 spin_lock_irqsave(&etsects->lock, flags); ptp_gianfar_gettime()
334 ns = tmr_cnt_read(etsects); ptp_gianfar_gettime()
336 spin_unlock_irqrestore(&etsects->lock, flags); ptp_gianfar_gettime()
348 struct etsects *etsects = container_of(ptp, struct etsects, caps); ptp_gianfar_settime() local
352 spin_lock_irqsave(&etsects->lock, flags); ptp_gianfar_settime()
354 tmr_cnt_write(etsects, ns); ptp_gianfar_settime()
355 set_fipers(etsects); ptp_gianfar_settime()
357 spin_unlock_irqrestore(&etsects->lock, flags); ptp_gianfar_settime()
365 struct etsects *etsects = container_of(ptp, struct etsects, caps); ptp_gianfar_enable() local
381 spin_lock_irqsave(&etsects->lock, flags); ptp_gianfar_enable()
382 mask = gfar_read(&etsects->regs->tmr_temask); ptp_gianfar_enable()
387 gfar_write(&etsects->regs->tmr_temask, mask); ptp_gianfar_enable()
388 spin_unlock_irqrestore(&etsects->lock, flags); ptp_gianfar_enable()
392 spin_lock_irqsave(&etsects->lock, flags); ptp_gianfar_enable()
393 mask = gfar_read(&etsects->regs->tmr_temask); ptp_gianfar_enable()
398 gfar_write(&etsects->regs->tmr_temask, mask); ptp_gianfar_enable()
399 spin_unlock_irqrestore(&etsects->lock, flags); ptp_gianfar_enable()
441 struct etsects *etsects; gianfar_ptp_probe() local
447 etsects = kzalloc(sizeof(*etsects), GFP_KERNEL); gianfar_ptp_probe()
448 if (!etsects) gianfar_ptp_probe()
453 etsects->caps = ptp_gianfar_caps; gianfar_ptp_probe()
455 if (get_of_u32(node, "fsl,cksel", &etsects->cksel)) gianfar_ptp_probe()
456 etsects->cksel = DEFAULT_CKSEL; gianfar_ptp_probe()
458 if (get_of_u32(node, "fsl,tclk-period", &etsects->tclk_period) || gianfar_ptp_probe()
459 get_of_u32(node, "fsl,tmr-prsc", &etsects->tmr_prsc) || gianfar_ptp_probe()
460 get_of_u32(node, "fsl,tmr-add", &etsects->tmr_add) || gianfar_ptp_probe()
461 get_of_u32(node, "fsl,tmr-fiper1", &etsects->tmr_fiper1) || gianfar_ptp_probe()
462 get_of_u32(node, "fsl,tmr-fiper2", &etsects->tmr_fiper2) || gianfar_ptp_probe()
463 get_of_u32(node, "fsl,max-adj", &etsects->caps.max_adj)) { gianfar_ptp_probe()
468 etsects->irq = platform_get_irq(dev, 0); gianfar_ptp_probe()
470 if (etsects->irq == NO_IRQ) { gianfar_ptp_probe()
474 if (request_irq(etsects->irq, isr, 0, DRIVER, etsects)) { gianfar_ptp_probe()
479 etsects->rsrc = platform_get_resource(dev, IORESOURCE_MEM, 0); gianfar_ptp_probe()
480 if (!etsects->rsrc) { gianfar_ptp_probe()
484 if (request_resource(&iomem_resource, etsects->rsrc)) { gianfar_ptp_probe()
489 spin_lock_init(&etsects->lock); gianfar_ptp_probe()
491 etsects->regs = ioremap(etsects->rsrc->start, gianfar_ptp_probe()
492 resource_size(etsects->rsrc)); gianfar_ptp_probe()
493 if (!etsects->regs) { gianfar_ptp_probe()
498 ptp_gianfar_settime(&etsects->caps, &now); gianfar_ptp_probe()
501 (etsects->tclk_period & TCLK_PERIOD_MASK) << TCLK_PERIOD_SHIFT | gianfar_ptp_probe()
502 (etsects->cksel & CKSEL_MASK) << CKSEL_SHIFT; gianfar_ptp_probe()
504 spin_lock_irqsave(&etsects->lock, flags); gianfar_ptp_probe()
506 gfar_write(&etsects->regs->tmr_ctrl, tmr_ctrl); gianfar_ptp_probe()
507 gfar_write(&etsects->regs->tmr_add, etsects->tmr_add); gianfar_ptp_probe()
508 gfar_write(&etsects->regs->tmr_prsc, etsects->tmr_prsc); gianfar_ptp_probe()
509 gfar_write(&etsects->regs->tmr_fiper1, etsects->tmr_fiper1); gianfar_ptp_probe()
510 gfar_write(&etsects->regs->tmr_fiper2, etsects->tmr_fiper2); gianfar_ptp_probe()
511 set_alarm(etsects); gianfar_ptp_probe()
512 gfar_write(&etsects->regs->tmr_ctrl, tmr_ctrl|FS|RTPE|TE|FRD); gianfar_ptp_probe()
514 spin_unlock_irqrestore(&etsects->lock, flags); gianfar_ptp_probe()
516 etsects->clock = ptp_clock_register(&etsects->caps, &dev->dev); gianfar_ptp_probe()
517 if (IS_ERR(etsects->clock)) { gianfar_ptp_probe()
518 err = PTR_ERR(etsects->clock); gianfar_ptp_probe()
521 gfar_phc_index = ptp_clock_index(etsects->clock); gianfar_ptp_probe()
523 platform_set_drvdata(dev, etsects); gianfar_ptp_probe()
528 iounmap(etsects->regs); gianfar_ptp_probe()
530 release_resource(etsects->rsrc); gianfar_ptp_probe()
532 free_irq(etsects->irq, etsects); gianfar_ptp_probe()
534 kfree(etsects); gianfar_ptp_probe()
541 struct etsects *etsects = platform_get_drvdata(dev); gianfar_ptp_remove() local
543 gfar_write(&etsects->regs->tmr_temask, 0); gianfar_ptp_remove()
544 gfar_write(&etsects->regs->tmr_ctrl, 0); gianfar_ptp_remove()
547 ptp_clock_unregister(etsects->clock); gianfar_ptp_remove()
548 iounmap(etsects->regs); gianfar_ptp_remove()
549 release_resource(etsects->rsrc); gianfar_ptp_remove()
550 free_irq(etsects->irq, etsects); gianfar_ptp_remove()
551 kfree(etsects); gianfar_ptp_remove()

Completed in 87 milliseconds