From patchwork Fri Feb 17 03:56:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 9578763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8357460586 for ; Fri, 17 Feb 2017 03:59:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7133D2860E for ; Fri, 17 Feb 2017 03:59:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65D332869D; Fri, 17 Feb 2017 03:59:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20E1328685 for ; Fri, 17 Feb 2017 03:59:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932089AbdBQD7m (ORCPT ); Thu, 16 Feb 2017 22:59:42 -0500 Received: from lucky1.263xmail.com ([211.157.147.132]:53294 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932110AbdBQD7m (ORCPT ); Thu, 16 Feb 2017 22:59:42 -0500 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.12]) by lucky1.263xmail.com (Postfix) with ESMTP id 3E582643AB; Fri, 17 Feb 2017 11:59:37 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 689883B4; Fri, 17 Feb 2017 11:59:36 +0800 (CST) X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: ulf.hansson@linaro.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <8c1cad7503cb6a2428e749abb2f04f7f> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from unknown (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith SMTP id 25873JC3Y4Z; Fri, 17 Feb 2017 11:59:37 +0800 (CST) From: Shawn Lin To: Ulf Hansson , Adrian Hunter Cc: linux-mmc@vger.kernel.org, Anssi Hannula , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Florian Fainelli , Ray Jui , Shawn Lin Subject: [RFC PATCH 2/4] mmc: sdhci: add new helper to get timeout clock Date: Fri, 17 Feb 2017 11:56:18 +0800 Message-Id: <1487303780-234812-3-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1487303780-234812-1-git-send-email-shawn.lin@rock-chips.com> References: <1487303780-234812-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the timeout clock is zero, it actually means we need to get it from other methods. Given the fact that almost all the platforms are getting this from the common clock framework API, so we could invent this new helper to be resued for the variant drivers. Signed-off-by: Shawn Lin --- drivers/mmc/host/sdhci-pltfm.c | 14 ++++++++++++++ drivers/mmc/host/sdhci-pltfm.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c index ad49bfa..5a88681 100644 --- a/drivers/mmc/host/sdhci-pltfm.c +++ b/drivers/mmc/host/sdhci-pltfm.c @@ -44,6 +44,20 @@ unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host) } EXPORT_SYMBOL_GPL(sdhci_pltfm_clk_get_max_clock); +unsigned int sdhci_pltfm_clk_get_timeout_clock(struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + unsigned int freq; + + freq = DIV_ROUND_UP(clk_get_rate(pltfm_host->clk), 1000); + + if (host->caps & SDHCI_TIMEOUT_CLK_UNIT) + freq = DIV_ROUND_UP(freq, 1000); + + return freq; +} +EXPORT_SYMBOL_GPL(sdhci_pltfm_clk_get_timeout_clock); + static const struct sdhci_ops sdhci_pltfm_ops = { .set_clock = sdhci_set_clock, .set_bus_width = sdhci_set_bus_width, diff --git a/drivers/mmc/host/sdhci-pltfm.h b/drivers/mmc/host/sdhci-pltfm.h index 957839d..14c11aa 100644 --- a/drivers/mmc/host/sdhci-pltfm.h +++ b/drivers/mmc/host/sdhci-pltfm.h @@ -103,6 +103,7 @@ extern int sdhci_pltfm_register(struct platform_device *pdev, extern int sdhci_pltfm_unregister(struct platform_device *pdev); extern unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host); +extern unsigned int sdhci_pltfm_clk_get_timeout_clock(struct sdhci_host *host); static inline void *sdhci_pltfm_priv(struct sdhci_pltfm_host *host) {