From patchwork Tue May 12 13:25:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 48371 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D9F8E2121F for ; Tue, 12 May 2015 13:26:02 +0000 (UTC) Received: by wgtl5 with SMTP id l5sf1925165wgt.1 for ; Tue, 12 May 2015 06:26:02 -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=XlziST/La9IBzXmek5D0j+KTPgrK1Uz/oOqkr5q9813JNmFn0sOdeJ5a10FqJ5FJsV lw3rrJJw4hUSCmuKMgNwBzjbnLRSAoWOtjCXiiobtZk2NlqHDwH62O0scDYvaVEv2bAo Cu2eHZ1zARinHxeB+JKuord2P1ztZrm3zCwLy8JqdWOed2zOFcOSXUSW7PUvlh3kSkVz 7aaXYtoMbdkhKwC/ISydbxL/OpOfLK6SNkSrTgb2fOTd9cWYZfswl96Ly1n0sdPmmOUL j0IK52W8RRsgvKD2ky68poH74AsfVlwj4YKhyR1cc1v8XGOtkwhk1u0UEPODLy0Jw7JQ b8sQ== X-Gm-Message-State: ALoCoQkOxVozd4WiRd82YH8hJT9gN3yS0tDo8YcVGDSkFZ8/mZ/lOudfQRtsLRoZogCBHU8LkAyO X-Received: by 10.112.138.2 with SMTP id qm2mr10695234lbb.19.1431437162161; Tue, 12 May 2015 06:26:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.98 with SMTP id ln2ls32250lac.61.gmail; Tue, 12 May 2015 06:26:02 -0700 (PDT) X-Received: by 10.112.159.162 with SMTP id xd2mr11808723lbb.67.1431437162026; Tue, 12 May 2015 06:26:02 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id js14si10348911lab.166.2015.05.12.06.26.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 06:26:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbbuc2 with SMTP id uc2so5737227lbb.2 for ; Tue, 12 May 2015 06:26:01 -0700 (PDT) X-Received: by 10.152.236.40 with SMTP id ur8mr12155851lac.19.1431437161937; Tue, 12 May 2015 06:26:01 -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 hn6csp2091538lbb; Tue, 12 May 2015 06:26:01 -0700 (PDT) X-Received: by 10.180.208.7 with SMTP id ma7mr30713585wic.0.1431437161231; Tue, 12 May 2015 06:26:01 -0700 (PDT) Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com. [74.125.82.53]) by mx.google.com with ESMTPS id p10si27529418wjz.24.2015.05.12.06.26.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 06:26:01 -0700 (PDT) Received-SPF: pass (google.com: domain of peter.griffin@linaro.org designates 74.125.82.53 as permitted sender) client-ip=74.125.82.53; Received: by wgnd10 with SMTP id d10so7350558wgn.2 for ; Tue, 12 May 2015 06:26:00 -0700 (PDT) X-Received: by 10.180.106.70 with SMTP id gs6mr29384219wib.36.1431437160841; Tue, 12 May 2015 06:26:00 -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 i13sm2885845wic.13.2015.05.12.06.25.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 May 2015 06:26:00 -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:25:40 +0100 Message-Id: <1431437141-18096-6-git-send-email-peter.griffin@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431437141-18096-1-git-send-email-peter.griffin@linaro.org> References: <1431437141-18096-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.178 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); +}