Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp354634imu; Fri, 25 Jan 2019 03:35:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Zmw3IW/xSFHiHIhFvq2yJObFGrjrSe2ZRGhhi2nzYewmm37sa0CR9t75+dqyPJqXwQGRQ X-Received: by 2002:a17:902:a60f:: with SMTP id u15mr10141385plq.275.1548416146367; Fri, 25 Jan 2019 03:35:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548416146; cv=none; d=google.com; s=arc-20160816; b=yUX7C2lioupDlRqHnCncjM9phL0znbmdA6CW5V7ceGIvkI5N1TKRedVfag6e5yHOKf SoREPpebQJG7Lg+3UyvwKwHQv2okrgkVfg7WoB7nFTQhjGyQa1Pj4heuRSSCTXhtBmO7 TqsVTOe6bUGMhsGcv31yrhWEYvDRsSHkuvhpaxhd2LP7XvsXtUs4gf1v0g4wW6JEeQe4 +o/MU8Jpxx5j2XbjJGXkPZjTpt1wQ0XlIiH9kFifrOPZSkdm8hyr3QYJvkp7muUBXv6Y nm8jd3JxBJF6AdGFLIOepC2CR+z9V+rO4K2nfctnm5hIkLgAgwJU9kXJlEn0HIPV5lPV qWiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xjY2MRM9vdpQUCN0uLDcMC5HjNI7mO2MWGACESExUyg=; b=z1OnUP/LSN31j7I5VRXQ1x9BTlbCmcEsHDaMIYjGZKkAG8O64WoHG3XZTRJkdYYj8U N8eiLcIsL0QReuJ1KHrOsyj03mjC7JSu8aTejETaDDWjVkT0oTKgNSGvd1qBLzbae9+l x64VMhYwld9CxkPWsyhXeJ7OagVw3smWpKaCCB8TPQax4edYeMlcn4BjazcR+TXVmz1T Otz+FUf03JI6Hvvhr4sAvT3JkaYWuRMqSweBRwYfGMHiAWfvAtpd5hJLcyEltEm4nbJ+ kK7FGABpI/wQ+WQeuMa7iTOF5UhLhvPvyUSOStqGwreG0oOVfhKritb7AO8ilayrx7Iu sLZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=D8t3fjzz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x61si25685918plb.303.2019.01.25.03.35.30; Fri, 25 Jan 2019 03:35:46 -0800 (PST) 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; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=D8t3fjzz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726667AbfAYLe6 (ORCPT + 99 others); Fri, 25 Jan 2019 06:34:58 -0500 Received: from mout02.posteo.de ([185.67.36.66]:50287 "EHLO mout02.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726026AbfAYLe6 (ORCPT ); Fri, 25 Jan 2019 06:34:58 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id D7CEE2400E5 for ; Fri, 25 Jan 2019 12:34:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1548416095; bh=oYyYmFp2j7XGH9Jl+ZPXOSkTm9PnOf7BpMey+cN1jYE=; h=From:To:Cc:Subject:Date:From; b=D8t3fjzzT0QkhfzehvTZIktnXG27YNJFGN9h/KU7GPNNvbONqQOSrQZqBCaRxvHdX 98KCkTlCiAp9u7cCq3FxB6AQiGghNT/puenTAWwB5pZj0QsHD3gsQqDCgv10oq7wR/ tOfX/Vh6HRFazT1XyCrFGhx9TrHXy2si9TDXG10zmk6EfqNqs6yJutWVaK3F3buIYr +7i+oOyUr0wPuGKGLO0szpTLrkfL4oXRU3Bt4WOg3cpnPmJfJSrHkUL7PfPWzvJ0ex zmvTzDATYIJxj+DRimrcXMxZm1apkDrfxIMDCvbaSAMIVkjIYYkWWuYrhIKwc5BxST gA+czcEwF+HOg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 43mH4Z0Gx9z9rxh; Fri, 25 Jan 2019 12:34:53 +0100 (CET) From: Martin Kepplinger To: linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robin@protonic.nl Cc: ulf.hansson@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, linux-imx@nxp.com, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [PATCH] mmc: mxs-mmc: Introduce regulator support Date: Fri, 25 Jan 2019 12:34:49 +0100 Message-Id: <20190125113449.10128-1-martink@posteo.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Martin Kepplinger This adds support for explicitly switching the mmc's power on and off. Signed-off-by: Martin Kepplinger --- This is not my patch. It's taken from https://patchwork.kernel.org/patch/4365751/ rebased and minimally changed; but we use this. Are there any objections to this? Robin, can I still add your Signed-off-by to this? Also, should I set you as the author? thanks, martin drivers/mmc/host/mxs-mmc.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c index add1e70195ea..e3c19fabb723 100644 --- a/drivers/mmc/host/mxs-mmc.c +++ b/drivers/mmc/host/mxs-mmc.c @@ -517,6 +517,26 @@ static void mxs_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) else host->bus_width = 0; + if (ios->power_mode != host->power_mode) { + switch (ios->power_mode) { + case MMC_POWER_OFF: + if ((host->vmmc) && regulator_disable(host->vmmc)) { + dev_err(mmc_dev(host->mmc), + "Failed to disable vmmc regulator\n"); + } + break; + case MMC_POWER_UP: + if ((host->vmmc) && regulator_enable(host->vmmc)) { + dev_err(mmc_dev(host->mmc), + "Failed to enable vmmc regulator\n"); + } + break; + default: + break; + } + host->power_mode = ios->power_mode; + } + if (ios->clock) mxs_ssp_set_clk_rate(&host->ssp, ios->clock); } @@ -613,16 +633,11 @@ static int mxs_mmc_probe(struct platform_device *pdev) host->mmc = mmc; host->sdio_irq_en = 0; + host->power_mode = MMC_POWER_OFF; reg_vmmc = devm_regulator_get(&pdev->dev, "vmmc"); - if (!IS_ERR(reg_vmmc)) { - ret = regulator_enable(reg_vmmc); - if (ret) { - dev_err(&pdev->dev, - "Failed to enable vmmc regulator: %d\n", ret); - goto out_mmc_free; - } - } + if (!IS_ERR(reg_vmmc)) + host->vmmc = reg_vmmc; ssp->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(ssp->clk)) { -- 2.20.1