diff options
Diffstat (limited to 'drivers/thermal/of-thermal.c')
-rw-r--r-- | drivers/thermal/of-thermal.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 668fb1bdea9e..b295b2b6c191 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c | |||
@@ -58,6 +58,8 @@ struct __thermal_bind_params { | |||
58 | * @mode: current thermal zone device mode (enabled/disabled) | 58 | * @mode: current thermal zone device mode (enabled/disabled) |
59 | * @passive_delay: polling interval while passive cooling is activated | 59 | * @passive_delay: polling interval while passive cooling is activated |
60 | * @polling_delay: zone polling interval | 60 | * @polling_delay: zone polling interval |
61 | * @slope: slope of the temperature adjustment curve | ||
62 | * @offset: offset of the temperature adjustment curve | ||
61 | * @ntrips: number of trip points | 63 | * @ntrips: number of trip points |
62 | * @trips: an array of trip points (0..ntrips - 1) | 64 | * @trips: an array of trip points (0..ntrips - 1) |
63 | * @num_tbps: number of thermal bind params | 65 | * @num_tbps: number of thermal bind params |
@@ -70,6 +72,8 @@ struct __thermal_zone { | |||
70 | enum thermal_device_mode mode; | 72 | enum thermal_device_mode mode; |
71 | int passive_delay; | 73 | int passive_delay; |
72 | int polling_delay; | 74 | int polling_delay; |
75 | int slope; | ||
76 | int offset; | ||
73 | 77 | ||
74 | /* trip data */ | 78 | /* trip data */ |
75 | int ntrips; | 79 | int ntrips; |
@@ -227,7 +231,8 @@ static int of_thermal_bind(struct thermal_zone_device *thermal, | |||
227 | ret = thermal_zone_bind_cooling_device(thermal, | 231 | ret = thermal_zone_bind_cooling_device(thermal, |
228 | tbp->trip_id, cdev, | 232 | tbp->trip_id, cdev, |
229 | tbp->max, | 233 | tbp->max, |
230 | tbp->min); | 234 | tbp->min, |
235 | tbp->usage); | ||
231 | if (ret) | 236 | if (ret) |
232 | return ret; | 237 | return ret; |
233 | } | 238 | } |
@@ -581,7 +586,7 @@ static int thermal_of_populate_bind_params(struct device_node *np, | |||
581 | u32 prop; | 586 | u32 prop; |
582 | 587 | ||
583 | /* Default weight. Usage is optional */ | 588 | /* Default weight. Usage is optional */ |
584 | __tbp->usage = 0; | 589 | __tbp->usage = THERMAL_WEIGHT_DEFAULT; |
585 | ret = of_property_read_u32(np, "contribution", &prop); | 590 | ret = of_property_read_u32(np, "contribution", &prop); |
586 | if (ret == 0) | 591 | if (ret == 0) |
587 | __tbp->usage = prop; | 592 | __tbp->usage = prop; |
@@ -715,7 +720,7 @@ static int thermal_of_populate_trip(struct device_node *np, | |||
715 | * @np parameter and fills the read data into a __thermal_zone data structure | 720 | * @np parameter and fills the read data into a __thermal_zone data structure |
716 | * and return this pointer. | 721 | * and return this pointer. |
717 | * | 722 | * |
718 | * TODO: Missing properties to parse: thermal-sensor-names and coefficients | 723 | * TODO: Missing properties to parse: thermal-sensor-names |
719 | * | 724 | * |
720 | * Return: On success returns a valid struct __thermal_zone, | 725 | * Return: On success returns a valid struct __thermal_zone, |
721 | * otherwise, it returns a corresponding ERR_PTR(). Caller must | 726 | * otherwise, it returns a corresponding ERR_PTR(). Caller must |
@@ -727,7 +732,7 @@ thermal_of_build_thermal_zone(struct device_node *np) | |||
727 | struct device_node *child = NULL, *gchild; | 732 | struct device_node *child = NULL, *gchild; |
728 | struct __thermal_zone *tz; | 733 | struct __thermal_zone *tz; |
729 | int ret, i; | 734 | int ret, i; |
730 | u32 prop; | 735 | u32 prop, coef[2]; |
731 | 736 | ||
732 | if (!np) { | 737 | if (!np) { |
733 | pr_err("no thermal zone np\n"); | 738 | pr_err("no thermal zone np\n"); |
@@ -752,6 +757,20 @@ thermal_of_build_thermal_zone(struct device_node *np) | |||
752 | } | 757 | } |
753 | tz->polling_delay = prop; | 758 | tz->polling_delay = prop; |
754 | 759 | ||
760 | /* | ||
761 | * REVIST: for now, the thermal framework supports only | ||
762 | * one sensor per thermal zone. Thus, we are considering | ||
763 | * only the first two values as slope and offset. | ||
764 | */ | ||
765 | ret = of_property_read_u32_array(np, "coefficients", coef, 2); | ||
766 | if (ret == 0) { | ||
767 | tz->slope = coef[0]; | ||
768 | tz->offset = coef[1]; | ||
769 | } else { | ||
770 | tz->slope = 1; | ||
771 | tz->offset = 0; | ||
772 | } | ||
773 | |||
755 | /* trips */ | 774 | /* trips */ |
756 | child = of_get_child_by_name(np, "trips"); | 775 | child = of_get_child_by_name(np, "trips"); |
757 | 776 | ||
@@ -865,6 +884,8 @@ int __init of_parse_thermal_zones(void) | |||
865 | for_each_child_of_node(np, child) { | 884 | for_each_child_of_node(np, child) { |
866 | struct thermal_zone_device *zone; | 885 | struct thermal_zone_device *zone; |
867 | struct thermal_zone_params *tzp; | 886 | struct thermal_zone_params *tzp; |
887 | int i, mask = 0; | ||
888 | u32 prop; | ||
868 | 889 | ||
869 | /* Check whether child is enabled or not */ | 890 | /* Check whether child is enabled or not */ |
870 | if (!of_device_is_available(child)) | 891 | if (!of_device_is_available(child)) |
@@ -891,8 +912,18 @@ int __init of_parse_thermal_zones(void) | |||
891 | /* No hwmon because there might be hwmon drivers registering */ | 912 | /* No hwmon because there might be hwmon drivers registering */ |
892 | tzp->no_hwmon = true; | 913 | tzp->no_hwmon = true; |
893 | 914 | ||
915 | if (!of_property_read_u32(child, "sustainable-power", &prop)) | ||
916 | tzp->sustainable_power = prop; | ||
917 | |||
918 | for (i = 0; i < tz->ntrips; i++) | ||
919 | mask |= 1 << i; | ||
920 | |||
921 | /* these two are left for temperature drivers to use */ | ||
922 | tzp->slope = tz->slope; | ||
923 | tzp->offset = tz->offset; | ||
924 | |||
894 | zone = thermal_zone_device_register(child->name, tz->ntrips, | 925 | zone = thermal_zone_device_register(child->name, tz->ntrips, |
895 | 0, tz, | 926 | mask, tz, |
896 | ops, tzp, | 927 | ops, tzp, |
897 | tz->passive_delay, | 928 | tz->passive_delay, |
898 | tz->polling_delay); | 929 | tz->polling_delay); |