Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B2EDC433F5 for ; Fri, 31 Dec 2021 14:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Message-ID:Mime-Version:References: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=7MBCCKT5aU9j9li/YlwfHl7js5i5WzR+yR6sgOhEBuk=; b=ZJVfWmDTXVNO+p MTAN4X8Q0KLN7MnEJHM9ehhytD535UrSBNy7wri8DJC7+dYWb9ynyLSwx0fH2luYrumALNMfRYGlr BEwVrbIsTLybC4dRRhcpJ9sWpNuN55tuYMw0OauaWmrH1mNfWqdOvfhE9z2yxC/uuatB2wiRqYaR5 rsnLjYwnqJm+BM9zSe8rsL8frs1hPJncdzuU5RSv64vKgGCaTOFbYv4Izh/g9fVMrtIvxElji4F/N SK9Y17rZ8IgBQuARxKqg2Xdph2tvLxfDQtjZUtpAA9gFtBwnDSkM7veDMIXkH2EHB+6Jr3oNMPldr 1otUXnCWAJsEqxHEeVXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n3IYJ-0067W2-CP; Fri, 31 Dec 2021 14:06:39 +0000 Received: from out28-53.mail.aliyun.com ([115.124.28.53]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n3IYE-0067Ve-E2 for linux-arm-kernel@lists.infradead.org; Fri, 31 Dec 2021 14:06:36 +0000 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.06537051|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_regular_dialog|0.0358684-0.00370216-0.960429; FP=0|0|0|0|0|-1|-1|-1; HT=ay29a033018047206; MF=michael@allwinnertech.com; NM=1; PH=DS; RN=10; RT=10; SR=0; TI=SMTPD_---.MV40a3-_1640959584; Received: from YanYan-NB(mailfrom:michael@allwinnertech.com fp:SMTPD_---.MV40a3-_1640959584) by smtp.aliyun-inc.com(10.147.42.197); Fri, 31 Dec 2021 22:06:26 +0800 Date: Fri, 31 Dec 2021 22:06:23 +0800 From: "michael@allwinnertech.com" To: "Ulf Hansson" Cc: mripard , wens , samuel , andre.przywara , jernej.skrabec , linux-mmc , linux-arm-kernel , linux-sunxi , linux-kernel Subject: Re: [PATCH 1/3] mmc:sunxi-mmc:add support on discrete device power supply References: <20211222030634.33816-1-michael@allwinnertech.com>, , <2021123116275961132724@allwinnertech.com>, X-Priority: 3 X-GUID: 4FA5C177-3B19-4D61-B241-12BA2B9C9D5A X-Has-Attach: no X-Mailer: Foxmail 7.2.22.194[cn] Mime-Version: 1.0 Message-ID: <2021123121313177857228@allwinnertech.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211231_060634_717448_ABF87874 X-CRM114-Status: GOOD ( 34.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org > On Fri, 31 Dec 2021 at 09:28, michael@allwinnertech.com > wrote: > > > > > From: Ulf Hansson > > > Date: 2021-12-29 00:49 > > > To: Michael Wu > > > CC: mripard; wens; samuel; andre.przywara; jernej.skrabec; linux-mmc; linux-arm-kernel; linux-sunxi; linux-kernel > > > Subject: Re: [PATCH 1/3] mmc:sunxi-mmc:add support on discrete device power supply > > > On Wed, 22 Dec 2021 at 04:07, Michael Wu wrote: > > > > > > > > Because some platform has no regulator, only use discrete devices > > > > to supply power,For this situation, to use sd/mmc card, we add ocr manually > > > > > > > > Signed-off-by: Michael Wu > > > > --- > > > > drivers/mmc/host/sunxi-mmc.c | 8 ++++++++ > > > > 1 file changed, 8 insertions(+) > > > > > > > > diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c > > > > index 2702736a1c57..afeefead6501 100644 > > > > --- a/drivers/mmc/host/sunxi-mmc.c > > > > +++ b/drivers/mmc/host/sunxi-mmc.c > > > > @@ -1300,6 +1300,14 @@ static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host, > > > > if (ret) > > > > return ret; > > > > > > > > + /** > > > > + * Some platforms has no regulator. Discrete devices are used instead. > > > > + * To support sd/mmc card, we need to add ocr manually. > > > > + */ > > > > + if (!host->mmc->ocr_avail) > > > > + host->mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; > > > > + > > > > > > Rather than doing this, I suggest you hook up a fixed vmmc regulator in the DTS. > > > > > > Nevertheless, it seems reasonable to check that the ocr_avail gets set > > > up correctly. And if it doesn't, perhaps we should print a warning and > > > return an error code. > > > > > > > + > > > > host->reg_base = devm_platform_ioremap_resource(pdev, 0); > > > > if (IS_ERR(host->reg_base)) > > > > return PTR_ERR(host->reg_base); > > > > > > Kind regards > > > Uffe > > > > Dear Uffe, > > Thanks for your suggestion. It is a better solution. > > I've modified my patch. Please check if it's reasonable. If it is, I'll re-sumbit it later. > > > > --- > > Subject: [PATCH v2] mmc: sunxi-mmc: check ocr_avail on resource request > > > > Some platforms have no regulator, discrete power devices are used instead. > > However, sunxi_mmc_probe does not catch this exception when regulator is > > absent in DTS. This leads to sd or eMMC init failure. > > To solve this, a fixed vmmc regulator must be hooked up in DTS, like this: > > reg_dummy_vmmc: dummy_vmmc { > > compatible = "regulator-fixed"; > > regulator-name = "dummy-vmmc"; > > regulator-min-microvolt = <500000>; > > regulator-max-microvolt = <3500000>; > > The min/max should be set to the same value as you can't really change > the voltage levels. > > If you know the voltage level that is supplied for your platform, then > state this value - otherwise I would suggest picking 3.3V, which is > rather commonly used for MMC/SD. Okay. The supplied voltage is 2.7V~3.6V. l'll correct the min/max value to 3.3V: regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; > > }; > > mmc0:mmc@4020000 { > > compatible = "allwinner,sun50i-a100-emmc"; > > device_type = "mmc0"; > > vmmc-supply = <®_dummy_vmmc>; > > } > > In this patch, we print an error message and abort the probe process if > > the regulator is not specified in DTS. > > > > Signed-off-by: Michael Wu > > --- > > > > diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c > > index 2702736..0da74bd 100644 > > --- a/drivers/mmc/host/sunxi-mmc.c > > +++ b/drivers/mmc/host/sunxi-mmc.c > > @@ -1300,6 +1300,11 @@ > > if (ret) > > return ret; > > > > + if (!host->mmc->ocr_avail) { > > + dev_err(&pdev->dev, "Could not get mmc regulator\n"); > > + return -EINVAL; > > + } > > + > > host->reg_base = devm_platform_ioremap_resource(pdev, 0); > > if (IS_ERR(host->reg_base)) > > return PTR_ERR(host->reg_base); > > > > Best Regards, > > Michael Wu > > Yep, this looks good to me! > > Kind regards > Uffe I'll submit the patch once I get back to work. Thanks for your effort and happy new year :) Best Regards, Michael Wu _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel