From patchwork Mon Aug 14 16:12:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 801240 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="H41TunSi"; dkim-atps=neutral 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 3xWLHR1L8vz9sPr for ; Tue, 15 Aug 2017 02:12:51 +1000 (AEST) 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:References: In-Reply-To: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:List-Owner; bh=EcqzoQvW8gME9hh+r4Mnz9wfell0cmjxbDQhFaYk0gU=; b=H41TunSix5Eys6EBkf+vyOqikY ENDIIBmiGwItPxLAJQOsbgzAqW3BiKXFrgJkFf6M4sz2g/UCmQ45RyS/4QHtpUae31uZV1XUl9yb5 +828559IZod4a4hLgxbMt+nyJ8B92IPquaclTCplC4vf9lGcJvJuRtXNsflU0FJjHmfB0L3KiGa4S mDoaUrty6wio8gWStzE9kX6n5B38x7myqkfAE3UgZvlJGkj1Zcbr/B4fBSyAy/DmHgfPRbD9qVWoe 3muL+/UWKSc15eSVeZA1m50fQv8jFf3v8QTxEHTLJLAZ1Q3EkhJ7bxu58dtYf8EO9M0CxoFKzBmS6 K9Z9nkCg==; 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 1dhHyz-00035K-Kf; Mon, 14 Aug 2017 16:12:49 +0000 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dhHyu-0002my-53 for linux-snps-arc@lists.infradead.org; Mon, 14 Aug 2017 16:12:47 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id A5B3D24E2049; Mon, 14 Aug 2017 09:12:21 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 8C6E5B76; Mon, 14 Aug 2017 09:12:21 -0700 (PDT) Received: from localhost.internal.synopsys.com (unknown [10.121.8.106]) by mailhost.synopsys.com (Postfix) with ESMTP id 9D93CB4A; Mon, 14 Aug 2017 09:12:19 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH 1/5] ARC: set and print cpu frequency at boot time Date: Mon, 14 Aug 2017 19:12:09 +0300 Message-Id: <20170814161213.17522-2-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170814161213.17522-1-Eugeniy.Paltsev@synopsys.com> References: <20170814161213.17522-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170814_091244_491275_303651D0 X-CRM114-Status: UNSURE ( 9.66 ) 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.47.9 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [198.182.47.9 listed in wl.mailspike.net] -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -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: Mark Rutland , devicetree@vger.kernel.org, Vineet Gupta , Alexey Brodkin , linux-kernel@vger.kernel.org, Rob Herring , Eugeniy Paltsev MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Print cpu frequency at boot time. In case we have pre-defined cpu frequency value in device tree try to set it. Signed-off-by: Eugeniy Paltsev --- arch/arc/kernel/setup.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c index 877cec8..b5fcc5d 100644 --- a/arch/arc/kernel/setup.c +++ b/arch/arc/kernel/setup.c @@ -464,12 +464,61 @@ void __init setup_arch(char **cmdline_p) arc_unwind_init(); } +static int __init set_cpu_freq(int cpu_id) +{ + struct device_node *cpunode; + u32 cpu_freq_required; + struct clk *clk; + int ret; + + cpunode = of_get_cpu_node(cpu_id, NULL); + if (cpunode == NULL) { + pr_err("Can't find CPU %d node.\n", cpu_id); + return -ENOENT; + } + + clk = of_clk_get(cpunode, 0); + if (IS_ERR(clk)) { + pr_err("CPU %d missing clk.\n", cpu_id); + return PTR_ERR(clk); + } + + ret = clk_prepare_enable(clk); + if (ret) { + pr_err("Couldn't enable CPU %d clk.\n", cpu_id); + return ret; + } + + /* + * In case we have pre-defined cpu frequency value in device tree + * try to set it. Otherwise just print current cpu frequency. + */ + if (of_property_read_u32(cpunode, "cpu-freq", &cpu_freq_required)) { + pr_info("CPU %d has no cpu-freq param. Frequency is %lu Hz.\n", + cpu_id, clk_get_rate(clk)); + return 0; + } + + if (clk_set_rate(clk, cpu_freq_required)) + pr_err("CPU %d frequency set failed. Probably fixed-clock is used for cpu.\n", + cpu_id); + + pr_info("CPU %d frequency is %lu Hz.\n", cpu_id, clk_get_rate(clk)); + + return 0; +} + /* * Called from start_kernel() - boot CPU only */ void __init time_init(void) { of_clk_init(NULL); + /* + * As for now we have common clock for all cpu cores, so set + * frequency only for master cpu. + */ + set_cpu_freq(0); timer_probe(); }