From patchwork Tue Jan 4 06:03:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wu X-Patchwork-Id: 12703000 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 2FC3EC433F5 for ; Tue, 4 Jan 2022 06:05:20 +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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=SPVWswigipyTxqjA0B/MYQBFvHWo1CEx/BDuaUjn+7Y=; b=rDUiHRkdte+StW LHkBYh8VVkFUM5QNVUW443Qr99joKHl/H0lZUL36Bn1xba2MhmXbIbMMxbiFgQFA0CXBiFQ6Q6jDJ LdYFtmSjUyiCbFAf54EMwm2HqXdx6GqkWGLs8h2A5FHRYFIVKg7r3R4UFr7x5jdlPUsC5qmUkVgNa keO5XM2SUqzsKLrxtY6iUMSZ67TMXiacc4/lZAVM7ZXdIZgfwc94DJC8fC8Ci/SGl7NSIye4elptp xmV6sFqcHh37vSp2rGTFVN8BrkwgWDLRQOwjCtqISyKAQAG2a32eOt0wZ3GVuRC2cL5e1Gn83Wdey mnH/BEEjA3t2+IfgPb+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4cv7-00APdQ-Hj; Tue, 04 Jan 2022 06:03:41 +0000 Received: from out28-196.mail.aliyun.com ([115.124.28.196]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4cv3-00APbq-IN for linux-arm-kernel@lists.infradead.org; Tue, 04 Jan 2022 06:03:40 +0000 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.1070646|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_alarm|0.00848475-0.00139035-0.990125; FP=0|0|0|0|0|-1|-1|-1; HT=ay29a033018047207; MF=michael@allwinnertech.com; NM=1; PH=DS; RN=11; RT=11; SR=0; TI=SMTPD_---.MWR.1lZ_1641276209; Received: from sunxibot.allwinnertech.com(mailfrom:michael@allwinnertech.com fp:SMTPD_---.MWR.1lZ_1641276209) by smtp.aliyun-inc.com(10.147.41.199); Tue, 04 Jan 2022 14:03:29 +0800 From: Michael Wu To: ulf.hansson@linaro.org, mripard@kernel.org, wens@csie.org, samuel@sholland.org, andre.przywara@arm.com Cc: jernej.skrabec@gmail.com, linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Michael Wu Subject: [PATCH v2] mmc: sunxi-mmc: check ocr_avail on resource request Date: Tue, 4 Jan 2022 14:03:25 +0800 Message-Id: <20220104060325.3957-1-michael@allwinnertech.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220103_220337_818847_8F061429 X-CRM114-Status: GOOD ( 10.22 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 = <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 --- drivers/mmc/host/sunxi-mmc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c index 2702736a1c57..0da74bddaf87 100644 --- a/drivers/mmc/host/sunxi-mmc.c +++ b/drivers/mmc/host/sunxi-mmc.c @@ -1300,6 +1300,11 @@ static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host, 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);