From patchwork Tue Jun 25 21:27:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Silbe X-Patchwork-Id: 254418 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id D79A62C013D for ; Wed, 26 Jun 2013 07:28:55 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 72E854A032; Tue, 25 Jun 2013 23:28:49 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5ExGV1BMo2yL; Tue, 25 Jun 2013 23:28:49 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1D3C44A04B; Tue, 25 Jun 2013 23:28:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 664004A027 for ; Tue, 25 Jun 2013 23:28:24 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vwDTqMrI5sSR for ; Tue, 25 Jun 2013 23:28:22 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=SKIP(-1.5) (only DNSBL check requested) Received: from b.mx.chost.de (s15264669.onlinehome-server.info [87.106.8.89]) by theia.denx.de (Postfix) with ESMTPS id 8DF7F4A02C for ; Tue, 25 Jun 2013 23:28:17 +0200 (CEST) Received: from sshgate.chost.de (sshgate.chost.de [::ffff:87.106.80.19]) by b.mx.chost.de with esmtp; Tue, 25 Jun 2013 23:28:15 +0200 id 019366AD.51CA0B6F.000007D5 Received: by sshgate.chost.de (sSMTP sendmail emulation); Tue, 25 Jun 2013 23:28:15 +0200 Received: (nullmailer pid 3996 invoked by uid 8193); Tue, 25 Jun 2013 21:28:08 -0000 From: Sascha Silbe To: u-boot@lists.denx.de Date: Tue, 25 Jun 2013 23:27:44 +0200 Message-Id: <1372195668-25496-5-git-send-email-t-uboot@infra-silbe.de> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1372195668-25496-1-git-send-email-t-uboot@infra-silbe.de> References: <51C9F64B.1020107@gmail.com> <1372195668-25496-1-git-send-email-t-uboot@infra-silbe.de> Cc: Rabeeh Khoury , Luka Perkov , Daniel Stodden , Andy Fleming Subject: [U-Boot] [PATCH v5 4/8] MMC: sdhci: Add support for dove sdhci X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This adds a driver for the sdhci controller found on Dove SoCs. Signed-off-by: Sascha Silbe --- v4->v5: no changes arch/arm/include/asm/arch-dove/mmc.h | 27 ++++++++++ drivers/mmc/Makefile | 1 + drivers/mmc/dove_sdhci.c | 101 +++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+) 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 24648a2..074af75 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -28,6 +28,7 @@ LIB := $(obj)libmmc.o 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_mci.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; +}