From 52ff04a216287e1e36d4a3ac977867412b91df45 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Fri, 4 Dec 2020 06:36:00 +0900 Subject: [PATCH 01/13] mmc: initialize an err variable Initialize an err variable to 0. Signed-off-by: Jaehoon Chung Reported-by: Coverity (CID: 313548) Reviewed-by: Tom Rini --- drivers/mmc/mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 36aab50f64..d67af80c01 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -2062,7 +2062,7 @@ static int mmc_select_hs400es(struct mmc *mmc) static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps) { - int err; + int err = 0; const struct mode_width_tuning *mwt; const struct ext_csd_bus_width *ecbw; From 1019b19665ee719762f7613a36bf1b7ef9c3b578 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Wed, 16 Dec 2020 07:24:50 +0900 Subject: [PATCH 02/13] cmd: mmc: update the mmc command's usage about argument It's confusing whether arguments are optional or mandatory. Update the command's usage to clarify how to use. Signed-off-by: Jaehoon Chung Reviewed-by: Simon Glass --- cmd/mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/mmc.c b/cmd/mmc.c index 1529a3e05d..cb6b59f36a 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -1017,13 +1017,13 @@ U_BOOT_CMD( " Power cycling is required to initialize partitions after set to complete.\n" #endif #ifdef CONFIG_SUPPORT_EMMC_BOOT - "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n" + "mmc bootbus \n" " - Set the BOOT_BUS_WIDTH field of the specified device\n" "mmc bootpart-resize \n" " - Change sizes of boot and RPMB partitions of specified device\n" - "mmc partconf dev [boot_ack boot_partition partition_access]\n" + "mmc partconf [boot_ack boot_partition partition_access]\n" " - Show or change the bits of the PARTITION_CONFIG field of the specified device\n" - "mmc rst-function dev value\n" + "mmc rst-function \n" " - Change the RST_n_FUNCTION field of the specified device\n" " WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n" #endif From 37e1362efc2ba9be5355b3c55f9f4f7a43f02de2 Mon Sep 17 00:00:00 2001 From: "Yuezhang.Mo@sony.com" Date: Thu, 14 Jan 2021 05:46:50 +0000 Subject: [PATCH 03/13] mmc: sdhci: skip cache invalidation if DMA is not used If DMA(SDMA or ADMA) is not used, the cache invalidation after reading is no need, should be skipped. Otherwise U-Boot may hang at the cache invalidation. Found this issue and tested this fix on DragonBoard 410c. Fixes: commit 4155ad9aac94 ("mmc: sdhci: fix missing cache invalidation after reading by DMA") Signed-off-by: Yuezhang.Mo Reviewed-by: Andy Wu --- drivers/mmc/sdhci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 5f18d472bd..d9ab6a0a83 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -177,8 +177,10 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data) } } while (!(stat & SDHCI_INT_DATA_END)); +#if (defined(CONFIG_MMC_SDHCI_SDMA) || CONFIG_IS_ENABLED(MMC_SDHCI_ADMA)) dma_unmap_single(host->start_addr, data->blocks * data->blocksize, mmc_get_dma_dir(data)); +#endif return 0; } From 8e2b0af7216d78b60fccb46a107a4a047938aea9 Mon Sep 17 00:00:00 2001 From: Stefan Bosch Date: Sat, 23 Jan 2021 13:37:41 +0100 Subject: [PATCH 04/13] mmc: fix response timeout after switch command After issuing the switch command: Wait until 'current state' of the card status becomes 'tran'. This prevents from response timeout at the next command because of 'current state' = 'data'. Signed-off-by: Stefan Bosch Reviewed-by: Jaehoon Chung --- drivers/mmc/mmc.c | 3 ++- include/mmc.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index d67af80c01..b4c8e7f293 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -841,7 +841,8 @@ static int __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value, value); return -EIO; } - if (!ret && (status & MMC_STATUS_RDY_FOR_DATA)) + if (!ret && (status & MMC_STATUS_RDY_FOR_DATA) && + (status & MMC_STATUS_CURR_STATE) == MMC_STATE_TRANS) return 0; udelay(100); } while (get_timer(start) < timeout_ms); diff --git a/include/mmc.h b/include/mmc.h index c12c7a0b5c..effccaaca0 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -178,6 +178,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define MMC_STATUS_ERROR (1 << 19) #define MMC_STATE_PRG (7 << 9) +#define MMC_STATE_TRANS (4 << 9) #define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */ #define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */ From 01962f8d7ced3d8b9748d3b902f7f9b68587c426 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 2 Feb 2021 10:32:48 +0800 Subject: [PATCH 05/13] mmc: mmc_spi: Print verbose debug output when crc16 check fails Add some verbose debug output when crc16 check fails. Signed-off-by: Bin Meng Reviewed-by: Jaehoon Chung --- drivers/mmc/mmc_spi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/mmc_spi.c b/drivers/mmc/mmc_spi.c index 46800bbed2..23b907328c 100644 --- a/drivers/mmc/mmc_spi.c +++ b/drivers/mmc/mmc_spi.c @@ -181,8 +181,10 @@ static int mmc_spi_readdata(struct udevice *dev, if (ret) return ret; #ifdef CONFIG_MMC_SPI_CRC_ON - if (be16_to_cpu(crc16_ccitt(0, buf, bsize)) != crc) { - debug("%s: data crc error\n", __func__); + u16 crc_ok = be16_to_cpu(crc16_ccitt(0, buf, bsize)); + if (crc_ok != crc) { + debug("%s: data crc error, expected %04x got %04x\n", + __func__, crc_ok, crc); r1 = R1_SPI_COM_CRC; break; } From 781aad0de93aedf94a17cc66b2f211bf156b718e Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 2 Feb 2021 10:48:46 +0800 Subject: [PATCH 06/13] mmc: mmc_spi: Move argument check to the beginning of mmc_spi_sendcmd() The argument check should happen before any transfer on the SPI lines. Signed-off-by: Bin Meng Reviewed-by: Jaehoon Chung --- drivers/mmc/mmc_spi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/mmc_spi.c b/drivers/mmc/mmc_spi.c index 23b907328c..a06862aa48 100644 --- a/drivers/mmc/mmc_spi.c +++ b/drivers/mmc/mmc_spi.c @@ -78,6 +78,9 @@ static int mmc_spi_sendcmd(struct udevice *dev, int i, rpos = 0, ret = 0; u8 cmdo[7], r; + if (!resp || !resp_size) + return 0; + debug("%s: cmd%d cmdarg=0x%x resp_type=0x%x " "resp_size=%d resp_match=%d resp_match_value=0x%x\n", __func__, cmdidx, cmdarg, resp_type, @@ -98,9 +101,6 @@ static int mmc_spi_sendcmd(struct udevice *dev, if (ret) return ret; - if (!resp || !resp_size) - return 0; - debug("%s: cmd%d", __func__, cmdidx); if (resp_match) { From 2f22cb40e57f28b694c05c0b631cbb0c09eb03a4 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 2 Feb 2021 10:48:47 +0800 Subject: [PATCH 07/13] mmc: mmc_spi: Fix potential spec violation in receiving card response After command is sent and before card response shows up on the line, there is a variable number of clock cycles in between called Ncr. The spec [1] says the minimum is 1 byte and the maximum is 8 bytes. Current logic in mmc_spi_sendcmd() has a flaw that it could only work with certain SD cards with their Ncr being just 1 byte. When resp_match is false, the codes try to receive only 1 byte from the SD card. On the other hand when resp_match is true, the logic happens to be no problem as it loops until timeout to receive as many bytes as possible to see a match of the expected resp_match_value. However not every call to mmc_spi_sendcmd() is made with resp_match being true hence this exposes a potential issue with SD cards that have a larger Ncr value. Given no issue was reported as of today, we can reasonably conclude that all cards being used on the supported boards happen to have a 1 byte Ncr timing requirement. But a broken case can be triggered by utilizing QEMU to emulate a larger value of Ncr (by default 1 byte Ncr is used on QEMU). This commit fixes such potential spec violation to improve the card compatibility. [1] "Physical Layer Specification Version 8.00" chapter 7.5.1: Command / Response chapter 7.5.4: Timing Values Signed-off-by: Bin Meng Reviewed-by: Jaehoon Chung --- drivers/mmc/mmc_spi.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/mmc_spi.c b/drivers/mmc/mmc_spi.c index a06862aa48..fbdbcf73ff 100644 --- a/drivers/mmc/mmc_spi.c +++ b/drivers/mmc/mmc_spi.c @@ -103,29 +103,31 @@ static int mmc_spi_sendcmd(struct udevice *dev, debug("%s: cmd%d", __func__, cmdidx); - if (resp_match) { + if (resp_match) r = ~resp_match_value; - i = CMD_TIMEOUT; - while (i) { - ret = dm_spi_xfer(dev, 1 * 8, NULL, &r, 0); - if (ret) - return ret; - debug(" resp%d=0x%x", rpos, r); - rpos++; - i--; + i = CMD_TIMEOUT; + while (i) { + ret = dm_spi_xfer(dev, 1 * 8, NULL, &r, 0); + if (ret) + return ret; + debug(" resp%d=0x%x", rpos, r); + rpos++; + i--; + if (resp_match) { if (r == resp_match_value) break; + } else { + if (!(r & 0x80)) + break; } - if (!i && (r != resp_match_value)) + + if (!i) return -ETIMEDOUT; } - for (i = 0; i < resp_size; i++) { - if (i == 0 && resp_match) { - resp[i] = resp_match_value; - continue; - } + resp[0] = r; + for (i = 1; i < resp_size; i++) { ret = dm_spi_xfer(dev, 1 * 8, NULL, &r, 0); if (ret) return ret; From 46938abd2c4c2b605c5af9483fff20ef6772eafc Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 2 Feb 2021 10:48:48 +0800 Subject: [PATCH 08/13] mmc: mmc_spi: Document the 3 local functions mmc_spi_sendcmd(), mmc_spi_readdata() and mmc_spi_writedata() are currently undocumented. Add comment blocks to explain the arguments and the return value. Signed-off-by: Bin Meng Reviewed-by: Jaehoon Chung --- drivers/mmc/mmc_spi.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/mmc_spi.c b/drivers/mmc/mmc_spi.c index fbdbcf73ff..e2d78794f2 100644 --- a/drivers/mmc/mmc_spi.c +++ b/drivers/mmc/mmc_spi.c @@ -37,7 +37,8 @@ #define SPI_RESPONSE_CRC_ERR ((5 << 1)|1) #define SPI_RESPONSE_WRITE_ERR ((6 << 1)|1) -/* Read and write blocks start with these tokens and end with crc; +/* + * Read and write blocks start with these tokens and end with crc; * on error, read tokens act like a subset of R2_SPI_* values. */ /* single block write multiblock read */ @@ -70,6 +71,20 @@ struct mmc_spi_priv { struct spi_slave *spi; }; +/** + * mmc_spi_sendcmd() - send a command to the SD card + * + * @dev: mmc_spi device + * @cmdidx: command index + * @cmdarg: command argument + * @resp_type: card response type + * @resp: buffer to store the card response + * @resp_size: size of the card response + * @resp_match: if true, compare each of received bytes with @resp_match_value + * @resp_match_value: a value to be compared with each of received bytes + * @r1b: if true, receive additional bytes for busy signal token + * @return 0 if OK, -ETIMEDOUT if no card response is received, -ve on error + */ static int mmc_spi_sendcmd(struct udevice *dev, ushort cmdidx, u32 cmdarg, u32 resp_type, u8 *resp, u32 resp_size, @@ -159,6 +174,15 @@ static int mmc_spi_sendcmd(struct udevice *dev, return 0; } +/** + * mmc_spi_readdata() - read data block(s) from the SD card + * + * @dev: mmc_spi device + * @xbuf: buffer of the actual data (excluding token and crc) to read + * @bcnt: number of data blocks to transfer + * @bsize: size of the actual data (excluding token and crc) in bytes + * @return 0 if OK, -ECOMM if crc error, -ETIMEDOUT on other errors + */ static int mmc_spi_readdata(struct udevice *dev, void *xbuf, u32 bcnt, u32 bsize) { @@ -207,6 +231,16 @@ static int mmc_spi_readdata(struct udevice *dev, return ret; } +/** + * mmc_spi_writedata() - write data block(s) to the SD card + * + * @dev: mmc_spi device + * @xbuf: buffer of the actual data (excluding token and crc) to write + * @bcnt: number of data blocks to transfer + * @bsize: size of actual data (excluding token and crc) in bytes + * @multi: indicate a transfer by multiple block write command (CMD25) + * @return 0 if OK, -ECOMM if crc error, -ETIMEDOUT on other errors + */ static int mmc_spi_writedata(struct udevice *dev, const void *xbuf, u32 bcnt, u32 bsize, int multi) { From caee38aef71105c6bbc1910bad0e60bdabd053e2 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Tue, 16 Feb 2021 10:16:52 +0900 Subject: [PATCH 09/13] mmc: pwrseq: add mmc-pwrseq file to provide a generic interface Add mmc-pwrseq file to provide a generic interface. Signed-off-by: Jaehoon Chung --- drivers/mmc/Kconfig | 7 ++++++ drivers/mmc/Makefile | 1 + drivers/mmc/mmc-pwrseq.c | 51 ++++++++++++++++++++++++++++++++++++++++ include/mmc.h | 14 +++++++++++ 4 files changed, 73 insertions(+) create mode 100644 drivers/mmc/mmc-pwrseq.c diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index f8ea92172e..f8ca52efb6 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -18,6 +18,13 @@ config MMC_WRITE help Enable write access to MMC and SD Cards +config MMC_PWRSEQ + bool "HW reset support for eMMC" + depends on PWRSEQ + help + Ths select Hardware reset support aka pwrseq-emmc for eMMC + devices. + config MMC_BROKEN_CD bool "Poll for broken card detection case" help diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index 1c849cbab2..89d6af3db3 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -6,6 +6,7 @@ obj-y += mmc.o obj-$(CONFIG_$(SPL_)DM_MMC) += mmc-uclass.o obj-$(CONFIG_$(SPL_)MMC_WRITE) += mmc_write.o +obj-$(CONFIG_MMC_PWRSEQ) += mmc-pwrseq.o obj-$(CONFIG_MMC_SDHCI_ADMA_HELPERS) += sdhci-adma.o ifndef CONFIG_$(SPL_)BLK diff --git a/drivers/mmc/mmc-pwrseq.c b/drivers/mmc/mmc-pwrseq.c new file mode 100644 index 0000000000..2539f61323 --- /dev/null +++ b/drivers/mmc/mmc-pwrseq.c @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2021 SAMSUNG Electronics + * Jaehoon Chung + */ + +#include +#include +#include +#include +#include +#include + +int mmc_pwrseq_get_power(struct udevice *dev, struct mmc_config *cfg) +{ + /* Enable power if needed */ + return uclass_get_device_by_phandle(UCLASS_PWRSEQ, dev, "mmc-pwrseq", + &cfg->pwr_dev); +} + +static int mmc_pwrseq_set_power(struct udevice *dev, bool enable) +{ + struct gpio_desc reset; + int ret; + + ret = gpio_request_by_name(dev, "reset-gpios", 0, &reset, GPIOD_IS_OUT); + if (ret) + return ret; + dm_gpio_set_value(&reset, 1); + udelay(1); + dm_gpio_set_value(&reset, 0); + udelay(200); + + return 0; +} + +static const struct pwrseq_ops mmc_pwrseq_ops = { + .set_power = mmc_pwrseq_set_power, +}; + +static const struct udevice_id mmc_pwrseq_ids[] = { + { .compatible = "mmc-pwrseq-emmc" }, + { } +}; + +U_BOOT_DRIVER(mmc_pwrseq_drv) = { + .name = "mmc_pwrseq_emmc", + .id = UCLASS_PWRSEQ, + .of_match = mmc_pwrseq_ids, + .ops = &mmc_pwrseq_ops, +}; diff --git a/include/mmc.h b/include/mmc.h index effccaaca0..8600881705 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -592,6 +592,9 @@ struct mmc_config { uint f_max; uint b_max; unsigned char part_type; +#ifdef CONFIG_MMC_PWRSEQ + struct udevice *pwr_dev; +#endif }; struct sd_ssr { @@ -808,6 +811,17 @@ int mmc_deinit(struct mmc *mmc); */ int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg); +#ifdef CONFIG_MMC_PWRSEQ +/** + * mmc_pwrseq_get_power() - get a power device from device tree + * + * @dev: MMC device + * @cfg: MMC configuration + * @return 0 if OK, -ve on error + */ +int mmc_pwrseq_get_power(struct udevice *dev, struct mmc_config *cfg); +#endif + int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size); /** From a96ea4d8d53fe724f7a1536c69a303b708d18014 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Tue, 16 Feb 2021 10:16:53 +0900 Subject: [PATCH 10/13] mmc: meson_gx_mmc: use mmc_pwrseq instead of meson_mmc_pwrseq Use mmc_pwrseq instead of meson_mmc_pwrseq. Signed-off-by: Jaehoon Chung Acked-by: Neil Armstrong --- drivers/mmc/meson_gx_mmc.c | 45 +++----------------------------------- 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c index 8b6dfa3b96..fcf4f03d1e 100644 --- a/drivers/mmc/meson_gx_mmc.c +++ b/drivers/mmc/meson_gx_mmc.c @@ -265,10 +265,6 @@ static int meson_mmc_probe(struct udevice *dev) uint32_t val; int ret; -#ifdef CONFIG_PWRSEQ - struct udevice *pwr_dev; -#endif - /* Enable the clocks feeding the MMC controller */ ret = clk_get_bulk(dev, &clocks); if (ret) @@ -292,12 +288,11 @@ static int meson_mmc_probe(struct udevice *dev) mmc_set_clock(mmc, cfg->f_min, MMC_CLK_ENABLE); -#ifdef CONFIG_PWRSEQ +#ifdef CONFIG_MMC_PWRSEQ /* Enable power if needed */ - ret = uclass_get_device_by_phandle(UCLASS_PWRSEQ, dev, "mmc-pwrseq", - &pwr_dev); + ret = mmc_pwrseq_get_power(dev, cfg); if (!ret) { - ret = pwrseq_set_power(pwr_dev, true); + ret = pwrseq_set_power(cfg->pwr_dev, true); if (ret) return ret; } @@ -342,37 +337,3 @@ U_BOOT_DRIVER(meson_mmc) = { .of_to_plat = meson_mmc_of_to_plat, .plat_auto = sizeof(struct meson_mmc_plat), }; - -#ifdef CONFIG_PWRSEQ -static int meson_mmc_pwrseq_set_power(struct udevice *dev, bool enable) -{ - struct gpio_desc reset; - int ret; - - ret = gpio_request_by_name(dev, "reset-gpios", 0, &reset, GPIOD_IS_OUT); - if (ret) - return ret; - dm_gpio_set_value(&reset, 1); - udelay(1); - dm_gpio_set_value(&reset, 0); - udelay(200); - - return 0; -} - -static const struct pwrseq_ops meson_mmc_pwrseq_ops = { - .set_power = meson_mmc_pwrseq_set_power, -}; - -static const struct udevice_id meson_mmc_pwrseq_ids[] = { - { .compatible = "mmc-pwrseq-emmc" }, - { } -}; - -U_BOOT_DRIVER(meson_mmc_pwrseq_drv) = { - .name = "mmc_pwrseq_emmc", - .id = UCLASS_PWRSEQ, - .of_match = meson_mmc_pwrseq_ids, - .ops = &meson_mmc_pwrseq_ops, -}; -#endif From 9d7e6611a0a66d2f922e526859289c9b7f54646f Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Tue, 16 Feb 2021 10:16:54 +0900 Subject: [PATCH 11/13] mmc: rockchip_dw_mmc: use mmc_pwrseq instead of rockchip_mmc_pwrseq Use mmc_pwrseq instead of rockchip_mmc_pwrseq. Signed-off-by: Jaehoon Chung --- drivers/mmc/rockchip_dw_mmc.c | 42 +++-------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c index 1be3c1741f..d7d5361fd5 100644 --- a/drivers/mmc/rockchip_dw_mmc.c +++ b/drivers/mmc/rockchip_dw_mmc.c @@ -105,7 +105,6 @@ static int rockchip_dwmmc_probe(struct udevice *dev) struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct rockchip_dwmmc_priv *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; - struct udevice *pwr_dev __maybe_unused; int ret; #if CONFIG_IS_ENABLED(OF_PLATDATA) @@ -136,12 +135,11 @@ static int rockchip_dwmmc_probe(struct udevice *dev) host->fifo_mode = priv->fifo_mode; -#ifdef CONFIG_PWRSEQ +#ifdef CONFIG_MMC_PWRSEQ /* Enable power if needed */ - ret = uclass_get_device_by_phandle(UCLASS_PWRSEQ, dev, "mmc-pwrseq", - &pwr_dev); + ret = mmc_pwrseq_get_power(dev, &plat->cfg); if (!ret) { - ret = pwrseq_set_power(pwr_dev, true); + ret = pwrseq_set_power(plat->cfg.pwr_dev, true); if (ret) return ret; } @@ -182,37 +180,3 @@ U_BOOT_DRIVER(rockchip_rk3288_dw_mshc) = { DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3328_dw_mshc) DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3368_dw_mshc) - -#ifdef CONFIG_PWRSEQ -static int rockchip_dwmmc_pwrseq_set_power(struct udevice *dev, bool enable) -{ - struct gpio_desc reset; - int ret; - - ret = gpio_request_by_name(dev, "reset-gpios", 0, &reset, GPIOD_IS_OUT); - if (ret) - return ret; - dm_gpio_set_value(&reset, 1); - udelay(1); - dm_gpio_set_value(&reset, 0); - udelay(200); - - return 0; -} - -static const struct pwrseq_ops rockchip_dwmmc_pwrseq_ops = { - .set_power = rockchip_dwmmc_pwrseq_set_power, -}; - -static const struct udevice_id rockchip_dwmmc_pwrseq_ids[] = { - { .compatible = "mmc-pwrseq-emmc" }, - { } -}; - -U_BOOT_DRIVER(rockchip_dwmmc_pwrseq_drv) = { - .name = "mmc_pwrseq_emmc", - .id = UCLASS_PWRSEQ, - .of_match = rockchip_dwmmc_pwrseq_ids, - .ops = &rockchip_dwmmc_pwrseq_ops, -}; -#endif From ba74bc1a0e4c34fadd5794d03e5c733baccb85f0 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Tue, 16 Feb 2021 10:16:55 +0900 Subject: [PATCH 12/13] ARM: mach-meson: select MMC_PWRSEQ config Before time, PWRSEQ is selected since below commit. commit 262d34363373 ("board: amlogic: select PWRSEQ for all amlogic platform") Select MMC_PWRSEQ config because of introducing CONFIG_MMC_PWRSEQ for only eMMC module. Signed-off-by: Jaehoon Chung --- arch/arm/mach-meson/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-meson/Kconfig b/arch/arm/mach-meson/Kconfig index 513a33dae2..6cba2c40dd 100644 --- a/arch/arm/mach-meson/Kconfig +++ b/arch/arm/mach-meson/Kconfig @@ -9,6 +9,7 @@ config MESON64_COMMON select SYSCON select REGMAP select PWRSEQ + select MMC_PWRSEQ select BOARD_LATE_INIT imply CMD_DM From 144d0574d5f3652008ef400e86cc66db5ef88736 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Tue, 16 Feb 2021 10:16:56 +0900 Subject: [PATCH 13/13] configs: enable CONFIG_MMC_PWRSEQ configuration Enable CONFIG_MMC_PWRSEQ configuration about boards that is using rockchip_dw_mmc driver. Signed-off-by: Jaehoon Chung --- configs/chromebit_mickey_defconfig | 1 + configs/chromebook_bob_defconfig | 1 + configs/chromebook_jerry_defconfig | 1 + configs/chromebook_minnie_defconfig | 1 + configs/chromebook_speedy_defconfig | 1 + 5 files changed, 5 insertions(+) diff --git a/configs/chromebit_mickey_defconfig b/configs/chromebit_mickey_defconfig index ba1215bca6..c09b63b946 100644 --- a/configs/chromebit_mickey_defconfig +++ b/configs/chromebit_mickey_defconfig @@ -63,6 +63,7 @@ CONFIG_CROS_EC_KEYB=y CONFIG_CROS_EC=y CONFIG_CROS_EC_SPI=y CONFIG_PWRSEQ=y +CONFIG_MMC_PWRSEQ=y # CONFIG_SPL_DM_MMC is not set CONFIG_MMC_DW=y CONFIG_MMC_DW_ROCKCHIP=y diff --git a/configs/chromebook_bob_defconfig b/configs/chromebook_bob_defconfig index 73635f0d13..a846b6470f 100644 --- a/configs/chromebook_bob_defconfig +++ b/configs/chromebook_bob_defconfig @@ -55,6 +55,7 @@ CONFIG_CROS_EC_KEYB=y CONFIG_CROS_EC=y CONFIG_CROS_EC_SPI=y CONFIG_PWRSEQ=y +CONFIG_MMC_PWRSEQ=y CONFIG_MMC_DW=y CONFIG_MMC_DW_ROCKCHIP=y CONFIG_MMC_SDHCI=y diff --git a/configs/chromebook_jerry_defconfig b/configs/chromebook_jerry_defconfig index dada557952..692b630174 100644 --- a/configs/chromebook_jerry_defconfig +++ b/configs/chromebook_jerry_defconfig @@ -65,6 +65,7 @@ CONFIG_CROS_EC_KEYB=y CONFIG_CROS_EC=y CONFIG_CROS_EC_SPI=y CONFIG_PWRSEQ=y +CONFIG_MMC_PWRSEQ=y # CONFIG_SPL_DM_MMC is not set CONFIG_MMC_DW=y CONFIG_MMC_DW_ROCKCHIP=y diff --git a/configs/chromebook_minnie_defconfig b/configs/chromebook_minnie_defconfig index 985ca94770..ae55842e3b 100644 --- a/configs/chromebook_minnie_defconfig +++ b/configs/chromebook_minnie_defconfig @@ -65,6 +65,7 @@ CONFIG_CROS_EC_KEYB=y CONFIG_CROS_EC=y CONFIG_CROS_EC_SPI=y CONFIG_PWRSEQ=y +CONFIG_MMC_PWRSEQ=y # CONFIG_SPL_DM_MMC is not set CONFIG_MMC_DW=y CONFIG_MMC_DW_ROCKCHIP=y diff --git a/configs/chromebook_speedy_defconfig b/configs/chromebook_speedy_defconfig index e3d4c30739..4b460ee6a9 100644 --- a/configs/chromebook_speedy_defconfig +++ b/configs/chromebook_speedy_defconfig @@ -64,6 +64,7 @@ CONFIG_CROS_EC_KEYB=y CONFIG_CROS_EC=y CONFIG_CROS_EC_SPI=y CONFIG_PWRSEQ=y +CONFIG_MMC_PWRSEQ=y # CONFIG_SPL_DM_MMC is not set CONFIG_MMC_DW=y CONFIG_MMC_DW_ROCKCHIP=y