From patchwork Wed Sep 10 09:41:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 4875461 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D9630C0338 for ; Wed, 10 Sep 2014 09:43:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A7C0201D5 for ; Wed, 10 Sep 2014 09:43:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBAF92018B for ; Wed, 10 Sep 2014 09:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751490AbaIJJnS (ORCPT ); Wed, 10 Sep 2014 05:43:18 -0400 Received: from top.free-electrons.com ([176.31.233.9]:35875 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751040AbaIJJmk (ORCPT ); Wed, 10 Sep 2014 05:42:40 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id 9CA977AE; Wed, 10 Sep 2014 11:42:38 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (col31-4-88-188-83-94.fbx.proxad.net [88.188.83.94]) by mail.free-electrons.com (Postfix) with ESMTPSA id 267936FD; Wed, 10 Sep 2014 11:42:09 +0200 (CEST) From: Thomas Petazzoni To: Viresh Kumar Cc: Rafael Wysocki , Lists linaro-kernel , "linux-pm@vger.kernel.org" , Shawn Guo , Stephen Boyd , "linux-arm-msm@vger.kernel.org" , Sachin Kamat , Thomas Abraham , Tomasz Figa , Santosh Shilimkar , "pramod.gurav@smartplayin.com" , Rob Herring , Mike Turquette , Gregory Clement , Ezequiel Garcia , Tawfik Bayouk , Nadav Haklai , Lior Amsalem , Thomas Petazzoni Subject: [PATCH 2/4] cpufreq: cpufreq-dt: extend with platform_data Date: Wed, 10 Sep 2014 11:41:50 +0200 Message-Id: <1410342112-13264-3-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1410342112-13264-1-git-send-email-thomas.petazzoni@free-electrons.com> References: <1410342112-13264-1-git-send-email-thomas.petazzoni@free-electrons.com> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit extends the cpufreq-dt driver to take a platform_data structure. This structure is for now used to tell the cpufreq-dt driver the layout of the clocks on the platform, i.e whether all CPUs share the same clock or whether each CPU has a separate clock. Signed-off-by: Thomas Petazzoni --- drivers/cpufreq/cpufreq-dt.c | 20 ++++++++++++++++++-- include/linux/cpufreq-dt.h | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 include/linux/cpufreq-dt.h diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index e002650..35d396e 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,9 @@ #include #include +/* cpufreq_driver->flags values */ +#define CPUFREQ_DT_INDEPENDENT_CLOCKS (1 << 16) + struct private_data { struct device *cpu_dev; struct regulator *cpu_reg; @@ -266,9 +270,17 @@ static int cpufreq_init(struct cpufreq_policy *policy) policy->driver_data = priv; policy->clk = cpu_clk; - ret = cpufreq_generic_init(policy, freq_table, transition_latency); - if (ret) + ret = cpufreq_table_validate_and_show(policy, freq_table); + if (ret) { + dev_err(cpu_dev, "%s: invalid frequency table: %d\n", __func__, + ret); goto out_cooling_unregister; + } + + policy->cpuinfo.transition_latency = transition_latency; + + if (!(cpufreq_get_driver_flags() & CPUFREQ_DT_INDEPENDENT_CLOCKS)) + cpumask_setall(policy->cpus); return 0; @@ -314,6 +326,7 @@ static struct cpufreq_driver dt_cpufreq_driver = { static int dt_cpufreq_probe(struct platform_device *pdev) { + struct cpufreq_dt_platform_data *pd = dev_get_platdata(&pdev->dev); struct device *cpu_dev; struct regulator *cpu_reg; struct clk *cpu_clk; @@ -334,6 +347,9 @@ static int dt_cpufreq_probe(struct platform_device *pdev) if (!IS_ERR(cpu_reg)) regulator_put(cpu_reg); + if (pd->independent_clocks) + dt_cpufreq_driver.flags |= CPUFREQ_DT_INDEPENDENT_CLOCKS; + ret = cpufreq_register_driver(&dt_cpufreq_driver); if (ret) dev_err(cpu_dev, "failed register driver: %d\n", ret); diff --git a/include/linux/cpufreq-dt.h b/include/linux/cpufreq-dt.h new file mode 100644 index 0000000..0414009 --- /dev/null +++ b/include/linux/cpufreq-dt.h @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2014 Marvell + * Thomas Petazzoni + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __CPUFREQ_DT_H__ +#define __CPUFREQ_DT_H__ + +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. + */ + bool independent_clocks; +}; + +#endif /* __CPUFREQ_DT_H__ */