ath79/mikrotik: use routerbootpart partitions
[oweals/openwrt.git] / target / linux / layerscape / patches-5.4 / 701-net-0098-sdk_dpaa-remove-ptp-clock-driver.patch
1 From 0738b02f733717693226db401784e884a0714d41 Mon Sep 17 00:00:00 2001
2 From: Yangbo Lu <yangbo.lu@nxp.com>
3 Date: Wed, 31 Oct 2018 16:59:01 +0800
4 Subject: [PATCH] sdk_dpaa: remove ptp clock driver
5
6 Removed dpaa_ptp driver since we could use common
7 ptp_qoriq driver in drivers/ptp/ instead.
8
9 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
10 ---
11  drivers/net/ethernet/freescale/sdk_dpaa/Makefile   |   1 -
12  drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h |  10 -
13  .../ethernet/freescale/sdk_dpaa/dpaa_eth_common.c  |  21 --
14  drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ptp.c | 291 ---------------------
15  drivers/net/ethernet/freescale/sdk_dpaa/mac.h      |   3 +-
16  5 files changed, 1 insertion(+), 325 deletions(-)
17  delete mode 100644 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ptp.c
18
19 --- a/drivers/net/ethernet/freescale/sdk_dpaa/Makefile
20 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/Makefile
21 @@ -9,7 +9,6 @@ include $(srctree)/drivers/net/ethernet/
22  ccflags-y += -I$(NET_DPA)
23  
24  obj-$(CONFIG_FSL_SDK_DPAA_ETH) += fsl_mac.o fsl_dpa.o
25 -obj-$(CONFIG_PTP_1588_CLOCK_DPAA) += dpaa_ptp.o
26  
27  fsl_dpa-objs += dpaa_ethtool.o dpaa_eth_sysfs.o dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o
28  ifeq ($(CONFIG_FSL_DPAA_DBG_LOOP),y)
29 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
30 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
31 @@ -646,16 +646,6 @@ static inline void _dpa_assign_wq(struct
32  #define dpa_get_queue_mapping(skb) skb_get_queue_mapping(skb)
33  #endif
34  
35 -#ifdef CONFIG_PTP_1588_CLOCK_DPAA
36 -struct ptp_priv_s {
37 -       struct device_node *node;
38 -       struct platform_device *of_dev;
39 -       struct ptp_clock *clock;
40 -       struct mac_device *mac_dev;
41 -};
42 -extern struct ptp_priv_s ptp_priv;
43 -#endif
44 -
45  static inline void _dpa_bp_free_pf(void *addr)
46  {
47         put_page(virt_to_head_page(addr));
48 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.c
49 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.c
50 @@ -55,10 +55,6 @@
51  /* Size in bytes of the FQ taildrop threshold */
52  #define DPA_FQ_TD              0x200000
53  
54 -#ifdef CONFIG_PTP_1588_CLOCK_DPAA
55 -struct ptp_priv_s ptp_priv;
56 -#endif
57 -
58  static struct dpa_bp *dpa_bp_array[64];
59  
60  int dpa_max_frm;
61 @@ -579,23 +575,6 @@ dpa_mac_probe(struct platform_device *_o
62         }
63  #endif
64  
65 -#ifdef CONFIG_PTP_1588_CLOCK_DPAA
66 -       if ((mac_dev->phy_if != PHY_INTERFACE_MODE_SGMII) ||
67 -           ((mac_dev->phy_if == PHY_INTERFACE_MODE_SGMII) &&
68 -                        (mac_dev->speed == SPEED_1000))) {
69 -               ptp_priv.node = of_parse_phandle(mac_node, "ptp-timer", 0);
70 -               if (ptp_priv.node) {
71 -                       ptp_priv.of_dev = of_find_device_by_node(ptp_priv.node);
72 -                       if (unlikely(ptp_priv.of_dev == NULL)) {
73 -                               dev_err(dpa_dev,
74 -                       "Cannot find device represented by timer_node\n");
75 -                               of_node_put(ptp_priv.node);
76 -                               return ERR_PTR(-EINVAL);
77 -                       }
78 -                       ptp_priv.mac_dev = mac_dev;
79 -               }
80 -       }
81 -#endif
82         return mac_dev;
83  }
84  EXPORT_SYMBOL(dpa_mac_probe);
85 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ptp.c
86 +++ /dev/null
87 @@ -1,291 +0,0 @@
88 -/*
89 - * DPAA Ethernet Driver -- PTP 1588 clock using the dTSEC
90 - *
91 - * Author: Yangbo Lu <yangbo.lu@freescale.com>
92 - *
93 - * Copyright 2014 Freescale Semiconductor, Inc.
94 - *
95 - * This program is free software; you can redistribute it and/or modify it
96 - * under the terms of the GNU General Public License as published by the
97 - * Free Software Foundation; either version 2 of the License, or (at your
98 - * option) any later version.
99 -*/
100 -
101 -#include <linux/device.h>
102 -#include <linux/hrtimer.h>
103 -#include <linux/init.h>
104 -#include <linux/interrupt.h>
105 -#include <linux/kernel.h>
106 -#include <linux/module.h>
107 -#include <linux/of.h>
108 -#include <linux/of_platform.h>
109 -#include <linux/timex.h>
110 -#include <linux/io.h>
111 -
112 -#include <linux/ptp_clock_kernel.h>
113 -
114 -#include "dpaa_eth.h"
115 -#include "mac.h"
116 -
117 -static struct mac_device *mac_dev;
118 -static u32 freqCompensation;
119 -
120 -/* Bit definitions for the TMR_CTRL register */
121 -#define ALM1P                 (1<<31) /* Alarm1 output polarity */
122 -#define ALM2P                 (1<<30) /* Alarm2 output polarity */
123 -#define FS                    (1<<28) /* FIPER start indication */
124 -#define PP1L                  (1<<27) /* Fiper1 pulse loopback mode enabled. */
125 -#define PP2L                  (1<<26) /* Fiper2 pulse loopback mode enabled. */
126 -#define TCLK_PERIOD_SHIFT     (16) /* 1588 timer reference clock period. */
127 -#define TCLK_PERIOD_MASK      (0x3ff)
128 -#define RTPE                  (1<<15) /* Record Tx Timestamp to PAL Enable. */
129 -#define FRD                   (1<<14) /* FIPER Realignment Disable */
130 -#define ESFDP                 (1<<11) /* External Tx/Rx SFD Polarity. */
131 -#define ESFDE                 (1<<10) /* External Tx/Rx SFD Enable. */
132 -#define ETEP2                 (1<<9) /* External trigger 2 edge polarity */
133 -#define ETEP1                 (1<<8) /* External trigger 1 edge polarity */
134 -#define COPH                  (1<<7) /* Generated clock output phase. */
135 -#define CIPH                  (1<<6) /* External oscillator input clock phase */
136 -#define TMSR                  (1<<5) /* Timer soft reset. */
137 -#define BYP                   (1<<3) /* Bypass drift compensated clock */
138 -#define TE                    (1<<2) /* 1588 timer enable. */
139 -#define CKSEL_SHIFT           (0)    /* 1588 Timer reference clock source */
140 -#define CKSEL_MASK            (0x3)
141 -
142 -/* Bit definitions for the TMR_TEVENT register */
143 -#define ETS2                  (1<<25) /* External trigger 2 timestamp sampled */
144 -#define ETS1                  (1<<24) /* External trigger 1 timestamp sampled */
145 -#define ALM2                  (1<<17) /* Current time = alarm time register 2 */
146 -#define ALM1                  (1<<16) /* Current time = alarm time register 1 */
147 -#define PP1                   (1<<7)  /* periodic pulse generated on FIPER1 */
148 -#define PP2                   (1<<6)  /* periodic pulse generated on FIPER2 */
149 -#define PP3                   (1<<5)  /* periodic pulse generated on FIPER3 */
150 -
151 -/* Bit definitions for the TMR_TEMASK register */
152 -#define ETS2EN                (1<<25) /* External trigger 2 timestamp enable */
153 -#define ETS1EN                (1<<24) /* External trigger 1 timestamp enable */
154 -#define ALM2EN                (1<<17) /* Timer ALM2 event enable */
155 -#define ALM1EN                (1<<16) /* Timer ALM1 event enable */
156 -#define PP1EN                 (1<<7) /* Periodic pulse event 1 enable */
157 -#define PP2EN                 (1<<6) /* Periodic pulse event 2 enable */
158 -
159 -/* Bit definitions for the TMR_PEVENT register */
160 -#define TXP2                  (1<<9) /* PTP transmitted timestamp im TXTS2 */
161 -#define TXP1                  (1<<8) /* PTP transmitted timestamp in TXTS1 */
162 -#define RXP                   (1<<0) /* PTP frame has been received */
163 -
164 -/* Bit definitions for the TMR_PEMASK register */
165 -#define TXP2EN                (1<<9) /* Transmit PTP packet event 2 enable */
166 -#define TXP1EN                (1<<8) /* Transmit PTP packet event 1 enable */
167 -#define RXPEN                 (1<<0) /* Receive PTP packet event enable */
168 -
169 -/* Bit definitions for the TMR_STAT register */
170 -#define STAT_VEC_SHIFT        (0) /* Timer general purpose status vector */
171 -#define STAT_VEC_MASK         (0x3f)
172 -
173 -/* Bit definitions for the TMR_PRSC register */
174 -#define PRSC_OCK_SHIFT        (0) /* Output clock division/prescale factor. */
175 -#define PRSC_OCK_MASK         (0xffff)
176 -
177 -
178 -#define N_EXT_TS       2
179 -
180 -static void set_alarm(void)
181 -{
182 -       u64 ns;
183 -
184 -       if (mac_dev->fm_rtc_get_cnt)
185 -               mac_dev->fm_rtc_get_cnt(mac_dev->fm_dev, &ns);
186 -       ns += 1500000000ULL;
187 -       ns = div_u64(ns, 1000000000UL) * 1000000000ULL;
188 -       ns -= DPA_PTP_NOMINAL_FREQ_PERIOD_NS;
189 -       if (mac_dev->fm_rtc_set_alarm)
190 -               mac_dev->fm_rtc_set_alarm(mac_dev->fm_dev, 0, ns);
191 -}
192 -
193 -static void set_fipers(void)
194 -{
195 -       u64 fiper;
196 -
197 -       if (mac_dev->fm_rtc_disable)
198 -               mac_dev->fm_rtc_disable(mac_dev->fm_dev);
199 -
200 -       set_alarm();
201 -       fiper = 1000000000ULL - DPA_PTP_NOMINAL_FREQ_PERIOD_NS;
202 -       if (mac_dev->fm_rtc_set_fiper)
203 -               mac_dev->fm_rtc_set_fiper(mac_dev->fm_dev, 0, fiper);
204 -
205 -       if (mac_dev->fm_rtc_enable)
206 -               mac_dev->fm_rtc_enable(mac_dev->fm_dev);
207 -}
208 -
209 -/* PTP clock operations */
210 -
211 -static int ptp_dpa_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
212 -{
213 -       u64 adj;
214 -       u32 diff, tmr_add;
215 -       int neg_adj = 0;
216 -
217 -       if (ppb < 0) {
218 -               neg_adj = 1;
219 -               ppb = -ppb;
220 -       }
221 -
222 -       tmr_add = freqCompensation;
223 -       adj = tmr_add;
224 -       adj *= ppb;
225 -       diff = div_u64(adj, 1000000000ULL);
226 -
227 -       tmr_add = neg_adj ? tmr_add - diff : tmr_add + diff;
228 -
229 -       if (mac_dev->fm_rtc_set_drift)
230 -               mac_dev->fm_rtc_set_drift(mac_dev->fm_dev, tmr_add);
231 -
232 -       return 0;
233 -}
234 -
235 -static int ptp_dpa_adjtime(struct ptp_clock_info *ptp, s64 delta)
236 -{
237 -       s64 now;
238 -
239 -       if (mac_dev->fm_rtc_get_cnt)
240 -               mac_dev->fm_rtc_get_cnt(mac_dev->fm_dev, &now);
241 -
242 -       now += delta;
243 -
244 -       if (mac_dev->fm_rtc_set_cnt)
245 -               mac_dev->fm_rtc_set_cnt(mac_dev->fm_dev, now);
246 -       set_fipers();
247 -
248 -       return 0;
249 -}
250 -
251 -static int ptp_dpa_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
252 -{
253 -       u64 ns;
254 -       u32 remainder;
255 -
256 -       if (mac_dev->fm_rtc_get_cnt)
257 -               mac_dev->fm_rtc_get_cnt(mac_dev->fm_dev, &ns);
258 -
259 -       ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
260 -       ts->tv_nsec = remainder;
261 -       return 0;
262 -}
263 -
264 -static int ptp_dpa_settime(struct ptp_clock_info *ptp,
265 -                              const struct timespec64 *ts)
266 -{
267 -       u64 ns;
268 -
269 -       ns = ts->tv_sec * 1000000000ULL;
270 -       ns += ts->tv_nsec;
271 -
272 -       if (mac_dev->fm_rtc_set_cnt)
273 -               mac_dev->fm_rtc_set_cnt(mac_dev->fm_dev, ns);
274 -       set_fipers();
275 -       return 0;
276 -}
277 -
278 -static int ptp_dpa_enable(struct ptp_clock_info *ptp,
279 -                             struct ptp_clock_request *rq, int on)
280 -{
281 -       u32 bit;
282 -
283 -       switch (rq->type) {
284 -       case PTP_CLK_REQ_EXTTS:
285 -               switch (rq->extts.index) {
286 -               case 0:
287 -                       bit = ETS1EN;
288 -                       break;
289 -               case 1:
290 -                       bit = ETS2EN;
291 -                       break;
292 -               default:
293 -                       return -EINVAL;
294 -               }
295 -               if (on) {
296 -                       if (mac_dev->fm_rtc_enable_interrupt)
297 -                               mac_dev->fm_rtc_enable_interrupt(
298 -                                       mac_dev->fm_dev, bit);
299 -               } else {
300 -                       if (mac_dev->fm_rtc_disable_interrupt)
301 -                               mac_dev->fm_rtc_disable_interrupt(
302 -                                       mac_dev->fm_dev, bit);
303 -               }
304 -               return 0;
305 -
306 -       case PTP_CLK_REQ_PPS:
307 -               if (on) {
308 -                       if (mac_dev->fm_rtc_enable_interrupt)
309 -                               mac_dev->fm_rtc_enable_interrupt(
310 -                                       mac_dev->fm_dev, PP1EN);
311 -               } else {
312 -                       if (mac_dev->fm_rtc_disable_interrupt)
313 -                               mac_dev->fm_rtc_disable_interrupt(
314 -                                       mac_dev->fm_dev, PP1EN);
315 -               }
316 -               return 0;
317 -
318 -       default:
319 -               break;
320 -       }
321 -
322 -       return -EOPNOTSUPP;
323 -}
324 -
325 -static struct ptp_clock_info ptp_dpa_caps = {
326 -       .owner          = THIS_MODULE,
327 -       .name           = "dpaa clock",
328 -       .max_adj        = 512000,
329 -       .n_alarm        = 0,
330 -       .n_ext_ts       = N_EXT_TS,
331 -       .n_per_out      = 0,
332 -       .pps            = 1,
333 -       .adjfreq        = ptp_dpa_adjfreq,
334 -       .adjtime        = ptp_dpa_adjtime,
335 -       .gettime64      = ptp_dpa_gettime,
336 -       .settime64      = ptp_dpa_settime,
337 -       .enable         = ptp_dpa_enable,
338 -};
339 -
340 -static int __init __cold dpa_ptp_load(void)
341 -{
342 -       struct device *ptp_dev;
343 -       struct timespec64 now;
344 -       struct ptp_clock *clock = ptp_priv.clock;
345 -       int dpa_phc_index;
346 -       int err;
347 -
348 -       if (!(ptp_priv.of_dev && ptp_priv.mac_dev))
349 -               return -ENODEV;
350 -
351 -       ptp_dev = &ptp_priv.of_dev->dev;
352 -       mac_dev = ptp_priv.mac_dev;
353 -
354 -       if (mac_dev->fm_rtc_get_drift)
355 -               mac_dev->fm_rtc_get_drift(mac_dev->fm_dev, &freqCompensation);
356 -
357 -       getnstimeofday64(&now);
358 -       ptp_dpa_settime(&ptp_dpa_caps, &now);
359 -
360 -       clock = ptp_clock_register(&ptp_dpa_caps, ptp_dev);
361 -       if (IS_ERR(clock)) {
362 -               err = PTR_ERR(clock);
363 -               return err;
364 -       }
365 -       dpa_phc_index = ptp_clock_index(clock);
366 -       return 0;
367 -}
368 -module_init(dpa_ptp_load);
369 -
370 -static void __exit __cold dpa_ptp_unload(void)
371 -{
372 -       struct ptp_clock *clock = ptp_priv.clock;
373 -
374 -       if (mac_dev->fm_rtc_disable_interrupt)
375 -               mac_dev->fm_rtc_disable_interrupt(mac_dev->fm_dev, 0xffffffff);
376 -       ptp_clock_unregister(clock);
377 -}
378 -module_exit(dpa_ptp_unload);
379 --- a/drivers/net/ethernet/freescale/sdk_dpaa/mac.h
380 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/mac.h
381 @@ -97,10 +97,9 @@ struct mac_device {
382         int (*fm_rtc_set_alarm)(struct fm *fm_dev, uint32_t id, uint64_t time);
383         int (*fm_rtc_set_fiper)(struct fm *fm_dev, uint32_t id,
384                                 uint64_t fiper);
385 -#ifdef CONFIG_PTP_1588_CLOCK_DPAA
386         int (*fm_rtc_enable_interrupt)(struct fm *fm_dev, uint32_t events);
387         int (*fm_rtc_disable_interrupt)(struct fm *fm_dev, uint32_t events);
388 -#endif
389 +
390         int (*set_wol)(struct fm_port *port, struct fm_mac_dev *fm_mac_dev,
391                         bool en);
392         int (*dump_mac_regs)(struct mac_device *h_mac, char *buf, int nn);