From patchwork Tue May 12 13:38:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 48379 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 51F922121F for ; Tue, 12 May 2015 13:38:59 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf1979244lbc.1 for ; Tue, 12 May 2015 06:38:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=a9Yb1GdV887KAZ9FMoZjWprOWlEPHhFDKyKTyCdneTQ=; b=V1k7uaYhF2QNZVkpV2DDW1N1WOE0V+ojkfaShTVUVH27dbhBthifOiFObtJrO2G8eS LIhDM/MJX6gDwubJug9fjUqh2ggF8f5IRWtzRh2f2uADFFkjaDJax3B1RtHNYO/mPlux OYKw66yvJQR/eRNfhkRkYCzKIEmNPOBXF+4qoe1NMtPuKq16hnJ44z0n+ikuyyqoaG2g kLnXhhPD6Q4lCq59ZcpvtYl/bZ04U8g49+hmF0K/5xvs5SPAIzpcAFWFJXl7X/PaNypa qg1xzhMTMNA8vhdWA0eq1JzrWDpPWVlt61RYsQLpEf8ujnAYnlohNhiocSc4J40jKlMb tuwg== X-Gm-Message-State: ALoCoQmDizNaRBHEBjwMMy7YbR4lNr4OU3tHn2gqw6PesZPkowpDIs7iSGu8s6y5KXBFqa89Jl5I X-Received: by 10.112.93.203 with SMTP id cw11mr10768249lbb.0.1431437938243; Tue, 12 May 2015 06:38:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.182.228 with SMTP id eh4ls33263lac.45.gmail; Tue, 12 May 2015 06:38:58 -0700 (PDT) X-Received: by 10.152.36.136 with SMTP id q8mr11869120laj.96.1431437938104; Tue, 12 May 2015 06:38:58 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id an10si10373322lac.169.2015.05.12.06.38.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 06:38:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbcga7 with SMTP id ga7so6090148lbc.1 for ; Tue, 12 May 2015 06:38:58 -0700 (PDT) X-Received: by 10.112.29.36 with SMTP id g4mr12438750lbh.56.1431437938012; Tue, 12 May 2015 06:38:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp2098835lbb; Tue, 12 May 2015 06:38:57 -0700 (PDT) X-Received: by 10.194.2.47 with SMTP id 15mr30614333wjr.101.1431437925765; Tue, 12 May 2015 06:38:45 -0700 (PDT) Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com. [209.85.212.174]) by mx.google.com with ESMTPS id y11si3162743wiv.114.2015.05.12.06.38.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 06:38:45 -0700 (PDT) Received-SPF: pass (google.com: domain of peter.griffin@linaro.org designates 209.85.212.174 as permitted sender) client-ip=209.85.212.174; Received: by wicmc15 with SMTP id mc15so54408828wic.1 for ; Tue, 12 May 2015 06:38:45 -0700 (PDT) X-Received: by 10.180.81.200 with SMTP id c8mr29320693wiy.49.1431437925497; Tue, 12 May 2015 06:38:45 -0700 (PDT) Received: from localhost.localdomain (cpc14-aztw22-2-0-cust189.18-1.cable.virginm.net. [82.45.1.190]) by mx.google.com with ESMTPSA id ei8sm27810166wjd.32.2015.05.12.06.38.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 May 2015 06:38:44 -0700 (PDT) From: Peter Griffin To: u-boot@lists.denx.de, albert.u.boot@aribaud.net, trini@konsulko.com, panto@antoniou-consulting.com, marex@denx.de Cc: Peter Griffin Subject: [PATCH 5/6] mmc: hi6220_dw_mmc: Add hi6220 glue code for dw_mmc controller. Date: Tue, 12 May 2015 14:38:31 +0100 Message-Id: <1431437912-18988-6-git-send-email-peter.griffin@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431437912-18988-1-git-send-email-peter.griffin@linaro.org> References: <1431437912-18988-1-git-send-email-peter.griffin@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.griffin@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch adds the glue code for hi6220 SoC which has 2x synopsis dw_mmc controllers. This will be used by the hikey board support in subsequent patches. Signed-off-by: Peter Griffin --- arch/arm/include/asm/arch-armv8/dwmmc.h | 8 +++++ drivers/mmc/Makefile | 1 + drivers/mmc/hi6220_dw_mmc.c | 63 +++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 arch/arm/include/asm/arch-armv8/dwmmc.h create mode 100644 drivers/mmc/hi6220_dw_mmc.c diff --git a/arch/arm/include/asm/arch-armv8/dwmmc.h b/arch/arm/include/asm/arch-armv8/dwmmc.h new file mode 100644 index 0000000..c747383 --- /dev/null +++ b/arch/arm/include/asm/arch-armv8/dwmmc.h @@ -0,0 +1,8 @@ +/* + * (C) Copyright 2015 Linaro + * Peter Griffin + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +int hi6220_dwmci_add_port(int index, u32 regbase, int bus_width); diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index ed73687..81a1a8f 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o obj-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o obj-$(CONFIG_DWMMC) += dw_mmc.o obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o +obj-$(CONFIG_HIKEY_DWMMC) += hi6220_dw_mmc.o obj-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o obj-$(CONFIG_FTSDC010) += ftsdc010_mci.o obj-$(CONFIG_FTSDC021) += ftsdc021_sdhci.o diff --git a/drivers/mmc/hi6220_dw_mmc.c b/drivers/mmc/hi6220_dw_mmc.c new file mode 100644 index 0000000..a3880a3 --- /dev/null +++ b/drivers/mmc/hi6220_dw_mmc.c @@ -0,0 +1,63 @@ +/* + * (C) Copyright 2015 Linaro + * peter.griffin + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include + +#define DWMMC_MAX_CH_NUM 4 + +/* +#define DWMMC_MAX_FREQ 52000000 +#define DWMMC_MIN_FREQ 400000 +*/ + +/*TODO we should probably use the frequencies above, but ATF uses + the ones below so stick with that for the moment */ +#define DWMMC_MAX_FREQ 50000000 +#define DWMMC_MIN_FREQ 378000 + +/* Source clock is configured to 100Mhz by ATF bl1*/ +#define MMC0_DEFAULT_FREQ 100000000 + +static int hi6220_dwmci_core_init(struct dwmci_host *host, int index) +{ + host->name = "HiKey DWMMC"; + + host->dev_index = index; + + /* Add the mmc channel to be registered with mmc core */ + if (add_dwmci(host, DWMMC_MAX_FREQ, DWMMC_MIN_FREQ)) { + printf("DWMMC%d registration failed\n", index); + return -1; + } + return 0; +} + +/* + * This function adds the mmc channel to be registered with mmc core. + * index - mmc channel number. + * regbase - register base address of mmc channel specified in 'index'. + * bus_width - operating bus width of mmc channel specified in 'index'. + */ +int hi6220_dwmci_add_port(int index, u32 regbase, int bus_width) +{ + struct dwmci_host *host = NULL; + + host = malloc(sizeof(struct dwmci_host)); + if (!host) { + error("dwmci_host malloc fail!\n"); + return -ENOMEM; + } + + host->ioaddr = (void *)regbase; + host->buswidth = bus_width; + host->bus_hz = MMC0_DEFAULT_FREQ; + + return hi6220_dwmci_core_init(host, index); +}