52fc252447c90b8329337292513638d11e98b1b5
[openwrt/openwrt.git] / target / linux / generic / pending-3.18 / 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 @@ -17,6 +17,7 @@
8 #include <linux/phy_fixed.h>
9 #include <linux/interrupt.h>
10 #include <linux/dma-mapping.h>
11 +#include <linux/platform_data/b53.h>
12 #include <bcm47xx_nvram.h>
13
14 static const struct bcma_device_id bgmac_bcma_tbl[] = {
15 @@ -1538,6 +1539,17 @@ static void bgmac_mii_unregister(struct
16 mdiobus_free(mii_bus);
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 * BCMA bus ops
32 **************************************************/
33 @@ -1666,6 +1678,16 @@ static int bgmac_probe(struct bcma_devic
34 net_dev->hw_features = net_dev->features;
35 net_dev->vlan_features = net_dev->features;
36
37 + if ((ci->id == BCMA_CHIP_ID_BCM4707 ||
38 + ci->id == BCMA_CHIP_ID_BCM53018) &&
39 + !bgmac_b53_pdata.regs) {
40 + bgmac_b53_pdata.regs = ioremap_nocache(0x18007000, 0x1000);
41 +
42 + err = platform_device_register(&bgmac_b53_dev);
43 + if (!err)
44 + bgmac->b53_device = &bgmac_b53_dev;
45 + }
46 +
47 err = register_netdev(bgmac->net_dev);
48 if (err) {
49 bgmac_err(bgmac, "Cannot register net device\n");
50 @@ -1692,6 +1714,10 @@ static void bgmac_remove(struct bcma_dev
51 {
52 struct bgmac *bgmac = bcma_get_drvdata(core);
53
54 + if (bgmac->b53_device)
55 + platform_device_unregister(&bgmac_b53_dev);
56 + bgmac->b53_device = NULL;
57 +
58 unregister_netdev(bgmac->net_dev);
59 bgmac_mii_unregister(bgmac);
60 netif_napi_del(&bgmac->napi);
61 --- a/drivers/net/ethernet/broadcom/bgmac.h
62 +++ b/drivers/net/ethernet/broadcom/bgmac.h
63 @@ -462,6 +462,9 @@ struct bgmac {
64 bool has_robosw;
65
66 bool loopback;
67 +
68 + /* platform device for associated switch */
69 + struct platform_device *b53_device;
70 };
71
72 static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)