| .. | .. |
|---|
| 12 | 12 | #include <linux/device.h> |
|---|
| 13 | 13 | #include <linux/thermal.h> |
|---|
| 14 | 14 | |
|---|
| 15 | +#include "thermal_netlink.h" |
|---|
| 16 | + |
|---|
| 17 | +/* Default Thermal Governor */ |
|---|
| 18 | +#if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE) |
|---|
| 19 | +#define DEFAULT_THERMAL_GOVERNOR "step_wise" |
|---|
| 20 | +#elif defined(CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE) |
|---|
| 21 | +#define DEFAULT_THERMAL_GOVERNOR "fair_share" |
|---|
| 22 | +#elif defined(CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE) |
|---|
| 23 | +#define DEFAULT_THERMAL_GOVERNOR "user_space" |
|---|
| 24 | +#elif defined(CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR) |
|---|
| 25 | +#define DEFAULT_THERMAL_GOVERNOR "power_allocator" |
|---|
| 26 | +#endif |
|---|
| 27 | + |
|---|
| 15 | 28 | /* Initial state of a cooling device during binding */ |
|---|
| 16 | 29 | #define THERMAL_NO_TARGET -1UL |
|---|
| 30 | + |
|---|
| 31 | +/* Init section thermal table */ |
|---|
| 32 | +extern struct thermal_governor *__governor_thermal_table[]; |
|---|
| 33 | +extern struct thermal_governor *__governor_thermal_table_end[]; |
|---|
| 34 | + |
|---|
| 35 | +#define THERMAL_TABLE_ENTRY(table, name) \ |
|---|
| 36 | + static typeof(name) *__thermal_table_entry_##name \ |
|---|
| 37 | + __used __section("__" #table "_thermal_table") = &name |
|---|
| 38 | + |
|---|
| 39 | +#define THERMAL_GOVERNOR_DECLARE(name) THERMAL_TABLE_ENTRY(governor, name) |
|---|
| 40 | + |
|---|
| 41 | +#define for_each_governor_table(__governor) \ |
|---|
| 42 | + for (__governor = __governor_thermal_table; \ |
|---|
| 43 | + __governor < __governor_thermal_table_end; \ |
|---|
| 44 | + __governor++) |
|---|
| 45 | + |
|---|
| 46 | +int for_each_thermal_zone(int (*cb)(struct thermal_zone_device *, void *), |
|---|
| 47 | + void *); |
|---|
| 48 | + |
|---|
| 49 | +int for_each_thermal_cooling_device(int (*cb)(struct thermal_cooling_device *, |
|---|
| 50 | + void *), void *); |
|---|
| 51 | + |
|---|
| 52 | +int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *), |
|---|
| 53 | + void *thermal_governor); |
|---|
| 54 | + |
|---|
| 55 | +struct thermal_zone_device *thermal_zone_get_by_id(int id); |
|---|
| 56 | + |
|---|
| 57 | +struct thermal_attr { |
|---|
| 58 | + struct device_attribute attr; |
|---|
| 59 | + char name[THERMAL_NAME_LENGTH]; |
|---|
| 60 | +}; |
|---|
| 61 | + |
|---|
| 62 | +static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev) |
|---|
| 63 | +{ |
|---|
| 64 | + return cdev->ops->get_requested_power && cdev->ops->state2power && |
|---|
| 65 | + cdev->ops->power2state; |
|---|
| 66 | +} |
|---|
| 67 | + |
|---|
| 68 | +int power_actor_get_max_power(struct thermal_cooling_device *cdev, |
|---|
| 69 | + u32 *max_power); |
|---|
| 70 | +int power_actor_get_min_power(struct thermal_cooling_device *cdev, |
|---|
| 71 | + u32 *min_power); |
|---|
| 72 | +int power_actor_set_power(struct thermal_cooling_device *cdev, |
|---|
| 73 | + struct thermal_instance *ti, u32 power); |
|---|
| 74 | +/** |
|---|
| 75 | + * struct thermal_trip - representation of a point in temperature domain |
|---|
| 76 | + * @np: pointer to struct device_node that this trip point was created from |
|---|
| 77 | + * @temperature: temperature value in miliCelsius |
|---|
| 78 | + * @hysteresis: relative hysteresis in miliCelsius |
|---|
| 79 | + * @type: trip point type |
|---|
| 80 | + */ |
|---|
| 81 | +struct thermal_trip { |
|---|
| 82 | + struct device_node *np; |
|---|
| 83 | + int temperature; |
|---|
| 84 | + int hysteresis; |
|---|
| 85 | + enum thermal_trip_type type; |
|---|
| 86 | +}; |
|---|
| 87 | + |
|---|
| 88 | +int get_tz_trend(struct thermal_zone_device *tz, int trip); |
|---|
| 89 | + |
|---|
| 90 | +struct thermal_instance * |
|---|
| 91 | +get_thermal_instance(struct thermal_zone_device *tz, |
|---|
| 92 | + struct thermal_cooling_device *cdev, |
|---|
| 93 | + int trip); |
|---|
| 17 | 94 | |
|---|
| 18 | 95 | /* |
|---|
| 19 | 96 | * This structure is used to describe the behavior of |
|---|
| .. | .. |
|---|
| 54 | 131 | int thermal_zone_device_set_policy(struct thermal_zone_device *, char *); |
|---|
| 55 | 132 | int thermal_build_list_of_policies(char *buf); |
|---|
| 56 | 133 | |
|---|
| 134 | +/* Helpers */ |
|---|
| 135 | +void thermal_zone_set_trips(struct thermal_zone_device *tz); |
|---|
| 136 | + |
|---|
| 57 | 137 | /* sysfs I/F */ |
|---|
| 58 | 138 | int thermal_zone_create_device_groups(struct thermal_zone_device *, int); |
|---|
| 59 | 139 | void thermal_zone_destroy_device_groups(struct thermal_zone_device *); |
|---|
| .. | .. |
|---|
| 61 | 141 | void thermal_cooling_device_destroy_sysfs(struct thermal_cooling_device *cdev); |
|---|
| 62 | 142 | /* used only at binding time */ |
|---|
| 63 | 143 | ssize_t trip_point_show(struct device *, struct device_attribute *, char *); |
|---|
| 64 | | -ssize_t trip_point_store(struct device *, struct device_attribute *, |
|---|
| 65 | | - const char *, size_t); |
|---|
| 66 | 144 | ssize_t weight_show(struct device *, struct device_attribute *, char *); |
|---|
| 67 | 145 | ssize_t weight_store(struct device *, struct device_attribute *, const char *, |
|---|
| 68 | 146 | size_t); |
|---|
| .. | .. |
|---|
| 76 | 154 | unsigned long new_state) {} |
|---|
| 77 | 155 | #endif /* CONFIG_THERMAL_STATISTICS */ |
|---|
| 78 | 156 | |
|---|
| 79 | | -#ifdef CONFIG_THERMAL_GOV_STEP_WISE |
|---|
| 80 | | -int thermal_gov_step_wise_register(void); |
|---|
| 81 | | -void thermal_gov_step_wise_unregister(void); |
|---|
| 82 | | -#else |
|---|
| 83 | | -static inline int thermal_gov_step_wise_register(void) { return 0; } |
|---|
| 84 | | -static inline void thermal_gov_step_wise_unregister(void) {} |
|---|
| 85 | | -#endif /* CONFIG_THERMAL_GOV_STEP_WISE */ |
|---|
| 86 | | - |
|---|
| 87 | | -#ifdef CONFIG_THERMAL_GOV_FAIR_SHARE |
|---|
| 88 | | -int thermal_gov_fair_share_register(void); |
|---|
| 89 | | -void thermal_gov_fair_share_unregister(void); |
|---|
| 90 | | -#else |
|---|
| 91 | | -static inline int thermal_gov_fair_share_register(void) { return 0; } |
|---|
| 92 | | -static inline void thermal_gov_fair_share_unregister(void) {} |
|---|
| 93 | | -#endif /* CONFIG_THERMAL_GOV_FAIR_SHARE */ |
|---|
| 94 | | - |
|---|
| 95 | | -#ifdef CONFIG_THERMAL_GOV_BANG_BANG |
|---|
| 96 | | -int thermal_gov_bang_bang_register(void); |
|---|
| 97 | | -void thermal_gov_bang_bang_unregister(void); |
|---|
| 98 | | -#else |
|---|
| 99 | | -static inline int thermal_gov_bang_bang_register(void) { return 0; } |
|---|
| 100 | | -static inline void thermal_gov_bang_bang_unregister(void) {} |
|---|
| 101 | | -#endif /* CONFIG_THERMAL_GOV_BANG_BANG */ |
|---|
| 102 | | - |
|---|
| 103 | | -#ifdef CONFIG_THERMAL_GOV_USER_SPACE |
|---|
| 104 | | -int thermal_gov_user_space_register(void); |
|---|
| 105 | | -void thermal_gov_user_space_unregister(void); |
|---|
| 106 | | -#else |
|---|
| 107 | | -static inline int thermal_gov_user_space_register(void) { return 0; } |
|---|
| 108 | | -static inline void thermal_gov_user_space_unregister(void) {} |
|---|
| 109 | | -#endif /* CONFIG_THERMAL_GOV_USER_SPACE */ |
|---|
| 110 | | - |
|---|
| 111 | | -#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR |
|---|
| 112 | | -int thermal_gov_power_allocator_register(void); |
|---|
| 113 | | -void thermal_gov_power_allocator_unregister(void); |
|---|
| 114 | | -#else |
|---|
| 115 | | -static inline int thermal_gov_power_allocator_register(void) { return 0; } |
|---|
| 116 | | -static inline void thermal_gov_power_allocator_unregister(void) {} |
|---|
| 117 | | -#endif /* CONFIG_THERMAL_GOV_POWER_ALLOCATOR */ |
|---|
| 118 | | - |
|---|
| 119 | 157 | /* device tree support */ |
|---|
| 120 | 158 | #ifdef CONFIG_THERMAL_OF |
|---|
| 121 | 159 | int of_parse_thermal_zones(void); |
|---|
| 122 | | -void of_thermal_destroy_zones(void); |
|---|
| 123 | 160 | int of_thermal_get_ntrips(struct thermal_zone_device *); |
|---|
| 124 | 161 | bool of_thermal_is_trip_valid(struct thermal_zone_device *, int); |
|---|
| 125 | 162 | const struct thermal_trip * |
|---|
| 126 | 163 | of_thermal_get_trip_points(struct thermal_zone_device *); |
|---|
| 127 | | -void of_thermal_handle_trip(struct thermal_zone_device *tz); |
|---|
| 128 | | -void of_thermal_handle_trip_temp(struct thermal_zone_device *tz, |
|---|
| 129 | | - int trip_temp); |
|---|
| 130 | 164 | #else |
|---|
| 131 | 165 | static inline int of_parse_thermal_zones(void) { return 0; } |
|---|
| 132 | | -static inline void of_thermal_destroy_zones(void) { } |
|---|
| 133 | 166 | static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz) |
|---|
| 134 | 167 | { |
|---|
| 135 | 168 | return 0; |
|---|
| .. | .. |
|---|
| 144 | 177 | { |
|---|
| 145 | 178 | return NULL; |
|---|
| 146 | 179 | } |
|---|
| 147 | | -static inline |
|---|
| 148 | | -void of_thermal_handle_trip(struct thermal_zone_device *tz) |
|---|
| 149 | | -{ } |
|---|
| 150 | | -static inline |
|---|
| 151 | | -void of_thermal_handle_trip_temp(struct thermal_zone_device *tz, |
|---|
| 152 | | - int trip_temp) |
|---|
| 153 | | -{ } |
|---|
| 154 | 180 | #endif |
|---|
| 155 | 181 | |
|---|
| 156 | 182 | #endif /* __THERMAL_CORE_H__ */ |
|---|