Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6851337imu; Thu, 31 Jan 2019 00:21:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN6xUvUbICfPC05hgC++z+N7ntdqRt0EYelgC7fIpi1dcSbvMjHjLNpvF1Glh8ZpZPOV/u4b X-Received: by 2002:a17:902:22f:: with SMTP id 44mr33662261plc.137.1548922906537; Thu, 31 Jan 2019 00:21:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548922906; cv=none; d=google.com; s=arc-20160816; b=aEvzrOjYa228dHiMNXZdAUYe1l/uhiMNXpy7+NtDRRBIlLIa/JsPvtVkENySvXiFKV qil4V8M7Gh/vZkFch8pRZc+gCBBMtWLPbf7nbwW7Ml0Gw+/qiHehueVBLoBlz3DjC1pX T6BL4IUoG8GeazKgzbPJ5/2yP5IkOKSgk+lTCMZx48HAcYwcXV68XbB8aFk3QXkHtwFO OOMZN0mCsZXSgIyO0HjhxY+LEga2rqt2Zu7ZoKb3KZ88t1kBQWupuGJbWFL7ifD9PfBb SZ0EEp8NczCJhjiUh3lGyveHKChTrsCbsWzu6QCwUvC1alZYqKCqRlROqEa6laR2sx+w AN8Q== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=LonobxVNeAC2Pne2uC5zTe4crFZdcdDgO1I7FZ3nB8E=; b=pj9YM8KEmrqLZA5ZbHbBwo53qChPMGYiJv7glCyDQicHCzFqng4473lR9hXd8/1nnk wuJQBXkgjmerCl+xruzn/MSj11Nh/ea5n/eunBzgsqCOFuZeEBP7fxAk9wZQsZFjTYg8 /IA7i5nLI6+u59IE7aWeUZrGQFY+uCkWZ/7h/NjzcZz8sz3Cjd+MZbeDY9nERh5tXhtH qRSY5MchjXmIN4JkKGB26BJE1ANPyhG49OLujL+cBZ2igmS8yEwsF9rOpceSSjkFNjCm tkAljpOV+JG7fzooiWPcYLKiQMZUY4y5LIt7MdNCJifMUACigIBmSOEImCbVffm21Q7e lgQg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si3798694pgi.89.2019.01.31.00.21.30; Thu, 31 Jan 2019 00:21: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731521AbfAaIUJ (ORCPT + 99 others); Thu, 31 Jan 2019 03:20:09 -0500 Received: from protonic.xs4all.nl ([83.163.252.89]:57185 "EHLO protonic.nl" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725855AbfAaIUJ (ORCPT ); Thu, 31 Jan 2019 03:20:09 -0500 Received: from erd987 (unknown [192.168.2.69]) by sparta (Postfix) with ESMTP id AB3D244A0058; Thu, 31 Jan 2019 09:21:21 +0100 (CET) Date: Thu, 31 Jan 2019 09:20:06 +0100 From: Robin van der Gracht To: Ulf Hansson Cc: Martin Kepplinger , "linux-mmc@vger.kernel.org" , Linux ARM , Shawn Guo , Sascha Hauer , dl-linux-imx , Linux Kernel Mailing List , Martin Kepplinger Subject: Re: [PATCH v4] mmc: mxs-mmc: Introduce regulator support Message-ID: <20190131092006.363d1dd4@erd987> In-Reply-To: References: <20190128144119.10092-1-martink@posteo.de> Organization: Protonic Holland X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 28 Jan 2019 22:15:23 +0100 Ulf Hansson wrote: > On Mon, 28 Jan 2019 at 15:41, 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 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); > > This is wrong, as it may cause the regulator usage count to become > wrongly balanced. > > Instead, via ->set_ios() when calling mmc_regulator_set_ocr(), it will > take care of enabling and disabling the regulator depending of the > requested vdd voltage level. > > > + 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 > > > > BTW, you didn't really answer my earlier question about the TI WiFi > chip. Doesn't you need a special clock for WiFi chip as well? How do > you intend to manage that? I used an external 32K oscillator (SLOW_CLK) for my wl1271. Other clocks ware generated on the module. I had to supply a 'vmmc-supply' in your wl1271 devicetree node, which will be used to power on/off the wlan module. The supply should be a (delayed) GPIO controlled 'fixed-regulator' attached to the wlan_en pin on the module. 1: Documentation/devicetree/bindings/net/wireless/ti,wlcore.txt Kind regards, -- Robin van der Gracht Protonic Holland tel.: +31 (0) 229 212928 fax.: +31 (0) 229 210930 Factorij 36 / 1689 AL Zwaag