From: Sebastian Hesselbarth <sebastian.hesselba...@gmail.com>

This adds a driver for the sdhci controller found on Dove SoCs.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselba...@gmail.com>
Signed-off-by: Sascha Silbe <t-ub...@infra-silbe.de>
---
 v3->v4: added header file with exported function

 arch/arm/include/asm/arch-dove/mmc.h |  27 ++++++++++
 drivers/mmc/Makefile                 |   1 +
 drivers/mmc/dove_sdhci.c             | 101 +++++++++++++++++++++++++++++++++++
 3 files changed, 129 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-dove/mmc.h
 create mode 100644 drivers/mmc/dove_sdhci.c

diff --git a/arch/arm/include/asm/arch-dove/mmc.h 
b/arch/arm/include/asm/arch-dove/mmc.h
new file mode 100644
index 0000000..579396c
--- /dev/null
+++ b/arch/arm/include/asm/arch-dove/mmc.h
@@ -0,0 +1,27 @@
+/*
+ * Marvell Dove SoC SDHCI
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef _DOVEMMC_H
+#define _DOVEMMC_H
+
+int dove_sdhci_init(int num);
+#endif /* _DOVEMMC_H */
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index fb6b502..cdff33d 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -31,6 +31,7 @@ endif
 
 COBJS-$(CONFIG_BFIN_SDH) += bfin_sdh.o
 COBJS-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o
+COBJS-$(CONFIG_DOVE_SDHCI) += dove_sdhci.o
 COBJS-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o
 COBJS-$(CONFIG_FTSDC010) += ftsdc010_esdhc.o
 COBJS-$(CONFIG_GENERIC_MMC) += mmc.o
diff --git a/drivers/mmc/dove_sdhci.c b/drivers/mmc/dove_sdhci.c
new file mode 100644
index 0000000..ac15fd7
--- /dev/null
+++ b/drivers/mmc/dove_sdhci.c
@@ -0,0 +1,101 @@
+/*
+ *
+ * Marvell Dove SDHCI driver
+ *
+ * Sebastian Hesselbarth <sebastian.hesselba...@gmail.com>
+ *
+ * Based on linux drivers/mmc/host/sdhci-dove.c
+ * by: Saeed Bishara <sa...@marvell.com>
+ *     Mike Rapoport <m...@compulab.co.il>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <sdhci.h>
+#include <asm/arch/dove.h>
+
+static u16 dove_sdhci_readw(struct sdhci_host *host, int reg)
+{
+       u16 ret;
+
+       switch (reg) {
+       case SDHCI_HOST_VERSION:
+       case SDHCI_SLOT_INT_STATUS:
+               /* those registers don't exist */
+               return 0;
+       default:
+               ret = readw(host->ioaddr + reg);
+       }
+
+       return ret;
+}
+
+static u32 dove_sdhci_readl(struct sdhci_host *host, int reg)
+{
+       u32 ret;
+
+       switch (reg) {
+       case SDHCI_CAPABILITIES:
+               ret = readl(host->ioaddr + reg);
+               /* Mask the support for 3.0V */
+               ret &= ~SDHCI_CAN_VDD_300;
+               break;
+       default:
+               ret = readl(host->ioaddr + reg);
+       }
+
+       return ret;
+}
+
+static struct sdhci_ops dove_sdhci_ops = {
+       .read_w = dove_sdhci_readw,
+       .read_l = dove_sdhci_readl,
+};
+
+static struct sdhci_host hosts[2] = {
+       {
+               .name = "Dove SDHCI0",
+               .ioaddr = (void *)DOVE_SDIO0_BASE,
+       },
+       {
+               .name = "Dove SDHCI1",
+               .ioaddr = (void *)DOVE_SDIO1_BASE,
+       },
+};
+
+int dove_sdhci_init(int num)
+{
+       struct sdhci_host *host;
+
+       if (num < 0 || num > 1)
+               return 1;
+
+       host = &hosts[num];
+
+       if (host->version)
+               return 1;
+
+       host->quirks =
+               SDHCI_QUIRK_NO_HISPD_BIT |
+               SDHCI_QUIRK_BROKEN_R1B |
+               SDHCI_QUIRK_32BIT_DMA_ADDR;
+       host->version = SDHCI_SPEC_200;
+       host->ops = &dove_sdhci_ops;
+
+       add_sdhci(host, 50000000, 4000000);
+       return 0;
+}
-- 
1.8.2.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to