blob: bbafd7b63d1a2f7dd33f4f8c8e6154a8d6a5107e [file] [log] [blame]
Shawn Guo95ceafd2012-09-06 07:09:11 +00001/*
2 * Copyright (C) 2012 Freescale Semiconductor, Inc.
3 *
Viresh Kumar748c8762014-08-28 11:22:24 +05304 * Copyright (C) 2014 Linaro.
5 * Viresh Kumar <viresh.kumar@linaro.org>
6 *
Viresh Kumarbbcf0712014-09-09 19:58:03 +05307 * The OPP code in function set_target() is reused from
Shawn Guo95ceafd2012-09-06 07:09:11 +00008 * drivers/cpufreq/omap-cpufreq.c
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16
17#include <linux/clk.h>
Sudeep KarkadaNageshae1825b22013-09-10 18:59:46 +010018#include <linux/cpu.h>
Eduardo Valentin77cff592013-07-15 09:09:14 -040019#include <linux/cpu_cooling.h>
Shawn Guo95ceafd2012-09-06 07:09:11 +000020#include <linux/cpufreq.h>
Thomas Petazzoni34e5a522014-10-19 11:30:28 +020021#include <linux/cpufreq-dt.h>
Eduardo Valentin77cff592013-07-15 09:09:14 -040022#include <linux/cpumask.h>
Shawn Guo95ceafd2012-09-06 07:09:11 +000023#include <linux/err.h>
24#include <linux/module.h>
25#include <linux/of.h>
Nishanth Menone4db1c72013-09-19 16:03:52 -050026#include <linux/pm_opp.h>
Shawn Guo5553f9e2013-01-30 14:27:49 +000027#include <linux/platform_device.h>
Shawn Guo95ceafd2012-09-06 07:09:11 +000028#include <linux/regulator/consumer.h>
29#include <linux/slab.h>
Eduardo Valentin77cff592013-07-15 09:09:14 -040030#include <linux/thermal.h>
Shawn Guo95ceafd2012-09-06 07:09:11 +000031
Viresh Kumard2f31f12014-08-28 11:22:28 +053032struct private_data {
33 struct device *cpu_dev;
34 struct regulator *cpu_reg;
35 struct thermal_cooling_device *cdev;
Viresh Kumar050794a2016-02-09 10:30:43 +053036 const char *reg_name;
Viresh Kumard2f31f12014-08-28 11:22:28 +053037};
Shawn Guo95ceafd2012-09-06 07:09:11 +000038
Bartlomiej Zolnierkiewicz21c36d32015-08-07 13:59:16 +020039static struct freq_attr *cpufreq_dt_attr[] = {
40 &cpufreq_freq_attr_scaling_available_freqs,
41 NULL, /* Extra space for boost-attr if required */
42 NULL,
43};
44
Viresh Kumarbbcf0712014-09-09 19:58:03 +053045static int set_target(struct cpufreq_policy *policy, unsigned int index)
Shawn Guo95ceafd2012-09-06 07:09:11 +000046{
Viresh Kumard2f31f12014-08-28 11:22:28 +053047 struct private_data *priv = policy->driver_data;
Shawn Guo95ceafd2012-09-06 07:09:11 +000048
Viresh Kumar78c3ba52016-02-09 10:30:46 +053049 return dev_pm_opp_set_rate(priv->cpu_dev,
50 policy->freq_table[index].frequency * 1000);
Shawn Guo95ceafd2012-09-06 07:09:11 +000051}
52
Viresh Kumar050794a2016-02-09 10:30:43 +053053/*
54 * An earlier version of opp-v1 bindings used to name the regulator
55 * "cpu0-supply", we still need to handle that for backwards compatibility.
56 */
Viresh Kumardf2c8ec2016-02-09 10:30:47 +053057static const char *find_supply_name(struct device *dev)
Viresh Kumar050794a2016-02-09 10:30:43 +053058{
Viresh Kumardf2c8ec2016-02-09 10:30:47 +053059 struct device_node *np;
Viresh Kumar050794a2016-02-09 10:30:43 +053060 struct property *pp;
61 int cpu = dev->id;
Viresh Kumardf2c8ec2016-02-09 10:30:47 +053062 const char *name = NULL;
63
64 np = of_node_get(dev->of_node);
65
66 /* This must be valid for sure */
67 if (WARN_ON(!np))
68 return NULL;
Viresh Kumar050794a2016-02-09 10:30:43 +053069
70 /* Try "cpu0" for older DTs */
71 if (!cpu) {
72 pp = of_find_property(np, "cpu0-supply", NULL);
Viresh Kumardf2c8ec2016-02-09 10:30:47 +053073 if (pp) {
74 name = "cpu0";
75 goto node_put;
76 }
Viresh Kumar050794a2016-02-09 10:30:43 +053077 }
78
79 pp = of_find_property(np, "cpu-supply", NULL);
Viresh Kumardf2c8ec2016-02-09 10:30:47 +053080 if (pp) {
81 name = "cpu";
82 goto node_put;
83 }
Viresh Kumar050794a2016-02-09 10:30:43 +053084
85 dev_dbg(dev, "no regulator for cpu%d\n", cpu);
Viresh Kumardf2c8ec2016-02-09 10:30:47 +053086node_put:
87 of_node_put(np);
88 return name;
Viresh Kumar050794a2016-02-09 10:30:43 +053089}
90
Viresh Kumar95b61052014-08-28 11:22:30 +053091static int allocate_resources(int cpu, struct device **cdev,
Viresh Kumard2f31f12014-08-28 11:22:28 +053092 struct regulator **creg, struct clk **cclk)
Shawn Guo95ceafd2012-09-06 07:09:11 +000093{
Viresh Kumard2f31f12014-08-28 11:22:28 +053094 struct device *cpu_dev;
95 struct regulator *cpu_reg;
96 struct clk *cpu_clk;
97 int ret = 0;
Viresh Kumar2d2c5e02014-08-28 11:22:29 +053098 char *reg_cpu0 = "cpu0", *reg_cpu = "cpu", *reg;
Shawn Guo95ceafd2012-09-06 07:09:11 +000099
Viresh Kumar95b61052014-08-28 11:22:30 +0530100 cpu_dev = get_cpu_device(cpu);
Sudeep KarkadaNageshae1825b22013-09-10 18:59:46 +0100101 if (!cpu_dev) {
Viresh Kumar95b61052014-08-28 11:22:30 +0530102 pr_err("failed to get cpu%d device\n", cpu);
Sudeep KarkadaNageshae1825b22013-09-10 18:59:46 +0100103 return -ENODEV;
104 }
Paolo Pisatif5c3ef22013-03-28 09:24:29 +0000105
Viresh Kumar2d2c5e02014-08-28 11:22:29 +0530106 /* Try "cpu0" for older DTs */
Viresh Kumar95b61052014-08-28 11:22:30 +0530107 if (!cpu)
108 reg = reg_cpu0;
109 else
110 reg = reg_cpu;
Viresh Kumar2d2c5e02014-08-28 11:22:29 +0530111
112try_again:
113 cpu_reg = regulator_get_optional(cpu_dev, reg);
Arnd Bergmannb331bc22016-01-25 16:45:48 +0100114 ret = PTR_ERR_OR_ZERO(cpu_reg);
115 if (ret) {
Nishanth Menonfc31d6f2013-05-01 13:38:12 +0000116 /*
Viresh Kumar95b61052014-08-28 11:22:30 +0530117 * If cpu's regulator supply node is present, but regulator is
Nishanth Menonfc31d6f2013-05-01 13:38:12 +0000118 * not yet registered, we should try defering probe.
119 */
Arnd Bergmannb331bc22016-01-25 16:45:48 +0100120 if (ret == -EPROBE_DEFER) {
Viresh Kumar95b61052014-08-28 11:22:30 +0530121 dev_dbg(cpu_dev, "cpu%d regulator not ready, retry\n",
122 cpu);
Arnd Bergmannb331bc22016-01-25 16:45:48 +0100123 return ret;
Nishanth Menonfc31d6f2013-05-01 13:38:12 +0000124 }
Viresh Kumar2d2c5e02014-08-28 11:22:29 +0530125
126 /* Try with "cpu-supply" */
127 if (reg == reg_cpu0) {
128 reg = reg_cpu;
129 goto try_again;
130 }
131
Arnd Bergmannb331bc22016-01-25 16:45:48 +0100132 dev_dbg(cpu_dev, "no regulator for cpu%d: %d\n", cpu, ret);
Nishanth Menonfc31d6f2013-05-01 13:38:12 +0000133 }
134
Lucas Stache3beb0a2014-05-16 12:20:42 +0200135 cpu_clk = clk_get(cpu_dev, NULL);
Arnd Bergmannb331bc22016-01-25 16:45:48 +0100136 ret = PTR_ERR_OR_ZERO(cpu_clk);
137 if (ret) {
Viresh Kumard2f31f12014-08-28 11:22:28 +0530138 /* put regulator */
139 if (!IS_ERR(cpu_reg))
140 regulator_put(cpu_reg);
141
Viresh Kumar48a86242014-08-28 11:22:26 +0530142 /*
143 * If cpu's clk node is present, but clock is not yet
144 * registered, we should try defering probe.
145 */
146 if (ret == -EPROBE_DEFER)
Viresh Kumar95b61052014-08-28 11:22:30 +0530147 dev_dbg(cpu_dev, "cpu%d clock not ready, retry\n", cpu);
Viresh Kumar48a86242014-08-28 11:22:26 +0530148 else
Abhilash Kesavan71796212014-10-31 18:09:33 +0530149 dev_err(cpu_dev, "failed to get cpu%d clock: %d\n", cpu,
150 ret);
Viresh Kumard2f31f12014-08-28 11:22:28 +0530151 } else {
152 *cdev = cpu_dev;
153 *creg = cpu_reg;
154 *cclk = cpu_clk;
155 }
Viresh Kumar48a86242014-08-28 11:22:26 +0530156
Viresh Kumard2f31f12014-08-28 11:22:28 +0530157 return ret;
158}
159
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530160static int cpufreq_init(struct cpufreq_policy *policy)
Viresh Kumard2f31f12014-08-28 11:22:28 +0530161{
162 struct cpufreq_frequency_table *freq_table;
Viresh Kumard2f31f12014-08-28 11:22:28 +0530163 struct private_data *priv;
164 struct device *cpu_dev;
165 struct regulator *cpu_reg;
166 struct clk *cpu_clk;
Bartlomiej Zolnierkiewicz953ba9f2015-09-08 18:41:03 +0200167 struct dev_pm_opp *suspend_opp;
Viresh Kumard2f31f12014-08-28 11:22:28 +0530168 unsigned int transition_latency;
Viresh Kumar457e99e62016-02-09 10:30:41 +0530169 bool opp_v1 = false;
Viresh Kumar050794a2016-02-09 10:30:43 +0530170 const char *name;
Viresh Kumard2f31f12014-08-28 11:22:28 +0530171 int ret;
172
Viresh Kumar95b61052014-08-28 11:22:30 +0530173 ret = allocate_resources(policy->cpu, &cpu_dev, &cpu_reg, &cpu_clk);
Viresh Kumard2f31f12014-08-28 11:22:28 +0530174 if (ret) {
Geert Uytterhoevenedd52b12014-10-23 11:52:54 +0200175 pr_err("%s: Failed to allocate resources: %d\n", __func__, ret);
Viresh Kumard2f31f12014-08-28 11:22:28 +0530176 return ret;
177 }
178
Viresh Kumar2e02d872015-07-29 16:23:10 +0530179 /* Get OPP-sharing information from "operating-points-v2" bindings */
Viresh Kumar8f8d37b2015-09-04 13:47:24 +0530180 ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, policy->cpus);
Viresh Kumar2e02d872015-07-29 16:23:10 +0530181 if (ret) {
182 /*
183 * operating-points-v2 not supported, fallback to old method of
184 * finding shared-OPPs for backward compatibility.
185 */
186 if (ret == -ENOENT)
Viresh Kumar457e99e62016-02-09 10:30:41 +0530187 opp_v1 = true;
Viresh Kumar2e02d872015-07-29 16:23:10 +0530188 else
Viresh Kumardf2c8ec2016-02-09 10:30:47 +0530189 goto out_put_reg_clk;
Viresh Kumar2e02d872015-07-29 16:23:10 +0530190 }
191
192 /*
Viresh Kumar050794a2016-02-09 10:30:43 +0530193 * OPP layer will be taking care of regulators now, but it needs to know
194 * the name of the regulator first.
195 */
Viresh Kumardf2c8ec2016-02-09 10:30:47 +0530196 name = find_supply_name(cpu_dev);
Viresh Kumar050794a2016-02-09 10:30:43 +0530197 if (name) {
198 ret = dev_pm_opp_set_regulator(cpu_dev, name);
199 if (ret) {
200 dev_err(cpu_dev, "Failed to set regulator for cpu%d: %d\n",
201 policy->cpu, ret);
Viresh Kumardf2c8ec2016-02-09 10:30:47 +0530202 goto out_put_reg_clk;
Viresh Kumar050794a2016-02-09 10:30:43 +0530203 }
204 }
205
206 /*
Viresh Kumar2e02d872015-07-29 16:23:10 +0530207 * Initialize OPP tables for all policy->cpus. They will be shared by
208 * all CPUs which have marked their CPUs shared with OPP bindings.
209 *
210 * For platforms not using operating-points-v2 bindings, we do this
211 * before updating policy->cpus. Otherwise, we will end up creating
212 * duplicate OPPs for policy->cpus.
213 *
214 * OPPs might be populated at runtime, don't check for error here
215 */
Viresh Kumar8f8d37b2015-09-04 13:47:24 +0530216 dev_pm_opp_of_cpumask_add_table(policy->cpus);
Viresh Kumar2e02d872015-07-29 16:23:10 +0530217
Viresh Kumar7d5d0c82015-09-02 14:36:48 +0530218 /*
219 * But we need OPP table to function so if it is not there let's
220 * give platform code chance to provide it for us.
221 */
222 ret = dev_pm_opp_get_opp_count(cpu_dev);
223 if (ret <= 0) {
Viresh Kumar896d6a42016-02-09 10:30:40 +0530224 dev_dbg(cpu_dev, "OPP table is not ready, deferring probe\n");
Viresh Kumar7d5d0c82015-09-02 14:36:48 +0530225 ret = -EPROBE_DEFER;
226 goto out_free_opp;
227 }
228
Viresh Kumar457e99e62016-02-09 10:30:41 +0530229 if (opp_v1) {
Viresh Kumar2e02d872015-07-29 16:23:10 +0530230 struct cpufreq_dt_platform_data *pd = cpufreq_get_driver_data();
231
232 if (!pd || !pd->independent_clocks)
233 cpumask_setall(policy->cpus);
234
235 /*
236 * OPP tables are initialized only for policy->cpu, do it for
237 * others as well.
238 */
Viresh Kumar8f8d37b2015-09-04 13:47:24 +0530239 ret = dev_pm_opp_set_sharing_cpus(cpu_dev, policy->cpus);
Viresh Kumar8bc86282015-09-02 14:36:49 +0530240 if (ret)
241 dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n",
242 __func__, ret);
Viresh Kumar2e02d872015-07-29 16:23:10 +0530243 }
Shawn Guo95ceafd2012-09-06 07:09:11 +0000244
Viresh Kumard2f31f12014-08-28 11:22:28 +0530245 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
246 if (!priv) {
247 ret = -ENOMEM;
Viresh Kumar2f0f6092014-11-25 16:04:21 +0530248 goto out_free_opp;
Viresh Kumard2f31f12014-08-28 11:22:28 +0530249 }
250
Viresh Kumar050794a2016-02-09 10:30:43 +0530251 priv->reg_name = name;
Shawn Guo95ceafd2012-09-06 07:09:11 +0000252
Lucas Stach045ee452014-10-24 15:05:55 +0200253 ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
254 if (ret) {
Viresh Kumar896d6a42016-02-09 10:30:40 +0530255 dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret);
Lucas Stach045ee452014-10-24 15:05:55 +0200256 goto out_free_priv;
257 }
258
Viresh Kumard2f31f12014-08-28 11:22:28 +0530259 priv->cpu_dev = cpu_dev;
260 priv->cpu_reg = cpu_reg;
261 policy->driver_data = priv;
262
263 policy->clk = cpu_clk;
Bartlomiej Zolnierkiewicz953ba9f2015-09-08 18:41:03 +0200264
265 rcu_read_lock();
266 suspend_opp = dev_pm_opp_get_suspend_opp(cpu_dev);
267 if (suspend_opp)
268 policy->suspend_freq = dev_pm_opp_get_freq(suspend_opp) / 1000;
269 rcu_read_unlock();
270
Thomas Petazzoni34e5a522014-10-19 11:30:28 +0200271 ret = cpufreq_table_validate_and_show(policy, freq_table);
272 if (ret) {
273 dev_err(cpu_dev, "%s: invalid frequency table: %d\n", __func__,
274 ret);
Viresh Kumar9a004422014-11-27 06:07:52 +0530275 goto out_free_cpufreq_table;
Thomas Petazzoni34e5a522014-10-19 11:30:28 +0200276 }
277
Viresh Kumard15fa862015-07-29 16:23:11 +0530278 /* Support turbo/boost mode */
279 if (policy_has_boost_freq(policy)) {
280 /* This gets disabled by core on driver unregister */
281 ret = cpufreq_enable_boost_support();
282 if (ret)
283 goto out_free_cpufreq_table;
Bartlomiej Zolnierkiewicz21c36d32015-08-07 13:59:16 +0200284 cpufreq_dt_attr[1] = &cpufreq_freq_attr_scaling_boost_freqs;
Viresh Kumard15fa862015-07-29 16:23:11 +0530285 }
286
Viresh Kumar755b8882016-02-09 10:30:45 +0530287 transition_latency = dev_pm_opp_get_max_transition_latency(cpu_dev);
288 if (!transition_latency)
289 transition_latency = CPUFREQ_ETERNAL;
290
Thomas Petazzoni34e5a522014-10-19 11:30:28 +0200291 policy->cpuinfo.transition_latency = transition_latency;
292
Shawn Guo95ceafd2012-09-06 07:09:11 +0000293 return 0;
294
Viresh Kumar9a004422014-11-27 06:07:52 +0530295out_free_cpufreq_table:
Nishanth Menon5d4879c2013-09-19 16:03:50 -0500296 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
Lucas Stach045ee452014-10-24 15:05:55 +0200297out_free_priv:
298 kfree(priv);
Viresh Kumar2f0f6092014-11-25 16:04:21 +0530299out_free_opp:
Viresh Kumar8f8d37b2015-09-04 13:47:24 +0530300 dev_pm_opp_of_cpumask_remove_table(policy->cpus);
Viresh Kumar050794a2016-02-09 10:30:43 +0530301 if (name)
302 dev_pm_opp_put_regulator(cpu_dev);
Viresh Kumard2f31f12014-08-28 11:22:28 +0530303out_put_reg_clk:
304 clk_put(cpu_clk);
305 if (!IS_ERR(cpu_reg))
306 regulator_put(cpu_reg);
307
308 return ret;
309}
310
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530311static int cpufreq_exit(struct cpufreq_policy *policy)
Viresh Kumard2f31f12014-08-28 11:22:28 +0530312{
313 struct private_data *priv = policy->driver_data;
314
Markus Elfring17ad13b2015-02-03 19:21:21 +0100315 cpufreq_cooling_unregister(priv->cdev);
Viresh Kumard2f31f12014-08-28 11:22:28 +0530316 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
Viresh Kumar8f8d37b2015-09-04 13:47:24 +0530317 dev_pm_opp_of_cpumask_remove_table(policy->related_cpus);
Viresh Kumar050794a2016-02-09 10:30:43 +0530318 if (priv->reg_name)
319 dev_pm_opp_put_regulator(priv->cpu_dev);
320
Viresh Kumard2f31f12014-08-28 11:22:28 +0530321 clk_put(policy->clk);
322 if (!IS_ERR(priv->cpu_reg))
323 regulator_put(priv->cpu_reg);
324 kfree(priv);
325
326 return 0;
327}
328
Viresh Kumar9a004422014-11-27 06:07:52 +0530329static void cpufreq_ready(struct cpufreq_policy *policy)
330{
331 struct private_data *priv = policy->driver_data;
332 struct device_node *np = of_node_get(priv->cpu_dev->of_node);
333
334 if (WARN_ON(!np))
335 return;
336
337 /*
338 * For now, just loading the cooling device;
339 * thermal DT code takes care of matching them.
340 */
341 if (of_find_property(np, "#cooling-cells", NULL)) {
Punit Agrawalf8fa8ae2015-11-17 12:06:22 +0000342 u32 power_coefficient = 0;
343
344 of_property_read_u32(np, "dynamic-power-coefficient",
345 &power_coefficient);
346
347 priv->cdev = of_cpufreq_power_cooling_register(np,
348 policy->related_cpus, power_coefficient, NULL);
Viresh Kumar9a004422014-11-27 06:07:52 +0530349 if (IS_ERR(priv->cdev)) {
350 dev_err(priv->cpu_dev,
351 "running cpufreq without cooling device: %ld\n",
352 PTR_ERR(priv->cdev));
353
354 priv->cdev = NULL;
355 }
356 }
357
358 of_node_put(np);
359}
360
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530361static struct cpufreq_driver dt_cpufreq_driver = {
Viresh Kumard2f31f12014-08-28 11:22:28 +0530362 .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
363 .verify = cpufreq_generic_frequency_table_verify,
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530364 .target_index = set_target,
Viresh Kumard2f31f12014-08-28 11:22:28 +0530365 .get = cpufreq_generic_get,
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530366 .init = cpufreq_init,
367 .exit = cpufreq_exit,
Viresh Kumar9a004422014-11-27 06:07:52 +0530368 .ready = cpufreq_ready,
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530369 .name = "cpufreq-dt",
Bartlomiej Zolnierkiewicz21c36d32015-08-07 13:59:16 +0200370 .attr = cpufreq_dt_attr,
Bartlomiej Zolnierkiewicz953ba9f2015-09-08 18:41:03 +0200371 .suspend = cpufreq_generic_suspend,
Viresh Kumard2f31f12014-08-28 11:22:28 +0530372};
373
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530374static int dt_cpufreq_probe(struct platform_device *pdev)
Viresh Kumard2f31f12014-08-28 11:22:28 +0530375{
376 struct device *cpu_dev;
377 struct regulator *cpu_reg;
378 struct clk *cpu_clk;
379 int ret;
380
381 /*
382 * All per-cluster (CPUs sharing clock/voltages) initialization is done
383 * from ->init(). In probe(), we just need to make sure that clk and
384 * regulators are available. Else defer probe and retry.
385 *
386 * FIXME: Is checking this only for CPU0 sufficient ?
387 */
Viresh Kumar95b61052014-08-28 11:22:30 +0530388 ret = allocate_resources(0, &cpu_dev, &cpu_reg, &cpu_clk);
Viresh Kumard2f31f12014-08-28 11:22:28 +0530389 if (ret)
390 return ret;
391
392 clk_put(cpu_clk);
393 if (!IS_ERR(cpu_reg))
394 regulator_put(cpu_reg);
395
Thomas Petazzoni34e5a522014-10-19 11:30:28 +0200396 dt_cpufreq_driver.driver_data = dev_get_platdata(&pdev->dev);
397
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530398 ret = cpufreq_register_driver(&dt_cpufreq_driver);
Viresh Kumard2f31f12014-08-28 11:22:28 +0530399 if (ret)
400 dev_err(cpu_dev, "failed register driver: %d\n", ret);
401
Shawn Guo95ceafd2012-09-06 07:09:11 +0000402 return ret;
403}
Shawn Guo5553f9e2013-01-30 14:27:49 +0000404
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530405static int dt_cpufreq_remove(struct platform_device *pdev)
Shawn Guo5553f9e2013-01-30 14:27:49 +0000406{
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530407 cpufreq_unregister_driver(&dt_cpufreq_driver);
Shawn Guo5553f9e2013-01-30 14:27:49 +0000408 return 0;
409}
410
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530411static struct platform_driver dt_cpufreq_platdrv = {
Shawn Guo5553f9e2013-01-30 14:27:49 +0000412 .driver = {
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530413 .name = "cpufreq-dt",
Shawn Guo5553f9e2013-01-30 14:27:49 +0000414 },
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530415 .probe = dt_cpufreq_probe,
416 .remove = dt_cpufreq_remove,
Shawn Guo5553f9e2013-01-30 14:27:49 +0000417};
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530418module_platform_driver(dt_cpufreq_platdrv);
Shawn Guo95ceafd2012-09-06 07:09:11 +0000419
Felipe Balbi07949bf2015-05-08 14:57:30 -0500420MODULE_ALIAS("platform:cpufreq-dt");
Viresh Kumar748c8762014-08-28 11:22:24 +0530421MODULE_AUTHOR("Viresh Kumar <viresh.kumar@linaro.org>");
Shawn Guo95ceafd2012-09-06 07:09:11 +0000422MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>");
Viresh Kumarbbcf0712014-09-09 19:58:03 +0530423MODULE_DESCRIPTION("Generic cpufreq driver");
Shawn Guo95ceafd2012-09-06 07:09:11 +0000424MODULE_LICENSE("GPL");