Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3542521imu; Mon, 28 Jan 2019 06:43:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Ik74s9OcrFAJxoCpJyQUgY9fd/ueKNT1T1c9p4ZO4vK3C76Gxm9dxjk7FLmn9E+jX+fw+ X-Received: by 2002:a17:902:a601:: with SMTP id u1mr22024533plq.77.1548686616130; Mon, 28 Jan 2019 06:43:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548686616; cv=none; d=google.com; s=arc-20160816; b=HCVhkSRVz1uYo4bVcRthMTl276c8pMl7qxo9aoezuLpCwFyltZYQH5StzUnMajYBkJ iEhGfhIPxbM574emBegSTGYQKCgjjO/zMa68WsizX/s9wXEkTycTMNE8WGi2WLIbeVWn lcIbrB5GgqE/Tgtjh2jAlGxCgWidjnbMRPZQ3nncatKnnE3AK3x6zR9f2A24JcTI+ts9 /9vS1WERhIzylpcZi8moIAwNO8XN96kkhjaPGcFfjJl5fTrARgPWNiOyilYtnYaGc8c4 60k12SmCX+Y2aK0+QiXBHi2ym25jkU9ZMUZ5V6QW8lauaynp1IoH7bfbaNNIyFU4AQzc VNeA== 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=CDLf4/Whgd3NOsOadF8q0ty1AfhdcQVaAW1c/orUgU8=; b=BjShWA2K85ffFcUc69QXwx+T7Ke/s0HnK8Cs+MNUpMRYtsEj8HrIZBo5Yz0PiJoIKf vRMib5Wfv/GWLyoS//vr9EQE6xqBW1ho1T8s9WpeQlh9cQBK8RIw4dEm+wRIvWNRi2ZN Kos+Piftw69FATIzmIdP8k9suowthPKNQKZLDWfi8xGtDIIQlz92s7NGdJw+WCWiI1Xi ze8hC+6orUcj7yzHY098C4YchESFgYxGd6IjICnaAPDOat5/cGj3WRcZHJ59xOmOEdwO HoC/zWqbZxRlYxf2TwrVbYAtbUlpFi3qcLbN1wHmi7S2xVh68EuaxGyXLglGBIIG8Dwh rdGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b="LL/nI9BA"; 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 u30si33673541pgn.170.2019.01.28.06.43.19; Mon, 28 Jan 2019 06:43:36 -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="LL/nI9BA"; 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 S1726906AbfA1Old (ORCPT + 99 others); Mon, 28 Jan 2019 09:41:33 -0500 Received: from mout02.posteo.de ([185.67.36.66]:51841 "EHLO mout02.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726266AbfA1Olc (ORCPT ); Mon, 28 Jan 2019 09:41:32 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 6D6BB2400FF for ; Mon, 28 Jan 2019 15:41:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1548686489; bh=78zSCAFqEXwMnvzKrGeKAP95cmc72vwf2d7Yy5hAJDg=; h=From:To:Cc:Subject:Date:From; b=LL/nI9BAFu0W+CakexYe5nqPEM99XYnrcOMihXm2BrYlKz6rLGKCfVm14oczgRjPK 3kelN6OLAi/Jxr1O6IQMA5JFApTHSSDXI6cxZX3JhJqgyVq9B6Nt3BWhnyuj7q/SHu s6por0RLnsSxVL33ivRkB+m94Bu+1xnJd9pBdv3OCqXpnk5Pki9iB/fLU/JFk1Ns2+ jiCp5gQJsF3ucb46WIgCdyra2U5CBgEdraKLVqoWpjmH0ubLLA0mP06HiOo6XFua9b DJ22vImXreJMmV97fQ4ImvZy+9fAQd1tYTUVEmsAA/2Fz98JmZm4l8W+IJc+Cmm68T Drd8vDkwhU3kg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 43pC4R2Hpyz9rxB; Mon, 28 Jan 2019 15:41:27 +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 v4] mmc: mxs-mmc: Introduce regulator support Date: Mon, 28 Jan 2019 15:41:19 +0100 Message-Id: <20190128144119.10092-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 which is needed for example for WL1837 WL1271 wifi controllers on imx28. While the wifi's vmmc-supply regulator can be configured in devicetree, "ip link set wlan0 down" doesn't turn off the VMMC regulator which leads to hangs when loading firmware, for example. Signed-off-by: Martin Kepplinger --- revision history ---------------- v4: re-added forgotten regulator_enable() during probe v3: improve API usage as suggested by Ulf v2: tested patch with changes suggested by Robin v1: question, why https://patchwork.kernel.org/patch/4365751/ didn't get in drivers/mmc/host/mxs-mmc.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c index add1e70195ea..23d275269d61 100644 --- a/drivers/mmc/host/mxs-mmc.c +++ b/drivers/mmc/host/mxs-mmc.c @@ -517,6 +517,22 @@ static void mxs_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) else host->bus_width = 0; + switch (ios->power_mode) { + case MMC_POWER_OFF: + if (!IS_ERR(host->mmc->supply.vmmc)) + mmc_regulator_set_ocr(host->mmc, + host->mmc->supply.vmmc, 0); + break; + case MMC_POWER_UP: + if (!IS_ERR(host->mmc->supply.vmmc)) + mmc_regulator_set_ocr(host->mmc, + host->mmc->supply.vmmc, + ios->vdd); + break; + default: + break; + } + if (ios->clock) mxs_ssp_set_clk_rate(&host->ssp, ios->clock); } @@ -588,7 +604,6 @@ static int mxs_mmc_probe(struct platform_device *pdev) struct mmc_host *mmc; struct resource *iores; int ret = 0, irq_err; - struct regulator *reg_vmmc; struct mxs_ssp *ssp; irq_err = platform_get_irq(pdev, 0); @@ -614,14 +629,15 @@ static int mxs_mmc_probe(struct platform_device *pdev) host->mmc = mmc; host->sdio_irq_en = 0; - 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; - } + ret = mmc_regulator_get_supply(mmc); + if (ret == -EPROBE_DEFER) + goto out_mmc_free; + + ret = regulator_enable(mmc->supply.vmmc); + if (ret) { + dev_err(&pdev->dev, + "Failed to enable vmmc regulator: %d\n", ret); + goto out_mmc_free; } ssp->clk = devm_clk_get(&pdev->dev, NULL); -- 2.20.1