Bin Meng | aada627 | 2014-12-17 15:50:46 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <errno.h> |
| 9 | #include <malloc.h> |
| 10 | #include <pci.h> |
| 11 | #include <pci_ids.h> |
| 12 | #include <sdhci.h> |
| 13 | |
| 14 | static struct pci_device_id mmc_supported[] = { |
| 15 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TCF_SDIO_0 }, |
| 16 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TCF_SDIO_1 }, |
| 17 | { } |
| 18 | }; |
| 19 | |
| 20 | int cpu_mmc_init(bd_t *bis) |
| 21 | { |
| 22 | struct sdhci_host *mmc_host; |
| 23 | pci_dev_t devbusfn; |
| 24 | u32 iobase; |
| 25 | int ret; |
| 26 | int i; |
| 27 | |
| 28 | for (i = 0; i < ARRAY_SIZE(mmc_supported); i++) { |
| 29 | devbusfn = pci_find_devices(mmc_supported, i); |
| 30 | if (devbusfn == -1) |
| 31 | return -ENODEV; |
| 32 | |
| 33 | mmc_host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host)); |
| 34 | if (!mmc_host) |
| 35 | return -ENOMEM; |
| 36 | |
| 37 | mmc_host->name = "Topcliff SDHCI"; |
| 38 | pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_0, &iobase); |
| 39 | mmc_host->ioaddr = (void *)iobase; |
| 40 | mmc_host->quirks = 0; |
| 41 | ret = add_sdhci(mmc_host, 0, 0); |
| 42 | if (ret) |
| 43 | return ret; |
| 44 | } |
| 45 | |
| 46 | return 0; |
| 47 | } |