Skip to contentSkip to conversation

ARM: Odroid XU3: Enable DM_MMC support which is necessary for CONFIG_BLK

PATCH New Lukasz Majewski 3 participants 11 messages Aug 1, 2018 – Aug 7, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover ARM: Odroid XU3: Enable DM_MMC support which is necessary for CONFIG_BLK

This patch series provides following improvements to Odroid XU3:
- Fix sdr_timing problem with DW_MMC running with DM
- Clean up the defconfig file
- Fix potential memory leak when running under DM (DW_MMC)
- Rebase on newest ML
- Remove the patch, which add support for booting only from SD card
Travis-CI: https://travis-ci.org/lmajewski/u-boot-dfu/builds/410698980
SHA1: ae5afc37204e72ebe6e6844f70afff99db3bd910

Changes in v2:
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line

Lukasz Majewski (8):
ARM: dw_mmc: Exclude dwmci Exynos priv_data allocation from
exynos_dwmci_get_config()
ARM: Odroid XU3: config: Disable SDHCI support in the Odroid XU3
ARM: Odroid XU3: Enable driver model support for MMC (DM_MMC)
ARM: Odroid XU3: Fix autoboot.cmd to use ${mmcbootdev} instead of
hardcoded 0
ARM: Odroid XU3: Adjust BOOT_TARGET_DEVICES to allow booting from SD

    card (mmc2)

ARM: Odroid XU3: MAINTAINERS: Add a co-maintainer for OdroidXU3
ARM: Odroid XU3: Fix the dwmci_exynos *priv data assignment for DM_MMC
(sdr_timing)
ARM: Odroid XU3: Modify exynos dw_mmc driver to support Odroid XU3 in
DM MMC

 board/samsung/common/bootscripts/autoboot.cmd |  6 ++---
 board/samsung/smdk5420/MAINTAINERS            |  1 +
 configs/odroid-xu3_defconfig                  |  3 +--
 drivers/mmc/exynos_dw_mmc.c                   | 37 +++++++++++++++------------
 include/configs/exynos5-common.h              |  1 +
 5 files changed, 27 insertions(+), 21 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH v2 1/8 ARM: dw_mmc: Exclude dwmci Exynos priv_data allocation from exynos_dwmci_get_config()

This commit prevents memory leak when this function is used with DM_MMC as the struct dwmci_exynos_priv_data is already allocated by DM.

It is necessary for NON DM aware devices to allocate this struct first.

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 drivers/mmc/exynos_dw_mmc.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/mmc/exynos_dw_mmc.c +15 -15
index 865fdf4dbba0..49c4f7634830 100644
@@ -146,17 +146,11 @@ static int do_dwmci_init(struct dwmci_host *host)
 }
 
 static int exynos_dwmci_get_config(const void *blob, int node,
-					struct dwmci_host *host)
+				   struct dwmci_host *host,
+				   struct dwmci_exynos_priv_data *priv)
 {
 	int err = 0;
 	u32 base, timing[3];
-	struct dwmci_exynos_priv_data *priv;
-
-	priv = malloc(sizeof(struct dwmci_exynos_priv_data));
-	if (!priv) {
-		pr_err("dwmci_exynos_priv_data malloc fail!\n");
-		return -ENOMEM;
-	}
 
 	/* Extract device id for each mmc channel */
 	host->dev_id = pinmux_decode_periph_id(blob, node);
@@ -167,7 +161,6 @@ static int exynos_dwmci_get_config(const void *blob, int node,
 
 	if (host->dev_index > 4) {
 		printf("DWMMC%d: Can't get the dev index\n", host->dev_index);
-		free(priv);
 		return -EINVAL;
 	}
 
@@ -178,7 +171,6 @@ static int exynos_dwmci_get_config(const void *blob, int node,
 	base = fdtdec_get_addr(blob, node, "reg");
 	if (!base) {
 		printf("DWMMC%d: Can't get base address\n", host->dev_index);
-		free(priv);
 		return -EINVAL;
 	}
 	host->ioaddr = (void *)base;
@@ -188,7 +180,6 @@ static int exynos_dwmci_get_config(const void *blob, int node,
 	if (err) {
 		printf("DWMMC%d: Can't get sdr-timings for devider\n",
 				host->dev_index);
-		free(priv);
 		return -EINVAL;
 	}
 
@@ -208,14 +199,13 @@ static int exynos_dwmci_get_config(const void *blob, int node,
 	host->bus_hz = fdtdec_get_int(blob, node, "bus_hz", 0);
 	host->div = fdtdec_get_int(blob, node, "div", 0);
 
-	host->priv = priv;
-
 	return 0;
 }
 
 static int exynos_dwmci_process_node(const void *blob,
 					int node_list[], int count)
 {
+	struct dwmci_exynos_priv_data *priv;
 	struct dwmci_host *host;
 	int i, node, err;
 
@@ -224,11 +214,20 @@ static int exynos_dwmci_process_node(const void *blob,
 		if (node <= 0)
 			continue;
 		host = &dwmci_host[i];
-		err = exynos_dwmci_get_config(blob, node, host);
+
+		priv = malloc(sizeof(struct dwmci_exynos_priv_data));
+		if (!priv) {
+			pr_err("dwmci_exynos_priv_data malloc fail!\n");
+			return -ENOMEM;
+		}
+
+		err = exynos_dwmci_get_config(blob, node, host, priv);
 		if (err) {
 			printf("%s: failed to decode dev %d\n", __func__, i);
+			free(priv);
 			return err;
 		}
+		host->priv = priv;
 
 		do_dwmci_init(host);
 	}
@@ -266,7 +265,8 @@ static int exynos_dwmmc_probe(struct udevice *dev)
 	struct dwmci_host *host = &priv->host;
 	int err;
 
-	err = exynos_dwmci_get_config(gd->fdt_blob, dev_of_offset(dev), host);
+	err = exynos_dwmci_get_config(gd->fdt_blob, dev_of_offset(dev), host,
+				      priv);
 	if (err)
 		return err;
 	err = do_dwmci_init(host);
Signature · 1 line
2.11.0
#2 lore raw

PATCH v2 2/8 ARM: Odroid XU3: config: Disable SDHCI support in the Odroid XU3

In reply to Lukasz Majewski

The Exynos5422 is solely using DW MMC IP block to support eMMC/SD devices, hence the SDHCI code doesn't need to be compiled it.

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 configs/odroid-xu3_defconfig | 2 --
 1 file changed, 2 deletions(-)
configs/odroid-xu3_defconfig +0 -2
index 5943c19cf9b3..6398c2cd0d6a 100644
@@ -30,8 +30,6 @@ CONFIG_ADC=y
 CONFIG_ADC_EXYNOS=y
 CONFIG_DFU_MMC=y
 CONFIG_MMC_DW=y
-CONFIG_MMC_SDHCI=y
-CONFIG_MMC_SDHCI_S5P=y
 CONFIG_NETDEVICES=y
 CONFIG_SMC911X=y
 CONFIG_SMC911X_BASE=0x5000000
Signature · 1 line
2.11.0
#3 lore raw

PATCH v2 3/8 ARM: Odroid XU3: Enable driver model support for MMC (DM_MMC)

In reply to Lukasz Majewski

This commit enables support for DW_MMC running with driver model.

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 configs/odroid-xu3_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/odroid-xu3_defconfig +1 -0
index 6398c2cd0d6a..632542d98420 100644
@@ -29,6 +29,7 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_ADC=y
 CONFIG_ADC_EXYNOS=y
 CONFIG_DFU_MMC=y
+CONFIG_DM_MMC=y
 CONFIG_MMC_DW=y
 CONFIG_NETDEVICES=y
 CONFIG_SMC911X=y
Signature · 1 line
2.11.0
#4 lore raw

PATCH v2 4/8 ARM: Odroid XU3: Fix autoboot.cmd to use ${mmcbootdev} instead of hardcoded 0

In reply to Lukasz Majewski

This commit adjusts the autoboot.cmd file to use ${mmcbootdev} instead of hardcoded value 0.

This is necessary to allow booting this board from the SD card.

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 board/samsung/common/bootscripts/autoboot.cmd | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
board/samsung/common/bootscripts/autoboot.cmd +3 -3
index 1faed8ba0c1a..11c724c4e095 100644
@@ -74,15 +74,15 @@ setenv boot_img "
 
 #### Routine: autoboot - choose proper boot path
 setenv autoboot "
-if test -e mmc 0:${mmcbootpart} Image.itb; then
+if test -e mmc ${mmcbootdev}:${mmcbootpart} Image.itb; then
 	echo Found kernel image: Image.itb;
 	run setboot_fit;
 	run boot_img;
-elif test -e mmc 0:${mmcbootpart} zImage; then
+elif test -e mmc ${mmcbootdev}:${mmcbootpart} zImage; then
 	echo Found kernel image: zImage;
 	run setboot_zimg;
 	run boot_img;
-elif test -e mmc 0:${mmcbootpart} uImage; then
+elif test -e mmc ${mmcbootdev}:${mmcbootpart} uImage; then
 	echo Found kernel image: uImage;
 	run setboot_uimg;
 	run boot_img;
Signature · 1 line
2.11.0
#5 lore raw

PATCH v2 5/8 ARM: Odroid XU3: Adjust BOOT_TARGET_DEVICES to allow booting from SD card (mmc2)

In reply to Lukasz Majewski

This change is necessary to allow booting the Odroid XU3 from SD card after enabling the DM_MMC support.

After this change the SD card mmc IP block is correctly enumerated as mmc2 (and not as mmc1 as in the legacy code).

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 include/configs/exynos5-common.h | 1 +
 1 file changed, 1 insertion(+)
include/configs/exynos5-common.h +1 -0
index a7621fc701b2..cd2a9046afec 100644
@@ -138,6 +138,7 @@
 #define BOOT_TARGET_DEVICES(func) \
 	func(MMC, mmc, 1) \
 	func(MMC, mmc, 0) \
+	func(MMC, mmc, 2) \
 	func(PXE, pxe, na) \
 	func(DHCP, dhcp, na)
 
Signature · 1 line
2.11.0
#6 lore raw

PATCH v2 5/8 ARM: Odroid XU3: Adjust BOOT_TARGET_DEVICES to allow booting from SD card (mmc2)

Quoted 10 lines · Lukasz Majewski

This change is necessary to allow booting the Odroid XU3 from SD card after enabling the DM_MMC support.

After this change the SD card mmc IP block is correctly enumerated as mmc2 (and not as mmc1 as in the legacy code).

Quoted 8 lines

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 include/configs/exynos5-common.h | 1 +
 1 file changed, 1 insertion(+)
#7 lore raw

PATCH v2 6/8 ARM: Odroid XU3: MAINTAINERS: Add a co-maintainer for OdroidXU3

In reply to Lukasz Majewski

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 board/samsung/smdk5420/MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
board/samsung/smdk5420/MAINTAINERS +1 -0
index 590a1140b07e..31c00360f287 100644
@@ -11,6 +11,7 @@ F:	configs/peach-pi_defconfig
 
 ODROID-XU3 BOARD
 M:	Jaehoon Chung <[email protected]>
+M:	Lukasz Majewski <[email protected]>
 S:	Maintained
 F:	board/samsung/smdk5420/
 F:	include/configs/odroid_xu3.h
Signature · 1 line
2.11.0
#8 lore raw

PATCH v2 7/8 ARM: Odroid XU3: Fix the dwmci_exynos *priv data assignment for DM_MMC (sdr_timing)

In reply to Lukasz Majewski

By convention for DM_MMC the host->priv is used to store struct udevice *dev pointer.

Unfortunately, the legacy Exynos DW MMC code uses this field to store pointer to dwmci_exynos_priv_data struct
Hence, we do need to get data in other way - namely by using container_of when host pointer is present.
In this way the sdr_timing data is properly accessed.

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 drivers/mmc/exynos_dw_mmc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/mmc/exynos_dw_mmc.c +5 -1
index 49c4f7634830..cd0fa4c6341b 100644
@@ -46,8 +46,12 @@ struct dwmci_exynos_priv_data {
  */
 static void exynos_dwmci_clksel(struct dwmci_host *host)
 {
+#ifdef CONFIG_DM_MMC
+	struct dwmci_exynos_priv_data *priv =
+		container_of(host, struct dwmci_exynos_priv_data, host);
+#else
 	struct dwmci_exynos_priv_data *priv = host->priv;
-
+#endif
 	dwmci_writel(host, DWMCI_CLKSEL, priv->sdr_timing);
 }
 
Signature · 1 line
2.11.0
#9 lore raw

PATCH v2 8/8 ARM: Odroid XU3: Modify exynos dw_mmc driver to support Odroid XU3 in DM MMC

In reply to Lukasz Majewski

This commit enables support for Exynos Designware MMC driver based on DM.

---

Changes in v2:
- Add tested-by
- Rebase on the newest main line

 drivers/mmc/exynos_dw_mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/exynos_dw_mmc.c +1 -0
index cd0fa4c6341b..435ccac59421 100644
@@ -295,6 +295,7 @@ static int exynos_dwmmc_bind(struct udevice *dev)
 
 static const struct udevice_id exynos_dwmmc_ids[] = {
 	{ .compatible = "samsung,exynos4412-dw-mshc" },
+	{ .compatible = "samsung,exynos-dwmmc" },
 	{ }
 };
 
Signature · 1 line
2.11.0
#10 lore raw

v2 cover ARM: Odroid XU3: Enable DM_MMC support which is necessary for CONFIG_BLK

In reply to Lukasz Majewski

Hi,

2018년 8월 1일 (수) 21:49, Lukasz Majewski <[email protected]>님이 작성:

Quoted 51 lines

This patch series provides following improvements to Odroid XU3:
- Fix sdr_timing problem with DW_MMC running with DM
- Clean up the defconfig file
- Fix potential memory leak when running under DM (DW_MMC)
- Rebase on newest ML
- Remove the patch, which add support for booting only from SD card
Travis-CI: https://travis-ci.org/lmajewski/u-boot-dfu/builds/410698980
SHA1 <https://travis-ci.org/lmajewski/u-boot-dfu/builds/410698980SHA1>:
ae5afc37204e72ebe6e6844f70afff99db3bd910

Changes in v2:
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line
- Add tested-by
- Rebase on the newest main line

Lukasz Majewski (8):
ARM: dw_mmc: Exclude dwmci Exynos priv_data allocation from
exynos_dwmci_get_config()
ARM: Odroid XU3: config: Disable SDHCI support in the Odroid XU3
ARM: Odroid XU3: Enable driver model support for MMC (DM_MMC)
ARM: Odroid XU3: Fix autoboot.cmd to use ${mmcbootdev} instead of
hardcoded 0
ARM: Odroid XU3: Adjust BOOT_TARGET_DEVICES to allow booting from SD

    card (mmc2)

ARM: Odroid XU3: MAINTAINERS: Add a co-maintainer for OdroidXU3
ARM: Odroid XU3: Fix the dwmci_exynos *priv data assignment for DM_MMC
(sdr_timing)
ARM: Odroid XU3: Modify exynos dw_mmc driver to support Odroid XU3 in
DM MMC

 board/samsung/common/bootscripts/autoboot.cmd |  6 ++---
 board/samsung/smdk5420/MAINTAINERS            |  1 +
 configs/odroid-xu3_defconfig                  |  3 +--
 drivers/mmc/exynos_dw_mmc.c                   | 37
+++++++++++++++------------
 include/configs/exynos5-common.h              |  1 +
 5 files changed, 27 insertions(+), 21 deletions(-)
Quoted 3 lines

--
2.11.0

applied to u-boot-samsung.

Thanks,
Minkyu Kang.

Quoted 1 line