net: phy: Add Broadcom BCM53xx switch driver
Subsystems (2)
v4 cover net: phy: Add Broadcom BCM53xx switch driver
Hi all,
This patch series adds support for the Broadcom BCM53xx switches, in particular BCM53125 which is found no the Lamobo R1 board.
The driver is largely based on the DSA/b53 driver Linux driver and only incorporates what is necessary to succesfully bring-up all ports (including the management port) for boot over the network:
=> dhcpdw_adjust_link: Speed: 1000, full duplex
BOOTP broadcast 1
DHCP client bound to address 192.168.0.11 (3 ms)
Using ethernet at 01c50000 device
TFTP from server 192.168.0.1; our IP address is 192.168.0.11 Filename 'sun7i-a20-lamobo-r1-kernel.bin'.
Load address: 0x42000000
Loading: #################################################################
#################################################################
################################
11.6 MiB/sdone
Bytes transferred = 2371552 (242fe0 hex)
=>
Joe there is one warning left which does not look legit to me since we now have a help paragraph describing the config symbol:
WARNING: please write a paragraph that describes the config symbol fully #34: FILE: drivers/net/phy/Kconfig:15:
+config B53_SWITCH
and one CHECK left which I intentionally did not fix because it makes the definitions of the bits less clear:
CHECK: Prefer using the BIT macro
#134: FILE: drivers/net/phy/b53.c:63:
+#define PORT_OVERRIDE_SPEED_100M (1 << PORT_OVERRIDE_SPEED_S)
Changes in v4:
- address most checkpatch.pl issues, couple remaining, one which looks bogus:
Changes in v3:
- dropped redundant phydev->priv assignment in b53_probe(), spotted by Joe
Changes in v2:
- collected Sefan's Reviewed-by and Joe's Acked-by tags
- use max() in drivers/net/designware.c as suggested by Joe
Florian Fainelli (4):
net: phy: Add Broadcom BCM53xx switch driver
net: designware: Pad small packets
net: phy: b53: Add b53_reg read/write commands
configs: Update Lamobo_R1 with B53 switch options
Florian Fainelli (4):
net: phy: Add Broadcom BCM53xx switch driver
net: designware: Pad small packets
net: phy: b53: Add b53_reg read/write commands
configs: Update Lamobo_R1 with B53 switch options
configs/Lamobo_R1_defconfig | 3 + drivers/net/designware.c | 5 + drivers/net/phy/Kconfig | 17 + drivers/net/phy/Makefile | 1 + drivers/net/phy/b53.c | 768 ++++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy.c | 3 + include/phy.h | 1 + 7 files changed, 798 insertions(+) create mode 100644 drivers/net/phy/b53.c
Signature · 1 line
2.14.1
PATCH v4 1/4 net: phy: Add Broadcom BCM53xx switch driver
Add a minimalistic Broadcom BCM53xx (roboswitch) switch driver similar to the Marvell MV88E617x. This takes care of configuring the minimum amount out of the switch hardware such that each user visible port (configurable) and the CPU port can forward packets between each other while preserving isolation with other ports.
This is useful for e.g: the Lamobo R1 board featuring a Broadcom BCM53125 switch.
--- drivers/net/phy/Kconfig | 17 ++ drivers/net/phy/Makefile | 1 + drivers/net/phy/b53.c | 629 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy.c | 3 + include/phy.h | 1 + 5 files changed, 651 insertions(+) create mode 100644 drivers/net/phy/b53.c
drivers/net/phy/Kconfig +17 -0
@@ -12,6 +12,23 @@ menuconfig PHYLIB if PHYLIB +config B53_SWITCH + bool "Broadcom BCM53xx (RoboSwitch) Ethernet switch PHY support." + help + Enable support for Broadcom BCM53xx (RoboSwitch) Ethernet switches. + This currently supports BCM53125 and similar models. + +if B53_SWITCH + +config B53_CPU_PORT + int "CPU port" + default 8 + +config B53_PHY_PORTS + hex "Bitmask of PHY ports" + +endif # B53_SWITCH + config MV88E61XX_SWITCH bool "Marvel MV88E61xx Ethernet switch PHY support."
drivers/net/phy/Makefile +1 -0
@@ -6,6 +6,7 @@ # obj-$(CONFIG_BITBANGMII) += miiphybb.o +obj-$(CONFIG_B53_SWITCH) += b53.o obj-$(CONFIG_MV88E61XX_SWITCH) += mv88e61xx.o obj-$(CONFIG_MV88E6352_SWITCH) += mv88e6352.o
drivers/net/phy/b53.c new file +629 -0
629 lines not on this page · raw message
drivers/net/phy/phy.c +3 -0
@@ -461,6 +461,9 @@ static LIST_HEAD(phy_drivers);int phy_init (void ) { +#ifdef CONFIG_B53_SWITCH +phy_b53_init (); +#endif #ifdef CONFIG_MV88E61XX_SWITCH phy_mv88e61xx_init ();#endif
include/phy.h +1 -0
@@ -257,6 +257,7 @@ int gen10g_startup(struct phy_device *phydev);int gen10g_shutdown (struct phy_device *phydev);int gen10g_discover_mmds (struct phy_device *phydev); +int phy_b53_init (void );int phy_mv88e61xx_init (void );int phy_aquantia_init (void );int phy_atheros_init (void );
Signature · 1 line
2.14.1
Hi Florian,
https://patchwork.ozlabs.org/patch/846612/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v4 2/4 net: designware: Pad small packets
In reply to Florian FainelliMake sure that we pad small packets to a minimum length of 60 bytes (without FCS). This is necessary to interface with Ethernet switches that will reject RUNT frames unless padded correctly.
--- drivers/net/designware.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/designware.c +5 -0
@@ -17,6 +17,7 @@#include <pci.h> #include <linux/compiler.h> #include <linux/err.h> +#include <linux/kernel.h> #include <asm/io.h> #include <power/regulator.h> #include "designware.h"
@@ -343,6 +344,8 @@ int designware_eth_enable(struct dw_eth_dev *priv)return 0 ; } +#define ETH_ZLEN 60 +static int _dw_eth_send (struct dw_eth_dev *priv,void *packet,int length) {struct eth_dma_regs *dma_p = priv->dma_regs_p;
@@ -369,6 +372,8 @@ static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length)return -EPERM ; } + length =max (length,ETH_ZLEN ); +memcpy ((void *)data_start, packet, length);/* Flush data to be sent */
Signature · 1 line
2.14.1
PATCH v4 2/4 net: designware: Pad small packets
Quoted 5 lines · Florian Fainelli
Make sure that we pad small packets to a minimum length of 60 bytes (without FCS). This is necessary to interface with Ethernet switches that will reject RUNT frames unless padded correctly.
Signed-off-by Florian Fainelli <[email protected]>
Thanks,
Stefan
PATCH v4 2/4 net: designware: Pad small packets
In reply to Florian FainelliQuoted 5 lines · Florian Fainelli
Make sure that we pad small packets to a minimum length of 60 bytes (without FCS). This is necessary to interface with Ethernet switches that will reject RUNT frames unless padded correctly.
Signed-off-by Florian Fainelli <[email protected]>
[U-Boot] net: designware: Pad small packets
In reply to Florian FainelliHi Florian,
https://patchwork.ozlabs.org/patch/846613/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v4 3/4 net: phy: b53: Add b53_reg read/write commands
In reply to Florian FainelliAdd a b53_reg read/write command which allows inspecting the switch registers. Because the Broadcom BCM53xx registers have different sizes, we need to split the accesses in 8, 16, 32, 48 or 64 bits to obtain expected results.
--- drivers/net/phy/b53.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+)
drivers/net/phy/b53.c +139 -0
@@ -627,3 +627,142 @@ int phy_b53_init(void)return 0 ; } + +int do_b53_reg_read (const char *name,int argc,char *const argv[]) +{ +u8 page, offset, width; +struct mii_dev *bus; +int ret = -EINVAL ; +u64 value64 =0 ; +u32 value32 =0 ; +u16 value16 =0 ; +u8 value8 =0 ; + + bus =miiphy_get_dev_by_name (name); +if (!bus) { +printf ("unable to find MDIO bus: %s\n" , name); +return ret; + } + + page =simple_strtoul (argv[1 ],NULL ,16 ); + offset =simple_strtoul (argv[2 ],NULL ,16 ); + width =simple_strtoul (argv[3 ],NULL ,10 ); + +switch (width) { +case 8 : + ret =b53_mdio_read8 (bus, page, offset, &value8); +printf ("page=0x%02x, offset=0x%02x, value=0x%02x\n" , + page, offset, value8); +break ; +case 16 : + ret =b53_mdio_read16 (bus, page, offset, &value16); +printf ("page=0x%02x, offset=0x%02x, value=0x%04x\n" , + page, offset, value16); +break ; +case 32 : + ret =b53_mdio_read32 (bus, page, offset, &value32); +printf ("page=0x%02x, offset=0x%02x, value=0x%08x\n" , + page, offset, value32); +break ; +case 48 : + ret =b53_mdio_read48 (bus, page, offset, &value64); +printf ("page=0x%02x, offset=0x%02x, value=0x%012llx\n" , + page, offset, value64); +break ; +case 64 : + ret =b53_mdio_read48 (bus, page, offset, &value64); +printf ("page=0x%02x, offset=0x%02x, value=0x%016llx\n" , + page, offset, value64); +break ; +default : +printf ("Unsupported width: %d\n" , width); +break ; + } + +return ret; +} + +int do_b53_reg_write (const char *name,int argc,char *const argv[]) +{ +u8 page, offset, width; +struct mii_dev *bus; +int ret = -EINVAL ; +u64 value64 =0 ; +u32 value =0 ; + + bus =miiphy_get_dev_by_name (name); +if (!bus) { +printf ("unable to find MDIO bus: %s\n" , name); +return ret; + } + + page =simple_strtoul (argv[1 ],NULL ,16 ); + offset =simple_strtoul (argv[2 ],NULL ,16 ); + width =simple_strtoul (argv[3 ],NULL ,10 ); +if (width ==48 || width ==64 ) + value64 =simple_strtoull (argv[4 ],NULL ,16 ); +else + value =simple_strtoul (argv[4 ],NULL ,16 ); + +switch (width) { +case 8 : + ret =b53_mdio_write8 (bus, page, offset, value &0xff ); +break ; +case 16 : + ret =b53_mdio_write16 (bus, page, offset, value); +break ; +case 32 : + ret =b53_mdio_write32 (bus, page, offset, value); +break ; +case 48 : + ret =b53_mdio_write48 (bus, page, offset, value64); +break ; +case 64 : + ret =b53_mdio_write64 (bus, page, offset, value64); +break ; +default : +printf ("Unsupported width: %d\n" , width); +break ; + } + +return ret; +} + +int do_b53_reg (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +const char *cmd, *mdioname; +int ret =0 ; + +if (argc <2 ) +return cmd_usage (cmdtp); + + cmd = argv[1 ]; + --argc; + ++argv; + +if (!strcmp (cmd,"write" )) { +if (argc <4 ) +return cmd_usage (cmdtp); + mdioname = argv[1 ]; + --argc; + ++argv; + ret =do_b53_reg_write (mdioname, argc, argv); + }else if (!strcmp (cmd,"read" )) { +if (argc <5 ) +return cmd_usage (cmdtp); + mdioname = argv[1 ]; + --argc; + ++argv; + ret =do_b53_reg_read (mdioname, argc, argv); + }else { +return cmd_usage (cmdtp); + } + +return ret; +} + +U_BOOT_CMD (b53_reg,7 ,1 , do_b53_reg, +"Broadcom B53 switch register access" , +"write mdioname page (hex) offset (hex) width (dec) value (hex)\n" +"read mdioname page (hex) offset (hex) width (dec)\n" + );
Signature · 1 line
2.14.1
[U-Boot] net: phy: b53: Add b53_reg read/write commands
Hi Florian,
https://patchwork.ozlabs.org/patch/846614/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v4 4/4 configs: Update Lamobo_R1 with B53 switch options
In reply to Florian FainelliEnable CONFIG_B53_SWITCH, define the CPU/management port number (8) and enable all 5 ports of the switch to be usable.
--- configs/Lamobo_R1_defconfig | 3 +++ 1 file changed, 3 insertions(+)
configs/Lamobo_R1_defconfig +3 -0
@@ -22,3 +22,6 @@ CONFIG_SUN7I_GMAC=y CONFIG_SCSI=y CONFIG_USB_EHCI_HCD=y CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y +CONFIG_B53_SWITCH=y +CONFIG_B53_CPU_PORT=8 +CONFIG_B53_PHY_PORTS=0x1f
Signature · 1 line
2.14.1
[U-Boot] configs: Update Lamobo_R1 with B53 switch options
Hi Florian,
https://patchwork.ozlabs.org/patch/846615/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
v4 cover net: phy: Add Broadcom BCM53xx switch driver
In reply to Florian FainelliQuoted 32 lines · Florian Fainelli
Hi all,
This patch series adds support for the Broadcom BCM53xx switches, in particular BCM53125 which is found no the Lamobo R1 board.
The driver is largely based on the DSA/b53 driver Linux driver and only incorporates what is necessary to succesfully bring-up all ports (including the management port) for boot over the network:
=> dhcp
dw_adjust_link: Speed: 1000, full duplex
BOOTP broadcast 1
DHCP client bound to address 192.168.0.11 (3 ms)
Using ethernet at01c50000device
TFTP from server 192.168.0.1; our IP address is 192.168.0.11 Filename 'sun7i-a20-lamobo-r1-kernel.bin'.
Load address:0x42000000
Loading: ################################################################################################################################## ################################ 11.6 MiB/sdone
Bytes transferred = 2371552 (242fe0 hex)
=>Joe there is one warning left which does not look legit to me since we now have a help paragraph describing the config symbol:
WARNING: please write a paragraph that describes the config symbol fully #34: FILE:
drivers/net/phy/Kconfig:15:
+configB53_SWITCH
Quoted 5 lines
and one CHECK left which I intentionally did not fix because it makes the definitions of the bits less clear:
CHECK: Prefer using the BIT macro
#134: FILE:drivers/net/phy/b53.c:63:
+#definePORT_OVERRIDE_SPEED_100M(1 <<PORT_OVERRIDE_SPEED_S)
Works for me.
Cheers,
-Joe
Quoted 42 lines
Changes in v4:
- address most checkpatch.pl issues, couple remaining, one which looks bogus:Changes in v3:
- dropped redundantphydev->privassignment inb53_probe(), spotted by JoeChanges in v2:
- collected Sefan's Reviewed-by and Joe's Acked-by tags
- usemax()indrivers/net/designware.cas suggested by JoeFlorian Fainelli (4):
net: phy: Add Broadcom BCM53xx switch driver
net: designware: Pad small packets
net: phy: b53: Addb53_regread/write commands
configs: UpdateLamobo_R1with B53 switch optionsFlorian Fainelli (4):
net: phy: Add Broadcom BCM53xx switch driver
net: designware: Pad small packets
net: phy: b53: Addb53_regread/write commands
configs: UpdateLamobo_R1with B53 switch optionsconfigs/Lamobo_R1_defconfig | 3 + drivers/net/designware.c | 5 + drivers/net/phy/Kconfig | 17 + drivers/net/phy/Makefile | 1 + drivers/net/phy/b53.c | 768 ++++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy.c | 3 + include/phy.h | 1 + 7 files changed, 798 insertions(+) create mode 100644 drivers/net/phy/b53.c--
2.14.1_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
v4 cover net: phy: Add Broadcom BCM53xx switch driver
Quoted 33 lines · Joe Hershberger
Quoted 32 lines · Florian Fainelli
Hi all,
This patch series adds support for the Broadcom BCM53xx switches, in particular BCM53125 which is found no the Lamobo R1 board.
The driver is largely based on the DSA/b53 driver Linux driver and only incorporates what is necessary to succesfully bring-up all ports (including the management port) for boot over the network:
=> dhcp
dw_adjust_link: Speed: 1000, full duplex
BOOTP broadcast 1
DHCP client bound to address 192.168.0.11 (3 ms)
Using ethernet at01c50000device
TFTP from server 192.168.0.1; our IP address is 192.168.0.11 Filename 'sun7i-a20-lamobo-r1-kernel.bin'.
Load address:0x42000000
Loading: ################################################################################################################################## ################################ 11.6 MiB/sdone
Bytes transferred = 2371552 (242fe0 hex)
=>Joe there is one warning left which does not look legit to me since we now have a help paragraph describing the config symbol:
WARNING: please write a paragraph that describes the config symbol fully #34: FILE:
drivers/net/phy/Kconfig:15:
+configB53_SWITCH
Quoted 7 lines
Quoted 5 lines
and one CHECK left which I intentionally did not fix because it makes the definitions of the bits less clear:
CHECK: Prefer using the BIT macro
#134: FILE:drivers/net/phy/b53.c:63:
+#definePORT_OVERRIDE_SPEED_100M(1 <<PORT_OVERRIDE_SPEED_S)Works for me.o
Should I expect you to queue up these patches in a git tree/branch, or is someone else picking up networking/PHY patches?
Signature · 1 line
Florian
v4 cover net: phy: Add Broadcom BCM53xx switch driver
Quoted 44 lines · Florian Fainelli
Quoted 33 lines · Joe Hershberger
Quoted 32 lines · Florian Fainelli
Hi all,
This patch series adds support for the Broadcom BCM53xx switches, in particular BCM53125 which is found no the Lamobo R1 board.
The driver is largely based on the DSA/b53 driver Linux driver and only incorporates what is necessary to succesfully bring-up all ports (including the management port) for boot over the network:
=> dhcp
dw_adjust_link: Speed: 1000, full duplex
BOOTP broadcast 1
DHCP client bound to address 192.168.0.11 (3 ms)
Using ethernet at01c50000device
TFTP from server 192.168.0.1; our IP address is 192.168.0.11 Filename 'sun7i-a20-lamobo-r1-kernel.bin'.
Load address:0x42000000
Loading: ################################################################################################################################## ################################ 11.6 MiB/sdone
Bytes transferred = 2371552 (242fe0 hex)
=>Joe there is one warning left which does not look legit to me since we now have a help paragraph describing the config symbol:
WARNING: please write a paragraph that describes the config symbol fully #34: FILE:
drivers/net/phy/Kconfig:15:
+configB53_SWITCHQuoted 7 lines
Quoted 5 lines
and one CHECK left which I intentionally did not fix because it makes the definitions of the bits less clear:
CHECK: Prefer using the BIT macro
#134: FILE:drivers/net/phy/b53.c:63:
+#definePORT_OVERRIDE_SPEED_100M(1 <<PORT_OVERRIDE_SPEED_S)Works for me.o
Quoted 2 lines
Should I expect you to queue up these patches in a git tree/branch, or is someone else picking up networking/PHY patches?
Sorry for the delay - I was out for a few weeks and couldn't get things in before I left due to people's bad patches breaking build.
Pull request sent today includes this.
Cheers,
-Joe