Linux-Amlogic Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ARM: dts: fix Ethernet and random MAC's on WeTek Hub/Play2
@ 2024-03-16 13:54 Christian Hewitt
  2024-03-16 13:54 ` [PATCH 1/3] ARM: dts: fix Ethernet " Christian Hewitt
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Christian Hewitt @ 2024-03-16 13:54 UTC (permalink / raw)
  To: u-boot, u-boot-amlogic, linux-amlogic

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%)

-- 
2.34.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] ARM: dts: fix Ethernet on WeTek Hub/Play2
  2024-03-16 13:54 [PATCH 0/3] ARM: dts: fix Ethernet and random MAC's on WeTek Hub/Play2 Christian Hewitt
@ 2024-03-16 13:54 ` Christian Hewitt
  2024-03-18  8:44   ` neil.armstrong
  2024-03-16 13:54 ` [PATCH 2/3] ARM: board: meson: update efuse MAC reading code Christian Hewitt
  2024-03-16 13:54 ` [PATCH 3/3] configs: amlogic: set board family to avoid random MAC on WeTek Hub/Play2 Christian Hewitt
  2 siblings, 1 reply; 7+ messages in thread
From: Christian Hewitt @ 2024-03-16 13:54 UTC (permalink / raw)
  To: u-boot, u-boot-amlogic, linux-amlogic

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.

Fixes: 67d5128df950 ("ARM: dts: add support for WeTek Hub and WeTek Play2")
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
 ...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.dtsi

diff --git a/arch/arm/dts/meson-gxbb-wetek-u-boot.dtsi b/arch/arm/dts/meson-gxbb-wetek-hub-u-boot.dtsi
similarity index 100%
rename from arch/arm/dts/meson-gxbb-wetek-u-boot.dtsi
rename to arch/arm/dts/meson-gxbb-wetek-hub-u-boot.dtsi
diff --git a/arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsi b/arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsi
new file mode 100644
index 00000000000..3743053eb9c
--- /dev/null
+++ b/arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsi
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2019 BayLibre, SAS.
+ * Author: Neil Armstrong <narmstrong@baylibre.com>
+ */
+
+#include "meson-gx-u-boot.dtsi"
+
+&ethmac {
+	snps,reset-gpio = <&gpio GPIOZ_14 0>;
+	snps,reset-delays-us = <0 10000 1000000>;
+	snps,reset-active-low;
+};
-- 
2.34.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] ARM: board: meson: update efuse MAC reading code
  2024-03-16 13:54 [PATCH 0/3] ARM: dts: fix Ethernet and random MAC's on WeTek Hub/Play2 Christian Hewitt
  2024-03-16 13:54 ` [PATCH 1/3] ARM: dts: fix Ethernet " Christian Hewitt
@ 2024-03-16 13:54 ` Christian Hewitt
  2024-03-18  8:48   ` neil.armstrong
  2024-03-16 13:54 ` [PATCH 3/3] configs: amlogic: set board family to avoid random MAC on WeTek Hub/Play2 Christian Hewitt
  2 siblings, 1 reply; 7+ messages in thread
From: Christian Hewitt @ 2024-03-16 13:54 UTC (permalink / raw)
  To: u-boot, u-boot-amlogic, linux-amlogic

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.

Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
 board/amlogic/p200/p200.c | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/board/amlogic/p200/p200.c b/board/amlogic/p200/p200.c
index 7c432f9d281..fb07eefa532 100644
--- a/board/amlogic/p200/p200.c
+++ b/board/amlogic/p200/p200.c
@@ -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		6
 
 int 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;
-- 
2.34.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] configs: amlogic: set board family to avoid random MAC on WeTek Hub/Play2
  2024-03-16 13:54 [PATCH 0/3] ARM: dts: fix Ethernet and random MAC's on WeTek Hub/Play2 Christian Hewitt
  2024-03-16 13:54 ` [PATCH 1/3] ARM: dts: fix Ethernet " Christian Hewitt
  2024-03-16 13:54 ` [PATCH 2/3] ARM: board: meson: update efuse MAC reading code Christian Hewitt
@ 2024-03-16 13:54 ` Christian Hewitt
  2024-03-18  8:50   ` neil.armstrong
  2 siblings, 1 reply; 7+ messages in thread
From: Christian Hewitt @ 2024-03-16 13:54 UTC (permalink / raw)
  To: u-boot, u-boot-amlogic, linux-amlogic

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 <christianshewitt@gmail.com>
---
 configs/wetek-hub_defconfig   | 1 +
 configs/wetek-play2_defconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/wetek-hub_defconfig b/configs/wetek-hub_defconfig
index fd92b041e73..413bbfe9ab7 100644
--- a/configs/wetek-hub_defconfig
+++ b/configs/wetek-hub_defconfig
@@ -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
diff --git a/configs/wetek-play2_defconfig b/configs/wetek-play2_defconfig
index b887419a6ba..dd98929444c 100644
--- a/configs/wetek-play2_defconfig
+++ b/configs/wetek-play2_defconfig
@@ -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
-- 
2.34.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] ARM: dts: fix Ethernet on WeTek Hub/Play2
  2024-03-16 13:54 ` [PATCH 1/3] ARM: dts: fix Ethernet " Christian Hewitt
@ 2024-03-18  8:44   ` neil.armstrong
  0 siblings, 0 replies; 7+ messages in thread
From: neil.armstrong @ 2024-03-18  8:44 UTC (permalink / raw)
  To: u-boot-amlogic, christianshewitt, u-boot, linux-amlogic

On 16/03/2024 14:54, Christian Hewitt wrote:
> 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.
> 
> Fixes: 67d5128df950 ("ARM: dts: add support for WeTek Hub and WeTek Play2")
> Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
> ---
>   ...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.dtsi
> 
> diff --git a/arch/arm/dts/meson-gxbb-wetek-u-boot.dtsi b/arch/arm/dts/meson-gxbb-wetek-hub-u-boot.dtsi
> similarity index 100%
> rename from arch/arm/dts/meson-gxbb-wetek-u-boot.dtsi
> rename to arch/arm/dts/meson-gxbb-wetek-hub-u-boot.dtsi
> diff --git a/arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsi b/arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsi
> new file mode 100644
> index 00000000000..3743053eb9c
> --- /dev/null
> +++ b/arch/arm/dts/meson-gxbb-wetek-play2-u-boot.dtsi
> @@ -0,0 +1,13 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +/*
> + * Copyright (c) 2019 BayLibre, SAS.
> + * Author: Neil Armstrong <narmstrong@baylibre.com>
> + */
> +
> +#include "meson-gx-u-boot.dtsi"
> +
> +&ethmac {
> +	snps,reset-gpio = <&gpio GPIOZ_14 0>;
> +	snps,reset-delays-us = <0 10000 1000000>;
> +	snps,reset-active-low;
> +};

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] ARM: board: meson: update efuse MAC reading code
  2024-03-16 13:54 ` [PATCH 2/3] ARM: board: meson: update efuse MAC reading code Christian Hewitt
@ 2024-03-18  8:48   ` neil.armstrong
  0 siblings, 0 replies; 7+ messages in thread
From: neil.armstrong @ 2024-03-18  8:48 UTC (permalink / raw)
  To: u-boot-amlogic, christianshewitt, u-boot, linux-amlogic

Hi,
On 16/03/2024 14:54, Christian Hewitt wrote:
> 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

> 
> Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
> ---
>   board/amlogic/p200/p200.c | 35 +++++++++++++++++++++--------------
>   1 file changed, 21 insertions(+), 14 deletions(-)
> 
> diff --git a/board/amlogic/p200/p200.c b/board/amlogic/p200/p200.c
> index 7c432f9d281..fb07eefa532 100644
> --- a/board/amlogic/p200/p200.c
> +++ b/board/amlogic/p200/p200.c
> @@ -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		6
>   
>   int 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;


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] configs: amlogic: set board family to avoid random MAC on WeTek Hub/Play2
  2024-03-16 13:54 ` [PATCH 3/3] configs: amlogic: set board family to avoid random MAC on WeTek Hub/Play2 Christian Hewitt
@ 2024-03-18  8:50   ` neil.armstrong
  0 siblings, 0 replies; 7+ messages in thread
From: neil.armstrong @ 2024-03-18  8:50 UTC (permalink / raw)
  To: u-boot-amlogic, christianshewitt, u-boot, linux-amlogic

Hi,

On 16/03/2024 14:54, Christian Hewitt wrote:
> 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 <christianshewitt@gmail.com>
> ---
>   configs/wetek-hub_defconfig   | 1 +
>   configs/wetek-play2_defconfig | 1 +
>   2 files changed, 2 insertions(+)
> 
> diff --git a/configs/wetek-hub_defconfig b/configs/wetek-hub_defconfig
> index fd92b041e73..413bbfe9ab7 100644
> --- a/configs/wetek-hub_defconfig
> +++ b/configs/wetek-hub_defconfig
> @@ -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
> diff --git a/configs/wetek-play2_defconfig b/configs/wetek-play2_defconfig
> index b887419a6ba..dd98929444c 100644
> --- a/configs/wetek-play2_defconfig
> +++ b/configs/wetek-play2_defconfig
> @@ -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

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-18  8:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-16 13:54 [PATCH 0/3] ARM: dts: fix Ethernet and random MAC's on WeTek Hub/Play2 Christian Hewitt
2024-03-16 13:54 ` [PATCH 1/3] ARM: dts: fix Ethernet " Christian Hewitt
2024-03-18  8:44   ` neil.armstrong
2024-03-16 13:54 ` [PATCH 2/3] ARM: board: meson: update efuse MAC reading code Christian Hewitt
2024-03-18  8:48   ` neil.armstrong
2024-03-16 13:54 ` [PATCH 3/3] configs: amlogic: set board family to avoid random MAC on WeTek Hub/Play2 Christian Hewitt
2024-03-18  8:50   ` neil.armstrong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox