mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-25 06:00:43 +00:00
imx: imx6ul: kontron-sl-mx6ul: Select correct boot and env device
Instead of checking both, SPI NOR and MMC for loading U-Boot proper and the environment, implement a way to detect the actual boot device even if the BootROM doesn't report it and we can't rely solely on the fuse settings, as by default we use MMC as primary boot device and boot from SPI NOR via the secondary fallback device (EEPROM Recovery Mode). Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
This commit is contained in:
parent
234b3be98e
commit
93935acc6f
5 changed files with 66 additions and 9 deletions
|
@ -6,3 +6,5 @@ obj-y := spl.o
|
|||
else
|
||||
obj-y := sl-mx6ul.o
|
||||
endif
|
||||
|
||||
obj-y += sl-mx6ul-common.o
|
||||
|
|
24
board/kontron/sl-mx6ul/sl-mx6ul-common.c
Normal file
24
board/kontron/sl-mx6ul/sl-mx6ul-common.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright (C) 2022 Kontron Electronics GmbH
|
||||
*/
|
||||
|
||||
#include <asm/types.h>
|
||||
#include <asm/arch/sys_proto.h>
|
||||
|
||||
#include <sl-mx6ul-common.h>
|
||||
|
||||
bool sl_mx6ul_is_spi_nor_boot(void)
|
||||
{
|
||||
u32 bmode = imx6_src_get_boot_mode();
|
||||
|
||||
/*
|
||||
* Check if "EEPROM Recovery" enabled and ECSPI2_CONREG not 0x0.
|
||||
* If this is the case and U-Boot didn't initialize the SPI bus
|
||||
* yet, we can safely assume that we are booting from SPI NOR.
|
||||
*/
|
||||
if ((bmode & 0x40000000) && readl(0x0200c008))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
11
board/kontron/sl-mx6ul/sl-mx6ul-common.h
Normal file
11
board/kontron/sl-mx6ul/sl-mx6ul-common.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2022 Kontron Electronics GmbH
|
||||
*/
|
||||
|
||||
#ifndef __SL_MX6UL_COMMON_H
|
||||
#define __SL_MX6UL_COMMON_H
|
||||
|
||||
bool sl_mx6ul_is_spi_nor_boot(void);
|
||||
|
||||
#endif // __SL_MX6UL_COMMON_H
|
|
@ -6,8 +6,10 @@
|
|||
#include <asm/arch/clock.h>
|
||||
#include <asm/arch/sys_proto.h>
|
||||
#include <asm/global_data.h>
|
||||
#include <env_internal.h>
|
||||
#include <fdt_support.h>
|
||||
#include <phy.h>
|
||||
#include <sl-mx6ul-common.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
|
@ -83,3 +85,16 @@ int board_init(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum env_location env_get_location(enum env_operation op, int prio)
|
||||
{
|
||||
if (prio)
|
||||
return ENVL_UNKNOWN;
|
||||
|
||||
if (sl_mx6ul_is_spi_nor_boot() && CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
|
||||
return ENVL_SPI_FLASH;
|
||||
else if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC))
|
||||
return ENVL_MMC;
|
||||
|
||||
return ENVL_NOWHERE;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <linux/sizes.h>
|
||||
#include <linux/errno.h>
|
||||
#include <mmc.h>
|
||||
#include <sl-mx6ul-common.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
|
@ -339,26 +340,30 @@ void board_boot_order(u32 *spl_boot_list)
|
|||
|
||||
/*
|
||||
* The default boot fuse settings use the SD card (MMC1) as primary
|
||||
* boot device, but allow SPI NOR as a fallback boot device.
|
||||
* We can't detect the fallback case and spl_boot_device() will return
|
||||
* BOOT_DEVICE_MMC1 despite the actual boot device being SPI NOR.
|
||||
* Therefore we try to load U-Boot proper vom SPI NOR after loading
|
||||
* from MMC has failed.
|
||||
* boot device, but allow SPI NOR as a fallback boot device. There
|
||||
* is no proper way to detect if the fallback was used. Therefore
|
||||
* we read the ECSPI2_CONREG register and see if it differs from the
|
||||
* reset value 0x0. If that's the case we can assume that the BootROM
|
||||
* has successfully probed the SPI NOR.
|
||||
*/
|
||||
spl_boot_list[0] = bootdev;
|
||||
|
||||
switch (bootdev) {
|
||||
case BOOT_DEVICE_MMC1:
|
||||
case BOOT_DEVICE_MMC2:
|
||||
spl_boot_list[1] = BOOT_DEVICE_SPI;
|
||||
if (sl_mx6ul_is_spi_nor_boot()) {
|
||||
spl_boot_list[0] = BOOT_DEVICE_SPI;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
spl_boot_list[0] = bootdev;
|
||||
}
|
||||
|
||||
int board_early_init_f(void)
|
||||
{
|
||||
setup_iomux_uart();
|
||||
setup_spi();
|
||||
if (sl_mx6ul_is_spi_nor_boot())
|
||||
setup_spi();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue