From patchwork Thu Jun 20 14:39:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 2756581 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BF0B4C0AB1 for ; Thu, 20 Jun 2013 14:44:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E8D8F202B7 for ; Thu, 20 Jun 2013 14:44:42 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 91789202B3 for ; Thu, 20 Jun 2013 14:44:41 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Upg5l-00020n-Sm; Thu, 20 Jun 2013 14:44:06 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Upg5f-0000wj-MX; Thu, 20 Jun 2013 14:43:59 +0000 Received: from mms1.broadcom.com ([216.31.210.17]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Upg5Q-0000up-MB for linux-arm-kernel@lists.infradead.org; Thu, 20 Jun 2013 14:43:45 +0000 Received: from [10.9.208.55] by mms1.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Thu, 20 Jun 2013 07:39:33 -0700 X-Server-Uuid: 06151B78-6688-425E-9DE2-57CB27892261 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.1.438.0; Thu, 20 Jun 2013 07:43:14 -0700 Received: from mail-irva-13.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; Thu, 20 Jun 2013 07:43:14 -0700 Received: from fainelli-desktop.broadcom.com ( dhcp-lab-brsc-21.bri.broadcom.com [10.178.5.21]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 6ED84F2D74; Thu, 20 Jun 2013 07:43:13 -0700 (PDT) From: "Florian Fainelli" To: lorenzo.pieralisi@arm.com Subject: [PATCH 1/3] ARM: kernel: get cpu clock rate from cpu clock node first Date: Thu, 20 Jun 2013 15:39:04 +0100 Message-ID: <1371739146-32639-2-git-send-email-f.fainelli@gmail.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1371739146-32639-1-git-send-email-f.fainelli@gmail.com> References: <1371739146-32639-1-git-send-email-f.fainelli@gmail.com> MIME-Version: 1.0 X-WSS-ID: 7DDDCBAF31W39594985-01-01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130620_104344_830514_F19664D6 X-CRM114-Status: GOOD ( 14.58 ) X-Spam-Score: -2.5 (--) Cc: Florian Fainelli , nico@linaro.org, devicetree-discuss@lists.ozlabs.org, rob.herring@calxeda.com, grant.likely@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,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 The current topology code will only attempt to parse a "clock-frequency" property for a given CPU node. Some platforms such as the ecx-2000 provide a clock node. Change the logic to first look for a clock node, and if we fail, fallback to parsing a "clock-frequency" property. To avoid unnecessary casting, change rate from u32 to unsigned long, and introduce the "prop" variable to hold the contents of the "clock-frequency" property. Signed-off-by: Florian Fainelli --- arch/arm/kernel/topology.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index c5a5954..8f340a1 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -104,7 +105,9 @@ static void __init parse_dt_topology(void) cpu_capacity = kzalloc(alloc_size, GFP_NOWAIT); while ((cn = of_find_node_by_type(cn, "cpu"))) { - const u32 *rate, *reg; + const u32 *prop, *reg; + unsigned long rate; + struct clk *cpu_clk; int len; if (cpu >= num_possible_cpus()) @@ -117,11 +120,17 @@ static void __init parse_dt_topology(void) if (cpu_eff->compatible == NULL) continue; - rate = of_get_property(cn, "clock-frequency", &len); - if (!rate || len != 4) { - pr_err("%s missing clock-frequency property\n", - cn->full_name); - continue; + cpu_clk = of_clk_get(cn, 0); + if (IS_ERR(cpu_clk)) { + prop = of_get_property(cn, "clock-frequency", &len); + if (!prop || len != 4) { + pr_err("%s missing clock-frequency property\n", + cn->full_name); + continue; + } + rate = be32_to_cpup(prop); + } else { + rate = clk_get_rate(cpu_clk); } reg = of_get_property(cn, "reg", &len); @@ -130,7 +139,7 @@ static void __init parse_dt_topology(void) continue; } - capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency; + capacity = (rate >> 20) * cpu_eff->efficiency; /* Save min capacity of the system */ if (capacity < min_capacity)