All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: "Marek Behún" <marek.behun@nic.cz>
Cc: u-boot@lists.denx.de, pali@kernel.org
Subject: Re: [PATCH u-boot-mvebu v2 1/4] arm: mvebu: Move get_boot_device() to cpu.c and make visible
Date: Tue, 17 Aug 2021 09:46:14 +0200	[thread overview]
Message-ID: <4f0cdb56-0a7e-7a48-cc47-c59050a001de@denx.de> (raw)
In-Reply-To: <20210816131940.24206-2-marek.behun@nic.cz>

On 16.08.21 15:19, Marek Behún wrote:
> Move the function get_boot_device() from spl.c to cpu.c.
> 
> Make it visible, so that it may be used from other files.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

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

Thanks,
Stefan

> ---
>   arch/arm/mach-mvebu/cpu.c              | 60 ++++++++++++++++++++
>   arch/arm/mach-mvebu/include/mach/cpu.h |  2 +
>   arch/arm/mach-mvebu/spl.c              | 77 +++-----------------------
>   3 files changed, 71 insertions(+), 68 deletions(-)
> 
> diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c
> index 0b935c46fb..daf8bd66a0 100644
> --- a/arch/arm/mach-mvebu/cpu.c
> +++ b/arch/arm/mach-mvebu/cpu.c
> @@ -14,6 +14,7 @@
>   #include <asm/pl310.h>
>   #include <asm/arch/cpu.h>
>   #include <asm/arch/soc.h>
> +#include <asm/spl.h>
>   #include <sdhci.h>
>   
>   #define DDR_BASE_CS_OFF(n)	(0x0000 + ((n) << 3))
> @@ -80,6 +81,65 @@ int mvebu_soc_family(void)
>   	return MVEBU_SOC_UNKNOWN;
>   }
>   
> +u32 get_boot_device(void)
> +{
> +	u32 val;
> +	u32 boot_device;
> +
> +	/*
> +	  * First check, if UART boot-mode is active. This can only
> +	  * be done, via the bootrom error register. Here the
> +	  * MSB marks if the UART mode is active.
> +	  */
> +	val = readl(CONFIG_BOOTROM_ERR_REG);
> +	boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
> +	debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
> +	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
> +	  */
> +	val = readl(CONFIG_SAR_REG);	/* SAR - Sample At Reset */
> +	boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
> +	debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device);
> +	switch (boot_device) {
> +#ifdef BOOT_FROM_NAND
> +	case BOOT_FROM_NAND:
> +		return BOOT_DEVICE_NAND;
> +#endif
> +#ifdef BOOT_FROM_MMC
> +	case BOOT_FROM_MMC:
> +	case BOOT_FROM_MMC_ALT:
> +		return BOOT_DEVICE_MMC1;
> +#endif
> +	case BOOT_FROM_UART:
> +#ifdef BOOT_FROM_UART_ALT
> +	case BOOT_FROM_UART_ALT:
> +#endif
> +		return BOOT_DEVICE_UART;
> +#ifdef BOOT_FROM_SATA
> +	case BOOT_FROM_SATA:
> +	case BOOT_FROM_SATA_ALT:
> +		return BOOT_DEVICE_SATA;
> +#endif
> +	case BOOT_FROM_SPI:
> +		return BOOT_DEVICE_SPI;
> +	default:
> +		return BOOT_DEVICE_BOOTROM;
> +	};
> +}
> +
>   #if defined(CONFIG_DISPLAY_CPUINFO)
>   
>   #if defined(CONFIG_ARMADA_375)
> diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h b/arch/arm/mach-mvebu/include/mach/cpu.h
> index 79858858c2..a7a62c7e7d 100644
> --- a/arch/arm/mach-mvebu/include/mach/cpu.h
> +++ b/arch/arm/mach-mvebu/include/mach/cpu.h
> @@ -148,6 +148,8 @@ void __noreturn return_to_bootrom(void);
>   int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks);
>   #endif
>   
> +u32 get_boot_device(void);
> +
>   void get_sar_freq(struct sar_freq_modes *sar_freq);
>   
>   /*
> diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
> index f0cf60bb14..8d6d4902f6 100644
> --- a/arch/arm/mach-mvebu/spl.c
> +++ b/arch/arm/mach-mvebu/spl.c
> @@ -171,74 +171,6 @@ int spl_parse_board_header(struct spl_image_info *spl_image,
>   	return 0;
>   }
>   
> -static u32 get_boot_device(void)
> -{
> -	u32 val;
> -	u32 boot_device;
> -
> -	/*
> -	 * First check, if UART boot-mode is active. This can only
> -	 * be done, via the bootrom error register. Here the
> -	 * MSB marks if the UART mode is active.
> -	 */
> -	val = readl(CONFIG_BOOTROM_ERR_REG);
> -	boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
> -	debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
> -	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
> -	 */
> -	val = readl(CONFIG_SAR_REG);	/* SAR - Sample At Reset */
> -	boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
> -	debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device);
> -	switch (boot_device) {
> -#ifdef BOOT_FROM_NAND
> -	case BOOT_FROM_NAND:
> -		return BOOT_DEVICE_NAND;
> -#endif
> -#ifdef BOOT_FROM_MMC
> -	case BOOT_FROM_MMC:
> -	case BOOT_FROM_MMC_ALT:
> -		return BOOT_DEVICE_MMC1;
> -#endif
> -	case BOOT_FROM_UART:
> -#ifdef BOOT_FROM_UART_ALT
> -	case BOOT_FROM_UART_ALT:
> -#endif
> -		return BOOT_DEVICE_UART;
> -#ifdef BOOT_FROM_SATA
> -	case BOOT_FROM_SATA:
> -	case BOOT_FROM_SATA_ALT:
> -		return BOOT_DEVICE_SATA;
> -#endif
> -	case BOOT_FROM_SPI:
> -		return BOOT_DEVICE_SPI;
> -	default:
> -		return BOOT_DEVICE_BOOTROM;
> -	};
> -}
> -
> -#else
> -
> -static u32 get_boot_device(void)
> -{
> -	return BOOT_DEVICE_BOOTROM;
> -}
> -
> -#endif
> -
>   u32 spl_boot_device(void)
>   {
>   	u32 boot_device = get_boot_device();
> @@ -285,6 +217,15 @@ u32 spl_boot_device(void)
>   	}
>   }
>   
> +#else
> +
> +u32 spl_boot_device(void)
> +{
> +	return BOOT_DEVICE_BOOTROM;
> +}
> +
> +#endif
> +
>   int board_return_to_bootrom(struct spl_image_info *spl_image,
>   			    struct spl_boot_device *bootdev)
>   {
> 


Viele Grüße,
Stefan

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

  parent reply	other threads:[~2021-08-17  7:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16 13:19 [PATCH u-boot-mvebu v2 0/4] turris_omnia: Disable MCU watchdog in SPL when booting over UART Marek Behún
2021-08-16 13:19 ` [PATCH u-boot-mvebu v2 1/4] arm: mvebu: Move get_boot_device() to cpu.c and make visible Marek Behún
2021-08-16 17:51   ` Pali Rohár
2021-08-17  7:46   ` Stefan Roese [this message]
2021-09-01  9:13   ` Stefan Roese
2021-08-16 13:19 ` [PATCH u-boot-mvebu v2 2/4] arm: mvebu: turris_omnia: don't guard by CONFIG_SPL_BUILD macro Marek Behún
2021-08-16 17:55   ` Pali Rohár
2021-08-17  7:46   ` Stefan Roese
2021-09-01  9:13   ` Stefan Roese
2021-08-16 13:19 ` [PATCH u-boot-mvebu v2 3/4] arm: mvebu: turris_omnia: disable MCU watchdog in SPL when booting over UART Marek Behún
2021-08-16 17:56   ` Pali Rohár
2021-08-17  7:46   ` Stefan Roese
2021-09-01  9:13   ` Stefan Roese
2021-08-16 13:19 ` [PATCH u-boot-mvebu v2 4/4] arm: mvebu: turris_omnia: disable MCU watchdog in board_late_init() Marek Behún
2021-08-16 17:56   ` Pali Rohár
2021-08-17  7:46   ` Stefan Roese
2021-09-01  9:14   ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f0cdb56-0a7e-7a48-cc47-c59050a001de@denx.de \
    --to=sr@denx.de \
    --cc=marek.behun@nic.cz \
    --cc=pali@kernel.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.