ARM: dts: fix Ethernet and random MAC's on WeTek Hub/Play2
Subsystems (2)
cover ARM: dts: fix Ethernet and random MAC's on WeTek Hub/Play2
In submitting the original patches for WeTek Hub/Play2 I appear to have squashed an experimental change to place the u-boot.dtsi file on the common board dtsi, but this was incorrect and results in broken Ethernet. Patch 1 creates per-board u-boot.dtsi files to fix that. However, while the NIC is now probed correctly this results in random MAC addresses. Setting the p200 family in board configs also does not work, so patch 2 revises (overwrites) the board init function using the same code as VIM3 which reads the factory MAC from efuse correctly, and patch 3 sets board family to ensure boards have a static MAC. The alternative would be to create a dedicated board definition for wetek boards. If that would be preferred, let me know and I can rework the changes to do that. And apologies for the mistake on the original submission.
Christian Hewitt (3):
ARM: dts: fix Ethernet on WeTek Hub/Play2
ARM: board: meson: update efuse MAC reading code
configs: amlogic: set board family to avoid random MAC on WeTek
Hub/Play2
arch/arm/dts/meson-gxbb-wetek-hub-u-boot.dtsi | 14 ++++++++
...tsi => meson-gxbb-wetek-play2-u-boot.dtsi} | 0
board/amlogic/p200/p200.c | 35 +++++++++++--------
configs/wetek-hub_defconfig | 1 +
configs/wetek-play2_defconfig | 1 +
5 files changed, 37 insertions(+), 14 deletions(-)
create mode 100644 arch/arm/dts/meson-gxbb-wetek-hub-u-boot.dtsi
rename arch/arm/dts/{meson-gxbb-wetek-u-boot.dtsi => meson-gxbb-wetek-play2-u-boot.dtsi} (100%)Signature · 1 line
2.34.1
PATCH 1/3 ARM: dts: fix Ethernet on WeTek Hub/Play2
Placing the snps,reset content needed for Ethernet to probe in a common uboot.dtsi results in the content not being used and broken Ethernet. Fix this by creating two board specific dtsi files with the right content.
---
...u-boot.dtsi => meson-gxbb-wetek-hub-u-boot.dtsi} | 0
arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsi | 13 +++++++++++++
2 files changed, 13 insertions(+)
rename arch/arm/dts/{meson-gxbb-wetek-u-boot.dtsi => meson-gxbb-wetek-hub-u-boot.dtsi} (100%)
create mode 100644 arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsiarch/arm/dts/meson-gxbb-wetek-hub-u-boot.dtsi renamed from arch/arm/dts/meson-gxbb-wetek-u-boot.dtsi +0 -0
arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsi new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 BayLibre, SAS. + * Author: Neil Armstrong <[email protected]> + */ + +#include "meson-gx-u-boot.dtsi" + +ðmac { + snps,reset-gpio = <&gpio GPIOZ_14 0>; + snps,reset-delays-us = <0 10000 1000000>; + snps,reset-active-low; +};
Signature · 1 line
2.34.1
Re: [PATCH 1/3] ARM: dts: fix Ethernet on WeTek Hub/Play2
Quoted 26 lines · Christian Hewitt
Placing the snps,reset content needed for Ethernet to probe in a common
uboot.dtsiresults in the content not being used and broken Ethernet. Fix this by creating two board specific dtsi files with the right content.Fixes 67d5128df950 ("ARM: dts: add support for WeTek Hub and WeTek Play2")Signed-off-by Christian Hewitt <[email protected]>--- ...u-boot.dtsi => meson-gxbb-wetek-hub-u-boot.dtsi} | 0 arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsi | 13 +++++++++++++ 2 files changed, 13 insertions(+)rename
arch/arm/dts/{meson-gxbb-wetek-u-boot.dtsi=>meson-gxbb-wetek-hub-u-boot.dtsi} (100%) create mode 100644arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsiarch/arm/dts/meson-gxbb-wetek-hub-u-boot.dtsi renamed from arch/arm/dts/meson-gxbb-wetek-u-boot.dtsi +0
-0arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsi new file +3
-0@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 BayLibre, SAS.
arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsi line 13
Quoted 10 lines
arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsi new file +10
-0+ * Author: Neil Armstrong <[email protected]> + */ + +#include "meson-gx-u-boot.dtsi" + +ðmac { + snps,reset-gpio = <&gpio GPIOZ_14 0>; + snps,reset-delays-us = <0 10000 1000000>; + snps,reset-active-low; +};
PATCH 2/3 ARM: board: meson: update efuse MAC reading code
In reply to Christian HewittCurrent code used for reading the factory programmed MAC from efuse on p200 boards does not appear to work resulting in a random MAC being generated. Update the p200 board data reusing the function from the VIM3 source.
--- board/amlogic/p200/p200.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-)
board/amlogic/p200/p200.c +21 -14
@@ -14,29 +14,36 @@#include <asm/arch/eth.h> #include <asm/arch/mem.h> -#define EFUSE_SN_OFFSET 20 -#define EFUSE_SN_SIZE 16 -#define EFUSE_MAC_OFFSET 52 -#define EFUSE_MAC_SIZE 6 +#define EFUSE_MAC_OFFSET 0 +#define EFUSE_MAC_SIZE 12 +#define MAC_ADDR_LEN 6int misc_init_r (void ) { -u8 mac_addr[EFUSE_MAC_SIZE ]; -char serial[EFUSE_SN_SIZE ]; +u8 mac_addr[MAC_ADDR_LEN ]; +char efuse_mac_addr[EFUSE_MAC_SIZE ], tmp[3 ];ssize_t len;if (!eth_env_get_enetaddr ("ethaddr" , mac_addr)) { len =meson_sm_read_efuse (EFUSE_MAC_OFFSET , - mac_addr,EFUSE_MAC_SIZE ); -if (len ==EFUSE_MAC_SIZE &&is_valid_ethaddr (mac_addr)) + efuse_mac_addr,EFUSE_MAC_SIZE ); +if (len !=EFUSE_MAC_SIZE ) +return 0 ; + +/* MAC is stored in ASCII format, 1bytes = 2characters */ +for (int i =0 ; i <6 ; i++) { + tmp[0 ] = efuse_mac_addr[i *2 ]; + tmp[1 ] = efuse_mac_addr[i *2 +1 ]; + tmp[2 ] ='\0' ; + mac_addr[i] =simple_strtoul (tmp,NULL ,16 ); + } + +if (is_valid_ethaddr (mac_addr))eth_env_set_enetaddr ("ethaddr" , mac_addr); - } +else +meson_generate_serial_ethaddr (); -if (!env_get ("serial#" )) { - len =meson_sm_read_efuse (EFUSE_SN_OFFSET , serial, -EFUSE_SN_SIZE ); -if (len ==EFUSE_SN_SIZE ) -env_set ("serial#" , serial); +eth_env_get_enetaddr ("ethaddr" , mac_addr); }return 0 ;
Signature · 1 line
2.34.1
[email protected]
maintainerRe: [PATCH 2/3] ARM: board: meson: update efuse MAC reading code
Hi,
Quoted 4 lines · Christian Hewitt
Current code used for reading the factory programmed MAC from efuse on p200 boards does not appear to work resulting in a random MAC being generated. Update the p200 board data reusing the function from the VIM3 source.
I'm pretty sure this code works on the Odroid-C2, but hardkernel had a custom way to store the mac address so perhaps you should move this code to an odroid-c2 board file first ?
Or try both methods ? if first method doesn't give a valid mac address try the ASCII format.
Neil
Quoted 61 lines
Signed-off-by Christian Hewitt <[email protected]>--- board/amlogic/p200/p200.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-)board/amlogic/p200/p200.c +21
-14@@ -14,29 +14,36 @@#include <asm/arch/eth.h> #include <asm/arch/mem.h> -#define EFUSE_SN_OFFSET 20 -#define EFUSE_SN_SIZE 16 -#define EFUSE_MAC_OFFSET 52 -#define EFUSE_MAC_SIZE 6 +#define EFUSE_MAC_OFFSET 0 +#define EFUSE_MAC_SIZE 12 +#define MAC_ADDR_LEN 6int misc_init_r (void ) { -u8 mac_addr[EFUSE_MAC_SIZE ]; -char serial[EFUSE_SN_SIZE ]; +u8 mac_addr[MAC_ADDR_LEN ]; +char efuse_mac_addr[EFUSE_MAC_SIZE ], tmp[3 ];ssize_t len;if (!eth_env_get_enetaddr ("ethaddr" , mac_addr)) { len =meson_sm_read_efuse (EFUSE_MAC_OFFSET , - mac_addr,EFUSE_MAC_SIZE ); -if (len ==EFUSE_MAC_SIZE &&is_valid_ethaddr (mac_addr)) + efuse_mac_addr,EFUSE_MAC_SIZE ); +if (len !=EFUSE_MAC_SIZE ) +return 0 ; + +/* MAC is stored in ASCII format, 1bytes = 2characters */ +for (int i =0 ; i <6 ; i++) { + tmp[0 ] = efuse_mac_addr[i *2 ]; + tmp[1 ] = efuse_mac_addr[i *2 +1 ]; + tmp[2 ] ='\0' ; + mac_addr[i] =simple_strtoul (tmp,NULL ,16 ); + } + +if (is_valid_ethaddr (mac_addr))eth_env_set_enetaddr ("ethaddr" , mac_addr); - } +else +meson_generate_serial_ethaddr (); -if (!env_get ("serial#" )) { - len =meson_sm_read_efuse (EFUSE_SN_OFFSET , serial, -EFUSE_SN_SIZE ); -if (len ==EFUSE_SN_SIZE ) -env_set ("serial#" , serial); +eth_env_get_enetaddr ("ethaddr" , mac_addr); }return 0 ;
PATCH 3/3 configs: amlogic: set board family to avoid random MAC on WeTek Hub/Play2
In reply to Christian HewittAdd CONFIG_SYS_BOARD="p200" to the Hub/Play2 board configs to ensure the factory programmed MAC is correctly read from efuse.
--- configs/wetek-hub_defconfig | 1 + configs/wetek-play2_defconfig | 1 + 2 files changed, 2 insertions(+)
configs/wetek-hub_defconfig +1 -0
@@ -1,5 +1,6 @@ CONFIG_ARM=y CONFIG_ARCH_MESON=y +CONFIG_SYS_BOARD="p200" CONFIG_TEXT_BASE=0x01000000 CONFIG_NR_DRAM_BANKS=1 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
configs/wetek-play2_defconfig +1 -0
@@ -1,5 +1,6 @@ CONFIG_ARM=y CONFIG_ARCH_MESON=y +CONFIG_SYS_BOARD="p200" CONFIG_TEXT_BASE=0x01000000 CONFIG_NR_DRAM_BANKS=1 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
Signature · 1 line
2.34.1
[email protected]
maintainerRe: [PATCH 3/3] configs: amlogic: set board family to avoid random MAC on WeTek Hub/Play2
Hi,
Quoted 25 lines · Christian Hewitt
Add
CONFIG_SYS_BOARD="p200" to the Hub/Play2 board configs to ensure the factory programmed MAC is correctly read from efuse.Signed-off-by Christian Hewitt <[email protected]>--- configs/wetek-hub_defconfig | 1 + configs/wetek-play2_defconfig | 1 + 2 files changed, 2 insertions(+)configs/wetek-hub_defconfig +1
-0@@ -1,5 +1,6 @@ CONFIG_ARM=y CONFIG_ARCH_MESON=y +CONFIG_SYS_BOARD="p200" CONFIG_TEXT_BASE=0x01000000 CONFIG_NR_DRAM_BANKS=1 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=yconfigs/wetek-play2_defconfig +0
-0
configs/wetek-play2_defconfig line 6
Quoted 6 lines
configs/wetek-play2_defconfig +1
-0@@ -1,5 +1,6 @@ CONFIG_ARM=y CONFIG_ARCH_MESON=y +CONFIG_SYS_BOARD="p200" CONFIG_TEXT_BASE=0x01000000 CONFIG_NR_DRAM_BANKS=1 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
CONFIG_SYS_BOARD="p200" is already the default value for MESON_GXBB, see arch/arm/mach-meson/Kconfig
Neil