u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm: mvebu: turris_omnia: Remove hardcoded spi-nor device tree path
@ 2022-08-01 21:58 Pali Rohár
  2022-08-02  6:51 ` Stefan Roese
  2022-08-09 11:33 ` Stefan Roese
  0 siblings, 2 replies; 3+ messages in thread
From: Pali Rohár @ 2022-08-01 21:58 UTC (permalink / raw)
  To: Stefan Roese; +Cc: Marek Behun, u-boot

Linux kernel DTS files renamed spi-nor@0 node to flash@0 which effectively
broke U-Boot to boot new Linux kernel versions correctly.

So remove hardcoded spi-nor device tree path from Turris Omnia board code
and replace it by searching for mtd node by compatible string.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 board/CZ.NIC/turris_omnia/turris_omnia.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
index 108d160f486d..9d7e63865f14 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -32,8 +32,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define OMNIA_SPI_NOR_PATH		"/soc/spi@10600/spi-nor@0"
-
 #define OMNIA_I2C_BUS_NAME		"i2c@11000->i2cmux@70->i2c@0"
 
 #define OMNIA_I2C_MCU_CHIP_ADDR		0x2a
@@ -1030,14 +1028,22 @@ static bool fixup_mtd_partitions(void *blob, int offset, struct mtd_info *mtd)
 
 static void fixup_spi_nor_partitions(void *blob)
 {
-	struct mtd_info *mtd;
+	struct mtd_info *mtd = NULL;
+	char mtd_path[64];
 	int node;
 
-	mtd = get_mtd_device_nm(OMNIA_SPI_NOR_PATH);
+	node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "jedec,spi-nor");
+	if (node < 0)
+		goto fail;
+
+	if (fdt_get_path(gd->fdt_blob, node, mtd_path, sizeof(mtd_path)) < 0)
+		goto fail;
+
+	mtd = get_mtd_device_nm(mtd_path);
 	if (IS_ERR_OR_NULL(mtd))
 		goto fail;
 
-	node = fdt_path_offset(blob, OMNIA_SPI_NOR_PATH);
+	node = fdt_node_offset_by_compatible(blob, -1, "jedec,spi-nor");
 	if (node < 0)
 		goto fail;
 
-- 
2.20.1


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

* Re: [PATCH] arm: mvebu: turris_omnia: Remove hardcoded spi-nor device tree path
  2022-08-01 21:58 [PATCH] arm: mvebu: turris_omnia: Remove hardcoded spi-nor device tree path Pali Rohár
@ 2022-08-02  6:51 ` Stefan Roese
  2022-08-09 11:33 ` Stefan Roese
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Roese @ 2022-08-02  6:51 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Marek Behun, u-boot

On 01.08.22 23:58, Pali Rohár wrote:
> Linux kernel DTS files renamed spi-nor@0 node to flash@0 which effectively
> broke U-Boot to boot new Linux kernel versions correctly.
> 
> So remove hardcoded spi-nor device tree path from Turris Omnia board code
> and replace it by searching for mtd node by compatible string.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   board/CZ.NIC/turris_omnia/turris_omnia.c | 16 +++++++++++-----
>   1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
> index 108d160f486d..9d7e63865f14 100644
> --- a/board/CZ.NIC/turris_omnia/turris_omnia.c
> +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
> @@ -32,8 +32,6 @@
>   
>   DECLARE_GLOBAL_DATA_PTR;
>   
> -#define OMNIA_SPI_NOR_PATH		"/soc/spi@10600/spi-nor@0"
> -
>   #define OMNIA_I2C_BUS_NAME		"i2c@11000->i2cmux@70->i2c@0"
>   
>   #define OMNIA_I2C_MCU_CHIP_ADDR		0x2a
> @@ -1030,14 +1028,22 @@ static bool fixup_mtd_partitions(void *blob, int offset, struct mtd_info *mtd)
>   
>   static void fixup_spi_nor_partitions(void *blob)
>   {
> -	struct mtd_info *mtd;
> +	struct mtd_info *mtd = NULL;
> +	char mtd_path[64];
>   	int node;
>   
> -	mtd = get_mtd_device_nm(OMNIA_SPI_NOR_PATH);
> +	node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "jedec,spi-nor");
> +	if (node < 0)
> +		goto fail;
> +
> +	if (fdt_get_path(gd->fdt_blob, node, mtd_path, sizeof(mtd_path)) < 0)
> +		goto fail;
> +
> +	mtd = get_mtd_device_nm(mtd_path);
>   	if (IS_ERR_OR_NULL(mtd))
>   		goto fail;
>   
> -	node = fdt_path_offset(blob, OMNIA_SPI_NOR_PATH);
> +	node = fdt_node_offset_by_compatible(blob, -1, "jedec,spi-nor");
>   	if (node < 0)
>   		goto fail;
>   

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH] arm: mvebu: turris_omnia: Remove hardcoded spi-nor device tree path
  2022-08-01 21:58 [PATCH] arm: mvebu: turris_omnia: Remove hardcoded spi-nor device tree path Pali Rohár
  2022-08-02  6:51 ` Stefan Roese
@ 2022-08-09 11:33 ` Stefan Roese
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Roese @ 2022-08-09 11:33 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Marek Behun, u-boot

On 01.08.22 23:58, Pali Rohár wrote:
> Linux kernel DTS files renamed spi-nor@0 node to flash@0 which effectively
> broke U-Boot to boot new Linux kernel versions correctly.
> 
> So remove hardcoded spi-nor device tree path from Turris Omnia board code
> and replace it by searching for mtd node by compatible string.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Applied to u-boot-marvell/master

Thanks,
Stefan

> ---
>   board/CZ.NIC/turris_omnia/turris_omnia.c | 16 +++++++++++-----
>   1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
> index 108d160f486d..9d7e63865f14 100644
> --- a/board/CZ.NIC/turris_omnia/turris_omnia.c
> +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
> @@ -32,8 +32,6 @@
>   
>   DECLARE_GLOBAL_DATA_PTR;
>   
> -#define OMNIA_SPI_NOR_PATH		"/soc/spi@10600/spi-nor@0"
> -
>   #define OMNIA_I2C_BUS_NAME		"i2c@11000->i2cmux@70->i2c@0"
>   
>   #define OMNIA_I2C_MCU_CHIP_ADDR		0x2a
> @@ -1030,14 +1028,22 @@ static bool fixup_mtd_partitions(void *blob, int offset, struct mtd_info *mtd)
>   
>   static void fixup_spi_nor_partitions(void *blob)
>   {
> -	struct mtd_info *mtd;
> +	struct mtd_info *mtd = NULL;
> +	char mtd_path[64];
>   	int node;
>   
> -	mtd = get_mtd_device_nm(OMNIA_SPI_NOR_PATH);
> +	node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "jedec,spi-nor");
> +	if (node < 0)
> +		goto fail;
> +
> +	if (fdt_get_path(gd->fdt_blob, node, mtd_path, sizeof(mtd_path)) < 0)
> +		goto fail;
> +
> +	mtd = get_mtd_device_nm(mtd_path);
>   	if (IS_ERR_OR_NULL(mtd))
>   		goto fail;
>   
> -	node = fdt_path_offset(blob, OMNIA_SPI_NOR_PATH);
> +	node = fdt_node_offset_by_compatible(blob, -1, "jedec,spi-nor");
>   	if (node < 0)
>   		goto fail;
>   

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

end of thread, other threads:[~2022-08-09 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-01 21:58 [PATCH] arm: mvebu: turris_omnia: Remove hardcoded spi-nor device tree path Pali Rohár
2022-08-02  6:51 ` Stefan Roese
2022-08-09 11:33 ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).