diff options
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/Kconfig | 10 | ||||
-rw-r--r-- | drivers/mmc/Makefile | 3 | ||||
-rw-r--r-- | drivers/mmc/mmc-uclass.c | 34 | ||||
-rw-r--r-- | drivers/mmc/mmc.c | 10 | ||||
-rw-r--r-- | drivers/mmc/sandbox_mmc.c | 25 |
5 files changed, 80 insertions, 2 deletions
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index 7ba85a2b62..3e835f7bca 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -1,5 +1,15 @@ menu "MMC Host controller Support" +config DM_MMC + bool "Enable MMC controllers using Driver Model" + depends on DM + help + This enables the MultiMediaCard (MMC) uclass which suports MMC and + Secure Digital I/O (SDIO) cards. Both removable (SD, micro-SD, etc.) + and non-removable (e.g. eMMC chip) devices are supported. These + appear as block devices in U-Boot and can support filesystems such + as EXT4 and FAT. + config SH_SDHI bool "SuperH/Renesas ARM SoCs on-chip SDHI host controller support" depends on RMOBILE diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index ed73687735..286df2fc7d 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -5,6 +5,8 @@ # SPDX-License-Identifier: GPL-2.0+ # +obj-$(CONFIG_DM_MMC) += mmc-uclass.o + obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o obj-$(CONFIG_BCM2835_SDHCI) += bcm2835_sdhci.o obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o @@ -29,6 +31,7 @@ obj-$(CONFIG_PXA_MMC_GENERIC) += pxa_mmc_gen.o obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o obj-$(CONFIG_S3C_SDI) += s3c_sdi.o obj-$(CONFIG_S5P_SDHCI) += s5p_sdhci.o +obj-$(CONFIG_SANDBOX) += sandbox_mmc.o obj-$(CONFIG_SDHCI) += sdhci.o obj-$(CONFIG_SH_MMCIF) += sh_mmcif.o obj-$(CONFIG_SH_SDHI) += sh_sdhi.o diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c new file mode 100644 index 0000000000..777489f5d8 --- /dev/null +++ b/drivers/mmc/mmc-uclass.c @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2015 Google, Inc + * Written by Simon Glass <sjg@chromium.org> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <mmc.h> +#include <dm.h> +#include <dm/lists.h> +#include <dm/root.h> + +struct mmc *mmc_get_mmc_dev(struct udevice *dev) +{ + struct mmc_uclass_priv *upriv; + + if (!device_active(dev)) + return NULL; + upriv = dev_get_uclass_priv(dev); + return upriv->mmc; +} + +U_BOOT_DRIVER(mmc) = { + .name = "mmc", + .id = UCLASS_MMC, +}; + +UCLASS_DRIVER(mmc) = { + .id = UCLASS_MMC, + .name = "mmc", + .flags = DM_UC_FLAG_SEQ_ALIAS, + .per_device_auto_alloc_size = sizeof(struct mmc_uclass_priv), +}; diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 79e6feeb13..da47037a30 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -250,14 +250,18 @@ static ulong mmc_bread(int dev_num, lbaint_t start, lbaint_t blkcnt, void *dst) return 0; } - if (mmc_set_blocklen(mmc, mmc->read_bl_len)) + if (mmc_set_blocklen(mmc, mmc->read_bl_len)) { + debug("%s: Failed to set blocklen\n", __func__); return 0; + } do { cur = (blocks_todo > mmc->cfg->b_max) ? mmc->cfg->b_max : blocks_todo; - if(mmc_read_blocks(mmc, dst, start, cur) != cur) + if (mmc_read_blocks(mmc, dst, start, cur) != cur) { + debug("%s: Failed to read blocks\n", __func__); return 0; + } blocks_todo -= cur; start += cur; dst += cur * mmc->read_bl_len; @@ -1761,8 +1765,10 @@ int mmc_initialize(bd_t *bis) INIT_LIST_HEAD (&mmc_devices); cur_dev_num = 0; +#ifndef CONFIG_DM_MMC if (board_mmc_init(bis) < 0) cpu_mmc_init(bis); +#endif #ifndef CONFIG_SPL_BUILD print_mmc_devices(','); diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c new file mode 100644 index 0000000000..f4646a824f --- /dev/null +++ b/drivers/mmc/sandbox_mmc.c @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2015 Google, Inc + * Written by Simon Glass <sjg@chromium.org> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <dm.h> +#include <errno.h> +#include <mmc.h> +#include <asm/test.h> + +DECLARE_GLOBAL_DATA_PTR; + +static const struct udevice_id sandbox_mmc_ids[] = { + { .compatible = "sandbox,mmc" }, + { } +}; + +U_BOOT_DRIVER(warm_mmc_sandbox) = { + .name = "mmc_sandbox", + .id = UCLASS_MMC, + .of_match = sandbox_mmc_ids, +}; |