[U-Boot] [PATCH v2 0/8] 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(-)

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.
Signed-off-by: Lukasz Majewski lukma@denx.de Tested-by: Anand Moon linux.amoon@gmail.com
---
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(-)
diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 865fdf4dbba0..49c4f7634830 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -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);

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.
Signed-off-by: Lukasz Majewski lukma@denx.de Tested-by: Anand Moon linux.amoon@gmail.com
---
Changes in v2: - Add tested-by - Rebase on the newest main line
configs/odroid-xu3_defconfig | 2 -- 1 file changed, 2 deletions(-)
diff --git a/configs/odroid-xu3_defconfig b/configs/odroid-xu3_defconfig index 5943c19cf9b3..6398c2cd0d6a 100644 --- a/configs/odroid-xu3_defconfig +++ b/configs/odroid-xu3_defconfig @@ -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

This commit enables support for DW_MMC running with driver model.
Signed-off-by: Lukasz Majewski lukma@denx.de Tested-by: Anand Moon linux.amoon@gmail.com
---
Changes in v2: - Add tested-by - Rebase on the newest main line
configs/odroid-xu3_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/odroid-xu3_defconfig b/configs/odroid-xu3_defconfig index 6398c2cd0d6a..632542d98420 100644 --- a/configs/odroid-xu3_defconfig +++ b/configs/odroid-xu3_defconfig @@ -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

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.
Signed-off-by: Lukasz Majewski lukma@denx.de Tested-by: Anand Moon linux.amoon@gmail.com
---
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(-)
diff --git a/board/samsung/common/bootscripts/autoboot.cmd b/board/samsung/common/bootscripts/autoboot.cmd index 1faed8ba0c1a..11c724c4e095 100644 --- a/board/samsung/common/bootscripts/autoboot.cmd +++ b/board/samsung/common/bootscripts/autoboot.cmd @@ -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;

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).
Signed-off-by: Lukasz Majewski lukma@denx.de Tested-by: Anand Moon linux.amoon@gmail.com
---
Changes in v2: - Add tested-by - Rebase on the newest main line
include/configs/exynos5-common.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/configs/exynos5-common.h b/include/configs/exynos5-common.h index a7621fc701b2..cd2a9046afec 100644 --- a/include/configs/exynos5-common.h +++ b/include/configs/exynos5-common.h @@ -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)

On 1 August 2018 at 06:48, Lukasz Majewski lukma@denx.de wrote:
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).
Signed-off-by: Lukasz Majewski lukma@denx.de Tested-by: Anand Moon linux.amoon@gmail.com
Changes in v2:
- Add tested-by
- Rebase on the newest main line
include/configs/exynos5-common.h | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Simon Glass sjg@chromium.org

Signed-off-by: Lukasz Majewski lukma@denx.de Tested-by: Anand Moon linux.amoon@gmail.com
---
Changes in v2: - Add tested-by - Rebase on the newest main line
board/samsung/smdk5420/MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
diff --git a/board/samsung/smdk5420/MAINTAINERS b/board/samsung/smdk5420/MAINTAINERS index 590a1140b07e..31c00360f287 100644 --- a/board/samsung/smdk5420/MAINTAINERS +++ b/board/samsung/smdk5420/MAINTAINERS @@ -11,6 +11,7 @@ F: configs/peach-pi_defconfig
ODROID-XU3 BOARD M: Jaehoon Chung jh80.chung@samsung.com +M: Lukasz Majewski lukma@denx.de S: Maintained F: board/samsung/smdk5420/ F: include/configs/odroid_xu3.h

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.
Signed-off-by: Lukasz Majewski lukma@denx.de Tested-by: Anand Moon linux.amoon@gmail.com
---
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(-)
diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 49c4f7634830..cd0fa4c6341b 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -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); }

This commit enables support for Exynos Designware MMC driver based on DM.
Signed-off-by: Lukasz Majewski lukma@denx.de Tested-by: Anand Moon linux.amoon@gmail.com
---
Changes in v2: - Add tested-by - Rebase on the newest main line
drivers/mmc/exynos_dw_mmc.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index cd0fa4c6341b..435ccac59421 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -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" }, { } };

Hi,
2018년 8월 1일 (수) 21:49, Lukasz Majewski lukma@denx.de님이 작성:
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(-)
-- 2.11.0
applied to u-boot-samsung.
Thanks, Minkyu Kang.
participants (3)
-
Lukasz Majewski
-
Minkyu Kang
-
Simon Glass