summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2017-06-26 16:36:15 -0700
committerBin Meng <bmeng.cn@gmail.com>2017-06-27 16:31:30 +0800
commitda2364cc14a0b34411c4a228ae687a23504afe04 (patch)
tree137855067bd0e1c6413fb6cbe4341a531cf9ef88 /drivers
parent7df4ff2c2689a6d3c16eb0c3cce098fcac622b0c (diff)
Revert "x86: Convert MMC to driver model"
This reverts commit ddb3ac3c716f56cead695444e65a7ba7b0946555. With MMC converted to driver model, SCSI driver is broken due to zero address access at (ops->read) in block_dread() function. The fix (SCSI driver converted to DM) is ready in u-boot-dm branch, but it is too late for this relese to get that in. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/pci_mmc.c86
1 files changed, 26 insertions, 60 deletions
diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c
index 6db89779ba..e39b476834 100644
--- a/drivers/mmc/pci_mmc.c
+++ b/drivers/mmc/pci_mmc.c
@@ -6,71 +6,37 @@
*/
#include <common.h>
-#include <dm.h>
#include <errno.h>
#include <malloc.h>
-#include <mapmem.h>
#include <sdhci.h>
#include <asm/pci.h>
-struct pci_mmc_plat {
- struct mmc_config cfg;
- struct mmc mmc;
-};
-
-struct pci_mmc_priv {
- struct sdhci_host host;
- void *base;
-};
-
-static int pci_mmc_probe(struct udevice *dev)
+int pci_mmc_init(const char *name, struct pci_device_id *mmc_supported)
{
- struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
- struct pci_mmc_plat *plat = dev_get_platdata(dev);
- struct pci_mmc_priv *priv = dev_get_priv(dev);
- struct sdhci_host *host = &priv->host;
- u32 ioaddr;
+ struct sdhci_host *mmc_host;
+ u32 iobase;
int ret;
-
- dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &ioaddr);
- host->ioaddr = map_sysmem(ioaddr, 0);
- host->name = dev->name;
- ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0);
- if (ret)
- return ret;
- host->mmc = &plat->mmc;
- host->mmc->priv = &priv->host;
- host->mmc->dev = dev;
- upriv->mmc = host->mmc;
-
- return sdhci_probe(dev);
+ int i;
+
+ for (i = 0; ; i++) {
+ struct udevice *dev;
+
+ ret = pci_find_device_id(mmc_supported, i, &dev);
+ if (ret)
+ return ret;
+ mmc_host = malloc(sizeof(struct sdhci_host));
+ if (!mmc_host)
+ return -ENOMEM;
+
+ mmc_host->name = name;
+ dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase);
+ mmc_host->ioaddr = (void *)(ulong)iobase;
+ mmc_host->quirks = 0;
+ mmc_host->max_clk = 0;
+ ret = add_sdhci(mmc_host, 0, 0);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
}
-
-static int pci_mmc_bind(struct udevice *dev)
-{
- struct pci_mmc_plat *plat = dev_get_platdata(dev);
-
- return sdhci_bind(dev, &plat->mmc, &plat->cfg);
-}
-
-U_BOOT_DRIVER(pci_mmc) = {
- .name = "pci_mmc",
- .id = UCLASS_MMC,
- .bind = pci_mmc_bind,
- .probe = pci_mmc_probe,
- .ops = &sdhci_ops,
- .priv_auto_alloc_size = sizeof(struct pci_mmc_priv),
- .platdata_auto_alloc_size = sizeof(struct pci_mmc_plat),
-};
-
-static struct pci_device_id mmc_supported[] = {
- { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT_SDIO) },
- { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT_SD) },
- { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT_EMMC2) },
- { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_SDIO) },
- { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TCF_SDIO_0) },
- { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TCF_SDIO_1) },
- {},
-};
-
-U_BOOT_PCI_DEVICE(pci_mmc, mmc_supported);