1 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.h
2 +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.h
3 @@ -336,6 +336,9 @@ struct bcm_enet_priv {
4 struct bcm63xx_enetsw_port used_ports[ENETSW_MAX_PORT];
5 int sw_port_link[ENETSW_MAX_PORT];
7 + /* platform device for associated switch */
8 + struct platform_device *b53_device;
10 /* used to poll switch port state */
11 struct timer_list swphy_poll;
12 spinlock_t enetsw_mdio_lock;
13 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
14 +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
16 #include <linux/dma-mapping.h>
17 #include <linux/platform_device.h>
18 #include <linux/if_vlan.h>
19 +#include <linux/platform_data/b53.h>
21 #include <bcm63xx_dev_enet.h>
22 #include "bcm63xx_enet.h"
23 @@ -1983,7 +1984,8 @@ static int bcm_enet_remove(struct platfo
27 -struct platform_driver bcm63xx_enet_driver = {
29 +static struct platform_driver bcm63xx_enet_driver = {
30 .probe = bcm_enet_probe,
31 .remove = bcm_enet_remove,
33 @@ -1992,6 +1994,42 @@ struct platform_driver bcm63xx_enet_driv
37 +struct b53_platform_data bcm63xx_b53_pdata = {
42 +struct platform_device bcm63xx_b53_dev = {
43 + .name = "b53-switch",
46 + .platform_data = &bcm63xx_b53_pdata,
50 +static int bcmenet_switch_register(struct bcm_enet_priv *priv, u16 port_mask)
54 + bcm63xx_b53_pdata.regs = priv->base;
55 + bcm63xx_b53_pdata.enabled_ports = port_mask;
56 + bcm63xx_b53_pdata.alias = priv->net_dev->name;
58 + ret = platform_device_register(&bcm63xx_b53_dev);
60 + priv->b53_device = &bcm63xx_b53_dev;
65 +static void bcmenet_switch_unregister(struct bcm_enet_priv *priv)
67 + if (priv->b53_device)
68 + platform_device_unregister(&bcm63xx_b53_dev);
70 + priv->b53_device = NULL;
74 * switch mii access callbacks
76 @@ -2245,29 +2283,6 @@ static int bcm_enetsw_open(struct net_de
77 enetsw_writeb(priv, rgmii_ctrl, ENETSW_RGMII_CTRL_REG(i));
81 - val = enetsw_readb(priv, ENETSW_GMCR_REG);
82 - val |= ENETSW_GMCR_RST_MIB_MASK;
83 - enetsw_writeb(priv, val, ENETSW_GMCR_REG);
85 - val &= ~ENETSW_GMCR_RST_MIB_MASK;
86 - enetsw_writeb(priv, val, ENETSW_GMCR_REG);
89 - /* force CPU port state */
90 - val = enetsw_readb(priv, ENETSW_IMPOV_REG);
91 - val |= ENETSW_IMPOV_FORCE_MASK | ENETSW_IMPOV_LINKUP_MASK;
92 - enetsw_writeb(priv, val, ENETSW_IMPOV_REG);
94 - /* enable switch forward engine */
95 - val = enetsw_readb(priv, ENETSW_SWMODE_REG);
96 - val |= ENETSW_SWMODE_FWD_EN_MASK;
97 - enetsw_writeb(priv, val, ENETSW_SWMODE_REG);
99 - /* enable jumbo on all ports */
100 - enetsw_writel(priv, 0x1ff, ENETSW_JMBCTL_PORT_REG);
101 - enetsw_writew(priv, 9728, ENETSW_JMBCTL_MAXSIZE_REG);
103 /* initialize flow control buffer allocation */
104 enet_dma_writel(priv, ENETDMA_BUFALLOC_FORCE_MASK | 0,
105 ENETDMA_BUFALLOC_REG(priv->rx_chan));
106 @@ -2727,6 +2742,9 @@ static int bcm_enetsw_probe(struct platf
107 struct bcm63xx_enetsw_platform_data *pd;
108 struct resource *res_mem;
109 int ret, irq_rx, irq_tx;
110 + unsigned i, num_ports = 0;
111 + u16 port_mask = BIT(8);
114 /* stop if shared driver failed, assume driver->probe will be
115 * called in the same order we register devices (correct ?)
116 @@ -2816,6 +2834,43 @@ static int bcm_enetsw_probe(struct platf
121 + val = enetsw_readb(priv, ENETSW_GMCR_REG);
122 + val |= ENETSW_GMCR_RST_MIB_MASK;
123 + enetsw_writeb(priv, val, ENETSW_GMCR_REG);
125 + val &= ~ENETSW_GMCR_RST_MIB_MASK;
126 + enetsw_writeb(priv, val, ENETSW_GMCR_REG);
129 + /* force CPU port state */
130 + val = enetsw_readb(priv, ENETSW_IMPOV_REG);
131 + val |= ENETSW_IMPOV_FORCE_MASK | ENETSW_IMPOV_LINKUP_MASK;
132 + enetsw_writeb(priv, val, ENETSW_IMPOV_REG);
134 + /* enable switch forward engine */
135 + val = enetsw_readb(priv, ENETSW_SWMODE_REG);
136 + val |= ENETSW_SWMODE_FWD_EN_MASK;
137 + enetsw_writeb(priv, val, ENETSW_SWMODE_REG);
139 + /* enable jumbo on all ports */
140 + enetsw_writel(priv, 0x1ff, ENETSW_JMBCTL_PORT_REG);
141 + enetsw_writew(priv, 9728, ENETSW_JMBCTL_MAXSIZE_REG);
143 + for (i = 0; i < priv->num_ports; i++) {
144 + struct bcm63xx_enetsw_port *port = &priv->used_ports[i];
150 + port_mask |= BIT(i);
153 + /* only register if there is more than one external port */
155 + bcmenet_switch_register(priv, port_mask);
160 @@ -2844,6 +2899,9 @@ static int bcm_enetsw_remove(struct plat
161 priv = netdev_priv(dev);
162 unregister_netdev(dev);
164 + /* remove switch */
165 + bcmenet_switch_unregister(priv);
167 /* release device resources */
169 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);