public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] arm: mvebu: Define env_sf_get_env_addr() for all Armada boards in SPL
@ 2022-08-08 17:13 Pali Rohár
  2022-08-09  9:20 ` Marek Behún
  2022-08-23 14:57 ` Stefan Roese
  0 siblings, 2 replies; 6+ messages in thread
From: Pali Rohár @ 2022-08-08 17:13 UTC (permalink / raw)
  To: Stefan Roese, Marek Behún; +Cc: u-boot

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.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 arch/arm/mach-mvebu/spl.c                | 13 +++++++++++++
 board/CZ.NIC/turris_omnia/turris_omnia.c | 10 ----------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index 13c99913c380..866e0ac62345 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -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;
diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
index 5921769f1e1d..3180305f8031 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -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
-- 
2.20.1


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

* Re: [PATCH] arm: mvebu: Define env_sf_get_env_addr() for all Armada boards in SPL
  2022-08-08 17:13 [PATCH] arm: mvebu: Define env_sf_get_env_addr() for all Armada boards in SPL Pali Rohár
@ 2022-08-09  9:20 ` Marek Behún
  2022-08-09  9:27   ` Pali Rohár
  2022-08-23 14:57 ` Stefan Roese
  1 sibling, 1 reply; 6+ messages in thread
From: Marek Behún @ 2022-08-09  9:20 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Stefan Roese, u-boot

On Mon,  8 Aug 2022 19:13:43 +0200
Pali Rohár <pali@kernel.org> 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.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

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...

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

* Re: [PATCH] arm: mvebu: Define env_sf_get_env_addr() for all Armada boards in SPL
  2022-08-09  9:20 ` Marek Behún
@ 2022-08-09  9:27   ` Pali Rohár
  2022-08-09 12:45     ` Marek Behún
  0 siblings, 1 reply; 6+ messages in thread
From: Pali Rohár @ 2022-08-09  9:27 UTC (permalink / raw)
  To: Marek Behún; +Cc: Stefan Roese, u-boot

On Tuesday 09 August 2022 11:20:12 Marek Behún wrote:
> On Mon,  8 Aug 2022 19:13:43 +0200
> Pali Rohár <pali@kernel.org> 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.
> > 
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> 
> 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

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

* Re: [PATCH] arm: mvebu: Define env_sf_get_env_addr() for all Armada boards in SPL
  2022-08-09  9:27   ` Pali Rohár
@ 2022-08-09 12:45     ` Marek Behún
  2022-08-09 13:12       ` Stefan Roese
  0 siblings, 1 reply; 6+ messages in thread
From: Marek Behún @ 2022-08-09 12:45 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Stefan Roese, u-boot

On Tue, 9 Aug 2022 11:27:09 +0200
Pali Rohár <pali@kernel.org> wrote:

> On Tuesday 09 August 2022 11:20:12 Marek Behún wrote:
> > On Mon,  8 Aug 2022 19:13:43 +0200
> > Pali Rohár <pali@kernel.org> 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.
> > > 
> > > Signed-off-by: Pali Rohár <pali@kernel.org>  
> > 
> > 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

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

Marek

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

* Re: [PATCH] arm: mvebu: Define env_sf_get_env_addr() for all Armada boards in SPL
  2022-08-09 12:45     ` Marek Behún
@ 2022-08-09 13:12       ` Stefan Roese
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Roese @ 2022-08-09 13:12 UTC (permalink / raw)
  To: Marek Behún, Pali Rohár; +Cc: u-boot

On 09.08.22 14:45, Marek Behún wrote:
> On Tue, 9 Aug 2022 11:27:09 +0200
> Pali Rohár <pali@kernel.org> wrote:
> 
>> On Tuesday 09 August 2022 11:20:12 Marek Behún wrote:
>>> On Mon,  8 Aug 2022 19:13:43 +0200
>>> Pali Rohár <pali@kernel.org> 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.
>>>>
>>>> Signed-off-by: Pali Rohár <pali@kernel.org>
>>>
>>> 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
> 
> I don't think such non-standard configurations are used :) Lets do that
> only if someone complains.

Agreed.

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

Thanks,
Stefan

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

* Re: [PATCH] arm: mvebu: Define env_sf_get_env_addr() for all Armada boards in SPL
  2022-08-08 17:13 [PATCH] arm: mvebu: Define env_sf_get_env_addr() for all Armada boards in SPL Pali Rohár
  2022-08-09  9:20 ` Marek Behún
@ 2022-08-23 14:57 ` Stefan Roese
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Roese @ 2022-08-23 14:57 UTC (permalink / raw)
  To: Pali Rohár, Marek Behún; +Cc: u-boot

On 08.08.22 19:13, Pali Rohár 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.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Applied to u-boot-marvell/master

Thanks,
Stefan

> ---
>   arch/arm/mach-mvebu/spl.c                | 13 +++++++++++++
>   board/CZ.NIC/turris_omnia/turris_omnia.c | 10 ----------
>   2 files changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
> index 13c99913c380..866e0ac62345 100644
> --- a/arch/arm/mach-mvebu/spl.c
> +++ b/arch/arm/mach-mvebu/spl.c
> @@ -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;
> diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
> index 5921769f1e1d..3180305f8031 100644
> --- a/board/CZ.NIC/turris_omnia/turris_omnia.c
> +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
> @@ -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

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] 6+ messages in thread

end of thread, other threads:[~2022-08-23 14:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-08 17:13 [PATCH] arm: mvebu: Define env_sf_get_env_addr() for all Armada boards in SPL Pali Rohár
2022-08-09  9:20 ` Marek Behún
2022-08-09  9:27   ` Pali Rohár
2022-08-09 12:45     ` Marek Behún
2022-08-09 13:12       ` Stefan Roese
2022-08-23 14:57 ` Stefan Roese

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