cb498154a4e48c2c8e815a7b970dfa68c4f3c7e1
[openwrt/staging/wigyori.git] / target / linux / bcm53xx / patches-3.10 / 205-bgmac-add-srab-switch.patch
1 --- a/drivers/net/ethernet/broadcom/bgmac.c
2 +++ b/drivers/net/ethernet/broadcom/bgmac.c
3 @@ -16,6 +16,7 @@
4 #include <linux/phy.h>
5 #include <linux/interrupt.h>
6 #include <linux/dma-mapping.h>
7 +#include <linux/platform_data/b53.h>
8 #ifdef CONFIG_BCM47XX
9 #include <bcm47xx_nvram.h>
10 #else
11 @@ -1424,6 +1425,17 @@ static void bgmac_mii_unregister(struct
12 mdiobus_free(mii_bus);
13 }
14
15 +static struct b53_platform_data bgmac_b53_pdata = {
16 +};
17 +
18 +static struct platform_device bgmac_b53_dev = {
19 + .name = "b53-srab-switch",
20 + .id = -1,
21 + .dev = {
22 + .platform_data = &bgmac_b53_pdata,
23 + },
24 +};
25 +
26 /**************************************************
27 * BCMA bus ops
28 **************************************************/
29 @@ -1523,6 +1535,16 @@ static int bgmac_probe(struct bcma_devic
30 goto err_dma_free;
31 }
32
33 + if (core->id.id != BCMA_CHIP_ID_BCM4707 &&
34 + core->id.id != BCMA_CHIP_ID_BCM53018 &&
35 + !bgmac_b53_pdata.regs) {
36 + bgmac_b53_pdata.regs = ioremap_nocache(0x18007000, 0x1000);
37 +
38 + err = platform_device_register(&bgmac_b53_dev);
39 + if (!err)
40 + bgmac->b53_device = &bgmac_b53_dev;
41 + }
42 +
43 err = register_netdev(bgmac->net_dev);
44 if (err) {
45 bgmac_err(bgmac, "Cannot register net device\n");
46 @@ -1552,6 +1574,10 @@ static void bgmac_remove(struct bcma_dev
47 {
48 struct bgmac *bgmac = bcma_get_drvdata(core);
49
50 + if (bgmac->b53_device)
51 + platform_device_unregister(&bgmac_b53_dev);
52 + bgmac->b53_device = NULL;
53 +
54 netif_napi_del(&bgmac->napi);
55 unregister_netdev(bgmac->net_dev);
56 bgmac_mii_unregister(bgmac);
57 --- a/drivers/net/ethernet/broadcom/bgmac.h
58 +++ b/drivers/net/ethernet/broadcom/bgmac.h
59 @@ -430,6 +430,9 @@ struct bgmac {
60 bool has_robosw;
61
62 bool loopback;
63 +
64 + /* platform device for associated switch */
65 + struct platform_device *b53_device;
66 };
67
68 static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)