2014-01-04 18:25:05 +00:00
|
|
|
From 2e3759f95d3c96282c19e6f57274d816c6cf1a0e Mon Sep 17 00:00:00 2001
|
|
|
|
From: Hauke Mehrtens <hauke@hauke-m.de>
|
|
|
|
Date: Sun, 10 Nov 2013 21:13:20 +0100
|
|
|
|
Subject: [PATCH 4/5] bgmac: reset all cores on Northstar SoC
|
|
|
|
|
|
|
|
On the Northstar SoC (BCM4707 and BCM53018) we have to enable all GMAC
|
|
|
|
cores when we just want to use on. We iterate over all the cores and
|
|
|
|
activate them.
|
|
|
|
|
|
|
|
Subject: [PATCH 5/5] bgmac: add support for Northstar SoC (BCM4707, BCM53018)
|
|
|
|
|
|
|
|
This adds support for the Northstar SoC. This SoC does not have a PMU in
|
|
|
|
bcma and no register on it should be called. In addition it support 2.5
|
|
|
|
GBit/s Ethernet to the PHY.
|
|
|
|
|
|
|
|
This GMAC core is not fully working there are still problems with the
|
|
|
|
DMA controller.
|
2013-07-28 21:20:15 +00:00
|
|
|
|
|
|
|
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
|
|
|
|
|
|
|
--- a/drivers/net/ethernet/broadcom/bgmac.c
|
|
|
|
+++ b/drivers/net/ethernet/broadcom/bgmac.c
|
2013-12-26 23:22:31 +00:00
|
|
|
@@ -825,6 +825,9 @@ static void bgmac_mac_speed(struct bgmac
|
|
|
|
case SPEED_1000:
|
2013-07-28 21:20:15 +00:00
|
|
|
set |= BGMAC_CMDCFG_ES_1000;
|
2013-12-26 23:22:31 +00:00
|
|
|
break;
|
|
|
|
+ case SPEED_2500:
|
2013-07-28 21:20:15 +00:00
|
|
|
+ set |= BGMAC_CMDCFG_ES_2500;
|
2013-12-26 23:22:31 +00:00
|
|
|
+ break;
|
|
|
|
default:
|
|
|
|
bgmac_err(bgmac, "Unsupported speed: %d\n", bgmac->mac_speed);
|
|
|
|
}
|
2014-01-04 18:25:05 +00:00
|
|
|
@@ -837,12 +840,26 @@ static void bgmac_mac_speed(struct bgmac
|
2013-07-28 21:20:15 +00:00
|
|
|
|
|
|
|
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) {
|
2013-12-26 23:22:31 +00:00
|
|
|
- bgmac->mac_speed = SPEED_100;
|
2013-07-28 21:20:15 +00:00
|
|
|
+ struct bcma_device *core = bgmac->core;
|
|
|
|
+ struct bcma_chipinfo *ci = &core->bus->chipinfo;
|
2013-12-26 23:22:31 +00:00
|
|
|
+ u8 imode;
|
2013-07-28 21:20:15 +00:00
|
|
|
+
|
2013-10-02 23:12:46 +00:00
|
|
|
+ if (ci->id == BCMA_CHIP_ID_BCM4707 ||
|
|
|
|
+ ci->id == BCMA_CHIP_ID_BCM53018) {
|
2013-12-26 23:22:31 +00:00
|
|
|
+ bcma_awrite32(core, BCMA_IOCTL,
|
2014-01-04 18:25:05 +00:00
|
|
|
+ bcma_aread32(core, BCMA_IOCTL) | 0x40 |
|
|
|
|
+ BGMAC_BCMA_IOCTL_SW_CLKEN);
|
2013-12-26 23:22:31 +00:00
|
|
|
+ bgmac->mac_speed = SPEED_2500;
|
|
|
|
bgmac->mac_duplex = DUPLEX_FULL;
|
|
|
|
bgmac_mac_speed(bgmac);
|
2013-07-28 21:20:15 +00:00
|
|
|
+ } else {
|
2014-01-04 18:25:05 +00:00
|
|
|
+ imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) &
|
|
|
|
+ BGMAC_DS_MM_MASK) >> BGMAC_DS_MM_SHIFT;
|
2013-07-28 21:20:15 +00:00
|
|
|
+ if (imode == 0 || imode == 1) {
|
2013-12-26 23:22:31 +00:00
|
|
|
+ bgmac->mac_speed = SPEED_100;
|
|
|
|
+ bgmac->mac_duplex = DUPLEX_FULL;
|
|
|
|
+ bgmac_mac_speed(bgmac);
|
2013-07-28 21:20:15 +00:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-04 18:25:05 +00:00
|
|
|
@@ -886,9 +903,14 @@ static void bgmac_chip_reset(struct bgma
|
|
|
|
flags |= BGMAC_BCMA_IOCTL_SW_RESET;
|
|
|
|
}
|
2013-07-28 21:20:15 +00:00
|
|
|
|
2014-01-04 18:25:05 +00:00
|
|
|
- bcma_core_enable(core, flags);
|
|
|
|
-
|
2013-07-28 21:20:15 +00:00
|
|
|
- if (core->id.rev > 2) {
|
2014-01-04 18:25:05 +00:00
|
|
|
+ /* 3GMAC: for BCM4707, only do core reset at bgmac_probe() */
|
|
|
|
+ if (ci->id != BCMA_CHIP_ID_BCM4707)
|
|
|
|
+ bcma_core_enable(core, flags);
|
|
|
|
+
|
|
|
|
+ /* Request Misc PLL for corerev > 2 */
|
|
|
|
+ if (core->id.rev > 2 &&
|
|
|
|
+ ci->id != BCMA_CHIP_ID_BCM4707 &&
|
2013-07-28 21:20:15 +00:00
|
|
|
+ ci->id != BCMA_CHIP_ID_BCM53018) {
|
2013-12-26 23:22:31 +00:00
|
|
|
bgmac_set(bgmac, BCMA_CLKCTLST,
|
|
|
|
BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
|
|
|
|
bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
|
2014-01-04 18:25:05 +00:00
|
|
|
@@ -1026,12 +1048,16 @@ static void bgmac_enable(struct bgmac *b
|
2013-07-28 21:20:15 +00:00
|
|
|
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;
|
2014-01-04 18:25:05 +00:00
|
|
|
+ bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) /
|
|
|
|
+ 1000000;
|
2013-07-28 21:20:15 +00:00
|
|
|
+ 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 */
|
2014-01-04 18:25:05 +00:00
|
|
|
@@ -1366,6 +1392,7 @@ static int bgmac_probe(struct bcma_devic
|
|
|
|
struct bgmac *bgmac;
|
|
|
|
struct ssb_sprom *sprom = &core->bus->sprom;
|
|
|
|
u8 *mac = core->core_unit ? sprom->et1mac : sprom->et0mac;
|
|
|
|
+ struct bcma_chipinfo *ci = &core->bus->chipinfo;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
/* We don't support 2nd, 3rd, ... units, SPROM has to be adjusted */
|
|
|
|
@@ -1404,8 +1431,16 @@ static int bgmac_probe(struct bcma_devic
|
2013-11-11 00:13:31 +00:00
|
|
|
}
|
2014-01-04 18:25:05 +00:00
|
|
|
bgmac->cmn = core->bus->drv_gmac_cmn.core;
|
|
|
|
|
|
|
|
- bgmac->phyaddr = core->core_unit ? sprom->et1phyaddr :
|
|
|
|
- sprom->et0phyaddr;
|
|
|
|
+ /*
|
|
|
|
+ * Too much can go wrong in scanning MDC/MDIO playing "whos my phy?" .
|
|
|
|
+ * Instead, explicitly use the phy address 30.
|
|
|
|
+ */
|
|
|
|
+ if (ci->id == BCMA_CHIP_ID_BCM4707 || ci->id == BCMA_CHIP_ID_BCM53018)
|
|
|
|
+ bgmac->phyaddr = BGMAC_PHY_NOREGS;
|
|
|
|
+ else
|
|
|
|
+ bgmac->phyaddr = core->core_unit ? sprom->et1phyaddr :
|
|
|
|
+ sprom->et0phyaddr;
|
|
|
|
+
|
|
|
|
bgmac->phyaddr &= BGMAC_PHY_MASK;
|
|
|
|
if (bgmac->phyaddr == BGMAC_PHY_MASK) {
|
|
|
|
bgmac_err(bgmac, "No PHY found\n");
|
|
|
|
@@ -1423,6 +1458,27 @@ static int bgmac_probe(struct bcma_devic
|
2013-11-11 00:13:31 +00:00
|
|
|
|
2014-01-04 18:25:05 +00:00
|
|
|
bgmac_chip_reset(bgmac);
|
|
|
|
|
|
|
|
+ /* For Northstar, we have to take all GMAC core out of reset */
|
2013-11-11 00:13:31 +00:00
|
|
|
+ if (core->id.id == BCMA_CHIP_ID_BCM4707 ||
|
|
|
|
+ core->id.id == BCMA_CHIP_ID_BCM53018) {
|
|
|
|
+ struct bcma_device *ns_core;
|
|
|
|
+ int ns_gmac;
|
|
|
|
+
|
2014-01-04 18:25:05 +00:00
|
|
|
+ /* Northstar has 4 GMAC cores */
|
2013-11-11 00:13:31 +00:00
|
|
|
+ for (ns_gmac = 0; ns_gmac < 4; ns_gmac++) {
|
2014-01-04 18:25:05 +00:00
|
|
|
+ /* As northstar requirement, we have to reset all GAMCs
|
|
|
|
+ * before accessing one. bgmac_chip_reset() call
|
|
|
|
+ * bcma_core_enable() for this core. Then the other
|
|
|
|
+ * three GAMCs didn't reset. We do it here.
|
2013-11-11 00:13:31 +00:00
|
|
|
+ */
|
2014-01-04 18:25:05 +00:00
|
|
|
+ ns_core = bcma_find_core_unit(core->bus,
|
|
|
|
+ BCMA_CORE_MAC_GBIT,
|
|
|
|
+ ns_gmac);
|
|
|
|
+ if (ns_core && !bcma_core_is_enabled(ns_core))
|
2013-11-11 00:13:31 +00:00
|
|
|
+ bcma_core_enable(ns_core, 0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
err = bgmac_dma_alloc(bgmac);
|
2014-01-04 18:25:05 +00:00
|
|
|
if (err) {
|
|
|
|
bgmac_err(bgmac, "Unable to alloc memory for DMA\n");
|
2013-07-28 21:20:15 +00:00
|
|
|
--- a/drivers/net/ethernet/broadcom/bgmac.h
|
|
|
|
+++ b/drivers/net/ethernet/broadcom/bgmac.h
|
2013-12-26 23:22:31 +00:00
|
|
|
@@ -189,6 +189,7 @@
|
2013-07-28 21:20:15 +00:00
|
|
|
#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
|