2013-04-22 12:56:49 +00:00
|
|
|
/*
|
2015-11-30 15:13:03 +00:00
|
|
|
* (C) Copyright 2013 - 2015 Xilinx, Inc.
|
2013-04-22 12:56:49 +00:00
|
|
|
*
|
|
|
|
* Xilinx Zynq SD Host Controller Interface
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2013-04-22 12:56:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2015-11-30 15:13:03 +00:00
|
|
|
#include <dm.h>
|
2014-02-24 10:16:31 +00:00
|
|
|
#include <fdtdec.h>
|
|
|
|
#include <libfdt.h>
|
2013-04-22 12:56:49 +00:00
|
|
|
#include <malloc.h>
|
|
|
|
#include <sdhci.h>
|
|
|
|
|
2016-01-05 06:51:04 +00:00
|
|
|
#ifndef CONFIG_ZYNQ_SDHCI_MIN_FREQ
|
|
|
|
# define CONFIG_ZYNQ_SDHCI_MIN_FREQ 0
|
|
|
|
#endif
|
|
|
|
|
2016-07-05 23:10:15 +00:00
|
|
|
struct arasan_sdhci_plat {
|
|
|
|
struct mmc_config cfg;
|
|
|
|
struct mmc mmc;
|
|
|
|
};
|
|
|
|
|
2015-11-30 15:13:03 +00:00
|
|
|
static int arasan_sdhci_probe(struct udevice *dev)
|
2013-04-22 12:56:49 +00:00
|
|
|
{
|
2016-07-05 23:10:15 +00:00
|
|
|
struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
|
2015-11-30 15:13:03 +00:00
|
|
|
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
|
|
|
|
struct sdhci_host *host = dev_get_priv(dev);
|
2016-07-05 23:10:15 +00:00
|
|
|
int ret;
|
2013-04-22 12:56:49 +00:00
|
|
|
|
2014-07-08 10:01:04 +00:00
|
|
|
host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD |
|
2014-01-22 08:17:09 +00:00
|
|
|
SDHCI_QUIRK_BROKEN_R1B;
|
2016-01-12 09:42:16 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_ZYNQ_HISPD_BROKEN
|
|
|
|
host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT;
|
|
|
|
#endif
|
|
|
|
|
2016-07-26 10:06:24 +00:00
|
|
|
ret = sdhci_setup_cfg(&plat->cfg, host, CONFIG_ZYNQ_SDHCI_MAX_FREQ,
|
|
|
|
CONFIG_ZYNQ_SDHCI_MIN_FREQ);
|
2016-07-05 23:10:15 +00:00
|
|
|
host->mmc = &plat->mmc;
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
host->mmc->priv = host;
|
2016-05-01 19:52:34 +00:00
|
|
|
host->mmc->dev = dev;
|
2016-07-05 23:10:15 +00:00
|
|
|
upriv->mmc = host->mmc;
|
2015-11-30 15:13:03 +00:00
|
|
|
|
2016-07-05 23:10:15 +00:00
|
|
|
return sdhci_probe(dev);
|
2013-04-22 12:56:49 +00:00
|
|
|
}
|
2015-11-30 15:13:03 +00:00
|
|
|
|
|
|
|
static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct sdhci_host *host = dev_get_priv(dev);
|
|
|
|
|
2016-04-22 11:59:31 +00:00
|
|
|
host->name = dev->name;
|
2015-11-30 15:13:03 +00:00
|
|
|
host->ioaddr = (void *)dev_get_addr(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-05 23:10:15 +00:00
|
|
|
static int arasan_sdhci_bind(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
|
|
|
|
|
2016-09-06 13:17:32 +00:00
|
|
|
return sdhci_bind(dev, &plat->mmc, &plat->cfg);
|
2016-07-05 23:10:15 +00:00
|
|
|
}
|
|
|
|
|
2015-11-30 15:13:03 +00:00
|
|
|
static const struct udevice_id arasan_sdhci_ids[] = {
|
|
|
|
{ .compatible = "arasan,sdhci-8.9a" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(arasan_sdhci_drv) = {
|
|
|
|
.name = "arasan_sdhci",
|
|
|
|
.id = UCLASS_MMC,
|
|
|
|
.of_match = arasan_sdhci_ids,
|
|
|
|
.ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata,
|
2016-07-05 23:10:15 +00:00
|
|
|
.ops = &sdhci_ops,
|
|
|
|
.bind = arasan_sdhci_bind,
|
2015-11-30 15:13:03 +00:00
|
|
|
.probe = arasan_sdhci_probe,
|
|
|
|
.priv_auto_alloc_size = sizeof(struct sdhci_host),
|
2016-07-05 23:10:15 +00:00
|
|
|
.platdata_auto_alloc_size = sizeof(struct arasan_sdhci_plat),
|
2015-11-30 15:13:03 +00:00
|
|
|
};
|