From patchwork Tue Dec 4 08:31:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [U-Boot,v2,03/10] MMC: sdhci: Add support for dove sdhci Date: Mon, 03 Dec 2012 22:31:56 -0000 From: Sebastian Hesselbarth X-Patchwork-Id: 203575 Message-Id: <1354609923-27320-4-git-send-email-sebastian.hesselbarth@gmail.com> To: Sebastian Hesselbarth Cc: Rabeeh Khoury , Luka Perkov , u-boot@lists.denx.de, Daniel Stodden , Andy Fleming This adds a driver for the sdhci controller found on Dove SoCs. Signed-off-by: Sebastian Hesselbarth --- Cc: u-boot@lists.denx.de Cc: Sebastian Hesselbarth Cc: Rabeeh Khoury Cc: Albert Aribaud Cc: Prafulla Wadaskar Cc: Andy Fleming Cc: Joe Hershberger Cc: Daniel Stodden Cc: Luka Perkov --- drivers/mmc/Makefile | 1 + drivers/mmc/dove_sdhci.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 drivers/mmc/dove_sdhci.c diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index 65791aa..f7c731f 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 + * + * Based on linux drivers/mmc/host/sdhci-dove.c + * by: Saeed Bishara + * Mike Rapoport + * + * 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 +#include +#include +#include + +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; +}