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: 5922441 Return-Path: X-Original-To: patchwork-linux-arm@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 6AC0D9F54F for ; Tue, 3 Mar 2015 13:06:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7983420225 for ; Tue, 3 Mar 2015 13:06:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81F8920222 for ; Tue, 3 Mar 2015 13:06:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YSmUu-0000Ts-NB; Tue, 03 Mar 2015 13:04:28 +0000 Received: from mail-pa0-f49.google.com ([209.85.220.49]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YSmUe-0000Hk-8a for linux-arm-kernel@lists.infradead.org; Tue, 03 Mar 2015 13:04:13 +0000 Received: by padfb1 with SMTP id fb1so14702951pad.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=FrpFF5cNJ1qlkBScnyWTt8pXlMu7XamNg3Td6lTlGQmBO6bbD0zM4CgGWpA2ZwEBbC NOSPmowoitVNV13Jj2I/SXkJ3Lt3HehJGfcbEkm9JLmfbYTmhncCmNk5n32FlhsVKzsU m1xbiXXtb6AtGFaPiOcXO+Y68OxvYiJE3b4GFRZxwUQt/aBwpR3BlZoYkqRqZ9e+YzLM eK2FtZqNosoTho0U8+qD2qnByDXnODJJMVD1wmHA49a2jWvzQ3Gtc+hGLsMdeDJ9+qCp KOo+7HuO4cB6vZ4x9l268C2LDhVkaP/Ox+7l5do2CLgIcUu4woIu5w0pZgJBL1Na3Gbb R+ow== X-Gm-Message-State: ALoCoQlafuqg27n8CgGzXSreomxxJ2GP/xmRs23rkITIX4lY1qYC4zfxg01Qnt0C3YdF3oEk3P+z 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150303_050412_386186_81EFECC0 X-CRM114-Status: GOOD ( 15.01 ) X-Spam-Score: -0.7 (/) Cc: Leo Yan X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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__ */