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