Received: by 10.223.164.221 with SMTP id h29csp1048644wrb; Thu, 26 Oct 2017 11:28:29 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SGUsM7wQ2s/+NLmjKOLwIFl84bKWfQ2l2U9Kwai1VRXrijWBdfNtIEAfQJUzFiKlEKWk2z X-Received: by 10.84.235.202 with SMTP id m10mr4963429plt.57.1509042509105; Thu, 26 Oct 2017 11:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509042509; cv=none; d=google.com; s=arc-20160816; b=R0UDjpEvMyQlvn33PVaPeHpTjTFiW5dbLfXE8tAURYnOlkL2qj7bSglQJ7dH+LJ8Qs yzvCOThrMX+zeNtvLC6SjeE3n8TgvV8a8wxJ3k11sV+tzvWH1YkmwhT3MY1+Z/7RsZhe KIwul/dOYNhHyDeK7JhuQV8vZ+0kocWsNGiBAyLv9yeigToaN6x/zJv9wqYgxlGfuuCi jhv6NA6csjYsByOWJHrvXlZydQTIF4HfmLre7Rx4gAPBsZ/wcTUQpc5JGyusXpM8hPoU JNPX8EoRBmwUjjZWepce2SySTvM0LqMqr6V0nV7huDDtrLjpTH1DrJKxFYkEc+Zbuwtf xxKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:newsgroups:cc:to:subject :arc-authentication-results; bh=spfuo8ku6XNWqXQpcUORtV25XzbaQTawrD3HOOkBFpA=; b=RoVS1ywLyVetmY4NfjGN8HqLdB2/Ki3XuwvzoJobTZlZ4tc1/vjXFKsCqahyszDdXZ aMjHidwm7eWrNBzts/rEPRuuRyjadPx5lcorUcNTyawJefK1B71ZIdZ9T/COpOOESmfr JynBLR2xOxoq1W0dgsEBSbc5+kSJ9zbC0rJeildKB/C+KV/YKVBRSMEv/8puyIxUWkl4 Qd64MaXQw2OAA2nDm51ohuutpcyUEyCtEzb4nvjFRZbOrkFwbRe8hH8Hz9WsdWz3BZIK n3O4YcyHKSENvawH5ZerJUmrZcajak3t/vjiAxONNzswez6GtnIVPg1FrJ90UiB8cTLg ba0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h71si3653840pgc.321.2017.10.26.11.28.14; Thu, 26 Oct 2017 11:28:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932399AbdJZS1t (ORCPT + 99 others); Thu, 26 Oct 2017 14:27:49 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.60.111]:39309 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932340AbdJZS1q (ORCPT ); Thu, 26 Oct 2017 14:27:46 -0400 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 544D910C0C2C; Thu, 26 Oct 2017 11:27:45 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 2CC99B5F; Thu, 26 Oct 2017 11:27:45 -0700 (PDT) Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id D8A3CAF0; Thu, 26 Oct 2017 11:27:34 -0700 (PDT) Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.104) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.266.1; Thu, 26 Oct 2017 11:25:53 -0700 Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.105) by IN01WEHTCA.internal.synopsys.com (10.144.199.103) with Microsoft SMTP Server (TLS) id 14.3.266.1; Thu, 26 Oct 2017 23:55:50 +0530 Received: from [10.10.161.66] (10.10.161.66) by IN01WEHTCB.internal.synopsys.com (10.144.199.243) with Microsoft SMTP Server (TLS) id 14.3.266.1; Thu, 26 Oct 2017 23:55:50 +0530 Subject: Re: [PATCH] CLK: ARC: Set initial pll output frequency specified in device tree To: , Michael Turquette , Stephen Boyd , Rob Herring CC: Eugeniy Paltsev , , , "Mark Rutland" Newsgroups: gmane.linux.kernel,gmane.linux.kernel.clk,gmane.linux.kernel.arc References: <20170929131357.26796-1-Eugeniy.Paltsev@synopsys.com> From: Vineet Gupta Message-ID: Date: Thu, 26 Oct 2017 11:25:44 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20170929131357.26796-1-Eugeniy.Paltsev@synopsys.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.10.161.66] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi folks, On 09/29/2017 06:13 AM, Eugeniy Paltsev wrote: > Add option to set initial output frequency of plls via > "clock-frequency" property in pll's device tree node. > This frequency will be set while pll driver probed. > > The usage example is setting CPU clock frequency on boot > See discussion: > https://www.mail-archive.com/linux-snps-arc@lists.infradead.org/msg02689.html Any yay / nay on this please ? I guess some de-duplication is in order anyways but is the overall approach sane ? Additional background / context in thread http://lists.infradead.org/pipermail/linux-snps-arc/2017-September/002900.html Thx, -Vineet > > Signed-off-by: Eugeniy Paltsev > --- > .../bindings/clock/snps,hsdk-pll-clock.txt | 5 ++++ > .../devicetree/bindings/clock/snps,pll-clock.txt | 5 ++++ > drivers/clk/axs10x/pll_clock.c | 34 ++++++++++++++++++++-- > drivers/clk/clk-hsdk-pll.c | 34 ++++++++++++++++++++-- > 4 files changed, 74 insertions(+), 4 deletions(-) > > diff --git a/Documentation/devicetree/bindings/clock/snps,hsdk-pll-clock.txt b/Documentation/devicetree/bindings/clock/snps,hsdk-pll-clock.txt > index c56c755..5703059 100644 > --- a/Documentation/devicetree/bindings/clock/snps,hsdk-pll-clock.txt > +++ b/Documentation/devicetree/bindings/clock/snps,hsdk-pll-clock.txt > @@ -13,6 +13,10 @@ Required properties: > - clocks: shall be the input parent clock phandle for the PLL. > - #clock-cells: from common clock binding; Should always be set to 0. > > +Optional properties: > +- clock-frequency: output frequency generated by pll in Hz which will be set > +while probing. Should be a single cell. > + > Example: > input_clk: input-clk { > clock-frequency = <33333333>; > @@ -25,4 +29,5 @@ Example: > reg = <0x00 0x10>; > #clock-cells = <0>; > clocks = <&input_clk>; > + clock-frequency = <1000000000>; > }; > diff --git a/Documentation/devicetree/bindings/clock/snps,pll-clock.txt b/Documentation/devicetree/bindings/clock/snps,pll-clock.txt > index 11fe487..5908f99 100644 > --- a/Documentation/devicetree/bindings/clock/snps,pll-clock.txt > +++ b/Documentation/devicetree/bindings/clock/snps,pll-clock.txt > @@ -13,6 +13,10 @@ registers and second for corresponding LOCK CGU register. > - clocks: shall be the input parent clock phandle for the PLL. > - #clock-cells: from common clock binding; Should always be set to 0. > > +Optional properties: > +- clock-frequency: output frequency generated by pll in Hz which will be set > +while probing. Should be a single cell. > + > Example: > input-clk: input-clk { > clock-frequency = <33333333>; > @@ -25,4 +29,5 @@ Example: > reg = <0x80 0x10>, <0x100 0x10>; > #clock-cells = <0>; > clocks = <&input-clk>; > + clock-frequency = <100000000>; > }; > diff --git a/drivers/clk/axs10x/pll_clock.c b/drivers/clk/axs10x/pll_clock.c > index 25d8c24..3f4345d 100644 > --- a/drivers/clk/axs10x/pll_clock.c > +++ b/drivers/clk/axs10x/pll_clock.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -215,6 +216,25 @@ static const struct clk_ops axs10x_pll_ops = { > .set_rate = axs10x_pll_set_rate, > }; > > +static void set_pll_rate_from_of(struct clk *clk, struct device_node *node) > +{ > + u32 requested_rate; > + > + /* If we specify initial pll output frequency try to set it */ > + if (of_property_read_u32(node, "clock-frequency", &requested_rate)) > + return; > + > + if (clk_prepare_enable(clk)) { > + pr_err("Cannot enable %s clock.\n", node->name); > + return; > + } > + > + if (clk_set_rate(clk, requested_rate)) > + pr_err("Cannot set %s clock rate.\n", node->name); > + > + pr_debug("Set %s clock to %u\n", node->name, requested_rate); > +} > + > static int axs10x_pll_clk_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -258,8 +278,15 @@ static int axs10x_pll_clk_probe(struct platform_device *pdev) > return ret; > } > > - return of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get, > - &pll_clk->hw); > + ret = of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get, > + &pll_clk->hw); > + if (ret) > + return ret; > + > + /* If we specify initial pll output frequency in dts try to set it */ > + set_pll_rate_from_of(pll_clk->hw.clk, dev->of_node); > + > + return 0; > } > > static int axs10x_pll_clk_remove(struct platform_device *pdev) > @@ -311,6 +338,9 @@ static void __init of_axs10x_pll_clk_setup(struct device_node *node) > goto err_unregister_clk; > } > > + /* If we specify initial pll output frequency in dts try to set it */ > + set_pll_rate_from_of(pll_clk->hw.clk, node); > + > return; > > err_unregister_clk: > diff --git a/drivers/clk/clk-hsdk-pll.c b/drivers/clk/clk-hsdk-pll.c > index bbf23717..74fd006 100644 > --- a/drivers/clk/clk-hsdk-pll.c > +++ b/drivers/clk/clk-hsdk-pll.c > @@ -9,6 +9,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -295,6 +296,25 @@ static const struct clk_ops hsdk_pll_ops = { > .set_rate = hsdk_pll_set_rate, > }; > > +static void set_pll_rate_from_of(struct clk *clk, struct device_node *node) > +{ > + u32 requested_rate; > + > + /* If we specify initial pll output frequency try to set it */ > + if (of_property_read_u32(node, "clock-frequency", &requested_rate)) > + return; > + > + if (clk_prepare_enable(clk)) { > + pr_err("Cannot enable %s clock.\n", node->name); > + return; > + } > + > + if (clk_set_rate(clk, requested_rate)) > + pr_err("Cannot set %s clock rate.\n", node->name); > + > + pr_debug("Set %s clock to %u\n", node->name, requested_rate); > +} > + > static int hsdk_pll_clk_probe(struct platform_device *pdev) > { > int ret; > @@ -340,8 +360,15 @@ static int hsdk_pll_clk_probe(struct platform_device *pdev) > return ret; > } > > - return of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get, > - &pll_clk->hw); > + ret = of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get, > + &pll_clk->hw); > + if (ret) > + return ret; > + > + /* If we specify initial pll output frequency in dts try to set it */ > + set_pll_rate_from_of(pll_clk->hw.clk, dev->of_node); > + > + return 0; > } > > static int hsdk_pll_clk_remove(struct platform_device *pdev) > @@ -400,6 +427,9 @@ static void __init of_hsdk_pll_clk_setup(struct device_node *node) > goto err_unmap_spec_regs; > } > > + /* If we specify initial pll output frequency in dts try to set it */ > + set_pll_rate_from_of(pll_clk->hw.clk, node); > + > return; > > err_unmap_spec_regs: > From 1579879904454070193@xxx Fri Sep 29 13:14:47 +0000 2017 X-GM-THRID: 1579879904454070193 X-Gmail-Labels: Inbox,Category Forums