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