Fix for rare beaglebone ethernet failures
cover Fix for rare beaglebone ethernet failures
There have been reports of ethernet network failures on beagle bone black. These have been root caused to ethernet PHY latching to a different address on boot than what is programmed in DT.
See: https://groups.google.com/d/msg/beagleboard/9mctrG26Mc8/1FuI_i5KW10J
This patch series tries to workaround this suitaiton by patching device-tree passed to kernel with the correct address. As well as updating the PHY address U-Boot drivers themselves use.
Tested on beaglebone black rev A4 by simulating the error condition I was also able to hit the actual hardware error once in a while.
Sekhar Nori (3):
drivers: net: cpsw: add support to update phy address
board: ti: am335x: add support to fixup phy address
configs: am335x_evm: enable OF_BOARD_SETUP
board/ti/am335x/board.c | 78 ++++++++++++++++++++++++++++++++++++++++++++ configs/am335x_evm_defconfig | 1 + drivers/net/cpsw.c | 29 ++++++++++++++++ include/cpsw.h | 1 + 4 files changed, 109 insertions(+)
Signature · 1 line
2.16.2
PATCH 1/3 drivers: net: cpsw: add support to update phy address
On some boards using TI CPSW, it may be possible that PHY address was not latched correctly, and the actual address that the phy responds on is different from that set in device-tree. For example, see this problem report on beaglebone black:
https://groups.google.com/d/msg/beagleboard/9mctrG26Mc8/1FuI_i5KW10J
Add support to check for this condition and use the detected phy address when its safe to do so.
Also, add a public API that exposes the phy address of a given slave. This can be used to update device-tree that is passed to Linux kernel.
--- drivers/net/cpsw.c | 29 +++++++++++++++++++++++++++++ include/cpsw.h | 1 + 2 files changed, 30 insertions(+)
drivers/net/cpsw.c +29 -0
@@ -1008,6 +1008,25 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave)return 1 ; } +static void cpsw_phy_addr_update (struct cpsw_priv *priv) +{ +struct cpsw_platform_data *data = &priv->data; +u16 alive = mdio_regs->alive &GENMASK (15 ,0 ); +int active = data->active_slave; +int new_addr =ffs (alive) -1 ; + +/* +* If there is only one phy alive and its address does not match +* that of active slave, then phy address can safely be updated. +*/ +if (hweight16 (alive) ==1 && + data->slave_data[active].phy_addr != new_addr) { +printf ("Updated phy address for CPSW#%d, old: %d, new: %d\n" , + active, data->slave_data[active].phy_addr, new_addr); + data->slave_data[active].phy_addr = new_addr; + } +} +int _cpsw_register (struct cpsw_priv *priv) {struct cpsw_slave *slave;
@@ -1034,6 +1053,9 @@ int _cpsw_register(struct cpsw_priv *priv) }cpsw_mdio_init (priv->dev->name, data->mdio_base, data->mdio_div); + +cpsw_phy_addr_update (priv); + priv->bus =miiphy_get_dev_by_name (priv->dev->name); for_active_slave(slave, priv)cpsw_phy_init (priv, slave);
@@ -1458,6 +1480,13 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)return 0 ; } +int cpsw_get_slave_phy_addr (struct udevice *dev,int slave) +{ +struct cpsw_priv *priv =dev_get_priv (dev); +struct cpsw_platform_data *data = &priv->data; + +return data->slave_data[slave].phy_addr; +}static const struct udevice_id cpsw_eth_ids[] = { { .compatible ="ti,cpsw" },
include/cpsw.h +1 -0
@@ -54,5 +54,6 @@ struct cpsw_platform_data {int cpsw_register (struct cpsw_platform_data *data);int ti_cm_get_macid (struct udevice *dev,int slave,u8 *mac_addr); +int cpsw_get_slave_phy_addr (struct udevice *dev,int slave);#endif /* _CPSW_H_ */
Signature · 1 line
2.16.2
PATCH 1/3 drivers: net: cpsw: add support to update phy address
Quoted 8 lines · Sekhar Nori
On some boards using TI CPSW, it may be possible that PHY address was not latched correctly, and the actual address that the phy responds on is different from that set in device-tree. For example, see this problem report on beaglebone black:
https://groups.google.com/d/msg/beagleboard/9mctrG26Mc8/1FuI_i5KW10J
Quoted 8 lines
Add support to check for this condition and use the detected phy address when its safe to do so.
Also, add a public API that exposes the phy address of a given slave. This can be used to update device-tree that is passed to Linux kernel.
Signed-off-by Sekhar Nori <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180824/8e8cfa57/attachment.sig>
PATCH 1/3 drivers: net: cpsw: add support to update phy address
In reply to Sekhar NoriQuoted 11 lines · Sekhar Nori
On some boards using TI CPSW, it may be possible that PHY address was not latched correctly, and the actual address that the phy responds on is different from that set in device-tree. For example, see this problem report on beaglebone black:
https://groups.google.com/d/msg/beagleboard/9mctrG26Mc8/1FuI_i5KW10J
Add support to check for this condition and use the detected phy address when its safe to do so.
Quoted 6 lines
Also, add a public API that exposes the phy address of a given slave. This can be used to update device-tree that is passed to Linux kernel.
Signed-off-by Sekhar Nori <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180926/f0fb4b36/attachment.sig>
PATCH 2/3 board: ti: am335x: add support to fixup phy address
In reply to Sekhar NoriOn beaglebone black, it can so happen that PHY address is not latched correctly on reset and board boots with PHY responding to a different address than that programmed in device-tree. For example, see this report:
https://groups.google.com/d/msg/beagleboard/9mctrG26Mc8/1FuI_i5KW10J
Workaround this by fixing up device-tree passed to kernel by using the PHY address detected in hardware.
Beaglebone itself uses only one ethernet port and its DT currently uses phy_id (obsoleted). But the function has been written to handle multiple ports and phy_id as well as phy-handle to make the function more generically useful.
--- board/ti/am335x/board.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)
board/ti/am335x/board.c +78 -0
@@ -608,6 +608,84 @@ static struct clk_synth cdce913_data = { };#endif +#if defined(CONFIG_OF_BOARD_SETUP ) && defined(CONFIG_OF_CONTROL ) && \ + defined(CONFIG_DM_ETH ) && defined(CONFIG_DRIVER_TI_CPSW ) + +#define MAX_CPSW_SLAVES 2 + +/* At the moment, we do not want to stop booting for any failures here */ +int ft_board_setup (void *fdt,bd_t *bd) +{ +const char *slave_path, *enet_name; +int enetnode, slavenode, phynode; +struct udevice *ethdev; +char alias[16 ]; +u32 phy_id[2 ]; +int phy_addr; +int i, ret; + +/* phy address fixup needed only on beagle bone family */ +if (!board_is_beaglebonex ()) + goto done; + +for (i =0 ; i <MAX_CPSW_SLAVES ; i++) { +sprintf (alias,"ethernet%d" , i); + + slave_path =fdt_get_alias (fdt, alias); +if (!slave_path) +continue ; + + slavenode =fdt_path_offset (fdt, slave_path); +if (slavenode <0 ) +continue ; + + enetnode =fdt_parent_offset (fdt, slavenode); + enet_name =fdt_get_name (fdt, enetnode,NULL ); + + ethdev =eth_get_dev_by_name (enet_name); +if (!ethdev) +continue ; + + phy_addr =cpsw_get_slave_phy_addr (ethdev, i); + +/* check for phy_id as well as phy-handle properties */ + ret =fdtdec_get_int_array_count (fdt, slavenode,"phy_id" , + phy_id,2 ); +if (ret ==2 ) { +if (phy_id[1 ] != phy_addr) { +printf ("fixing up phy_id for %s, old: %d, new: %d\n" , + alias, phy_id[1 ], phy_addr); + + phy_id[0 ] =cpu_to_fdt32 (phy_id[0 ]); + phy_id[1 ] =cpu_to_fdt32 (phy_addr); +do_fixup_by_path (fdt, slave_path,"phy_id" , + phy_id,sizeof (phy_id),0 ); + } + }else { + phynode =fdtdec_lookup_phandle (fdt, slavenode, +"phy-handle" ); +if (phynode <0 ) +continue ; + + ret =fdtdec_get_int (fdt, phynode,"reg" , -ENOENT ); +if (ret <0 ) +continue ; + +if (ret != phy_addr) { +printf ("fixing up phy-handle for %s, old: %d, new: %d\n" , + alias, ret, phy_addr); + +fdt_setprop_u32 (fdt, phynode,"reg" , +cpu_to_fdt32 (phy_addr)); + } + } + } + +done: +return 0 ; +} +#endif +/* * Basic board specific setup. Pinmux has been handled already. */
Signature · 1 line
2.16.2
PATCH 2/3 board: ti: am335x: add support to fixup phy address
Quoted 10 lines · Sekhar Nori
On beaglebone black, it can so happen that PHY address is not latched correctly on reset and board boots with PHY responding to a different address than that programmed in device-tree. For example, see this report:
https://groups.google.com/d/msg/beagleboard/9mctrG26Mc8/1FuI_i5KW10J
Workaround this by fixing up device-tree passed to kernel by using the PHY address detected in hardware.
Quoted 6 lines
Beaglebone itself uses only one ethernet port and its DT currently uses
phy_id(obsoleted). But the function has been written to handle multiple ports andphy_idas well as phy-handle to make the function more generically useful.Signed-off-by Sekhar Nori <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180824/82fa0d9f/attachment.sig>
PATCH 2/3 board: ti: am335x: add support to fixup phy address
In reply to Sekhar NoriQuoted 10 lines · Sekhar Nori
On beaglebone black, it can so happen that PHY address is not latched correctly on reset and board boots with PHY responding to a different address than that programmed in device-tree. For example, see this report:
https://groups.google.com/d/msg/beagleboard/9mctrG26Mc8/1FuI_i5KW10J
Workaround this by fixing up device-tree passed to kernel by using the PHY address detected in hardware.
Quoted 7 lines
Beaglebone itself uses only one ethernet port and its DT currently uses
phy_id(obsoleted). But the function has been written to handle multiple ports andphy_idas well as phy-handle to make the function more generically useful.Signed-off-by Sekhar Nori <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180926/dcc0b892/attachment.sig>
PATCH 3/3 configs: am335x_evm: enable OF_BOARD_SETUP
In reply to Sekhar NoriEnable CONFIG_OF_BOARD_SETUP as it is needed for Beaglebone black to overwrite the Ethernet phy address present in DT in case the phy latches on to a different address.
--- configs/am335x_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/am335x_evm_defconfig +1 -0
@@ -6,6 +6,7 @@ CONFIG_SPL=y CONFIG_DEFAULT_DEVICE_TREE="am335x-evm" CONFIG_DISTRO_DEFAULTS=y CONFIG_SPL_LOAD_FIT=y +CONFIG_OF_BOARD_SETUP=y CONFIG_BOOTCOMMAND="if test ${boot_fit} -eq 1; then run update_to_fit; fi; run findfdt; run init_console; run envboot; run distro_bootcmd" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_VERSION_VARIABLE=y
Signature · 1 line
2.16.2
PATCH 3/3 configs: am335x_evm: enable OF_BOARD_SETUP
Quoted 5 lines · Sekhar Nori
Enable
CONFIG_OF_BOARD_SETUPas it is needed for Beaglebone black to overwrite the Ethernet phy address present in DT in case the phy latches on to a different address.Signed-off-by Sekhar Nori <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180824/94d3797e/attachment.sig>
PATCH 3/3 configs: am335x_evm: enable OF_BOARD_SETUP
In reply to Sekhar NoriQuoted 6 lines · Sekhar Nori
Enable
CONFIG_OF_BOARD_SETUPas it is needed for Beaglebone black to overwrite the Ethernet phy address present in DT in case the phy latches on to a different address.Signed-off-by Sekhar Nori <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180926/d19c01ef/attachment.sig>
cover Fix for rare beaglebone ethernet failures
In reply to Sekhar NoriQuoted 18 lines · Sekhar Nori
There have been reports of ethernet network failures on beagle bone black. These have been root caused to ethernet PHY latching to a different address on boot than what is programmed in DT.
See: https://groups.google.com/d/msg/beagleboard/9mctrG26Mc8/1FuI_i5KW10J
This patch series tries to workaround this suitaiton by patching device-tree passed to kernel with the correct address. As well as updating the PHY address U-Boot drivers themselves use.
Tested on beaglebone black rev A4 by simulating the error condition I was also able to hit the actual hardware error once in a while.
Sekhar Nori (3):
drivers: net: cpsw: add support to update phy address
board: ti: am335x: add support to fixup phy address
configs:am335x_evm: enableOF_BOARD_SETUP
Quoted 6 lines
board/ti/am335x/board.c | 78 ++++++++++++++++++++++++++++++++++++++++++++ configs/am335x_evm_defconfig | 1 + drivers/net/cpsw.c | 29 ++++++++++++++++ include/cpsw.h | 1 + 4 files changed, 109 insertions(+)
Signature · 2 lines
regards, -grygorii