]>
Commit | Line | Data |
---|---|---|
91785f70 SG |
1 | /* |
2 | * Copyright (C) 2015, Google, Inc | |
3 | * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com> | |
4 | * | |
5 | * SPDX-License-Identifier: GPL-2.0+ | |
6 | */ | |
7 | ||
8 | #include <common.h> | |
9 | #include <errno.h> | |
10 | #include <malloc.h> | |
11 | #include <sdhci.h> | |
12 | #include <asm/pci.h> | |
13 | ||
4abe8e40 | 14 | int pci_mmc_init(const char *name, struct pci_device_id *mmc_supported) |
91785f70 SG |
15 | { |
16 | struct sdhci_host *mmc_host; | |
91785f70 SG |
17 | u32 iobase; |
18 | int ret; | |
19 | int i; | |
20 | ||
4abe8e40 SG |
21 | for (i = 0; ; i++) { |
22 | struct udevice *dev; | |
91785f70 | 23 | |
4abe8e40 SG |
24 | ret = pci_find_device_id(mmc_supported, i, &dev); |
25 | if (ret) | |
26 | return ret; | |
91785f70 SG |
27 | mmc_host = malloc(sizeof(struct sdhci_host)); |
28 | if (!mmc_host) | |
29 | return -ENOMEM; | |
30 | ||
cacd1d2f | 31 | mmc_host->name = name; |
4abe8e40 | 32 | dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase); |
91785f70 SG |
33 | mmc_host->ioaddr = (void *)iobase; |
34 | mmc_host->quirks = 0; | |
35 | ret = add_sdhci(mmc_host, 0, 0); | |
36 | if (ret) | |
37 | return ret; | |
38 | } | |
39 | ||
40 | return 0; | |
41 | } |