diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-01-23 23:10:05 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-01-23 23:10:05 +0000 |
commit | 5a84f323d2781d6dd6fa312f630715319c743cb8 (patch) | |
tree | 43b3f096db903f4723a12d51f35202d82851320a /sys/dev/ofw | |
parent | bd40c7e337a18bf9d463aefa7cf13a50a67e2077 (diff) |
Make thermal framework support in sxitemp(4) interrupt driven such that
it works with future Linux device trees.
ok patrick@
Diffstat (limited to 'sys/dev/ofw')
-rw-r--r-- | sys/dev/ofw/ofw_thermal.c | 20 | ||||
-rw-r--r-- | sys/dev/ofw/ofw_thermal.h | 3 |
2 files changed, 21 insertions, 2 deletions
diff --git a/sys/dev/ofw/ofw_thermal.c b/sys/dev/ofw/ofw_thermal.c index 89b5d0e4d4a..c4f88392d59 100644 --- a/sys/dev/ofw/ofw_thermal.c +++ b/sys/dev/ofw/ofw_thermal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofw_thermal.c,v 1.5 2019/12/03 09:17:20 patrick Exp $ */ +/* $OpenBSD: ofw_thermal.c,v 1.6 2020/01/23 23:10:04 kettenis Exp $ */ /* * Copyright (c) 2019 Mark Kettenis * @@ -69,6 +69,7 @@ struct thermal_zone { uint32_t *tz_sensors; uint32_t tz_polling_delay; uint32_t tz_polling_delay_passive; + LIST_ENTRY(thermal_zone) tz_list; struct trippoint *tz_trips; int tz_ntrips; @@ -83,6 +84,9 @@ struct thermal_zone { int32_t tz_temperature; }; +LIST_HEAD(, thermal_zone) thermal_zones = + LIST_HEAD_INITIALIZER(thermal_zones); + void thermal_sensor_register(struct thermal_sensor *ts) { @@ -95,6 +99,19 @@ thermal_sensor_register(struct thermal_sensor *ts) } void +thermal_sensor_update(struct thermal_sensor *ts, uint32_t *cells) +{ + struct thermal_zone *tz; + + LIST_FOREACH(tz, &thermal_zones, tz_list) { + if (tz->tz_sensors[0] == ts->ts_phandle && + memcmp(&tz->tz_sensors[1], cells, + ts->ts_cells * sizeof(uint32_t)) == 0) + task_add(tztq, &tz->tz_poll_task); + } +} + +void cooling_device_register(struct cooling_device *cd) { cd->cd_cells = OF_getpropint(cd->cd_node, "#cooling-cells", 0); @@ -447,6 +464,7 @@ thermal_zone_init(int node) /* Start polling if we are requested to do so. */ if (tz->tz_polling_delay > 0) timeout_add_msec(&tz->tz_poll_to, tz->tz_polling_delay); + LIST_INSERT_HEAD(&thermal_zones, tz, tz_list); } void diff --git a/sys/dev/ofw/ofw_thermal.h b/sys/dev/ofw/ofw_thermal.h index dc7769c4978..21c63041bd7 100644 --- a/sys/dev/ofw/ofw_thermal.h +++ b/sys/dev/ofw/ofw_thermal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ofw_thermal.h,v 1.1 2019/07/02 20:12:11 kettenis Exp $ */ +/* $OpenBSD: ofw_thermal.h,v 1.2 2020/01/23 23:10:04 kettenis Exp $ */ /* * Copyright (c) 2019 Mark Kettenis * @@ -46,6 +46,7 @@ struct cooling_device { #define THERMAL_NO_LIMIT 0xffffffffU void thermal_sensor_register(struct thermal_sensor *); +void thermal_sensor_update(struct thermal_sensor *, uint32_t *); void cooling_device_register(struct cooling_device *); void thermal_init(void); |