From patchwork Thu Mar 8 14:52:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 10268237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C09E86037E for ; Thu, 8 Mar 2018 14:56:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0D4B22230 for ; Thu, 8 Mar 2018 14:56:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4DBF2846F; Thu, 8 Mar 2018 14:56:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 49F5422230 for ; Thu, 8 Mar 2018 14:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=M6MuzCpXHy79W7nwTM/5JEkIHVhsSfW3mLp1s1M2deU=; b=NPqEpzh8g2HCupS9jQxocc4mQF tzCwkuHSavDWnLtD5R+CBnqfsz6+55ZW+5/Y8JogdJ9eYupGE4kzZiyYRcFQAb++JqkA5VV28nA+7 XpolOtUyQIKzp79QXgBSrLatuAUFzDsiHMNm9dOivV3KX03ZQzZa2pCFoyI6O2M+5byxvAvwqVDYG vyE2WPsjQQ/TbJVrZNbOPvW2lsZKfN4/0UW/6N4b6SIJ5lh/QLewiPZ0TiS4Y/bMG7MRZy7FWe285 Gg1GM164tfzZqgW+SHWNTltDYntICmEhqtiXP6ljzt3kDBvwA1Axpuxaqn4d5z6xsfE5wVWBmS3zs b/4qTB0A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1etwxZ-00023n-5T; Thu, 08 Mar 2018 14:55:57 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1etwv7-0007gR-B5 for linux-arm-kernel@lists.infradead.org; Thu, 08 Mar 2018 14:53:32 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id C0ACA207E5; Thu, 8 Mar 2018 15:53:09 +0100 (CET) Received: from localhost (unknown [185.94.189.190]) by mail.bootlin.com (Postfix) with ESMTPSA id 309F620012; Thu, 8 Mar 2018 15:53:09 +0100 (CET) From: Maxime Ripard To: Chen-Yu Tsai , Maxime Ripard , ulf.hansson@linaro.org Subject: [PATCH v2 6/8] mmc: sunxi: Move the reset deassertion before enabling the clocks Date: Thu, 8 Mar 2018 15:52:52 +0100 Message-Id: <4b3035d91ee18d544b5893470258396b5b7880a1.1520520655.git-series.maxime.ripard@bootlin.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180308_065326_469640_C150AD70 X-CRM114-Status: GOOD ( 13.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni , linux-mmc@vger.kernel.org, Quentin Schulz , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP As per Allwinner guidelines, the reset line should be deasserted before turning the clocks on. Implement it in our driver as well. Signed-off-by: Maxime Ripard --- drivers/mmc/host/sunxi-mmc.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c index 34bc90bc04b2..c6431f6e816f 100644 --- a/drivers/mmc/host/sunxi-mmc.c +++ b/drivers/mmc/host/sunxi-mmc.c @@ -1188,10 +1188,19 @@ static int sunxi_mmc_enable(struct sunxi_mmc_host *host) { int ret; + if (!IS_ERR(host->reset)) { + ret = reset_control_reset(host->reset); + if (ret) { + dev_err(host->dev, "Couldn't reset the MMC controller (%d)\n", + ret); + return ret; + } + } + ret = clk_prepare_enable(host->clk_ahb); if (ret) { - dev_err(dev, "Couldn't enable the bus clocks (%d)\n", ret); - return ret; + dev_err(host->dev, "Couldn't enable the bus clocks (%d)\n", ret); + goto error_assert_reset; } ret = clk_prepare_enable(host->clk_mmc); @@ -1212,28 +1221,16 @@ static int sunxi_mmc_enable(struct sunxi_mmc_host *host) goto error_disable_clk_output; } - if (!IS_ERR(host->reset)) { - ret = reset_control_reset(host->reset); - if (ret) { - dev_err(dev, "Couldn't reset the MMC controller (%d)\n", - ret); - goto error_disable_clk_sample; - } - } - /* * Sometimes the controller asserts the irq on boot for some reason, * make sure the controller is in a sane state before enabling irqs. */ ret = sunxi_mmc_reset_host(host); if (ret) - goto error_assert_reset; + goto error_disable_clk_sample; return 0; -error_assert_reset: - if (!IS_ERR(host->reset)) - reset_control_assert(host->reset); error_disable_clk_sample: clk_disable_unprepare(host->clk_sample); error_disable_clk_output: @@ -1242,6 +1239,9 @@ static int sunxi_mmc_enable(struct sunxi_mmc_host *host) clk_disable_unprepare(host->clk_mmc); error_disable_clk_ahb: clk_disable_unprepare(host->clk_ahb); +error_assert_reset: + if (!IS_ERR(host->reset)) + reset_control_assert(host->reset); return ret; } @@ -1249,13 +1249,13 @@ static void sunxi_mmc_disable(struct sunxi_mmc_host *host) { sunxi_mmc_reset_host(host); - if (!IS_ERR(host->reset)) - reset_control_assert(host->reset); - clk_disable_unprepare(host->clk_sample); clk_disable_unprepare(host->clk_output); clk_disable_unprepare(host->clk_mmc); clk_disable_unprepare(host->clk_ahb); + + if (!IS_ERR(host->reset)) + reset_control_assert(host->reset); } static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host,