kernel: bump 4.14 to 4.14.125 (FS#2305 FS#2297)
[oweals/openwrt.git] / target / linux / layerscape / patches-4.14 / 712-etsec-support-layerscape.patch
1 From f0f6e88696957d376d8875f675c1caf75a33fd67 Mon Sep 17 00:00:00 2001
2 From: Biwen Li <biwen.li@nxp.com>
3 Date: Wed, 17 Apr 2019 18:58:34 +0800
4 Subject: [PATCH] etsec: support layerscape
5
6 This is an integrated patch of etsec for layerscape
7
8 Signed-off-by: Biwen Li <biwen.li@nxp.com>
9 Signed-off-by: David S. Miller <davem@davemloft.net>
10 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
11 ---
12  drivers/net/ethernet/freescale/gianfar.h      |  3 ---
13  .../net/ethernet/freescale/gianfar_ethtool.c  | 23 +++++++++++++++----
14  2 files changed, 18 insertions(+), 8 deletions(-)
15
16 --- a/drivers/net/ethernet/freescale/gianfar.h
17 +++ b/drivers/net/ethernet/freescale/gianfar.h
18 @@ -1372,7 +1372,4 @@ struct filer_table {
19         struct gfar_filer_entry fe[MAX_FILER_CACHE_IDX + 20];
20  };
21  
22 -/* The gianfar_ptp module will set this variable */
23 -extern int gfar_phc_index;
24 -
25  #endif /* __GIANFAR_H */
26 --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
27 +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
28 @@ -41,6 +41,8 @@
29  #include <linux/phy.h>
30  #include <linux/sort.h>
31  #include <linux/if_vlan.h>
32 +#include <linux/of_platform.h>
33 +#include <linux/fsl/ptp_qoriq.h>
34  
35  #include "gianfar.h"
36  
37 @@ -1509,24 +1511,35 @@ static int gfar_get_nfc(struct net_devic
38         return ret;
39  }
40  
41 -int gfar_phc_index = -1;
42 -EXPORT_SYMBOL(gfar_phc_index);
43 -
44  static int gfar_get_ts_info(struct net_device *dev,
45                             struct ethtool_ts_info *info)
46  {
47         struct gfar_private *priv = netdev_priv(dev);
48 +       struct platform_device *ptp_dev;
49 +       struct device_node *ptp_node;
50 +       struct qoriq_ptp *ptp = NULL;
51 +
52 +       info->phc_index = -1;
53  
54         if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)) {
55                 info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
56                                         SOF_TIMESTAMPING_SOFTWARE;
57 -               info->phc_index = -1;
58                 return 0;
59         }
60 +
61 +       ptp_node = of_find_compatible_node(NULL, NULL, "fsl,etsec-ptp");
62 +       if (ptp_node) {
63 +               ptp_dev = of_find_device_by_node(ptp_node);
64 +               if (ptp_dev)
65 +                       ptp = platform_get_drvdata(ptp_dev);
66 +       }
67 +
68 +       if (ptp)
69 +               info->phc_index = ptp->phc_index;
70 +
71         info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
72                                 SOF_TIMESTAMPING_RX_HARDWARE |
73                                 SOF_TIMESTAMPING_RAW_HARDWARE;
74 -       info->phc_index = gfar_phc_index;
75         info->tx_types = (1 << HWTSTAMP_TX_OFF) |
76                          (1 << HWTSTAMP_TX_ON);
77         info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |