bcm53xx: add initial bgmac patches
[openwrt.git] / target / linux / bcm53xx / patches-3.10 / 204-bgmac-add-supprot-for-BCM4707.patch
1 From 91c50931fd696fa8d2f9888482f89a6a0683fe6f Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Mon, 15 Jul 2013 22:22:25 +0200
4 Subject: [PATCH 19/20] bgmac: add supprot for BCM4707
5
6
7 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
8 ---
9  drivers/net/ethernet/broadcom/bgmac.c |   56 +++++++++++++++++++++++----------
10  drivers/net/ethernet/broadcom/bgmac.h |    2 ++
11  2 files changed, 42 insertions(+), 16 deletions(-)
12
13 --- a/drivers/net/ethernet/broadcom/bgmac.c
14 +++ b/drivers/net/ethernet/broadcom/bgmac.c
15 @@ -842,6 +842,8 @@ static void bgmac_speed(struct bgmac *bg
16                 set |= BGMAC_CMDCFG_ES_100;
17         if (speed & BGMAC_SPEED_1000)
18                 set |= BGMAC_CMDCFG_ES_1000;
19 +       if (speed & BGMAC_SPEED_2500)
20 +               set |= BGMAC_CMDCFG_ES_2500;
21         if (!bgmac->full_duplex)
22                 set |= BGMAC_CMDCFG_HD;
23         bgmac_cmdcfg_maskset(bgmac, mask, set, true);
24 @@ -849,13 +851,28 @@ static void bgmac_speed(struct bgmac *bg
25  
26  static void bgmac_miiconfig(struct bgmac *bgmac)
27  {
28 -       u8 imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
29 -                       BGMAC_DS_MM_SHIFT;
30 -       if (imode == 0 || imode == 1) {
31 -               if (bgmac->autoneg)
32 -                       bgmac_speed(bgmac, BGMAC_SPEED_100);
33 -               else
34 +       struct bcma_device *core = bgmac->core;
35 +       struct bcma_chipinfo *ci = &core->bus->chipinfo;
36 +
37 +       if (ci->id != BCMA_CHIP_ID_BCM4707 &&
38 +           ci->id != BCMA_CHIP_ID_BCM53018) {
39 +               if (bgmac->autoneg) {
40 +                       bcma_awrite32(core, BCMA_IOCTL,
41 +                                     bcma_aread32(core, BCMA_IOCTL) | 0x44);
42 +
43 +                       bgmac_speed(bgmac, BGMAC_SPEED_2500);
44 +               } else {
45                         bgmac_speed(bgmac, bgmac->speed);
46 +               }
47 +       } else {
48 +               u8 imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) &
49 +                           BGMAC_DS_MM_MASK) >> BGMAC_DS_MM_SHIFT;
50 +               if (imode == 0 || imode == 1) {
51 +                       if (bgmac->autoneg)
52 +                               bgmac_speed(bgmac, BGMAC_SPEED_100);
53 +                       else
54 +                               bgmac_speed(bgmac, bgmac->speed);
55 +               }
56         }
57  }
58  
59 @@ -901,7 +918,8 @@ static void bgmac_chip_reset(struct bgma
60  
61         bcma_core_enable(core, flags);
62  
63 -       if (core->id.rev > 2) {
64 +       if (core->id.rev > 2 && ci->id != BCMA_CHIP_ID_BCM4707 &&
65 +           ci->id != BCMA_CHIP_ID_BCM53018) {
66                 bgmac_set(bgmac, BCMA_CLKCTLST, 1 << 8);
67                 bgmac_wait_value(bgmac->core, BCMA_CLKCTLST, 1 << 24, 1 << 24,
68                                  1000);
69 @@ -922,10 +940,13 @@ static void bgmac_chip_reset(struct bgma
70                         et_swtype &= 0x0f;
71                         et_swtype <<= 4;
72                         sw_type = et_swtype;
73 -               } else if (ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == 9) {
74 +               } else if (ci->id == BCMA_CHIP_ID_BCM5357 &&
75 +                          ci->pkg == BCMA_PKG_ID_BCM5358) {
76                         sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII;
77 -               } else if ((ci->id != BCMA_CHIP_ID_BCM53572 && ci->pkg == 10) ||
78 -                          (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == 9)) {
79 +               } else if ((ci->id != BCMA_CHIP_ID_BCM53572 &&
80 +                           ci->pkg == BCMA_PKG_ID_BCM47186) ||
81 +                          (ci->id == BCMA_CHIP_ID_BCM53572 &&
82 +                           ci->pkg == BCMA_PKG_ID_BCM47188)) {
83                         sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RGMII |
84                                   BGMAC_CHIPCTL_1_SW_TYPE_RGMII;
85                 }
86 @@ -1030,12 +1051,15 @@ static void bgmac_enable(struct bgmac *b
87                 break;
88         }
89  
90 -       rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
91 -       rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
92 -       bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) / 1000000;
93 -       mdp = (bp_clk * 128 / 1000) - 3;
94 -       rxq_ctl |= (mdp << BGMAC_RXQ_CTL_MDP_SHIFT);
95 -       bgmac_write(bgmac, BGMAC_RXQ_CTL, rxq_ctl);
96 +       if (ci->id != BCMA_CHIP_ID_BCM4707 &&
97 +           ci->id != BCMA_CHIP_ID_BCM53018) {
98 +               rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
99 +               rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
100 +               bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) / 1000000;
101 +               mdp = (bp_clk * 128 / 1000) - 3;
102 +               rxq_ctl |= (mdp << BGMAC_RXQ_CTL_MDP_SHIFT);
103 +               bgmac_write(bgmac, BGMAC_RXQ_CTL, rxq_ctl);
104 +       }
105  }
106  
107  /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */
108 --- a/drivers/net/ethernet/broadcom/bgmac.h
109 +++ b/drivers/net/ethernet/broadcom/bgmac.h
110 @@ -185,6 +185,7 @@
111  #define   BGMAC_CMDCFG_ES_10                   0x00000000
112  #define   BGMAC_CMDCFG_ES_100                  0x00000004
113  #define   BGMAC_CMDCFG_ES_1000                 0x00000008
114 +#define   BGMAC_CMDCFG_ES_2500                 0x0000000C
115  #define  BGMAC_CMDCFG_PROM                     0x00000010      /* Set to activate promiscuous mode */
116  #define  BGMAC_CMDCFG_PAD_EN                   0x00000020
117  #define  BGMAC_CMDCFG_CF                       0x00000040
118 @@ -345,6 +346,7 @@
119  #define BGMAC_SPEED_10                         0x0001
120  #define BGMAC_SPEED_100                                0x0002
121  #define BGMAC_SPEED_1000                       0x0004
122 +#define BGMAC_SPEED_2500                       0x0008
123  
124  #define BGMAC_WEIGHT   64
125