1 bgmac: add supprot for BCM4707
3 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
5 --- a/drivers/net/ethernet/broadcom/bgmac.c
6 +++ b/drivers/net/ethernet/broadcom/bgmac.c
7 @@ -887,6 +887,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 @@ -894,13 +896,28 @@ static void bgmac_speed(struct bgmac *bg
18 static void bgmac_miiconfig(struct bgmac *bgmac)
20 - u8 imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
22 - if (imode == 0 || imode == 1) {
24 - bgmac_speed(bgmac, BGMAC_SPEED_100);
26 + struct bcma_device *core = bgmac->core;
27 + struct bcma_chipinfo *ci = &core->bus->chipinfo;
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);
35 + bgmac_speed(bgmac, BGMAC_SPEED_2500);
37 bgmac_speed(bgmac, bgmac->speed);
40 + u8 imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) &
41 + BGMAC_DS_MM_MASK) >> BGMAC_DS_MM_SHIFT;
42 + if (imode == 0 || imode == 1) {
44 + bgmac_speed(bgmac, BGMAC_SPEED_100);
46 + bgmac_speed(bgmac, bgmac->speed);
51 @@ -946,7 +963,8 @@ static void bgmac_chip_reset(struct bgma
53 bcma_core_enable(core, flags);
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,
61 @@ -967,10 +985,13 @@ static void bgmac_chip_reset(struct bgma
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;
78 @@ -1077,12 +1098,15 @@ static void bgmac_enable(struct bgmac *b
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);
99 /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */
100 @@ -1488,6 +1512,25 @@ static int bgmac_probe(struct bcma_devic
101 goto err_netdev_free;
104 + /* Northstar, take all GMAC cores out of reset */
105 + if (core->id.id == BCMA_CHIP_ID_BCM4707 ||
106 + core->id.id == BCMA_CHIP_ID_BCM53018) {
107 + struct bcma_device *ns_core;
110 + for (ns_gmac = 0; ns_gmac < 4; ns_gmac++) {
111 + /* As northstar requirement, we have to reset all GAMCs before
112 + * accessing them. et_probe() call pci_enable_device() for etx
113 + * and do si_core_reset for GAMCx only. Then the other three
114 + * GAMCs didn't reset. We do it here.
116 + ns_core = bcma_find_core_unit(core->bus, BCMA_CORE_MAC_GBIT, ns_gmac);
117 + if (!bcma_core_is_enabled(ns_core)) {
118 + bcma_core_enable(ns_core, 0);
123 bgmac_chip_reset(bgmac);
125 err = bgmac_dma_alloc(bgmac);
126 --- a/drivers/net/ethernet/broadcom/bgmac.h
127 +++ b/drivers/net/ethernet/broadcom/bgmac.h
129 #define BGMAC_CMDCFG_ES_10 0x00000000
130 #define BGMAC_CMDCFG_ES_100 0x00000004
131 #define BGMAC_CMDCFG_ES_1000 0x00000008
132 +#define BGMAC_CMDCFG_ES_2500 0x0000000C
133 #define BGMAC_CMDCFG_PROM 0x00000010 /* Set to activate promiscuous mode */
134 #define BGMAC_CMDCFG_PAD_EN 0x00000020
135 #define BGMAC_CMDCFG_CF 0x00000040
137 #define BGMAC_SPEED_10 0x0001
138 #define BGMAC_SPEED_100 0x0002
139 #define BGMAC_SPEED_1000 0x0004
140 +#define BGMAC_SPEED_2500 0x0008
142 #define BGMAC_WEIGHT 64