add NS2 support to bgmac
Subsystems (6)
v4 cover add NS2 support to bgmac
Changes in v4:
* Actually send out the lane swap binding doc patch (Per Scott Branden)
* Remove unused #define (Per Andrew Lunn)
Changes in v3:
* Clean-up the bgmac DT binding doc (per Rob Herring)
* Document the lane swap binding and make it generic (Per Andrew Lunn)
Changes in v2:
* Remove the PHY power-on (per Andrew Lunn)
* Misc PHY clean-ups regarding comments and #defines (per Andrew Lunn) This results on none of the original PHY code from Vikas being present. So, I'm removing him as an author and giving him "Inspired-by" credit.
* Move PHY lane swapping to PHY driver (per Andrew Lunn and Florian Fainelli)
* Remove bgmac sleep (per Florian Fainelli)
* Re-add bgmac chip reset (per Florian Fainelli and Ray Jui)
* Rebased on latest net-next
* Added patch for bcm54xx_auxctl_read, which is used in the BCM54810
Add support for the amac found in the Broadcom Northstar2 SoC to the bgmac driver. This necessitates adding support to connect to an externally defined phy (as described in the device tree) in the driver. These phy changes are in addition to the changes necessary to get NS2 working.
Jon Mason (7):
net: phy: broadcom: add bcm54xx_auxctl_read
Documentation: devicetree: add PHY lane swap binding
net: phy: broadcom: Add BCM54810 PHY entry
Documentation: devicetree: net: add NS2 bindings to amac
net: ethernet: bgmac: device tree phy enablement
net: ethernet: bgmac: add NS2 support
arm64: dts: NS2: add AMAC ethernet support
.../devicetree/bindings/net/brcm,amac.txt | 16 ++-- Documentation/devicetree/bindings/net/phy.txt | 3 + arch/arm64/boot/dts/broadcom/ns2-svk.dts | 5 ++ arch/arm64/boot/dts/broadcom/ns2.dtsi | 12 +++ drivers/net/ethernet/broadcom/bgmac-bcma.c | 48 ++++++++++ drivers/net/ethernet/broadcom/bgmac-platform.c | 100 ++++++++++++++++++++- drivers/net/ethernet/broadcom/bgmac.c | 55 ++---------- drivers/net/ethernet/broadcom/bgmac.h | 8 ++ drivers/net/phy/Kconfig | 2 +- drivers/net/phy/broadcom.c | 68 +++++++++++++- include/linux/brcmphy.h | 10 +++ 11 files changed, 270 insertions(+), 57 deletions(-)
Signature · 1 line
2.7.4
PATCH v4 1/7 net: phy: broadcom: add bcm54xx_auxctl_read
Add a helper function to read the AUXCTL register for the BCM54xx. This mirrors the bcm54xx_auxctl_write function already present in the code.
--- drivers/net/phy/broadcom.c | 10 ++++++++++ include/linux/brcmphy.h | 1 + 2 files changed, 11 insertions(+)
drivers/net/phy/broadcom.c +10 -0
@@ -30,6 +30,16 @@ MODULE_DESCRIPTION("Broadcom PHY driver");MODULE_AUTHOR ("Maciej W. Rozycki" );MODULE_LICENSE ("GPL" ); +static int bcm54xx_auxctl_read (struct phy_device *phydev,u16 regnum) +{ +/* The register must be written to both the Shadow Register Select and +* the Shadow Read Register Selector +*/ +phy_write (phydev,MII_BCM54XX_AUX_CTL , regnum | + regnum <<MII_BCM54XX_AUXCTL_SHDWSEL_READ_SHIFT ); +return phy_read (phydev,MII_BCM54XX_AUX_CTL ); +} +static int bcm54xx_auxctl_write (struct phy_device *phydev,u16 regnum,u16 val) {return phy_write (phydev,MII_BCM54XX_AUX_CTL , regnum | val);
include/linux/brcmphy.h +1 -0
@@ -110,6 +110,7 @@#define MII_BCM54XX_AUXCTL_MISC_FORCE_AMDIX 0x0200#define MII_BCM54XX_AUXCTL_MISC_RDSEL_MISC 0x7000#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC 0x0007 +#define MII_BCM54XX_AUXCTL_SHDWSEL_READ_SHIFT 12#define MII_BCM54XX_AUXCTL_SHDWSEL_MASK 0x0007
Signature · 1 line
2.7.4
PATCH v4 2/7 Documentation: devicetree: add PHY lane swap binding
In reply to Jon MasonAdd the documentation for PHY lane swapping. This is a boolean entry to notify the phy device drivers that the TX/RX lanes need to be swapped.
--- Documentation/devicetree/bindings/net/phy.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/net/phy.txt +3 -0
@@ -35,6 +35,9 @@ Optional Properties: - broken-turn-around: If set, indicates the PHY device does not correctly release the turn around line low at the end of a MDIO transaction. +- enet-phy-lane-swap: If set, indicates the PHY device requires swapping the + TX/RX lanes to function properly. + Example: ethernet-phy at 0 {
Signature · 1 line
2.7.4
Andrew Lunn
maintainerRe: [PATCH v4 2/7] Documentation: devicetree: add PHY lane swap binding
Quoted 2 lines
+- enet-phy-lane-swap: If set, indicates the PHY device requires swapping the + TX/RX lanes to function properly.
Is 'requires' the right word here? The PHY performs the actual swap of the Tx/Rx lanes.
Andrew
Re: [PATCH v4 2/7] Documentation: devicetree: add PHY lane swap binding
Quoted 5 lines · Andrew Lunn
Quoted 2 lines
+- enet-phy-lane-swap: If set, indicates the PHY device requires swapping the + TX/RX lanes to function properly.Is 'requires' the right word here? The PHY performs the actual swap of the Tx/Rx lanes.
What I'm trying to say here is that without the lane swapping, the PHY will not function properly. Thus, those PHYs require this parameter to work. I am open to suggestions to reword the sentence to make it clearer.
Thanks,
Jon
Quoted 2 lines
Andrew
Re: [PATCH v4 2/7] Documentation: devicetree: add PHY lane swap binding
Quoted 11 lines · Jon Mason
Quoted 5 lines · Andrew Lunn
Quoted 2 lines
+- enet-phy-lane-swap: If set, indicates the PHY device requires swapping the + TX/RX lanes to function properly.Is 'requires' the right word here? The PHY performs the actual swap of the Tx/Rx lanes.
What I'm trying to say here is that without the lane swapping, the PHY will not function properly. Thus, those PHYs require this parameter to work. I am open to suggestions to reword the sentence to make it clearer.
If set, indicates the PHY will swap the TX/RX lanes to compensate for the board being designed with the lanes swapped.
Quoted 6 lines
Thanks,
JonQuoted 2 lines
Andrew
Andrew Lunn
maintainerRe: [PATCH v4 2/7] Documentation: devicetree: add PHY lane swap binding
Quoted 2 lines
If set, indicates the PHY will swap the TX/RX lanes to compensate for the board being designed with the lanes swapped.
Thanks, much better.
Andrew
PATCH v4 3/7 net: phy: broadcom: Add BCM54810 PHY entry
In reply to Jon MasonThe BCM54810 PHY requires some semi-unique configuration, which results in some additional configuration in addition to the standard config. Also, some users of the BCM54810 require the PHY lanes to be swapped. Since there is no way to detect this, add a device tree query to see if it is applicable.
--- drivers/net/phy/Kconfig | 2 +- drivers/net/phy/broadcom.c | 58 +++++++++++++++++++++++++++++++++++++++++++++- include/linux/brcmphy.h | 9 +++++++ 3 files changed, 67 insertions(+), 2 deletions(-)
drivers/net/phy/Kconfig +1 -1
@@ -217,7 +217,7 @@ config BROADCOM_PHY select BCM_NET_PHYLIB ---help--- Currently supports the BCM5411, BCM5421, BCM5461, BCM54616S, BCM5464, - BCM5481 and BCM5482 PHYs. + BCM5481, BCM54810 and BCM5482 PHYs. config CICADA_PHY tristate "Cicada PHYs"
drivers/net/phy/broadcom.c +57 -1
100 lines not on this page · raw message
include/linux/brcmphy.h +9 -0
@@ -13,6 +13,7 @@#define PHY_ID_BCM5241 0x0143bc30#define PHY_ID_BCMAC131 0x0143bc70#define PHY_ID_BCM5481 0x0143bca0 +#define PHY_ID_BCM54810 0x03625d00#define PHY_ID_BCM5482 0x0143bcb0#define PHY_ID_BCM5411 0x00206070#define PHY_ID_BCM5421 0x002060e0
@@ -56,6 +57,7 @@#define PHY_BRCM_EXT_IBND_TX_ENABLE 0x00002000#define PHY_BRCM_CLEAR_RGMII_MODE 0x00004000#define PHY_BRCM_DIS_TXCRXC_NOENRGY 0x00008000 +/* Broadcom BCM7xxx specific workarounds */ #define PHY_BRCM_7XXX_REV (x) (((x) >> 8) & 0xff)#define PHY_BRCM_7XXX_PATCH (x) ((x) & 0xff)
@@ -111,6 +113,7 @@#define MII_BCM54XX_AUXCTL_MISC_RDSEL_MISC 0x7000#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC 0x0007#define MII_BCM54XX_AUXCTL_SHDWSEL_READ_SHIFT 12 +#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN (1 << 8)#define MII_BCM54XX_AUXCTL_SHDWSEL_MASK 0x0007
@@ -192,6 +195,12 @@#define BCM5482_SSD_SGMII_SLAVE_EN 0x0002/* Slave mode enable */ #define BCM5482_SSD_SGMII_SLAVE_AD 0x0001/* Slave auto-detection */ +/* BCM54810 Registers */ +#define BCM54810_EXP_BROADREACH_LRE_MISC_CTL (MII_BCM54XX_EXP_SEL_ER + 0x90) +#define BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN (1 << 0) +#define BCM54810_SHD_CLK_CTL 0x3 +#define BCM54810_SHD_CLK_CTL_GTXCLK_EN (1 << 9) +/*****************************************************************************/ /* Fast Ethernet Transceiver definitions. */
Signature · 1 line
2.7.4
PATCH v4 4/7 Documentation: devicetree: net: add NS2 bindings to amac
In reply to Jon MasonClean-up the documentation to the bgmac-amac driver, per suggestion by Rob Herring, and add details for NS2 support.
--- Documentation/devicetree/bindings/net/brcm,amac.txt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/net/brcm,amac.txt +11 -5
@@ -2,11 +2,17 @@ Broadcom AMAC Ethernet Controller Device Tree Bindings ------------------------------------------------------------- Required properties: - - compatible: "brcm,amac" or "brcm,nsp-amac" - - reg: Address and length of the GMAC registers, - Address and length of the GMAC IDM registers - - reg-names: Names of the registers. Must have both "amac_base" and - "idm_base" + - compatible: "brcm,amac" + "brcm,nsp-amac" + "brcm,ns2-amac" + - reg: Address and length of the register set for the device. It + contains the information of registers in the same order as + described by reg-names + - reg-names: Names of the registers. + "amac_base": Address and length of the GMAC registers + "idm_base": Address and length of the GMAC IDM registers + "nicpm_base": Address and length of the NIC Port Manager + registers (required for Northstar2) - interrupts: Interrupt number Optional properties:
Signature · 1 line
2.7.4
PATCH v4 5/7 net: ethernet: bgmac: device tree phy enablement
In reply to Jon MasonChange the bgmac driver to allow for phy's defined by the device tree
--- drivers/net/ethernet/broadcom/bgmac-bcma.c | 48 ++++++++++++++++++++++++ drivers/net/ethernet/broadcom/bgmac-platform.c | 48 +++++++++++++++++++++++- drivers/net/ethernet/broadcom/bgmac.c | 52 ++------------------------ drivers/net/ethernet/broadcom/bgmac.h | 7 ++++ 4 files changed, 105 insertions(+), 50 deletions(-)
drivers/net/ethernet/broadcom/bgmac-bcma.c +48 -0
@@ -80,6 +80,50 @@ static void bcma_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset, u32 mask,bcma_maskset32 (bgmac->bcma.cmn, offset, mask, set); } +static int bcma_phy_connect (struct bgmac *bgmac) +{ +struct phy_device *phy_dev; +char bus_id[MII_BUS_ID_SIZE +3 ]; + +/* Connect to the PHY */ +snprintf (bus_id,sizeof (bus_id),PHY_ID_FMT , bgmac->mii_bus->id, + bgmac->phyaddr); + phy_dev =phy_connect (bgmac->net_dev, bus_id, bgmac_adjust_link, +PHY_INTERFACE_MODE_MII ); +if (IS_ERR (phy_dev)) { +dev_err (bgmac->dev,"PHY connecton failed\n" ); +return PTR_ERR (phy_dev); + } + +return 0 ; +} + +static int bcma_phy_direct_connect (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,-1 ,NULL ); +if (!phy_dev ||IS_ERR (phy_dev)) { +dev_err (bgmac->dev,"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) { +dev_err (bgmac->dev,"Connecting PHY failed\n" ); +return err; + } + +return err; +} +static const struct bcma_device_id bgmac_bcma_tbl[] = {BCMA_CORE (BCMA_MANUF_BCM ,BCMA_CORE_4706_MAC_GBIT ,BCMA_ANY_REV ,BCMA_ANY_CLASS ),
@@ -275,6 +319,10 @@ static int bgmac_probe(struct bcma_device *core) bgmac->cco_ctl_maskset = bcma_bgmac_cco_ctl_maskset; bgmac->get_bus_clock = bcma_bgmac_get_bus_clock; bgmac->cmn_maskset32 = bcma_bgmac_cmn_maskset32; +if (bgmac->mii_bus) + bgmac->phy_connect = bcma_phy_connect; +else + bgmac->phy_connect = bcma_phy_direct_connect; err =bgmac_enet_probe (bgmac);if (err)
drivers/net/ethernet/broadcom/bgmac-platform.c +47 -1
72 lines not on this page · raw message
drivers/net/ethernet/broadcom/bgmac.c +3 -49
70 lines not on this page · raw message
drivers/net/ethernet/broadcom/bgmac.h +7 -0
@@ -513,10 +513,12 @@ struct bgmac {u32 (*get_bus_clock)(struct bgmac *bgmac);void (*cmn_maskset32)(struct bgmac *bgmac,u16 offset,u32 mask,u32 set); +int (*phy_connect)(struct bgmac *bgmac); };int bgmac_enet_probe (struct bgmac *info);void bgmac_enet_remove (struct bgmac *bgmac); +void bgmac_adjust_link (struct net_device *net_dev);struct mii_bus *bcma_mdio_mii_register (struct bcma_device *core,u8 phyaddr);void bcma_mdio_mii_unregister (struct mii_bus *mii_bus);
@@ -583,4 +585,9 @@ static inline void bgmac_set(struct bgmac *bgmac, u16 offset, u32 set) {bgmac_maskset (bgmac, offset, ~0 , set); } + +static inline int bgmac_phy_connect (struct bgmac *bgmac) +{ +return bgmac->phy_connect (bgmac); +}#endif /* _BGMAC_H */
Signature · 1 line
2.7.4
PATCH v4 6/7 net: ethernet: bgmac: add NS2 support
In reply to Jon MasonAdd support for the variant of amac hardware present in the Broadcom Northstar2 based SoCs. Northstar2 requires an additional register to be configured with the port speed/duplexity (NICPM). This can be added to the link callback to hide it from the instances that do not use this. Also, clearing of the pending interrupts on init is required due to observed issues on some platforms.
--- drivers/net/ethernet/broadcom/bgmac-platform.c | 56 +++++++++++++++++++++++++- drivers/net/ethernet/broadcom/bgmac.c | 3 ++ drivers/net/ethernet/broadcom/bgmac.h | 1 + 3 files changed, 58 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bgmac-platform.c +54 -2
@@ -14,12 +14,21 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/bcma/bcma.h> +#include <linux/brcmphy.h> #include <linux/etherdevice.h> #include <linux/of_address.h> #include <linux/of_mdio.h> #include <linux/of_net.h> #include "bgmac.h" +#define NICPM_IOMUX_CTRL 0x00000008 + +#define NICPM_IOMUX_CTRL_INIT_VAL 0x3196e000 +#define NICPM_IOMUX_CTRL_SPD_SHIFT 10 +#define NICPM_IOMUX_CTRL_SPD_10M 0 +#define NICPM_IOMUX_CTRL_SPD_100M 1 +#define NICPM_IOMUX_CTRL_SPD_1000M 2 +static u32 platform_bgmac_read (struct bgmac *bgmac,u16 offset) {return readl (bgmac->plat.base + offset);
@@ -87,12 +96,46 @@ static void platform_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset,WARN_ON (1 ); } +static void bgmac_nicpm_speed_set (struct net_device *net_dev) +{ +struct bgmac *bgmac =netdev_priv (net_dev); +u32 val; + +if (!bgmac->plat.nicpm_base) +return ; + + val =NICPM_IOMUX_CTRL_INIT_VAL ; +switch (bgmac->net_dev->phydev->speed) { +default : +pr_err ("Unsupported speed. Defaulting to 1000Mb\n" ); +case SPEED_1000 : + val |=NICPM_IOMUX_CTRL_SPD_1000M <<NICPM_IOMUX_CTRL_SPD_SHIFT ; +break ; +case SPEED_100 : + val |=NICPM_IOMUX_CTRL_SPD_100M <<NICPM_IOMUX_CTRL_SPD_SHIFT ; +break ; +case SPEED_10 : + val |=NICPM_IOMUX_CTRL_SPD_10M <<NICPM_IOMUX_CTRL_SPD_SHIFT ; +break ; + } + +writel (val, bgmac->plat.nicpm_base +NICPM_IOMUX_CTRL ); + +bgmac_adjust_link (bgmac->net_dev); +} +static int platform_phy_connect (struct bgmac *bgmac) {struct phy_device *phy_dev; - phy_dev =of_phy_get_and_connect (bgmac->net_dev, bgmac->dev->of_node, - bgmac_adjust_link); +if (bgmac->plat.nicpm_base) + phy_dev =of_phy_get_and_connect (bgmac->net_dev, + bgmac->dev->of_node, + bgmac_nicpm_speed_set); +else + phy_dev =of_phy_get_and_connect (bgmac->net_dev, + bgmac->dev->of_node, + bgmac_adjust_link);if (!phy_dev) {dev_err (bgmac->dev,"Phy connect failed\n" );return -ENODEV ;
@@ -182,6 +225,14 @@ static int bgmac_probe(struct platform_device *pdev)if (IS_ERR (bgmac->plat.idm_base))return PTR_ERR (bgmac->plat.idm_base); + regs =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"nicpm_base" ); +if (regs) { + bgmac->plat.nicpm_base =devm_ioremap_resource (&pdev->dev, + regs); +if (IS_ERR (bgmac->plat.nicpm_base)) +return PTR_ERR (bgmac->plat.nicpm_base); + } + bgmac->read = platform_bgmac_read; bgmac->write = platform_bgmac_write; bgmac->idm_read = platform_bgmac_idm_read;
@@ -213,6 +264,7 @@ static int bgmac_remove(struct platform_device *pdev)static const struct of_device_id bgmac_of_enet_match[] = { {.compatible ="brcm,amac" ,}, {.compatible ="brcm,nsp-amac" ,}, + {.compatible ="brcm,ns2-amac" ,}, {}, };
drivers/net/ethernet/broadcom/bgmac.c +3 -0
@@ -1082,6 +1082,9 @@ static void bgmac_enable(struct bgmac *bgmac)/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */ static void bgmac_chip_init (struct bgmac *bgmac) { +/* Clear any erroneously pending interrupts */ +bgmac_write (bgmac,BGMAC_INT_STATUS , ~0 ); +/* 1 interrupt per received frame */ bgmac_write (bgmac,BGMAC_INT_RECV_LAZY ,1 <<BGMAC_IRL_FC_SHIFT );
drivers/net/ethernet/broadcom/bgmac.h +1 -0
@@ -463,6 +463,7 @@ struct bgmac {struct {void *base;void *idm_base; +void *nicpm_base; } plat;struct {struct bcma_device *core;
Signature · 1 line
2.7.4
Re: [PATCH v4 6/7] net: ethernet: bgmac: add NS2 support
One change in this patch
Quoted 46 lines · Jon Mason
Add support for the variant of amac hardware present in the Broadcom Northstar2 based SoCs. Northstar2 requires an additional register to be configured with the port speed/duplexity (NICPM). This can be added to the link callback to hide it from the instances that do not use this. Also, clearing of the pending interrupts on init is required due to observed issues on some platforms.
Signed-off-by Jon Mason <[email protected]>--- drivers/net/ethernet/broadcom/bgmac-platform.c | 56 +++++++++++++++++++++++++- drivers/net/ethernet/broadcom/bgmac.c | 3 ++ drivers/net/ethernet/broadcom/bgmac.h | 1 + 3 files changed, 58 insertions(+), 2 deletions(-)drivers/net/ethernet/broadcom/bgmac-platform.c +11
-0@@ -14,12 +14,21 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/bcma/bcma.h> +#include <linux/brcmphy.h> #include <linux/etherdevice.h> #include <linux/of_address.h> #include <linux/of_mdio.h> #include <linux/of_net.h> #include "bgmac.h" +#define NICPM_IOMUX_CTRL 0x00000008 + +#define NICPM_IOMUX_CTRL_INIT_VAL 0x3196e000 +#define NICPM_IOMUX_CTRL_SPD_SHIFT 10 +#define NICPM_IOMUX_CTRL_SPD_10M 0 +#define NICPM_IOMUX_CTRL_SPD_100M 1 +#define NICPM_IOMUX_CTRL_SPD_1000M 2 +static u32 platform_bgmac_read (struct bgmac *bgmac,u16 offset) {return readl (bgmac->plat.base + offset);@@ -87,12 +96,46 @@ static void platform_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset,WARN_ON (1 ); } +static void bgmac_nicpm_speed_set (struct net_device *net_dev) +{
drivers/net/ethernet/broadcom/bgmac-platform.c static void platform_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset, · line 110
Quoted 10 lines
drivers/net/ethernet/broadcom/bgmac-platform.c +10
-0+struct bgmac *bgmac =netdev_priv (net_dev); +u32 val; + +if (!bgmac->plat.nicpm_base) +return ; + + val =NICPM_IOMUX_CTRL_INIT_VAL ; +switch (bgmac->net_dev->phydev->speed) { +default : +pr_err ("Unsupported speed. Defaulting to 1000Mb\n" );
This should be dev_err
Quoted 83 lines
drivers/net/ethernet/broadcom/bgmac-platform.c +33
-2+case SPEED_1000 : + val |=NICPM_IOMUX_CTRL_SPD_1000M <<NICPM_IOMUX_CTRL_SPD_SHIFT ; +break ; +case SPEED_100 : + val |=NICPM_IOMUX_CTRL_SPD_100M <<NICPM_IOMUX_CTRL_SPD_SHIFT ; +break ; +case SPEED_10 : + val |=NICPM_IOMUX_CTRL_SPD_10M <<NICPM_IOMUX_CTRL_SPD_SHIFT ; +break ; + } + +writel (val, bgmac->plat.nicpm_base +NICPM_IOMUX_CTRL ); + +bgmac_adjust_link (bgmac->net_dev); +} +static int platform_phy_connect (struct bgmac *bgmac) {struct phy_device *phy_dev; - phy_dev =of_phy_get_and_connect (bgmac->net_dev, bgmac->dev->of_node, - bgmac_adjust_link); +if (bgmac->plat.nicpm_base) + phy_dev =of_phy_get_and_connect (bgmac->net_dev, + bgmac->dev->of_node, + bgmac_nicpm_speed_set); +else + phy_dev =of_phy_get_and_connect (bgmac->net_dev, + bgmac->dev->of_node, + bgmac_adjust_link);if (!phy_dev) {dev_err (bgmac->dev,"Phy connect failed\n" );return -ENODEV ;@@ -182,6 +225,14 @@ static int bgmac_probe(struct platform_device *pdev)if (IS_ERR (bgmac->plat.idm_base))return PTR_ERR (bgmac->plat.idm_base); + regs =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"nicpm_base" ); +if (regs) { + bgmac->plat.nicpm_base =devm_ioremap_resource (&pdev->dev, + regs); +if (IS_ERR (bgmac->plat.nicpm_base)) +return PTR_ERR (bgmac->plat.nicpm_base); + } + bgmac->read = platform_bgmac_read; bgmac->write = platform_bgmac_write; bgmac->idm_read = platform_bgmac_idm_read;@@ -213,6 +264,7 @@ static int bgmac_remove(struct platform_device *pdev)static const struct of_device_id bgmac_of_enet_match[] = { {.compatible ="brcm,amac" ,}, {.compatible ="brcm,nsp-amac" ,}, + {.compatible ="brcm,ns2-amac" ,}, {}, };drivers/net/ethernet/broadcom/bgmac.c +3
-0@@ -1082,6 +1082,9 @@ static void bgmac_enable(struct bgmac *bgmac)/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */ static void bgmac_chip_init (struct bgmac *bgmac) { +/* Clear any erroneously pending interrupts */ +bgmac_write (bgmac,BGMAC_INT_STATUS , ~0 ); +/* 1 interrupt per received frame */ bgmac_write (bgmac,BGMAC_INT_RECV_LAZY ,1 <<BGMAC_IRL_FC_SHIFT );drivers/net/ethernet/broadcom/bgmac.h +1
-0@@ -463,6 +463,7 @@ struct bgmac {struct {void *base;void *idm_base; +void *nicpm_base; } plat;struct {struct bcma_device *core;
Re: [PATCH v4 6/7] net: ethernet: bgmac: add NS2 support
Quoted 47 lines · Scott Branden
One change in this patch
Quoted 44 lines · Jon Mason
Add support for the variant of amac hardware present in the Broadcom Northstar2 based SoCs. Northstar2 requires an additional register to be configured with the port speed/duplexity (NICPM). This can be added to the link callback to hide it from the instances that do not use this. Also, clearing of the pending interrupts on init is required due to observed issues on some platforms.
Signed-off-by Jon Mason <[email protected]>---
drivers/net/ethernet/broadcom/bgmac-platform.c | 56 +++++++++++++++++++++++++- drivers/net/ethernet/broadcom/bgmac.c | 3 ++ drivers/net/ethernet/broadcom/bgmac.h | 1 + 3 files changed, 58 insertions(+), 2 deletions(-)drivers/net/ethernet/broadcom/bgmac-platform.c +9
-0@@ -14,12 +14,21 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/bcma/bcma.h> +#include <linux/brcmphy.h> #include <linux/etherdevice.h> #include <linux/of_address.h> #include <linux/of_mdio.h> #include <linux/of_net.h> #include "bgmac.h" +#define NICPM_IOMUX_CTRL 0x00000008 + +#define NICPM_IOMUX_CTRL_INIT_VAL 0x3196e000 +#define NICPM_IOMUX_CTRL_SPD_SHIFT 10 +#define NICPM_IOMUX_CTRL_SPD_10M 0 +#define NICPM_IOMUX_CTRL_SPD_100M 1 +#define NICPM_IOMUX_CTRL_SPD_1000M 2 +static u32 platform_bgmac_read (struct bgmac *bgmac,u16 offset) {return readl (bgmac->plat.base + offset);@@ -87,12 +96,46 @@ static void platform_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset,WARN_ON (1 ); }
Quoted 13 lines
drivers/net/ethernet/broadcom/bgmac-platform.c static void platform_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset, · line 110
Quoted 12 lines
drivers/net/ethernet/broadcom/bgmac-platform.c +12
-0+static void bgmac_nicpm_speed_set (struct net_device *net_dev) +{ +struct bgmac *bgmac =netdev_priv (net_dev); +u32 val; + +if (!bgmac->plat.nicpm_base) +return ; + + val =NICPM_IOMUX_CTRL_INIT_VAL ; +switch (bgmac->net_dev->phydev->speed) { +default : +pr_err ("Unsupported speed. Defaulting to 1000Mb\n" );This should be
dev_err
It should probably be netdev_err (and there are a few instances below that should probably be changed to netdev_err as well).
Thanks,
Jon
Quoted 83 lines
Quoted 83 lines
drivers/net/ethernet/broadcom/bgmac-platform.c +33
-2+case SPEED_1000 : + val |=NICPM_IOMUX_CTRL_SPD_1000M <<NICPM_IOMUX_CTRL_SPD_SHIFT ; +break ; +case SPEED_100 : + val |=NICPM_IOMUX_CTRL_SPD_100M <<NICPM_IOMUX_CTRL_SPD_SHIFT ; +break ; +case SPEED_10 : + val |=NICPM_IOMUX_CTRL_SPD_10M <<NICPM_IOMUX_CTRL_SPD_SHIFT ; +break ; + } + +writel (val, bgmac->plat.nicpm_base +NICPM_IOMUX_CTRL ); + +bgmac_adjust_link (bgmac->net_dev); +} +static int platform_phy_connect (struct bgmac *bgmac) {struct phy_device *phy_dev; - phy_dev =of_phy_get_and_connect (bgmac->net_dev, bgmac->dev->of_node, - bgmac_adjust_link); +if (bgmac->plat.nicpm_base) + phy_dev =of_phy_get_and_connect (bgmac->net_dev, + bgmac->dev->of_node, + bgmac_nicpm_speed_set); +else + phy_dev =of_phy_get_and_connect (bgmac->net_dev, + bgmac->dev->of_node, + bgmac_adjust_link);if (!phy_dev) {dev_err (bgmac->dev,"Phy connect failed\n" );return -ENODEV ;@@ -182,6 +225,14 @@ static int bgmac_probe(struct platform_device *pdev)if (IS_ERR (bgmac->plat.idm_base))return PTR_ERR (bgmac->plat.idm_base); + regs =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"nicpm_base" ); +if (regs) { + bgmac->plat.nicpm_base =devm_ioremap_resource (&pdev->dev, + regs); +if (IS_ERR (bgmac->plat.nicpm_base)) +return PTR_ERR (bgmac->plat.nicpm_base); + } + bgmac->read = platform_bgmac_read; bgmac->write = platform_bgmac_write; bgmac->idm_read = platform_bgmac_idm_read;@@ -213,6 +264,7 @@ static int bgmac_remove(struct platform_device *pdev)static const struct of_device_id bgmac_of_enet_match[] = { {.compatible ="brcm,amac" ,}, {.compatible ="brcm,nsp-amac" ,}, + {.compatible ="brcm,ns2-amac" ,}, {}, };drivers/net/ethernet/broadcom/bgmac.c +3
-0@@ -1082,6 +1082,9 @@ static void bgmac_enable(struct bgmac *bgmac)/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */ static void bgmac_chip_init (struct bgmac *bgmac) { +/* Clear any erroneously pending interrupts */ +bgmac_write (bgmac,BGMAC_INT_STATUS , ~0 ); +/* 1 interrupt per received frame */ bgmac_write (bgmac,BGMAC_INT_RECV_LAZY ,1 <<BGMAC_IRL_FC_SHIFT );drivers/net/ethernet/broadcom/bgmac.h +1
-0@@ -463,6 +463,7 @@ struct bgmac {struct {void *base;void *idm_base; +void *nicpm_base; } plat;struct {struct bcma_device *core;
Re: [PATCH v4 6/7] net: ethernet: bgmac: add NS2 support
Quoted 62 lines · Jon Mason
Quoted 47 lines · Scott Branden
One change in this patch
Quoted 44 lines · Jon Mason
Add support for the variant of amac hardware present in the Broadcom Northstar2 based SoCs. Northstar2 requires an additional register to be configured with the port speed/duplexity (NICPM). This can be added to the link callback to hide it from the instances that do not use this. Also, clearing of the pending interrupts on init is required due to observed issues on some platforms.
Signed-off-by Jon Mason <[email protected]>---
drivers/net/ethernet/broadcom/bgmac-platform.c | 56 +++++++++++++++++++++++++- drivers/net/ethernet/broadcom/bgmac.c | 3 ++ drivers/net/ethernet/broadcom/bgmac.h | 1 + 3 files changed, 58 insertions(+), 2 deletions(-)drivers/net/ethernet/broadcom/bgmac-platform.c +9
-0@@ -14,12 +14,21 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/bcma/bcma.h> +#include <linux/brcmphy.h> #include <linux/etherdevice.h> #include <linux/of_address.h> #include <linux/of_mdio.h> #include <linux/of_net.h> #include "bgmac.h" +#define NICPM_IOMUX_CTRL 0x00000008 + +#define NICPM_IOMUX_CTRL_INIT_VAL 0x3196e000 +#define NICPM_IOMUX_CTRL_SPD_SHIFT 10 +#define NICPM_IOMUX_CTRL_SPD_10M 0 +#define NICPM_IOMUX_CTRL_SPD_100M 1 +#define NICPM_IOMUX_CTRL_SPD_1000M 2 +static u32 platform_bgmac_read (struct bgmac *bgmac,u16 offset) {return readl (bgmac->plat.base + offset);@@ -87,12 +96,46 @@ static void platform_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset,WARN_ON (1 ); }Quoted 13 lines
drivers/net/ethernet/broadcom/bgmac-platform.c static void platform_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset, · line 110
Quoted 12 lines
drivers/net/ethernet/broadcom/bgmac-platform.c +12
-0+static void bgmac_nicpm_speed_set (struct net_device *net_dev) +{ +struct bgmac *bgmac =netdev_priv (net_dev); +u32 val; + +if (!bgmac->plat.nicpm_base) +return ; + + val =NICPM_IOMUX_CTRL_INIT_VAL ; +switch (bgmac->net_dev->phydev->speed) { +default : +pr_err ("Unsupported speed. Defaulting to 1000Mb\n" );This should be
dev_err
Quoted 2 lines
It should probably be
netdev_err(and there are a few instances below that should probably be changed tonetdev_erras well).
Actually, the other instances I referenced above should not be netdev_err, as they are enountered before the netdev is created. So, dev_err is correct for them.
That being said, the original pr_err that Scott referenced should be netdev_err (as it is encountered after the netdev is created). v5 will make that change.
Thanks,
Jon
Quoted 87 lines
Thanks,
JonQuoted 83 lines
Quoted 83 lines
drivers/net/ethernet/broadcom/bgmac-platform.c +33
-2+case SPEED_1000 : + val |=NICPM_IOMUX_CTRL_SPD_1000M <<NICPM_IOMUX_CTRL_SPD_SHIFT ; +break ; +case SPEED_100 : + val |=NICPM_IOMUX_CTRL_SPD_100M <<NICPM_IOMUX_CTRL_SPD_SHIFT ; +break ; +case SPEED_10 : + val |=NICPM_IOMUX_CTRL_SPD_10M <<NICPM_IOMUX_CTRL_SPD_SHIFT ; +break ; + } + +writel (val, bgmac->plat.nicpm_base +NICPM_IOMUX_CTRL ); + +bgmac_adjust_link (bgmac->net_dev); +} +static int platform_phy_connect (struct bgmac *bgmac) {struct phy_device *phy_dev; - phy_dev =of_phy_get_and_connect (bgmac->net_dev, bgmac->dev->of_node, - bgmac_adjust_link); +if (bgmac->plat.nicpm_base) + phy_dev =of_phy_get_and_connect (bgmac->net_dev, + bgmac->dev->of_node, + bgmac_nicpm_speed_set); +else + phy_dev =of_phy_get_and_connect (bgmac->net_dev, + bgmac->dev->of_node, + bgmac_adjust_link);if (!phy_dev) {dev_err (bgmac->dev,"Phy connect failed\n" );return -ENODEV ;@@ -182,6 +225,14 @@ static int bgmac_probe(struct platform_device *pdev)if (IS_ERR (bgmac->plat.idm_base))return PTR_ERR (bgmac->plat.idm_base); + regs =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"nicpm_base" ); +if (regs) { + bgmac->plat.nicpm_base =devm_ioremap_resource (&pdev->dev, + regs); +if (IS_ERR (bgmac->plat.nicpm_base)) +return PTR_ERR (bgmac->plat.nicpm_base); + } + bgmac->read = platform_bgmac_read; bgmac->write = platform_bgmac_write; bgmac->idm_read = platform_bgmac_idm_read;@@ -213,6 +264,7 @@ static int bgmac_remove(struct platform_device *pdev)static const struct of_device_id bgmac_of_enet_match[] = { {.compatible ="brcm,amac" ,}, {.compatible ="brcm,nsp-amac" ,}, + {.compatible ="brcm,ns2-amac" ,}, {}, };drivers/net/ethernet/broadcom/bgmac.c +3
-0@@ -1082,6 +1082,9 @@ static void bgmac_enable(struct bgmac *bgmac)/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */ static void bgmac_chip_init (struct bgmac *bgmac) { +/* Clear any erroneously pending interrupts */ +bgmac_write (bgmac,BGMAC_INT_STATUS , ~0 ); +/* 1 interrupt per received frame */ bgmac_write (bgmac,BGMAC_INT_RECV_LAZY ,1 <<BGMAC_IRL_FC_SHIFT );drivers/net/ethernet/broadcom/bgmac.h +1
-0@@ -463,6 +463,7 @@ struct bgmac {struct {void *base;void *idm_base; +void *nicpm_base; } plat;struct {struct bcma_device *core;
PATCH v4 7/7 arm64: dts: NS2: add AMAC ethernet support
In reply to Jon MasonAdd support for the AMAC ethernet to the Broadcom Northstar2 SoC device tree
--- arch/arm64/boot/dts/broadcom/ns2-svk.dts | 5 +++++ arch/arm64/boot/dts/broadcom/ns2.dtsi | 12 ++++++++++++ 2 files changed, 17 insertions(+)
arch/arm64/boot/dts/broadcom/ns2-svk.dts +5 -0
@@ -56,6 +56,10 @@ }; }; +&enet { + status = "ok"; +}; + &pci_phy0 { status = "ok"; };
@@ -172,6 +176,7 @@ &mdio_mux_iproc { mdio at 10 { gphy0: eth-phy at 10 { + enet-phy-lane-swap; reg = <0x10>; }; };
arch/arm64/boot/dts/broadcom/ns2.dtsi +12 -0
@@ -191,6 +191,18 @@ #include "ns2-clock.dtsi" + enet: ethernet at 61000000 { + compatible = "brcm,ns2-amac"; + reg = <0x61000000 0x1000>, + <0x61090000 0x1000>, + <0x61030000 0x100>; + reg-names = "amac_base", "idm_base", "nicpm_base"; + interrupts = <GIC_SPI 341 IRQ_TYPE_LEVEL_HIGH>; + phy-handle = <&gphy0>; + phy-mode = "rgmii"; + status = "disabled"; + }; + dma0: dma at 61360000 { compatible = "arm,pl330", "arm,primecell"; reg = <0x61360000 0x1000>;
Signature · 1 line
2.7.4