From patchwork Tue Jun 7 21:08:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Mason X-Patchwork-Id: 9162637 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 8EA9760467 for ; Tue, 7 Jun 2016 21:10:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F9C028361 for ; Tue, 7 Jun 2016 21:10:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7458F2836E; Tue, 7 Jun 2016 21:10:35 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D51C2836B for ; Tue, 7 Jun 2016 21:10:34 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bAOFN-0002fz-RB; Tue, 07 Jun 2016 21:09:13 +0000 Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bAOFF-0002RD-A6 for linux-arm-kernel@lists.infradead.org; Tue, 07 Jun 2016 21:09:05 +0000 Received: by mail-pa0-x22d.google.com with SMTP id hl6so2011395pac.2 for ; Tue, 07 Jun 2016 14:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3D7gcQHwds+D68ywFrSurrCh2A7KhuwzopYJPrTYL6M=; b=hOlpybPLx0cQlEW0DjgERrZKb6Mf7k+wEkpiiOeBGp98Ff/+hFFU9JaY2hrrRtnvXp MFfMxGb/lFgxwjFnXbgBv0DLscSPVjZwKBrb2uz2w6zzBrv4fI5e55cYVP/g0Do94Cqi WLUGGv+nRW9RDEaH7xGE7hFJh5/Bkaj2Pc3nw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3D7gcQHwds+D68ywFrSurrCh2A7KhuwzopYJPrTYL6M=; b=F/UECLNnQoBT4QNjQyqTnGSAZzD2WXU7FKoDgz0BMBhVCfRd6zUTFCzXkgpvRRXyUm BwZrjCIG2s8gGO0OAX/4sDCbuwzhMGQdA0KFcJpyYmxxgHlPDInRMrx5nG4eJl+uoaUX IW3kAH3fKJ0xVq7wp4949WxWu6nzQymJM8x/aHHQY1aSpMhBPER5jECxwfgen7BJZ8H6 npvF+HbFThGw/er1PzZGDo++u0Ealz7eytrG8/jbyFfzfCcda5WZ38iRaaw1hS2+Uk2p 1DnSWVhv+jFJU4E9Pj9MZpmoEEA7IPwkcHkeSopZrVeiZzsER4wLJd12dx/tyr4dIvSw S9/Q== X-Gm-Message-State: ALyK8tK5jaZm9He0nzMmPaeKt5cjrY9MDU6tNo9x+D3fRh8Ei+I+p9GpnpLSuWU9QHZHZUoP X-Received: by 10.66.140.17 with SMTP id rc17mr1477396pab.79.1465333724256; Tue, 07 Jun 2016 14:08:44 -0700 (PDT) Received: from venom.rtp.broadcom.com ([216.31.219.19]) by smtp.gmail.com with ESMTPSA id eh9sm35175726pad.47.2016.06.07.14.08.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jun 2016 14:08:43 -0700 (PDT) From: Jon Mason To: Russell King Subject: [RFC 1/1] ARM: print MHz in /proc/cpuinfo Date: Tue, 7 Jun 2016 17:08:33 -0400 Message-Id: <1465333713-14339-2-git-send-email-jon.mason@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465333713-14339-1-git-send-email-jon.mason@broadcom.com> References: <1465333713-14339-1-git-send-email-jon.mason@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160607_140905_403136_F19A62FD X-CRM114-Status: GOOD ( 15.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Query the CPU core clock in the device tree to determine the core clock speed. Output this clock rate in /proc/cpuinfo to match the output from other architectures. The output is intentionally patterned after the x86 output, to match existing (and possibly expected) convention. If any errors are encountered in querying the clock (or the speed is erroneously zero), nothing will be printed out. Thus any existing devices that do not have CPU clocks defined in the device tree will work as before. Signed-off-by: Jon Mason --- arch/arm/kernel/setup.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 7b53500..0c3e25a 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -1178,10 +1179,32 @@ static const char *hwcap2_str[] = { NULL }; +static unsigned long cpu_freq(unsigned int core) +{ + struct device_node *np; + struct clk *c; + unsigned long rate = 0; + + np = of_get_cpu_node(core, NULL); + if (!np) + goto err; + + c = of_clk_get_by_name(np, NULL); + if (IS_ERR(c)) + goto err; + + rate = clk_get_rate(c); + + clk_put(c); +err: + return rate; +} + static int c_show(struct seq_file *m, void *v) { int i, j; u32 cpuid; + unsigned long rate; for_each_online_cpu(i) { /* @@ -1194,6 +1217,12 @@ static int c_show(struct seq_file *m, void *v) seq_printf(m, "model name\t: %s rev %d (%s)\n", cpu_name, cpuid & 15, elf_platform); + rate = cpu_freq(i); + if (rate) + /* Change from Hz into MHz */ + seq_printf(m, "cpu MHz\t\t: %lu.%03lu\n", + rate / 1000000, rate / 1000 % 1000); + #if defined(CONFIG_SMP) seq_printf(m, "BogoMIPS\t: %lu.%02lu\n", per_cpu(cpu_data, i).loops_per_jiffy / (500000UL/HZ),