Hi Vaishnav,

On 11/05/22 11:33AM, Vaishnav Achath wrote:
> implement overrides for spl_spi_boot_bus() and spl_spi_boot_cs()
> lookup functions according to bootmode selection, so as to support
> both QSPI and OSPI boot using the same build.
> 
> Signed-off-by: Vaishnav Achath <vaishna...@ti.com>
> ---
>  arch/arm/mach-k3/j721e_init.c   | 17 +++++++++++++++++
>  arch/arm/mach-k3/sysfw-loader.c |  4 ++--
>  2 files changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
> index f503f15f19..82391b5cf8 100644
> --- a/arch/arm/mach-k3/j721e_init.c
> +++ b/arch/arm/mach-k3/j721e_init.c
> @@ -355,6 +355,23 @@ static u32 __get_primary_bootmedia(u32 main_devstat, u32 
> wkup_devstat)
>       return bootmode;
>  }
>  
> +u32 spl_spi_boot_bus(void)
> +{
> +     u32 wkup_devstat = readl(CTRLMMR_WKUP_DEVSTAT);
> +     u32 main_devstat = readl(CTRLMMR_MAIN_DEVSTAT);
> +     u32 bootmode = ((wkup_devstat & WKUP_DEVSTAT_PRIMARY_BOOTMODE_MASK) >>
> +                     WKUP_DEVSTAT_PRIMARY_BOOTMODE_SHIFT) |
> +                     ((main_devstat & MAIN_DEVSTAT_BOOT_MODE_B_MASK) << 
> BOOT_MODE_B_SHIFT);
> +
> +     return (bootmode == BOOT_DEVICE_QSPI) ? 1 : 0;
> +}
> +
> +/* both OSPI and QSPI flash are in CS0 */
> +u32 spl_spi_boot_cs(void)
> +{
> +     return 0;
> +}
> +

I don't think we need to hard-code the chip select here. Let that come 
from the config. Other than this,

Reviewed-by: Pratyush Yadav <p.ya...@ti.com>

>  u32 spl_boot_device(void)
>  {
>       u32 wkup_devstat = readl(CTRLMMR_WKUP_DEVSTAT);
> diff --git a/arch/arm/mach-k3/sysfw-loader.c b/arch/arm/mach-k3/sysfw-loader.c
> index 5e48c36ccd..8ff36759c1 100644
> --- a/arch/arm/mach-k3/sysfw-loader.c
> +++ b/arch/arm/mach-k3/sysfw-loader.c
> @@ -324,9 +324,9 @@ static void *k3_sysfw_get_spi_addr(void)
>       struct udevice *dev;
>       fdt_addr_t addr;
>       int ret;
> +     unsigned int sf_bus = spl_spi_boot_bus();
>  
> -     ret = uclass_find_device_by_seq(UCLASS_SPI, CONFIG_SF_DEFAULT_BUS,
> -                                     &dev);
> +     ret = uclass_find_device_by_seq(UCLASS_SPI, sf_bus, &dev);
>       if (ret)
>               return NULL;
>  
> -- 
> 2.17.1
> 

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

Reply via email to