blob: f21ea524af9f8ef0c387b9bb64176ef28eaad94a [file] [log] [blame]
Michal Simek0dd222b2013-04-22 14:56:49 +02001/*
Michal Simek9ecd2682015-11-30 16:13:03 +01002 * (C) Copyright 2013 - 2015 Xilinx, Inc.
Michal Simek0dd222b2013-04-22 14:56:49 +02003 *
4 * Xilinx Zynq SD Host Controller Interface
5 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Michal Simek0dd222b2013-04-22 14:56:49 +02007 */
8
9#include <common.h>
Michal Simek9ecd2682015-11-30 16:13:03 +010010#include <dm.h>
Michal Simekc57ba042014-02-24 11:16:31 +010011#include <fdtdec.h>
12#include <libfdt.h>
Michal Simek0dd222b2013-04-22 14:56:49 +020013#include <malloc.h>
14#include <sdhci.h>
Michal Simek0dd222b2013-04-22 14:56:49 +020015
Siva Durga Prasad Paladuguf02a5e22016-01-05 12:21:04 +053016#ifndef CONFIG_ZYNQ_SDHCI_MIN_FREQ
17# define CONFIG_ZYNQ_SDHCI_MIN_FREQ 0
18#endif
19
Michal Simek9ecd2682015-11-30 16:13:03 +010020static int arasan_sdhci_probe(struct udevice *dev)
Michal Simek0dd222b2013-04-22 14:56:49 +020021{
Michal Simek9ecd2682015-11-30 16:13:03 +010022 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
23 struct sdhci_host *host = dev_get_priv(dev);
Michal Simek0dd222b2013-04-22 14:56:49 +020024
Siva Durga Prasad Paladugu049e0032014-07-08 15:31:04 +053025 host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD |
Siva Durga Prasad Paladugu0d6891b2014-01-22 09:17:09 +010026 SDHCI_QUIRK_BROKEN_R1B;
Michal Simek0dd222b2013-04-22 14:56:49 +020027 host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
28
Siva Durga Prasad Paladuguf02a5e22016-01-05 12:21:04 +053029 add_sdhci(host, CONFIG_ZYNQ_SDHCI_MAX_FREQ,
30 CONFIG_ZYNQ_SDHCI_MIN_FREQ);
Michal Simek9ecd2682015-11-30 16:13:03 +010031
32 upriv->mmc = host->mmc;
33
Michal Simek0dd222b2013-04-22 14:56:49 +020034 return 0;
35}
Michal Simek9ecd2682015-11-30 16:13:03 +010036
37static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
38{
39 struct sdhci_host *host = dev_get_priv(dev);
40
41 host->name = (char *)dev->name;
42 host->ioaddr = (void *)dev_get_addr(dev);
43
44 return 0;
45}
46
47static const struct udevice_id arasan_sdhci_ids[] = {
48 { .compatible = "arasan,sdhci-8.9a" },
49 { }
50};
51
52U_BOOT_DRIVER(arasan_sdhci_drv) = {
53 .name = "arasan_sdhci",
54 .id = UCLASS_MMC,
55 .of_match = arasan_sdhci_ids,
56 .ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata,
57 .probe = arasan_sdhci_probe,
58 .priv_auto_alloc_size = sizeof(struct sdhci_host),
59};