2015-01-28 13:13:39 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015, Google, Inc
|
|
|
|
* Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <sdhci.h>
|
|
|
|
#include <asm/pci.h>
|
|
|
|
|
2015-11-30 04:18:08 +08:00
|
|
|
int pci_mmc_init(const char *name, struct pci_device_id *mmc_supported)
|
2015-01-28 13:13:39 +08:00
|
|
|
{
|
|
|
|
struct sdhci_host *mmc_host;
|
|
|
|
u32 iobase;
|
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
|
2015-11-30 04:18:08 +08:00
|
|
|
for (i = 0; ; i++) {
|
|
|
|
struct udevice *dev;
|
2015-01-28 13:13:39 +08:00
|
|
|
|
2015-11-30 04:18:08 +08:00
|
|
|
ret = pci_find_device_id(mmc_supported, i, &dev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2015-01-28 13:13:39 +08:00
|
|
|
mmc_host = malloc(sizeof(struct sdhci_host));
|
|
|
|
if (!mmc_host)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2016-04-22 19:59:31 +08:00
|
|
|
mmc_host->name = name;
|
2015-11-30 04:18:08 +08:00
|
|
|
dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase);
|
2016-09-26 11:33:10 +08:00
|
|
|
mmc_host->ioaddr = (void *)(ulong)iobase;
|
2015-01-28 13:13:39 +08:00
|
|
|
mmc_host->quirks = 0;
|
2017-01-17 22:58:48 +08:00
|
|
|
mmc_host->max_clk = 0;
|
2015-01-28 13:13:39 +08:00
|
|
|
ret = add_sdhci(mmc_host, 0, 0);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|