From patchwork Wed Aug 16 05:37:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 110200 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp337494qge; Tue, 15 Aug 2017 22:37:36 -0700 (PDT) X-Received: by 10.99.184.2 with SMTP id p2mr569692pge.194.1502861855927; Tue, 15 Aug 2017 22:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502861855; cv=none; d=google.com; s=arc-20160816; b=EboYqWVom+LhrSKFWDYBZgE7SaLrbUxiMoz+r4UmYo9fjcLy2gEzOi6E96CmRVYAdN 0zV26b5L+6JS6PEHkT3pTgSNTEYkYGyq4wBJC870JUk626zGZLF0a8bVHVGDxom2meGi sdKcxEAxvDCb3q3QOrebIWWfmCcMX9z8t7Bc9+OdW5eLFnPxtufCdEwW4/eUzkV/QXRC +Ys2VgpCdTIoy/z+gC+BgXIOD1ouYvIXUDxA4zIeKi7KPmVnu4o8jufhbvg3tdSuW72u kQwkT1KctMZfMlSBz32U5uaX83TJaj8oQIMEynRs64p3gwko2TdPre0LyOoUdf4t+uOq Dz9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=PKSGYdJEldxL+CAdsd1Lmtev+NvZ/mhijqYYvA3dJFQ=; b=Iz2OwmXOuB+wYUlbaXKvQDmr+NAJJFlni3ftcPCaU3fDznZMNpoHIdV3GZCLuSOJph 8GR7BWutWc59UmaoEd3ze4UKMwP42nktLm8iFxkJ0T5rf9fZ+rVJlAM2G+v8xbTCWQHs AFK/mj3tO9Y98yFh+F2KDQPhYq3A6mwg13FUcuAY1c2jfo0+B7tZGh61bhY/HeXzGpem aHns6HT+HAnHqxEtR/juaAHKvgOultrs1nRLF0qa1iEZplMmjvyzrvzxlKllPp2Cbvz7 wfWwRau13/dehpIo0rB/QNn0VbE4VYxYgH/zuxtFhPpy6fMgYNSFEJ5usbUcyJ5IvXxQ +Hlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vea8Es/g; 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=pass (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 c188si42150pfb.46.2017.08.15.22.37.35; Tue, 15 Aug 2017 22:37:35 -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; dkim=pass header.i=@linaro.org header.s=google header.b=Vea8Es/g; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751224AbdHPFhe (ORCPT + 12 others); Wed, 16 Aug 2017 01:37:34 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:34800 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751068AbdHPFhd (ORCPT ); Wed, 16 Aug 2017 01:37:33 -0400 Received: by mail-pf0-f175.google.com with SMTP id o86so1908605pfj.1 for ; Tue, 15 Aug 2017 22:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=PKSGYdJEldxL+CAdsd1Lmtev+NvZ/mhijqYYvA3dJFQ=; b=Vea8Es/gg0jBPzbt3CqBH9WoVXgz9NWXKEsg3l+3tm+Cuur5OvDkhmpvh941IJPvsq +VC+uhbHmKbv45On2hAn9hI22KnYzai3nNIGkeZyGNQPny6TBRlgNstMZ/hXW06pNpi6 XhnmhQRKTVXO3DuYiLObqnVAKrcuQ3K+5fvz8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PKSGYdJEldxL+CAdsd1Lmtev+NvZ/mhijqYYvA3dJFQ=; b=MRtK267zBBQT21ElCQMlKDIflVZGc+9Xg93Na6EidKOZu0rIoYo3VC8lIjq9r0pxN5 q9ve4YI/TnG+jy20X76DloXsPyYWS7+rsbz6TKnctcwlQOBSX8oeTJSbV11nj9XpsNKX sRG41LlYwfJ38jNSWjxauasSiWZF5f6v9hUKt0iOKQ5wyiHfSRVhihPB/BF5x7SGe3mm 7l3Wu79JuABrQEkkpNFubrkqUJBidYpRnpEPZ9QQfIM3LGbqx8YsjkY6sPFR9SiXSWKU oV1LdKHBsAAFAITw7rxrbCHqWx/iKwaxnxUbiyM/IhEK8qs6tKru4ywutwYIRbgfG8/A APPw== X-Gm-Message-State: AHYfb5jBp7yIExYhtb7/TtaVxaw2fXRkmZIImajZBxhDph3dj2l78/O8 yyZUHcY9sU+qnm36jMaf1g== X-Received: by 10.98.224.73 with SMTP id f70mr571921pfh.12.1502861852838; Tue, 15 Aug 2017 22:37:32 -0700 (PDT) Received: from localhost ([122.172.110.130]) by smtp.gmail.com with ESMTPSA id j1sm87692pgs.77.2017.08.15.22.37.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Aug 2017 22:37:31 -0700 (PDT) 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: [PATCH 1/2] cpufreq: dt-platdev: Automatically create cpufreq device with OPP v2 Date: Wed, 16 Aug 2017 11:07:27 +0530 Message-Id: X-Mailer: git-send-email 2.14.1.202.g24db08a6e8fe 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 --- drivers/cpufreq/cpufreq-dt-platdev.c | 45 ++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-) -- 2.7.4 Acked-by: Chen-Yu Tsai Tested-by: Simon Horman Reviewed-by: Masahiro Yamada 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);