kernel: bgmac: backport patch switching to feature_flags
[openwrt/staging/yousong.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 @@ -1408,6 +1409,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 @@ -1656,6 +1668,7 @@ static int bgmac_probe(struct bcma_devic
34 bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
35 bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
36 bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
37 + bgmac->feature_flags |= BGMAC_FEAT_SRAB;
38 break;
39 default:
40 bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
41 @@ -1703,6 +1716,14 @@ static int bgmac_probe(struct bcma_devic
42 net_dev->hw_features = net_dev->features;
43 net_dev->vlan_features = net_dev->features;
44
45 + if ((bgmac->feature_flags & BGMAC_FEAT_SRAB) && !bgmac_b53_pdata.regs) {
46 + bgmac_b53_pdata.regs = ioremap_nocache(0x18007000, 0x1000);
47 +
48 + err = platform_device_register(&bgmac_b53_dev);
49 + if (!err)
50 + bgmac->b53_device = &bgmac_b53_dev;
51 + }
52 +
53 err = register_netdev(bgmac->net_dev);
54 if (err) {
55 dev_err(bgmac->dev, "Cannot register net device\n");
56 @@ -1730,6 +1751,10 @@ static void bgmac_remove(struct bcma_dev
57 {
58 struct bgmac *bgmac = bcma_get_drvdata(core);
59
60 + if (bgmac->b53_device)
61 + platform_device_unregister(&bgmac_b53_dev);
62 + bgmac->b53_device = NULL;
63 +
64 unregister_netdev(bgmac->net_dev);
65 phy_disconnect(bgmac->net_dev->phydev);
66 bcma_mdio_mii_unregister(bgmac->mii_bus);
67 --- a/drivers/net/ethernet/broadcom/bgmac.h
68 +++ b/drivers/net/ethernet/broadcom/bgmac.h
69 @@ -392,6 +392,7 @@
70 #define BGMAC_FEAT_NO_CLR_MIB BIT(13)
71 #define BGMAC_FEAT_FORCE_SPEED_2500 BIT(14)
72 #define BGMAC_FEAT_CMDCFG_SR_REV4 BIT(15)
73 +#define BGMAC_FEAT_SRAB BIT(16)
74
75 struct bgmac_slot_info {
76 union {
77 @@ -473,6 +474,9 @@ struct bgmac {
78 bool has_robosw;
79
80 bool loopback;
81 +
82 + /* platform device for associated switch */
83 + struct platform_device *b53_device;
84 };
85
86 struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);