All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Two mpfs icicle init fixes
@ 2024-05-15 15:04 Conor Dooley
  2024-05-15 15:04 ` [PATCH v1 1/2] board: microchip: icicle: correct type for node offset Conor Dooley
  2024-05-15 15:04 ` [PATCH v1 2/2] board: microchip: icicle: make both ethernets optional Conor Dooley
  0 siblings, 2 replies; 5+ messages in thread
From: Conor Dooley @ 2024-05-15 15:04 UTC (permalink / raw)
  To: u-boot; +Cc: conor, Conor Dooley, Padmarao Begari, Cyril Jean, Tom Rini

From: Conor Dooley <conor.dooley@microchip.com>

Two fixes for issues that I spotted today while looking into passing a
minimal dtb to U-Boot from the first bootloader stage. This minimal dtb
had no ethernet nodes, and the code in this patches fell over :\

Cheers,
Conor.
---
CC: Padmarao Begari <padmarao.begari@microchip.com>
CC: Cyril Jean <cyril.jean@microchip.com>
CC: Tom Rini <trini@konsulko.com>
CC: Conor Dooley <conor.dooley@microchip.com>
CC: u-boot@lists.denx.de

Conor Dooley (2):
  board: microchip: icicle: correct type for node offset
  board: microchip: icicle: make both ethernets optional

 board/microchip/mpfs_icicle/mpfs_icicle.c | 25 ++++++++---------------
 1 file changed, 8 insertions(+), 17 deletions(-)

-- 
2.43.0


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

* [PATCH v1 1/2] board: microchip: icicle: correct type for node offset
  2024-05-15 15:04 [PATCH v1 0/2] Two mpfs icicle init fixes Conor Dooley
@ 2024-05-15 15:04 ` Conor Dooley
  2024-05-30  3:11   ` Leo Liang
  2024-05-15 15:04 ` [PATCH v1 2/2] board: microchip: icicle: make both ethernets optional Conor Dooley
  1 sibling, 1 reply; 5+ messages in thread
From: Conor Dooley @ 2024-05-15 15:04 UTC (permalink / raw)
  To: u-boot; +Cc: conor, Conor Dooley, Padmarao Begari, Cyril Jean, Tom Rini

From: Conor Dooley <conor.dooley@microchip.com>

Node offsets returned by libfdt can contain negative error numbers, so
the variable type should be "int". As things stand, if the ethernet
nodes are not found in the early init callback, the if (node < 0) tests
pass and the code errors out while trying to set the local-mac-address
for a non-existent node.

Fixes: 64413e1b7c ("riscv: Add Microchip MPFS Icicle Kit support")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
---
 board/microchip/mpfs_icicle/mpfs_icicle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/microchip/mpfs_icicle/mpfs_icicle.c b/board/microchip/mpfs_icicle/mpfs_icicle.c
index 7beac33cfb..5fd0ec66a9 100644
--- a/board/microchip/mpfs_icicle/mpfs_icicle.c
+++ b/board/microchip/mpfs_icicle/mpfs_icicle.c
@@ -72,7 +72,7 @@ int board_early_init_f(void)
 int board_late_init(void)
 {
 	u32 ret;
-	u32 node;
+	int node;
 	u8 idx;
 	u8 device_serial_number[16] = { 0 };
 	unsigned char mac_addr[6];
-- 
2.43.0


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

* [PATCH v1 2/2] board: microchip: icicle: make both ethernets optional
  2024-05-15 15:04 [PATCH v1 0/2] Two mpfs icicle init fixes Conor Dooley
  2024-05-15 15:04 ` [PATCH v1 1/2] board: microchip: icicle: correct type for node offset Conor Dooley
@ 2024-05-15 15:04 ` Conor Dooley
  2024-05-30  3:13   ` Leo Liang
  1 sibling, 1 reply; 5+ messages in thread
From: Conor Dooley @ 2024-05-15 15:04 UTC (permalink / raw)
  To: u-boot; +Cc: conor, Conor Dooley, Padmarao Begari, Cyril Jean, Tom Rini

From: Conor Dooley <conor.dooley@microchip.com>

A given AMP configuration for a board may make either one, or neither
of, the ethernet ports available to U-Boot. The Icicle's init code will
fail if mac1 is not present, so move it to the optional approach taken
for mac0.

Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
---
 board/microchip/mpfs_icicle/mpfs_icicle.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/board/microchip/mpfs_icicle/mpfs_icicle.c b/board/microchip/mpfs_icicle/mpfs_icicle.c
index 5fd0ec66a9..4d7d843dfa 100644
--- a/board/microchip/mpfs_icicle/mpfs_icicle.c
+++ b/board/microchip/mpfs_icicle/mpfs_icicle.c
@@ -79,18 +79,6 @@ int board_late_init(void)
 	char icicle_mac_addr[20];
 	void *blob = (void *)gd->fdt_blob;
 
-	node = fdt_path_offset(blob, "/soc/ethernet@20112000");
-	if (node < 0) {
-		printf("No ethernet0 path offset\n");
-		return -ENODEV;
-	}
-
-	ret = fdtdec_get_byte_array(blob, node, "local-mac-address", mac_addr, 6);
-	if (ret) {
-		printf("No local-mac-address property for ethernet@20112000\n");
-		return -EINVAL;
-	}
-
 	read_device_serial_number(device_serial_number, 16);
 
 	/* Update MAC address with device serial number */
@@ -101,10 +89,13 @@ int board_late_init(void)
 	mac_addr[4] = device_serial_number[1];
 	mac_addr[5] = device_serial_number[0];
 
-	ret = fdt_setprop(blob, node, "local-mac-address", mac_addr, 6);
-	if (ret) {
-		printf("Error setting local-mac-address property for ethernet@20112000\n");
-		return -ENODEV;
+	node = fdt_path_offset(blob, "/soc/ethernet@20112000");
+	if (node >= 0) {
+		ret = fdt_setprop(blob, node, "local-mac-address", mac_addr, 6);
+		if (ret) {
+			printf("Error setting local-mac-address property for ethernet@20112000\n");
+			return -ENODEV;
+		}
 	}
 
 	icicle_mac_addr[0] = '[';
-- 
2.43.0


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

* Re: [PATCH v1 1/2] board: microchip: icicle: correct type for node offset
  2024-05-15 15:04 ` [PATCH v1 1/2] board: microchip: icicle: correct type for node offset Conor Dooley
@ 2024-05-30  3:11   ` Leo Liang
  0 siblings, 0 replies; 5+ messages in thread
From: Leo Liang @ 2024-05-30  3:11 UTC (permalink / raw)
  To: Conor Dooley; +Cc: u-boot, Conor Dooley, Padmarao Begari, Cyril Jean, Tom Rini

On Wed, May 15, 2024 at 04:04:30PM +0100, Conor Dooley wrote:
> From: Conor Dooley <conor.dooley@microchip.com>
> 
> Node offsets returned by libfdt can contain negative error numbers, so
> the variable type should be "int". As things stand, if the ethernet
> nodes are not found in the early init callback, the if (node < 0) tests
> pass and the code errors out while trying to set the local-mac-address
> for a non-existent node.
> 
> Fixes: 64413e1b7c ("riscv: Add Microchip MPFS Icicle Kit support")
> Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
> ---
>  board/microchip/mpfs_icicle/mpfs_icicle.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

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

* Re: [PATCH v1 2/2] board: microchip: icicle: make both ethernets optional
  2024-05-15 15:04 ` [PATCH v1 2/2] board: microchip: icicle: make both ethernets optional Conor Dooley
@ 2024-05-30  3:13   ` Leo Liang
  0 siblings, 0 replies; 5+ messages in thread
From: Leo Liang @ 2024-05-30  3:13 UTC (permalink / raw)
  To: Conor Dooley; +Cc: u-boot, Conor Dooley, Padmarao Begari, Cyril Jean, Tom Rini

On Wed, May 15, 2024 at 04:04:31PM +0100, Conor Dooley wrote:
> From: Conor Dooley <conor.dooley@microchip.com>
> 
> A given AMP configuration for a board may make either one, or neither
> of, the ethernet ports available to U-Boot. The Icicle's init code will
> fail if mac1 is not present, so move it to the optional approach taken
> for mac0.
> 
> Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
> ---
>  board/microchip/mpfs_icicle/mpfs_icicle.c | 23 +++++++----------------
>  1 file changed, 7 insertions(+), 16 deletions(-)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

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

end of thread, other threads:[~2024-05-30  3:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-15 15:04 [PATCH v1 0/2] Two mpfs icicle init fixes Conor Dooley
2024-05-15 15:04 ` [PATCH v1 1/2] board: microchip: icicle: correct type for node offset Conor Dooley
2024-05-30  3:11   ` Leo Liang
2024-05-15 15:04 ` [PATCH v1 2/2] board: microchip: icicle: make both ethernets optional Conor Dooley
2024-05-30  3:13   ` Leo Liang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.