5e358c38c1d0b4a338ee98d123449438eefe8a24
[openwrt/openwrt.git] / target / linux / generic / patches-4.4 / 773-bgmac-add-srab-switch.patch
1 Register switch connected to srab
2
3 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
4
5 --- a/drivers/net/ethernet/broadcom/bgmac.c
6 +++ b/drivers/net/ethernet/broadcom/bgmac.c
7 @@ -11,6 +11,7 @@
8
9 #include <linux/bcma/bcma.h>
10 #include <linux/etherdevice.h>
11 +#include <linux/platform_data/b53.h>
12 #include <linux/bcm47xx_nvram.h>
13 #include "bgmac.h"
14
15 @@ -1403,6 +1404,17 @@ static const struct ethtool_ops bgmac_et
16 .get_drvinfo = bgmac_get_drvinfo,
17 };
18
19 +static struct b53_platform_data bgmac_b53_pdata = {
20 +};
21 +
22 +static struct platform_device bgmac_b53_dev = {
23 + .name = "b53-srab-switch",
24 + .id = -1,
25 + .dev = {
26 + .platform_data = &bgmac_b53_pdata,
27 + },
28 +};
29 +
30 /**************************************************
31 * MII
32 **************************************************/
33 @@ -1549,6 +1561,14 @@ int bgmac_enet_probe(struct bgmac *bgmac
34 net_dev->hw_features = net_dev->features;
35 net_dev->vlan_features = net_dev->features;
36
37 + if ((bgmac->feature_flags & BGMAC_FEAT_SRAB) && !bgmac_b53_pdata.regs) {
38 + bgmac_b53_pdata.regs = ioremap_nocache(0x18007000, 0x1000);
39 +
40 + err = platform_device_register(&bgmac_b53_dev);
41 + if (!err)
42 + bgmac->b53_device = &bgmac_b53_dev;
43 + }
44 +
45 err = register_netdev(bgmac->net_dev);
46 if (err) {
47 dev_err(bgmac->dev, "Cannot register net device\n");
48 @@ -1571,6 +1591,10 @@ EXPORT_SYMBOL_GPL(bgmac_enet_probe);
49
50 void bgmac_enet_remove(struct bgmac *bgmac)
51 {
52 + if (bgmac->b53_device)
53 + platform_device_unregister(&bgmac_b53_dev);
54 + bgmac->b53_device = NULL;
55 +
56 unregister_netdev(bgmac->net_dev);
57 phy_disconnect(bgmac->net_dev->phydev);
58 netif_napi_del(&bgmac->napi);
59 --- a/drivers/net/ethernet/broadcom/bgmac.h
60 +++ b/drivers/net/ethernet/broadcom/bgmac.h
61 @@ -409,6 +409,7 @@
62 #define BGMAC_FEAT_CC4_IF_SW_TYPE BIT(17)
63 #define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII BIT(18)
64 #define BGMAC_FEAT_CC7_IF_TYPE_RGMII BIT(19)
65 +#define BGMAC_FEAT_SRAB BIT(20)
66
67 struct bgmac_slot_info {
68 union {
69 @@ -513,6 +514,9 @@ struct bgmac {
70 u32 (*get_bus_clock)(struct bgmac *bgmac);
71 void (*cmn_maskset32)(struct bgmac *bgmac, u16 offset, u32 mask,
72 u32 set);
73 +
74 + /* platform device for associated switch */
75 + struct platform_device *b53_device;
76 };
77
78 struct bgmac *bgmac_alloc(struct device *dev);
79 --- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
80 +++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
81 @@ -230,6 +230,7 @@ static int bgmac_probe(struct bcma_devic
82 bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
83 bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
84 bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
85 + bgmac->feature_flags |= BGMAC_FEAT_SRAB;
86 break;
87 case BCMA_CHIP_ID_BCM53573:
88 bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;