diff options
Diffstat (limited to 'drivers/devfreq/exynos/exynos5_bus.c')
-rw-r--r-- | drivers/devfreq/exynos/exynos5_bus.c | 57 |
1 files changed, 22 insertions, 35 deletions
diff --git a/drivers/devfreq/exynos/exynos5_bus.c b/drivers/devfreq/exynos/exynos5_bus.c index 574b16b59be5..a60da3c1c48e 100644 --- a/drivers/devfreq/exynos/exynos5_bus.c +++ b/drivers/devfreq/exynos/exynos5_bus.c | |||
@@ -15,10 +15,9 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/devfreq.h> | 16 | #include <linux/devfreq.h> |
17 | #include <linux/io.h> | 17 | #include <linux/io.h> |
18 | #include <linux/opp.h> | 18 | #include <linux/pm_opp.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/suspend.h> | 20 | #include <linux/suspend.h> |
21 | #include <linux/opp.h> | ||
22 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
23 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
24 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
@@ -132,7 +131,7 @@ static int exynos5_busfreq_int_target(struct device *dev, unsigned long *_freq, | |||
132 | struct platform_device *pdev = container_of(dev, struct platform_device, | 131 | struct platform_device *pdev = container_of(dev, struct platform_device, |
133 | dev); | 132 | dev); |
134 | struct busfreq_data_int *data = platform_get_drvdata(pdev); | 133 | struct busfreq_data_int *data = platform_get_drvdata(pdev); |
135 | struct opp *opp; | 134 | struct dev_pm_opp *opp; |
136 | unsigned long old_freq, freq; | 135 | unsigned long old_freq, freq; |
137 | unsigned long volt; | 136 | unsigned long volt; |
138 | 137 | ||
@@ -144,8 +143,8 @@ static int exynos5_busfreq_int_target(struct device *dev, unsigned long *_freq, | |||
144 | return PTR_ERR(opp); | 143 | return PTR_ERR(opp); |
145 | } | 144 | } |
146 | 145 | ||
147 | freq = opp_get_freq(opp); | 146 | freq = dev_pm_opp_get_freq(opp); |
148 | volt = opp_get_voltage(opp); | 147 | volt = dev_pm_opp_get_voltage(opp); |
149 | rcu_read_unlock(); | 148 | rcu_read_unlock(); |
150 | 149 | ||
151 | old_freq = data->curr_freq; | 150 | old_freq = data->curr_freq; |
@@ -246,7 +245,7 @@ static int exynos5250_init_int_tables(struct busfreq_data_int *data) | |||
246 | int i, err = 0; | 245 | int i, err = 0; |
247 | 246 | ||
248 | for (i = LV_0; i < _LV_END; i++) { | 247 | for (i = LV_0; i < _LV_END; i++) { |
249 | err = opp_add(data->dev, exynos5_int_opp_table[i].clk, | 248 | err = dev_pm_opp_add(data->dev, exynos5_int_opp_table[i].clk, |
250 | exynos5_int_opp_table[i].volt); | 249 | exynos5_int_opp_table[i].volt); |
251 | if (err) { | 250 | if (err) { |
252 | dev_err(data->dev, "Cannot add opp entries.\n"); | 251 | dev_err(data->dev, "Cannot add opp entries.\n"); |
@@ -262,7 +261,7 @@ static int exynos5_busfreq_int_pm_notifier_event(struct notifier_block *this, | |||
262 | { | 261 | { |
263 | struct busfreq_data_int *data = container_of(this, | 262 | struct busfreq_data_int *data = container_of(this, |
264 | struct busfreq_data_int, pm_notifier); | 263 | struct busfreq_data_int, pm_notifier); |
265 | struct opp *opp; | 264 | struct dev_pm_opp *opp; |
266 | unsigned long maxfreq = ULONG_MAX; | 265 | unsigned long maxfreq = ULONG_MAX; |
267 | unsigned long freq; | 266 | unsigned long freq; |
268 | unsigned long volt; | 267 | unsigned long volt; |
@@ -276,14 +275,14 @@ static int exynos5_busfreq_int_pm_notifier_event(struct notifier_block *this, | |||
276 | data->disabled = true; | 275 | data->disabled = true; |
277 | 276 | ||
278 | rcu_read_lock(); | 277 | rcu_read_lock(); |
279 | opp = opp_find_freq_floor(data->dev, &maxfreq); | 278 | opp = dev_pm_opp_find_freq_floor(data->dev, &maxfreq); |
280 | if (IS_ERR(opp)) { | 279 | if (IS_ERR(opp)) { |
281 | rcu_read_unlock(); | 280 | rcu_read_unlock(); |
282 | err = PTR_ERR(opp); | 281 | err = PTR_ERR(opp); |
283 | goto unlock; | 282 | goto unlock; |
284 | } | 283 | } |
285 | freq = opp_get_freq(opp); | 284 | freq = dev_pm_opp_get_freq(opp); |
286 | volt = opp_get_voltage(opp); | 285 | volt = dev_pm_opp_get_voltage(opp); |
287 | rcu_read_unlock(); | 286 | rcu_read_unlock(); |
288 | 287 | ||
289 | err = exynos5_int_setvolt(data, volt); | 288 | err = exynos5_int_setvolt(data, volt); |
@@ -316,7 +315,7 @@ unlock: | |||
316 | static int exynos5_busfreq_int_probe(struct platform_device *pdev) | 315 | static int exynos5_busfreq_int_probe(struct platform_device *pdev) |
317 | { | 316 | { |
318 | struct busfreq_data_int *data; | 317 | struct busfreq_data_int *data; |
319 | struct opp *opp; | 318 | struct dev_pm_opp *opp; |
320 | struct device *dev = &pdev->dev; | 319 | struct device *dev = &pdev->dev; |
321 | struct device_node *np; | 320 | struct device_node *np; |
322 | unsigned long initial_freq; | 321 | unsigned long initial_freq; |
@@ -351,46 +350,43 @@ static int exynos5_busfreq_int_probe(struct platform_device *pdev) | |||
351 | 350 | ||
352 | err = exynos5250_init_int_tables(data); | 351 | err = exynos5250_init_int_tables(data); |
353 | if (err) | 352 | if (err) |
354 | goto err_regulator; | 353 | return err; |
355 | 354 | ||
356 | data->vdd_int = regulator_get(dev, "vdd_int"); | 355 | data->vdd_int = devm_regulator_get(dev, "vdd_int"); |
357 | if (IS_ERR(data->vdd_int)) { | 356 | if (IS_ERR(data->vdd_int)) { |
358 | dev_err(dev, "Cannot get the regulator \"vdd_int\"\n"); | 357 | dev_err(dev, "Cannot get the regulator \"vdd_int\"\n"); |
359 | err = PTR_ERR(data->vdd_int); | 358 | return PTR_ERR(data->vdd_int); |
360 | goto err_regulator; | ||
361 | } | 359 | } |
362 | 360 | ||
363 | data->int_clk = clk_get(dev, "int_clk"); | 361 | data->int_clk = devm_clk_get(dev, "int_clk"); |
364 | if (IS_ERR(data->int_clk)) { | 362 | if (IS_ERR(data->int_clk)) { |
365 | dev_err(dev, "Cannot get clock \"int_clk\"\n"); | 363 | dev_err(dev, "Cannot get clock \"int_clk\"\n"); |
366 | err = PTR_ERR(data->int_clk); | 364 | return PTR_ERR(data->int_clk); |
367 | goto err_clock; | ||
368 | } | 365 | } |
369 | 366 | ||
370 | rcu_read_lock(); | 367 | rcu_read_lock(); |
371 | opp = opp_find_freq_floor(dev, | 368 | opp = dev_pm_opp_find_freq_floor(dev, |
372 | &exynos5_devfreq_int_profile.initial_freq); | 369 | &exynos5_devfreq_int_profile.initial_freq); |
373 | if (IS_ERR(opp)) { | 370 | if (IS_ERR(opp)) { |
374 | rcu_read_unlock(); | 371 | rcu_read_unlock(); |
375 | dev_err(dev, "Invalid initial frequency %lu kHz.\n", | 372 | dev_err(dev, "Invalid initial frequency %lu kHz.\n", |
376 | exynos5_devfreq_int_profile.initial_freq); | 373 | exynos5_devfreq_int_profile.initial_freq); |
377 | err = PTR_ERR(opp); | 374 | return PTR_ERR(opp); |
378 | goto err_opp_add; | ||
379 | } | 375 | } |
380 | initial_freq = opp_get_freq(opp); | 376 | initial_freq = dev_pm_opp_get_freq(opp); |
381 | initial_volt = opp_get_voltage(opp); | 377 | initial_volt = dev_pm_opp_get_voltage(opp); |
382 | rcu_read_unlock(); | 378 | rcu_read_unlock(); |
383 | data->curr_freq = initial_freq; | 379 | data->curr_freq = initial_freq; |
384 | 380 | ||
385 | err = clk_set_rate(data->int_clk, initial_freq * 1000); | 381 | err = clk_set_rate(data->int_clk, initial_freq * 1000); |
386 | if (err) { | 382 | if (err) { |
387 | dev_err(dev, "Failed to set initial frequency\n"); | 383 | dev_err(dev, "Failed to set initial frequency\n"); |
388 | goto err_opp_add; | 384 | return err; |
389 | } | 385 | } |
390 | 386 | ||
391 | err = exynos5_int_setvolt(data, initial_volt); | 387 | err = exynos5_int_setvolt(data, initial_volt); |
392 | if (err) | 388 | if (err) |
393 | goto err_opp_add; | 389 | return err; |
394 | 390 | ||
395 | platform_set_drvdata(pdev, data); | 391 | platform_set_drvdata(pdev, data); |
396 | 392 | ||
@@ -419,12 +415,6 @@ static int exynos5_busfreq_int_probe(struct platform_device *pdev) | |||
419 | 415 | ||
420 | err_devfreq_add: | 416 | err_devfreq_add: |
421 | devfreq_remove_device(data->devfreq); | 417 | devfreq_remove_device(data->devfreq); |
422 | platform_set_drvdata(pdev, NULL); | ||
423 | err_opp_add: | ||
424 | clk_put(data->int_clk); | ||
425 | err_clock: | ||
426 | regulator_put(data->vdd_int); | ||
427 | err_regulator: | ||
428 | return err; | 418 | return err; |
429 | } | 419 | } |
430 | 420 | ||
@@ -435,9 +425,6 @@ static int exynos5_busfreq_int_remove(struct platform_device *pdev) | |||
435 | pm_qos_remove_request(&data->int_req); | 425 | pm_qos_remove_request(&data->int_req); |
436 | unregister_pm_notifier(&data->pm_notifier); | 426 | unregister_pm_notifier(&data->pm_notifier); |
437 | devfreq_remove_device(data->devfreq); | 427 | devfreq_remove_device(data->devfreq); |
438 | regulator_put(data->vdd_int); | ||
439 | clk_put(data->int_clk); | ||
440 | platform_set_drvdata(pdev, NULL); | ||
441 | 428 | ||
442 | return 0; | 429 | return 0; |
443 | } | 430 | } |
@@ -479,7 +466,7 @@ static int __init exynos5_busfreq_int_init(void) | |||
479 | 466 | ||
480 | exynos5_devfreq_pdev = | 467 | exynos5_devfreq_pdev = |
481 | platform_device_register_simple("exynos5-bus-int", -1, NULL, 0); | 468 | platform_device_register_simple("exynos5-bus-int", -1, NULL, 0); |
482 | if (IS_ERR_OR_NULL(exynos5_devfreq_pdev)) { | 469 | if (IS_ERR(exynos5_devfreq_pdev)) { |
483 | ret = PTR_ERR(exynos5_devfreq_pdev); | 470 | ret = PTR_ERR(exynos5_devfreq_pdev); |
484 | goto out1; | 471 | goto out1; |
485 | } | 472 | } |