From patchwork Wed Mar 4 19:32:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 5939411 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8AB4ABF440 for ; Wed, 4 Mar 2015 19:35:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 847D02034A for ; Wed, 4 Mar 2015 19:35:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB76220320 for ; Wed, 4 Mar 2015 19:35:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758362AbbCDTeR (ORCPT ); Wed, 4 Mar 2015 14:34:17 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:62903 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759327AbbCDTeN (ORCPT ); Wed, 4 Mar 2015 14:34:13 -0500 Received: from wuerfel.lan. ([149.172.15.242]) by mrelayeu.kundenserver.de (mreue003) with ESMTPSA (Nemesis) id 0MFwt0-1YEP4w38g2-00Es95; Wed, 04 Mar 2015 20:33:36 +0100 From: Arnd Bergmann To: linux-arm-msm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, David Brown , Daniel Walker , Bryan Huntsman , Stephen Boyd , Tim Bird , Bjorn Andersson , Linus Walleij , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Ulf Hansson , Arnd Bergmann Subject: [RFC PATCH 04/18] mmc: msm: move clk-reset logic to platform Date: Wed, 4 Mar 2015 20:32:58 +0100 Message-Id: <1425497592-1831064-5-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.1.0.rc2 In-Reply-To: <1425497592-1831064-1-git-send-email-arnd@arndb.de> References: <1425497592-1831064-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:nzlJlmfoYC1m3o1f0HIds4yUgkn0znwpwe4o686j9dG9qSCuwbt X0YTnEEwCktbyrZAXiEbXo1HejGlwnWAzELVI9a+gLeNOwFVl/YLNOO4ZRdOO6+uF4z3Q8P t2VMlJXgxeoE2bJsFp91lc/SVsoskI+W7i0loE/KBk/6tNpRMxZegFotv2QvZ2VGUToW1tg tAeKPtVedWvIpUN7lSrXg== X-UI-Out-Filterresults: notjunk:1; Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 There is no generic interface for resetting a clock, and creating a reset driver for msm seems overkill, so this moves the reset logic from the msm_sdcc driver into a platform_data callback that calls into the clock driver. This follows the model that is used for all other devices on the msm platform that require a clk reset. Signed-off-by: Arnd Bergmann Acked-by: Ulf Hansson --- arch/arm/mach-msm/board-qsd8x50.c | 18 +++++++++++++++++- arch/arm/mach-msm/board-trout-mmc.c | 18 ++++++++++++++++++ arch/arm/mach-msm/clock.c | 2 +- drivers/mmc/host/msm_sdcc.c | 12 ++---------- include/linux/platform_data/mmc-msm_sdcc.h | 3 +++ 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/arch/arm/mach-msm/board-qsd8x50.c b/arch/arm/mach-msm/board-qsd8x50.c index 4c748616ef47..9676a73683d2 100644 --- a/arch/arm/mach-msm/board-qsd8x50.c +++ b/arch/arm/mach-msm/board-qsd8x50.c @@ -180,6 +180,21 @@ static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd) return 0; } +static void msm_sdcc_clk_reset(struct clk *clk) +{ + int ret; + + ret = clk_reset(clk, CLK_RESET_ASSERT); + if (ret) + pr_err("sdcc clock assert failed at %lu Hz with err %d\n", + clk_get_rate(clk), ret); + + ret = clk_reset(clk, CLK_RESET_DEASSERT); + if (ret) + pr_err("sdcc clock deassert failed at %lu Hz with err %d\n", + clk_get_rate(clk), ret); +} + static struct msm_mmc_gpio_data sdc1_gpio = { .gpio = sdc1_gpio_cfg, .size = ARRAY_SIZE(sdc1_gpio_cfg), @@ -188,7 +203,8 @@ static struct msm_mmc_gpio_data sdc1_gpio = { static struct msm_mmc_platform_data qsd8x50_sdc1_data = { .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29, .translate_vdd = msm_sdcc_setup_power, - .gpio_data = &sdc1_gpio, + .gpio_data = &sdc1_gpio, + .clk_reset = msm_sdcc_clk_reset, }; static void __init qsd8x50_init_mmc(void) diff --git a/arch/arm/mach-msm/board-trout-mmc.c b/arch/arm/mach-msm/board-trout-mmc.c index 3723e55819d6..2474bba71c8b 100644 --- a/arch/arm/mach-msm/board-trout-mmc.c +++ b/arch/arm/mach-msm/board-trout-mmc.c @@ -2,6 +2,7 @@ ** Author: Brian Swetland */ #include +#include #include #include #include @@ -14,6 +15,7 @@ #include #include +#include #include @@ -154,6 +156,21 @@ static unsigned int trout_sdslot_status(struct device *dev) return (!status); } +static void trout_sdcc_clk_reset(struct clk *clk) +{ + int ret; + + ret = clk_reset(clk, CLK_RESET_ASSERT); + if (ret) + pr_err("sdcc clock assert failed at %lu Hz with err %d\n", + clk_get_rate(clk), ret); + + ret = clk_reset(clk, CLK_RESET_DEASSERT); + if (ret) + pr_err("sdcc clock deassert failed at %lu Hz with err %d\n", + clk_get_rate(clk), ret); +} + #define TROUT_MMC_VDD MMC_VDD_165_195 | MMC_VDD_20_21 | MMC_VDD_21_22 \ | MMC_VDD_22_23 | MMC_VDD_23_24 | MMC_VDD_24_25 \ | MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 \ @@ -163,6 +180,7 @@ static struct msm_mmc_platform_data trout_sdslot_data = { .ocr_mask = TROUT_MMC_VDD, .status = trout_sdslot_status, .translate_vdd = trout_sdslot_switchvdd, + .clk_reset = trout_sdcc_clk_reset, }; int __init trout_init_mmc(unsigned int sys_rev) diff --git a/arch/arm/mach-msm/clock.c b/arch/arm/mach-msm/clock.c index 35ea02b52483..0b59ad5eb557 100644 --- a/arch/arm/mach-msm/clock.c +++ b/arch/arm/mach-msm/clock.c @@ -23,6 +23,6 @@ int clk_reset(struct clk *clk, enum clk_reset_action action) { struct clk_hw *hw = __clk_get_hw(clk); struct msm_clk *m = to_msm_clk(hw); + return m->reset(hw, action); } -EXPORT_SYMBOL(clk_reset); diff --git a/drivers/mmc/host/msm_sdcc.c b/drivers/mmc/host/msm_sdcc.c index 3002e377e9f7..be5b9b3b3843 100644 --- a/drivers/mmc/host/msm_sdcc.c +++ b/drivers/mmc/host/msm_sdcc.c @@ -45,7 +45,6 @@ #include #include -#include /* data mover definitions */ @@ -493,15 +492,8 @@ static void msmsdcc_reset_and_restore(struct msmsdcc_host *host) mci_mask0 = readl(host->base + MMCIMASK0); /* Reset the controller */ - ret = clk_reset(host->clk, CLK_RESET_ASSERT); - if (ret) - pr_err("%s: Clock assert failed at %u Hz with err %d\n", - mmc_hostname(host->mmc), host->clk_rate, ret); - - ret = clk_reset(host->clk, CLK_RESET_DEASSERT); - if (ret) - pr_err("%s: Clock deassert failed at %u Hz with err %d\n", - mmc_hostname(host->mmc), host->clk_rate, ret); + if (host->plat->clk_reset) + host->plat->clk_reset(host->clk); pr_info("%s: Controller has been re-initialiazed\n", mmc_hostname(host->mmc)); diff --git a/include/linux/platform_data/mmc-msm_sdcc.h b/include/linux/platform_data/mmc-msm_sdcc.h index 55aa873c9396..6f1821a4bf93 100644 --- a/include/linux/platform_data/mmc-msm_sdcc.h +++ b/include/linux/platform_data/mmc-msm_sdcc.h @@ -15,6 +15,8 @@ struct msm_mmc_gpio_data { u8 size; }; +struct clk; + struct msm_mmc_platform_data { unsigned int ocr_mask; /* available voltages */ u32 (*translate_vdd)(struct device *, unsigned int); @@ -22,6 +24,7 @@ struct msm_mmc_platform_data { int (*register_status_notify)(void (*callback)(int card_present, void *dev_id), void *dev_id); struct msm_mmc_gpio_data *gpio_data; void (*init_card)(struct mmc_card *card); + void (*clk_reset)(struct clk *clk); }; #endif