Skip to contentSkip to conversation

arm: exynos: Read default MMC device from XOM[7:5] pins

PATCH Superseded Marek Szyprowski 2 participants 6 messages Jan 17, 2020 – Jan 28, 2020 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20200117130253eucas1p29b33f449b7be430ef0adcfdd47f2b130@eucas1p2.samsung.com

#1 lore raw

PATCH v2 1/1 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).

---
v2:
- store mmc boot device to ${mmcbootdev} env
- print information about boot mmc device

---
 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(+)
arch/arm/mach-exynos/include/mach/cpu.h +1 -0
index 766edeeb29..fb5fdaf3ba 100644
@@ -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
board/samsung/common/board.c +28 -0
index ee2fc7971e..cb94ced54e 100644
@@ -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();
+}
configs/odroid-xu3_defconfig +1 -0
index 20038d4197..2e982e1b53 100644
@@ -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
configs/odroid_defconfig +1 -0
index be914e4caf..e4392e477e 100644
@@ -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
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 1/1 arm: exynos: Read default MMC device from XOM[7:5] pins

Hi,

Quoted 99 lines · Marek Szyprowski

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).

---
v2:
- store mmc boot device to ${mmcbootdev} env
- print information about boot mmc device

---
 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(+)
arch/arm/mach-exynos/include/mach/cpu.h +1 -0
index 766edeeb29..fb5fdaf3ba 100644
@@ -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
board/samsung/common/board.c +28 -0
index ee2fc7971e..cb94ced54e 100644
@@ -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();
+}
configs/odroid-xu3_defconfig +0 -0
index 20038d4197..2e982e1b53 100644

configs/odroid-xu3_defconfig CONFIG_FIT_BEST_MATCH=y · line 17

Quoted 4 lines
configs/odroid-xu3_defconfig +1 -0
@@ -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

Is it a related change?

Quoted 9 lines
configs/odroid-xu3_defconfig +0 -0
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_BOARD_TYPES=y
configs/odroid_defconfig +0 -0
index be914e4caf..e4392e477e 100644

configs/odroid_defconfig CONFIG_BOOTARGS="Please use defined boot" · line 23

Quoted 7 lines
configs/odroid_defconfig +1 -0
@@ -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

Thanks,
Minkyu Kang.

#3 lore raw

PATCH v2 1/1 arm: exynos: Read default MMC device from XOM[7:5] pins

Hi Minkyu,

Quoted 97 lines · Minkyu Kang
Quoted 96 lines · Marek Szyprowski

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).

---
v2:
- store mmc boot device to ${mmcbootdev} env
- print information about boot mmc device

---
  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(+)
arch/arm/mach-exynos/include/mach/cpu.h +1 -0
index 766edeeb29..fb5fdaf3ba 100644
@@ -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
board/samsung/common/board.c +28 -0
index ee2fc7971e..cb94ced54e 100644
@@ -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();
+}
configs/odroid-xu3_defconfig +0 -0
index 20038d4197..2e982e1b53 100644
Quoted 8 lines

configs/odroid-xu3_defconfig CONFIG_FIT_BEST_MATCH=y · line 17

Quoted 7 lines
configs/odroid-xu3_defconfig +1 -0
@@ -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

Is it a related change?

Yes, it is needed to enable the code added to board_late_init() function.

Quoted 7 lines
Quoted 7 lines
configs/odroid-xu3_defconfig +0 -0
  # CONFIG_DISPLAY_BOARDINFO is not set
  CONFIG_DISPLAY_BOARDINFO_LATE=y
  CONFIG_BOARD_TYPES=y
configs/odroid_defconfig +0 -0
index be914e4caf..e4392e477e 100644
Quoted 8 lines

configs/odroid_defconfig CONFIG_BOOTARGS="Please use defined boot" · line 23

Quoted 8 lines
configs/odroid_defconfig +1 -0
@@ -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

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
#4 lore raw

PATCH v2 1/1 arm: exynos: Read default MMC device from XOM[7:5] pins

Hi!

Quoted 109 lines · Marek Szyprowski

Hi Minkyu,

Quoted 97 lines · Minkyu Kang
Quoted 96 lines · Marek Szyprowski

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).

---
v2:
- store mmc boot device to ${mmcbootdev} env
- print information about boot mmc device

---
  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(+)
arch/arm/mach-exynos/include/mach/cpu.h +1 -0
index 766edeeb29..fb5fdaf3ba 100644
@@ -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
board/samsung/common/board.c +28 -0
index ee2fc7971e..cb94ced54e 100644
@@ -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();
+}
configs/odroid-xu3_defconfig +0 -0
index 20038d4197..2e982e1b53 100644
Quoted 8 lines

configs/odroid-xu3_defconfig CONFIG_FIT_BEST_MATCH=y · line 17

Quoted 7 lines
configs/odroid-xu3_defconfig +1 -0
@@ -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

Is it a related change?

Quoted 1 line

Yes, it is needed to enable the code added to board_late_init() function.

I mean, is your changes should located to board_late_init?

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
configs/odroid-xu3_defconfig +0 -0
  # CONFIG_DISPLAY_BOARDINFO is not set
  CONFIG_DISPLAY_BOARDINFO_LATE=y
  CONFIG_BOARD_TYPES=y
configs/odroid_defconfig +0 -0
index be914e4caf..e4392e477e 100644
@@ -17,6 +17,7 @@ CONFIG_BOOTARGS="Please use defined boot"
  CONFIG_SYS_CONSOLE_IS_IN_ENV=y
Quoted 9 lines
Quoted 6 lines

configs/odroid_defconfig CONFIG_BOOTARGS="Please use defined boot" · line 23

Quoted 6 lines
configs/odroid_defconfig +1 -0
  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

Best regards

Thanks,
Minkyu Kang.

#5 lore raw

PATCH v2 1/1 arm: exynos: Read default MMC device from XOM[7:5] pins

Hi

Quoted 107 lines · Minkyu Kang
Quoted 106 lines · Marek Szyprowski
Quoted 105 lines · Minkyu Kang
Quoted 99 lines · Marek Szyprowski

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).

---
v2:
- store mmc boot device to ${mmcbootdev} env
- print information about boot mmc device

---
   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(+)
arch/arm/mach-exynos/include/mach/cpu.h +1 -0
index 766edeeb29..fb5fdaf3ba 100644
@@ -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
board/samsung/common/board.c +28 -0
index ee2fc7971e..cb94ced54e 100644
@@ -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();
+}
configs/odroid-xu3_defconfig +0 -0
index 20038d4197..2e982e1b53 100644

configs/odroid-xu3_defconfig CONFIG_FIT_BEST_MATCH=y · line 17

Quoted 4 lines
configs/odroid-xu3_defconfig +1 -0
@@ -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

Is it a related change?

Quoted 2 lines
Quoted 1 line

Yes, it is needed to enable the code added to board_late_init() function.

I mean, is your changes should located to board_late_init?

Setting mmcbootdev env is being done in board_late_init() (see the diff a few lines above), so to make it working, one has to enable CONFIG_BOARD_LATE_INIT.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
configs/odroid-xu3_defconfig +0 -0
   # CONFIG_DISPLAY_BOARDINFO is not set
   CONFIG_DISPLAY_BOARDINFO_LATE=y
   CONFIG_BOARD_TYPES=y
configs/odroid_defconfig +0 -0
index be914e4caf..e4392e477e 100644
@@ -17,6 +17,7 @@ CONFIG_BOOTARGS="Please use defined boot"
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

configs/odroid_defconfig CONFIG_BOOTARGS="Please use defined boot" · line 23

Quoted 8 lines
configs/odroid_defconfig +1 -0
   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

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
#6 lore raw

PATCH v2 1/1 arm: exynos: Read default MMC device from XOM[7:5] pins

Quoted 126 lines · Marek Szyprowski

Hi

Quoted 107 lines · Minkyu Kang
Quoted 106 lines · Marek Szyprowski
Quoted 105 lines · Minkyu Kang
Quoted 99 lines · Marek Szyprowski

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).

---
v2:
- store mmc boot device to ${mmcbootdev} env
- print information about boot mmc device

---
   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(+)
arch/arm/mach-exynos/include/mach/cpu.h +1 -0
index 766edeeb29..fb5fdaf3ba 100644
@@ -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
board/samsung/common/board.c +28 -0
index ee2fc7971e..cb94ced54e 100644
@@ -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();
+}
configs/odroid-xu3_defconfig +0 -0
index 20038d4197..2e982e1b53 100644

configs/odroid-xu3_defconfig CONFIG_FIT_BEST_MATCH=y · line 17

Quoted 4 lines
configs/odroid-xu3_defconfig +1 -0
@@ -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

Is it a related change?

Quoted 2 lines
Quoted 1 line

Yes, it is needed to enable the code added to board_late_init() function.

I mean, is your changes should located to board_late_init?

Setting mmcbootdev env is being done in board_late_init() (see the diff a few lines above), so to make it working, one has to enable CONFIG_BOARD_LATE_INIT.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
configs/odroid-xu3_defconfig +0 -0
   # CONFIG_DISPLAY_BOARDINFO is not set
   CONFIG_DISPLAY_BOARDINFO_LATE=y
   CONFIG_BOARD_TYPES=y
configs/odroid_defconfig +0 -0
index be914e4caf..e4392e477e 100644
@@ -17,6 +17,7 @@ CONFIG_BOOTARGS="Please use defined boot"
   CONFIG_SYS_CONSOLE_IS_IN_ENV=y
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

configs/odroid_defconfig CONFIG_BOOTARGS="Please use defined boot" · line 23

Quoted 7 lines
configs/odroid_defconfig +1 -0
   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

Best regards

applied to u-boot-samsung.

Thanks,
Minkyu Kang.