2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2015-01-28 05:13:39 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015, Google, Inc
|
|
|
|
* Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2017-07-31 02:24:01 +00:00
|
|
|
#include <dm.h>
|
2015-01-28 05:13:39 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <malloc.h>
|
2017-07-31 02:24:01 +00:00
|
|
|
#include <mapmem.h>
|
2015-01-28 05:13:39 +00:00
|
|
|
#include <sdhci.h>
|
|
|
|
#include <asm/pci.h>
|
|
|
|
|
2017-07-31 02:24:01 +00:00
|
|
|
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)
|
2015-01-28 05:13:39 +00:00
|
|
|
{
|
2017-07-31 02:24:01 +00:00
|
|
|
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;
|
2015-01-28 05:13:39 +00:00
|
|
|
int ret;
|
2017-07-31 02:24:01 +00:00
|
|
|
|
2018-02-15 08:09:43 +00:00
|
|
|
host->ioaddr = (void *)dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0,
|
|
|
|
PCI_REGION_MEM);
|
2017-07-31 02:24:01 +00:00
|
|
|
host->name = dev->name;
|
2019-08-06 02:47:56 +00:00
|
|
|
host->mmc = &plat->mmc;
|
|
|
|
host->mmc->dev = dev;
|
2017-07-31 02:24:01 +00:00
|
|
|
ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
host->mmc->priv = &priv->host;
|
|
|
|
upriv->mmc = host->mmc;
|
|
|
|
|
|
|
|
return sdhci_probe(dev);
|
2015-01-28 05:13:39 +00:00
|
|
|
}
|
2017-07-31 02:24:01 +00:00
|
|
|
|
|
|
|
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[] = {
|
2017-08-09 07:21:00 +00:00
|
|
|
{ PCI_DEVICE_CLASS(PCI_CLASS_SYSTEM_SDHCI << 8, 0xffff00) },
|
2017-07-31 02:24:01 +00:00
|
|
|
{},
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_PCI_DEVICE(pci_mmc, mmc_supported);
|