[PATCH 5/5] arm: exynos: Read default MMC device from XOM[7:5] pins
authorMarek Szyprowski <m.szyprowski@samsung.com>
Fri, 17 Jan 2020 13:02:44 +0000 (14:02 +0100)
committerVagrant Cascadian <vagrant@debian.org>
Thu, 13 Feb 2020 06:29:38 +0000 (06:29 +0000)
XOM pins provide information for iROM bootloader about the boot device.
Those pins are mapped to lower bits of OP_MODE register (0x10000008),
which is common for all Exynos SoC variants. Set the default MMC device id
to reflect the boot device selected by XOM[7:5] pins (2 for the SD or 0 for
the eMMC).

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
Gbp-Pq: Topic exynos
Gbp-Pq: Name 0007-arm-exynos-Read-default-MMC-device-from-XOM-7-5-pins.patch

arch/arm/mach-exynos/include/mach/cpu.h
board/samsung/common/board.c
configs/odroid-xu3_defconfig
configs/odroid_defconfig

index 766edeeb298b3a5bf01fa2225739899da0a94bef..fb5fdaf3ba8d721a56b27ed6c7e65772688a6ed9 100644 (file)
@@ -17,6 +17,7 @@
 
 #define EXYNOS4_GPIO_PART3_BASE                0x03860000
 #define EXYNOS4_PRO_ID                 0x10000000
+#define EXYNOS4_OP_MODE                        0x10000008
 #define EXYNOS4_SYSREG_BASE            0x10010000
 #define EXYNOS4_POWER_BASE             0x10020000
 #define EXYNOS4_SWRESET                        0x10020400
index ee2fc7971eb079c8097f453982577d66e8b70b79..cb94ced54ed9620600d5938ca82cc9d5e181c6c5 100644 (file)
@@ -24,6 +24,8 @@
 #include <asm/arch/sromc.h>
 #include <lcd.h>
 #include <i2c.h>
+#include <mmc.h>
+#include <stdio_dev.h>
 #include <usb.h>
 #include <dwc3-uboot.h>
 #include <samsung/misc.h>
@@ -42,6 +44,20 @@ __weak int exynos_power_init(void)
        return 0;
 }
 
+/**
+ * get_boot_mmc_dev() - read boot MMC device id from XOM[7:5] pins.
+ */
+static int get_boot_mmc_dev(void)
+{
+       u32 mode = readl(EXYNOS4_OP_MODE) & 0x1C;
+
+       if (mode == 0x04)
+               return 2; /* MMC2: SD */
+
+       /* MMC0: eMMC or unknown */
+       return 0;
+}
+
 #if defined CONFIG_EXYNOS_TMU
 /* Boot Time Thermal Analysis for SoC temperature threshold breach */
 static void boot_temp_check(void)
@@ -280,6 +296,8 @@ int board_late_init(void)
 {
        struct udevice *dev;
        int ret;
+       int mmcbootdev = get_boot_mmc_dev();
+       char mmcbootdev_str[16];
 
        stdio_print_current_devices();
        ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
@@ -292,6 +310,11 @@ int board_late_init(void)
                panic("Cannot init cros-ec device");
                return -1;
        }
+
+       printf("Boot device: MMC(%u)\n", mmcbootdev);
+       sprintf(mmcbootdev_str, "%u", mmcbootdev);
+       env_set("mmcbootdev", mmcbootdev_str);
+
        return 0;
 }
 #endif
@@ -359,3 +382,8 @@ int board_usb_cleanup(int index, enum usb_init_type init)
 #endif
        return 0;
 }
+
+int mmc_get_env_dev(void)
+{
+       return get_boot_mmc_dev();
+}
index 20038d419767920b210ddecc3f60c7fecec8c5e4..2e982e1b533adc061d9847d4e51f54d67d6fccfb 100644 (file)
@@ -14,6 +14,7 @@ CONFIG_FIT_BEST_MATCH=y
 CONFIG_SILENT_CONSOLE=y
 CONFIG_CONSOLE_MUX=y
 CONFIG_MISC_INIT_R=y
+CONFIG_BOARD_LATE_INIT=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_BOARD_TYPES=y
index be914e4cafec0c792d587e5d743eab5a7ee8947c..e4392e477ed0ce32a3d91bba9f925440268fc040 100644 (file)
@@ -17,6 +17,7 @@ CONFIG_BOOTARGS="Please use defined boot"
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_MISC_INIT_R=y
+CONFIG_BOARD_LATE_INIT=y
 CONFIG_BOARD_TYPES=y
 CONFIG_SYS_PROMPT="Odroid # "
 # CONFIG_CMD_XIMG is not set