Rebased from upstream / out of band repository.
[librecmc/librecmc.git] / target / linux / generic / hack-4.19 / 773-bgmac-add-srab-switch.patch
1 From 3cb240533ab787899dc7f17aa7d6c5b4810e2e58 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Fri, 7 Jul 2017 17:26:01 +0200
4 Subject: bcm53xx: bgmac: use srab switch driver
5
6 use the srab switch driver on these SoCs.
7
8 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
9 ---
10  drivers/net/ethernet/broadcom/bgmac-bcma.c |  1 +
11  drivers/net/ethernet/broadcom/bgmac.c      | 24 ++++++++++++++++++++++++
12  drivers/net/ethernet/broadcom/bgmac.h      |  4 ++++
13  3 files changed, 29 insertions(+)
14
15 --- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
16 +++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
17 @@ -268,6 +268,7 @@ static int bgmac_probe(struct bcma_devic
18                 bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
19                 bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
20                 bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
21 +               bgmac->feature_flags |= BGMAC_FEAT_SRAB;
22                 break;
23         default:
24                 bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
25 --- a/drivers/net/ethernet/broadcom/bgmac.c
26 +++ b/drivers/net/ethernet/broadcom/bgmac.c
27 @@ -12,6 +12,7 @@
28  #include <linux/bcma/bcma.h>
29  #include <linux/etherdevice.h>
30  #include <linux/interrupt.h>
31 +#include <linux/platform_data/b53.h>
32  #include <linux/bcm47xx_nvram.h>
33  #include <linux/phy.h>
34  #include <linux/phy_fixed.h>
35 @@ -1409,6 +1410,17 @@ static const struct ethtool_ops bgmac_et
36         .set_link_ksettings     = phy_ethtool_set_link_ksettings,
37  };
38  
39 +static struct b53_platform_data bgmac_b53_pdata = {
40 +};
41 +
42 +static struct platform_device bgmac_b53_dev = {
43 +       .name           = "b53-srab-switch",
44 +       .id             = -1,
45 +       .dev            = {
46 +               .platform_data = &bgmac_b53_pdata,
47 +       },
48 +};
49 +
50  /**************************************************
51   * MII
52   **************************************************/
53 @@ -1540,6 +1552,14 @@ int bgmac_enet_probe(struct bgmac *bgmac
54         net_dev->hw_features = net_dev->features;
55         net_dev->vlan_features = net_dev->features;
56  
57 +       if ((bgmac->feature_flags & BGMAC_FEAT_SRAB) && !bgmac_b53_pdata.regs) {
58 +               bgmac_b53_pdata.regs = ioremap_nocache(0x18007000, 0x1000);
59 +
60 +               err = platform_device_register(&bgmac_b53_dev);
61 +               if (!err)
62 +                       bgmac->b53_device = &bgmac_b53_dev;
63 +       }
64 +
65         err = register_netdev(bgmac->net_dev);
66         if (err) {
67                 dev_err(bgmac->dev, "Cannot register net device\n");
68 @@ -1562,6 +1582,10 @@ EXPORT_SYMBOL_GPL(bgmac_enet_probe);
69  
70  void bgmac_enet_remove(struct bgmac *bgmac)
71  {
72 +       if (bgmac->b53_device)
73 +               platform_device_unregister(&bgmac_b53_dev);
74 +       bgmac->b53_device = NULL;
75 +
76         unregister_netdev(bgmac->net_dev);
77         phy_disconnect(bgmac->net_dev->phydev);
78         netif_napi_del(&bgmac->napi);
79 --- a/drivers/net/ethernet/broadcom/bgmac.h
80 +++ b/drivers/net/ethernet/broadcom/bgmac.h
81 @@ -427,6 +427,7 @@
82  #define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII        BIT(18)
83  #define BGMAC_FEAT_CC7_IF_TYPE_RGMII   BIT(19)
84  #define BGMAC_FEAT_IDM_MASK            BIT(20)
85 +#define BGMAC_FEAT_SRAB                        BIT(21)
86  
87  struct bgmac_slot_info {
88         union {
89 @@ -532,6 +533,9 @@ struct bgmac {
90         void (*cmn_maskset32)(struct bgmac *bgmac, u16 offset, u32 mask,
91                               u32 set);
92         int (*phy_connect)(struct bgmac *bgmac);
93 +
94 +       /* platform device for associated switch */
95 +       struct platform_device *b53_device;
96  };
97  
98  struct bgmac *bgmac_alloc(struct device *dev);