Skip to content

Commit 1cb94db

Browse files
Rafał Miłeckidavem330
authored andcommitted
net: bgmac: support Ethernet core on BCM53573 SoCs
BCM53573 is a new series of Broadcom's SoCs. It's based on ARM and can be found in two packages (versions): BCM53573 and BCM47189. It shares some code with the Northstar family, but also requires some new quirks. First of all there can be up to 2 Ethernet cores on this SoC. If that is the case, they are connected to two different switch ports allowing some more complex/optimized setups. It seems the second unit doesn't come fully configured and requires some IRQ quirk. Other than that only the first core is connected to the PHY. For the second one we have to register fixed PHY (similarly to the Northstar), otherwise generic PHY driver would get some invalid info. This has been successfully tested on Tenda AC9 (BCM47189B0). Signed-off-by: Rafał Miłecki <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6b2a314 commit 1cb94db

File tree

5 files changed

+66
-1
lines changed

5 files changed

+66
-1
lines changed

drivers/net/ethernet/broadcom/bgmac-bcma.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl);
9292
/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
9393
static int bgmac_probe(struct bcma_device *core)
9494
{
95+
struct bcma_chipinfo *ci = &core->bus->chipinfo;
9596
struct ssb_sprom *sprom = &core->bus->sprom;
9697
struct mii_bus *mii_bus;
9798
struct bgmac *bgmac;
@@ -157,7 +158,8 @@ static int bgmac_probe(struct bcma_device *core)
157158
dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
158159
bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
159160

160-
if (!bgmac_is_bcm4707_family(core)) {
161+
if (!bgmac_is_bcm4707_family(core) &&
162+
!(ci->id == BCMA_CHIP_ID_BCM53573 && core->core_unit == 1)) {
161163
mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
162164
if (!IS_ERR(mii_bus)) {
163165
err = PTR_ERR(mii_bus);
@@ -230,6 +232,21 @@ static int bgmac_probe(struct bcma_device *core)
230232
bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
231233
bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
232234
break;
235+
case BCMA_CHIP_ID_BCM53573:
236+
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
237+
bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
238+
if (ci->pkg == BCMA_PKG_ID_BCM47189)
239+
bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
240+
if (core->core_unit == 0) {
241+
bgmac->feature_flags |= BGMAC_FEAT_CC4_IF_SW_TYPE;
242+
if (ci->pkg == BCMA_PKG_ID_BCM47189)
243+
bgmac->feature_flags |=
244+
BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII;
245+
} else if (core->core_unit == 1) {
246+
bgmac->feature_flags |= BGMAC_FEAT_IRQ_ID_OOB_6;
247+
bgmac->feature_flags |= BGMAC_FEAT_CC7_IF_TYPE_RGMII;
248+
}
249+
break;
233250
default:
234251
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
235252
bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;

drivers/net/ethernet/broadcom/bgmac.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,27 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
940940
bgmac_cco_ctl_maskset(bgmac, 1, ~(BGMAC_CHIPCTL_1_IF_TYPE_MASK |
941941
BGMAC_CHIPCTL_1_SW_TYPE_MASK),
942942
sw_type);
943+
} else if (bgmac->feature_flags & BGMAC_FEAT_CC4_IF_SW_TYPE) {
944+
u32 sw_type = BGMAC_CHIPCTL_4_IF_TYPE_MII |
945+
BGMAC_CHIPCTL_4_SW_TYPE_EPHY;
946+
u8 et_swtype = 0;
947+
char buf[4];
948+
949+
if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
950+
if (kstrtou8(buf, 0, &et_swtype))
951+
dev_err(bgmac->dev, "Failed to parse et_swtype (%s)\n",
952+
buf);
953+
sw_type = (et_swtype & 0x0f) << 12;
954+
} else if (bgmac->feature_flags & BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII) {
955+
sw_type = BGMAC_CHIPCTL_4_IF_TYPE_RGMII |
956+
BGMAC_CHIPCTL_4_SW_TYPE_RGMII;
957+
}
958+
bgmac_cco_ctl_maskset(bgmac, 4, ~(BGMAC_CHIPCTL_4_IF_TYPE_MASK |
959+
BGMAC_CHIPCTL_4_SW_TYPE_MASK),
960+
sw_type);
961+
} else if (bgmac->feature_flags & BGMAC_FEAT_CC7_IF_TYPE_RGMII) {
962+
bgmac_cco_ctl_maskset(bgmac, 7, ~BGMAC_CHIPCTL_7_IF_TYPE_MASK,
963+
BGMAC_CHIPCTL_7_IF_TYPE_RGMII);
943964
}
944965

945966
if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw)
@@ -1467,6 +1488,10 @@ int bgmac_enet_probe(struct bgmac *info)
14671488
*/
14681489
bgmac_clk_enable(bgmac, 0);
14691490

1491+
/* This seems to be fixing IRQ by assigning OOB #6 to the core */
1492+
if (bgmac->feature_flags & BGMAC_FEAT_IRQ_ID_OOB_6)
1493+
bgmac_idm_write(bgmac, BCMA_OOB_SEL_OUT_A30, 0x86);
1494+
14701495
bgmac_chip_reset(bgmac);
14711496

14721497
err = bgmac_dma_alloc(bgmac);

drivers/net/ethernet/broadcom/bgmac.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,21 @@
369369
#define BGMAC_CHIPCTL_1_SW_TYPE_RGMII 0x000000C0
370370
#define BGMAC_CHIPCTL_1_RXC_DLL_BYPASS 0x00010000
371371

372+
#define BGMAC_CHIPCTL_4_IF_TYPE_MASK 0x00003000
373+
#define BGMAC_CHIPCTL_4_IF_TYPE_RMII 0x00000000
374+
#define BGMAC_CHIPCTL_4_IF_TYPE_MII 0x00001000
375+
#define BGMAC_CHIPCTL_4_IF_TYPE_RGMII 0x00002000
376+
#define BGMAC_CHIPCTL_4_SW_TYPE_MASK 0x0000C000
377+
#define BGMAC_CHIPCTL_4_SW_TYPE_EPHY 0x00000000
378+
#define BGMAC_CHIPCTL_4_SW_TYPE_EPHYMII 0x00004000
379+
#define BGMAC_CHIPCTL_4_SW_TYPE_EPHYRMII 0x00008000
380+
#define BGMAC_CHIPCTL_4_SW_TYPE_RGMII 0x0000C000
381+
382+
#define BGMAC_CHIPCTL_7_IF_TYPE_MASK 0x000000C0
383+
#define BGMAC_CHIPCTL_7_IF_TYPE_RMII 0x00000000
384+
#define BGMAC_CHIPCTL_7_IF_TYPE_MII 0x00000040
385+
#define BGMAC_CHIPCTL_7_IF_TYPE_RGMII 0x00000080
386+
372387
#define BGMAC_WEIGHT 64
373388

374389
#define ETHER_MAX_LEN 1518
@@ -390,6 +405,10 @@
390405
#define BGMAC_FEAT_NO_CLR_MIB BIT(13)
391406
#define BGMAC_FEAT_FORCE_SPEED_2500 BIT(14)
392407
#define BGMAC_FEAT_CMDCFG_SR_REV4 BIT(15)
408+
#define BGMAC_FEAT_IRQ_ID_OOB_6 BIT(16)
409+
#define BGMAC_FEAT_CC4_IF_SW_TYPE BIT(17)
410+
#define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII BIT(18)
411+
#define BGMAC_FEAT_CC7_IF_TYPE_RGMII BIT(19)
393412

394413
struct bgmac_slot_info {
395414
union {

include/linux/bcma/bcma.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ struct bcma_host_ops {
205205
#define BCMA_PKG_ID_BCM4709 0
206206
#define BCMA_CHIP_ID_BCM47094 53030
207207
#define BCMA_CHIP_ID_BCM53018 53018
208+
#define BCMA_CHIP_ID_BCM53573 53573
209+
#define BCMA_PKG_ID_BCM53573 0
210+
#define BCMA_PKG_ID_BCM47189 1
208211

209212
/* Board types (on PCI usually equals to the subsystem dev id) */
210213
/* BCM4313 */

include/linux/bcma/bcma_regs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define BCMA_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
2424

2525
/* Agent registers (common for every core) */
26+
#define BCMA_OOB_SEL_OUT_A30 0x0100
2627
#define BCMA_IOCTL 0x0408 /* IO control */
2728
#define BCMA_IOCTL_CLK 0x0001
2829
#define BCMA_IOCTL_FGC 0x0002

0 commit comments

Comments
 (0)