bcm63xx: add support for linux 3.8
[openwrt.git] / target / linux / brcm63xx / patches-3.8 / 424-MIPS-BCM63XX-add-support-for-BCM6328-in-bcm_enetsw.patch
1 From a1bd0479a1ddac4f21afd4ebfe8f667b9fa5eff2 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Tue, 14 Jun 2011 21:14:39 +0200
4 Subject: [PATCH 50/72] MIPS: BCM63XX: add support for BCM6328 in bcm_enetsw
5
6 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
7 ---
8  arch/mips/bcm63xx/clk.c                               |   15 +++++++++++----
9  arch/mips/bcm63xx/dev-enet.c                          |    9 ++++++---
10  arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h |    1 +
11  3 files changed, 18 insertions(+), 7 deletions(-)
12
13 --- a/arch/mips/bcm63xx/clk.c
14 +++ b/arch/mips/bcm63xx/clk.c
15 @@ -119,11 +119,18 @@ static struct clk clk_ephy = {
16   */
17  static void enetsw_set(struct clk *clk, int enable)
18  {
19 -       if (!BCMCPU_IS_6368())
20 +       u32 mask;
21 +
22 +       if (!BCMCPU_IS_6328() && !BCMCPU_IS_6368())
23                 return;
24 -       bcm_hwclock_set(CKCTL_6368_ROBOSW_EN |
25 -                       CKCTL_6368_SWPKT_USB_EN |
26 -                       CKCTL_6368_SWPKT_SAR_EN, enable);
27 +
28 +       if (BCMCPU_IS_6328())
29 +               mask = CKCTL_6328_ROBOSW_EN;
30 +       else
31 +               mask = CKCTL_6368_ROBOSW_EN | CKCTL_6368_SWPKT_USB_EN |
32 +                       CKCTL_6368_SWPKT_SAR_EN;
33 +
34 +       bcm_hwclock_set(mask, enable);
35         if (enable) {
36                 /* reset switch core afer clock change */
37                 bcm63xx_core_set_reset(BCM63XX_RESET_ENETSW, 1);
38 --- a/arch/mips/bcm63xx/dev-enet.c
39 +++ b/arch/mips/bcm63xx/dev-enet.c
40 @@ -141,7 +141,7 @@ static int __init register_shared(void)
41         shared_res[0].end = shared_res[0].start;
42         shared_res[0].end += (RSET_ENETDMA_SIZE)  - 1;
43  
44 -       if (BCMCPU_IS_6368())
45 +       if (BCMCPU_IS_6328() || BCMCPU_IS_6368())
46                 chan_count = 32;
47         else
48                 chan_count = 16;
49 @@ -224,7 +224,7 @@ bcm63xx_enetsw_register(const struct bcm
50  {
51         int ret;
52  
53 -       if (!BCMCPU_IS_6368())
54 +       if (!BCMCPU_IS_6328() && !BCMCPU_IS_6368())
55                 return -ENODEV;
56  
57         ret = register_shared();
58 @@ -241,7 +241,10 @@ bcm63xx_enetsw_register(const struct bcm
59  
60         memcpy(bcm63xx_enetsw_device.dev.platform_data, pd, sizeof (*pd));
61  
62 -       enetsw_pd.num_ports = ENETSW_PORTS_6368;
63 +       if (BCMCPU_IS_6328())
64 +               enetsw_pd.num_ports = ENETSW_PORTS_6328;
65 +       else if (BCMCPU_IS_6368())
66 +               enetsw_pd.num_ports = ENETSW_PORTS_6368;
67  
68         ret = platform_device_register(&bcm63xx_enetsw_device);
69         if (ret)
70 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
71 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
72 @@ -43,6 +43,7 @@ struct bcm63xx_enet_platform_data {
73   * on board ethernet switch platform data
74   */
75  #define ENETSW_MAX_PORT        6
76 +#define ENETSW_PORTS_6328 5 /* 4 FE PHY + 1 RGMII */
77  #define ENETSW_PORTS_6368 6 /* 4 FE PHY + 2 RGMII */
78  
79  #define ENETSW_RGMII_PORT0     4