blob: d405929b64140fa4355bf7c399850ab76a3da645 [file] [log] [blame]
Michal Simek293eb332013-04-22 14:56:49 +02001/*
Michal Simekd9ae52c2015-11-30 16:13:03 +01002 * (C) Copyright 2013 - 2015 Xilinx, Inc.
Michal Simek293eb332013-04-22 14:56:49 +02003 *
4 * Xilinx Zynq SD Host Controller Interface
5 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Michal Simek293eb332013-04-22 14:56:49 +02007 */
8
9#include <common.h>
Michal Simekd9ae52c2015-11-30 16:13:03 +010010#include <dm.h>
Michal Simek345d3c02014-02-24 11:16:31 +010011#include <fdtdec.h>
12#include <libfdt.h>
Michal Simek293eb332013-04-22 14:56:49 +020013#include <malloc.h>
14#include <sdhci.h>
Michal Simek293eb332013-04-22 14:56:49 +020015
Siva Durga Prasad Paladugua57a4a52016-01-05 12:21:04 +053016#ifndef CONFIG_ZYNQ_SDHCI_MIN_FREQ
17# define CONFIG_ZYNQ_SDHCI_MIN_FREQ 0
18#endif
19
Michal Simekd9ae52c2015-11-30 16:13:03 +010020static int arasan_sdhci_probe(struct udevice *dev)
Michal Simek293eb332013-04-22 14:56:49 +020021{
Michal Simekd9ae52c2015-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 Simek293eb332013-04-22 14:56:49 +020024
Siva Durga Prasad Paladugueddabd12014-07-08 15:31:04 +053025 host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD |
Siva Durga Prasad Paladuguf9ec45d2014-01-22 09:17:09 +010026 SDHCI_QUIRK_BROKEN_R1B;
Siva Durga Prasad Paladugub2156142016-01-12 15:12:16 +053027
28#ifdef CONFIG_ZYNQ_HISPD_BROKEN
29 host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT;
30#endif
31
Michal Simek293eb332013-04-22 14:56:49 +020032 host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
33
Siva Durga Prasad Paladugua57a4a52016-01-05 12:21:04 +053034 add_sdhci(host, CONFIG_ZYNQ_SDHCI_MAX_FREQ,
35 CONFIG_ZYNQ_SDHCI_MIN_FREQ);
Michal Simekd9ae52c2015-11-30 16:13:03 +010036
37 upriv->mmc = host->mmc;
Simon Glasscffe5d82016-05-01 13:52:34 -060038 host->mmc->dev = dev;
Michal Simekd9ae52c2015-11-30 16:13:03 +010039
Michal Simek293eb332013-04-22 14:56:49 +020040 return 0;
41}
Michal Simekd9ae52c2015-11-30 16:13:03 +010042
43static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
44{
45 struct sdhci_host *host = dev_get_priv(dev);
46
Masahiro Yamadacacd1d22016-04-22 20:59:31 +090047 host->name = dev->name;
Michal Simekd9ae52c2015-11-30 16:13:03 +010048 host->ioaddr = (void *)dev_get_addr(dev);
49
50 return 0;
51}
52
53static const struct udevice_id arasan_sdhci_ids[] = {
54 { .compatible = "arasan,sdhci-8.9a" },
55 { }
56};
57
58U_BOOT_DRIVER(arasan_sdhci_drv) = {
59 .name = "arasan_sdhci",
60 .id = UCLASS_MMC,
61 .of_match = arasan_sdhci_ids,
62 .ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata,
63 .probe = arasan_sdhci_probe,
64 .priv_auto_alloc_size = sizeof(struct sdhci_host),
65};