diff options
author | Tom Rini <trini@konsulko.com> | 2019-07-31 08:34:35 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-07-31 08:34:35 -0400 |
commit | 3fe483b13ec96aacfeb6fa9b7c2a5dc8bb38a866 (patch) | |
tree | c6d04d4d492ea8c354ec0b853355c4a0cdca3fdf | |
parent | a239147fa2c0c3fe849ccaffd72c4dc4cae2be71 (diff) | |
parent | fea3939d31ccde5b8372bc5506a35ac169de03c8 (diff) |
Merge tag 'mmc-7-31' of https://gitlab.denx.de/u-boot/custodians/u-boot-mmc
A new mmc/sd block test case
Bug fixes for sdhci and mv_sdhci
-rw-r--r-- | drivers/mmc/mmc.c | 2 | ||||
-rw-r--r-- | drivers/mmc/mtk-sd.c | 3 | ||||
-rw-r--r-- | drivers/mmc/mv_sdhci.c | 6 | ||||
-rw-r--r-- | drivers/mmc/sdhci.c | 2 | ||||
-rw-r--r-- | test/py/tests/test_mmc_wr.py | 105 |
5 files changed, 113 insertions, 5 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index c9aa13b409a..eecc7d687e3 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -2819,12 +2819,12 @@ int mmc_start_init(struct mmc *mmc) MMC_CAP(MMC_LEGACY) | MMC_MODE_1BIT; #if !defined(CONFIG_MMC_BROKEN_CD) - /* we pretend there's no card when init is NULL */ no_card = mmc_getcd(mmc) == 0; #else no_card = 0; #endif #if !CONFIG_IS_ENABLED(DM_MMC) + /* we pretend there's no card when init is NULL */ no_card = no_card || (mmc->cfg->ops->init == NULL); #endif if (no_card) { diff --git a/drivers/mmc/mtk-sd.c b/drivers/mmc/mtk-sd.c index e0ac3e9d695..49085090c82 100644 --- a/drivers/mmc/mtk-sd.c +++ b/drivers/mmc/mtk-sd.c @@ -13,6 +13,7 @@ #include <errno.h> #include <malloc.h> #include <stdbool.h> +#include <watchdog.h> #include <asm/gpio.h> #include <dm/pinctrl.h> #include <linux/bitops.h> @@ -623,6 +624,8 @@ static int msdc_start_data(struct msdc_host *host, struct mmc_data *data) u32 size; int ret; + WATCHDOG_RESET(); + if (data->flags == MMC_DATA_WRITE) host->last_data_write = 1; diff --git a/drivers/mmc/mv_sdhci.c b/drivers/mmc/mv_sdhci.c index bf26d2e4e26..f5f3e432471 100644 --- a/drivers/mmc/mv_sdhci.c +++ b/drivers/mmc/mv_sdhci.c @@ -114,6 +114,9 @@ static int mv_sdhci_probe(struct udevice *dev) host->name = MVSDH_NAME; host->ioaddr = (void *)devfdt_get_addr(dev); host->quirks = SDHCI_QUIRK_32BIT_DMA_ADDR | SDHCI_QUIRK_WAIT_SEND_CMD; + host->mmc = &plat->mmc; + host->mmc->dev = dev; + host->mmc->priv = host; ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0); if (ret) @@ -124,9 +127,6 @@ static int mv_sdhci_probe(struct udevice *dev) sdhci_mvebu_mbus_config(host->ioaddr); } - host->mmc = &plat->mmc; - host->mmc->dev = dev; - host->mmc->priv = host; upriv->mmc = host->mmc; return sdhci_probe(dev); diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 0a0770cc203..2779bca93f0 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -623,7 +623,7 @@ static int sdhci_init(struct mmc *mmc) #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_GPIO) struct udevice *dev = mmc->dev; - gpio_request_by_name(dev, "cd-gpio", 0, + gpio_request_by_name(dev, "cd-gpios", 0, &host->cd_gpio, GPIOD_IS_IN); #endif diff --git a/test/py/tests/test_mmc_wr.py b/test/py/tests/test_mmc_wr.py new file mode 100644 index 00000000000..601279a6a4a --- /dev/null +++ b/test/py/tests/test_mmc_wr.py @@ -0,0 +1,105 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2019, Texas Instrument +# Author: Jean-Jacques Hiblot <jjhiblot@ti.com> + +# Test U-Boot's "mmc write" command. The test generates random data, writes it +# to the eMMC or SD card, then reads it back and performs a comparison. + +import pytest +import u_boot_utils + +""" +This test relies on boardenv_* to containing configuration values to define +which MMC devices should be tested. For example: + +env__mmc_wr_configs = ( + { + "fixture_id": "emmc-boot0", + "is_emmc": True, + "devid": 1, + "partid": 1, + "sector": 0x10, + "count": 100, + "test_iterations": 50, + }, + { + "fixture_id": "emmc-boot1", + "is_emmc": True, + "devid": 1, + "partid": 2, + "sector": 0x10, + "count": 100, + "test_iterations": 50, + }, +) + +""" + +@pytest.mark.buildconfigspec('cmd_mmc','cmd_memory') +def test_mmc_wr(u_boot_console, env__mmc_wr_config): + """Test the "mmc write" command. + + Args: + u_boot_console: A U-Boot console connection. + env__mmc_wr_config: The single MMC configuration on which + to run the test. See the file-level comment above for details + of the format. + + Returns: + Nothing. + """ + + is_emmc = env__mmc_wr_config['is_emmc'] + devid = env__mmc_wr_config['devid'] + partid = env__mmc_wr_config.get('partid', 0) + sector = env__mmc_wr_config.get('sector', 0) + count_sectors = env__mmc_wr_config.get('count', 1) + test_iterations = env__mmc_wr_config.get('test_iterations', 1) + + + count_bytes = count_sectors * 512 + bcfg = u_boot_console.config.buildconfig + ram_base = u_boot_utils.find_ram_base(u_boot_console) + src_addr = '0x%08x' % ram_base + dst_addr = '0x%08x' % (ram_base + count_bytes) + + + for i in range(test_iterations): + # Generate random data + cmd = 'random %s %x' % (src_addr, count_bytes) + response = u_boot_console.run_command(cmd) + good_response = '%d bytes filled with random data' % (count_bytes) + assert good_response in response + + # Select MMC device + cmd = 'mmc dev %d' % devid + if is_emmc: + cmd += ' %d' % partid + response = u_boot_console.run_command(cmd) + assert 'no card present' not in response + if is_emmc: + partid_response = "(part %d)" % partid + else: + partid_response = "" + good_response = 'mmc%d%s is current device' % (devid, partid_response) + assert good_response in response + + # Write data + cmd = 'mmc write %s %x %x' % (src_addr, sector, count_sectors) + response = u_boot_console.run_command(cmd) + good_response = 'MMC write: dev # %d, block # %d, count %d ... %d blocks written: OK' % ( + devid, sector, count_sectors, count_sectors) + assert good_response in response + + # Read data + cmd = 'mmc read %s %x %x' % (dst_addr, sector, count_sectors) + response = u_boot_console.run_command(cmd) + good_response = 'MMC read: dev # %d, block # %d, count %d ... %d blocks read: OK' % ( + devid, sector, count_sectors, count_sectors) + assert good_response in response + + # Compare src and dst data + cmd = 'cmp.b %s %s %x' % (src_addr, dst_addr, count_bytes) + response = u_boot_console.run_command(cmd) + good_response = 'Total of %d byte(s) were the same' % (count_bytes) + assert good_response in response |