From patchwork Thu Apr 30 12:32:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 6303221 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 18DBCBEEE1 for ; Thu, 30 Apr 2015 12:32:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 346A820148 for ; Thu, 30 Apr 2015 12:32:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 33D0C20120 for ; Thu, 30 Apr 2015 12:32:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751246AbbD3McX (ORCPT ); Thu, 30 Apr 2015 08:32:23 -0400 Received: from ducie-dc1.codethink.co.uk ([185.25.241.215]:45515 "EHLO ducie-dc1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750943AbbD3McX (ORCPT ); Thu, 30 Apr 2015 08:32:23 -0400 Received: from localhost (localhost [127.0.0.1]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTP id 86ACA4615B1; Thu, 30 Apr 2015 13:32:21 +0100 (BST) X-Virus-Scanned: Debian amavisd-new at ducie-dc1.codethink.co.uk Received: from ducie-dc1.codethink.co.uk ([127.0.0.1]) by localhost (ducie-dc1.codethink.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j51v7nZmuExi; Thu, 30 Apr 2015 13:32:19 +0100 (BST) Received: from [192.168.25.61] (unknown [192.168.25.61]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTPSA id 7B67A4609CA; Thu, 30 Apr 2015 13:32:17 +0100 (BST) Message-ID: <1430397136.5802.44.camel@xylophone.i.decadent.org.uk> Subject: [RFC PATCH 5/7] mmc: sh_mobile_sdhi: Add UHS-I mode support From: Ben Hutchings To: Ian Molton , linux-mmc@vger.kernel.org Cc: linux-sh@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@lists.codethink.co.uk Date: Thu, 30 Apr 2015 13:32:16 +0100 In-Reply-To: <1430396995.5802.39.camel@xylophone.i.decadent.org.uk> References: <1430396995.5802.39.camel@xylophone.i.decadent.org.uk> Organization: Codethink Ltd. X-Mailer: Evolution 3.4.4-3 Mime-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement voltage switch, supporting modes up to SDR-50. Based on work by Shinobu Uehara, Rob Taylor, William Towle and Ian Molton. This uses two voltage regulators, one external and one on the pfc. Signed-off-by: Ben Hutchings --- drivers/mmc/host/sh_mobile_sdhi.c | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 92a58c6007fe..c8538a256e22 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "tmio_mmc.h" @@ -84,6 +85,7 @@ MODULE_DEVICE_TABLE(of, sh_mobile_sdhi_of_match); struct sh_mobile_sdhi { struct clk *clk; + struct regulator *vqmmc_ref; struct tmio_mmc_data mmc_data; struct tmio_mmc_dma dma_priv; }; @@ -148,6 +150,41 @@ static void sh_mobile_sdhi_set_clk_div(struct platform_device *pdev, int clk) } } +static int sh_mobile_sdhi_start_signal_voltage_switch( + struct tmio_mmc_host *host, unsigned char signal_voltage) +{ + struct sh_mobile_sdhi *priv = host_to_priv(host); + int min_uV, max_uV; + int ret; + + if (signal_voltage == MMC_SIGNAL_VOLTAGE_330) { + min_uV = 2700000; + max_uV = 3600000; + } else if (signal_voltage == MMC_SIGNAL_VOLTAGE_180) { + min_uV = 1700000; + max_uV = 1950000; + } else { + return -EINVAL; + } + + if (!IS_ERR(host->mmc->supply.vqmmc)) { + ret = regulator_set_voltage(host->mmc->supply.vqmmc, + min_uV, max_uV); + if (ret) + return ret; + } + + if (!IS_ERR(priv->vqmmc_ref)) { + ret = regulator_set_voltage(priv->vqmmc_ref, + min_uV, max_uV); + if (ret) + return ret; + } + + usleep_range(5000, 5500); + return 0; +} + static int sh_mobile_sdhi_wait_idle(struct tmio_mmc_host *host) { int timeout = 1000; @@ -240,6 +277,13 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) goto eprobe; } + priv->vqmmc_ref = devm_regulator_get_optional(&pdev->dev, "vqmmc-ref"); + if (IS_ERR(priv->vqmmc_ref)) { + if (PTR_ERR(priv->vqmmc_ref) == -EPROBE_DEFER) + return -EPROBE_DEFER; + dev_info(&pdev->dev, "No vqmmc reference regulator found\n"); + } + host = tmio_mmc_host_alloc(pdev); if (!host) { ret = -ENOMEM; @@ -253,6 +297,10 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) host->clk_enable = sh_mobile_sdhi_clk_enable; host->clk_disable = sh_mobile_sdhi_clk_disable; host->multi_io_quirk = sh_mobile_sdhi_multi_io_quirk; + + host->start_signal_voltage_switch + = sh_mobile_sdhi_start_signal_voltage_switch; + /* SD control register space size is 0x100, 0x200 for bus_shift=1 */ if (resource_size(res) > 0x100) host->bus_shift = 1;