171350db4SDurgadoss R /*
271350db4SDurgadoss R  *  thermal_core.h
371350db4SDurgadoss R  *
471350db4SDurgadoss R  *  Copyright (C) 2012  Intel Corp
571350db4SDurgadoss R  *  Author: Durgadoss R <durgadoss.r@intel.com>
671350db4SDurgadoss R  *
771350db4SDurgadoss R  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
871350db4SDurgadoss R  *  This program is free software; you can redistribute it and/or modify
971350db4SDurgadoss R  *  it under the terms of the GNU General Public License as published by
1071350db4SDurgadoss R  *  the Free Software Foundation; version 2 of the License.
1171350db4SDurgadoss R  *
1271350db4SDurgadoss R  *  This program is distributed in the hope that it will be useful, but
1371350db4SDurgadoss R  *  WITHOUT ANY WARRANTY; without even the implied warranty of
1471350db4SDurgadoss R  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1571350db4SDurgadoss R  *  General Public License for more details.
1671350db4SDurgadoss R  *
1771350db4SDurgadoss R  *  You should have received a copy of the GNU General Public License along
1871350db4SDurgadoss R  *  with this program; if not, write to the Free Software Foundation, Inc.,
1971350db4SDurgadoss R  *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
2071350db4SDurgadoss R  *
2171350db4SDurgadoss R  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2271350db4SDurgadoss R  */
2371350db4SDurgadoss R 
2471350db4SDurgadoss R #ifndef __THERMAL_CORE_H__
2571350db4SDurgadoss R #define __THERMAL_CORE_H__
2671350db4SDurgadoss R 
2771350db4SDurgadoss R #include <linux/device.h>
2871350db4SDurgadoss R #include <linux/thermal.h>
2971350db4SDurgadoss R 
3071350db4SDurgadoss R /* Initial state of a cooling device during binding */
3171350db4SDurgadoss R #define THERMAL_NO_TARGET -1UL
3271350db4SDurgadoss R 
3371350db4SDurgadoss R /*
3471350db4SDurgadoss R  * This structure is used to describe the behavior of
3571350db4SDurgadoss R  * a certain cooling device on a certain trip point
3671350db4SDurgadoss R  * in a certain thermal zone
3771350db4SDurgadoss R  */
3871350db4SDurgadoss R struct thermal_instance {
3971350db4SDurgadoss R 	int id;
4071350db4SDurgadoss R 	char name[THERMAL_NAME_LENGTH];
4171350db4SDurgadoss R 	struct thermal_zone_device *tz;
4271350db4SDurgadoss R 	struct thermal_cooling_device *cdev;
4371350db4SDurgadoss R 	int trip;
4471350db4SDurgadoss R 	unsigned long upper;	/* Highest cooling state for this trip point */
4571350db4SDurgadoss R 	unsigned long lower;	/* Lowest cooling state for this trip point */
4671350db4SDurgadoss R 	unsigned long target;	/* expected cooling state */
4771350db4SDurgadoss R 	char attr_name[THERMAL_NAME_LENGTH];
4871350db4SDurgadoss R 	struct device_attribute attr;
4971350db4SDurgadoss R 	struct list_head tz_node; /* node in tz->thermal_instances */
5071350db4SDurgadoss R 	struct list_head cdev_node; /* node in cdev->thermal_instances */
5171350db4SDurgadoss R };
5271350db4SDurgadoss R 
5380a26a5cSZhang Rui int thermal_register_governor(struct thermal_governor *);
5480a26a5cSZhang Rui void thermal_unregister_governor(struct thermal_governor *);
5580a26a5cSZhang Rui 
5680a26a5cSZhang Rui #ifdef CONFIG_THERMAL_GOV_STEP_WISE
5780a26a5cSZhang Rui int thermal_gov_step_wise_register(void);
5880a26a5cSZhang Rui void thermal_gov_step_wise_unregister(void);
5980a26a5cSZhang Rui #else
6080a26a5cSZhang Rui static inline int thermal_gov_step_wise_register(void) { return 0; }
6180a26a5cSZhang Rui static inline void thermal_gov_step_wise_unregister(void) {}
6280a26a5cSZhang Rui #endif /* CONFIG_THERMAL_GOV_STEP_WISE */
6380a26a5cSZhang Rui 
6480a26a5cSZhang Rui #ifdef CONFIG_THERMAL_GOV_FAIR_SHARE
6580a26a5cSZhang Rui int thermal_gov_fair_share_register(void);
6680a26a5cSZhang Rui void thermal_gov_fair_share_unregister(void);
6780a26a5cSZhang Rui #else
6880a26a5cSZhang Rui static inline int thermal_gov_fair_share_register(void) { return 0; }
6980a26a5cSZhang Rui static inline void thermal_gov_fair_share_unregister(void) {}
7080a26a5cSZhang Rui #endif /* CONFIG_THERMAL_GOV_FAIR_SHARE */
7180a26a5cSZhang Rui 
7280a26a5cSZhang Rui #ifdef CONFIG_THERMAL_GOV_USER_SPACE
7380a26a5cSZhang Rui int thermal_gov_user_space_register(void);
7480a26a5cSZhang Rui void thermal_gov_user_space_unregister(void);
7580a26a5cSZhang Rui #else
7680a26a5cSZhang Rui static inline int thermal_gov_user_space_register(void) { return 0; }
7780a26a5cSZhang Rui static inline void thermal_gov_user_space_unregister(void) {}
7880a26a5cSZhang Rui #endif /* CONFIG_THERMAL_GOV_USER_SPACE */
7980a26a5cSZhang Rui 
804e5e4705SEduardo Valentin /* device tree support */
814e5e4705SEduardo Valentin #ifdef CONFIG_THERMAL_OF
824e5e4705SEduardo Valentin int of_parse_thermal_zones(void);
834e5e4705SEduardo Valentin void of_thermal_destroy_zones(void);
844e5e4705SEduardo Valentin #else
854e5e4705SEduardo Valentin static inline int of_parse_thermal_zones(void) { return 0; }
864e5e4705SEduardo Valentin static inline void of_thermal_destroy_zones(void) { }
874e5e4705SEduardo Valentin #endif
884e5e4705SEduardo Valentin 
8971350db4SDurgadoss R #endif /* __THERMAL_CORE_H__ */
90