[brcm63xx] add preliminary support for 3.6 kernel
[openwrt.git] / target / linux / brcm63xx / patches-3.6 / 418-bcm63xx_enet-store-the-number-of-ports-instead-of-ha.patch
1 From efe31ec8fca92162fc21630611971345014a81a0 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Tue, 10 Jul 2012 10:39:30 +0200
4 Subject: [PATCH 33/84] bcm63xx_enet: store the number of ports instead of hardcoding them
5
6 This will be needed for devices with a different number of ports
7 ---
8  arch/mips/bcm63xx/dev-enet.c                       |    2 ++
9  .../include/asm/mach-bcm63xx/bcm63xx_dev_enet.h    |    2 ++
10  drivers/net/ethernet/broadcom/bcm63xx_enet.c       |    9 +++++----
11  drivers/net/ethernet/broadcom/bcm63xx_enet.h       |    1 +
12  4 files changed, 10 insertions(+), 4 deletions(-)
13
14 --- a/arch/mips/bcm63xx/dev-enet.c
15 +++ b/arch/mips/bcm63xx/dev-enet.c
16 @@ -239,6 +239,8 @@ bcm63xx_enetsw_register(const struct bcm
17  
18         memcpy(bcm63xx_enetsw_device.dev.platform_data, pd, sizeof (*pd));
19  
20 +       enetsw_pd.num_ports = ENETSW_PORTS_6368;
21 +
22         ret = platform_device_register(&bcm63xx_enetsw_device);
23         if (ret)
24                 return ret;
25 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
26 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
27 @@ -43,6 +43,7 @@ struct bcm63xx_enet_platform_data {
28   * on board ethernet switch platform data
29   */
30  #define ENETSW_MAX_PORT        6
31 +#define ENETSW_PORTS_6368 6 /* 4 FE PHY + 2 RGMII */
32  
33  struct bcm63xx_enetsw_port {
34         int             used;
35 @@ -58,6 +59,7 @@ struct bcm63xx_enetsw_port {
36  
37  struct bcm63xx_enetsw_platform_data {
38         char mac_addr[ETH_ALEN];
39 +       int num_ports;
40         struct bcm63xx_enetsw_port used_ports[ENETSW_MAX_PORT];
41  };
42  
43 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
44 +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
45 @@ -2041,7 +2041,7 @@ static void swphy_poll_timer(unsigned lo
46         struct bcm_enet_priv *priv = (struct bcm_enet_priv *)data;
47         unsigned int i;
48  
49 -       for (i = 0; i < ARRAY_SIZE(priv->used_ports); i++) {
50 +       for (i = 0; i < priv->num_ports; i++) {
51                 struct bcm63xx_enetsw_port *port;
52                 int val, j, up, advertise, lpa, lpa2, speed, duplex, media;
53                 u8 override;
54 @@ -2207,7 +2207,7 @@ static int bcm_enetsw_open(struct net_de
55         priv->rx_curr_desc = 0;
56  
57         /* disable all ports */
58 -       for (i = 0; i < 6; i++) {
59 +       for (i = 0; i < priv->num_ports; i++) {
60                 enetsw_writeb(priv, ENETSW_PORTOV_ENABLE_MASK,
61                               ENETSW_PORTOV_REG(i));
62                 enetsw_writeb(priv, ENETSW_PTCTRL_RXDIS_MASK |
63 @@ -2303,7 +2303,7 @@ static int bcm_enetsw_open(struct net_de
64         /*
65          * apply override config for bypass_link ports here.
66          */
67 -       for (i = 0; i < ARRAY_SIZE(priv->used_ports); i++) {
68 +       for (i = 0; i < priv->num_ports; i++) {
69                 struct bcm63xx_enetsw_port *port;
70                 u8 override;
71                 port = &priv->used_ports[i];
72 @@ -2447,7 +2447,7 @@ static int bcm_enetsw_phy_is_external(st
73  {
74         int i;
75  
76 -       for (i = 0; i < (int)ARRAY_SIZE(priv->used_ports); ++i) {
77 +       for (i = 0; i < priv->num_ports; ++i) {
78                 if (!priv->used_ports[i].used)
79                         continue;
80                 if (priv->used_ports[i].phy_id == phy_id)
81 @@ -2735,6 +2735,7 @@ static int __devinit bcm_enetsw_probe(st
82                 memcpy(dev->dev_addr, pd->mac_addr, ETH_ALEN);
83                 memcpy(priv->used_ports, pd->used_ports,
84                        sizeof (pd->used_ports));
85 +               priv->num_ports = pd->num_ports;
86         }
87  
88         ret = compute_hw_mtu(priv, dev->mtu);
89 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.h
90 +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.h
91 @@ -354,6 +354,7 @@ struct bcm_enet_priv {
92         unsigned int hw_mtu;
93  
94         /* port mapping for switch devices */
95 +       int num_ports;
96         struct bcm63xx_enetsw_port used_ports[ENETSW_MAX_PORT];
97         int sw_port_link[ENETSW_MAX_PORT];
98