hongbo.zhang | aa1acb0 | 2012-11-15 18:56:42 +0800 | [diff] [blame] | 1 | /* |
| 2 | * db8500_cpufreq_cooling.c - DB8500 cpufreq works as cooling device. |
| 3 | * |
| 4 | * Copyright (C) 2012 ST-Ericsson |
| 5 | * Copyright (C) 2012 Linaro Ltd. |
| 6 | * |
| 7 | * Author: Hongbo Zhang <hongbo.zhang@linaro.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | */ |
| 19 | |
| 20 | #include <linux/cpu_cooling.h> |
hongbo.zhang | aa1acb0 | 2012-11-15 18:56:42 +0800 | [diff] [blame] | 21 | #include <linux/err.h> |
| 22 | #include <linux/module.h> |
Sachin Kamat | c076fc4 | 2012-12-19 14:20:59 +0530 | [diff] [blame] | 23 | #include <linux/of.h> |
hongbo.zhang | aa1acb0 | 2012-11-15 18:56:42 +0800 | [diff] [blame] | 24 | #include <linux/platform_device.h> |
| 25 | #include <linux/slab.h> |
| 26 | |
| 27 | static int db8500_cpufreq_cooling_probe(struct platform_device *pdev) |
| 28 | { |
| 29 | struct thermal_cooling_device *cdev; |
hongbo.zhang | aa1acb0 | 2012-11-15 18:56:42 +0800 | [diff] [blame] | 30 | |
Viresh Kumar | b45257b | 2014-12-04 09:41:44 +0530 | [diff] [blame] | 31 | cdev = cpufreq_cooling_register(cpu_present_mask); |
Eduardo Valentin | 70d23b2 | 2013-04-25 14:13:34 +0000 | [diff] [blame] | 32 | if (IS_ERR(cdev)) { |
Eduardo Valentin | 38cbf04 | 2014-12-12 09:58:29 -0400 | [diff] [blame] | 33 | int ret = PTR_ERR(cdev); |
| 34 | |
| 35 | if (ret != -EPROBE_DEFER) |
| 36 | dev_err(&pdev->dev, |
| 37 | "Failed to register cooling device %d\n", |
| 38 | ret); |
| 39 | |
| 40 | return ret; |
hongbo.zhang | aa1acb0 | 2012-11-15 18:56:42 +0800 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | platform_set_drvdata(pdev, cdev); |
| 44 | |
| 45 | dev_info(&pdev->dev, "Cooling device registered: %s\n", cdev->type); |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | static int db8500_cpufreq_cooling_remove(struct platform_device *pdev) |
| 51 | { |
| 52 | struct thermal_cooling_device *cdev = platform_get_drvdata(pdev); |
| 53 | |
| 54 | cpufreq_cooling_unregister(cdev); |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | static int db8500_cpufreq_cooling_suspend(struct platform_device *pdev, |
| 60 | pm_message_t state) |
| 61 | { |
| 62 | return -ENOSYS; |
| 63 | } |
| 64 | |
| 65 | static int db8500_cpufreq_cooling_resume(struct platform_device *pdev) |
| 66 | { |
| 67 | return -ENOSYS; |
| 68 | } |
| 69 | |
| 70 | #ifdef CONFIG_OF |
| 71 | static const struct of_device_id db8500_cpufreq_cooling_match[] = { |
| 72 | { .compatible = "stericsson,db8500-cpufreq-cooling" }, |
| 73 | {}, |
| 74 | }; |
Luis de Bethencourt | 0847e26 | 2015-09-03 13:10:14 +0200 | [diff] [blame] | 75 | MODULE_DEVICE_TABLE(of, db8500_cpufreq_cooling_match); |
hongbo.zhang | aa1acb0 | 2012-11-15 18:56:42 +0800 | [diff] [blame] | 76 | #endif |
| 77 | |
| 78 | static struct platform_driver db8500_cpufreq_cooling_driver = { |
| 79 | .driver = { |
hongbo.zhang | aa1acb0 | 2012-11-15 18:56:42 +0800 | [diff] [blame] | 80 | .name = "db8500-cpufreq-cooling", |
Sachin Kamat | c076fc4 | 2012-12-19 14:20:59 +0530 | [diff] [blame] | 81 | .of_match_table = of_match_ptr(db8500_cpufreq_cooling_match), |
hongbo.zhang | aa1acb0 | 2012-11-15 18:56:42 +0800 | [diff] [blame] | 82 | }, |
| 83 | .probe = db8500_cpufreq_cooling_probe, |
| 84 | .suspend = db8500_cpufreq_cooling_suspend, |
| 85 | .resume = db8500_cpufreq_cooling_resume, |
| 86 | .remove = db8500_cpufreq_cooling_remove, |
| 87 | }; |
| 88 | |
| 89 | static int __init db8500_cpufreq_cooling_init(void) |
| 90 | { |
| 91 | return platform_driver_register(&db8500_cpufreq_cooling_driver); |
| 92 | } |
| 93 | |
| 94 | static void __exit db8500_cpufreq_cooling_exit(void) |
| 95 | { |
| 96 | platform_driver_unregister(&db8500_cpufreq_cooling_driver); |
| 97 | } |
| 98 | |
| 99 | /* Should be later than db8500_cpufreq_register */ |
| 100 | late_initcall(db8500_cpufreq_cooling_init); |
| 101 | module_exit(db8500_cpufreq_cooling_exit); |
| 102 | |
| 103 | MODULE_AUTHOR("Hongbo Zhang <hongbo.zhang@stericsson.com>"); |
| 104 | MODULE_DESCRIPTION("DB8500 cpufreq cooling driver"); |
| 105 | MODULE_LICENSE("GPL"); |