On 10 Nov 24, Yong Shen wrote:
> Hi there,
> 
> In power management group, we have a working item of exposing thermal
> information to user space through sysfs. However, so far, the thermal
> sensor drivers under 'drivers/hwmon' expose their information in
> various nodes under sysfs, which makes information collection
> difficult.
> Intel's thermal framework is located under 'drivers/thermal', but all
> the thermal drivers under hwmon don't make use of it due to some
> reason (part of the reason for this situation may be that intel's
> thermal framework is comparatively new therefore when those sensor
> drivers were implemented they did not have a framework to register
> themselves.)

It is not that new (after checking)

$ git describe 203d3d4aa482339b4816f131f713e1b8ee37f6dd
v2.6.24-6482-g203d3d4

> We like to find out a simple and unified way to expose thermal related
> information, intel's thermal interface could be a choice. Using
> thermal framework is straightforward, below is a sample driver for
> this purpose. Thus all the information goes to /sys/class/thermal,
> like temperature, mode...
> 
> ...
> #include <linux/module.h>
> #include <linux/device.h>
> #include <linux/thermal.h>
> #include <linux/hwmon.h>
> static int thermal_get_temp(struct thermal_zone_device *thermal,
>                                             unsigned long *temp)
> {
>         *temp = xxx;
>         return 0;
> }
> static struct device *hwmon;
> static struct thermal_zone_device *thermal;
> static struct thermal_zone_device_ops ops = {
>         .get_temp = thermal_get_temp,
> };
> static int __init sensor_init(void)
> {
> ...
>         thermal = thermal_zone_device_register("sample", 0, 0,
>                         &ops, 0, 0, 0, 0);
> }
> static void __exit sensor_cleanup(void)
> {
> ...
> }
> module_init(sensor_init);
> module_exit(sensor_cleanup);
> 
> Are there any better ideas about this? Your comments are highly appreciated.

What is important is not just a user-space interface (in /sys), but also a
in-kernel interface that drivers can call.

I had a brief look at the thermal API. There are two types of devices:
 * Thermal Zone (a sensor)
 * Cooling device (fan, processor, perhaps even a policy manager?)

You can bind cooling devices with thermal zones.

Can the thermal_zone_bind_cooling_device() function be used by external
drivers for registering call-backs for thermal trip conditions?

/Amit

_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to