From patchwork Fri Feb 7 14:00:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 3605301 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 980529F344 for ; Fri, 7 Feb 2014 14:00:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF11320117 for ; Fri, 7 Feb 2014 14:00:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D74FE20120 for ; Fri, 7 Feb 2014 14:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753368AbaBGOA4 (ORCPT ); Fri, 7 Feb 2014 09:00:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18816 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752163AbaBGOAz (ORCPT ); Fri, 7 Feb 2014 09:00:55 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s17E0nx0011701 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Feb 2014 09:00:49 -0500 Received: from localhost.localdomain.com (vpn1-7-169.ams2.redhat.com [10.36.7.169]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s17E0j7w027623; Fri, 7 Feb 2014 09:00:48 -0500 From: Hans de Goede To: =?UTF-8?q?David=20Lanzend=C3=B6rfer?= Cc: Maxime Ripard , linux-mmc@vger.kernel.org, linux-sunxi@googlegroups.com, Hans de Goede Subject: [PATCH 1/2] sunxi-mci: Move clk_enable / disable into host_init / exit Date: Fri, 7 Feb 2014 15:00:40 +0100 Message-Id: <1391781641-7382-2-git-send-email-hdegoede@redhat.com> In-Reply-To: <1391781641-7382-1-git-send-email-hdegoede@redhat.com> References: <1391781641-7382-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Hans de Goede --- drivers/mmc/host/sunxi-mci.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/host/sunxi-mci.c b/drivers/mmc/host/sunxi-mci.c index 627d0ee..0eb59be 100644 --- a/drivers/mmc/host/sunxi-mci.c +++ b/drivers/mmc/host/sunxi-mci.c @@ -45,10 +45,23 @@ #include "sunxi-mci.h" -static void sunxi_mmc_init_host(struct mmc_host *mmc) +static int sunxi_mmc_init_host(struct mmc_host *mmc) { u32 rval; struct sunxi_mmc_host *smc_host = mmc_priv(mmc); + int ret; + + ret = clk_prepare_enable(smc_host->clk_ahb); + if (ret) { + dev_err(mmc_dev(smc_host->mmc), "AHB clk err %d\n", ret); + return ret; + } + ret = clk_prepare_enable(smc_host->clk_mod); + if (ret) { + dev_err(mmc_dev(smc_host->mmc), "MOD clk err %d\n", ret); + clk_disable_unprepare(smc_host->clk_ahb); + return ret; + } /* reset controller */ rval = mci_readl(smc_host, REG_GCTRL) | SDXC_HWReset; @@ -64,11 +77,15 @@ static void sunxi_mmc_init_host(struct mmc_host *mmc) rval = mci_readl(smc_host, REG_GCTRL)|SDXC_INTEnb; rval &= ~SDXC_AccessDoneDirect; mci_writel(smc_host, REG_GCTRL, rval); + + return 0; } static void sunxi_mmc_exit_host(struct sunxi_mmc_host *smc_host) { mci_writel(smc_host, REG_GCTRL, SDXC_HWReset); + clk_disable_unprepare(smc_host->clk_ahb); + clk_disable_unprepare(smc_host->clk_mod); } /* /\* UHS-I Operation Modes */ @@ -515,21 +532,11 @@ static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) udelay(200); } - err = clk_prepare_enable(host->clk_ahb); - if (err) { - dev_err(mmc_dev(host->mmc), "AHB clk err %d\n", err); - host->ferror = 1; - return; - } - err = clk_prepare_enable(host->clk_mod); + err = sunxi_mmc_init_host(mmc); if (err) { - dev_err(mmc_dev(host->mmc), "MOD clk err %d\n", err); - clk_disable_unprepare(host->clk_ahb); host->ferror = 1; return; } - - sunxi_mmc_init_host(mmc); enable_irq(host->irq); dev_dbg(mmc_dev(host->mmc), "power on!\n"); @@ -540,8 +547,6 @@ static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) dev_dbg(mmc_dev(host->mmc), "power off!\n"); disable_irq(host->irq); sunxi_mmc_exit_host(host); - clk_disable_unprepare(host->clk_ahb); - clk_disable_unprepare(host->clk_mod); if (!IS_ERR(host->vmmc)) mmc_regulator_set_ocr(host->mmc, host->vmmc, 0); host->ferror = 0;