e6ad0a51dc585afa9209a91ac1f6adc3af20cebc
[openwrt/staging/wigyori.git] / target / linux / generic / hack-4.9 / 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 @@ -236,6 +236,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 case BCMA_CHIP_ID_BCM53573:
24 bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
25 --- a/drivers/net/ethernet/broadcom/bgmac.c
26 +++ b/drivers/net/ethernet/broadcom/bgmac.c
27 @@ -11,6 +11,7 @@
28
29 #include <linux/bcma/bcma.h>
30 #include <linux/etherdevice.h>
31 +#include <linux/platform_data/b53.h>
32 #include <linux/bcm47xx_nvram.h>
33 #include "bgmac.h"
34
35 @@ -1387,6 +1388,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 @@ -1533,6 +1545,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 @@ -1555,6 +1575,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 @@ -409,6 +409,7 @@
82 #define BGMAC_FEAT_CC4_IF_SW_TYPE BIT(17)
83 #define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII BIT(18)
84 #define BGMAC_FEAT_CC7_IF_TYPE_RGMII BIT(19)
85 +#define BGMAC_FEAT_SRAB BIT(20)
86
87 struct bgmac_slot_info {
88 union {
89 @@ -513,6 +514,9 @@ struct bgmac {
90 u32 (*get_bus_clock)(struct bgmac *bgmac);
91 void (*cmn_maskset32)(struct bgmac *bgmac, u16 offset, u32 mask,
92 u32 set);
93 +
94 + /* platform device for associated switch */
95 + struct platform_device *b53_device;
96 };
97
98 struct bgmac *bgmac_alloc(struct device *dev);