Hi Arjan, This third patch, adds notification support to medfield thermal driver.
This patch enables monitoring the sensors on the platform. When the temperature crosses any of the configured thresholds, the monitor sends a notification via the thermal framework. ------------------------------------------------------------------------- Signed-off-by: <[email protected]> Index: ac_kernel/kernel/drivers/hwmon/intel_mid_thermal.c =================================================================== --- ac_kernel.orig/kernel/drivers/hwmon/intel_mid_thermal.c +++ ac_kernel/kernel/drivers/hwmon/intel_mid_thermal.c @@ -94,8 +94,7 @@ MODULE_LICENSE("GPL"); /*convert adc_val to die temperature */ #define TO_MSIC_DIE_TEMP(adc_val) ((368 * (adc_val) / 1000) - 220) -#define CHECK_INTERVAL (300 * HZ) - +#define CHECK_INTERVAL (300 * HZ) #define TEMP_CONST1 0 #define TEMP_CONST2 0 #define PASSIVE_FREQ 2000 @@ -120,12 +119,14 @@ static int read_trip_temp(struct thermal static int read_curr_temp(struct thermal_zone_device *, long *); static int read_trip_type(struct thermal_zone_device *, int, enum thermal_trip_type *); - +static int platform_thermal_monitor(struct thermal_zone_device *, int, + enum thermal_trip_type); struct thermal_zone_device_ops tzd_ops = { .get_trip_type = read_trip_type, .get_trip_temp = read_trip_temp, .set_trip_temp = write_trip_temp, .get_temp = read_curr_temp, + .notify = platform_thermal_monitor, }; static char *name[MSIC_THERMAL_SENSORS] = {"skin0", "skin1", @@ -564,6 +565,78 @@ static int read_curr_temp(struct thermal } /** + * is_event_valid - checks the event is valid or not + * @index: indicates which trip_point has caused the event + * context: can sleep + * + * Check whether has happened after the specified time interval. + * This is to avoid getting multiple (similar)events within a short + * span of time. Returns 1 only if the event has occurred after the + * CHECK_INTERVAL. + */ +static int is_event_valid(struct thermal_device_info *td_info, + unsigned int index) +{ + u64 now, check_time; + + WARN_ON(td_info == NULL); + + now = get_jiffies_64(); + check_time = td_info->event_timer[index]; + + if (time_before(now, check_time)) + return 0; + + td_info->event_timer[index] = now + CHECK_INTERVAL; + + return 1; +} + +/** + * platform_thermal_monitor - monitors the thermal behaviour of the platform + * @trip_index: index of the trip_point that will be checked + * @type: one of the thermal_trip_types + * context: can sleep + * + * This method monitors the thermal activities of the platform and generates + * a netlink event when current temperature crosses any of the thresholds. + */ +static int platform_thermal_monitor(struct thermal_zone_device *tz, + int trip_index, enum thermal_trip_type type) +{ + int cur_temp; + int trip_temp; + struct thermal_device_info *td_info = + (struct thermal_device_info *)tz->devdata; + + WARN_ON(td_info == NULL); + + cur_temp = td_info->curr_temp; + trip_temp = td_info->trip_temp[trip_index]; + + if (!is_event_valid(td_info, trip_index)) + return 0; + + switch (trip_index) { + case 0: + if (cur_temp <= trip_temp) + generate_netlink_event(tz->id, THERMAL_AUX0); + break; + case 1: + if (cur_temp >= trip_temp) + generate_netlink_event(tz->id, THERMAL_AUX1); + break; + case 2: + if (cur_temp >= trip_temp) + generate_netlink_event(tz->id, THERMAL_CRITICAL); + break; + default: + WARN_ON(1); + } + return 0; +} + +/** * mid_thermal_probe - mfld thermal initialize * @pdev: platform device structure * Context: can sleep
MFLD_thermal_driver_notification.patch
Description: MFLD_thermal_driver_notification.patch
_______________________________________________ Meego-kernel mailing list [email protected] http://lists.meego.com/listinfo/meego-kernel
