From patchwork Sun Dec 2 14:36:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 203237 X-Patchwork-Delegate: prafulla@marvell.com 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 02FED2C007D for ; Mon, 3 Dec 2012 04:25:34 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 805804A047; Sun, 2 Dec 2012 18:25:27 +0100 (CET) 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 n8pTUyznNouA; Sun, 2 Dec 2012 18:25:27 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7066B4A048; Sun, 2 Dec 2012 18:24:45 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3E9734A030 for ; Sun, 2 Dec 2012 15:36:48 +0100 (CET) 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 J6NOOR+WXY82 for ; Sun, 2 Dec 2012 15:36:47 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-bk0-f44.google.com (mail-bk0-f44.google.com [209.85.214.44]) by theia.denx.de (Postfix) with ESMTPS id 7F70E4A026 for ; Sun, 2 Dec 2012 15:36:44 +0100 (CET) Received: by mail-bk0-f44.google.com with SMTP id w11so739270bku.3 for ; Sun, 02 Dec 2012 06:36:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=xmttQFR0ZbFAYhfJW0WAsPoa5FnATFpU8JFOvj7cqO8=; b=kdUyrnHysCtsJL2YZ6wfKrO2XFE7TD/oKrWGvPUspAmLxeM81qT/dmR/5m4fGQ5za5 mWhL7HFDHbj9UfIvs79yYWr7Iy8aRPVSx6sbx1Kg5T+jLvbyeNB2zlz6ZGVJXo4DEgxQ 4QCQR/e9m9omVqxfHSgm1dHePb/DWH/JI14AmY3Y1ohMqSXU7pdvcJCWgEncYjQUwAfJ N1k5VdW2tfYb7eVelbeZdYKRFdYTNfHv37UbDiDrFU3JBYFU6i4zCBuj7G6wQDCatH0j dvqsu4V81W9BSzEJyQ+PFdjQkY7vMcDoIsihQFkkIC+NhpXh2dNeHYso//OS4TD81rzg zz1g== Received: by 10.204.15.203 with SMTP id l11mr2001958bka.74.1354459004724; Sun, 02 Dec 2012 06:36:44 -0800 (PST) Received: from nijin.lan (dslc-082-083-245-055.pools.arcor-ip.net. [82.83.245.55]) by mx.google.com with ESMTPS id u3sm5605994bkw.9.2012.12.02.06.36.40 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 02 Dec 2012 06:36:42 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Date: Sun, 2 Dec 2012 15:36:15 +0100 Message-Id: <1354458982-14403-4-git-send-email-sebastian.hesselbarth@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1354458982-14403-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1354458982-14403-1-git-send-email-sebastian.hesselbarth@gmail.com> X-Mailman-Approved-At: Sun, 02 Dec 2012 18:24:40 +0100 Cc: Dieter Kiermaier , Rabeeh Khoury , u-boot@lists.denx.de, Daniel Stodden , Andy Fleming Subject: [U-Boot] [PATCH 03/10] 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: 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: Dieter Kiermaier --- 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; +}