From: Rafał Miłecki Date: Sat, 21 Mar 2015 11:45:50 +0000 (+0000) Subject: kernel: backport bgmac patches X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=ba10454b9115bd876a4c1cbf694d582b87039feb;p=openwrt%2Fstaging%2Flinusw.git kernel: backport bgmac patches This allows dropping some hacky bcm53xx bgmac patch forcing link state. Signed-off-by: Rafał Miłecki SVN-Revision: 44917 --- diff --git a/target/linux/bcm53xx/patches-3.18/900-bgmac-some-fixes-to-get-bgmac-work.patch b/target/linux/bcm53xx/patches-3.18/900-bgmac-some-fixes-to-get-bgmac-work.patch deleted file mode 100644 index c3ae68d714..0000000000 --- a/target/linux/bcm53xx/patches-3.18/900-bgmac-some-fixes-to-get-bgmac-work.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0bd576e93a188fd3aab769b622fb3d35fa9bc7a7 Mon Sep 17 00:00:00 2001 -From: Hauke Mehrtens -Date: Sat, 3 May 2014 19:55:38 +0200 -Subject: [PATCH 15/15] bgmac: some fixes to get bgmac work - -Signed-off-by: Hauke Mehrtens ---- - drivers/net/ethernet/broadcom/Kconfig | 2 +- - drivers/net/phy/phy_device.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - ---- a/drivers/net/ethernet/broadcom/Kconfig -+++ b/drivers/net/ethernet/broadcom/Kconfig -@@ -143,7 +143,7 @@ config BNX2X_SRIOV - - config BGMAC - tristate "BCMA bus GBit core support" -- depends on BCMA_HOST_SOC && HAS_DMA && BCM47XX -+ depends on BCMA_HOST_SOC && HAS_DMA - select PHYLIB - ---help--- - This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus. ---- a/drivers/net/phy/phy_device.c -+++ b/drivers/net/phy/phy_device.c -@@ -931,7 +931,7 @@ int genphy_update_link(struct phy_device - return status; - - if ((status & BMSR_LSTATUS) == 0) -- phydev->link = 0; -+ phydev->link = 1; - else - phydev->link = 1; - diff --git a/target/linux/generic/patches-3.18/072-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch b/target/linux/generic/patches-3.18/072-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch new file mode 100644 index 0000000000..ee49e1cc00 --- /dev/null +++ b/target/linux/generic/patches-3.18/072-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch @@ -0,0 +1,45 @@ +From 21697336d46b71dd031f29e426dda0b1e7f06cc0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Wed, 11 Feb 2015 18:06:34 +0100 +Subject: [PATCH] bgmac: fix device initialization on Northstar SoCs (condition + typo) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On Northstar (Broadcom's ARM architecture) we need to manually enable +all cores. Code for that is already in place, but the condition for it +was wrong. + +Signed-off-by: Rafał Miłecki +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c +index ea63cb0..676ffe0 100644 +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -1412,6 +1412,7 @@ static void bgmac_mii_unregister(struct bgmac *bgmac) + /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */ + static int bgmac_probe(struct bcma_device *core) + { ++ struct bcma_chipinfo *ci = &core->bus->chipinfo; + struct net_device *net_dev; + struct bgmac *bgmac; + struct ssb_sprom *sprom = &core->bus->sprom; +@@ -1474,8 +1475,8 @@ static int bgmac_probe(struct bcma_device *core) + bgmac_chip_reset(bgmac); + + /* For Northstar, we have to take all GMAC core out of reset */ +- if (core->id.id == BCMA_CHIP_ID_BCM4707 || +- core->id.id == BCMA_CHIP_ID_BCM53018) { ++ if (ci->id == BCMA_CHIP_ID_BCM4707 || ++ ci->id == BCMA_CHIP_ID_BCM53018) { + struct bcma_device *ns_core; + int ns_gmac; + +-- +1.8.4.5 + diff --git a/target/linux/generic/patches-3.18/073-bgmac-Clean-warning-messages.patch b/target/linux/generic/patches-3.18/073-bgmac-Clean-warning-messages.patch new file mode 100644 index 0000000000..fd3e11d672 --- /dev/null +++ b/target/linux/generic/patches-3.18/073-bgmac-Clean-warning-messages.patch @@ -0,0 +1,55 @@ +From 8edfe3b6fad28da191c8fa15e4e0d8f7335a0091 Mon Sep 17 00:00:00 2001 +From: Peter Senna Tschudin +Date: Sat, 7 Mar 2015 12:10:26 +0100 +Subject: [PATCH] bgmac: Clean warning messages +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On my test environment the throughput of a file transfer drops +from 4.4MBps to 116KBps due the number of repeated warning +messages. This patch removes the warning messages as DMA works +correctly with addresses using 0xC0000000 bits. + +Signed-off-by: Peter Senna Tschudin +Acked-by: Rafał Miłecki +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c +index 676ffe0..0469f72 100644 +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -302,9 +302,6 @@ static int bgmac_dma_rx_skb_for_slot(struct bgmac *bgmac, + slot->skb = skb; + slot->dma_addr = dma_addr; + +- if (slot->dma_addr & 0xC0000000) +- bgmac_warn(bgmac, "DMA address using 0xC0000000 bit(s), it may need translation trick\n"); +- + return 0; + } + +@@ -505,8 +502,6 @@ static int bgmac_dma_alloc(struct bgmac *bgmac) + ring->mmio_base); + goto err_dma_free; + } +- if (ring->dma_base & 0xC0000000) +- bgmac_warn(bgmac, "DMA address using 0xC0000000 bit(s), it may need translation trick\n"); + + ring->unaligned = bgmac_dma_unaligned(bgmac, ring, + BGMAC_DMA_RING_TX); +@@ -536,8 +531,6 @@ static int bgmac_dma_alloc(struct bgmac *bgmac) + err = -ENOMEM; + goto err_dma_free; + } +- if (ring->dma_base & 0xC0000000) +- bgmac_warn(bgmac, "DMA address using 0xC0000000 bit(s), it may need translation trick\n"); + + ring->unaligned = bgmac_dma_unaligned(bgmac, ring, + BGMAC_DMA_RING_RX); +-- +1.8.4.5 + diff --git a/target/linux/generic/patches-3.18/074-bgmac-register-fixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch b/target/linux/generic/patches-3.18/074-bgmac-register-fixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch new file mode 100644 index 0000000000..472b22b0e7 --- /dev/null +++ b/target/linux/generic/patches-3.18/074-bgmac-register-fixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch @@ -0,0 +1,81 @@ +From c25b23b8a387e7d31f7a74af8e37b61e9e6ebb21 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 20 Mar 2015 23:14:31 +0100 +Subject: [PATCH] bgmac: register fixed PHY for ARM BCM470X / BCM5301X chipsets +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On ARM SoCs with bgmac Ethernet hardware we don't have any normal PHY. +There is always a switch attached but it's not even controlled over MDIO +like in case of MIPS devices. +We need a fixed PHY to be able to send/receive packets from the switch. + +Signed-off-by: Rafał Miłecki +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 34 ++++++++++++++++++++++++++++++++++ + 1 file changed, 34 insertions(+) + +diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c +index 0469f72..efda7cf 100644 +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -1330,13 +1331,46 @@ static void bgmac_adjust_link(struct net_device *net_dev) + } + } + ++static int bgmac_fixed_phy_register(struct bgmac *bgmac) ++{ ++ struct fixed_phy_status fphy_status = { ++ .link = 1, ++ .speed = SPEED_1000, ++ .duplex = DUPLEX_FULL, ++ }; ++ struct phy_device *phy_dev; ++ int err; ++ ++ phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, NULL); ++ if (!phy_dev || IS_ERR(phy_dev)) { ++ bgmac_err(bgmac, "Failed to register fixed PHY device\n"); ++ return -ENODEV; ++ } ++ ++ err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link, ++ PHY_INTERFACE_MODE_MII); ++ if (err) { ++ bgmac_err(bgmac, "Connecting PHY failed\n"); ++ return err; ++ } ++ ++ bgmac->phy_dev = phy_dev; ++ ++ return err; ++} ++ + static int bgmac_mii_register(struct bgmac *bgmac) + { ++ struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo; + struct mii_bus *mii_bus; + struct phy_device *phy_dev; + char bus_id[MII_BUS_ID_SIZE + 3]; + int i, err = 0; + ++ if (ci->id == BCMA_CHIP_ID_BCM4707 || ++ ci->id == BCMA_CHIP_ID_BCM53018) ++ return bgmac_fixed_phy_register(bgmac); ++ + mii_bus = mdiobus_alloc(); + if (!mii_bus) + return -ENOMEM; +-- +1.8.4.5 + diff --git a/target/linux/generic/patches-3.18/075-bgmac-allow-enabling-on-ARCH_BCM_5301X.patch b/target/linux/generic/patches-3.18/075-bgmac-allow-enabling-on-ARCH_BCM_5301X.patch new file mode 100644 index 0000000000..e3352dd99f --- /dev/null +++ b/target/linux/generic/patches-3.18/075-bgmac-allow-enabling-on-ARCH_BCM_5301X.patch @@ -0,0 +1,33 @@ +From fc300dc3733fdc328e6e10c7b8379b60c26cd648 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 20 Mar 2015 23:14:32 +0100 +Subject: [PATCH] bgmac: allow enabling on ARCH_BCM_5301X +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Home routers based on ARM SoCs like BCM4708 also have bcma bus with core +supported by bgmac. + +Signed-off-by: Rafał Miłecki +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig +index ee4fdfe..a6f9142 100644 +--- a/drivers/net/ethernet/broadcom/Kconfig ++++ b/drivers/net/ethernet/broadcom/Kconfig +@@ -143,7 +143,7 @@ config BNX2X_SRIOV + + config BGMAC + tristate "BCMA bus GBit core support" +- depends on BCMA_HOST_SOC && HAS_DMA && BCM47XX ++ depends on BCMA_HOST_SOC && HAS_DMA && (BCM47XX || ARCH_BCM_5301X) + select PHYLIB + ---help--- + This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus. +-- +1.8.4.5 + diff --git a/target/linux/generic/patches-3.18/770-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch b/target/linux/generic/patches-3.18/770-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch deleted file mode 100644 index 1d6b66c199..0000000000 --- a/target/linux/generic/patches-3.18/770-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch +++ /dev/null @@ -1,41 +0,0 @@ -From b053c5ad4d99d8f025efadd5c8b4bd84ea06eb6f Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= -Date: Wed, 11 Feb 2015 17:55:32 +0100 -Subject: [PATCH FIX] bgmac: fix device initialization on Northstar SoCs - (condition typo) -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -On Northstar (Broadcom's ARM architecture) we need to manually enable -all cores. Code for that is already in place, but the condition for it -was wrong. - -Signed-off-by: Rafał Miłecki ---- -Can we have it for 3.20, please? ---- - drivers/net/ethernet/broadcom/bgmac.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - ---- a/drivers/net/ethernet/broadcom/bgmac.c -+++ b/drivers/net/ethernet/broadcom/bgmac.c -@@ -1412,6 +1412,7 @@ static void bgmac_mii_unregister(struct - /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */ - static int bgmac_probe(struct bcma_device *core) - { -+ struct bcma_chipinfo *ci = &core->bus->chipinfo; - struct net_device *net_dev; - struct bgmac *bgmac; - struct ssb_sprom *sprom = &core->bus->sprom; -@@ -1474,8 +1475,8 @@ static int bgmac_probe(struct bcma_devic - bgmac_chip_reset(bgmac); - - /* For Northstar, we have to take all GMAC core out of reset */ -- if (core->id.id == BCMA_CHIP_ID_BCM4707 || -- core->id.id == BCMA_CHIP_ID_BCM53018) { -+ if (ci->id == BCMA_CHIP_ID_BCM4707 || -+ ci->id == BCMA_CHIP_ID_BCM53018) { - struct bcma_device *ns_core; - int ns_gmac; - diff --git a/target/linux/generic/patches-3.18/773-bgmac-add-srab-switch.patch b/target/linux/generic/patches-3.18/773-bgmac-add-srab-switch.patch index ef12cac9bf..0a8b451247 100644 --- a/target/linux/generic/patches-3.18/773-bgmac-add-srab-switch.patch +++ b/target/linux/generic/patches-3.18/773-bgmac-add-srab-switch.patch @@ -4,15 +4,15 @@ Signed-off-by: Hauke Mehrtens --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c -@@ -16,6 +16,7 @@ - #include +@@ -17,6 +17,7 @@ + #include #include #include +#include #include static const struct bcma_device_id bgmac_bcma_tbl[] = { -@@ -1405,6 +1406,17 @@ static void bgmac_mii_unregister(struct +@@ -1432,6 +1433,17 @@ static void bgmac_mii_unregister(struct mdiobus_free(mii_bus); } @@ -30,7 +30,7 @@ Signed-off-by: Hauke Mehrtens /************************************************** * BCMA bus ops **************************************************/ -@@ -1524,6 +1536,16 @@ static int bgmac_probe(struct bcma_devic +@@ -1551,6 +1563,16 @@ static int bgmac_probe(struct bcma_devic goto err_dma_free; } @@ -47,7 +47,7 @@ Signed-off-by: Hauke Mehrtens err = register_netdev(bgmac->net_dev); if (err) { bgmac_err(bgmac, "Cannot register net device\n"); -@@ -1550,6 +1572,10 @@ static void bgmac_remove(struct bcma_dev +@@ -1577,6 +1599,10 @@ static void bgmac_remove(struct bcma_dev { struct bgmac *bgmac = bcma_get_drvdata(core); diff --git a/target/linux/generic/patches-3.18/775-bgmac-check-length-of-received-frame.patch b/target/linux/generic/patches-3.18/775-bgmac-check-length-of-received-frame.patch index c3d63b65fa..883c77b2f5 100644 --- a/target/linux/generic/patches-3.18/775-bgmac-check-length-of-received-frame.patch +++ b/target/linux/generic/patches-3.18/775-bgmac-check-length-of-received-frame.patch @@ -9,7 +9,7 @@ Subject: [PATCH] bgmac: check length of received frame --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c -@@ -363,6 +363,27 @@ static int bgmac_dma_rx_read(struct bgma +@@ -361,6 +361,27 @@ static int bgmac_dma_rx_read(struct bgma dma_addr_t old_dma_addr = slot->dma_addr; int err; diff --git a/target/linux/generic/patches-3.19/070-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch b/target/linux/generic/patches-3.19/070-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch new file mode 100644 index 0000000000..ee49e1cc00 --- /dev/null +++ b/target/linux/generic/patches-3.19/070-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch @@ -0,0 +1,45 @@ +From 21697336d46b71dd031f29e426dda0b1e7f06cc0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Wed, 11 Feb 2015 18:06:34 +0100 +Subject: [PATCH] bgmac: fix device initialization on Northstar SoCs (condition + typo) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On Northstar (Broadcom's ARM architecture) we need to manually enable +all cores. Code for that is already in place, but the condition for it +was wrong. + +Signed-off-by: Rafał Miłecki +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c +index ea63cb0..676ffe0 100644 +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -1412,6 +1412,7 @@ static void bgmac_mii_unregister(struct bgmac *bgmac) + /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */ + static int bgmac_probe(struct bcma_device *core) + { ++ struct bcma_chipinfo *ci = &core->bus->chipinfo; + struct net_device *net_dev; + struct bgmac *bgmac; + struct ssb_sprom *sprom = &core->bus->sprom; +@@ -1474,8 +1475,8 @@ static int bgmac_probe(struct bcma_device *core) + bgmac_chip_reset(bgmac); + + /* For Northstar, we have to take all GMAC core out of reset */ +- if (core->id.id == BCMA_CHIP_ID_BCM4707 || +- core->id.id == BCMA_CHIP_ID_BCM53018) { ++ if (ci->id == BCMA_CHIP_ID_BCM4707 || ++ ci->id == BCMA_CHIP_ID_BCM53018) { + struct bcma_device *ns_core; + int ns_gmac; + +-- +1.8.4.5 + diff --git a/target/linux/generic/patches-3.19/071-bgmac-Clean-warning-messages.patch b/target/linux/generic/patches-3.19/071-bgmac-Clean-warning-messages.patch new file mode 100644 index 0000000000..fd3e11d672 --- /dev/null +++ b/target/linux/generic/patches-3.19/071-bgmac-Clean-warning-messages.patch @@ -0,0 +1,55 @@ +From 8edfe3b6fad28da191c8fa15e4e0d8f7335a0091 Mon Sep 17 00:00:00 2001 +From: Peter Senna Tschudin +Date: Sat, 7 Mar 2015 12:10:26 +0100 +Subject: [PATCH] bgmac: Clean warning messages +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On my test environment the throughput of a file transfer drops +from 4.4MBps to 116KBps due the number of repeated warning +messages. This patch removes the warning messages as DMA works +correctly with addresses using 0xC0000000 bits. + +Signed-off-by: Peter Senna Tschudin +Acked-by: Rafał Miłecki +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c +index 676ffe0..0469f72 100644 +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -302,9 +302,6 @@ static int bgmac_dma_rx_skb_for_slot(struct bgmac *bgmac, + slot->skb = skb; + slot->dma_addr = dma_addr; + +- if (slot->dma_addr & 0xC0000000) +- bgmac_warn(bgmac, "DMA address using 0xC0000000 bit(s), it may need translation trick\n"); +- + return 0; + } + +@@ -505,8 +502,6 @@ static int bgmac_dma_alloc(struct bgmac *bgmac) + ring->mmio_base); + goto err_dma_free; + } +- if (ring->dma_base & 0xC0000000) +- bgmac_warn(bgmac, "DMA address using 0xC0000000 bit(s), it may need translation trick\n"); + + ring->unaligned = bgmac_dma_unaligned(bgmac, ring, + BGMAC_DMA_RING_TX); +@@ -536,8 +531,6 @@ static int bgmac_dma_alloc(struct bgmac *bgmac) + err = -ENOMEM; + goto err_dma_free; + } +- if (ring->dma_base & 0xC0000000) +- bgmac_warn(bgmac, "DMA address using 0xC0000000 bit(s), it may need translation trick\n"); + + ring->unaligned = bgmac_dma_unaligned(bgmac, ring, + BGMAC_DMA_RING_RX); +-- +1.8.4.5 + diff --git a/target/linux/generic/patches-3.19/072-bgmac-register-fixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch b/target/linux/generic/patches-3.19/072-bgmac-register-fixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch new file mode 100644 index 0000000000..472b22b0e7 --- /dev/null +++ b/target/linux/generic/patches-3.19/072-bgmac-register-fixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch @@ -0,0 +1,81 @@ +From c25b23b8a387e7d31f7a74af8e37b61e9e6ebb21 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 20 Mar 2015 23:14:31 +0100 +Subject: [PATCH] bgmac: register fixed PHY for ARM BCM470X / BCM5301X chipsets +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On ARM SoCs with bgmac Ethernet hardware we don't have any normal PHY. +There is always a switch attached but it's not even controlled over MDIO +like in case of MIPS devices. +We need a fixed PHY to be able to send/receive packets from the switch. + +Signed-off-by: Rafał Miłecki +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 34 ++++++++++++++++++++++++++++++++++ + 1 file changed, 34 insertions(+) + +diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c +index 0469f72..efda7cf 100644 +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -1330,13 +1331,46 @@ static void bgmac_adjust_link(struct net_device *net_dev) + } + } + ++static int bgmac_fixed_phy_register(struct bgmac *bgmac) ++{ ++ struct fixed_phy_status fphy_status = { ++ .link = 1, ++ .speed = SPEED_1000, ++ .duplex = DUPLEX_FULL, ++ }; ++ struct phy_device *phy_dev; ++ int err; ++ ++ phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, NULL); ++ if (!phy_dev || IS_ERR(phy_dev)) { ++ bgmac_err(bgmac, "Failed to register fixed PHY device\n"); ++ return -ENODEV; ++ } ++ ++ err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link, ++ PHY_INTERFACE_MODE_MII); ++ if (err) { ++ bgmac_err(bgmac, "Connecting PHY failed\n"); ++ return err; ++ } ++ ++ bgmac->phy_dev = phy_dev; ++ ++ return err; ++} ++ + static int bgmac_mii_register(struct bgmac *bgmac) + { ++ struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo; + struct mii_bus *mii_bus; + struct phy_device *phy_dev; + char bus_id[MII_BUS_ID_SIZE + 3]; + int i, err = 0; + ++ if (ci->id == BCMA_CHIP_ID_BCM4707 || ++ ci->id == BCMA_CHIP_ID_BCM53018) ++ return bgmac_fixed_phy_register(bgmac); ++ + mii_bus = mdiobus_alloc(); + if (!mii_bus) + return -ENOMEM; +-- +1.8.4.5 + diff --git a/target/linux/generic/patches-3.19/073-bgmac-allow-enabling-on-ARCH_BCM_5301X.patch b/target/linux/generic/patches-3.19/073-bgmac-allow-enabling-on-ARCH_BCM_5301X.patch new file mode 100644 index 0000000000..674d561181 --- /dev/null +++ b/target/linux/generic/patches-3.19/073-bgmac-allow-enabling-on-ARCH_BCM_5301X.patch @@ -0,0 +1,33 @@ +From fc300dc3733fdc328e6e10c7b8379b60c26cd648 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 20 Mar 2015 23:14:32 +0100 +Subject: [PATCH] bgmac: allow enabling on ARCH_BCM_5301X +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Home routers based on ARM SoCs like BCM4708 also have bcma bus with core +supported by bgmac. + +Signed-off-by: Rafał Miłecki +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig +index ee4fdfe..a6f9142 100644 +--- a/drivers/net/ethernet/broadcom/Kconfig ++++ b/drivers/net/ethernet/broadcom/Kconfig +@@ -142,7 +142,7 @@ config BNX2X_SRIOV + + config BGMAC + tristate "BCMA bus GBit core support" +- depends on BCMA_HOST_SOC && HAS_DMA && BCM47XX ++ depends on BCMA_HOST_SOC && HAS_DMA && (BCM47XX || ARCH_BCM_5301X) + select PHYLIB + ---help--- + This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus. +-- +1.8.4.5 + diff --git a/target/linux/generic/patches-3.19/770-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch b/target/linux/generic/patches-3.19/770-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch deleted file mode 100644 index 1d6b66c199..0000000000 --- a/target/linux/generic/patches-3.19/770-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch +++ /dev/null @@ -1,41 +0,0 @@ -From b053c5ad4d99d8f025efadd5c8b4bd84ea06eb6f Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= -Date: Wed, 11 Feb 2015 17:55:32 +0100 -Subject: [PATCH FIX] bgmac: fix device initialization on Northstar SoCs - (condition typo) -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -On Northstar (Broadcom's ARM architecture) we need to manually enable -all cores. Code for that is already in place, but the condition for it -was wrong. - -Signed-off-by: Rafał Miłecki ---- -Can we have it for 3.20, please? ---- - drivers/net/ethernet/broadcom/bgmac.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - ---- a/drivers/net/ethernet/broadcom/bgmac.c -+++ b/drivers/net/ethernet/broadcom/bgmac.c -@@ -1412,6 +1412,7 @@ static void bgmac_mii_unregister(struct - /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */ - static int bgmac_probe(struct bcma_device *core) - { -+ struct bcma_chipinfo *ci = &core->bus->chipinfo; - struct net_device *net_dev; - struct bgmac *bgmac; - struct ssb_sprom *sprom = &core->bus->sprom; -@@ -1474,8 +1475,8 @@ static int bgmac_probe(struct bcma_devic - bgmac_chip_reset(bgmac); - - /* For Northstar, we have to take all GMAC core out of reset */ -- if (core->id.id == BCMA_CHIP_ID_BCM4707 || -- core->id.id == BCMA_CHIP_ID_BCM53018) { -+ if (ci->id == BCMA_CHIP_ID_BCM4707 || -+ ci->id == BCMA_CHIP_ID_BCM53018) { - struct bcma_device *ns_core; - int ns_gmac; - diff --git a/target/linux/generic/patches-3.19/773-bgmac-add-srab-switch.patch b/target/linux/generic/patches-3.19/773-bgmac-add-srab-switch.patch index ef12cac9bf..0a8b451247 100644 --- a/target/linux/generic/patches-3.19/773-bgmac-add-srab-switch.patch +++ b/target/linux/generic/patches-3.19/773-bgmac-add-srab-switch.patch @@ -4,15 +4,15 @@ Signed-off-by: Hauke Mehrtens --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c -@@ -16,6 +16,7 @@ - #include +@@ -17,6 +17,7 @@ + #include #include #include +#include #include static const struct bcma_device_id bgmac_bcma_tbl[] = { -@@ -1405,6 +1406,17 @@ static void bgmac_mii_unregister(struct +@@ -1432,6 +1433,17 @@ static void bgmac_mii_unregister(struct mdiobus_free(mii_bus); } @@ -30,7 +30,7 @@ Signed-off-by: Hauke Mehrtens /************************************************** * BCMA bus ops **************************************************/ -@@ -1524,6 +1536,16 @@ static int bgmac_probe(struct bcma_devic +@@ -1551,6 +1563,16 @@ static int bgmac_probe(struct bcma_devic goto err_dma_free; } @@ -47,7 +47,7 @@ Signed-off-by: Hauke Mehrtens err = register_netdev(bgmac->net_dev); if (err) { bgmac_err(bgmac, "Cannot register net device\n"); -@@ -1550,6 +1572,10 @@ static void bgmac_remove(struct bcma_dev +@@ -1577,6 +1599,10 @@ static void bgmac_remove(struct bcma_dev { struct bgmac *bgmac = bcma_get_drvdata(core); diff --git a/target/linux/generic/patches-3.19/775-bgmac-check-length-of-received-frame.patch b/target/linux/generic/patches-3.19/775-bgmac-check-length-of-received-frame.patch index c3d63b65fa..883c77b2f5 100644 --- a/target/linux/generic/patches-3.19/775-bgmac-check-length-of-received-frame.patch +++ b/target/linux/generic/patches-3.19/775-bgmac-check-length-of-received-frame.patch @@ -9,7 +9,7 @@ Subject: [PATCH] bgmac: check length of received frame --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c -@@ -363,6 +363,27 @@ static int bgmac_dma_rx_read(struct bgma +@@ -361,6 +361,27 @@ static int bgmac_dma_rx_read(struct bgma dma_addr_t old_dma_addr = slot->dma_addr; int err; diff --git a/target/linux/generic/patches-4.0/070-bgmac-register-fixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch b/target/linux/generic/patches-4.0/070-bgmac-register-fixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch new file mode 100644 index 0000000000..472b22b0e7 --- /dev/null +++ b/target/linux/generic/patches-4.0/070-bgmac-register-fixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch @@ -0,0 +1,81 @@ +From c25b23b8a387e7d31f7a74af8e37b61e9e6ebb21 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 20 Mar 2015 23:14:31 +0100 +Subject: [PATCH] bgmac: register fixed PHY for ARM BCM470X / BCM5301X chipsets +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On ARM SoCs with bgmac Ethernet hardware we don't have any normal PHY. +There is always a switch attached but it's not even controlled over MDIO +like in case of MIPS devices. +We need a fixed PHY to be able to send/receive packets from the switch. + +Signed-off-by: Rafał Miłecki +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 34 ++++++++++++++++++++++++++++++++++ + 1 file changed, 34 insertions(+) + +diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c +index 0469f72..efda7cf 100644 +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -1330,13 +1331,46 @@ static void bgmac_adjust_link(struct net_device *net_dev) + } + } + ++static int bgmac_fixed_phy_register(struct bgmac *bgmac) ++{ ++ struct fixed_phy_status fphy_status = { ++ .link = 1, ++ .speed = SPEED_1000, ++ .duplex = DUPLEX_FULL, ++ }; ++ struct phy_device *phy_dev; ++ int err; ++ ++ phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, NULL); ++ if (!phy_dev || IS_ERR(phy_dev)) { ++ bgmac_err(bgmac, "Failed to register fixed PHY device\n"); ++ return -ENODEV; ++ } ++ ++ err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link, ++ PHY_INTERFACE_MODE_MII); ++ if (err) { ++ bgmac_err(bgmac, "Connecting PHY failed\n"); ++ return err; ++ } ++ ++ bgmac->phy_dev = phy_dev; ++ ++ return err; ++} ++ + static int bgmac_mii_register(struct bgmac *bgmac) + { ++ struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo; + struct mii_bus *mii_bus; + struct phy_device *phy_dev; + char bus_id[MII_BUS_ID_SIZE + 3]; + int i, err = 0; + ++ if (ci->id == BCMA_CHIP_ID_BCM4707 || ++ ci->id == BCMA_CHIP_ID_BCM53018) ++ return bgmac_fixed_phy_register(bgmac); ++ + mii_bus = mdiobus_alloc(); + if (!mii_bus) + return -ENOMEM; +-- +1.8.4.5 + diff --git a/target/linux/generic/patches-4.0/071-bgmac-allow-enabling-on-ARCH_BCM_5301X.patch b/target/linux/generic/patches-4.0/071-bgmac-allow-enabling-on-ARCH_BCM_5301X.patch new file mode 100644 index 0000000000..674d561181 --- /dev/null +++ b/target/linux/generic/patches-4.0/071-bgmac-allow-enabling-on-ARCH_BCM_5301X.patch @@ -0,0 +1,33 @@ +From fc300dc3733fdc328e6e10c7b8379b60c26cd648 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 20 Mar 2015 23:14:32 +0100 +Subject: [PATCH] bgmac: allow enabling on ARCH_BCM_5301X +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Home routers based on ARM SoCs like BCM4708 also have bcma bus with core +supported by bgmac. + +Signed-off-by: Rafał Miłecki +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig +index ee4fdfe..a6f9142 100644 +--- a/drivers/net/ethernet/broadcom/Kconfig ++++ b/drivers/net/ethernet/broadcom/Kconfig +@@ -142,7 +142,7 @@ config BNX2X_SRIOV + + config BGMAC + tristate "BCMA bus GBit core support" +- depends on BCMA_HOST_SOC && HAS_DMA && BCM47XX ++ depends on BCMA_HOST_SOC && HAS_DMA && (BCM47XX || ARCH_BCM_5301X) + select PHYLIB + ---help--- + This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus. +-- +1.8.4.5 + diff --git a/target/linux/generic/patches-4.0/773-bgmac-add-srab-switch.patch b/target/linux/generic/patches-4.0/773-bgmac-add-srab-switch.patch index e49a841b0b..0a8b451247 100644 --- a/target/linux/generic/patches-4.0/773-bgmac-add-srab-switch.patch +++ b/target/linux/generic/patches-4.0/773-bgmac-add-srab-switch.patch @@ -4,15 +4,15 @@ Signed-off-by: Hauke Mehrtens --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c -@@ -16,6 +16,7 @@ - #include +@@ -17,6 +17,7 @@ + #include #include #include +#include #include static const struct bcma_device_id bgmac_bcma_tbl[] = { -@@ -1398,6 +1399,17 @@ static void bgmac_mii_unregister(struct +@@ -1432,6 +1433,17 @@ static void bgmac_mii_unregister(struct mdiobus_free(mii_bus); } @@ -30,7 +30,7 @@ Signed-off-by: Hauke Mehrtens /************************************************** * BCMA bus ops **************************************************/ -@@ -1517,6 +1529,16 @@ static int bgmac_probe(struct bcma_devic +@@ -1551,6 +1563,16 @@ static int bgmac_probe(struct bcma_devic goto err_dma_free; } @@ -47,7 +47,7 @@ Signed-off-by: Hauke Mehrtens err = register_netdev(bgmac->net_dev); if (err) { bgmac_err(bgmac, "Cannot register net device\n"); -@@ -1543,6 +1565,10 @@ static void bgmac_remove(struct bcma_dev +@@ -1577,6 +1599,10 @@ static void bgmac_remove(struct bcma_dev { struct bgmac *bgmac = bcma_get_drvdata(core); diff --git a/target/linux/generic/patches-4.0/775-bgmac-check-length-of-received-frame.patch b/target/linux/generic/patches-4.0/775-bgmac-check-length-of-received-frame.patch index d39626b160..883c77b2f5 100644 --- a/target/linux/generic/patches-4.0/775-bgmac-check-length-of-received-frame.patch +++ b/target/linux/generic/patches-4.0/775-bgmac-check-length-of-received-frame.patch @@ -9,7 +9,7 @@ Subject: [PATCH] bgmac: check length of received frame --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c -@@ -360,6 +360,27 @@ static int bgmac_dma_rx_read(struct bgma +@@ -361,6 +361,27 @@ static int bgmac_dma_rx_read(struct bgma dma_addr_t old_dma_addr = slot->dma_addr; int err;