diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 5bea526773a..d7c57442da9 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -815,6 +815,9 @@ void thermal_zone_device_update(FAR struct thermal_zone_device_s *zdev) { int trip_high = INT_MAX; int trip_low = INT_MIN; + FAR struct thermal_instance_s *pos; + unsigned int current; + clock_t delay; int trip; int temp; int ret; @@ -893,8 +896,27 @@ void thermal_zone_device_update(FAR struct thermal_zone_device_s *zdev) } } + /* Update worker invoke delay */ + + delay = zdev->params->passive_delay; + list_for_every_entry(&zdev->instance_list, pos, + struct thermal_instance_s, zdev_node) + { + if (zdev->params->trips[pos->trip].type == THERMAL_PASSIVE) + { + continue; + } + + pos->cdev->ops->get_state(pos->cdev, ¤t); + if ((current != 0 && current != THERMAL_NO_TARGET) || + (pos->target != 0 && pos->target != THERMAL_NO_TARGET)) + { + delay = zdev->params->polling_delay; + } + } + work_queue(LPWORK, &zdev->monitor, (worker_t)thermal_zone_device_update, - zdev, zdev->params->polling_delay); + zdev, delay); unlock: nxmutex_unlock(&g_thermal_lock); diff --git a/drivers/thermal/thermal_dummy.c b/drivers/thermal/thermal_dummy.c index 0de5daa06fc..42b2ce9aada 100644 --- a/drivers/thermal/thermal_dummy.c +++ b/drivers/thermal/thermal_dummy.c @@ -112,7 +112,7 @@ static const struct thermal_zone_trip_s g_dummy_trips[] = { {.name = "cpu_crit", .temp = 90, .hyst = 5, .type = THERMAL_CRITICAL}, {.name = "cpu_alert1", .temp = 70, .hyst = 5, .type = THERMAL_HOT}, - {.name = "cpu_alert0", .temp = 60, .hyst = 5, .type = THERMAL_NORMAL}, + {.name = "cpu_alert0", .temp = 60, .hyst = 5, .type = THERMAL_PASSIVE}, }; static const struct thermal_zone_map_s g_dummy_maps[] = @@ -143,6 +143,7 @@ static const struct thermal_zone_map_s g_dummy_maps[] = static const struct thermal_zone_params_s g_dummy_params = { .gov_name = "step_wise", + .passive_delay = CONFIG_THERMAL_DUMMY_POLLING_DELAY * 2, .polling_delay = CONFIG_THERMAL_DUMMY_POLLING_DELAY, .trips = g_dummy_trips, .num_trips = nitems(g_dummy_trips), @@ -165,6 +166,13 @@ static struct dummy_zone_device_s g_dummy_zone = .temp_jump = true, }; +static const struct thermal_cooling_device_ops_s g_dummy_cooling_ops = +{ + .set_state = dummy_cdev_set_state, + .get_state = dummy_cdev_get_state, + .get_max_state = dummy_cdev_get_max_state, +}; + /* Cooling Device - fan0 */ static struct dummy_cooling_device_s g_dummy_fan0_data = @@ -173,13 +181,6 @@ static struct dummy_cooling_device_s g_dummy_fan0_data = .max_state = 16, }; -static const struct thermal_cooling_device_ops_s g_dummy_fan0_ops = -{ - .set_state = dummy_cdev_set_state, - .get_state = dummy_cdev_get_state, - .get_max_state = dummy_cdev_get_max_state, -}; - /* Cooling Device - cpufreq */ #ifdef CONFIG_THERMAL_DUMMY_CPUFREQ @@ -338,7 +339,7 @@ int thermal_dummy_init(void) /* Cooling Device */ cdev = thermal_cooling_device_register("fan0", &g_dummy_fan0_data, - &g_dummy_fan0_ops); + &g_dummy_cooling_ops); if (cdev == NULL) { therr("Register cooling device fan0 failed!\n"); diff --git a/include/nuttx/thermal.h b/include/nuttx/thermal.h index 673c8416490..a9061a6d549 100644 --- a/include/nuttx/thermal.h +++ b/include/nuttx/thermal.h @@ -71,7 +71,8 @@ enum thermal_trend_e enum thermal_trip_type_e { - THERMAL_NORMAL, + THERMAL_ACTIVE, + THERMAL_PASSIVE, THERMAL_HOT, THERMAL_CRITICAL, THERMAL_TRIP_TYPE_MAX, @@ -163,6 +164,7 @@ struct thermal_zone_trip_s struct thermal_zone_params_s { FAR const char *gov_name; + int passive_delay; int polling_delay; FAR const struct thermal_zone_trip_s *trips; int num_trips;