From: Marek Szyprowski Date: Fri, 29 Jan 2021 12:03:03 +0000 (+0100) Subject: rpi: use board_early_init_r to init PCI/USB and detect boot device X-Git-Tag: accepted/tizen/unified/20221108.163909~88 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=38b68596a099135a3e7b73499247b21d21bb1c3e;p=platform%2Fkernel%2Fu-boot.git rpi: use board_early_init_r to init PCI/USB and detect boot device Move initialization of the PCI and the USB subsystems from the 'preboot' command to the board's early_init_r() function and then try to detect a boot device by accessing the MMC0 device. If it works, then set boot device interface to 'mmc', if not, use 'usb'. This allows the environment variales to be loaded from the proper storage interface. Signed-off-by: Marek Szyprowski Change-Id: Idf06ba827167479510206587308875c8eedce892 --- diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index f4668abb5a..8c843c60e2 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -23,6 +23,7 @@ #ifdef CONFIG_ARM64 #include #endif +#include #include #include @@ -466,6 +467,30 @@ static void set_serial_number(void) env_set("serial#", serial_string); } +#if defined(CONFIG_PCI) && defined(CONFIG_BOARD_EARLY_INIT_R) +static char *boot_interface; +int board_early_init_r(void) +{ + /* + * Currently there is not way to detect which device (SD card or + * USB Mass Storage) has been used by VideoCore to load the uboot, + * so just try MMC0 first, if not then use USB. + */ + mmc_init_device(0); + boot_interface = (blk_get_dev("mmc", 0)) ? "mmc" : "usb"; + + pci_init(); + usb_init(); + + return 0; +} + +char *env_fat_get_interface(void) +{ + return boot_interface; +} +#endif + int misc_init_r(void) { set_fdt_addr();