From patchwork Mon Jan 20 10:20:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 239795 List-Id: U-Boot discussion From: jh80.chung at samsung.com (Jaehoon Chung) Date: Mon, 20 Jan 2020 19:20:26 +0900 Subject: [RFC 1/4] mmc: bcm2835_sdhci: use phys2bus macro when dma address is accessed In-Reply-To: <20200120102029.14264-1-jh80.chung@samsung.com> References: <20200120102029.14264-1-jh80.chung@samsung.com> Message-ID: <20200120102029.14264-2-jh80.chung@samsung.com> Use phys2bus macro when dma address is accessed. After applied it, SDMA mode can be used. When thor download is used, - Before : 1.8MB/s - After : 7.23MB/s Signed-off-by: Jaehoon Chung --- drivers/mmc/bcm2835_sdhci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c index 39c93db275..222ba22d66 100644 --- a/drivers/mmc/bcm2835_sdhci.c +++ b/drivers/mmc/bcm2835_sdhci.c @@ -46,6 +46,7 @@ #include #include #include +#include /* 400KHz is max freq for card ID etc. Use that as min */ #define MIN_FREQ 400000 @@ -86,7 +87,11 @@ static inline void bcm2835_sdhci_raw_writel(struct sdhci_host *host, u32 val, ; } - writel(val, host->ioaddr + reg); + if (reg == SDHCI_DMA_ADDRESS) + writel(phys_to_bus((unsigned long)val), host->ioaddr + reg); + else + writel(val, host->ioaddr + reg); + bcm_host->last_write = timer_get_us(); } From patchwork Mon Jan 20 10:20:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 239798 List-Id: U-Boot discussion From: jh80.chung at samsung.com (Jaehoon Chung) Date: Mon, 20 Jan 2020 19:20:27 +0900 Subject: [RFC 2/4] mmc: sdhci: add quriks relevant to broken SDMA In-Reply-To: <20200120102029.14264-1-jh80.chung@samsung.com> References: <20200120102029.14264-1-jh80.chung@samsung.com> Message-ID: <20200120102029.14264-3-jh80.chung@samsung.com> ADd quirks relevant to broken SDMA. If set to SDHCI_QUIRK_BROKEN_SDMA, it should be run the pio mode. Signed-off-by: Jaehoon Chung --- drivers/mmc/sdhci.c | 10 ++++++++-- include/sdhci.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 01fa5a9d4d..acda997fbc 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -728,12 +728,18 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, #ifdef CONFIG_MMC_SDHCI_SDMA if (!(caps & SDHCI_CAN_DO_SDMA)) { - printf("%s: Your controller doesn't support SDMA!!\n", + if (host->quirks & SDHCI_QUIRK_BROKEN_SDMA) { + caps &= ~SDHCI_CAN_DO_SDMA; + goto skip; + } else { + printf("%s: Your controller doesn't support SDMA!!\n", __func__); - return -EINVAL; + return -EINVAL; + } } host->flags |= USE_SDMA; +skip: #endif #if CONFIG_IS_ENABLED(MMC_SDHCI_ADMA) if (!(caps & SDHCI_CAN_DO_ADMA2)) { diff --git a/include/sdhci.h b/include/sdhci.h index 01addb7a60..9865a9d6c8 100644 --- a/include/sdhci.h +++ b/include/sdhci.h @@ -243,6 +243,7 @@ #define SDHCI_QUIRK_WAIT_SEND_CMD (1 << 6) #define SDHCI_QUIRK_USE_WIDE8 (1 << 8) #define SDHCI_QUIRK_NO_1_8_V (1 << 9) +#define SDHCI_QUIRK_BROKEN_SDMA (1 << 10) /* to make gcc happy */ struct sdhci_host; From patchwork Mon Jan 20 10:20:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 239799 List-Id: U-Boot discussion From: jh80.chung at samsung.com (Jaehoon Chung) Date: Mon, 20 Jan 2020 19:20:28 +0900 Subject: [RFC 3/4] mmc: bcm2835_sdhci: set SDHCI_QUIRK_BROKEN_SDMA flag In-Reply-To: <20200120102029.14264-1-jh80.chung@samsung.com> References: <20200120102029.14264-1-jh80.chung@samsung.com> Message-ID: <20200120102029.14264-4-jh80.chung@samsung.com> RPI4 is used device-tree that taken from firmware. mmcnr at 73e00000 is enabled on device-tree, so it's probed on u-boot side. Because it's for SDIO interface, it doesn't need to probe. When SDMA is enabled, mmcnr's probe is always failed. Below log is unnecessary : sdhci_setup_cfg: Your controller doesn't support SDMA!! mmcnr at 7e30000 - probe failed: -22 Signed-off-by: Jaehoon Chung --- drivers/mmc/bcm2835_sdhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c index 222ba22d66..f763c9a36e 100644 --- a/drivers/mmc/bcm2835_sdhci.c +++ b/drivers/mmc/bcm2835_sdhci.c @@ -216,7 +216,8 @@ static int bcm2835_sdhci_probe(struct udevice *dev) host->name = dev->name; host->ioaddr = (void *)base; host->quirks = SDHCI_QUIRK_BROKEN_VOLTAGE | SDHCI_QUIRK_BROKEN_R1B | - SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_NO_HISPD_BIT; + SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_NO_HISPD_BIT | + SDHCI_QUIRK_BROKEN_SDMA; host->max_clk = emmc_freq; host->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; host->ops = &bcm2835_ops; From patchwork Mon Jan 20 10:20:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 239796 List-Id: U-Boot discussion From: jh80.chung at samsung.com (Jaehoon Chung) Date: Mon, 20 Jan 2020 19:20:29 +0900 Subject: [RFC 4/4] configs: rpi_4_32b_defconfig: enable SDHCI_SDMA config In-Reply-To: <20200120102029.14264-1-jh80.chung@samsung.com> References: <20200120102029.14264-1-jh80.chung@samsung.com> Message-ID: <20200120102029.14264-5-jh80.chung@samsung.com> Enable SDHCI_SDMA configuration. Signed-off-by: Jaehoon Chung --- configs/rpi_4_32b_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/rpi_4_32b_defconfig b/configs/rpi_4_32b_defconfig index 00f80f71ad..8fbadc0bc8 100644 --- a/configs/rpi_4_32b_defconfig +++ b/configs/rpi_4_32b_defconfig @@ -23,6 +23,7 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y CONFIG_DM_KEYBOARD=y CONFIG_DM_MMC=y CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_SDMA=y CONFIG_MMC_SDHCI_BCM2835=y CONFIG_PINCTRL=y # CONFIG_PINCTRL_GENERIC is not set