Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3360441imu; Mon, 28 Jan 2019 03:34:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN6Rml1lWYlbG+YS0fZECFnQ6fgS67TRJt7qQy9VFtv+pY8cxNpWvcDot++B+0yESq5FND0Q X-Received: by 2002:a17:902:4d46:: with SMTP id o6mr20536199plh.302.1548675268420; Mon, 28 Jan 2019 03:34:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548675268; cv=none; d=google.com; s=arc-20160816; b=PrpDtOflpUum9stuKOyL114xhmKV3wQHjmbdV2C5qRqo4XDef/awo13rei1TcgAj4P pKGmdg1kxAyv55JAgqpZ9AEeOIh4lSII7/D51MLZtQ9shyYLxxlZnMv2S6PMX8kmAYBK USsKinkIUR1OF26yGrHkyW1GwF4Q1n4zW3304FEFbRA5IWeXziAt2xi5+oLOV8z5b8kl SKM466Sp5e5jK7UCEiytcH6oAMCI1nO20Skh3b+Be9eT7EjQFH3nH2j36erFA5u5+TeO r4Av/PXJ8q0afa0Kbtgk7g10BVdacxK9CYpRctVPPbRNqzJkQ394liEWd5L1FxfaP8p0 DkjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=eBDrm1PCVZfCKpICeTE3MM436tQNH63XHBlLwrxqY+g=; b=l1lNhQ6euRgA22MWGISZGfiEV2Lw3pcKPCkprP5R7Ofgy+bjvEaAv4TMOdDkY4dld6 nfSTuxgDB/iIhCwvbGrnMop5wwfilDeXdgPSMyYCXkcFN3PBJM1Q6K4u2xLg9qMxueAC vPuspYmR+aVLTuuP2lA/vqyVJFZy2ejEjtgfJhKI2ILamRuRY98o4ARANUphSN4Z4P0P RybCtV/kDYruXrTrRDW6CibIQSN414LqSryXu8q82/z1V9wu0L481ZiwwrShYRql7nb9 eiaI7k8zFVmEUZxhsaWDJ3nTWOM3bvHtZtx1OvyBVSKKMt1GrgLGkSZAC05DqEqy7r4i TjMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B6IXIxs2; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 37si34647815plq.210.2019.01.28.03.34.12; Mon, 28 Jan 2019 03:34:28 -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=@linaro.org header.s=google header.b=B6IXIxs2; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726689AbfA1Ld4 (ORCPT + 99 others); Mon, 28 Jan 2019 06:33:56 -0500 Received: from mail-ua1-f68.google.com ([209.85.222.68]:41373 "EHLO mail-ua1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726415AbfA1Ld4 (ORCPT ); Mon, 28 Jan 2019 06:33:56 -0500 Received: by mail-ua1-f68.google.com with SMTP id z24so5453982ual.8 for ; Mon, 28 Jan 2019 03:33:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eBDrm1PCVZfCKpICeTE3MM436tQNH63XHBlLwrxqY+g=; b=B6IXIxs2rNeEKlGAAyr/j/89sOBRoDvDGz30BOTojHr8W10ibuNDOTAsBty5zduvPU FzfhlMVVXPMFBQcnNaaSYFTtUxvMS/YIseTjEiBVaInwBAkaq87rGGbcj6mADRC8g7TA nC/Jz92sM0ZtvA57OmmS2d8tee4SHU8gjB4pg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eBDrm1PCVZfCKpICeTE3MM436tQNH63XHBlLwrxqY+g=; b=TdOtH2VJtUFBYkLB8pLlmka7AWLuyW8KYnJBEB5wCx2irTxeKA3kYvSfe0NIYgwMQ0 rJTXjExoDuXpeKMqyK4kYiTKQTLz3hFsNF6xT04rcXs0o+KDFuUAT5Ly5lwgAeAJUh93 yB8efF2lxpckjnPI47AwJlbKL+s9We9TfT28/gZ+HC+dm2Iy2/wsDx6asdd+xPVdLIrp KzKJMw5j3SYW/Rlu7+sbqT6Uc9cv79APr+OvaSKnJJOiTi1QefoayD7OSLvOuxetsAHQ tZd6t/BVpVbjv/6ENefSlMjz0d7uMQhR7LedSLguaOkGqR8LXwfWF6WDe1vdCqnoXesn jSLQ== X-Gm-Message-State: AJcUukeqtU6ACywRLpCBFlxfPCOrtIBiC26iX5ON+PzgFwu1iLwT+EJU U0y0XaW5yXxDFTb464NxGwYUHzbv5x+sy/GWZNflOQ== X-Received: by 2002:ab0:3484:: with SMTP id c4mr8899547uar.39.1548675234990; Mon, 28 Jan 2019 03:33:54 -0800 (PST) MIME-Version: 1.0 References: <20190128102022.1880-1-martink@posteo.de> In-Reply-To: <20190128102022.1880-1-martink@posteo.de> From: Ulf Hansson Date: Mon, 28 Jan 2019 12:33:19 +0100 Message-ID: Subject: Re: [PATCH v2] mmc: mxs-mmc: Introduce regulator support To: Martin Kepplinger Cc: "linux-mmc@vger.kernel.org" , Linux ARM , Robin van der Gracht , Shawn Guo , Sascha Hauer , Sascha Hauer , dl-linux-imx , Linux Kernel Mailing List , Martin Kepplinger Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 28 Jan 2019 at 11:20, Martin Kepplinger wrote: > > 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. Isn't there a GPIO that needs to be toggled and separate clk for the WiFi chip that needs to be enabled as well? > > 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; You don't need this here as this is already part of the generic struct mmc_host (via the struct mmc_supply). > > unsigned char bus_width; > spinlock_t lock; > int sdio_irq_en; > bool broken_cd; > + unsigned char power_mode; Ditto. > }; > > 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"); You should use mmc_regulator_set_ocr() instead. > + break; > + case MMC_POWER_UP: > + if (regulator_enable(host->vmmc)) Ditto. > + 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; This isn't needed. The state is already controlled by the mmc core. > > reg_vmmc = devm_regulator_get(&pdev->dev, "vmmc"); You should use mmc_regulator_get_supply() instead. > - 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 > Kind regards Uffe