kernel: update bgmac by adding Florian's upstream changes
[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 @@ -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 <linux/bcm47xx_nvram.h>
13
14 static const struct bcma_device_id bgmac_bcma_tbl[] = {
15 @@ -1680,6 +1681,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 @@ -1825,6 +1837,14 @@ 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 (bgmac_is_bcm4707_family(bgmac) && !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 bgmac_err(bgmac, "Cannot register net device\n");
48 @@ -1851,6 +1871,10 @@ static void bgmac_remove(struct bcma_dev
49 {
50 struct bgmac *bgmac = bcma_get_drvdata(core);
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 bgmac_mii_unregister(bgmac);
58 netif_napi_del(&bgmac->napi);
59 --- a/drivers/net/ethernet/broadcom/bgmac.h
60 +++ b/drivers/net/ethernet/broadcom/bgmac.h
61 @@ -462,6 +462,9 @@ struct bgmac {
62 bool has_robosw;
63
64 bool loopback;
65 +
66 + /* platform device for associated switch */
67 + struct platform_device *b53_device;
68 };
69
70 static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)