From patchwork Mon Aug 21 13:13:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 110524 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1259540qge; Mon, 21 Aug 2017 06:13:38 -0700 (PDT) X-Received: by 10.99.37.4 with SMTP id l4mr6983933pgl.408.1503321218609; Mon, 21 Aug 2017 06:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503321218; cv=none; d=google.com; s=arc-20160816; b=SuMCe+rykOGxmpBKgErpwXZGkLVB7VYyFvxX4V/ktFytkEcXgd8q8HW9wPtOOblj7p 6mtnTdcyHQKVfrdeX76h1l+aH803AuicA+jFllrJgqDhC5BXGOiFwzn7XYgLcWgEkGqA qVOAmlrXMkwJoziz1wm36TMZymTV5/UdXzCJlxJw5Xd1h186pj/sAyB0LORoqMqVG2oJ pRysN/fuERT7ajNGfTN7GKHDlZIpuBO0H1obLwISpqVi2Ayg1X91pV3z7l8s1iglmiXD /jR60Fe9XKbBQuG1JvQEtC/DZax6T4qEg0NRTrqT1nw3/ZGT+E6jRoM/hsG44tFdbvrd +laQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=fCcYKOwTEmm9U2HCWxWI+ZvNV1618u13lnvjZfHVvjo=; b=BUxLzG/LPAcck8gcFS/tM709S2hNowQqkG/bdyTKqNVBcQFe/0mw+Pgeo6iKVA8yi4 24wLcCtWzhQrud7XcqXMjRVDaHddzIOm1iS3/xKBvrZkZmzqz1jW6yAdpgQh4dK9UWXI Fjfe5nuJ0zwM2lELtBVqUfszZKp4oCfBQdmA16PHd4Jr6hnJP/zxl3sLe1sgF0SQrOhj UtTQAQ5W3ylnBWphEXCGFHwye3ORhOenKCp9ctZbCjyXR8BnaH7lbyJF4NRNBPT5IJo3 uKIq9IGYCt01v8XNmJXTexhlPh5WIm7HXg8/52PVfGEX2hfOYUUF0ek3uwYHm7jCaTd8 wD8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v67si5966748pfd.551.2017.08.21.06.13.38; Mon, 21 Aug 2017 06:13:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753854AbdHUNNh (ORCPT + 12 others); Mon, 21 Aug 2017 09:13:37 -0400 Received: from kirsty.vergenet.net ([202.4.237.240]:46272 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753755AbdHUNNg (ORCPT ); Mon, 21 Aug 2017 09:13:36 -0400 Received: from reginn.horms.nl (52D9BC73.cm-11-1c.dynamic.ziggo.nl [82.217.188.115]) by kirsty.vergenet.net (Postfix) with ESMTPA id CA13125B74A; Mon, 21 Aug 2017 23:13:34 +1000 (AEST) Received: by reginn.horms.nl (Postfix, from userid 7100) id 67E27940328; Mon, 21 Aug 2017 15:13:32 +0200 (CEST) Date: Mon, 21 Aug 2017 15:13:32 +0200 From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , geert@linux-m68k.org, maxime.ripard@free-electrons.com, wens@csie.org, xuwei5@hisilicon.com, kgene@kernel.org, krzk@kernel.org, yamada.masahiro@socionext.com, jun.nie@linaro.org, baoyou.xie@linaro.org, linux-kernel@vger.kernel.org Subject: [1/2] cpufreq: dt-platdev: Automatically create cpufreq device with OPP v2 Message-ID: <20170821131332.GA14662@verge.net.au> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The initial idea of creating the cpufreq-dt-platdev.c file was to keep a list of platforms that use the "operating-points" (V1) bindings and create cpufreq device for them only, as we weren't sure which platforms would want the device to get created automatically as some had their own cpufreq drivers as well, or wanted to initialize cpufreq after doing some stuff from platform code. But that wasn't the case with platforms using "operating-points-v2" property. We wanted the device to get created automatically without the need of adding them to the whitelist. Though, we will still have some exceptions where we don't want to create the device automatically. Rename the earlier platform list as *whitelist* and create a new *blacklist* as well. The cpufreq-dt device will get created if: - The platform is there in the whitelist OR - The platform has "operating-points-v2" property in CPU0's DT node and isn't part of the blacklist . Reported-by: Geert Uytterhoeven Signed-off-by: Viresh Kumar I have exercised this on the r8a7795 and r8a7795 with the following reverted: * 034def597bb7 ("cpufreq: rcar: Add support for R8A7795 SoC") * bea2ebca6b91 ("cpufreq: dt: Add r8a7796 support to to use generic cpufreq driver") Tested-by: Simon Horman --- drivers/cpufreq/cpufreq-dt-platdev.c | 45 ++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c index bcee384b3251..061b468512a2 100644 --- a/drivers/cpufreq/cpufreq-dt-platdev.c +++ b/drivers/cpufreq/cpufreq-dt-platdev.c @@ -9,11 +9,16 @@ #include #include +#include #include #include "cpufreq-dt.h" -static const struct of_device_id machines[] __initconst = { +/* + * Machines for which the cpufreq device is *always* created, mostly used for + * platforms using "operating-points" (V1) property. + */ +static const struct of_device_id whitelist[] __initconst = { { .compatible = "allwinner,sun4i-a10", }, { .compatible = "allwinner,sun5i-a10s", }, { .compatible = "allwinner,sun5i-a13", }, @@ -101,21 +106,51 @@ static const struct of_device_id machines[] __initconst = { { } }; +/* + * Machines for which the cpufreq device is *not* created, mostly used for + * platforms using "operating-points-v2" property. + */ +static const struct of_device_id blacklist[] __initconst = { + { } +}; + +static bool __init cpu0_node_has_opp_v2_prop(void) +{ + struct device_node *np = of_cpu_device_node_get(0); + bool ret = false; + + if (of_get_property(np, "operating-points-v2", NULL)) + ret = true; + + of_node_put(np); + return ret; +} + static int __init cpufreq_dt_platdev_init(void) { struct device_node *np = of_find_node_by_path("/"); const struct of_device_id *match; + const void *data = NULL; if (!np) return -ENODEV; - match = of_match_node(machines, np); + match = of_match_node(whitelist, np); + if (match) { + data = match->data; + goto create_pdev; + } + + if (cpu0_node_has_opp_v2_prop() && !of_match_node(blacklist, np)) + goto create_pdev; + of_node_put(np); - if (!match) - return -ENODEV; + return -ENODEV; +create_pdev: + of_node_put(np); return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt", - -1, match->data, + -1, data, sizeof(struct cpufreq_dt_platform_data))); } device_initcall(cpufreq_dt_platdev_init);