Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3300027imu; Mon, 28 Jan 2019 02:21:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN6AzGaRg2wYCj4GSHJtl2K1lT1C0mOC6+t2fHpnQtU9KJTbv9DIbEedGscQ2+xvAxykHHT8 X-Received: by 2002:a63:e655:: with SMTP id p21mr19102568pgj.70.1548670866599; Mon, 28 Jan 2019 02:21:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548670866; cv=none; d=google.com; s=arc-20160816; b=l5l/I0shRYvE6R7RLk+HusY3wA/Sa0Xl+WwSMfdDHNU+olCVUMY+R0oPKixF1/HMiH dAsHZQ/PBR0Y77Fb38wB341dbXZ5I7V34Ac+Q8SAFiMFe4g2K+6CQkHnXwj6VrZh6IrR dm3TpCtNmK5HshSCEmhf8y+7vrD6JSK7Gd8HUg7DodBL0RjvkljeVNHIj1+ClekacdGW XjeWHGKKZzDoyAbuCAIZtZB4T0pMXDQHP4xF4QpfhXZgxAC7Wg4rT9vPiI8iMMx704OU elbzgj1Af7XF5cn+Nw4h+adHscFQYIfqQVf4+xNCj3S8srFAh2LmTUH9HDpPqJ7Ytlic qTww== 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=tUnzXsHZQohYcWSuWiOhzitDvcfvYF7iaZJ6Z9hXwWY=; b=uyHpvJr7/k8htgDFX7XLWqkHlX/s4WnzGoj+iypkCk0cMEO574W6IwPRLEpTyZQAl4 5FtEgpxFRBPGm8ps5xH6eLybaFLwk/NsTjI0CvP+cSwF+vvn+jeWSzwcyuLs8y6XiEXg bEHI5YOemk8t04XFCRUWS/ghuhMWfudKBX0PdHnCUO29W26PZ7u81DIm+73C85ggCmB4 UxcyqxQF+qp0T0T9QZGIbfhDxqhRwvm4kC9Vkj3RKm6WpIGEyl5L1umxkGA6l08Ksmd6 Y83rRQJVeKJ9RyPbzymee4ZubCxow8cj84RPtSDM3PcueLbvkJd6fnOh3f7vmc72Fw4o 79/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=FUL4cGIP; 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 1si5272566plr.189.2019.01.28.02.20.51; Mon, 28 Jan 2019 02:21:06 -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=FUL4cGIP; 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 S1726893AbfA1KUb (ORCPT + 99 others); Mon, 28 Jan 2019 05:20:31 -0500 Received: from mout02.posteo.de ([185.67.36.66]:50333 "EHLO mout02.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726779AbfA1KUa (ORCPT ); Mon, 28 Jan 2019 05:20:30 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 372012400FB for ; Mon, 28 Jan 2019 11:20:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1548670828; bh=R2SL3qXPRrTk5inyV+kmoVKVzKoBzirKte3NylclSkY=; h=From:To:Cc:Subject:Date:From; b=FUL4cGIP5kOvXbqr6X9wEmCXPGQmSukbLd76m5DpKSxFYCmb1e1yJMl/oWEimP6MC wRF6/rhvOMpudAX9gOoM4NeOh/DSJjINTQlBd0xZM8V55iq6v7fg/Tltf0M+7ltsRJ EjVcZztNLQ5e+QZbsG9kcdD8Vhm6GcW/J+eG1nLgB29Ep7NFlZ9XI+dMKaYAxT9xRP VVIOR6IsUQC1fs0GqlSez2rHt97qUusOi6zBX0kJ4wR/zesLLq2xg41oXUaFtSyUN9 kKXX6NZGITHsv2henaEVjZ2T+zI/xPnzGjnUcMbfBV+KCHJEEZYMBSG8D1bkcRQyyi /8QNLMoDVNJ1A== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 43p5HF6Kdfz9rxb; Mon, 28 Jan 2019 11:20:25 +0100 (CET) From: Martin Kepplinger To: linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robin@protonic.nl, ulf.hansson@linaro.org Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [PATCH v2] mmc: mxs-mmc: Introduce regulator support Date: Mon, 28 Jan 2019 11:20:22 +0100 Message-Id: <20190128102022.1880-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 wifi controllers. ip link set wlan0 down doesn't turn off the VMMC regulator which leads to hangs when loading firmware. Tested on i.MX28. Signed-off-by: Martin Kepplinger --- again, this isn't new. it's (rebased and simplified) https://patchwork.kernel.org/patch/4365751/ Thanks Robin for your input! revision history ---------------- v1: was just a question why this hasn't gone in earlier. 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..fdaca0fcec99 100644 --- a/drivers/mmc/host/mxs-mmc.c +++ b/drivers/mmc/host/mxs-mmc.c @@ -66,11 +66,13 @@ struct mxs_mmc_host { struct mmc_request *mrq; struct mmc_command *cmd; struct mmc_data *data; + struct regulator *vmmc; unsigned char bus_width; spinlock_t lock; int sdio_irq_en; bool broken_cd; + unsigned char power_mode; }; static int mxs_mmc_get_cd(struct mmc_host *mmc) @@ -517,6 +519,24 @@ static void mxs_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) else host->bus_width = 0; + if (host->vmmc && ios->power_mode != host->power_mode) { + switch (ios->power_mode) { + case MMC_POWER_OFF: + if (regulator_disable(host->vmmc)) + dev_err(mmc_dev(host->mmc), + "Failed to disable vmmc regulator\n"); + break; + case MMC_POWER_UP: + if (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