From patchwork Tue Jul 11 13:36:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mason X-Patchwork-Id: 9834711 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 4C4D360363 for ; Tue, 11 Jul 2017 13:37:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A8AB25EA6 for ; Tue, 11 Jul 2017 13:37:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C113283BB; Tue, 11 Jul 2017 13:37:40 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8696A25EA6 for ; Tue, 11 Jul 2017 13:37:39 +0000 (UTC) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:References:To:From:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9AfP4cPWYwTw4z3RSW8lzj8Dw5/FgEPnhWaavltXvGY=; b=ad7beE0Yo6L0yr BDQNn9dO5op0rc1p5crGBF0/ZVzoLsEkYH5nA89HtG3KyAIzc9Ikgp+QB5zxynu2+5twP0VbBdaH+ JhZpKX8MxfroJ998cCMLJWCXgK/iHLf/g/mevLKEIeodhBkuHxUmbSyLysdWRe7PFAmA7RH4aj7ZF dl7QCVMY9aITu4dBZE+QfM8RVJwcHDlp7l+/hsEE6MCwI1O0NP+y4skMus0/8C/c+B3hy6cwuozLb ZgrkI8c72zYaMIZMkjdH8kw5r6N42xMsAIt05+L3CvcSo1YM7si6SoOq58V1jANNbIVF3PNra0rMS Dyib+wLwVvtCZe3Hxu0w==; 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 1dUvM6-0006eT-5T; Tue, 11 Jul 2017 13:37:34 +0000 Received: from smtp5-g21.free.fr ([212.27.42.5]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dUvM1-0006Rq-9L for linux-arm-kernel@lists.infradead.org; Tue, 11 Jul 2017 13:37:31 +0000 Received: from [172.27.0.114] (unknown [92.154.11.170]) (Authenticated sender: slash.tmp) by smtp5-g21.free.fr (Postfix) with ESMTPSA id A04F85FFCC; Tue, 11 Jul 2017 15:36:50 +0200 (CEST) Subject: Re: cpufreq: frequency scaling spec in DT node From: Mason To: Viresh Kumar References: <1f665895-a2a0-6bdf-a9d9-66219fe3a8ef@free.fr> <20170629100459.GL29665@vireshk-i7> <538b1aa2-9298-6f21-392e-73d6559b581c@free.fr> <20170629143432.GM29665@vireshk-i7> <405bfa30-b083-2690-5747-aa1cd423e576@free.fr> Message-ID: <9a2638ee-e04f-13f1-b1e5-56f27b58da2e@free.fr> Date: Tue, 11 Jul 2017 15:36:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.1 MIME-Version: 1.0 In-Reply-To: <405bfa30-b083-2690-5747-aa1cd423e576@free.fr> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170711_063729_634197_904309B0 X-CRM114-Status: GOOD ( 14.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thibaud Cornic , "Rafael J. Wysocki" , Linux ARM , linux-pm 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 On 11/07/2017 11:27, Mason wrote: > I'll experiment with the other solution of creating the OPP table > at init. For the sake of discussion, based on your suggestion to use dev_pm_opp_add(), I have tested the patch below. There is one remaining error: [ 2.071139] of: dev_pm_opp_of_cpumask_add_table: couldn't find opp table for cpu:0, -19 Reached through: [ 1.878461] [] (dev_pm_opp_of_add_table) from [] (dev_pm_opp_of_cpumask_add_table+0x40/0xc8) [ 1.888695] [] (dev_pm_opp_of_cpumask_add_table) from [] (cpufreq_init+0x23c/0x2dc) [ 1.898139] [] (cpufreq_init) from [] (cpufreq_online+0xb8/0x660) [ 1.906009] [] (cpufreq_online) from [] (cpufreq_add_dev+0xbc/0xcc) [ 1.914058] [] (cpufreq_add_dev) from [] (subsys_interface_register+0x90/0xcc) [ 1.923065] [] (subsys_interface_register) from [] (cpufreq_register_driver+0x15c/0x1e0) [ 1.932945] [] (cpufreq_register_driver) from [] (dt_cpufreq_probe+0x78/0xec) [ 1.941866] [] (dt_cpufreq_probe) from [] (platform_drv_probe+0x34/0x6c) The cpufreq-dt driver seems to recover despite the error: /sys/devices/system/cpu/cpu0/cpufreq$ cat scaling_available_frequencies 135000 243000 405000 607500 1215000 Regards. arch/arm/boot/dts/tango4-smp8758.dtsi | 1 - drivers/cpufreq/Makefile | 1 + drivers/cpufreq/cpufreq-dt-platdev.c | 2 -- drivers/cpufreq/tango-cpufreq.c | 45 +++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/tango4-smp8758.dtsi b/arch/arm/boot/dts/tango4-smp8758.dtsi index d2e65c46bcc7..eca33d568690 100644 --- a/arch/arm/boot/dts/tango4-smp8758.dtsi +++ b/arch/arm/boot/dts/tango4-smp8758.dtsi @@ -13,7 +13,6 @@ reg = <0>; clocks = <&clkgen CPU_CLK>; clock-latency = <1>; - operating-points = <1215000 0 607500 0 405000 0 243000 0 135000 0>; }; cpu1: cpu@1 { diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 0a9b6a093646..5ae156dc0d35 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile @@ -75,6 +75,7 @@ obj-$(CONFIG_ARM_SA1110_CPUFREQ) += sa1110-cpufreq.o obj-$(CONFIG_ARM_SCPI_CPUFREQ) += scpi-cpufreq.o obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o obj-$(CONFIG_ARM_STI_CPUFREQ) += sti-cpufreq.o +obj-$(CONFIG_ARCH_TANGO) += tango-cpufreq.o obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c index 71267626456b..1490e4ce3fbc 100644 --- a/drivers/cpufreq/cpufreq-dt-platdev.c +++ b/drivers/cpufreq/cpufreq-dt-platdev.c @@ -70,8 +70,6 @@ { .compatible = "rockchip,rk3368", }, { .compatible = "rockchip,rk3399", }, - { .compatible = "sigma,tango4" }, - { .compatible = "ti,am33xx", }, { .compatible = "ti,dra7", }, { .compatible = "ti,omap2", }, diff --git a/drivers/cpufreq/tango-cpufreq.c b/drivers/cpufreq/tango-cpufreq.c new file mode 100644 index 000000000000..270c8261ebfa --- /dev/null +++ b/drivers/cpufreq/tango-cpufreq.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include + +static const struct of_device_id machines[] __initconst = { + { .compatible = "sigma,tango4" }, + { .compatible = "sigma,tango5" }, + { /* sentinel */ } +}; + +static void __init build_opp_table(struct device *cpu_dev, struct clk *cpu_clk) +{ + unsigned long max_freq = clk_get_rate(cpu_clk); + + dev_pm_opp_add(cpu_dev, max_freq / 1, 0); + dev_pm_opp_add(cpu_dev, max_freq / 2, 0); + dev_pm_opp_add(cpu_dev, max_freq / 3, 0); + dev_pm_opp_add(cpu_dev, max_freq / 5, 0); + dev_pm_opp_add(cpu_dev, max_freq / 9, 0); +} + +static int __init cpufreq_dt_platdev_init(void) +{ + struct device *cpu_dev = get_cpu_device(0); + const struct of_device_id *match; + struct clk *cpu_clk; + void *res; + + match = of_match_node(machines, of_root); + if (!match) + return -ENODEV; + + cpu_clk = clk_get(cpu_dev, NULL); + if (IS_ERR(cpu_clk)) + return -ENODEV; + + build_opp_table(cpu_dev, cpu_clk); + + res = platform_device_register_data(NULL, "cpufreq-dt", -1, NULL, 0); + + return PTR_ERR_OR_ZERO(res); +} +device_initcall(cpufreq_dt_platdev_init);