]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc: atmel: Add atmel sdhci support
authorWenyou Yang <wenyou.yang@atmel.com>
Mon, 2 Nov 2015 02:57:09 +0000 (10:57 +0800)
committerAndreas Bießmann <andreas.devel@googlemail.com>
Tue, 3 Nov 2015 13:21:31 +0000 (14:21 +0100)
The SDHCI is introduced by sama5d2, named as Secure Digital Multimedia
Card Controller(SDMMC). It supports the embedded MultiMedia Card (e.MMC)
Specification V4.41, 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.

Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Reviewed-by: Andreas Bießmann <andreas.devel@googlemail.com>
arch/arm/mach-at91/include/mach/atmel_sdhci.h [new file with mode: 0644]
drivers/mmc/Makefile
drivers/mmc/atmel_sdhci.c [new file with mode: 0644]

diff --git a/arch/arm/mach-at91/include/mach/atmel_sdhci.h b/arch/arm/mach-at91/include/mach/atmel_sdhci.h
new file mode 100644 (file)
index 0000000..9652bc2
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2015 Atmel Corporation
+ *                   Wenyou.Yang <wenyou.yang@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
index 99d02954ed6b6fb9287f2104dc14db987144fa09..5d357056ddd1732b6a4f3b7013df6a667eb6588f 100644 (file)
@@ -8,6 +8,7 @@
 obj-$(CONFIG_DM_MMC) += mmc-uclass.o
 
 obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o
+obj-$(CONFIG_ATMEL_SDHCI) += atmel_sdhci.o
 obj-$(CONFIG_BCM2835_SDHCI) += bcm2835_sdhci.o
 obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o
 obj-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o
diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c
new file mode 100644 (file)
index 0000000..24b68b6
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 Atmel Corporation
+ *                   Wenyou.Yang <wenyou.yang@atmel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <sdhci.h>
+#include <asm/arch/clk.h>
+
+#define ATMEL_SDHC_MIN_FREQ    400000
+
+int atmel_sdhci_init(void *regbase, u32 id)
+{
+       struct sdhci_host *host;
+       u32 max_clk, min_clk = ATMEL_SDHC_MIN_FREQ;
+
+       host = (struct sdhci_host *)calloc(1, sizeof(struct sdhci_host));
+       if (!host) {
+               printf("%s: sdhci_host calloc failed\n", __func__);
+               return -ENOMEM;
+       }
+
+       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);
+       if (!max_clk) {
+               printf("%s: Failed to get the proper clock\n", __func__);
+               free(host);
+               return -ENODEV;
+       }
+
+       add_sdhci(host, max_clk, min_clk);
+
+       return 0;
+}