From patchwork Fri Jan 24 22:28:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Kryger X-Patchwork-Id: 23691 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0F7B203C5 for ; Fri, 24 Jan 2014 22:34:20 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id fa1sf8996509pad.0 for ; Fri, 24 Jan 2014 14:34:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe:content-type; bh=qBSZ1MhRkEjA1DT6IRwJEqXqG9t4FgK4+e9XwmiFGzI=; b=cQnTRM1VnXIk7b1oTHYL8UMYFLS7EBTPbL2Qbxq11wzZveqyU5SvnLT64VEYEc7kwq OJNb1H5WrZPD3Kb/keuRaVwIY4NZMuO7oBYoKjpm5f8xFHwfmXQFqhvKvGwpX+LLD8IT gfRj/O/lzsAGRngWiR/5aqI6SCFadqQRK0fvC0Se107WBBJLJrekpPe/JRAzYjKUN28o JYQtYZhW2Oe0RbSVh6f9a+vMz37NVTWofqzUK2AOr5Qhc3ObGh+gOGGkGscxPTBUF6yF 8oP4hpHiopABugAreqyd6qNyFoRC0Ni/r63Nqa5BzVVJPpGzP0ZS6xEUHOzeTp3mvFkG DrSQ== X-Gm-Message-State: ALoCoQn1mcVcSMQolL8dDuZ8+ehWmjxrhn23kQVCwHRNprBh8TTHJqfJCZ5KEolEcMRkSpVfu62R X-Received: by 10.66.189.163 with SMTP id gj3mr6077354pac.32.1390602859630; Fri, 24 Jan 2014 14:34:19 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.101.134 with SMTP id u6ls784236qge.79.gmail; Fri, 24 Jan 2014 14:34:19 -0800 (PST) X-Received: by 10.58.219.1 with SMTP id pk1mr25908vec.49.1390602859477; Fri, 24 Jan 2014 14:34:19 -0800 (PST) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id sj10si1247774vcb.15.2014.01.24.14.34.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 Jan 2014 14:34:19 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id le5so2209147vcb.2 for ; Fri, 24 Jan 2014 14:34:19 -0800 (PST) X-Received: by 10.220.110.210 with SMTP id o18mr26884vcp.49.1390602859331; Fri, 24 Jan 2014 14:34:19 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp11297vcz; Fri, 24 Jan 2014 14:34:18 -0800 (PST) X-Received: by 10.182.117.195 with SMTP id kg3mr13832084obb.17.1390602858605; Fri, 24 Jan 2014 14:34:18 -0800 (PST) Received: from mail-gw1-out.broadcom.com (mail-gw1-out.broadcom.com. [216.31.210.62]) by mx.google.com with ESMTP id so9si1267418oeb.36.2014.01.24.14.34.17 for ; Fri, 24 Jan 2014 14:34:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of tkryger@broadcom.com designates 216.31.210.62 as permitted sender) client-ip=216.31.210.62; X-IronPort-AV: E=Sophos;i="4.95,715,1384329600"; d="scan'208";a="11312930" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw1-out.broadcom.com with ESMTP; 24 Jan 2014 14:54:38 -0800 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.1.438.0; Fri, 24 Jan 2014 14:34:17 -0800 Received: from mail-sj1-12.sj.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.1.438.0; Fri, 24 Jan 2014 14:34:17 -0800 Received: from mps-infra-lab3.broadcom.com (mps-infra-lab3.sj.broadcom.com [10.19.114.109]) by mail-sj1-12.sj.broadcom.com (Postfix) with ESMTP id 2B15E211B3; Fri, 24 Jan 2014 14:28:49 -0800 (PST) Received: by mps-infra-lab3.broadcom.com (Postfix, from userid 1004) id 09C1E458A29; Fri, 24 Jan 2014 14:28:48 -0800 (PST) From: Tim Kryger To: Chris Ball , Christian Daudt , Ulf Hansson , Axel Lin CC: Tim Kryger , Linux MMC List , Linux Kernel List , Linaro Patches List Subject: [PATCH] mmc: sdhci-bcm-kona: Add basic use of clocks Date: Fri, 24 Jan 2014 14:28:34 -0800 Message-ID: <1390602514-2843-1-git-send-email-tim.kryger@linaro.org> X-Mailer: git-send-email 1.8.0.1 MIME-Version: 1.0 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tim.kryger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Enable the external clock needed by the host controller during the probe and disable it during the remove. Signed-off-by: Tim Kryger Reviewed-by: Markus Mayer Reviewed-by: Matt Porter Reviewed-by: Christian Daudt --- This was dropped from "Update Kona drivers to use clocks" series so the remaining patches could get into v3.14: https://lkml.org/lkml/2014/1/24/286 Without this change the bcm28155_ap board can not be configured to use the bcm281xx clock driver since unused clocks will be disabled during late init. drivers/mmc/host/sdhci-bcm-kona.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c index 7a190fe..923eefa 100644 --- a/drivers/mmc/host/sdhci-bcm-kona.c +++ b/drivers/mmc/host/sdhci-bcm-kona.c @@ -54,6 +54,7 @@ struct sdhci_bcm_kona_dev { struct mutex write_lock; /* protect back to back writes */ + struct clk *external_clk; }; @@ -257,6 +258,24 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev) goto err_pltfm_free; } + /* Get and enable the external clock */ + kona_dev->external_clk = devm_clk_get(dev, NULL); + if (IS_ERR(kona_dev->external_clk)) { + dev_err(dev, "Failed to get external clock\n"); + ret = PTR_ERR(kona_dev->external_clk); + goto err_pltfm_free; + } + + if (clk_set_rate(kona_dev->external_clk, host->mmc->f_max) != 0) { + dev_err(dev, "Failed to set rate external clock\n"); + goto err_pltfm_free; + } + + if (clk_prepare_enable(kona_dev->external_clk) != 0) { + dev_err(dev, "Failed to enable external clock\n"); + goto err_pltfm_free; + } + dev_dbg(dev, "non-removable=%c\n", (host->mmc->caps & MMC_CAP_NONREMOVABLE) ? 'Y' : 'N'); dev_dbg(dev, "cd_gpio %c, wp_gpio %c\n", @@ -271,7 +290,7 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev) ret = sdhci_bcm_kona_sd_reset(host); if (ret) - goto err_pltfm_free; + goto err_clk_disable; sdhci_bcm_kona_sd_init(host); @@ -307,6 +326,9 @@ err_remove_host: err_reset: sdhci_bcm_kona_sd_reset(host); +err_clk_disable: + clk_disable_unprepare(kona_dev->external_clk); + err_pltfm_free: sdhci_pltfm_free(pdev); @@ -316,7 +338,18 @@ err_pltfm_free: static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev) { - return sdhci_pltfm_unregister(pdev); + struct sdhci_host *host = platform_get_drvdata(pdev); + struct sdhci_pltfm_host *pltfm_priv = sdhci_priv(host); + struct sdhci_bcm_kona_dev *kona_dev = sdhci_pltfm_priv(pltfm_priv); + int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); + + sdhci_remove_host(host, dead); + + clk_disable_unprepare(kona_dev->external_clk); + + sdhci_pltfm_free(pdev); + + return 0; } static struct platform_driver sdhci_bcm_kona_driver = {