ipq806x: Add support for IPQ806x chip family
[openwrt/staging/wigyori.git] / target / linux / ipq806x / patches / 0173-cpufreq-Add-module-to-register-cpufreq-krait-device.patch
1 From f1db56284b01b1212a211023dcaa7846fd07d0ec Mon Sep 17 00:00:00 2001
2 From: Stephen Boyd <sboyd@codeaurora.org>
3 Date: Fri, 30 May 2014 17:16:53 -0700
4 Subject: [PATCH 173/182] cpufreq: Add module to register cpufreq-krait device
5
6 Register a cpufreq-krait device whenever we detect that a
7 "qcom,krait" compatible CPU is present in DT.
8
9 Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
10 ---
11 drivers/cpufreq/Kconfig.arm | 8 +++++++
12 drivers/cpufreq/Makefile | 1 +
13 drivers/cpufreq/qcom-cpufreq.c | 48 ++++++++++++++++++++++++++++++++++++++++
14 3 files changed, 57 insertions(+)
15 create mode 100644 drivers/cpufreq/qcom-cpufreq.c
16
17 diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
18 index 3129749..6ae884d 100644
19 --- a/drivers/cpufreq/Kconfig.arm
20 +++ b/drivers/cpufreq/Kconfig.arm
21 @@ -123,6 +123,14 @@ config ARM_OMAP2PLUS_CPUFREQ
22 depends on ARCH_OMAP2PLUS
23 default ARCH_OMAP2PLUS
24
25 +config ARM_QCOM_CPUFREQ
26 + tristate "Qualcomm based"
27 + depends on ARCH_QCOM
28 + help
29 + This adds the CPUFreq driver for Qualcomm SoC based boards.
30 +
31 + If in doubt, say N.
32 +
33 config ARM_S3C_CPUFREQ
34 bool
35 help
36 diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
37 index f6f4485..f5d18a3 100644
38 --- a/drivers/cpufreq/Makefile
39 +++ b/drivers/cpufreq/Makefile
40 @@ -60,6 +60,7 @@ obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o
41 obj-$(CONFIG_ARM_INTEGRATOR) += integrator-cpufreq.o
42 obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o
43 obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ) += omap-cpufreq.o
44 +obj-$(CONFIG_ARM_QCOM_CPUFREQ) += qcom-cpufreq.o
45 obj-$(CONFIG_PXA25x) += pxa2xx-cpufreq.o
46 obj-$(CONFIG_PXA27x) += pxa2xx-cpufreq.o
47 obj-$(CONFIG_PXA3xx) += pxa3xx-cpufreq.o
48 diff --git a/drivers/cpufreq/qcom-cpufreq.c b/drivers/cpufreq/qcom-cpufreq.c
49 new file mode 100644
50 index 0000000..71f4387
51 --- /dev/null
52 +++ b/drivers/cpufreq/qcom-cpufreq.c
53 @@ -0,0 +1,48 @@
54 +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
55 + *
56 + * This program is free software; you can redistribute it and/or modify
57 + * it under the terms of the GNU General Public License version 2 and
58 + * only version 2 as published by the Free Software Foundation.
59 + *
60 + * This program is distributed in the hope that it will be useful,
61 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
62 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63 + * GNU General Public License for more details.
64 + */
65 +
66 +#include <linux/kernel.h>
67 +#include <linux/module.h>
68 +#include <linux/cpu.h>
69 +#include <linux/of.h>
70 +#include <linux/platform_device.h>
71 +#include <linux/err.h>
72 +
73 +static int qcom_cpufreq_driver_init(void)
74 +{
75 + struct platform_device_info devinfo = { .name = "cpufreq-krait", };
76 + struct device *cpu_dev;
77 + struct device_node *np;
78 + struct platform_device *pdev;
79 +
80 + cpu_dev = get_cpu_device(0);
81 + if (!cpu_dev)
82 + return -ENODEV;
83 +
84 + np = of_node_get(cpu_dev->of_node);
85 + if (!np)
86 + return -ENOENT;
87 +
88 + if (!of_device_is_compatible(np, "qcom,krait")) {
89 + of_node_put(np);
90 + return -ENODEV;
91 + }
92 + of_node_put(np);
93 +
94 + pdev = platform_device_register_full(&devinfo);
95 +
96 + return PTR_ERR_OR_ZERO(pdev);
97 +}
98 +module_init(qcom_cpufreq_driver_init);
99 +
100 +MODULE_DESCRIPTION("Qualcomm CPUfreq driver");
101 +MODULE_LICENSE("GPL v2");
102 --
103 1.7.10.4
104