From a6ee3fe19d8bdf369edbd9301eb2be283458b920 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Wed, 15 Jan 2020 16:18:03 +0100 Subject: [PATCH 1/8] arm: dts: exynos: Extend board description u-boot uses the same DTS for the all Odroid XU3-based boards, so list them in the model description to let user know that those boards are supported. Signed-off-by: Marek Szyprowski Reviewed-by: Lukasz Majewski Signed-off-by: Minkyu Kang --- arch/arm/dts/exynos5422-odroidxu3.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/dts/exynos5422-odroidxu3.dts b/arch/arm/dts/exynos5422-odroidxu3.dts index 6df6be91814..256df6d6c27 100644 --- a/arch/arm/dts/exynos5422-odroidxu3.dts +++ b/arch/arm/dts/exynos5422-odroidxu3.dts @@ -10,7 +10,7 @@ #include "exynos54xx.dtsi" / { - model = "Odroid XU3 based on EXYNOS5422"; + model = "Odroid XU3/XU4/HC1/HC2 based on Exynos5422"; compatible = "samsung,odroidxu3", "samsung,exynos5"; aliases { From fa06669d0181b2c92ba86fb6c40a4cb0c196b13c Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Tue, 14 Jan 2020 15:04:20 +0100 Subject: [PATCH 2/8] arm: exynos: Use proper ADC device name Since commit 4213609cc7 ("drivers: core: use strcmp when find device by name") one has to provide full name to get requested object. Fix the code used to detect Odroid board revision to use proper ADC device name then. Signed-off-by: Marek Szyprowski Reviewed-by: Anand Moon Signed-off-by: Minkyu Kang --- board/samsung/common/exynos5-dt-types.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/board/samsung/common/exynos5-dt-types.c b/board/samsung/common/exynos5-dt-types.c index 516c32923e4..d51cc4eedcb 100644 --- a/board/samsung/common/exynos5-dt-types.c +++ b/board/samsung/common/exynos5-dt-types.c @@ -67,7 +67,7 @@ static int odroid_get_adc_val(unsigned int *adcval) unsigned int adcval_prev = 0; int ret, retries = 20; - ret = adc_channel_single_shot("adc", CONFIG_ODROID_REV_AIN, + ret = adc_channel_single_shot("adc@12D10000", CONFIG_ODROID_REV_AIN, &adcval_prev); if (ret) return ret; @@ -75,8 +75,8 @@ static int odroid_get_adc_val(unsigned int *adcval) while (retries--) { mdelay(5); - ret = adc_channel_single_shot("adc", CONFIG_ODROID_REV_AIN, - adcval); + ret = adc_channel_single_shot("adc@12D10000", + CONFIG_ODROID_REV_AIN, adcval); if (ret) return ret; From 4b8984e969fa8e68f2fdd79c70cd4be8f1f1378c Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Thu, 16 Jan 2020 14:46:04 +0100 Subject: [PATCH 3/8] arm: exynos: Use proper PMIC device names Since commit 4213609cc7 ("drivers: core: use strcmp when find device by name") one has to provide full name to get requested object. Fix the code used to detect enable power regulators on the supported Exynos boards to use proper PMIC device device name then. Signed-off-by: Marek Szyprowski Reviewed-by: Anand Moon Reviewed-by: Lukasz Majewski Signed-off-by: Minkyu Kang --- board/samsung/common/exynos5-dt-types.c | 2 +- board/samsung/common/exynos5-dt.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/board/samsung/common/exynos5-dt-types.c b/board/samsung/common/exynos5-dt-types.c index d51cc4eedcb..1413dc89788 100644 --- a/board/samsung/common/exynos5-dt-types.c +++ b/board/samsung/common/exynos5-dt-types.c @@ -129,7 +129,7 @@ static const char *odroid_get_type_str(void) if (gd->board_type != EXYNOS5_BOARD_ODROID_XU3_REV02) goto exit; - ret = pmic_get("s2mps11", &dev); + ret = pmic_get("s2mps11_pmic@66", &dev); if (ret) goto exit; diff --git a/board/samsung/common/exynos5-dt.c b/board/samsung/common/exynos5-dt.c index 387d1b91809..eef46b0dc44 100644 --- a/board/samsung/common/exynos5-dt.c +++ b/board/samsung/common/exynos5-dt.c @@ -65,9 +65,9 @@ int exynos_power_init(void) int ret; #ifdef CONFIG_PMIC_S2MPS11 - ret = pmic_get("s2mps11_pmic", &dev); + ret = pmic_get("s2mps11_pmic@66", &dev); #else - ret = pmic_get("max77686", &dev); + ret = pmic_get("max77686_pmic@09", &dev); if (!ret) { /* TODO(sjg@chromium.org): Move into the clock/pmic API */ ret = pmic_clrsetbits(dev, MAX77686_REG_PMIC_32KHZ, 0, @@ -79,7 +79,7 @@ int exynos_power_init(void) if (ret) return ret; } else { - ret = pmic_get("s5m8767-pmic", &dev); + ret = pmic_get("s5m8767_pmic@66", &dev); /* TODO(sjg@chromium.org): Use driver model to access clock */ #ifdef CONFIG_PMIC_S5M8767 if (!ret) From e27108c433a249ba8ebc59f7a3113b9b666f5d67 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Thu, 16 Jan 2020 16:25:33 +0100 Subject: [PATCH 4/8] mmc: s5p_sdhci: Read generic MMC properties from DT Read generic MMC properties from device-tree. This allows to specify for example cd-inverted property and let MMC core to properly handle such case. Signed-off-by: Marek Szyprowski Reviewed-by: Anand Moon Signed-off-by: Minkyu Kang --- drivers/mmc/s5p_sdhci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c index 53efa968cf5..b5fe828dd60 100644 --- a/drivers/mmc/s5p_sdhci.c +++ b/drivers/mmc/s5p_sdhci.c @@ -204,8 +204,13 @@ static int s5p_sdhci_probe(struct udevice *dev) if (ret) return ret; + ret = mmc_of_parse(dev, &plat->cfg); + if (ret) + return ret; + host->mmc = &plat->mmc; host->mmc->dev = dev; + ret = sdhci_setup_cfg(&plat->cfg, host, 0, 400000); if (ret) return ret; From 1bca28a5d98a81a9d189a46347f8a92619624f94 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Thu, 16 Jan 2020 16:25:34 +0100 Subject: [PATCH 5/8] arm: dts: exynos: Fix card-detect polarity for SD card on Odroid U3/X2 Card detect line for SD-card on Odroid U3/X2 boards are active low, so add cd-inverted property to indicate this, as u-boot's GPIO driver doesn't support specifying line polarity. This restores S5P_SDHCI driver operation on Odroid U3/X2 boards. Signed-off-by: Marek Szyprowski Reviewed-by: Anand Moon Signed-off-by: Minkyu Kang --- arch/arm/dts/exynos4412-odroid.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/dts/exynos4412-odroid.dts b/arch/arm/dts/exynos4412-odroid.dts index cc8e0dd0418..e6c72227559 100644 --- a/arch/arm/dts/exynos4412-odroid.dts +++ b/arch/arm/dts/exynos4412-odroid.dts @@ -236,6 +236,7 @@ &sdhci2 { samsung,bus-width = <4>; samsung,timing = <1 2 3>; + cd-inverted; cd-gpios = <&gpk2 2 0>; status = "okay"; }; From da63b5da61318a2ea8a84a41f2e49eb24f8a3759 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Thu, 16 Jan 2020 16:25:35 +0100 Subject: [PATCH 6/8] arm: dts: exynos: Use common alias for Odroid U3/X2 MMC2 (SD-card) Use MMC0 for eMMC and MMC2 for SD-card as other Exynos-based boards do. This allows to use common code to get MMC device id based on the XOM[7:5] pins. Signed-off-by: Marek Szyprowski Reviewed-by: Anand Moon Signed-off-by: Minkyu Kang --- arch/arm/dts/exynos4412-odroid.dts | 2 +- include/configs/odroid.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/exynos4412-odroid.dts b/arch/arm/dts/exynos4412-odroid.dts index e6c72227559..ce08e8dc1eb 100644 --- a/arch/arm/dts/exynos4412-odroid.dts +++ b/arch/arm/dts/exynos4412-odroid.dts @@ -17,7 +17,7 @@ serial0 = "/serial@13800000"; console = "/serial@13810000"; mmc0 = &mshc_0; - mmc1 = &sdhci2; + mmc2 = &sdhci2; }; serial@13810000 { diff --git a/include/configs/odroid.h b/include/configs/odroid.h index 77fca32fcaf..7989fb29d15 100644 --- a/include/configs/odroid.h +++ b/include/configs/odroid.h @@ -80,7 +80,7 @@ "tzsw raw 0x83f 0x138\0" #define BOOT_TARGET_DEVICES(func) \ - func(MMC, mmc, 1) \ + func(MMC, mmc, 2) \ func(MMC, mmc, 0) #include From 86c88711082b9fb4da5f7eb0b80d5604c283f0c5 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Fri, 17 Jan 2020 14:02:44 +0100 Subject: [PATCH 7/8] arm: exynos: Read default MMC device from XOM[7:5] pins 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 Signed-off-by: Minkyu Kang --- arch/arm/mach-exynos/include/mach/cpu.h | 1 + board/samsung/common/board.c | 28 +++++++++++++++++++++++++ configs/odroid-xu3_defconfig | 1 + configs/odroid_defconfig | 1 + 4 files changed, 31 insertions(+) diff --git a/arch/arm/mach-exynos/include/mach/cpu.h b/arch/arm/mach-exynos/include/mach/cpu.h index 766edeeb298..fb5fdaf3ba8 100644 --- a/arch/arm/mach-exynos/include/mach/cpu.h +++ b/arch/arm/mach-exynos/include/mach/cpu.h @@ -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 diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c index 5d4646d14c8..390060e51f7 100644 --- a/board/samsung/common/board.c +++ b/board/samsung/common/board.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include @@ -43,6 +45,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) @@ -281,6 +297,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); @@ -293,6 +311,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 @@ -360,3 +383,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(); +} diff --git a/configs/odroid-xu3_defconfig b/configs/odroid-xu3_defconfig index 20038d41976..2e982e1b533 100644 --- a/configs/odroid-xu3_defconfig +++ b/configs/odroid-xu3_defconfig @@ -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 diff --git a/configs/odroid_defconfig b/configs/odroid_defconfig index be914e4cafe..e4392e477ed 100644 --- a/configs/odroid_defconfig +++ b/configs/odroid_defconfig @@ -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 From 51521e43603d37e6be2ffd1ad2607361650500e9 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Fri, 17 Jan 2020 14:12:58 +0100 Subject: [PATCH 8/8] arm: exynos: odroid: Change autoboot script to use ${mmcbootdev} This fixes the default boot command for the SD-card boot case. Signed-off-by: Marek Szyprowski Signed-off-by: Minkyu Kang --- include/configs/odroid.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/configs/odroid.h b/include/configs/odroid.h index 7989fb29d15..a7e2a3d9a23 100644 --- a/include/configs/odroid.h +++ b/include/configs/odroid.h @@ -146,13 +146,13 @@ "run kernel_args;" \ "bootz ${kernel_addr_r} ${initrd_addr} ${fdt_addr};\0" \ "autoboot=" \ - "if test -e mmc 0 boot.scr; then; " \ + "if test -e mmc ${mmcbootdev} boot.scr; then; " \ "run boot_script; " \ - "elif test -e mmc 0 Image.itb; then; " \ + "elif test -e mmc ${mmcbootdev} Image.itb; then; " \ "run boot_fit;" \ - "elif test -e mmc 0 zImage; then; " \ + "elif test -e mmc ${mmcbootdev} zImage; then; " \ "run boot_zimg;" \ - "elif test -e mmc 0 uImage; then; " \ + "elif test -e mmc ${mmcbootdev} uImage; then; " \ "run boot_uimg;" \ "fi;\0" \ "console=" CONFIG_DEFAULT_CONSOLE \