From 2051aefe71b646b14220c52e85c42b26be1e7cad Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 11 Oct 2016 15:08:43 +0800 Subject: mmc: introduce mmc_power_init In device tree, there is vmmc-supply property for SD/MMC. Introduce mmc_power_init function to handle vmmc-supply. mmc_power_init will first invoke board_mmc_power_init to avoid break boards which already implement board_mmc_power_init. If DM_MMC and DM_REGULATOR is defined, the regulator will be enabled to power up the device. Signed-off-by: Peng Fan Cc: Jaehoon Chung diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 0312da9..320413a 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1582,6 +1583,31 @@ __weak void board_mmc_power_init(void) { } +static int mmc_power_init(struct mmc *mmc) +{ + board_mmc_power_init(); + +#if defined(CONFIG_DM_MMC) && defined(CONFIG_DM_REGULATOR) && \ + !defined(CONFIG_SPL_BUILD) + struct udevice *vmmc_supply; + int ret; + + ret = device_get_supply_regulator(mmc->dev, "vmmc-supply", + &vmmc_supply); + if (ret) { + puts("No vmmc supply\n"); + return 0; + } + + ret = regulator_set_enable(vmmc_supply, true); + if (ret) { + puts("Error enabling VMMC supply\n"); + return ret; + } +#endif + return 0; +} + int mmc_start_init(struct mmc *mmc) { bool no_card; @@ -1606,7 +1632,9 @@ int mmc_start_init(struct mmc *mmc) #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT mmc_adapter_card_type_ident(); #endif - board_mmc_power_init(); + err = mmc_power_init(mmc); + if (err) + return err; #ifdef CONFIG_DM_MMC_OPS /* The device has already been probed ready for use */ -- cgit v0.10.2 From be256cbf0456865471ff63dd7579cd6404574c44 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Thu, 13 Oct 2016 10:33:06 +0900 Subject: mmc: sdhci: fix the "misaligned operation at range" for cache This pathc is fixed the below thing. If misaligned the cache range, Just flush to CACHLINE_SIZE. "CACHE: Misaligned operation at range [7ae55b00, 7ae55b08]" Signed-off-by: Jaehoon Chung diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 837c538..10ff57e 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -242,6 +242,7 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, sdhci_writel(host, cmd->cmdarg, SDHCI_ARGUMENT); #ifdef CONFIG_MMC_SDMA + trans_bytes = ALIGN(trans_bytes, CONFIG_SYS_CACHELINE_SIZE); flush_cache(start_addr, trans_bytes); #endif sdhci_writew(host, SDHCI_MAKE_CMD(cmd->cmdidx, flags), SDHCI_COMMAND); -- cgit v0.10.2 From dd399cb736c81b2af70426c2afc9d5e4bac95830 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 14 Oct 2016 00:13:18 +0900 Subject: mmc: refactor two core functions Drop unneeded variables and assignments. Signed-off-by: Masahiro Yamada diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 77424cd..2fe5d61 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -116,13 +116,7 @@ int get_mmc_num(void) int mmc_get_next_devnum(void) { - int ret; - - ret = blk_find_max_devnum(IF_TYPE_MMC); - if (ret < 0) - return ret; - - return ret; + return blk_find_max_devnum(IF_TYPE_MMC); } struct blk_desc *mmc_get_blk_desc(struct mmc *mmc) @@ -243,7 +237,6 @@ static int mmc_select_hwpart(struct udevice *bdev, int hwpart) struct udevice *mmc_dev = dev_get_parent(bdev); struct mmc *mmc = mmc_get_mmc_dev(mmc_dev); struct blk_desc *desc = dev_get_uclass_platdata(bdev); - int ret; if (desc->hwpart == hwpart) return 0; @@ -251,11 +244,7 @@ static int mmc_select_hwpart(struct udevice *bdev, int hwpart) if (mmc->part_config == MMCPART_NOAVAILABLE) return -EMEDIUMTYPE; - ret = mmc_switch_part(mmc, hwpart); - if (ret) - return ret; - - return 0; + return mmc_switch_part(mmc, hwpart); } static const struct blk_ops mmc_blk_ops = { -- cgit v0.10.2 From f55ae19703ebf3aa19eadb66d6977779675c88d5 Mon Sep 17 00:00:00 2001 From: Sylvain Lesne Date: Mon, 24 Oct 2016 18:24:37 +0200 Subject: dm: mmc: socfpga: fix MMC_OPS support Now that CONFIG_BLK and CONFIG_MMC_OPS are enabled by default with CONFIG_DM_MMC, the DWMMC driver on the socfpga platform fails at runtime. This adds the missing fields in the driver declaration. Signed-off-by: Sylvain Lesne Acked-by: Marek Vasut Reviewed-by: Simon Glass diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c index 5a3a4ff..0a22e58 100644 --- a/drivers/mmc/socfpga_dw_mmc.c +++ b/drivers/mmc/socfpga_dw_mmc.c @@ -151,7 +151,9 @@ U_BOOT_DRIVER(socfpga_dwmmc_drv) = { .id = UCLASS_MMC, .of_match = socfpga_dwmmc_ids, .ofdata_to_platdata = socfpga_dwmmc_ofdata_to_platdata, + .ops = &dm_dwmci_ops, .bind = socfpga_dwmmc_bind, .probe = socfpga_dwmmc_probe, .priv_auto_alloc_size = sizeof(struct dwmci_socfpga_priv_data), + .platdata_auto_alloc_size = sizeof(struct socfpga_dwmci_plat), }; -- cgit v0.10.2 From 288db7c7c00acadf699a726deba2d9825bdd9c2b Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Mon, 24 Oct 2016 15:22:22 +0900 Subject: mmc: add the device name in debugging message for supplying vmmc If vmmc didn't supply, we didn't know which card didn't supply vmmc. And changed from "put" to "debug". Signed-off-by: Jaehoon Chung Reviewed-by: Peng Fan diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 320413a..4380c7c 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1595,7 +1595,7 @@ static int mmc_power_init(struct mmc *mmc) ret = device_get_supply_regulator(mmc->dev, "vmmc-supply", &vmmc_supply); if (ret) { - puts("No vmmc supply\n"); + debug("%s: No vmmc supply\n", mmc->dev->name); return 0; } -- cgit v0.10.2 From 2a1bedaa03a27b3d4a94f9e251f269814ed72e3e Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Fri, 21 Oct 2016 20:52:35 +0900 Subject: mmc: sdhci: assign to clk_mul when host version is upper than SD3.0 To prevent the wrong value check the SD version. Signed-off-by: Jaehoon Chung diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 10ff57e..766e9ee 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -608,9 +608,11 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, * In case of Host Controller v3.00, find out whether clock * multiplier is supported. */ - caps_1 = sdhci_readl(host, SDHCI_CAPABILITIES_1); - host->clk_mul = (caps_1 & SDHCI_CLOCK_MUL_MASK) >> - SDHCI_CLOCK_MUL_SHIFT; + if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) { + caps_1 = sdhci_readl(host, SDHCI_CAPABILITIES_1); + host->clk_mul = (caps_1 & SDHCI_CLOCK_MUL_MASK) >> + SDHCI_CLOCK_MUL_SHIFT; + } return 0; } -- cgit v0.10.2