From: Viresh Kumar <viresh.kumar@linaro.org>
To: Rafael Wysocki <rjw@rjwysocki.net>,
arnd.bergmann@linaro.org, Viresh Kumar <viresh.kumar@linaro.org>
Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
kgene.kim@samsung.com, xf@rock-chips.com, heiko@sntech.de,
mmcclint@codeaurora.org, k.kozlowski@samsung.com,
linux-kernel@vger.kernel.org
Subject: [PATCH V3 2/4] cpufreq: dt: Add generic platform-device creation support
Date: Wed, 30 Mar 2016 13:45:26 +0530 [thread overview]
Message-ID: <9de0943d865948c7cffae4be3c6cfc8e5b2743ca.1459325515.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1459325515.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1459325515.git.viresh.kumar@linaro.org>
Multiple platforms are using the generic cpufreq-dt driver now, and all
of them are required to create a platform device with name "cpufreq-dt",
in order to get the cpufreq-dt probed.
Many of them do it from platform code, others have special drivers just
to do that.
It would be more sensible to do this at a generic place, where all such
platform can mark their entries.
This patch adds a separate file to get this device created. Currently
the compat list of platforms that we support is empty, and will be
filled in as and when we move platforms to use it.
It always compiles as part of the kernel and so doesn't need a
module-exit operation.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/cpufreq/Kconfig | 10 ++++++++++
drivers/cpufreq/Makefile | 1 +
drivers/cpufreq/cpufreq-dt-platdev.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+)
create mode 100644 drivers/cpufreq/cpufreq-dt-platdev.c
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index a7f45853c103..8c26e3c53498 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -191,6 +191,7 @@ config CPUFREQ_DT
depends on HAVE_CLK && OF
# if CPU_THERMAL is on and THERMAL=m, CPUFREQ_DT cannot be =y:
depends on !CPU_THERMAL || THERMAL
+ select CPUFREQ_DT_PLATDEV
select PM_OPP
help
This adds a generic DT based cpufreq driver for frequency management.
@@ -199,6 +200,15 @@ config CPUFREQ_DT
If in doubt, say N.
+config CPUFREQ_DT_PLATDEV
+ bool
+ help
+ This adds a generic DT based cpufreq platdev driver for frequency
+ management. This creates a 'cpufreq-dt' platform device, on the
+ supported platforms.
+
+ If in doubt, say N.
+
if X86
source "drivers/cpufreq/Kconfig.x86"
endif
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 9e63fb1b09f8..b9224fdb8322 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE) += cpufreq_conservative.o
obj-$(CONFIG_CPU_FREQ_GOV_COMMON) += cpufreq_governor.o
obj-$(CONFIG_CPUFREQ_DT) += cpufreq-dt.o
+obj-$(CONFIG_CPUFREQ_DT_PLATDEV) += cpufreq-dt-platdev.o
##################################################################################
# x86 drivers.
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
new file mode 100644
index 000000000000..2a3532427ecf
--- /dev/null
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 Linaro.
+ * Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * 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.
+ */
+
+#include <linux/err.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+static const struct of_device_id machines[] = {
+};
+
+static int __init cpufreq_dt_platdev_init(void)
+{
+ struct device_node *np = of_find_node_by_path("/");
+
+ if (!np)
+ return -ENODEV;
+
+ if (!of_match_node(machines, np))
+ return -ENODEV;
+
+ of_node_put(of_root);
+
+ return PTR_ERR_OR_ZERO(platform_device_register_simple("cpufreq-dt", -1,
+ NULL, 0));
+}
+device_initcall(cpufreq_dt_platdev_init);
--
2.7.1.410.g6faf27b
next prev parent reply other threads:[~2016-03-30 8:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-30 8:15 [PATCH V3 0/4] cpufreq: dt: Create platform device from generic code Viresh Kumar
2016-03-30 8:15 ` [PATCH V3 1/4] cpufreq: dt: Include types.h from cpufreq-dt.h Viresh Kumar
2016-03-30 8:15 ` Viresh Kumar [this message]
2016-04-13 19:46 ` [PATCH V3 2/4] cpufreq: dt: Add generic platform-device creation support Matthew McClintock
2016-03-30 8:15 ` [PATCH V3 3/4] ARM: exynos: exynos-cpufreq platform device isn't supported anymore Viresh Kumar
2016-03-30 8:30 ` Krzysztof Kozlowski
2016-03-30 8:15 ` [PATCH V3 4/4] cpufreq: exynos: Use generic platdev driver Viresh Kumar
2016-04-07 8:31 ` [PATCH V3 0/4] cpufreq: dt: Create platform device from generic code Viresh Kumar
2016-04-20 9:55 ` Viresh Kumar
2016-04-20 21:27 ` Mason
2016-04-20 22:31 ` Rafael J. Wysocki
2016-04-27 16:47 ` Mason
2016-04-27 16:57 ` Matthew McClintock
2016-04-28 2:27 ` Viresh Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9de0943d865948c7cffae4be3c6cfc8e5b2743ca.1459325515.git.viresh.kumar@linaro.org \
--to=viresh.kumar@linaro.org \
--cc=arnd.bergmann@linaro.org \
--cc=heiko@sntech.de \
--cc=k.kozlowski@samsung.com \
--cc=kgene.kim@samsung.com \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mmcclint@codeaurora.org \
--cc=rjw@rjwysocki.net \
--cc=xf@rock-chips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).