Skip to contentSkip to conversation

arm: mvebu: Define env_sf_get_env_addr() for all Armada boards in SPL

PATCH In review Pali Rohár 3 participants 6 messages Aug 8, 2022 – Aug 23, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: mvebu: Define env_sf_get_env_addr() for all Armada boards in SPL

SPI0 CS0 Flash is mapped to address range 0xD4000000 - 0xD7FFFFFF by BootROM. Proper U-Boot removes this direct mapping. So it is available only in SPL. This applies for all 32-bit Armada BootROMs. SPL mvebu code is used only on 32-bit Armada SoCs. So move env_sf_get_env_addr() function from Turris Omnia board to common SPL mvebu code and add proper checks for SPI0 CS0.

---
 arch/arm/mach-mvebu/spl.c                | 13 +++++++++++++
 board/CZ.NIC/turris_omnia/turris_omnia.c | 10 ----------
 2 files changed, 13 insertions(+), 10 deletions(-)
arch/arm/mach-mvebu/spl.c +13 -0
index 13c99913c380..866e0ac62345 100644
@@ -292,6 +292,19 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
 	hang();
 }
 
+/*
+ * SPI0 CS0 Flash is mapped to address range 0xD4000000 - 0xD7FFFFFF by BootROM.
+ * Proper U-Boot removes this direct mapping. So it is available only in SPL.
+ */
+#if defined(CONFIG_SPL_ENV_IS_IN_SPI_FLASH) && \
+    CONFIG_ENV_SPI_BUS == 0 && CONFIG_ENV_SPI_CS == 0 && \
+    CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE <= 64*1024*1024
+void *env_sf_get_env_addr(void)
+{
+	return (void *)0xD4000000 + CONFIG_ENV_OFFSET;
+}
+#endif
+
 void board_init_f(ulong dummy)
 {
 	int ret;
board/CZ.NIC/turris_omnia/turris_omnia.c +0 -10
index 5921769f1e1d..3180305f8031 100644
@@ -255,16 +255,6 @@ static bool omnia_detect_wwan_usb3(const char *wwan_slot)
 	return false;
 }
 
-void *env_sf_get_env_addr(void)
-{
-	/* SPI Flash is mapped to address 0xD4000000 only in SPL */
-#ifdef CONFIG_SPL_BUILD
-	return (void *)0xD4000000 + CONFIG_ENV_OFFSET;
-#else
-	return NULL;
-#endif
-}
-
 int hws_board_topology_load(struct serdes_map **serdes_map_array, u8 *count)
 {
 #ifdef CONFIG_SPL_ENV_SUPPORT
Signature · 1 line
2.20.1
#1 lore raw
Quoted 7 lines · On Mon, 8 Aug 2022 19:13:43 +0200 Pali Rohár <[email protected]> wrote:

SPI0 CS0 Flash is mapped to address range 0xD4000000 - 0xD7FFFFFF by BootROM. Proper U-Boot removes this direct mapping. So it is available only in SPL. This applies for all 32-bit Armada BootROMs. SPL mvebu code is used only on 32-bit Armada SoCs. So move env_sf_get_env_addr() function from Turris Omnia board to common SPL mvebu code and add proper checks for SPI0 CS0.

Do we know that this will work for all flash memories used on those other boards? Some boards may have non-compliant SPI-NORs soldered on.

But if BootROM on those boards also uses this mapping to read flash, it should be okay...

#2 lore raw
Quoted 9 lines · On Tuesday 09 August 2022 11:20:12 Marek Behún wrote:
Quoted 6 lines · On Mon, 8 Aug 2022 19:13:43 +0200 Pali Rohár <[email protected]> wrote:

SPI0 CS0 Flash is mapped to address range 0xD4000000 - 0xD7FFFFFF by BootROM. Proper U-Boot removes this direct mapping. So it is available only in SPL. This applies for all 32-bit Armada BootROMs. SPL mvebu code is used only on 32-bit Armada SoCs. So move env_sf_get_env_addr() function from Turris Omnia board to common SPL mvebu code and add proper checks for SPI0 CS0.

Quoted 7 lines
Quoted 1 line

Do we know that this will work for all flash memories used on those other boards? Some boards may have non-compliant SPI-NORs soldered on.

But if BootROM on those boards also uses this mapping to read flash, it should be okay...

IIRC this range is used by BootROM for reading SPL.

Ok, I can imagine some very special configuration where SPL kwbimage is stored on eMMC, eMMC is used for BootROM booting, but ENV is stored on non-standard SPI flash, which BootROM cannot access, but U-Boot yes.

So maybe I should add another #ifdef guard e.g. ?

  #ifdef CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI
#3 lore raw
Quoted 20 lines · On Tue, 9 Aug 2022 11:27:09 +0200 Pali Rohár <[email protected]> wrote:
Quoted 9 lines · On Tuesday 09 August 2022 11:20:12 Marek Behún wrote:
Quoted 6 lines · On Mon, 8 Aug 2022 19:13:43 +0200 Pali Rohár <[email protected]> wrote:

SPI0 CS0 Flash is mapped to address range 0xD4000000 - 0xD7FFFFFF by BootROM. Proper U-Boot removes this direct mapping. So it is available only in SPL. This applies for all 32-bit Armada BootROMs. SPL mvebu code is used only on 32-bit Armada SoCs. So move env_sf_get_env_addr() function from Turris Omnia board to common SPL mvebu code and add proper checks for SPI0 CS0.

Quoted 7 lines
Quoted 1 line

Do we know that this will work for all flash memories used on those other boards? Some boards may have non-compliant SPI-NORs soldered on.

But if BootROM on those boards also uses this mapping to read flash, it should be okay...

IIRC this range is used by BootROM for reading SPL.

Quoted 7 lines

Ok, I can imagine some very special configuration where SPL kwbimage is stored on eMMC, eMMC is used for BootROM booting, but ENV is stored on non-standard SPI flash, which BootROM cannot access, but U-Boot yes.

So maybe I should add another #ifdef guard e.g. ?

  #ifdef CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI

I don't think such non-standard configurations are used :) Lets do that only if someone complains.

Marek

Reviewed-by
#4 lore raw
Quoted 27 lines · Marek Behún
Quoted 24 lines · On Tue, 9 Aug 2022 11:27:09 +0200 Pali Rohár <[email protected]> wrote:
Quoted 9 lines · On Tuesday 09 August 2022 11:20:12 Marek Behún wrote:
Quoted 6 lines · On Mon, 8 Aug 2022 19:13:43 +0200 Pali Rohár <[email protected]> wrote:

SPI0 CS0 Flash is mapped to address range 0xD4000000 - 0xD7FFFFFF by BootROM. Proper U-Boot removes this direct mapping. So it is available only in SPL. This applies for all 32-bit Armada BootROMs. SPL mvebu code is used only on 32-bit Armada SoCs. So move env_sf_get_env_addr() function from Turris Omnia board to common SPL mvebu code and add proper checks for SPI0 CS0.

Quoted 7 lines
Quoted 1 line

Do we know that this will work for all flash memories used on those other boards? Some boards may have non-compliant SPI-NORs soldered on.

But if BootROM on those boards also uses this mapping to read flash, it should be okay...

IIRC this range is used by BootROM for reading SPL.

Ok, I can imagine some very special configuration where SPL kwbimage is stored on eMMC, eMMC is used for BootROM booting, but ENV is stored on non-standard SPI flash, which BootROM cannot access, but U-Boot yes.

Quoted 6 lines
Quoted 3 lines

So maybe I should add another #ifdef guard e.g. ?

   #ifdef CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI

I don't think such non-standard configurations are used :) Lets do that only if someone complains.

Agreed.

Thanks,
Stefan

#5 lore raw
In reply to Pali Rohár
Quoted 7 lines · Pali Rohár

SPI0 CS0 Flash is mapped to address range 0xD4000000 - 0xD7FFFFFF by BootROM. Proper U-Boot removes this direct mapping. So it is available only in SPL. This applies for all 32-bit Armada BootROMs. SPL mvebu code is used only on 32-bit Armada SoCs. So move env_sf_get_env_addr() function from Turris Omnia board to common SPL mvebu code and add proper checks for SPI0 CS0.

Applied to u-boot-marvell/master

Thanks,
Stefan

Quoted 40 lines
---
  arch/arm/mach-mvebu/spl.c                | 13 +++++++++++++
  board/CZ.NIC/turris_omnia/turris_omnia.c | 10 ----------
  2 files changed, 13 insertions(+), 10 deletions(-)
arch/arm/mach-mvebu/spl.c +13 -0
index 13c99913c380..866e0ac62345 100644
@@ -292,6 +292,19 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
  	hang();
  }
 
+/*
+ * SPI0 CS0 Flash is mapped to address range 0xD4000000 - 0xD7FFFFFF by BootROM.
+ * Proper U-Boot removes this direct mapping. So it is available only in SPL.
+ */
+#if defined(CONFIG_SPL_ENV_IS_IN_SPI_FLASH) && \
+    CONFIG_ENV_SPI_BUS == 0 && CONFIG_ENV_SPI_CS == 0 && \
+    CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE <= 64*1024*1024
+void *env_sf_get_env_addr(void)
+{
+	return (void *)0xD4000000 + CONFIG_ENV_OFFSET;
+}
+#endif
+
  void board_init_f(ulong dummy)
  {
  	int ret;
board/CZ.NIC/turris_omnia/turris_omnia.c +0 -3
index 5921769f1e1d..3180305f8031 100644
@@ -255,16 +255,6 @@ static bool omnia_detect_wwan_usb3(const char *wwan_slot)
  	return false;
  }
 
-void *env_sf_get_env_addr(void)
-{
-	/* SPI Flash is mapped to address 0xD4000000 only in SPL */

board/CZ.NIC/turris_omnia/turris_omnia.c static bool omnia_detect_wwan_usb3(const char *wwan_slot) · line 260

Quoted 10 lines
board/CZ.NIC/turris_omnia/turris_omnia.c +0 -7
-#ifdef CONFIG_SPL_BUILD
-	return (void *)0xD4000000 + CONFIG_ENV_OFFSET;
-#else
-	return NULL;
-#endif
-}
-
  int hws_board_topology_load(struct serdes_map **serdes_map_array, u8 *count)
  {
  #ifdef CONFIG_SPL_ENV_SUPPORT

Viele Grüße,
Stefan Roese

Signature · 3 lines
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: [email protected]