From patchwork Fri Sep 14 09:08:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chander Kashyap X-Patchwork-Id: 11409 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 48D1623E41 for ; Fri, 14 Sep 2012 09:09:55 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id A17DBA32EAD for ; Fri, 14 Sep 2012 09:09:54 +0000 (UTC) Received: by ieak11 with SMTP id k11so6203860iea.11 for ; Fri, 14 Sep 2012 02:09:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=kCMb7pe7xnvEqK0QFNbH80Z1USpgSsV0ftBOcpKWyvY=; b=FjEJ+Mf3R2o2wTCPEwiEf4y3gtrxPXgYBoFdGwzFks9TZi4eBL7Wscx6qDm3aXuyXR 9V5vHlc2r8k/jptXVdwFEiYIHFaMx6V1M2TCvLpjsNPFZMwC/ueEYkUJZE4gbwjQdfi/ S5IvDtxRwWfGpqJ/tZLNhBfsUiuTY6V6KMsQBGeEkpYSXPeUWwnEwKLASplprpDP8YGz g4xjs3i0E42u+dh/BIoRPAuzz4OVww7aIna0p5PhbgiGMTBls0MhcOv1Rme3KoN9tjMY PZb6m3g/i3j9Vey51ftQJ6dezbiV8BZFYUet95a/y9YQ2woQnEYtE+8hvHcXlcKHg0g1 3RkA== Received: by 10.50.7.212 with SMTP id l20mr2240687iga.43.1347613793965; Fri, 14 Sep 2012 02:09:53 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp178475igc; Fri, 14 Sep 2012 02:09:53 -0700 (PDT) Received: by 10.68.202.193 with SMTP id kk1mr4343925pbc.136.1347613793208; Fri, 14 Sep 2012 02:09:53 -0700 (PDT) Received: from mail-pz0-f45.google.com (mail-pz0-f45.google.com [209.85.210.45]) by mx.google.com with ESMTPS id rr1si1933309pbc.188.2012.09.14.02.09.53 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Sep 2012 02:09:53 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.45 is neither permitted nor denied by best guess record for domain of chander.kashyap@linaro.org) client-ip=209.85.210.45; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.45 is neither permitted nor denied by best guess record for domain of chander.kashyap@linaro.org) smtp.mail=chander.kashyap@linaro.org Received: by mail-pz0-f45.google.com with SMTP id n15so2517828dad.18 for ; Fri, 14 Sep 2012 02:09:53 -0700 (PDT) Received: by 10.68.217.69 with SMTP id ow5mr4471506pbc.35.1347613792923; Fri, 14 Sep 2012 02:09:52 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id qo8sm683031pbb.19.2012.09.14.02.09.49 (version=SSLv3 cipher=OTHER); Fri, 14 Sep 2012 02:09:52 -0700 (PDT) From: Chander Kashyap To: linux-mmc@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: cjb@laptop.org, ben@simtec.co.uk, broonie@opensource.wolfsonmicro.com, kgene.kim@samsung.com, girish.shivananjappa@linaro.org, patches@linaro.org, Chander Kashyap Subject: [PATCH 1/3] mmc: sdhci-s3c: Enable only required bus clock Date: Fri, 14 Sep 2012 14:38:49 +0530 Message-Id: <1347613731-29428-2-git-send-email-chander.kashyap@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1347613731-29428-1-git-send-email-chander.kashyap@linaro.org> References: <1347613731-29428-1-git-send-email-chander.kashyap@linaro.org> X-Gm-Message-State: ALoCoQkUyzwLLOUpRW5Dk4HfOvZbzAtmosl2iuMhm6HnPt5u2K5a6yYExxgQWQFmwUEjjXO8zIvK In case of multiple bus clock sources, all the clock sources were getting enabled. As only one clock source is needed at the time hence enable only the required bus clock. This patch does as follows: 1. In sdhci_s3c_probe enable only required bus clock source. 2. Handle the disabling of old bus clock and enables the best clock selected in sdhci_s3c_set_clock(). Signed-off-by: Chander Kashyap Acked-by: Jaehoon Chung --- drivers/mmc/host/sdhci-s3c.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index 00969ba..0cbb4c2 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c @@ -203,10 +203,12 @@ static void sdhci_s3c_set_clock(struct sdhci_host *host, unsigned int clock) best_src, clock, best); /* select the new clock source */ - if (ourhost->cur_clk != best_src) { struct clk *clk = ourhost->clk_bus[best_src]; + clk_enable(clk); + clk_disable(ourhost->clk_bus[ourhost->cur_clk]); + /* turn clock off to card before changing clock source */ writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL); @@ -501,8 +503,6 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) */ sc->cur_clk = ptr; - clk_enable(clk); - dev_info(dev, "clock source %d: %s (%ld Hz)\n", ptr, name, clk_get_rate(clk)); } @@ -513,6 +513,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) goto err_no_busclks; } + clk_enable(sc->clk_bus[sc->cur_clk]); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); host->ioaddr = devm_request_and_ioremap(&pdev->dev, res); if (!host->ioaddr) { @@ -621,9 +623,9 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) return 0; err_req_regs: + clk_disable(sc->clk_bus[sc->cur_clk]); for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) { if (sc->clk_bus[ptr]) { - clk_disable(sc->clk_bus[ptr]); clk_put(sc->clk_bus[ptr]); } } @@ -658,9 +660,9 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); + clk_disable(sc->clk_bus[sc->cur_clk]); for (ptr = 0; ptr < 3; ptr++) { if (sc->clk_bus[ptr]) { - clk_disable(sc->clk_bus[ptr]); clk_put(sc->clk_bus[ptr]); } }