diff mbox series

[U-Boot,v2,2/2] ARM: mach-mvebu: handle fall-back to UART boot

Message ID 20180817084742.11628-2-judge.packham@gmail.com
State Accepted
Commit 2fd4284051e33763e3424cbd7e106e0a75dfd16e
Delegated to: Stefan Roese
Headers show
Series [U-Boot,v2,1/2] Revert "arm: mvebu: fix boot from UART when in fallback mode" | expand

Commit Message

Chris Packham Aug. 17, 2018, 8:47 a.m. UTC
The bootROM in the Armada-38x (and similar) SoC has two modes for UART
boot. The first is when the normal boot media is blank (or otherwise
missing the kwb header). The second is when the boot sequence has been
interrupted with the magic byte sequence on the UART lines.

In the first mode the bootROM routine and error code register will
indicate that there was an error booting from the configured media in
bits 7:0. In the second mode there is no error to indicate but the boot
source is provided via bits 31:28.

Handle both situations so that kwboot can be used for both boot
strapping a blank board and for intercepting a regular boot sequence.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
---
I think this probably applies to more than just the A38X but I've been
conservative in restricting this for now. If other Marvell SoCs are
found to have the same behaviour we can extend this to cover them.

Changes in v2:
- new

 arch/arm/mach-mvebu/include/mach/soc.h |  2 ++
 arch/arm/mach-mvebu/spl.c              | 10 ++++++++++
 2 files changed, 12 insertions(+)

Comments

Sean Nyekjær Aug. 17, 2018, 9:42 a.m. UTC | #1
On 17/08/2018 10.47, Chris Packham wrote:
> The bootROM in the Armada-38x (and similar) SoC has two modes for UART
> boot. The first is when the normal boot media is blank (or otherwise
> missing the kwb header). The second is when the boot sequence has been
> interrupted with the magic byte sequence on the UART lines.
> 
> In the first mode the bootROM routine and error code register will
> indicate that there was an error booting from the configured media in
> bits 7:0. In the second mode there is no error to indicate but the boot
> source is provided via bits 31:28.
> 
> Handle both situations so that kwboot can be used for both boot
> strapping a blank board and for intercepting a regular boot sequence.
> 
> Signed-off-by: Chris Packham <judge.packham@gmail.com>
Signed-off-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
> ---
> I think this probably applies to more than just the A38X but I've been
> conservative in restricting this for now. If other Marvell SoCs are
> found to have the same behaviour we can extend this to cover them.
> 
> Changes in v2:
> - new
> 
>   arch/arm/mach-mvebu/include/mach/soc.h |  2 ++
>   arch/arm/mach-mvebu/spl.c              | 10 ++++++++++
>   2 files changed, 12 insertions(+)
> 
> diff --git a/arch/arm/mach-mvebu/include/mach/soc.h b/arch/arm/mach-mvebu/include/mach/soc.h
> index 660dd148abc5..6e2e14efe0b7 100644
> --- a/arch/arm/mach-mvebu/include/mach/soc.h
> +++ b/arch/arm/mach-mvebu/include/mach/soc.h
> @@ -114,6 +114,8 @@
>   #define BOOTROM_ERR_MODE_OFFS	28
>   #define BOOTROM_ERR_MODE_MASK	(0xf << BOOTROM_ERR_MODE_OFFS)
>   #define BOOTROM_ERR_MODE_UART	0x6
> +#define BOOTROM_ERR_CODE_OFFS	0
> +#define BOOTROM_ERR_CODE_MASK	(0xf << BOOTROM_ERR_CODE_OFFS)
>   
>   #if defined(CONFIG_ARMADA_375)
>   /* SAR values for Armada 375 */
> diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
> index 4c3933b8354d..9dd7c84b6874 100644
> --- a/arch/arm/mach-mvebu/spl.c
> +++ b/arch/arm/mach-mvebu/spl.c
> @@ -28,6 +28,16 @@ static u32 get_boot_device(void)
>   	if (boot_device == BOOTROM_ERR_MODE_UART)
>   		return BOOT_DEVICE_UART;
>   
> +#ifdef CONFIG_ARMADA_38X
> +	/*
> +	 * If the bootrom error code contains any other than zeros it's an
> +	 * error condition and the bootROM has fallen back to UART boot
> +	 */
> +	boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
> +	if (boot_device)
> +		return BOOT_DEVICE_UART;
> +#endif
> +
>   	/*
>   	 * Now check the SAR register for the strapped boot-device
>   	 */
>
Sean Nyekjær Aug. 27, 2018, 7:41 a.m. UTC | #2
CC'ing someone with some hardware to test :-)

On 17/08/2018 11.42, Sean Nyekjær wrote:
> 
> 
> On 17/08/2018 10.47, Chris Packham wrote:
>> The bootROM in the Armada-38x (and similar) SoC has two modes for UART
>> boot. The first is when the normal boot media is blank (or otherwise
>> missing the kwb header). The second is when the boot sequence has been
>> interrupted with the magic byte sequence on the UART lines.
>>
>> In the first mode the bootROM routine and error code register will
>> indicate that there was an error booting from the configured media in
>> bits 7:0. In the second mode there is no error to indicate but the boot
>> source is provided via bits 31:28.
>>
>> Handle both situations so that kwboot can be used for both boot
>> strapping a blank board and for intercepting a regular boot sequence.
>>
>> Signed-off-by: Chris Packham <judge.packham@gmail.com>
> Signed-off-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
>> ---
>> I think this probably applies to more than just the A38X but I've been
>> conservative in restricting this for now. If other Marvell SoCs are
>> found to have the same behaviour we can extend this to cover them.
>>
>> Changes in v2:
>> - new
>>
>>   arch/arm/mach-mvebu/include/mach/soc.h |  2 ++
>>   arch/arm/mach-mvebu/spl.c              | 10 ++++++++++
>>   2 files changed, 12 insertions(+)
>>
>> diff --git a/arch/arm/mach-mvebu/include/mach/soc.h 
>> b/arch/arm/mach-mvebu/include/mach/soc.h
>> index 660dd148abc5..6e2e14efe0b7 100644
>> --- a/arch/arm/mach-mvebu/include/mach/soc.h
>> +++ b/arch/arm/mach-mvebu/include/mach/soc.h
>> @@ -114,6 +114,8 @@
>>   #define BOOTROM_ERR_MODE_OFFS    28
>>   #define BOOTROM_ERR_MODE_MASK    (0xf << BOOTROM_ERR_MODE_OFFS)
>>   #define BOOTROM_ERR_MODE_UART    0x6
>> +#define BOOTROM_ERR_CODE_OFFS    0
>> +#define BOOTROM_ERR_CODE_MASK    (0xf << BOOTROM_ERR_CODE_OFFS)
>>   #if defined(CONFIG_ARMADA_375)
>>   /* SAR values for Armada 375 */
>> diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
>> index 4c3933b8354d..9dd7c84b6874 100644
>> --- a/arch/arm/mach-mvebu/spl.c
>> +++ b/arch/arm/mach-mvebu/spl.c
>> @@ -28,6 +28,16 @@ static u32 get_boot_device(void)
>>       if (boot_device == BOOTROM_ERR_MODE_UART)
>>           return BOOT_DEVICE_UART;
>> +#ifdef CONFIG_ARMADA_38X
>> +    /*
>> +     * If the bootrom error code contains any other than zeros it's an
>> +     * error condition and the bootROM has fallen back to UART boot
>> +     */
>> +    boot_device = (val & BOOTROM_ERR_CODE_MASK) >> 
>> BOOTROM_ERR_CODE_OFFS;
>> +    if (boot_device)
>> +        return BOOT_DEVICE_UART;
>> +#endif
>> +
>>       /*
>>        * Now check the SAR register for the strapped boot-device
>>        */
>>
Stefan Roese Sept. 19, 2018, 12:16 p.m. UTC | #3
On 17.08.2018 10:47, Chris Packham wrote:
> The bootROM in the Armada-38x (and similar) SoC has two modes for UART
> boot. The first is when the normal boot media is blank (or otherwise
> missing the kwb header). The second is when the boot sequence has been
> interrupted with the magic byte sequence on the UART lines.
> 
> In the first mode the bootROM routine and error code register will
> indicate that there was an error booting from the configured media in
> bits 7:0. In the second mode there is no error to indicate but the boot
> source is provided via bits 31:28.
> 
> Handle both situations so that kwboot can be used for both boot
> strapping a blank board and for intercepting a regular boot sequence.
> 
> Signed-off-by: Chris Packham <judge.packham@gmail.com>
> ---
> I think this probably applies to more than just the A38X but I've been
> conservative in restricting this for now. If other Marvell SoCs are
> found to have the same behaviour we can extend this to cover them.
> 
> Changes in v2:
> - new
> 
>   arch/arm/mach-mvebu/include/mach/soc.h |  2 ++
>   arch/arm/mach-mvebu/spl.c              | 10 ++++++++++
>   2 files changed, 12 insertions(+)
> 
> diff --git a/arch/arm/mach-mvebu/include/mach/soc.h b/arch/arm/mach-mvebu/include/mach/soc.h
> index 660dd148abc5..6e2e14efe0b7 100644
> --- a/arch/arm/mach-mvebu/include/mach/soc.h
> +++ b/arch/arm/mach-mvebu/include/mach/soc.h
> @@ -114,6 +114,8 @@
>   #define BOOTROM_ERR_MODE_OFFS	28
>   #define BOOTROM_ERR_MODE_MASK	(0xf << BOOTROM_ERR_MODE_OFFS)
>   #define BOOTROM_ERR_MODE_UART	0x6
> +#define BOOTROM_ERR_CODE_OFFS	0
> +#define BOOTROM_ERR_CODE_MASK	(0xf << BOOTROM_ERR_CODE_OFFS)
>   
>   #if defined(CONFIG_ARMADA_375)
>   /* SAR values for Armada 375 */
> diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
> index 4c3933b8354d..9dd7c84b6874 100644
> --- a/arch/arm/mach-mvebu/spl.c
> +++ b/arch/arm/mach-mvebu/spl.c
> @@ -28,6 +28,16 @@ static u32 get_boot_device(void)
>   	if (boot_device == BOOTROM_ERR_MODE_UART)
>   		return BOOT_DEVICE_UART;
>   
> +#ifdef CONFIG_ARMADA_38X
> +	/*
> +	 * If the bootrom error code contains any other than zeros it's an
> +	 * error condition and the bootROM has fallen back to UART boot
> +	 */
> +	boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
> +	if (boot_device)
> +		return BOOT_DEVICE_UART;
> +#endif
> +
>   	/*
>   	 * Now check the SAR register for the strapped boot-device
>   	 */
> 

Applied to u-boot-marvell/master

Thanks,
Stefan
diff mbox series

Patch

diff --git a/arch/arm/mach-mvebu/include/mach/soc.h b/arch/arm/mach-mvebu/include/mach/soc.h
index 660dd148abc5..6e2e14efe0b7 100644
--- a/arch/arm/mach-mvebu/include/mach/soc.h
+++ b/arch/arm/mach-mvebu/include/mach/soc.h
@@ -114,6 +114,8 @@ 
 #define BOOTROM_ERR_MODE_OFFS	28
 #define BOOTROM_ERR_MODE_MASK	(0xf << BOOTROM_ERR_MODE_OFFS)
 #define BOOTROM_ERR_MODE_UART	0x6
+#define BOOTROM_ERR_CODE_OFFS	0
+#define BOOTROM_ERR_CODE_MASK	(0xf << BOOTROM_ERR_CODE_OFFS)
 
 #if defined(CONFIG_ARMADA_375)
 /* SAR values for Armada 375 */
diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index 4c3933b8354d..9dd7c84b6874 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -28,6 +28,16 @@  static u32 get_boot_device(void)
 	if (boot_device == BOOTROM_ERR_MODE_UART)
 		return BOOT_DEVICE_UART;
 
+#ifdef CONFIG_ARMADA_38X
+	/*
+	 * If the bootrom error code contains any other than zeros it's an
+	 * error condition and the bootROM has fallen back to UART boot
+	 */
+	boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
+	if (boot_device)
+		return BOOT_DEVICE_UART;
+#endif
+
 	/*
 	 * Now check the SAR register for the strapped boot-device
 	 */