[U-Boot] [PATCH] mmc: atmel_sdhci: move to the driver model & DT
Wenyou Yang
wenyou.yang at atmel.com
Mon Apr 18 08:25:48 CEST 2016
Move the driver to the driver model & DT support.
Signed-off-by: Wenyou Yang <wenyou.yang at atmel.com>
---
arch/arm/mach-at91/include/mach/atmel_sdhci.h | 13 --------
drivers/mmc/Kconfig | 10 ++++++
drivers/mmc/atmel_sdhci.c | 44 ++++++++++++++++++++-------
3 files changed, 43 insertions(+), 24 deletions(-)
delete mode 100644 arch/arm/mach-at91/include/mach/atmel_sdhci.h
diff --git a/arch/arm/mach-at91/include/mach/atmel_sdhci.h b/arch/arm/mach-at91/include/mach/atmel_sdhci.h
deleted file mode 100644
index 9652bc2..0000000
--- a/arch/arm/mach-at91/include/mach/atmel_sdhci.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright (c) 2015 Atmel Corporation
- * Wenyou.Yang <wenyou.yang at atmel.com>
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-#ifndef __ATMEL_SDHCI_H
-#define __ATMEL_SDHCI_H
-
-int atmel_sdhci_init(void *regbase, u32 id);
-
-#endif
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index dc8532f..7f6b2e1 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -16,6 +16,16 @@ config DM_MMC
appear as block devices in U-Boot and can support filesystems such
as EXT4 and FAT.
+config ATMEL_SDHCI
+ bool "Atmel SDHCI controller support"
+ depends on DM_MMC && ARCH_AT91
+ help
+ This enables support for the Atmel SDHCI controller, which supports
+ the embedded MultiMedia Card (e.MMC) Specification V4.51, the SD
+ Memory Card Specification V3.0, and the SDIO V3.0 specification.
+ It is compliant with the SD Host Controller Standard V3.0
+ specification.
+
config ROCKCHIP_DWMMC
bool "Rockchip SD/MMC controller support"
depends on DM_MMC && OF_CONTROL
diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c
index 24b68b6..ec2885e 100644
--- a/drivers/mmc/atmel_sdhci.c
+++ b/drivers/mmc/atmel_sdhci.c
@@ -6,35 +6,57 @@
*/
#include <common.h>
+#include <dm.h>
#include <malloc.h>
#include <sdhci.h>
#include <asm/arch/clk.h>
+DECLARE_GLOBAL_DATA_PTR;
+
#define ATMEL_SDHC_MIN_FREQ 400000
-int atmel_sdhci_init(void *regbase, u32 id)
+static int atmel_sdhci_probe(struct udevice *dev)
{
- struct sdhci_host *host;
+ struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+ struct sdhci_host *host = dev_get_priv(dev);
u32 max_clk, min_clk = ATMEL_SDHC_MIN_FREQ;
+ u32 periph_id;
- host = (struct sdhci_host *)calloc(1, sizeof(struct sdhci_host));
- if (!host) {
- printf("%s: sdhci_host calloc failed\n", __func__);
- return -ENOMEM;
- }
+ host->name = (char *)dev->name;
+ host->ioaddr = (void *)dev_get_addr(dev);
- host->name = "atmel_sdhci";
- host->ioaddr = regbase;
host->quirks = 0;
host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
- max_clk = at91_get_periph_generated_clk(id);
+
+ host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+ "bus-width", 4);
+
+ periph_id = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "id", 0);
+ if (periph_id < 0)
+ return -EINVAL;
+
+ max_clk = at91_get_periph_generated_clk(periph_id);
if (!max_clk) {
printf("%s: Failed to get the proper clock\n", __func__);
- free(host);
return -ENODEV;
}
add_sdhci(host, max_clk, min_clk);
+ upriv->mmc = host->mmc;
+
return 0;
}
+
+static const struct udevice_id atmel_sdhci_ids[] = {
+ { .compatible = "atmel,sama5d2-sdhci" },
+ { }
+};
+
+U_BOOT_DRIVER(atmel_sdhci_drv) = {
+ .name = "atmel_sdhci",
+ .id = UCLASS_MMC,
+ .of_match = atmel_sdhci_ids,
+ .probe = atmel_sdhci_probe,
+ .priv_auto_alloc_size = sizeof(struct sdhci_host),
+};
--
2.7.4
More information about the U-Boot
mailing list