From patchwork Thu Jul 5 10:14:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 1159041 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C0D1740ABE for ; Thu, 5 Jul 2012 10:14:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932100Ab2GEKO0 (ORCPT ); Thu, 5 Jul 2012 06:14:26 -0400 Received: from mail-bk0-f46.google.com ([209.85.214.46]:42557 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755103Ab2GEKOQ (ORCPT ); Thu, 5 Jul 2012 06:14:16 -0400 Received: by bkwj10 with SMTP id j10so3238387bkw.19 for ; Thu, 05 Jul 2012 03:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=bMGFZLvKMNyldgeux2S18Anz+zdTCjOiPHPwjlYwKNA=; b=0qM8pCG2LiC3jEfEWhATTGeJ6rEGaNLfBux6+cogaaoWyZSugAB/RYk75uxDV9MXlN poy/8dPFr4dI7wVzxaz+u30xP28Hpf0ZYgXP1/+52UpI5Gm2uyfUdR7iSX36TOuon8ZN 7WEoUhpBH0bQbYQfXCT13B/WfE4mA1+dG5kWi7e4piXLKiglVrAiLn+79q5aMrlwp9oz eukgXZ0Q6U4pI7os8B0dVpqZJ30M7vtpX7ALzwwLb49TMQxxz6n7ABMZvLbNB8LS/ob1 HjAOkhlYmgigar9iVBQNFOk7kTafqXMaGJeSnuIpLGozbjGAB7OJyVVikWxOkOtA1f9a 8K2A== Received: by 10.204.148.75 with SMTP id o11mr13251775bkv.11.1341483255407; Thu, 05 Jul 2012 03:14:15 -0700 (PDT) Received: from localhost.localdomain (dslc-082-083-240-137.pools.arcor-ip.net. [82.83.240.137]) by mx.google.com with ESMTPS id m2sm20250426bkm.2.2012.07.05.03.14.13 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 03:14:14 -0700 (PDT) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Cc: Chris Ball , Anton Vorontsov , Shawn Guo , Viresh Kumar , Manuel Lauss , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/2] mmc: sdhci-dove: Prepare for common clock framework Date: Thu, 5 Jul 2012 12:14:01 +0200 Message-Id: <1341483241-18300-2-git-send-email-sebastian.hesselbarth@googlemail.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1341483241-18300-1-git-send-email-sebastian.hesselbarth@googlemail.com> References: <1341483241-18300-1-git-send-email-sebastian.hesselbarth@googlemail.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org As mach-dove is moving towards common clock framework prepare the sdhci driver to grab it's clock. Signed-off-by: Sebastian Hesselbarth Cc: Chris Ball Cc: Anton Vorontsov Cc: Shawn Guo Cc: Viresh Kumar Cc: Manuel Lauss Cc: linux-mmc@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/mmc/host/sdhci-dove.c | 48 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c index 9c85368..a6e53a1 100644 --- a/drivers/mmc/host/sdhci-dove.c +++ b/drivers/mmc/host/sdhci-dove.c @@ -20,11 +20,17 @@ */ #include +#include +#include #include #include #include "sdhci-pltfm.h" +struct sdhci_dove_priv { + struct clk *clk; +}; + static u16 sdhci_dove_readw(struct sdhci_host *host, int reg) { u16 ret; @@ -72,11 +78,51 @@ static struct sdhci_pltfm_data sdhci_dove_pdata = { static int __devinit sdhci_dove_probe(struct platform_device *pdev) { - return sdhci_pltfm_register(pdev, &sdhci_dove_pdata); + struct sdhci_host *host; + struct sdhci_pltfm_host *pltfm_host; + struct sdhci_dove_priv *priv; + int ret; + + ret = sdhci_pltfm_register(pdev, &sdhci_dove_pdata); + if (ret) + goto sdhci_dove_register_fail; + + priv = devm_kzalloc(&pdev->dev, sizeof(struct sdhci_dove_priv), + GFP_KERNEL); + if (!priv) { + dev_err(&pdev->dev, "unable to allocate private data"); + ret = -ENOMEM; + goto sdhci_dove_allocate_fail; + } + + host = platform_get_drvdata(pdev); + pltfm_host = sdhci_priv(host); + pltfm_host->priv = priv; + + priv->clk = clk_get(&pdev->dev, NULL); + if (!IS_ERR(priv->clk)) + clk_prepare_enable(priv->clk); + return 0; + +sdhci_dove_allocate_fail: + sdhci_pltfm_unregister(pdev); +sdhci_dove_register_fail: + return ret; } static int __devexit sdhci_dove_remove(struct platform_device *pdev) { + struct sdhci_host *host = platform_get_drvdata(pdev); + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_dove_priv *priv = pltfm_host->priv; + + if (priv->clk) { + if (!IS_ERR(priv->clk)) { + clk_disable_unprepare(priv->clk); + clk_put(priv->clk); + } + devm_kfree(&pdev->dev, priv->clk); + } return sdhci_pltfm_unregister(pdev); }