From patchwork Tue Sep 1 19:32:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 52944 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id DED6D2300F for ; Tue, 1 Sep 2015 19:36:12 +0000 (UTC) Received: by lagj9 with SMTP id j9sf2920544lag.0 for ; Tue, 01 Sep 2015 12:36:11 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=9NDvSzobLWfIJnhLJ2jp5DL92SMXa0q3QAbLH6duz00=; b=efKS9V4aXv7Re4qykCsCOvD/5zLRvjLAzCha9YKI5fDZuRZvOAB7mEMbb6sZYUbi2Q sWIcrMdK2VNkjtzs493MceUqydXWqzTxMlSvnxBnvGT4NVLeIsLLbOjHlZOrMcDb/qrc VGnt3iR4RsORPgva+AUSzbEvuSYmq5pqWpxhVVpRjC/B9eeszlnogQWYLDh2JvX97GWB aSoKTtjHAHgqvcKUiLgKWxSSImlviHqoQ9Vel7487hfi273trVEUhgCxNmmIozzbgfHc 4EYxeqYQwE5H5R6wyWLrBLX4of1lfA5LKS54dFV/zD+7UOpi7191ZqkiRwni5k59EXqO 1h4g== X-Gm-Message-State: ALoCoQngUDY0XQ1Ybae7febaU6SX4Z8/6nSpIcyeUzgbkckWi1EYc7mewJMA95RVQ4fHc0/qcnkv X-Received: by 10.180.12.205 with SMTP id a13mr1282912wic.4.1441136171820; Tue, 01 Sep 2015 12:36:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.219.4 with SMTP id pk4ls645715lac.90.gmail; Tue, 01 Sep 2015 12:36:11 -0700 (PDT) X-Received: by 10.152.20.70 with SMTP id l6mr3218992lae.4.1441136171635; Tue, 01 Sep 2015 12:36:11 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id t6si17342472lae.163.2015.09.01.12.36.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2015 12:36:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbpo4 with SMTP id o4so5802439lbp.2 for ; Tue, 01 Sep 2015 12:36:11 -0700 (PDT) X-Received: by 10.112.131.98 with SMTP id ol2mr14015341lbb.56.1441136171511; Tue, 01 Sep 2015 12:36:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.164.42 with SMTP id yn10csp73767lbb; Tue, 1 Sep 2015 12:36:10 -0700 (PDT) X-Received: by 10.69.26.38 with SMTP id iv6mr49405104pbd.151.1441136170437; Tue, 01 Sep 2015 12:36:10 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id km1si31442760pdb.43.2015.09.01.12.36.09; Tue, 01 Sep 2015 12:36:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755396AbbIATfv (ORCPT + 28 others); Tue, 1 Sep 2015 15:35:51 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:32816 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753460AbbIATfc (ORCPT ); Tue, 1 Sep 2015 15:35:32 -0400 Received: by pary6 with SMTP id y6so430549par.0 for ; Tue, 01 Sep 2015 12:35:31 -0700 (PDT) X-Received: by 10.68.98.34 with SMTP id ef2mr48906578pbb.45.1441136131863; Tue, 01 Sep 2015 12:35:31 -0700 (PDT) Received: from localhost.localdomain ([202.62.93.143]) by smtp.gmail.com with ESMTPSA id gw3sm19019035pbc.46.2015.09.01.12.35.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Sep 2015 12:35:31 -0700 (PDT) From: Vaibhav Hiremath To: linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Vaibhav Hiremath Subject: [RFC 3/3] mmc: sdhci-pxav3: Add ->voltage_switch callback support Date: Wed, 2 Sep 2015 01:02:18 +0530 Message-Id: <1441135938-8056-4-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441135938-8056-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1441135938-8056-1-git-send-email-vaibhav.hiremath@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vaibhav.hiremath@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.176 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In case PXA1928 family of devices, there is device/controller specific configuration to control voltage/power on the IO pins. This patch implements and enables the sdhci_ops->voltage_switch() callback api. Note that IO pad register addresses are fetched as a memory resource. For example, in case of PXA1928 and family of devices, the DT property would look something like, sdh1: sdh@d4280000 { compatible = "mrvl,pxav3-mmc"; reg-names = "sdhci", "io-pwr", "io-pwr-lock-unlock"; reg = <0xd4280000 0x120>, <0xd401e81c 4>, <0xd4015068 8>; ... }; Signed-off-by: Vaibhav Hiremath --- drivers/mmc/host/sdhci-pxav3.c | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c index 5d26fe0..cebb2f9 100644 --- a/drivers/mmc/host/sdhci-pxav3.c +++ b/drivers/mmc/host/sdhci-pxav3.c @@ -63,11 +63,18 @@ #define IO_PWR_AKEY_ASSAR 0xeb10 #define IO_PWR_MMC1_PAD_1V8 BIT(2) +/* IO Power control */ +#define IO_PWR_AKEY_ASFAR 0xbaba +#define IO_PWR_AKEY_ASSAR 0xeb10 +#define IO_PWR_MMC1_PAD_1V8 BIT(2) + struct sdhci_pxa { struct clk *clk_core; struct clk *clk_io; u8 power_mode; void __iomem *sdio3_conf_reg; + void __iomem *io_pwr_reg; + void __iomem *io_pwr_lock_reg; }; /* @@ -307,6 +314,38 @@ static void pxav3_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs) __func__, uhs, ctrl_2); } +static void pxav3_voltage_switch(struct sdhci_host *host, + u8 signal_voltage) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_pxa *pxa = pltfm_host->priv; + unsigned int val; + + if (!pxa->io_pwr_reg || !pxa->io_pwr_lock_reg) + return; + + /* Lock register is 64 bit: First & Second access register */ + writel(IO_PWR_AKEY_ASFAR, pxa->io_pwr_lock_reg); + writel(IO_PWR_AKEY_ASSAR, pxa->io_pwr_lock_reg + 4); + val = readl(pxa->io_pwr_reg); + + switch (signal_voltage) { + case MMC_SIGNAL_VOLTAGE_180: + case MMC_SIGNAL_VOLTAGE_120: + val |= IO_PWR_MMC1_PAD_1V8; + break; + case MMC_SIGNAL_VOLTAGE_330: + default: + val &= ~IO_PWR_MMC1_PAD_1V8; + break; + } + + writel(IO_PWR_AKEY_ASFAR, pxa->io_pwr_lock_reg); + writel(IO_PWR_AKEY_ASSAR, pxa->io_pwr_lock_reg + 4); + + writel(val, pxa->io_pwr_reg); +} + static const struct sdhci_ops pxav3_sdhci_ops = { .set_clock = sdhci_set_clock, .platform_send_init_74_clocks = pxav3_gen_init_74_clocks, @@ -314,6 +353,7 @@ static const struct sdhci_ops pxav3_sdhci_ops = { .set_bus_width = sdhci_set_bus_width, .reset = pxav3_reset, .set_uhs_signaling = pxav3_set_uhs_signaling, + .voltage_switch = pxav3_voltage_switch, }; static struct sdhci_pltfm_data sdhci_pxav3_pdata = { @@ -368,6 +408,7 @@ static int sdhci_pxav3_probe(struct platform_device *pdev) struct sdhci_host *host = NULL; struct sdhci_pxa *pxa = NULL; const struct of_device_id *match; + struct resource *res; int ret; pxa = devm_kzalloc(&pdev->dev, sizeof(struct sdhci_pxa), GFP_KERNEL); @@ -408,6 +449,24 @@ static int sdhci_pxav3_probe(struct platform_device *pdev) goto err_mbus_win; } + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "io-pwr-conf"); + if (res) { + pxa->io_pwr_reg = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(pxa->io_pwr_reg)) { + ret = PTR_ERR(pxa->io_pwr_reg); + goto err_mbus_win; + } + } + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "io-pwr-lock-unlock"); + if (res) { + pxa->io_pwr_lock_reg = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(pxa->io_pwr_lock_reg)) { + ret = PTR_ERR(pxa->io_pwr_lock_reg); + goto err_mbus_win; + } + } + match = of_match_device(of_match_ptr(sdhci_pxav3_of_match), &pdev->dev); if (match) { ret = mmc_of_parse(host->mmc);