From patchwork Mon Apr 22 14:52:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 238559 X-Patchwork-Delegate: trini@ti.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 7B9FC2C00E8 for ; Tue, 23 Apr 2013 00:55:02 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4C8844A4F1; Mon, 22 Apr 2013 16:54:13 +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 x1HDOK2wq5Qn; Mon, 22 Apr 2013 16:54:13 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8ABEC4A35B; Mon, 22 Apr 2013 16:53:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1A2EC4A295 for ; Mon, 22 Apr 2013 16:53:13 +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 gl6s1Dk5dfW6 for ; Mon, 22 Apr 2013 16:53:10 +0200 (CEST) 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-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by theia.denx.de (Postfix) with ESMTPS id 71D714A2A0 for ; Mon, 22 Apr 2013 16:52:50 +0200 (CEST) Received: by mail-wi0-f169.google.com with SMTP id h11so4840574wiv.0 for ; Mon, 22 Apr 2013 07:52:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:in-reply-to:references:content-type :x-gm-message-state; bh=+0vAH6e/hpMrLwLJrbi9GRhunqxr/cfRE3kSQQx13io=; b=IQNlApE3nLnsoWAW6Op68K3VuKjTwUVyLJZ6MCT87ybP9+HOXxs5aWSJ4uhAMwdUId WuOM6eLd3HXSErPxdb1VDUjKO/nCBGbRbWHX4YyWsLGBKD5EFwVufRR9V4ZocDtnWUtR VNKeoiF9x38vgjMujPjUKGVOSoXmt/8mPUcLUGM7ELhQ9lBfIaRcRoZGHFGf35juRE2k 6zd+uNvcwPMF97NvM4l14+I7urxZP4st8yvrMfNfS9tgSGH61HjIO8sqEfR584eVCLAf qY7E1OExzMayT0JOAhx5pvLIcYVMKdAe+KpUWDA/TUsDQQ1ralaJhNVJTgEq+QgqN4qI BI+Q== X-Received: by 10.194.173.228 with SMTP id bn4mr53249750wjc.20.1366642368791; Mon, 22 Apr 2013 07:52:48 -0700 (PDT) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id n2sm20493388wiy.6.2013.04.22.07.52.46 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Mon, 22 Apr 2013 07:52:46 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, Albert Aribaud Date: Mon, 22 Apr 2013 16:52:10 +0200 Message-Id: <139c1d9a783597a7c945a56f7d423d4bdc0ec1f2.1366641836.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1366642332-11185-1-git-send-email-michal.simek@xilinx.com> References: <1366642332-11185-1-git-send-email-michal.simek@xilinx.com> In-Reply-To: <98a6e4d33e61c56c76b9bd78ef5d8e74ebd1510c.1366641836.git.michal.simek@xilinx.com> References: <98a6e4d33e61c56c76b9bd78ef5d8e74ebd1510c.1366641836.git.michal.simek@xilinx.com> X-Gm-Message-State: ALoCoQlMmaKbROXYOeEhrF1WUxCUw4hYicNbX4wS7V3Lb+C84qhFR+2JBTK0fHYru2cCNCMhYn5u Cc: Peter Crosthwaite , Jagannadha Sutradharudu Teki Subject: [U-Boot] [PATCH 12/14] mmc: Add support for Xilinx Zynq sdhci controller 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 Add support for SD, MMC and eMMC card on Xilinx Zynq. Signed-off-by: Michal Simek --- arch/arm/include/asm/arch-zynq/hardware.h | 2 ++ arch/arm/include/asm/arch-zynq/sys_proto.h | 3 +++ board/xilinx/zynq/board.c | 17 +++++++++++++ drivers/mmc/Makefile | 1 + drivers/mmc/zynq_sdhci.c | 40 ++++++++++++++++++++++++++++++ include/configs/zynq.h | 16 ++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 drivers/mmc/zynq_sdhci.c -- 1.8.2.1 diff --git a/arch/arm/include/asm/arch-zynq/hardware.h b/arch/arm/include/asm/arch-zynq/hardware.h index e0f6eba..3fa94d7 100644 --- a/arch/arm/include/asm/arch-zynq/hardware.h +++ b/arch/arm/include/asm/arch-zynq/hardware.h @@ -29,6 +29,8 @@ #define CONFIG_SCUTIMER_BASEADDR 0xF8F00600 #define CONFIG_ZYNQ_GEM_BASEADDR0 0xE000B000 #define CONFIG_ZYNQ_GEM_BASEADDR1 0xE000C000 +#define CONFIG_ZYNQ_SDHCI_BASEADDR0 0xE0100000 +#define CONFIG_ZYNQ_SDHCI_BASEADDR1 0xE0101000 /* Reflect slcr offsets */ struct slcr_regs { diff --git a/arch/arm/include/asm/arch-zynq/sys_proto.h b/arch/arm/include/asm/arch-zynq/sys_proto.h index 57128dc..af9e7f8 100644 --- a/arch/arm/include/asm/arch-zynq/sys_proto.h +++ b/arch/arm/include/asm/arch-zynq/sys_proto.h @@ -28,4 +28,7 @@ extern void zynq_slcr_unlock(void); extern void zynq_slcr_cpu_reset(void); extern void zynq_slcr_gem_clk_setup(u32 gem_id, u32 rclk, u32 clk); +/* Driver extern functions */ +extern int zynq_sdhci_init(u32 regbase); + #endif /* _SYS_PROTO_H_ */ diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 574a6fb..e42febd 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -54,6 +54,23 @@ int board_eth_init(bd_t *bis) } #endif +#ifdef CONFIG_CMD_MMC +int board_mmc_init(bd_t *bd) +{ + int ret = 0; + +#if defined(CONFIG_ZYNQ_SDHCI) +# if defined(CONFIG_ZYNQ_SDHCI0) + ret = zynq_sdhci_init(CONFIG_ZYNQ_SDHCI_BASEADDR0); +# endif +# if defined(CONFIG_ZYNQ_SDHCI1) + ret |= zynq_sdhci_init(CONFIG_ZYNQ_SDHCI_BASEADDR1); +# endif +#endif + return ret; +} +#endif + int dram_init(void) { gd->ram_size = CONFIG_SYS_SDRAM_SIZE; diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index 1d6faa2..7cd4281 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -49,6 +49,7 @@ COBJS-$(CONFIG_SH_MMCIF) += sh_mmcif.o COBJS-$(CONFIG_TEGRA_MMC) += tegra_mmc.o COBJS-$(CONFIG_DWMMC) += dw_mmc.o COBJS-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o +COBJS-$(CONFIG_ZYNQ_SDHCI) += zynq_sdhci.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c new file mode 100644 index 0000000..9e37af4 --- /dev/null +++ b/drivers/mmc/zynq_sdhci.c @@ -0,0 +1,40 @@ +/* + * (C) Copyright 2013 Inc. + * + * Xilinx Zynq SD Host Controller Interface + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * 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 + +int zynq_sdhci_init(u32 regbase) +{ + struct sdhci_host *host = NULL; + + host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host)); + if (!host) { + printf("zynq_sdhci_init: sdhci_host malloc fail\n"); + return 1; + } + + host->name = "zynq_sdhci"; + host->ioaddr = (void *)regbase; + host->quirks = SDHCI_QUIRK_NO_CD | SDHCI_QUIRK_WAIT_SEND_CMD; + host->version = sdhci_readw(host, SDHCI_HOST_VERSION); + + host->host_caps = MMC_MODE_HC; + + add_sdhci(host, 52000000, 52000000 >> 9); + return 0; +} diff --git a/include/configs/zynq.h b/include/configs/zynq.h index 3b23354..2ed88a7 100644 --- a/include/configs/zynq.h +++ b/include/configs/zynq.h @@ -56,6 +56,22 @@ #define CONFIG_ZYNQ_GEM0 #define CONFIG_ZYNQ_GEM_PHY_ADDR0 7 +#define CONFIG_ZYNQ_SDHCI +#define CONFIG_ZYNQ_SDHCI0 + +/* MMC */ +#if defined(CONFIG_ZYNQ_SDHCI0) || defined(CONFIG_ZYNQ_SDHCI1) +# define CONFIG_MMC +# define CONFIG_GENERIC_MMC +# define CONFIG_SDHCI +# define CONFIG_ZYNQ_SDHCI +# define CONFIG_CMD_MMC +# define CONFIG_CMD_FAT +# define CONFIG_SUPPORT_VFAT +# define CONFIG_CMD_EXT2 +# define CONFIG_DOS_PARTITION +#endif + #if defined(CONFIG_ZYNQ_DCC) # define CONFIG_ARM_DCC # define CONFIG_CPU_V6 /* Required by CONFIG_ARM_DCC */