Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.8 157 lines 5.7 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * thermal_core.h 4 * 5 * Copyright (C) 2012 Intel Corp 6 * Author: Durgadoss R <durgadoss.r@intel.com> 7 */ 8 9#ifndef __THERMAL_CORE_H__ 10#define __THERMAL_CORE_H__ 11 12#include <linux/device.h> 13#include <linux/thermal.h> 14 15#include "thermal_netlink.h" 16#include "thermal_debugfs.h" 17 18/* Default Thermal Governor */ 19#if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE) 20#define DEFAULT_THERMAL_GOVERNOR "step_wise" 21#elif defined(CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE) 22#define DEFAULT_THERMAL_GOVERNOR "fair_share" 23#elif defined(CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE) 24#define DEFAULT_THERMAL_GOVERNOR "user_space" 25#elif defined(CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR) 26#define DEFAULT_THERMAL_GOVERNOR "power_allocator" 27#elif defined(CONFIG_THERMAL_DEFAULT_GOV_BANG_BANG) 28#define DEFAULT_THERMAL_GOVERNOR "bang_bang" 29#endif 30 31/* Initial state of a cooling device during binding */ 32#define THERMAL_NO_TARGET -1UL 33 34/* Init section thermal table */ 35extern struct thermal_governor *__governor_thermal_table[]; 36extern struct thermal_governor *__governor_thermal_table_end[]; 37 38#define THERMAL_TABLE_ENTRY(table, name) \ 39 static typeof(name) *__thermal_table_entry_##name \ 40 __used __section("__" #table "_thermal_table") = &name 41 42#define THERMAL_GOVERNOR_DECLARE(name) THERMAL_TABLE_ENTRY(governor, name) 43 44#define for_each_governor_table(__governor) \ 45 for (__governor = __governor_thermal_table; \ 46 __governor < __governor_thermal_table_end; \ 47 __governor++) 48 49int for_each_thermal_zone(int (*cb)(struct thermal_zone_device *, void *), 50 void *); 51 52int for_each_thermal_cooling_device(int (*cb)(struct thermal_cooling_device *, 53 void *), void *); 54 55int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *), 56 void *thermal_governor); 57 58struct thermal_zone_device *thermal_zone_get_by_id(int id); 59 60struct thermal_attr { 61 struct device_attribute attr; 62 char name[THERMAL_NAME_LENGTH]; 63}; 64 65static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev) 66{ 67 return cdev->ops->get_requested_power && cdev->ops->state2power && 68 cdev->ops->power2state; 69} 70 71void thermal_cdev_update(struct thermal_cooling_device *); 72void __thermal_cdev_update(struct thermal_cooling_device *cdev); 73 74int get_tz_trend(struct thermal_zone_device *tz, const struct thermal_trip *trip); 75 76struct thermal_instance * 77get_thermal_instance(struct thermal_zone_device *tz, 78 struct thermal_cooling_device *cdev, 79 int trip); 80 81/* 82 * This structure is used to describe the behavior of 83 * a certain cooling device on a certain trip point 84 * in a certain thermal zone 85 */ 86struct thermal_instance { 87 int id; 88 char name[THERMAL_NAME_LENGTH]; 89 struct thermal_zone_device *tz; 90 struct thermal_cooling_device *cdev; 91 const struct thermal_trip *trip; 92 bool initialized; 93 unsigned long upper; /* Highest cooling state for this trip point */ 94 unsigned long lower; /* Lowest cooling state for this trip point */ 95 unsigned long target; /* expected cooling state */ 96 char attr_name[THERMAL_NAME_LENGTH]; 97 struct device_attribute attr; 98 char weight_attr_name[THERMAL_NAME_LENGTH]; 99 struct device_attribute weight_attr; 100 struct list_head tz_node; /* node in tz->thermal_instances */ 101 struct list_head cdev_node; /* node in cdev->thermal_instances */ 102 unsigned int weight; /* The weight of the cooling device */ 103 bool upper_no_limit; 104}; 105 106#define to_thermal_zone(_dev) \ 107 container_of(_dev, struct thermal_zone_device, device) 108 109#define to_cooling_device(_dev) \ 110 container_of(_dev, struct thermal_cooling_device, device) 111 112int thermal_register_governor(struct thermal_governor *); 113void thermal_unregister_governor(struct thermal_governor *); 114int thermal_zone_device_set_policy(struct thermal_zone_device *, char *); 115int thermal_build_list_of_policies(char *buf); 116void __thermal_zone_device_update(struct thermal_zone_device *tz, 117 enum thermal_notify_event event); 118void thermal_zone_device_critical_reboot(struct thermal_zone_device *tz); 119void thermal_governor_update_tz(struct thermal_zone_device *tz, 120 enum thermal_notify_event reason); 121 122/* Helpers */ 123#define for_each_trip(__tz, __trip) \ 124 for (__trip = __tz->trips; __trip - __tz->trips < __tz->num_trips; __trip++) 125 126void __thermal_zone_set_trips(struct thermal_zone_device *tz); 127int thermal_zone_trip_id(const struct thermal_zone_device *tz, 128 const struct thermal_trip *trip); 129void thermal_zone_trip_updated(struct thermal_zone_device *tz, 130 const struct thermal_trip *trip); 131int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp); 132 133/* sysfs I/F */ 134int thermal_zone_create_device_groups(struct thermal_zone_device *, int); 135void thermal_zone_destroy_device_groups(struct thermal_zone_device *); 136void thermal_cooling_device_setup_sysfs(struct thermal_cooling_device *); 137void thermal_cooling_device_destroy_sysfs(struct thermal_cooling_device *cdev); 138void thermal_cooling_device_stats_reinit(struct thermal_cooling_device *cdev); 139/* used only at binding time */ 140ssize_t trip_point_show(struct device *, struct device_attribute *, char *); 141ssize_t weight_show(struct device *, struct device_attribute *, char *); 142ssize_t weight_store(struct device *, struct device_attribute *, const char *, 143 size_t); 144 145#ifdef CONFIG_THERMAL_STATISTICS 146void thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev, 147 unsigned long new_state); 148#else 149static inline void 150thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev, 151 unsigned long new_state) {} 152#endif /* CONFIG_THERMAL_STATISTICS */ 153 154/* device tree support */ 155int thermal_zone_device_is_enabled(struct thermal_zone_device *tz); 156 157#endif /* __THERMAL_CORE_H__ */