--- zzzz-none-000/linux-3.10.107/drivers/net/ethernet/freescale/gianfar_ptp.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/net/ethernet/freescale/gianfar_ptp.c 2021-02-04 17:41:59.000000000 +0000 @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -134,7 +133,7 @@ #define REG_SIZE sizeof(struct gianfar_ptp_registers) struct etsects { - struct gianfar_ptp_registers *regs; + struct gianfar_ptp_registers __iomem *regs; spinlock_t lock; /* protects regs */ struct ptp_clock *clock; struct ptp_clock_info caps; @@ -323,10 +322,10 @@ return 0; } -static int ptp_gianfar_gettime(struct ptp_clock_info *ptp, struct timespec *ts) +static int ptp_gianfar_gettime(struct ptp_clock_info *ptp, + struct timespec64 *ts) { u64 ns; - u32 remainder; unsigned long flags; struct etsects *etsects = container_of(ptp, struct etsects, caps); @@ -336,20 +335,19 @@ spin_unlock_irqrestore(&etsects->lock, flags); - ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder); - ts->tv_nsec = remainder; + *ts = ns_to_timespec64(ns); + return 0; } static int ptp_gianfar_settime(struct ptp_clock_info *ptp, - const struct timespec *ts) + const struct timespec64 *ts) { u64 ns; unsigned long flags; struct etsects *etsects = container_of(ptp, struct etsects, caps); - ns = ts->tv_sec * 1000000000ULL; - ns += ts->tv_nsec; + ns = timespec64_to_ns(ts); spin_lock_irqsave(&etsects->lock, flags); @@ -415,11 +413,12 @@ .n_alarm = 0, .n_ext_ts = N_EXT_TS, .n_per_out = 0, + .n_pins = 0, .pps = 1, .adjfreq = ptp_gianfar_adjfreq, .adjtime = ptp_gianfar_adjtime, - .gettime = ptp_gianfar_gettime, - .settime = ptp_gianfar_settime, + .gettime64 = ptp_gianfar_gettime, + .settime64 = ptp_gianfar_settime, .enable = ptp_gianfar_enable, }; @@ -440,7 +439,7 @@ { struct device_node *node = dev->dev.of_node; struct etsects *etsects; - struct timespec now; + struct timespec64 now; int err = -ENOMEM; u32 tmr_ctrl; unsigned long flags; @@ -452,7 +451,9 @@ err = -ENODEV; etsects->caps = ptp_gianfar_caps; - etsects->cksel = DEFAULT_CKSEL; + + if (get_of_u32(node, "fsl,cksel", &etsects->cksel)) + etsects->cksel = DEFAULT_CKSEL; if (get_of_u32(node, "fsl,tclk-period", &etsects->tclk_period) || get_of_u32(node, "fsl,tmr-prsc", &etsects->tmr_prsc) || @@ -466,7 +467,7 @@ etsects->irq = platform_get_irq(dev, 0); - if (etsects->irq == NO_IRQ) { + if (etsects->irq < 0) { pr_err("irq not in device tree\n"); goto no_node; } @@ -493,7 +494,7 @@ pr_err("ioremap ptp registers failed\n"); goto no_ioremap; } - getnstimeofday(&now); + getnstimeofday64(&now); ptp_gianfar_settime(&etsects->caps, &now); tmr_ctrl = @@ -519,7 +520,7 @@ } gfar_phc_index = ptp_clock_index(etsects->clock); - dev_set_drvdata(&dev->dev, etsects); + platform_set_drvdata(dev, etsects); return 0; @@ -537,7 +538,7 @@ static int gianfar_ptp_remove(struct platform_device *dev) { - struct etsects *etsects = dev_get_drvdata(&dev->dev); + struct etsects *etsects = platform_get_drvdata(dev); gfar_write(&etsects->regs->tmr_temask, 0); gfar_write(&etsects->regs->tmr_ctrl, 0); @@ -552,16 +553,16 @@ return 0; } -static struct of_device_id match_table[] = { +static const struct of_device_id match_table[] = { { .compatible = "fsl,etsec-ptp" }, {}, }; +MODULE_DEVICE_TABLE(of, match_table); static struct platform_driver gianfar_ptp_driver = { .driver = { .name = "gianfar_ptp", .of_match_table = match_table, - .owner = THIS_MODULE, }, .probe = gianfar_ptp_probe, .remove = gianfar_ptp_remove,