Michal Simek | 293eb33 | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 1 | /* |
Michal Simek | d9ae52c | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 2 | * (C) Copyright 2013 - 2015 Xilinx, Inc. |
Michal Simek | 293eb33 | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 3 | * |
| 4 | * Xilinx Zynq SD Host Controller Interface |
| 5 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | 293eb33 | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Michal Simek | d9ae52c | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 10 | #include <dm.h> |
Michal Simek | 345d3c0 | 2014-02-24 11:16:31 +0100 | [diff] [blame] | 11 | #include <fdtdec.h> |
| 12 | #include <libfdt.h> |
Michal Simek | 293eb33 | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 13 | #include <malloc.h> |
| 14 | #include <sdhci.h> |
Michal Simek | 293eb33 | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 15 | |
Michal Simek | d9ae52c | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 16 | static int arasan_sdhci_probe(struct udevice *dev) |
Michal Simek | 293eb33 | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 17 | { |
Michal Simek | d9ae52c | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 18 | struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); |
| 19 | struct sdhci_host *host = dev_get_priv(dev); |
Michal Simek | 293eb33 | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 20 | |
Siva Durga Prasad Paladugu | eddabd1 | 2014-07-08 15:31:04 +0530 | [diff] [blame] | 21 | host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD | |
Siva Durga Prasad Paladugu | f9ec45d | 2014-01-22 09:17:09 +0100 | [diff] [blame] | 22 | SDHCI_QUIRK_BROKEN_R1B; |
Michal Simek | 293eb33 | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 23 | host->version = sdhci_readw(host, SDHCI_HOST_VERSION); |
| 24 | |
Siva Durga Prasad Paladugu | b8a9beb | 2015-11-25 11:51:37 +0530 | [diff] [blame] | 25 | add_sdhci(host, CONFIG_ZYNQ_SDHCI_MAX_FREQ, 0); |
Michal Simek | d9ae52c | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 26 | |
| 27 | upriv->mmc = host->mmc; |
| 28 | |
Michal Simek | 293eb33 | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 29 | return 0; |
| 30 | } |
Michal Simek | d9ae52c | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 31 | |
| 32 | static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev) |
| 33 | { |
| 34 | struct sdhci_host *host = dev_get_priv(dev); |
| 35 | |
| 36 | host->name = (char *)dev->name; |
| 37 | host->ioaddr = (void *)dev_get_addr(dev); |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | static const struct udevice_id arasan_sdhci_ids[] = { |
| 43 | { .compatible = "arasan,sdhci-8.9a" }, |
| 44 | { } |
| 45 | }; |
| 46 | |
| 47 | U_BOOT_DRIVER(arasan_sdhci_drv) = { |
| 48 | .name = "arasan_sdhci", |
| 49 | .id = UCLASS_MMC, |
| 50 | .of_match = arasan_sdhci_ids, |
| 51 | .ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata, |
| 52 | .probe = arasan_sdhci_probe, |
| 53 | .priv_auto_alloc_size = sizeof(struct sdhci_host), |
| 54 | }; |