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: 10268225 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 1F985602C8 for ; Thu, 8 Mar 2018 14:55:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10036298D0 for ; Thu, 8 Mar 2018 14:55:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 095B028DA3; Thu, 8 Mar 2018 14:55:19 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80C5929EC8 for ; Thu, 8 Mar 2018 14:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934297AbeCHOx0 (ORCPT ); Thu, 8 Mar 2018 09:53:26 -0500 Received: from mail.bootlin.com ([62.4.15.54]:51433 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933878AbeCHOxM (ORCPT ); Thu, 8 Mar 2018 09:53:12 -0500 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 Cc: linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, Quentin Schulz , Thomas Petazzoni 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: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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,