mirror of https://github.com/hak5/openwrt.git
126 lines
4.3 KiB
Diff
126 lines
4.3 KiB
Diff
|
From 91c50931fd696fa8d2f9888482f89a6a0683fe6f Mon Sep 17 00:00:00 2001
|
||
|
From: Hauke Mehrtens <hauke@hauke-m.de>
|
||
|
Date: Mon, 15 Jul 2013 22:22:25 +0200
|
||
|
Subject: [PATCH 19/20] bgmac: add supprot for BCM4707
|
||
|
|
||
|
|
||
|
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
||
|
---
|
||
|
drivers/net/ethernet/broadcom/bgmac.c | 56 +++++++++++++++++++++++----------
|
||
|
drivers/net/ethernet/broadcom/bgmac.h | 2 ++
|
||
|
2 files changed, 42 insertions(+), 16 deletions(-)
|
||
|
|
||
|
--- a/drivers/net/ethernet/broadcom/bgmac.c
|
||
|
+++ b/drivers/net/ethernet/broadcom/bgmac.c
|
||
|
@@ -842,6 +842,8 @@ static void bgmac_speed(struct bgmac *bg
|
||
|
set |= BGMAC_CMDCFG_ES_100;
|
||
|
if (speed & BGMAC_SPEED_1000)
|
||
|
set |= BGMAC_CMDCFG_ES_1000;
|
||
|
+ if (speed & BGMAC_SPEED_2500)
|
||
|
+ set |= BGMAC_CMDCFG_ES_2500;
|
||
|
if (!bgmac->full_duplex)
|
||
|
set |= BGMAC_CMDCFG_HD;
|
||
|
bgmac_cmdcfg_maskset(bgmac, mask, set, true);
|
||
|
@@ -849,13 +851,28 @@ static void bgmac_speed(struct bgmac *bg
|
||
|
|
||
|
static void bgmac_miiconfig(struct bgmac *bgmac)
|
||
|
{
|
||
|
- u8 imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
|
||
|
- BGMAC_DS_MM_SHIFT;
|
||
|
- if (imode == 0 || imode == 1) {
|
||
|
- if (bgmac->autoneg)
|
||
|
- bgmac_speed(bgmac, BGMAC_SPEED_100);
|
||
|
- else
|
||
|
+ struct bcma_device *core = bgmac->core;
|
||
|
+ struct bcma_chipinfo *ci = &core->bus->chipinfo;
|
||
|
+
|
||
|
+ if (ci->id != BCMA_CHIP_ID_BCM4707 &&
|
||
|
+ ci->id != BCMA_CHIP_ID_BCM53018) {
|
||
|
+ if (bgmac->autoneg) {
|
||
|
+ bcma_awrite32(core, BCMA_IOCTL,
|
||
|
+ bcma_aread32(core, BCMA_IOCTL) | 0x44);
|
||
|
+
|
||
|
+ bgmac_speed(bgmac, BGMAC_SPEED_2500);
|
||
|
+ } else {
|
||
|
bgmac_speed(bgmac, bgmac->speed);
|
||
|
+ }
|
||
|
+ } else {
|
||
|
+ u8 imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) &
|
||
|
+ BGMAC_DS_MM_MASK) >> BGMAC_DS_MM_SHIFT;
|
||
|
+ if (imode == 0 || imode == 1) {
|
||
|
+ if (bgmac->autoneg)
|
||
|
+ bgmac_speed(bgmac, BGMAC_SPEED_100);
|
||
|
+ else
|
||
|
+ bgmac_speed(bgmac, bgmac->speed);
|
||
|
+ }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@@ -901,7 +918,8 @@ static void bgmac_chip_reset(struct bgma
|
||
|
|
||
|
bcma_core_enable(core, flags);
|
||
|
|
||
|
- if (core->id.rev > 2) {
|
||
|
+ if (core->id.rev > 2 && ci->id != BCMA_CHIP_ID_BCM4707 &&
|
||
|
+ ci->id != BCMA_CHIP_ID_BCM53018) {
|
||
|
bgmac_set(bgmac, BCMA_CLKCTLST, 1 << 8);
|
||
|
bgmac_wait_value(bgmac->core, BCMA_CLKCTLST, 1 << 24, 1 << 24,
|
||
|
1000);
|
||
|
@@ -922,10 +940,13 @@ static void bgmac_chip_reset(struct bgma
|
||
|
et_swtype &= 0x0f;
|
||
|
et_swtype <<= 4;
|
||
|
sw_type = et_swtype;
|
||
|
- } else if (ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == 9) {
|
||
|
+ } else if (ci->id == BCMA_CHIP_ID_BCM5357 &&
|
||
|
+ ci->pkg == BCMA_PKG_ID_BCM5358) {
|
||
|
sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII;
|
||
|
- } else if ((ci->id != BCMA_CHIP_ID_BCM53572 && ci->pkg == 10) ||
|
||
|
- (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == 9)) {
|
||
|
+ } else if ((ci->id != BCMA_CHIP_ID_BCM53572 &&
|
||
|
+ ci->pkg == BCMA_PKG_ID_BCM47186) ||
|
||
|
+ (ci->id == BCMA_CHIP_ID_BCM53572 &&
|
||
|
+ ci->pkg == BCMA_PKG_ID_BCM47188)) {
|
||
|
sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RGMII |
|
||
|
BGMAC_CHIPCTL_1_SW_TYPE_RGMII;
|
||
|
}
|
||
|
@@ -1030,12 +1051,15 @@ static void bgmac_enable(struct bgmac *b
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
- rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
|
||
|
- rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
|
||
|
- bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) / 1000000;
|
||
|
- mdp = (bp_clk * 128 / 1000) - 3;
|
||
|
- rxq_ctl |= (mdp << BGMAC_RXQ_CTL_MDP_SHIFT);
|
||
|
- bgmac_write(bgmac, BGMAC_RXQ_CTL, rxq_ctl);
|
||
|
+ if (ci->id != BCMA_CHIP_ID_BCM4707 &&
|
||
|
+ ci->id != BCMA_CHIP_ID_BCM53018) {
|
||
|
+ rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
|
||
|
+ rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
|
||
|
+ bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) / 1000000;
|
||
|
+ mdp = (bp_clk * 128 / 1000) - 3;
|
||
|
+ rxq_ctl |= (mdp << BGMAC_RXQ_CTL_MDP_SHIFT);
|
||
|
+ bgmac_write(bgmac, BGMAC_RXQ_CTL, rxq_ctl);
|
||
|
+ }
|
||
|
}
|
||
|
|
||
|
/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */
|
||
|
--- a/drivers/net/ethernet/broadcom/bgmac.h
|
||
|
+++ b/drivers/net/ethernet/broadcom/bgmac.h
|
||
|
@@ -185,6 +185,7 @@
|
||
|
#define BGMAC_CMDCFG_ES_10 0x00000000
|
||
|
#define BGMAC_CMDCFG_ES_100 0x00000004
|
||
|
#define BGMAC_CMDCFG_ES_1000 0x00000008
|
||
|
+#define BGMAC_CMDCFG_ES_2500 0x0000000C
|
||
|
#define BGMAC_CMDCFG_PROM 0x00000010 /* Set to activate promiscuous mode */
|
||
|
#define BGMAC_CMDCFG_PAD_EN 0x00000020
|
||
|
#define BGMAC_CMDCFG_CF 0x00000040
|
||
|
@@ -345,6 +346,7 @@
|
||
|
#define BGMAC_SPEED_10 0x0001
|
||
|
#define BGMAC_SPEED_100 0x0002
|
||
|
#define BGMAC_SPEED_1000 0x0004
|
||
|
+#define BGMAC_SPEED_2500 0x0008
|
||
|
|
||
|
#define BGMAC_WEIGHT 64
|
||
|
|