From patchwork Tue Mar 3 13:03:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 5922391 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B7CFD9F380 for ; Tue, 3 Mar 2015 13:04:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D366A20265 for ; Tue, 3 Mar 2015 13:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 59846202B8 for ; Tue, 3 Mar 2015 13:03:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756562AbbCCNDx (ORCPT ); Tue, 3 Mar 2015 08:03:53 -0500 Received: from mail-pd0-f171.google.com ([209.85.192.171]:40470 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756560AbbCCNDv (ORCPT ); Tue, 3 Mar 2015 08:03:51 -0500 Received: by pdbfp1 with SMTP id fp1so11118594pdb.7 for ; Tue, 03 Mar 2015 05:03:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=edJGJTiWulCHlq9mZboOMz8xrkvWGN/hTfnh15BJFrs=; b=Nut0L7I+fXfVRshL40ZIhEEQ+uT1vmwcnOjzFG0nwL4b1SYGUlqGsEZzwOargZ7lCp +ZOegi9Lq5DlsUzJPUls/8goN65TOhWWTN13Cc1X0QpneE+66GFfATrnDMOsh+m6K/4u EQD9IBaKvCqDmEewlzLTg4ccsToqYqhSSI+yW5I3prNC6JKSl+4dn4UFy7KCnOQW3LNq WG4hcMmHGfXZWcidv1iCltMNwNzBeYoW+ANATckk83pANt/LFIqtr+pzoZ8QNjS3tWUc hCwrC2Ks8SzcJkTcO2bBsCkqHh+jypIwdyKqKH+zu3Z3JhWgw3bWlx8Ed1LaQrEfm1rJ /UmA== X-Gm-Message-State: ALoCoQmkdh61U+iTI6NCzy5QyJ4WzhnFmqlFotNAOirScTAFySmF5L8bcSRuCNIAHpGeIlzHfv8A X-Received: by 10.68.172.162 with SMTP id bd2mr1231108pbc.89.1425387830941; Tue, 03 Mar 2015 05:03:50 -0800 (PST) Received: from localhost.localdomain ([180.150.148.224]) by mx.google.com with ESMTPSA id ak7sm971123pad.47.2015.03.03.05.03.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Mar 2015 05:03:50 -0800 (PST) From: Leo Yan To: Viresh Kumar , Shawn Guo , Thomas Petazzoni , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH 1/2] cpufreq-dt: support cluster level clock Date: Tue, 3 Mar 2015 21:03:36 +0800 Message-Id: <1425387817-11382-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1425387817-11382-1-git-send-email-leo.yan@linaro.org> References: <1425387817-11382-1-git-send-email-leo.yan@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the previous code, cpufreq-dt driver support single clock shared by all CPUs or every CPU has dedicated clock; but it cannot support cluster level clock domain, which is very common implementation for ARM SoCs. So this patch add the support for cluster level clock; which use the platform parameter "clk_domain_boundary" to indicate whether the clock domain is bound to system level, cluster level or CPU level. Signed-off-by: Leo Yan --- drivers/cpufreq/Kconfig | 5 +++-- drivers/cpufreq/cpufreq-dt.c | 14 +++++++++++++- include/linux/cpufreq-dt.h | 16 ++++++++++++---- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index a171fef..fe1aee1 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig @@ -193,8 +193,9 @@ config CPUFREQ_DT select PM_OPP help This adds a generic DT based cpufreq driver for frequency management. - It supports both uniprocessor (UP) and symmetric multiprocessor (SMP) - systems which share clock and voltage across all CPUs. + It supports uniprocessor (UP), and symmetric multiprocessor (SMP) + systems which share clock and voltage across all CPUs; and it also + supports cluster level or cpu level's clock domain. If in doubt, say N. diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index bab67db..c03532c 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -294,8 +294,20 @@ static int cpufreq_init(struct cpufreq_policy *policy) policy->cpuinfo.transition_latency = transition_latency; pd = cpufreq_get_driver_data(); - if (!pd || !pd->independent_clocks) + if (!pd || pd->clk_domain_boundary == CPUFREQ_DT_CLK_PER_SYS) cpumask_setall(policy->cpus); + else if (pd->clk_domain_boundary == CPUFREQ_DT_CLK_PER_CLUSTER) + cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu)); + else if (pd->clk_domain_boundary != CPUFREQ_DT_CLK_PER_CPU) { + /* + * If each CPU has its own clock, don't need bind cpus; + * otherwise will handle wrong parameter. + */ + dev_err(cpu_dev, "%s: invalid clk boundary value: %d\n", + __func__, pd->clk_domain_boundary); + ret = -EINVAL; + goto out_free_cpufreq_table; + } of_node_put(np); diff --git a/include/linux/cpufreq-dt.h b/include/linux/cpufreq-dt.h index 0414009..d6fe6e3 100644 --- a/include/linux/cpufreq-dt.h +++ b/include/linux/cpufreq-dt.h @@ -10,13 +10,21 @@ #ifndef __CPUFREQ_DT_H__ #define __CPUFREQ_DT_H__ +enum cpufreq_dt_clk_type { + CPUFREQ_DT_CLK_PER_SYS = 0, + CPUFREQ_DT_CLK_PER_CLUSTER, + CPUFREQ_DT_CLK_PER_CPU, +}; + struct cpufreq_dt_platform_data { /* - * True when each CPU has its own clock to control its - * frequency, false when all CPUs are controlled by a single - * clock. + * Use this to distinguish three kinds of clock domain: + * + * - all CPUs are controlled by a single clock; + * - all CPUs in cluster share one clock; + * - each CPU has its own clock to control its frequency; */ - bool independent_clocks; + enum cpufreq_dt_clk_type clk_domain_boundary; }; #endif /* __CPUFREQ_DT_H__ */