[U-Boot] [PATCH 0/5] mmc: exynos_dw_mmc: clean the unnecessary codes

This patch-set is for maintaining more easier than now. Now, exynos_dw_mmc codes are too huge. Some codes can be reused and removed. Basic goal is the using DM. Before applied DM, it needs to clean more.
In future, exynos_dw_mmc controller should support DM.
Jaehoon Chung (5): mmc: exynos_dw_mmc: remove the unused function mmc: exynos_dw_mmc: remove #ifdef for OF_CONTROL mmc: exynos_dw_mmc: add the error control for checking index mmc: exynos_dw_mmc: clean the unused and unnecessary codes mmc: exynos_dw_mmc: use the 4bit bus-width by default
arch/arm/mach-exynos/include/mach/dwmmc.h | 1 - drivers/mmc/exynos_dw_mmc.c | 78 ++++++------------------------- 2 files changed, 14 insertions(+), 65 deletions(-)

This function have maintained for supporting Non-FDT. Now, Almost all SoC are changed to fdt style. So there are no that this function is called anywhere.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com --- arch/arm/mach-exynos/include/mach/dwmmc.h | 1 - drivers/mmc/exynos_dw_mmc.c | 36 ------------------------------- 2 files changed, 37 deletions(-)
diff --git a/arch/arm/mach-exynos/include/mach/dwmmc.h b/arch/arm/mach-exynos/include/mach/dwmmc.h index bd997ad..ab8361f 100644 --- a/arch/arm/mach-exynos/include/mach/dwmmc.h +++ b/arch/arm/mach-exynos/include/mach/dwmmc.h @@ -28,4 +28,3 @@ #define DWMCI_DIVRATIO_MASK 0x7
int exynos_dwmmc_init(const void *blob); -int exynos_dwmci_add_port(int index, u32 regbase, int bus_width, u32 clksel); diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 863bbb3..2b9b3aa 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -122,42 +122,6 @@ static int exynos_dwmci_core_init(struct dwmci_host *host, int index) return 0; }
-/* - * This function adds the mmc channel to be registered with mmc core. - * index - mmc channel number. - * regbase - register base address of mmc channel specified in 'index'. - * bus_width - operating bus width of mmc channel specified in 'index'. - * clksel - value to be written into CLKSEL register in case of FDT. - * NULL in case od non-FDT. - */ -int exynos_dwmci_add_port(int index, u32 regbase, int bus_width, u32 clksel) -{ - struct dwmci_host *host = NULL; - struct dwmci_exynos_priv_data *priv; - - host = malloc(sizeof(struct dwmci_host)); - if (!host) { - error("dwmci_host malloc fail!\n"); - return -ENOMEM; - } - - priv = malloc(sizeof(struct dwmci_exynos_priv_data)); - if (!priv) { - error("dwmci_exynos_priv_data malloc fail!\n"); - return -ENOMEM; - } - - host->ioaddr = (void *)regbase; - host->buswidth = bus_width; - - if (clksel) - priv->sdr_timing = clksel; - - host->priv = priv; - - return exynos_dwmci_core_init(host, index); -} - #if CONFIG_IS_ENABLED(OF_CONTROL) static struct dwmci_host dwmci_host[DWMMC_MAX_CH_NUM];

On 29 June 2016 at 03:46, Jaehoon Chung jh80.chung@samsung.com wrote:
This function have maintained for supporting Non-FDT. Now, Almost all SoC are changed to fdt style. So there are no that this function is called anywhere.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com
arch/arm/mach-exynos/include/mach/dwmmc.h | 1 - drivers/mmc/exynos_dw_mmc.c | 36 ------------------------------- 2 files changed, 37 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Removed #ifdef for OF_CONTROL. It might use 'OF_CONTROL' by default.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com --- drivers/mmc/exynos_dw_mmc.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 2b9b3aa..80d17ad 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -122,7 +122,6 @@ static int exynos_dwmci_core_init(struct dwmci_host *host, int index) return 0; }
-#if CONFIG_IS_ENABLED(OF_CONTROL) static struct dwmci_host dwmci_host[DWMMC_MAX_CH_NUM];
static int do_dwmci_init(struct dwmci_host *host) @@ -250,4 +249,3 @@ int exynos_dwmmc_init(const void *blob)
return err; } -#endif

On 29 June 2016 at 03:46, Jaehoon Chung jh80.chung@samsung.com wrote:
Removed #ifdef for OF_CONTROL. It might use 'OF_CONTROL' by default.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com
drivers/mmc/exynos_dw_mmc.c | 2 -- 1 file changed, 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

PERIPH_ID_SDMMC4(131) is not continous value with PERIPH_ID_SDMMC0(75). If there is no 'index' property in fdt, then dev_index should be assigned to dev_id(Peripheral ID). At this time, dev_index should be "56". It means Exynos SoC has "56" numbers of DWMMC IP. To prevent this behavior, it needs to check the maximum device index.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com --- drivers/mmc/exynos_dw_mmc.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 80d17ad..5860023 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -160,6 +160,11 @@ static int exynos_dwmci_get_config(const void *blob, int node, if (host->dev_index == host->dev_id) host->dev_index = host->dev_id - PERIPH_ID_SDMMC0;
+ if (host->dev_index > 4) { + printf("DWMMC%d: Can't get the dev index\n", host->dev_index); + return -EINVAL; + } + /* Get the bus width from the device node */ host->buswidth = fdtdec_get_int(blob, node, "samsung,bus-width", 0); if (host->buswidth <= 0) {

On 29 June 2016 at 03:46, Jaehoon Chung jh80.chung@samsung.com wrote:
PERIPH_ID_SDMMC4(131) is not continous value with PERIPH_ID_SDMMC0(75). If there is no 'index' property in fdt, then dev_index should be assigned to dev_id(Peripheral ID). At this time, dev_index should be "56". It means Exynos SoC has "56" numbers of DWMMC IP. To prevent this behavior, it needs to check the maximum device index.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com
drivers/mmc/exynos_dw_mmc.c | 5 +++++ 1 file changed, 5 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

Clean the unused and unnecessary codse. This patch is one of them for preparing to use DM. Because it's easy to maintain and combine DM after cleaning codes.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com --- drivers/mmc/exynos_dw_mmc.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-)
diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 5860023..cfbe135 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -80,11 +80,10 @@ static void exynos_dwmci_board_init(struct dwmci_host *host) exynos_dwmci_clksel(host); }
-static int exynos_dwmci_core_init(struct dwmci_host *host, int index) +static int exynos_dwmci_core_init(struct dwmci_host *host) { unsigned int div; unsigned long freq, sclk; - struct dwmci_exynos_priv_data *priv = host->priv;
if (host->bus_hz) freq = host->bus_hz; @@ -92,10 +91,10 @@ static int exynos_dwmci_core_init(struct dwmci_host *host, int index) freq = DWMMC_MAX_FREQ;
/* request mmc clock vlaue of 52MHz. */ - sclk = get_mmc_clk(index); + sclk = get_mmc_clk(host->dev_index); div = DIV_ROUND_UP(sclk, freq); /* set the clock divisor for mmc */ - set_mmc_clk(index, div); + set_mmc_clk(host->dev_index, div);
host->name = "EXYNOS DWMMC"; #ifdef CONFIG_EXYNOS5420 @@ -103,20 +102,12 @@ static int exynos_dwmci_core_init(struct dwmci_host *host, int index) #endif host->board_init = exynos_dwmci_board_init;
- if (!priv->sdr_timing) { - if (index == 0) - priv->sdr_timing = DWMMC_MMC0_SDR_TIMING_VAL; - else if (index == 2) - priv->sdr_timing = DWMMC_MMC2_SDR_TIMING_VAL; - } - host->caps = MMC_MODE_DDR_52MHz; host->clksel = exynos_dwmci_clksel; - host->dev_index = index; host->get_mmc_clk = exynos_dwmci_get_clk; /* Add the mmc channel to be registered with mmc core */ if (add_dwmci(host, DWMMC_MAX_FREQ, DWMMC_MIN_FREQ)) { - printf("DWMMC%d registration failed\n", index); + printf("DWMMC%d registration failed\n", host->dev_index); return -1; } return 0; @@ -126,18 +117,16 @@ static struct dwmci_host dwmci_host[DWMMC_MAX_CH_NUM];
static int do_dwmci_init(struct dwmci_host *host) { - int index, flag, err; - - index = host->dev_index; + int flag, err;
flag = host->buswidth == 8 ? PINMUX_FLAG_8BIT_MODE : PINMUX_FLAG_NONE; err = exynos_pinmux_config(host->dev_id, flag); if (err) { - printf("DWMMC%d not configure\n", index); + printf("DWMMC%d not configure\n", host->dev_index); return err; }
- return exynos_dwmci_core_init(host, index); + return exynos_dwmci_core_init(host); }
static int exynos_dwmci_get_config(const void *blob, int node, @@ -233,15 +222,13 @@ static int exynos_dwmci_process_node(const void *blob,
int exynos_dwmmc_init(const void *blob) { - int compat_id; int node_list[DWMMC_MAX_CH_NUM]; int boot_dev_node; int err = 0, count;
- compat_id = COMPAT_SAMSUNG_EXYNOS_DWMMC; - count = fdtdec_find_aliases_for_id(blob, "mmc", - compat_id, node_list, DWMMC_MAX_CH_NUM); + COMPAT_SAMSUNG_EXYNOS_DWMMC, node_list, + DWMMC_MAX_CH_NUM);
/* For DWMMC always set boot device as mmc 0 */ if (count >= 3 && get_boot_mode() == BOOT_MODE_SD) {

On 29 June 2016 at 03:46, Jaehoon Chung jh80.chung@samsung.com wrote:
Clean the unused and unnecessary codse. This patch is one of them for preparing to use DM. Because it's easy to maintain and combine DM after cleaning codes.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com
drivers/mmc/exynos_dw_mmc.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

If there is not "samsung,bus-width" property, use the 4bit buswidth by default. Almost all Exnyos SoCs support at least 4bit buswidth.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com --- drivers/mmc/exynos_dw_mmc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index cfbe135..ab0df46 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -154,12 +154,8 @@ static int exynos_dwmci_get_config(const void *blob, int node, return -EINVAL; }
- /* Get the bus width from the device node */ - host->buswidth = fdtdec_get_int(blob, node, "samsung,bus-width", 0); - if (host->buswidth <= 0) { - printf("DWMMC%d: Can't get bus-width\n", host->dev_index); - return -EINVAL; - } + /* Get the bus width from the device node (Default is 4bit buswidth) */ + host->buswidth = fdtdec_get_int(blob, node, "samsung,bus-width", 4);
/* Set the base address from the device node */ base = fdtdec_get_addr(blob, node, "reg");

On 29 June 2016 at 03:46, Jaehoon Chung jh80.chung@samsung.com wrote:
If there is not "samsung,bus-width" property, use the 4bit buswidth by default. Almost all Exnyos SoCs support at least 4bit buswidth.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com
drivers/mmc/exynos_dw_mmc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On 29/06/16 19:46, Jaehoon Chung wrote:
This patch-set is for maintaining more easier than now. Now, exynos_dw_mmc codes are too huge. Some codes can be reused and removed. Basic goal is the using DM. Before applied DM, it needs to clean more.
In future, exynos_dw_mmc controller should support DM.
Jaehoon Chung (5): mmc: exynos_dw_mmc: remove the unused function mmc: exynos_dw_mmc: remove #ifdef for OF_CONTROL mmc: exynos_dw_mmc: add the error control for checking index mmc: exynos_dw_mmc: clean the unused and unnecessary codes mmc: exynos_dw_mmc: use the 4bit bus-width by default
arch/arm/mach-exynos/include/mach/dwmmc.h | 1 - drivers/mmc/exynos_dw_mmc.c | 78 ++++++------------------------- 2 files changed, 14 insertions(+), 65 deletions(-)
applied to u-boot-samsung.
Thanks, Minkyu Kang.
participants (3)
-
Jaehoon Chung
-
Minkyu Kang
-
Simon Glass