]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
dm: mmc: Add an MMC uclass
authorSimon Glass <sjg@chromium.org>
Tue, 23 Jun 2015 21:38:48 +0000 (15:38 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 21 Jul 2015 23:39:25 +0000 (17:39 -0600)
Add basic support for MMC, providing a uclass which can set up an MMC
device. This allows MMC drivers to move to using driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/mmc/Kconfig
drivers/mmc/Makefile
drivers/mmc/mmc-uclass.c [new file with mode: 0644]
drivers/mmc/mmc.c
include/dm/uclass-id.h
include/mmc.h

index 7ba85a2b62c45b5f968dbddc1994d7f174163e9a..3e835f7bca0b6c374e94a7b0f09c7d51654fad2e 100644 (file)
@@ -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
index ed7368773516753e994e1c60300b96c6f5620b87..2680c6342b1308a325c42187e05e9d79c4115a67 100644 (file)
@@ -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
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
new file mode 100644 (file)
index 0000000..777489f
--- /dev/null
@@ -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),
+};
index 79e6feeb13aca8a3ac55f92478307bf8dbfc8319..4eab274f732794b136ac4f88ac9231b42065cf33 100644 (file)
@@ -1761,8 +1761,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(',');
index a961648645eaa3d17ac3b071723a44525d9ea51f..cba7c0a45eb094885ed9b8131886ccad46e57f0e 100644 (file)
@@ -36,6 +36,7 @@ enum uclass_id {
        UCLASS_LED,             /* Light-emitting diode (LED) */
        UCLASS_LPC,             /* x86 'low pin count' interface */
        UCLASS_MASS_STORAGE,    /* Mass storage device */
+       UCLASS_MMC,             /* SD / MMC card or chip */
        UCLASS_MOD_EXP,         /* RSA Mod Exp device */
        UCLASS_PCH,             /* x86 platform controller hub */
        UCLASS_PCI,             /* PCI bus */
index dd98b3b8acfe1cd98c8f3a68a4534d8f262af949..cda9a19ce0aab545faf5bc70ced71e34f0a48ad3 100644 (file)
 #define MMC_NUM_BOOT_PARTITION 2
 #define MMC_PART_RPMB           3       /* RPMB partition number */
 
+/* Driver model support */
+
+/**
+ * struct mmc_uclass_priv - Holds information about a device used by the uclass
+ */
+struct mmc_uclass_priv {
+       struct mmc *mmc;
+};
+
+/**
+ * mmc_get_mmc_dev() - get the MMC struct pointer for a device
+ *
+ * Provided that the device is already probed and ready for use, this value
+ * will be available.
+ *
+ * @dev:       Device
+ * @return associated mmc struct pointer if available, else NULL
+ */
+struct mmc *mmc_get_mmc_dev(struct udevice *dev);
+
+/* End of driver model support */
+
 struct mmc_cid {
        unsigned long psn;
        unsigned short oid;