From patchwork Wed Feb 22 10:36:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zakharov Vlad X-Patchwork-Id: 731051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vSv290TxDz9s65 for ; Wed, 22 Feb 2017 21:37:21 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lxnf6c05"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=RhtvgrwYwIKBROq0AS/kb072Y7NiwBO2qwG1aj39PUU=; b=lxn f6c055biuMjySYZowkd3foCpL8nbxPCs6ufYCkUTJPwYJlfR3PeizflMh4FIBCzBg649JqZLzSPzI LDEivb6D/kmP5YKaj/IelljaPJCpO+s5lxd1PsWcDY6FRIgJXybljjmKRpAOb3Yb+coXlVONeuAkb 4MHs4QayH8MTfkKJ432fq5Q2oM4dw59ThfXjfNSxB2DAOHweEwb7gUfxL+9tnfeuBH/jEc6JSL7/S BtdfgOgKfOayw1FFqOBcljBemnASwV1uOPWEo1s+JTOp6GnujVCfpvVNm2H2A8KiPDGF4g3dX+Zst JpsmkIEzsJa6s4gzlz1myh8Ibv5WHFw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cgUIR-0000nV-Fx; Wed, 22 Feb 2017 10:37:19 +0000 Received: from smtprelay2.synopsys.com ([198.182.60.111] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cgUIH-0000cs-SE for linux-snps-arc@lists.infradead.org; Wed, 22 Feb 2017 10:37:11 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 53CA110C12ED; Wed, 22 Feb 2017 02:36:48 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 116FD470; Wed, 22 Feb 2017 02:36:48 -0800 (PST) Received: from vzakhar-8460.internal.synopsys.com (vzakhar-8460.internal.synopsys.com [10.121.8.100]) by mailhost.synopsys.com (Postfix) with ESMTP id 8BB4044A; Wed, 22 Feb 2017 02:36:46 -0800 (PST) From: Vlad Zakharov To: linux-snps-arc@lists.infradead.org Subject: [PATCH] arc: get rate from clk driver instead of reading device tree Date: Wed, 22 Feb 2017 13:36:36 +0300 Message-Id: <1487759796-14418-1-git-send-email-vzakhar@synopsys.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170222_023709_922137_02A7D70B X-CRM114-Status: UNSURE ( 8.09 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.60.111 listed in list.dnswl.org] -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [198.182.60.111 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vlad Zakharov , Vineet Gupta , Alexey Brodkin , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We were reading clock rate directly from device tree "clock-frequency" property of corresponding clock node in show_cpuinfo function. Such approach is correct only in case cpu is always clocked by "fixed-clock". If we use clock driver that allows rate to be changed this won't work as rate may change during the time or even "clock-frequency" property may not be presented at all. So this commit replaces reading device tree with getting rate from clock driver. This approach is much more flexible and will work for both fixed and mutable clocks. Signed-off-by: Vlad Zakharov --- arch/arc/kernel/setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c index 3093fa8..49b0804 100644 --- a/arch/arc/kernel/setup.c +++ b/arch/arc/kernel/setup.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -488,7 +489,8 @@ static int show_cpuinfo(struct seq_file *m, void *v) { char *str; int cpu_id = ptr_to_cpu(v); - struct device_node *core_clk = of_find_node_by_name(NULL, "core_clk"); + struct device *cpu_dev = get_cpu_device(cpu_id); + struct clk *cpu_clk = clk_get(cpu_dev, "core_clk"); u32 freq = 0; if (!cpu_online(cpu_id)) { @@ -502,7 +504,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) seq_printf(m, arc_cpu_mumbojumbo(cpu_id, str, PAGE_SIZE)); - of_property_read_u32(core_clk, "clock-frequency", &freq); + freq = clk_get_rate(cpu_clk); if (freq) seq_printf(m, "CPU speed\t: %u.%02u Mhz\n", freq / 1000000, (freq / 10000) % 100);