Commit 0db9723c authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux

Pull thermal management updates from Zhang Rui:
 "Specifics:

   - enhance Thermal Framework with several new capabilities:

       * use power estimates
       * compute weights with relative integers instead of percentages
       * allow governors to have private data in thermal zones
       * export thermal zone parameters through sysfs

     Thanks to the ARM thermal team (Javi, Punit, KP).

   - introduce a new thermal governor: power allocator.  First in kernel
     closed loop PI(D) controller for thermal control.  Thanks to ARM
     thermal team.

   - enhance OF thermal to allow thermal zones to have sustainable power
     HW specification.  Thanks to Punit.

   - introduce thermal driver for Intel Quark SoC x1000platform.  Thanks
     to Ong, Boon Leong.

   - introduce QPNP PMIC temperature alarm driver.  Thanks to Ivan T. I.

   - introduce thermal driver for Hisilicon hi6220.  Thanks to
     kongxinwei.

   - enhance Exynos thermal driver to handle Exynos5433 TMU.  Thanks to
     Chanwoo C.

   - TI thermal driver now has a better implementation for EOCZ bit.
     From Pavel M.

   - add id for Skylake processors in int340x processor thermal driver.

   - a couple of small fixes and cleanups."

* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: (36 commits)
  thermal: hisilicon: add new hisilicon thermal sensor driver
  dt-bindings: Document the hi6220 thermal sensor bindings
  thermal: of-thermal: add support for reading coefficients property
  thermal: support slope and offset coefficients
  thermal: power_allocator: round the division when divvying up power
  thermal: exynos: Add the support for Exynos5433 TMU
  thermal: cpu_cooling: Fix power calculation when CPUs are offline
  thermal: cpu_cooling: Remove cpu_dev update on policy CPU update
  thermal: export thermal_zone_parameters to sysfs
  thermal: cpu_cooling: Check memory allocation of power_table
  ti-soc-thermal: request temperature periodically if hw can't do that itself
  ti-soc-thermal: implement eocz bit to make driver useful on omap3
  cleanup ti-soc-thermal
  thermal: remove stale THERMAL_POWER_ACTOR select
  thermal: Default OF created trip points to writable
  thermal: core: Add Kconfig option to enable writable trips
  thermal: x86_pkg_temp: drop const for thermal_zone_parameters
  of: thermal: Introduce sustainable power for a thermal zone
  thermal: add trace events to the power allocator governor
  thermal: introduce the Power Allocator governor
  ...
parents 4570a371 111b23cf
* Temperature Sensor on hisilicon SoCs
** Required properties :
- compatible: "hisilicon,tsensor".
- reg: physical base address of thermal sensor and length of memory mapped
region.
- interrupt: The interrupt number to the cpu. Defines the interrupt used
by /SOCTHERM/tsensor.
- clock-names: Input clock name, should be 'thermal_clk'.
- clocks: phandles for clock specified in "clock-names" property.
- #thermal-sensor-cells: Should be 1. See ./thermal.txt for a description.
Example :
tsensor: tsensor@0,f7030700 {
compatible = "hisilicon,tsensor";
reg = <0x0 0xf7030700 0x0 0x1000>;
interrupts = <0 7 0x4>;
clocks = <&sys_ctrl HI6220_TSENSOR_CLK>;
clock-names = "thermal_clk";
#thermal-sensor-cells = <1>;
}
Qualcomm QPNP PMIC Temperature Alarm
QPNP temperature alarm peripherals are found inside of Qualcomm PMIC chips
that utilize the Qualcomm SPMI implementation. These peripherals provide an
interrupt signal and status register to identify high PMIC die temperature.
Required properties:
- compatible: Should contain "qcom,spmi-temp-alarm".
- reg: Specifies the SPMI address and length of the controller's
registers.
- interrupts: PMIC temperature alarm interrupt.
- #thermal-sensor-cells: Should be 0. See thermal.txt for a description.
Optional properties:
- io-channels: Should contain IIO channel specifier for the ADC channel,
which report chip die temperature.
- io-channel-names: Should contain "thermal".
Example:
pm8941_temp: thermal-alarm@2400 {
compatible = "qcom,spmi-temp-alarm";
reg = <0x2400 0x100>;
interrupts = <0 0x24 0 IRQ_TYPE_EDGE_RISING>;
#thermal-sensor-cells = <0>;
io-channels = <&pm8941_vadc VADC_DIE_TEMP>;
io-channel-names = "thermal";
};
thermal-zones {
pm8941 {
polling-delay-passive = <250>;
polling-delay = <1000>;
thermal-sensors = <&pm8941_temp>;
trips {
passive {
temperature = <1050000>;
hysteresis = <2000>;
type = "passive";
};
alert {
temperature = <125000>;
hysteresis = <2000>;
type = "hot";
};
crit {
temperature = <145000>;
hysteresis = <2000>;
type = "critical";
};
};
};
};
...@@ -167,6 +167,13 @@ Optional property: ...@@ -167,6 +167,13 @@ Optional property:
by means of sensor ID. Additional coefficients are by means of sensor ID. Additional coefficients are
interpreted as constant offset. interpreted as constant offset.
- sustainable-power: An estimate of the sustainable power (in mW) that the
Type: unsigned thermal zone can dissipate at the desired
Size: one cell control temperature. For reference, the
sustainable power of a 4'' phone is typically
2000mW, while on a 10'' tablet is around
4500mW.
Note: The delay properties are bound to the maximum dT/dt (temperature Note: The delay properties are bound to the maximum dT/dt (temperature
derivative over time) in two situations for a thermal zone: derivative over time) in two situations for a thermal zone:
(i) - when passive cooling is activated (polling-delay-passive); and (i) - when passive cooling is activated (polling-delay-passive); and
...@@ -546,6 +553,8 @@ thermal-zones { ...@@ -546,6 +553,8 @@ thermal-zones {
*/ */
coefficients = <1200 -345 890>; coefficients = <1200 -345 890>;
sustainable-power = <2500>;
trips { trips {
/* Trips are based on resulting linear equation */ /* Trips are based on resulting linear equation */
cpu_trip: cpu-trip { cpu_trip: cpu-trip {
......
...@@ -36,8 +36,162 @@ the user. The registration APIs returns the cooling device pointer. ...@@ -36,8 +36,162 @@ the user. The registration APIs returns the cooling device pointer.
np: pointer to the cooling device device tree node np: pointer to the cooling device device tree node
clip_cpus: cpumask of cpus where the frequency constraints will happen. clip_cpus: cpumask of cpus where the frequency constraints will happen.
1.1.3 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) 1.1.3 struct thermal_cooling_device *cpufreq_power_cooling_register(
const struct cpumask *clip_cpus, u32 capacitance,
get_static_t plat_static_func)
Similar to cpufreq_cooling_register, this function registers a cpufreq
cooling device. Using this function, the cooling device will
implement the power extensions by using a simple cpu power model. The
cpus must have registered their OPPs using the OPP library.
The additional parameters are needed for the power model (See 2. Power
models). "capacitance" is the dynamic power coefficient (See 2.1
Dynamic power). "plat_static_func" is a function to calculate the
static power consumed by these cpus (See 2.2 Static power).
1.1.4 struct thermal_cooling_device *of_cpufreq_power_cooling_register(
struct device_node *np, const struct cpumask *clip_cpus, u32 capacitance,
get_static_t plat_static_func)
Similar to cpufreq_power_cooling_register, this function register a
cpufreq cooling device with power extensions using the device tree
information supplied by the np parameter.
1.1.5 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
This interface function unregisters the "thermal-cpufreq-%x" cooling device. This interface function unregisters the "thermal-cpufreq-%x" cooling device.
cdev: Cooling device pointer which has to be unregistered. cdev: Cooling device pointer which has to be unregistered.
2. Power models
The power API registration functions provide a simple power model for
CPUs. The current power is calculated as dynamic + (optionally)
static power. This power model requires that the operating-points of
the CPUs are registered using the kernel's opp library and the
`cpufreq_frequency_table` is assigned to the `struct device` of the
cpu. If you are using CONFIG_CPUFREQ_DT then the
`cpufreq_frequency_table` should already be assigned to the cpu
device.
The `plat_static_func` parameter of `cpufreq_power_cooling_register()`
and `of_cpufreq_power_cooling_register()` is optional. If you don't
provide it, only dynamic power will be considered.
2.1 Dynamic power
The dynamic power consumption of a processor depends on many factors.
For a given processor implementation the primary factors are:
- The time the processor spends running, consuming dynamic power, as
compared to the time in idle states where dynamic consumption is
negligible. Herein we refer to this as 'utilisation'.
- The voltage and frequency levels as a result of DVFS. The DVFS
level is a dominant factor governing power consumption.
- In running time the 'execution' behaviour (instruction types, memory
access patterns and so forth) causes, in most cases, a second order
variation. In pathological cases this variation can be significant,
but typically it is of a much lesser impact than the factors above.
A high level dynamic power consumption model may then be represented as:
Pdyn = f(run) * Voltage^2 * Frequency * Utilisation
f(run) here represents the described execution behaviour and its
result has a units of Watts/Hz/Volt^2 (this often expressed in
mW/MHz/uVolt^2)
The detailed behaviour for f(run) could be modelled on-line. However,
in practice, such an on-line model has dependencies on a number of
implementation specific processor support and characterisation
factors. Therefore, in initial implementation that contribution is
represented as a constant coefficient. This is a simplification
consistent with the relative contribution to overall power variation.
In this simplified representation our model becomes:
Pdyn = Capacitance * Voltage^2 * Frequency * Utilisation
Where `capacitance` is a constant that represents an indicative
running time dynamic power coefficient in fundamental units of
mW/MHz/uVolt^2. Typical values for mobile CPUs might lie in range
from 100 to 500. For reference, the approximate values for the SoC in
ARM's Juno Development Platform are 530 for the Cortex-A57 cluster and
140 for the Cortex-A53 cluster.
2.2 Static power
Static leakage power consumption depends on a number of factors. For a
given circuit implementation the primary factors are:
- Time the circuit spends in each 'power state'
- Temperature
- Operating voltage
- Process grade
The time the circuit spends in each 'power state' for a given
evaluation period at first order means OFF or ON. However,
'retention' states can also be supported that reduce power during
inactive periods without loss of context.
Note: The visibility of state entries to the OS can vary, according to
platform specifics, and this can then impact the accuracy of a model
based on OS state information alone. It might be possible in some
cases to extract more accurate information from system resources.
The temperature, operating voltage and process 'grade' (slow to fast)
of the circuit are all significant factors in static leakage power
consumption. All of these have complex relationships to static power.
Circuit implementation specific factors include the chosen silicon
process as well as the type, number and size of transistors in both
the logic gates and any RAM elements included.
The static power consumption modelling must take into account the
power managed regions that are implemented. Taking the example of an
ARM processor cluster, the modelling would take into account whether
each CPU can be powered OFF separately or if only a single power
region is implemented for the complete cluster.
In one view, there are others, a static power consumption model can
then start from a set of reference values for each power managed
region (e.g. CPU, Cluster/L2) in each state (e.g. ON, OFF) at an
arbitrary process grade, voltage and temperature point. These values
are then scaled for all of the following: the time in each state, the
process grade, the current temperature and the operating voltage.
However, since both implementation specific and complex relationships
dominate the estimate, the appropriate interface to the model from the
cpu cooling device is to provide a function callback that calculates
the static power in this platform. When registering the cpu cooling
device pass a function pointer that follows the `get_static_t`
prototype:
int plat_get_static(cpumask_t *cpumask, int interval,
unsigned long voltage, u32 &power);
`cpumask` is the cpumask of the cpus involved in the calculation.
`voltage` is the voltage at which they are operating. The function
should calculate the average static power for the last `interval`
milliseconds. It returns 0 on success, -E* on error. If it
succeeds, it should store the static power in `power`. Reading the
temperature of the cpus described by `cpumask` is left for
plat_get_static() to do as the platform knows best which thermal
sensor is closest to the cpu.
If `plat_static_func` is NULL, static power is considered to be
negligible for this platform and only dynamic power is considered.
The platform specific callback can then use any combination of tables
and/or equations to permute the estimated value. Process grade
information is not passed to the model since access to such data, from
on-chip measurement capability or manufacture time data, is platform
specific.
Note: the significance of static power for CPUs in comparison to
dynamic power is highly dependent on implementation. Given the
potential complexity in implementation, the importance and accuracy of
its inclusion when using cpu cooling devices should be assessed on a
case by case basis.
This diff is collapsed.
...@@ -95,7 +95,7 @@ temperature) and throttle appropriate devices. ...@@ -95,7 +95,7 @@ temperature) and throttle appropriate devices.
1.3 interface for binding a thermal zone device with a thermal cooling device 1.3 interface for binding a thermal zone device with a thermal cooling device
1.3.1 int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, 1.3.1 int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
int trip, struct thermal_cooling_device *cdev, int trip, struct thermal_cooling_device *cdev,
unsigned long upper, unsigned long lower); unsigned long upper, unsigned long lower, unsigned int weight);
This interface function bind a thermal cooling device to the certain trip This interface function bind a thermal cooling device to the certain trip
point of a thermal zone device. point of a thermal zone device.
...@@ -110,6 +110,8 @@ temperature) and throttle appropriate devices. ...@@ -110,6 +110,8 @@ temperature) and throttle appropriate devices.
lower:the Minimum cooling state can be used for this trip point. lower:the Minimum cooling state can be used for this trip point.
THERMAL_NO_LIMIT means no lower limit, THERMAL_NO_LIMIT means no lower limit,
and the cooling device can be in cooling state 0. and the cooling device can be in cooling state 0.
weight: the influence of this cooling device in this thermal
zone. See 1.4.1 below for more information.
1.3.2 int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, 1.3.2 int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz,
int trip, struct thermal_cooling_device *cdev); int trip, struct thermal_cooling_device *cdev);
...@@ -127,9 +129,15 @@ temperature) and throttle appropriate devices. ...@@ -127,9 +129,15 @@ temperature) and throttle appropriate devices.
This structure defines the following parameters that are used to bind This structure defines the following parameters that are used to bind
a zone with a cooling device for a particular trip point. a zone with a cooling device for a particular trip point.
.cdev: The cooling device pointer .cdev: The cooling device pointer
.weight: The 'influence' of a particular cooling device on this zone. .weight: The 'influence' of a particular cooling device on this
This is on a percentage scale. The sum of all these weights zone. This is relative to the rest of the cooling
(for a particular zone) cannot exceed 100. devices. For example, if all cooling devices have a
weight of 1, then they all contribute the same. You can
use percentages if you want, but it's not mandatory. A
weight of 0 means that this cooling device doesn't
contribute to the cooling of this zone unless all cooling
devices have a weight of 0. If all weights are 0, then
they all contribute the same.
.trip_mask:This is a bit mask that gives the binding relation between .trip_mask:This is a bit mask that gives the binding relation between
this thermal zone and cdev, for a particular trip point. this thermal zone and cdev, for a particular trip point.
If nth bit is set, then the cdev and thermal zone are bound If nth bit is set, then the cdev and thermal zone are bound
...@@ -176,6 +184,14 @@ Thermal zone device sys I/F, created once it's registered: ...@@ -176,6 +184,14 @@ Thermal zone device sys I/F, created once it's registered:
|---trip_point_[0-*]_type: Trip point type |---trip_point_[0-*]_type: Trip point type
|---trip_point_[0-*]_hyst: Hysteresis value for this trip point |---trip_point_[0-*]_hyst: Hysteresis value for this trip point
|---emul_temp: Emulated temperature set node |---emul_temp: Emulated temperature set node
|---sustainable_power: Sustainable dissipatable power
|---k_po: Proportional term during temperature overshoot
|---k_pu: Proportional term during temperature undershoot
|---k_i: PID's integral term in the power allocator gov
|---k_d: PID's derivative term in the power allocator
|---integral_cutoff: Offset above which errors are accumulated
|---slope: Slope constant applied as linear extrapolation
|---offset: Offset constant applied as linear extrapolation
Thermal cooling device sys I/F, created once it's registered: Thermal cooling device sys I/F, created once it's registered:
/sys/class/thermal/cooling_device[0-*]: /sys/class/thermal/cooling_device[0-*]:
...@@ -192,6 +208,8 @@ thermal_zone_bind_cooling_device/thermal_zone_unbind_cooling_device. ...@@ -192,6 +208,8 @@ thermal_zone_bind_cooling_device/thermal_zone_unbind_cooling_device.
/sys/class/thermal/thermal_zone[0-*]: /sys/class/thermal/thermal_zone[0-*]:
|---cdev[0-*]: [0-*]th cooling device in current thermal zone |---cdev[0-*]: [0-*]th cooling device in current thermal zone
|---cdev[0-*]_trip_point: Trip point that cdev[0-*] is associated with |---cdev[0-*]_trip_point: Trip point that cdev[0-*] is associated with
|---cdev[0-*]_weight: Influence of the cooling device in
this thermal zone
Besides the thermal zone device sysfs I/F and cooling device sysfs I/F, Besides the thermal zone device sysfs I/F and cooling device sysfs I/F,
the generic thermal driver also creates a hwmon sysfs I/F for each _type_ the generic thermal driver also creates a hwmon sysfs I/F for each _type_
...@@ -265,6 +283,14 @@ cdev[0-*]_trip_point ...@@ -265,6 +283,14 @@ cdev[0-*]_trip_point
point. point.
RO, Optional RO, Optional
cdev[0-*]_weight
The influence of cdev[0-*] in this thermal zone. This value
is relative to the rest of cooling devices in the thermal
zone. For example, if a cooling device has a weight double
than that of other, it's twice as effective in cooling the
thermal zone.
RW, Optional
passive passive
Attribute is only present for zones in which the passive cooling Attribute is only present for zones in which the passive cooling
policy is not supported by native thermal driver. Default is zero policy is not supported by native thermal driver. Default is zero
...@@ -289,6 +315,66 @@ emul_temp ...@@ -289,6 +315,66 @@ emul_temp
because userland can easily disable the thermal policy by simply because userland can easily disable the thermal policy by simply
flooding this sysfs node with low temperature values. flooding this sysfs node with low temperature values.
sustainable_power
An estimate of the sustained power that can be dissipated by
the thermal zone. Used by the power allocator governor. For
more information see Documentation/thermal/power_allocator.txt
Unit: milliwatts
RW, Optional
k_po
The proportional term of the power allocator governor's PID
controller during temperature overshoot. Temperature overshoot
is when the current temperature is above the "desired
temperature" trip point. For more information see
Documentation/thermal/power_allocator.txt
RW, Optional
k_pu
The proportional term of the power allocator governor's PID
controller during temperature undershoot. Temperature undershoot
is when the current temperature is below the "desired
temperature" trip point. For more information see
Documentation/thermal/power_allocator.txt
RW, Optional
k_i
The integral term of the power allocator governor's PID
controller. This term allows the PID controller to compensate
for long term drift. For more information see
Documentation/thermal/power_allocator.txt
RW, Optional
k_d
The derivative term of the power allocator governor's PID
controller. For more information see
Documentation/thermal/power_allocator.txt
RW, Optional
integral_cutoff
Temperature offset from the desired temperature trip point
above which the integral term of the power allocator
governor's PID controller starts accumulating errors. For
example, if integral_cutoff is 0, then the integral term only
accumulates error when temperature is above the desired
temperature trip point. For more information see
Documentation/thermal/power_allocator.txt
RW, Optional
slope
The slope constant used in a linear extrapolation model
to determine a hotspot temperature based off the sensor's
raw readings. It is up to the device driver to determine
the usage of these values.
RW, Optional
offset
The offset constant used in a linear extrapolation model
to determine a hotspot temperature based off the sensor's
raw readings. It is up to the device driver to determine
the usage of these values.
RW, Optional
***************************** *****************************
* Cooling device attributes * * Cooling device attributes *
***************************** *****************************
...@@ -318,7 +404,8 @@ passive, active. If an ACPI thermal zone supports critical, passive, ...@@ -318,7 +404,8 @@ passive, active. If an ACPI thermal zone supports critical, passive,
active[0] and active[1] at the same time, it may register itself as a active[0] and active[1] at the same time, it may register itself as a
thermal_zone_device (thermal_zone1) with 4 trip points in all. thermal_zone_device (thermal_zone1) with 4 trip points in all.
It has one processor and one fan, which are both registered as It has one processor and one fan, which are both registered as
thermal_cooling_device. thermal_cooling_device. Both are considered to have the same
effectiveness in cooling the thermal zone.
If the processor is listed in _PSL method, and the fan is listed in _AL0 If the processor is listed in _PSL method, and the fan is listed in _AL0
method, the sys I/F structure will be built like this: method, the sys I/F structure will be built like this:
...@@ -340,8 +427,10 @@ method, the sys I/F structure will be built like this: ...@@ -340,8 +427,10 @@ method, the sys I/F structure will be built like this:
|---trip_point_3_type: active1 |---trip_point_3_type: active1
|---cdev0: --->/sys/class/thermal/cooling_device0 |---cdev0: --->/sys/class/thermal/cooling_device0
|---cdev0_trip_point: 1 /* cdev0 can be used for passive */ |---cdev0_trip_point: 1 /* cdev0 can be used for passive */
|---cdev0_weight: 1024
|---cdev1: --->/sys/class/thermal/cooling_device3 |---cdev1: --->/sys/class/thermal/cooling_device3
|---cdev1_trip_point: 2 /* cdev1 can be used for active[0]*/ |---cdev1_trip_point: 2 /* cdev1 can be used for active[0]*/
|---cdev1_weight: 1024
|cooling_device0: |cooling_device0:
|---type: Processor |---type: Processor
......
...@@ -800,7 +800,8 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, ...@@ -800,7 +800,8 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
result = result =
thermal_zone_bind_cooling_device thermal_zone_bind_cooling_device
(thermal, trip, cdev, (thermal, trip, cdev,
THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); THERMAL_NO_LIMIT, THERMAL_NO_LIMIT,
THERMAL_WEIGHT_DEFAULT);
else else
result = result =
thermal_zone_unbind_cooling_device thermal_zone_unbind_cooling_device
...@@ -824,7 +825,8 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, ...@@ -824,7 +825,8 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
if (bind) if (bind)
result = thermal_zone_bind_cooling_device result = thermal_zone_bind_cooling_device
(thermal, trip, cdev, (thermal, trip, cdev,
THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); THERMAL_NO_LIMIT, THERMAL_NO_LIMIT,
THERMAL_WEIGHT_DEFAULT);
else else
result = thermal_zone_unbind_cooling_device result = thermal_zone_unbind_cooling_device
(thermal, trip, cdev); (thermal, trip, cdev);
...@@ -841,7 +843,8 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, ...@@ -841,7 +843,8 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
result = thermal_zone_bind_cooling_device result = thermal_zone_bind_cooling_device
(thermal, THERMAL_TRIPS_NONE, (thermal, THERMAL_TRIPS_NONE,
cdev, THERMAL_NO_LIMIT, cdev, THERMAL_NO_LIMIT,
THERMAL_NO_LIMIT); THERMAL_NO_LIMIT,
THERMAL_WEIGHT_DEFAULT);
else else
result = thermal_zone_unbind_cooling_device result = thermal_zone_unbind_cooling_device
(thermal, THERMAL_TRIPS_NONE, (thermal, THERMAL_TRIPS_NONE,
......
...@@ -372,7 +372,8 @@ static int acerhdf_bind(struct thermal_zone_device *thermal, ...@@ -372,7 +372,8 @@ static int acerhdf_bind(struct thermal_zone_device *thermal,
return 0; return 0;
if (thermal_zone_bind_cooling_device(thermal, 0, cdev, if (thermal_zone_bind_cooling_device(thermal, 0, cdev,
THERMAL_NO_LIMIT, THERMAL_NO_LIMIT)) { THERMAL_NO_LIMIT, THERMAL_NO_LIMIT,
THERMAL_WEIGHT_DEFAULT)) {
pr_err("error binding cooling dev\n"); pr_err("error binding cooling dev\n");
return -EINVAL; return -EINVAL;
} }
......
...@@ -42,6 +42,17 @@ config THERMAL_OF ...@@ -42,6 +42,17 @@ config THERMAL_OF
Say 'Y' here if you need to build thermal infrastructure Say 'Y' here if you need to build thermal infrastructure
based on device tree. based on device tree.
config THERMAL_WRITABLE_TRIPS
bool "Enable writable trip points"
help
This option allows the system integrator to choose whether
trip temperatures can be changed from userspace. The
writable trips need to be specified when setting up the
thermal zone but the choice here takes precedence.
Say 'Y' here if you would like to allow userspace tools to
change trip temperatures.
choice choice
prompt "Default Thermal governor" prompt "Default Thermal governor"
default THERMAL_DEFAULT_GOV_STEP_WISE default THERMAL_DEFAULT_GOV_STEP_WISE
...@@ -71,6 +82,14 @@ config THERMAL_DEFAULT_GOV_USER_SPACE ...@@ -71,6 +82,14 @@ config THERMAL_DEFAULT_GOV_USER_SPACE
Select this if you want to let the user space manage the Select this if you want to let the user space manage the
platform thermals. platform thermals.
config THERMAL_DEFAULT_GOV_POWER_ALLOCATOR
bool "power_allocator"
select THERMAL_GOV_POWER_ALLOCATOR
help
Select this if you want to control temperature based on
system and device power allocation. This governor can only
operate on cooling devices that implement the power API.
endchoice endchoice
config THERMAL_GOV_FAIR_SHARE config THERMAL_GOV_FAIR_SHARE
...@@ -99,6 +118,12 @@ config THERMAL_GOV_USER_SPACE ...@@ -99,6 +118,12 @@ config THERMAL_GOV_USER_SPACE
help help
Enable this to let the user space manage the platform thermals. Enable this to let the user space manage the platform thermals.
config THERMAL_GOV_POWER_ALLOCATOR
bool "Power allocator thermal governor"
help
Enable this to manage platform thermals by dynamically
allocating and limiting power to devices.
config CPU_THERMAL config CPU_THERMAL
bool "generic cpu cooling support" bool "generic cpu cooling support"
depends on CPU_FREQ depends on CPU_FREQ
...@@ -136,6 +161,14 @@ config THERMAL_EMULATION ...@@ -136,6 +161,14 @@ config THERMAL_EMULATION
because userland can easily disable the thermal policy by simply because userland can easily disable the thermal policy by simply
flooding this sysfs node with low temperature values. flooding this sysfs node with low temperature values.
config HISI_THERMAL
tristate "Hisilicon thermal driver"
depends on ARCH_HISI && CPU_THERMAL && OF
help
Enable this to plug hisilicon's thermal sensor driver into the Linux
thermal framework. cpufreq is used as the cooling device to throttle
CPUs when the passive trip is crossed.
config IMX_THERMAL config IMX_THERMAL
tristate "Temperature sensor driver for Freescale i.MX SoCs" tristate "Temperature sensor driver for Freescale i.MX SoCs"
depends on CPU_THERMAL depends on CPU_THERMAL
...@@ -249,9 +282,20 @@ config X86_PKG_TEMP_THERMAL ...@@ -249,9 +282,20 @@ config X86_PKG_TEMP_THERMAL
two trip points which can be set by user to get notifications via thermal two trip points which can be set by user to get notifications via thermal
notification methods. notification methods.
config INTEL_SOC_DTS_IOSF_CORE
tristate
depends on X86
select IOSF_MBI
help
This is becoming a common feature for Intel SoCs to expose the additional
digital temperature sensors (DTSs) using side band interface (IOSF). This
implements the common set of helper functions to register, get temperature
and get/set thresholds on DTSs.
config INTEL_SOC_DTS_THERMAL config INTEL_SOC_DTS_THERMAL
tristate "Intel SoCs DTS thermal driver" tristate "Intel SoCs DTS thermal driver"
depends on X86 && IOSF_MBI depends on X86
select INTEL_SOC_DTS_IOSF_CORE
help help
Enable this to register Intel SoCs (e.g. Bay Trail) platform digital Enable this to register Intel SoCs (e.g. Bay Trail) platform digital
temperature sensor (DTS). These SoCs have two additional DTSs in temperature sensor (DTS). These SoCs have two additional DTSs in
...@@ -261,12 +305,23 @@ config INTEL_SOC_DTS_THERMAL ...@@ -261,12 +305,23 @@ config INTEL_SOC_DTS_THERMAL
notification methods.The other trip is a critical trip point, which notification methods.The other trip is a critical trip point, which
was set by the driver based on the TJ MAX temperature. was set by the driver based on the TJ MAX temperature.
config INTEL_QUARK_DTS_THERMAL
tristate "Intel Quark DTS thermal driver"
depends on X86_INTEL_QUARK
help
Enable this to register Intel Quark SoC (e.g. X1000) platform digital
temperature sensor (DTS). For X1000 SoC, it has one on-die DTS.
The DTS will be registered as a thermal zone. There are two trip points:
hot & critical. The critical trip point default value is set by
underlying BIOS/Firmware.
config INT340X_THERMAL config INT340X_THERMAL
tristate "ACPI INT340X thermal drivers" tristate "ACPI INT340X thermal drivers"
depends on X86 && ACPI depends on X86 && ACPI
select THERMAL_GOV_USER_SPACE select THERMAL_GOV_USER_SPACE
select ACPI_THERMAL_REL select ACPI_THERMAL_REL
select ACPI_FAN select ACPI_FAN
select INTEL_SOC_DTS_IOSF_CORE
help help
Newer laptops and tablets that use ACPI may have thermal sensors and Newer laptops and tablets that use ACPI may have thermal sensors and
other devices with thermal control capabilities outside the core other devices with thermal control capabilities outside the core
...@@ -299,4 +354,15 @@ depends on ARCH_STI && OF ...@@ -299,4 +354,15 @@ depends on ARCH_STI && OF
source "drivers/thermal/st/Kconfig" source "drivers/thermal/st/Kconfig"
endmenu endmenu
config QCOM_SPMI_TEMP_ALARM
tristate "Qualcomm SPMI PMIC Temperature Alarm"
depends on OF && SPMI && IIO
select REGMAP_SPMI
help
This enables a thermal sysfs driver for Qualcomm plug-and-play (QPNP)
PMIC devices. It shows up in sysfs as a thermal sensor with multiple
trip points. The temperature reported by the thermal sensor reflects the
real time die temperature if an ADC is present or an estimate of the
temperature based upon the over temperature stage value.
endif endif
...@@ -14,6 +14,7 @@ thermal_sys-$(CONFIG_THERMAL_GOV_FAIR_SHARE) += fair_share.o ...@@ -14,6 +14,7 @@ thermal_sys-$(CONFIG_THERMAL_GOV_FAIR_SHARE) += fair_share.o
thermal_sys-$(CONFIG_THERMAL_GOV_BANG_BANG) += gov_bang_bang.o thermal_sys-$(CONFIG_THERMAL_GOV_BANG_BANG) += gov_bang_bang.o
thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE) += step_wise.o thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE) += step_wise.o
thermal_sys-$(CONFIG_THERMAL_GOV_USER_SPACE) += user_space.o thermal_sys-$(CONFIG_THERMAL_GOV_USER_SPACE) += user_space.o
thermal_sys-$(CONFIG_THERMAL_GOV_POWER_ALLOCATOR) += power_allocator.o
# cpufreq cooling # cpufreq cooling
thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
...@@ -22,6 +23,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o ...@@ -22,6 +23,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
thermal_sys-$(CONFIG_CLOCK_THERMAL) += clock_cooling.o thermal_sys-$(CONFIG_CLOCK_THERMAL) += clock_cooling.o
# platform thermal drivers # platform thermal drivers
obj-$(CONFIG_QCOM_SPMI_TEMP_ALARM) += qcom-spmi-temp-alarm.o
obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o
obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o
obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o
...@@ -34,8 +36,11 @@ obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o ...@@ -34,8 +36,11 @@ obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o
obj-$(CONFIG_DB8500_CPUFREQ_COOLING) += db8500_cpufreq_cooling.o obj-$(CONFIG_DB8500_CPUFREQ_COOLING) += db8500_cpufreq_cooling.o
obj-$(CONFIG_INTEL_POWERCLAMP) += intel_powerclamp.o obj-$(CONFIG_INTEL_POWERCLAMP) += intel_powerclamp.o
obj-$(CONFIG_X86_PKG_TEMP_THERMAL) += x86_pkg_temp_thermal.o obj-$(CONFIG_X86_PKG_TEMP_THERMAL) += x86_pkg_temp_thermal.o
obj-$(CONFIG_INTEL_SOC_DTS_IOSF_CORE) += intel_soc_dts_iosf.o
obj-$(CONFIG_INTEL_SOC_DTS_THERMAL) += intel_soc_dts_thermal.o obj-$(CONFIG_INTEL_SOC_DTS_THERMAL) += intel_soc_dts_thermal.o
obj-$(CONFIG_INTEL_QUARK_DTS_THERMAL) += intel_quark_dts_thermal.o
obj-$(CONFIG_TI_SOC_THERMAL) += ti-soc-thermal/ obj-$(CONFIG_TI_SOC_THERMAL) += ti-soc-thermal/
obj-$(CONFIG_INT340X_THERMAL) += int340x_thermal/ obj-$(CONFIG_INT340X_THERMAL) += int340x_thermal/
obj-$(CONFIG_ST_THERMAL) += st/ obj-$(CONFIG_ST_THERMAL) += st/
obj-$(CONFIG_TEGRA_SOCTHERM) += tegra_soctherm.o obj-$(CONFIG_TEGRA_SOCTHERM) += tegra_soctherm.o
obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o
This diff is collapsed.
...@@ -76,7 +76,7 @@ static int db8500_cdev_bind(struct thermal_zone_device *thermal, ...@@ -76,7 +76,7 @@ static int db8500_cdev_bind(struct thermal_zone_device *thermal,
upper = lower = i > max_state ? max_state : i; upper = lower = i > max_state ? max_state : i;
ret = thermal_zone_bind_cooling_device(thermal, i, cdev, ret = thermal_zone_bind_cooling_device(thermal, i, cdev,
upper, lower); upper, lower, THERMAL_WEIGHT_DEFAULT);
dev_info(&cdev->device, "%s bind to %d: %d-%s\n", cdev->type, dev_info(&cdev->device, "%s bind to %d: %d-%s\n", cdev->type,
i, ret, ret ? "fail" : "succeed"); i, ret, ret ? "fail" : "succeed");
......
...@@ -59,17 +59,17 @@ static int get_trip_level(struct thermal_zone_device *tz) ...@@ -59,17 +59,17 @@ static int get_trip_level(struct thermal_zone_device *tz)
} }
static long get_target_state(struct thermal_zone_device *tz, static long get_target_state(struct thermal_zone_device *tz,
struct thermal_cooling_device *cdev, int weight, int level) struct thermal_cooling_device *cdev, int percentage, int level)
{ {
unsigned long max_state; unsigned long max_state;
cdev->ops->get_max_state(cdev, &max_state); cdev->ops->get_max_state(cdev, &max_state);
return (long)(weight * level * max_state) / (100 * tz->trips); return (long)(percentage * level * max_state) / (100 * tz->trips);
} }
/** /**
* fair_share_throttle - throttles devices asscciated with the given zone * fair_share_throttle - throttles devices associated with the given zone
* @tz - thermal_zone_device * @tz - thermal_zone_device
* *
* Throttling Logic: This uses three parameters to calculate the new * Throttling Logic: This uses three parameters to calculate the new
...@@ -77,7 +77,7 @@ static long get_target_state(struct thermal_zone_device *tz, ...@@ -77,7 +77,7 @@ static long get_target_state(struct thermal_zone_device *tz,
* *
* Parameters used for Throttling: * Parameters used for Throttling:
* P1. max_state: Maximum throttle state exposed by the cooling device. * P1. max_state: Maximum throttle state exposed by the cooling device.
* P2. weight[i]/100: * P2. percentage[i]/100:
* How 'effective' the 'i'th device is, in cooling the given zone. * How 'effective' the 'i'th device is, in cooling the given zone.
* P3. cur_trip_level/max_no_of_trips: * P3. cur_trip_level/max_no_of_trips:
* This describes the extent to which the devices should be throttled. * This describes the extent to which the devices should be throttled.
...@@ -88,28 +88,33 @@ static long get_target_state(struct thermal_zone_device *tz, ...@@ -88,28 +88,33 @@ static long get_target_state(struct thermal_zone_device *tz,
*/ */
static int fair_share_throttle(struct thermal_zone_device *tz, int trip) static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
{ {
const struct thermal_zone_params *tzp;
struct thermal_cooling_device *cdev;
struct thermal_instance *instance; struct thermal_instance *instance;
int i; int total_weight = 0;
int total_instance = 0;
int cur_trip_level = get_trip_level(tz); int cur_trip_level = get_trip_level(tz);
if (!tz->tzp || !tz->tzp->tbp) list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
return -EINVAL; if (instance->trip != trip)
continue;
total_weight += instance->weight;
total_instance++;
}
tzp = tz->tzp; list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
int percentage;
struct thermal_cooling_device *cdev = instance->cdev;
for (i = 0; i < tzp->num_tbps; i++) { if (instance->trip != trip)
if (!tzp->tbp[i].cdev)
continue; continue;
cdev = tzp->tbp[i].cdev; if (!total_weight)
instance = get_thermal_instance(tz, cdev, trip); percentage = 100 / total_instance;
if (!instance) else
continue; percentage = (instance->weight * 100) / total_weight;
instance->target = get_target_state(tz, cdev, instance->target = get_target_state(tz, cdev, percentage,
tzp->tbp[i].weight, cur_trip_level); cur_trip_level);
instance->cdev->updated = false; instance->cdev->updated = false;
thermal_cdev_update(cdev); thermal_cdev_update(cdev);
......
This diff is collapsed.
...@@ -306,7 +306,8 @@ static int imx_bind(struct thermal_zone_device *tz, ...@@ -306,7 +306,8 @@ static int imx_bind(struct thermal_zone_device *tz,
ret = thermal_zone_bind_cooling_device(tz, IMX_TRIP_PASSIVE, cdev, ret = thermal_zone_bind_cooling_device(tz, IMX_TRIP_PASSIVE, cdev,
THERMAL_NO_LIMIT, THERMAL_NO_LIMIT,
THERMAL_NO_LIMIT); THERMAL_NO_LIMIT,
THERMAL_WEIGHT_DEFAULT);
if (ret) { if (ret) {
dev_err(&tz->device, dev_err(&tz->device,
"binding zone %s with cdev %s failed:%d\n", "binding zone %s with cdev %s failed:%d\n",
......
...@@ -16,15 +16,20 @@ ...@@ -16,15 +16,20 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/thermal.h> #include <linux/thermal.h>
#include "int340x_thermal_zone.h" #include "int340x_thermal_zone.h"
#include "../intel_soc_dts_iosf.h"
/* Broadwell-U/HSB thermal reporting device */ /* Broadwell-U/HSB thermal reporting device */
#define PCI_DEVICE_ID_PROC_BDW_THERMAL 0x1603 #define PCI_DEVICE_ID_PROC_BDW_THERMAL 0x1603
#define PCI_DEVICE_ID_PROC_HSB_THERMAL 0x0A03 #define PCI_DEVICE_ID_PROC_HSB_THERMAL 0x0A03
/* Skylake thermal reporting device */
#define PCI_DEVICE_ID_PROC_SKL_THERMAL 0x1903
/* Braswell thermal reporting device */ /* Braswell thermal reporting device */
#define PCI_DEVICE_ID_PROC_BSW_THERMAL 0x22DC #define PCI_DEVICE_ID_PROC_BSW_THERMAL 0x22DC
...@@ -42,6 +47,7 @@ struct proc_thermal_device { ...@@ -42,6 +47,7 @@ struct proc_thermal_device {
struct acpi_device *adev; struct acpi_device *adev;
struct power_config power_limits[2]; struct power_config power_limits[2];
struct int34x_thermal_zone *int340x_zone; struct int34x_thermal_zone *int340x_zone;
struct intel_soc_dts_sensors *soc_dts;
}; };
enum proc_thermal_emum_mode_type { enum proc_thermal_emum_mode_type {
...@@ -308,6 +314,18 @@ static int int3401_remove(struct platform_device *pdev) ...@@ -308,6 +314,18 @@ static int int3401_remove(struct platform_device *pdev)
return 0; return 0;
} }
static irqreturn_t proc_thermal_pci_msi_irq(int irq, void *devid)
{
struct proc_thermal_device *proc_priv;
struct pci_dev *pdev = devid;
proc_priv = pci_get_drvdata(pdev);
intel_soc_dts_iosf_interrupt_handler(proc_priv->soc_dts);
return IRQ_HANDLED;
}
static int proc_thermal_pci_probe(struct pci_dev *pdev, static int proc_thermal_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *unused) const struct pci_device_id *unused)
{ {
...@@ -334,18 +352,57 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, ...@@ -334,18 +352,57 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev,
pci_set_drvdata(pdev, proc_priv); pci_set_drvdata(pdev, proc_priv);
proc_thermal_emum_mode = PROC_THERMAL_PCI; proc_thermal_emum_mode = PROC_THERMAL_PCI;
if (pdev->device == PCI_DEVICE_ID_PROC_BSW_THERMAL) {
/*
* Enumerate additional DTS sensors available via IOSF.
* But we are not treating as a failure condition, if
* there are no aux DTSs enabled or fails. This driver
* already exposes sensors, which can be accessed via
* ACPI/MSR. So we don't want to fail for auxiliary DTSs.
*/
proc_priv->soc_dts = intel_soc_dts_iosf_init(
INTEL_SOC_DTS_INTERRUPT_MSI, 2, 0);
if (proc_priv->soc_dts && pdev->irq) {
ret = pci_enable_msi(pdev);
if (!ret) {
ret = request_threaded_irq(pdev->irq, NULL,
proc_thermal_pci_msi_irq,
IRQF_ONESHOT, "proc_thermal",
pdev);
if (ret) {
intel_soc_dts_iosf_exit(
proc_priv->soc_dts);
pci_disable_msi(pdev);
proc_priv->soc_dts = NULL;
}
}
} else
dev_err(&pdev->dev, "No auxiliary DTSs enabled\n");
}
return 0; return 0;
} }
static void proc_thermal_pci_remove(struct pci_dev *pdev) static void proc_thermal_pci_remove(struct pci_dev *pdev)
{ {
proc_thermal_remove(pci_get_drvdata(pdev)); struct proc_thermal_device *proc_priv = pci_get_drvdata(pdev);
if (proc_priv->soc_dts) {
intel_soc_dts_iosf_exit(proc_priv->soc_dts);
if (pdev->irq) {
free_irq(pdev->irq, pdev);
pci_disable_msi(pdev);
}
}
proc_thermal_remove(proc_priv);
pci_disable_device(pdev); pci_disable_device(pdev);
} }
static const struct pci_device_id proc_thermal_pci_ids[] = { static const struct pci_device_id proc_thermal_pci_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BDW_THERMAL)}, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BDW_THERMAL)},
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_HSB_THERMAL)}, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_HSB_THERMAL)},
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_SKL_THERMAL)},
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BSW_THERMAL)}, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BSW_THERMAL)},
{ 0, }, { 0, },
}; };
......
...@@ -697,6 +697,7 @@ static const struct x86_cpu_id intel_powerclamp_ids[] __initconst = { ...@@ -697,6 +697,7 @@ static const struct x86_cpu_id intel_powerclamp_ids[] __initconst = {
{ X86_VENDOR_INTEL, 6, 0x4d}, { X86_VENDOR_INTEL, 6, 0x4d},
{ X86_VENDOR_INTEL, 6, 0x4f}, { X86_VENDOR_INTEL, 6, 0x4f},
{ X86_VENDOR_INTEL, 6, 0x56}, { X86_VENDOR_INTEL, 6, 0x56},
{ X86_VENDOR_INTEL, 6, 0x57},
{} {}
}; };
MODULE_DEVICE_TABLE(x86cpu, intel_powerclamp_ids); MODULE_DEVICE_TABLE(x86cpu, intel_powerclamp_ids);
......
This diff is collapsed.
This diff is collapsed.
/*
* intel_soc_dts_iosf.h
* Copyright (c) 2015, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#ifndef _INTEL_SOC_DTS_IOSF_CORE_H
#define _INTEL_SOC_DTS_IOSF_CORE_H
#include <linux/thermal.h>
/* DTS0 and DTS 1 */
#define SOC_MAX_DTS_SENSORS 2
enum intel_soc_dts_interrupt_type {
INTEL_SOC_DTS_INTERRUPT_NONE,
INTEL_SOC_DTS_INTERRUPT_APIC,
INTEL_SOC_DTS_INTERRUPT_MSI,
INTEL_SOC_DTS_INTERRUPT_SCI,
INTEL_SOC_DTS_INTERRUPT_SMI,
};
struct intel_soc_dts_sensors;
struct intel_soc_dts_sensor_entry {
int id;
u32 temp_mask;
u32 temp_shift;
u32 store_status;
u32 trip_mask;
u32 trip_count;
enum thermal_trip_type trip_types[2];
struct thermal_zone_device *tzone;
struct intel_soc_dts_sensors *sensors;
};
struct intel_soc_dts_sensors {
u32 tj_max;
spinlock_t intr_notify_lock;
struct mutex dts_update_lock;
enum intel_soc_dts_interrupt_type intr_type;
struct intel_soc_dts_sensor_entry soc_dts[SOC_MAX_DTS_SENSORS];
};
struct intel_soc_dts_sensors *intel_soc_dts_iosf_init(
enum intel_soc_dts_interrupt_type intr_type, int trip_count,
int read_only_trip_count);
void intel_soc_dts_iosf_exit(struct intel_soc_dts_sensors *sensors);
void intel_soc_dts_iosf_interrupt_handler(
struct intel_soc_dts_sensors *sensors);
int intel_soc_dts_iosf_add_read_only_critical_trip(
struct intel_soc_dts_sensors *sensors, int critical_offset);
#endif
This diff is collapsed.
...@@ -58,6 +58,8 @@ struct __thermal_bind_params { ...@@ -58,6 +58,8 @@ struct __thermal_bind_params {
* @mode: current thermal zone device mode (enabled/disabled) * @mode: current thermal zone device mode (enabled/disabled)
* @passive_delay: polling interval while passive cooling is activated * @passive_delay: polling interval while passive cooling is activated
* @polling_delay: zone polling interval * @polling_delay: zone polling interval
* @slope: slope of the temperature adjustment curve
* @offset: offset of the temperature adjustment curve
* @ntrips: number of trip points * @ntrips: number of trip points
* @trips: an array of trip points (0..ntrips - 1) * @trips: an array of trip points (0..ntrips - 1)
* @num_tbps: number of thermal bind params * @num_tbps: number of thermal bind params
...@@ -70,6 +72,8 @@ struct __thermal_zone { ...@@ -70,6 +72,8 @@ struct __thermal_zone {
enum thermal_device_mode mode; enum thermal_device_mode mode;
int passive_delay; int passive_delay;
int polling_delay; int polling_delay;
int slope;
int offset;
/* trip data */ /* trip data */
int ntrips; int ntrips;
...@@ -227,7 +231,8 @@ static int of_thermal_bind(struct thermal_zone_device *thermal, ...@@ -227,7 +231,8 @@ static int of_thermal_bind(struct thermal_zone_device *thermal,
ret = thermal_zone_bind_cooling_device(thermal, ret = thermal_zone_bind_cooling_device(thermal,
tbp->trip_id, cdev, tbp->trip_id, cdev,
tbp->max, tbp->max,
tbp->min); tbp->min,
tbp->usage);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -581,7 +586,7 @@ static int thermal_of_populate_bind_params(struct device_node *np, ...@@ -581,7 +586,7 @@ static int thermal_of_populate_bind_params(struct device_node *np,
u32 prop; u32 prop;
/* Default weight. Usage is optional */ /* Default weight. Usage is optional */
__tbp->usage = 0; __tbp->usage = THERMAL_WEIGHT_DEFAULT;
ret = of_property_read_u32(np, "contribution", &prop); ret = of_property_read_u32(np, "contribution", &prop);
if (ret == 0) if (ret == 0)
__tbp->usage = prop; __tbp->usage = prop;
...@@ -715,7 +720,7 @@ static int thermal_of_populate_trip(struct device_node *np, ...@@ -715,7 +720,7 @@ static int thermal_of_populate_trip(struct device_node *np,
* @np parameter and fills the read data into a __thermal_zone data structure * @np parameter and fills the read data into a __thermal_zone data structure
* and return this pointer. * and return this pointer.
* *
* TODO: Missing properties to parse: thermal-sensor-names and coefficients * TODO: Missing properties to parse: thermal-sensor-names
* *
* Return: On success returns a valid struct __thermal_zone, * Return: On success returns a valid struct __thermal_zone,
* otherwise, it returns a corresponding ERR_PTR(). Caller must * otherwise, it returns a corresponding ERR_PTR(). Caller must
...@@ -727,7 +732,7 @@ thermal_of_build_thermal_zone(struct device_node *np) ...@@ -727,7 +732,7 @@ thermal_of_build_thermal_zone(struct device_node *np)
struct device_node *child = NULL, *gchild; struct device_node *child = NULL, *gchild;
struct __thermal_zone *tz; struct __thermal_zone *tz;
int ret, i; int ret, i;
u32 prop; u32 prop, coef[2];
if (!np) { if (!np) {
pr_err("no thermal zone np\n"); pr_err("no thermal zone np\n");
...@@ -752,6 +757,20 @@ thermal_of_build_thermal_zone(struct device_node *np) ...@@ -752,6 +757,20 @@ thermal_of_build_thermal_zone(struct device_node *np)
} }
tz->polling_delay = prop; tz->polling_delay = prop;
/*
* REVIST: for now, the thermal framework supports only
* one sensor per thermal zone. Thus, we are considering
* only the first two values as slope and offset.
*/
ret = of_property_read_u32_array(np, "coefficients", coef, 2);
if (ret == 0) {
tz->slope = coef[0];
tz->offset = coef[1];
} else {
tz->slope = 1;
tz->offset = 0;
}
/* trips */ /* trips */
child = of_get_child_by_name(np, "trips"); child = of_get_child_by_name(np, "trips");
...@@ -865,6 +884,8 @@ int __init of_parse_thermal_zones(void) ...@@ -865,6 +884,8 @@ int __init of_parse_thermal_zones(void)
for_each_child_of_node(np, child) { for_each_child_of_node(np, child) {
struct thermal_zone_device *zone; struct thermal_zone_device *zone;
struct thermal_zone_params *tzp; struct thermal_zone_params *tzp;
int i, mask = 0;
u32 prop;
/* Check whether child is enabled or not */ /* Check whether child is enabled or not */
if (!of_device_is_available(child)) if (!of_device_is_available(child))
...@@ -891,8 +912,18 @@ int __init of_parse_thermal_zones(void) ...@@ -891,8 +912,18 @@ int __init of_parse_thermal_zones(void)
/* No hwmon because there might be hwmon drivers registering */ /* No hwmon because there might be hwmon drivers registering */
tzp->no_hwmon = true; tzp->no_hwmon = true;
if (!of_property_read_u32(child, "sustainable-power", &prop))
tzp->sustainable_power = prop;
for (i = 0; i < tz->ntrips; i++)
mask |= 1 << i;
/* these two are left for temperature drivers to use */
tzp->slope = tz->slope;
tzp->offset = tz->offset;
zone = thermal_zone_device_register(child->name, tz->ntrips, zone = thermal_zone_device_register(child->name, tz->ntrips,
0, tz, mask, tz,
ops, tzp, ops, tzp,
tz->passive_delay, tz->passive_delay,
tz->polling_delay); tz->polling_delay);
......
This diff is collapsed.
/*
* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/iio/consumer.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/thermal.h>
#define QPNP_TM_REG_TYPE 0x04
#define QPNP_TM_REG_SUBTYPE 0x05
#define QPNP_TM_REG_STATUS 0x08
#define QPNP_TM_REG_SHUTDOWN_CTRL1 0x40
#define QPNP_TM_REG_ALARM_CTRL 0x46
#define QPNP_TM_TYPE 0x09
#define QPNP_TM_SUBTYPE 0x08
#define STATUS_STAGE_MASK 0x03
#define SHUTDOWN_CTRL1_THRESHOLD_MASK 0x03
#define ALARM_CTRL_FORCE_ENABLE 0x80
/*
* Trip point values based on threshold control
* 0 = {105 C, 125 C, 145 C}
* 1 = {110 C, 130 C, 150 C}
* 2 = {115 C, 135 C, 155 C}
* 3 = {120 C, 140 C, 160 C}
*/
#define TEMP_STAGE_STEP 20000 /* Stage step: 20.000 C */
#define TEMP_STAGE_HYSTERESIS 2000
#define TEMP_THRESH_MIN 105000 /* Threshold Min: 105 C */
#define TEMP_THRESH_STEP 5000 /* Threshold step: 5 C */
#define THRESH_MIN 0
/* Temperature in Milli Celsius reported during stage 0 if no ADC is present */
#define DEFAULT_TEMP 37000
struct qpnp_tm_chip {
struct regmap *map;
struct thermal_zone_device *tz_dev;
long temp;
unsigned int thresh;
unsigned int stage;
unsigned int prev_stage;
unsigned int base;
struct iio_channel *adc;
};
static int qpnp_tm_read(struct qpnp_tm_chip *chip, u16 addr, u8 *data)
{
unsigned int val;
int ret;
ret = regmap_read(chip->map, chip->base + addr, &val);
if (ret < 0)
return ret;
*data = val;
return 0;
}
static int qpnp_tm_write(struct qpnp_tm_chip *chip, u16 addr, u8 data)
{
return regmap_write(chip->map, chip->base + addr, data);
}
/*
* This function updates the internal temp value based on the
* current thermal stage and threshold as well as the previous stage
*/
static int qpnp_tm_update_temp_no_adc(struct qpnp_tm_chip *chip)
{
unsigned int stage;
int ret;
u8 reg = 0;
ret = qpnp_tm_read(chip, QPNP_TM_REG_STATUS, &reg);
if (ret < 0)
return ret;
stage = reg & STATUS_STAGE_MASK;
if (stage > chip->stage) {
/* increasing stage, use lower bound */
chip->temp = (stage - 1) * TEMP_STAGE_STEP +
chip->thresh * TEMP_THRESH_STEP +
TEMP_STAGE_HYSTERESIS + TEMP_THRESH_MIN;
} else if (stage < chip->stage) {
/* decreasing stage, use upper bound */
chip->temp = stage * TEMP_STAGE_STEP +
chip->thresh * TEMP_THRESH_STEP -
TEMP_STAGE_HYSTERESIS + TEMP_THRESH_MIN;
}
chip->stage = stage;
return 0;
}
static int qpnp_tm_get_temp(void *data, long *temp)
{
struct qpnp_tm_chip *chip = data;
int ret, mili_celsius;
if (!temp)
return -EINVAL;
if (IS_ERR(chip->adc)) {
ret = qpnp_tm_update_temp_no_adc(chip);
if (ret < 0)
return ret;
} else {
ret = iio_read_channel_processed(chip->adc, &mili_celsius);
if (ret < 0)
return ret;
chip->temp = mili_celsius;
}
*temp = chip->temp < 0 ? 0 : chip->temp;
return 0;
}
static const struct thermal_zone_of_device_ops qpnp_tm_sensor_ops = {
.get_temp = qpnp_tm_get_temp,
};
static irqreturn_t qpnp_tm_isr(int irq, void *data)
{
struct qpnp_tm_chip *chip = data;
thermal_zone_device_update(chip->tz_dev);
return IRQ_HANDLED;
}
/*
* This function initializes the internal temp value based on only the
* current thermal stage and threshold. Setup threshold control and
* disable shutdown override.
*/
static int qpnp_tm_init(struct qpnp_tm_chip *chip)
{
int ret;
u8 reg;
chip->thresh = THRESH_MIN;
chip->temp = DEFAULT_TEMP;
ret = qpnp_tm_read(chip, QPNP_TM_REG_STATUS, &reg);
if (ret < 0)
return ret;
chip->stage = reg & STATUS_STAGE_MASK;
if (chip->stage)
chip->temp = chip->thresh * TEMP_THRESH_STEP +
(chip->stage - 1) * TEMP_STAGE_STEP +
TEMP_THRESH_MIN;
/*
* Set threshold and disable software override of stage 2 and 3
* shutdowns.
*/
reg = chip->thresh & SHUTDOWN_CTRL1_THRESHOLD_MASK;
ret = qpnp_tm_write(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, reg);
if (ret < 0)
return ret;
/* Enable the thermal alarm PMIC module in always-on mode. */
reg = ALARM_CTRL_FORCE_ENABLE;
ret = qpnp_tm_write(chip, QPNP_TM_REG_ALARM_CTRL, reg);
return ret;
}
static int qpnp_tm_probe(struct platform_device *pdev)
{
struct qpnp_tm_chip *chip;
struct device_node *node;
u8 type, subtype;
u32 res[2];
int ret, irq;
node = pdev->dev.of_node;
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
return -ENOMEM;
dev_set_drvdata(&pdev->dev, chip);
chip->map = dev_get_regmap(pdev->dev.parent, NULL);
if (!chip->map)
return -ENXIO;
ret = of_property_read_u32_array(node, "reg", res, 2);
if (ret < 0)
return ret;
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return irq;
/* ADC based measurements are optional */
chip->adc = iio_channel_get(&pdev->dev, "thermal");
if (PTR_ERR(chip->adc) == -EPROBE_DEFER)
return PTR_ERR(chip->adc);
chip->base = res[0];
ret = qpnp_tm_read(chip, QPNP_TM_REG_TYPE, &type);
if (ret < 0) {
dev_err(&pdev->dev, "could not read type\n");
goto fail;
}
ret = qpnp_tm_read(chip, QPNP_TM_REG_SUBTYPE, &subtype);
if (ret < 0) {
dev_err(&pdev->dev, "could not read subtype\n");
goto fail;
}
if (type != QPNP_TM_TYPE || subtype != QPNP_TM_SUBTYPE) {
dev_err(&pdev->dev, "invalid type 0x%02x or subtype 0x%02x\n",
type, subtype);
ret = -ENODEV;
goto fail;
}
ret = qpnp_tm_init(chip);
if (ret < 0) {
dev_err(&pdev->dev, "init failed\n");
goto fail;
}
ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, qpnp_tm_isr,
IRQF_ONESHOT, node->name, chip);
if (ret < 0)
goto fail;
chip->tz_dev = thermal_zone_of_sensor_register(&pdev->dev, 0, chip,
&qpnp_tm_sensor_ops);
if (IS_ERR(chip->tz_dev)) {
dev_err(&pdev->dev, "failed to register sensor\n");
ret = PTR_ERR(chip->tz_dev);
goto fail;
}
return 0;
fail:
if (!IS_ERR(chip->adc))
iio_channel_release(chip->adc);
return ret;
}
static int qpnp_tm_remove(struct platform_device *pdev)
{
struct qpnp_tm_chip *chip = dev_get_drvdata(&pdev->dev);
thermal_zone_of_sensor_unregister(&pdev->dev, chip->tz_dev);
if (!IS_ERR(chip->adc))
iio_channel_release(chip->adc);
return 0;
}
static const struct of_device_id qpnp_tm_match_table[] = {
{ .compatible = "qcom,spmi-temp-alarm" },
{ }
};
MODULE_DEVICE_TABLE(of, qpnp_tm_match_table);
static struct platform_driver qpnp_tm_driver = {
.driver = {
.name = "spmi-temp-alarm",
.of_match_table = qpnp_tm_match_table,
},
.probe = qpnp_tm_probe,
.remove = qpnp_tm_remove,
};
module_platform_driver(qpnp_tm_driver);
MODULE_ALIAS("platform:spmi-temp-alarm");
MODULE_DESCRIPTION("QPNP PMIC Temperature Alarm driver");
MODULE_LICENSE("GPL v2");
...@@ -97,6 +97,32 @@ ...@@ -97,6 +97,32 @@
#define EXYNOS4412_MUX_ADDR_VALUE 6 #define EXYNOS4412_MUX_ADDR_VALUE 6
#define EXYNOS4412_MUX_ADDR_SHIFT 20 #define EXYNOS4412_MUX_ADDR_SHIFT 20
/* Exynos5433 specific registers */
#define EXYNOS5433_TMU_REG_CONTROL1 0x024
#define EXYNOS5433_TMU_SAMPLING_INTERVAL 0x02c
#define EXYNOS5433_TMU_COUNTER_VALUE0 0x030
#define EXYNOS5433_TMU_COUNTER_VALUE1 0x034
#define EXYNOS5433_TMU_REG_CURRENT_TEMP1 0x044
#define EXYNOS5433_THD_TEMP_RISE3_0 0x050
#define EXYNOS5433_THD_TEMP_RISE7_4 0x054
#define EXYNOS5433_THD_TEMP_FALL3_0 0x060
#define EXYNOS5433_THD_TEMP_FALL7_4 0x064
#define EXYNOS5433_TMU_REG_INTEN 0x0c0
#define EXYNOS5433_TMU_REG_INTPEND 0x0c8
#define EXYNOS5433_TMU_EMUL_CON 0x110
#define EXYNOS5433_TMU_PD_DET_EN 0x130
#define EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT 16
#define EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT 23
#define EXYNOS5433_TRIMINFO_SENSOR_ID_MASK \
(0xf << EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT)
#define EXYNOS5433_TRIMINFO_CALIB_SEL_MASK BIT(23)
#define EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING 0
#define EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING 1
#define EXYNOS5433_PD_DET_EN 1
/*exynos5440 specific registers*/ /*exynos5440 specific registers*/
#define EXYNOS5440_TMU_S0_7_TRIM 0x000 #define EXYNOS5440_TMU_S0_7_TRIM 0x000
#define EXYNOS5440_TMU_S0_7_CTRL 0x020 #define EXYNOS5440_TMU_S0_7_CTRL 0x020
...@@ -484,6 +510,101 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev) ...@@ -484,6 +510,101 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
return ret; return ret;
} }
static int exynos5433_tmu_initialize(struct platform_device *pdev)
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct exynos_tmu_platform_data *pdata = data->pdata;
struct thermal_zone_device *tz = data->tzd;
unsigned int status, trim_info;
unsigned int rising_threshold = 0, falling_threshold = 0;
unsigned long temp, temp_hist;
int ret = 0, threshold_code, i, sensor_id, cal_type;
status = readb(data->base + EXYNOS_TMU_REG_STATUS);
if (!status) {
ret = -EBUSY;
goto out;
}
trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
sanitize_temp_error(data, trim_info);
/* Read the temperature sensor id */
sensor_id = (trim_info & EXYNOS5433_TRIMINFO_SENSOR_ID_MASK)
>> EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT;
dev_info(&pdev->dev, "Temperature sensor ID: 0x%x\n", sensor_id);
/* Read the calibration mode */
writel(trim_info, data->base + EXYNOS_TMU_REG_TRIMINFO);
cal_type = (trim_info & EXYNOS5433_TRIMINFO_CALIB_SEL_MASK)
>> EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT;
switch (cal_type) {
case EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING:
pdata->cal_type = TYPE_ONE_POINT_TRIMMING;
break;
case EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING:
pdata->cal_type = TYPE_TWO_POINT_TRIMMING;
break;
default:
pdata->cal_type = TYPE_ONE_POINT_TRIMMING;
break;
};
dev_info(&pdev->dev, "Calibration type is %d-point calibration\n",
cal_type ? 2 : 1);
/* Write temperature code for rising and falling threshold */
for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
int rising_reg_offset, falling_reg_offset;
int j = 0;
switch (i) {
case 0:
case 1:
case 2:
case 3:
rising_reg_offset = EXYNOS5433_THD_TEMP_RISE3_0;
falling_reg_offset = EXYNOS5433_THD_TEMP_FALL3_0;
j = i;
break;
case 4:
case 5:
case 6:
case 7:
rising_reg_offset = EXYNOS5433_THD_TEMP_RISE7_4;
falling_reg_offset = EXYNOS5433_THD_TEMP_FALL7_4;
j = i - 4;
break;
default:
continue;
}
/* Write temperature code for rising threshold */
tz->ops->get_trip_temp(tz, i, &temp);
temp /= MCELSIUS;
threshold_code = temp_to_code(data, temp);
rising_threshold = readl(data->base + rising_reg_offset);
rising_threshold |= (threshold_code << j * 8);
writel(rising_threshold, data->base + rising_reg_offset);
/* Write temperature code for falling threshold */
tz->ops->get_trip_hyst(tz, i, &temp_hist);
temp_hist = temp - (temp_hist / MCELSIUS);
threshold_code = temp_to_code(data, temp_hist);
falling_threshold = readl(data->base + falling_reg_offset);
falling_threshold &= ~(0xff << j * 8);
falling_threshold |= (threshold_code << j * 8);
writel(falling_threshold, data->base + falling_reg_offset);
}
data->tmu_clear_irqs(data);
out:
return ret;
}
static int exynos5440_tmu_initialize(struct platform_device *pdev) static int exynos5440_tmu_initialize(struct platform_device *pdev)
{ {
struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct exynos_tmu_data *data = platform_get_drvdata(pdev);
...@@ -643,6 +764,48 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on) ...@@ -643,6 +764,48 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
writel(con, data->base + EXYNOS_TMU_REG_CONTROL); writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
} }
static void exynos5433_tmu_control(struct platform_device *pdev, bool on)
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tz = data->tzd;
unsigned int con, interrupt_en, pd_det_en;
con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
if (on) {
con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
interrupt_en =
(of_thermal_is_trip_valid(tz, 7)
<< EXYNOS7_TMU_INTEN_RISE7_SHIFT) |
(of_thermal_is_trip_valid(tz, 6)
<< EXYNOS7_TMU_INTEN_RISE6_SHIFT) |
(of_thermal_is_trip_valid(tz, 5)
<< EXYNOS7_TMU_INTEN_RISE5_SHIFT) |
(of_thermal_is_trip_valid(tz, 4)
<< EXYNOS7_TMU_INTEN_RISE4_SHIFT) |
(of_thermal_is_trip_valid(tz, 3)
<< EXYNOS7_TMU_INTEN_RISE3_SHIFT) |
(of_thermal_is_trip_valid(tz, 2)
<< EXYNOS7_TMU_INTEN_RISE2_SHIFT) |
(of_thermal_is_trip_valid(tz, 1)
<< EXYNOS7_TMU_INTEN_RISE1_SHIFT) |
(of_thermal_is_trip_valid(tz, 0)
<< EXYNOS7_TMU_INTEN_RISE0_SHIFT);
interrupt_en |=
interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
} else {
con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
interrupt_en = 0; /* Disable all interrupts */
}
pd_det_en = on ? EXYNOS5433_PD_DET_EN : 0;
writel(pd_det_en, data->base + EXYNOS5433_TMU_PD_DET_EN);
writel(interrupt_en, data->base + EXYNOS5433_TMU_REG_INTEN);
writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
}
static void exynos5440_tmu_control(struct platform_device *pdev, bool on) static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
{ {
struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct exynos_tmu_data *data = platform_get_drvdata(pdev);
...@@ -770,6 +933,8 @@ static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data, ...@@ -770,6 +933,8 @@ static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data,
if (data->soc == SOC_ARCH_EXYNOS5260) if (data->soc == SOC_ARCH_EXYNOS5260)
emul_con = EXYNOS5260_EMUL_CON; emul_con = EXYNOS5260_EMUL_CON;
if (data->soc == SOC_ARCH_EXYNOS5433)
emul_con = EXYNOS5433_TMU_EMUL_CON;
else if (data->soc == SOC_ARCH_EXYNOS7) else if (data->soc == SOC_ARCH_EXYNOS7)
emul_con = EXYNOS7_TMU_REG_EMUL_CON; emul_con = EXYNOS7_TMU_REG_EMUL_CON;
else else
...@@ -882,6 +1047,9 @@ static void exynos4210_tmu_clear_irqs(struct exynos_tmu_data *data) ...@@ -882,6 +1047,9 @@ static void exynos4210_tmu_clear_irqs(struct exynos_tmu_data *data)
} else if (data->soc == SOC_ARCH_EXYNOS7) { } else if (data->soc == SOC_ARCH_EXYNOS7) {
tmu_intstat = EXYNOS7_TMU_REG_INTPEND; tmu_intstat = EXYNOS7_TMU_REG_INTPEND;
tmu_intclear = EXYNOS7_TMU_REG_INTPEND; tmu_intclear = EXYNOS7_TMU_REG_INTPEND;
} else if (data->soc == SOC_ARCH_EXYNOS5433) {
tmu_intstat = EXYNOS5433_TMU_REG_INTPEND;
tmu_intclear = EXYNOS5433_TMU_REG_INTPEND;
} else { } else {
tmu_intstat = EXYNOS_TMU_REG_INTSTAT; tmu_intstat = EXYNOS_TMU_REG_INTSTAT;
tmu_intclear = EXYNOS_TMU_REG_INTCLEAR; tmu_intclear = EXYNOS_TMU_REG_INTCLEAR;
...@@ -926,6 +1094,7 @@ static const struct of_device_id exynos_tmu_match[] = { ...@@ -926,6 +1094,7 @@ static const struct of_device_id exynos_tmu_match[] = {
{ .compatible = "samsung,exynos5260-tmu", }, { .compatible = "samsung,exynos5260-tmu", },
{ .compatible = "samsung,exynos5420-tmu", }, { .compatible = "samsung,exynos5420-tmu", },
{ .compatible = "samsung,exynos5420-tmu-ext-triminfo", }, { .compatible = "samsung,exynos5420-tmu-ext-triminfo", },
{ .compatible = "samsung,exynos5433-tmu", },
{ .compatible = "samsung,exynos5440-tmu", }, { .compatible = "samsung,exynos5440-tmu", },
{ .compatible = "samsung,exynos7-tmu", }, { .compatible = "samsung,exynos7-tmu", },
{ /* sentinel */ }, { /* sentinel */ },
...@@ -949,6 +1118,8 @@ static int exynos_of_get_soc_type(struct device_node *np) ...@@ -949,6 +1118,8 @@ static int exynos_of_get_soc_type(struct device_node *np)
else if (of_device_is_compatible(np, else if (of_device_is_compatible(np,
"samsung,exynos5420-tmu-ext-triminfo")) "samsung,exynos5420-tmu-ext-triminfo"))
return SOC_ARCH_EXYNOS5420_TRIMINFO; return SOC_ARCH_EXYNOS5420_TRIMINFO;
else if (of_device_is_compatible(np, "samsung,exynos5433-tmu"))
return SOC_ARCH_EXYNOS5433;
else if (of_device_is_compatible(np, "samsung,exynos5440-tmu")) else if (of_device_is_compatible(np, "samsung,exynos5440-tmu"))
return SOC_ARCH_EXYNOS5440; return SOC_ARCH_EXYNOS5440;
else if (of_device_is_compatible(np, "samsung,exynos7-tmu")) else if (of_device_is_compatible(np, "samsung,exynos7-tmu"))
...@@ -1069,6 +1240,13 @@ static int exynos_map_dt_data(struct platform_device *pdev) ...@@ -1069,6 +1240,13 @@ static int exynos_map_dt_data(struct platform_device *pdev)
data->tmu_set_emulation = exynos4412_tmu_set_emulation; data->tmu_set_emulation = exynos4412_tmu_set_emulation;
data->tmu_clear_irqs = exynos4210_tmu_clear_irqs; data->tmu_clear_irqs = exynos4210_tmu_clear_irqs;
break; break;
case SOC_ARCH_EXYNOS5433:
data->tmu_initialize = exynos5433_tmu_initialize;
data->tmu_control = exynos5433_tmu_control;
data->tmu_read = exynos4412_tmu_read;
data->tmu_set_emulation = exynos4412_tmu_set_emulation;
data->tmu_clear_irqs = exynos4210_tmu_clear_irqs;
break;
case SOC_ARCH_EXYNOS5440: case SOC_ARCH_EXYNOS5440:
data->tmu_initialize = exynos5440_tmu_initialize; data->tmu_initialize = exynos5440_tmu_initialize;
data->tmu_control = exynos5440_tmu_control; data->tmu_control = exynos5440_tmu_control;
...@@ -1172,7 +1350,9 @@ static int exynos_tmu_probe(struct platform_device *pdev) ...@@ -1172,7 +1350,9 @@ static int exynos_tmu_probe(struct platform_device *pdev)
goto err_clk_sec; goto err_clk_sec;
} }
if (data->soc == SOC_ARCH_EXYNOS7) { switch (data->soc) {
case SOC_ARCH_EXYNOS5433:
case SOC_ARCH_EXYNOS7:
data->sclk = devm_clk_get(&pdev->dev, "tmu_sclk"); data->sclk = devm_clk_get(&pdev->dev, "tmu_sclk");
if (IS_ERR(data->sclk)) { if (IS_ERR(data->sclk)) {
dev_err(&pdev->dev, "Failed to get sclk\n"); dev_err(&pdev->dev, "Failed to get sclk\n");
...@@ -1184,7 +1364,10 @@ static int exynos_tmu_probe(struct platform_device *pdev) ...@@ -1184,7 +1364,10 @@ static int exynos_tmu_probe(struct platform_device *pdev)
goto err_clk; goto err_clk;
} }
} }
} break;
default:
break;
};
ret = exynos_tmu_initialize(pdev); ret = exynos_tmu_initialize(pdev);
if (ret) { if (ret) {
......
...@@ -33,6 +33,7 @@ enum soc_type { ...@@ -33,6 +33,7 @@ enum soc_type {
SOC_ARCH_EXYNOS5260, SOC_ARCH_EXYNOS5260,
SOC_ARCH_EXYNOS5420, SOC_ARCH_EXYNOS5420,
SOC_ARCH_EXYNOS5420_TRIMINFO, SOC_ARCH_EXYNOS5420_TRIMINFO,
SOC_ARCH_EXYNOS5433,
SOC_ARCH_EXYNOS5440, SOC_ARCH_EXYNOS5440,
SOC_ARCH_EXYNOS7, SOC_ARCH_EXYNOS7,
}; };
......
This diff is collapsed.
...@@ -46,8 +46,11 @@ struct thermal_instance { ...@@ -46,8 +46,11 @@ struct thermal_instance {
unsigned long target; /* expected cooling state */ unsigned long target; /* expected cooling state */
char attr_name[THERMAL_NAME_LENGTH]; char attr_name[THERMAL_NAME_LENGTH];
struct device_attribute attr; struct device_attribute attr;
char weight_attr_name[THERMAL_NAME_LENGTH];
struct device_attribute weight_attr;
struct list_head tz_node; /* node in tz->thermal_instances */ struct list_head tz_node; /* node in tz->thermal_instances */
struct list_head cdev_node; /* node in cdev->thermal_instances */ struct list_head cdev_node; /* node in cdev->thermal_instances */
unsigned int weight; /* The weight of the cooling device */
}; };
int thermal_register_governor(struct thermal_governor *); int thermal_register_governor(struct thermal_governor *);
...@@ -85,6 +88,14 @@ static inline int thermal_gov_user_space_register(void) { return 0; } ...@@ -85,6 +88,14 @@ static inline int thermal_gov_user_space_register(void) { return 0; }
static inline void thermal_gov_user_space_unregister(void) {} static inline void thermal_gov_user_space_unregister(void) {}
#endif /* CONFIG_THERMAL_GOV_USER_SPACE */ #endif /* CONFIG_THERMAL_GOV_USER_SPACE */
#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR
int thermal_gov_power_allocator_register(void);
void thermal_gov_power_allocator_unregister(void);
#else
static inline int thermal_gov_power_allocator_register(void) { return 0; }
static inline void thermal_gov_power_allocator_unregister(void) {}
#endif /* CONFIG_THERMAL_GOV_POWER_ALLOCATOR */
/* device tree support */ /* device tree support */
#ifdef CONFIG_THERMAL_OF #ifdef CONFIG_THERMAL_OF
int of_parse_thermal_zones(void); int of_parse_thermal_zones(void);
......
This diff is collapsed.
...@@ -75,7 +75,7 @@ static inline int ti_thermal_hotspot_temperature(int t, int s, int c) ...@@ -75,7 +75,7 @@ static inline int ti_thermal_hotspot_temperature(int t, int s, int c)
} }
/* thermal zone ops */ /* thermal zone ops */
/* Get temperature callback function for thermal zone*/ /* Get temperature callback function for thermal zone */
static inline int __ti_thermal_get_temp(void *devdata, long *temp) static inline int __ti_thermal_get_temp(void *devdata, long *temp)
{ {
struct thermal_zone_device *pcb_tz = NULL; struct thermal_zone_device *pcb_tz = NULL;
...@@ -146,7 +146,8 @@ static int ti_thermal_bind(struct thermal_zone_device *thermal, ...@@ -146,7 +146,8 @@ static int ti_thermal_bind(struct thermal_zone_device *thermal,
return thermal_zone_bind_cooling_device(thermal, 0, cdev, return thermal_zone_bind_cooling_device(thermal, 0, cdev,
/* bind with min and max states defined by cpu_cooling */ /* bind with min and max states defined by cpu_cooling */
THERMAL_NO_LIMIT, THERMAL_NO_LIMIT,
THERMAL_NO_LIMIT); THERMAL_NO_LIMIT,
THERMAL_WEIGHT_DEFAULT);
} }
/* Unbind callback functions for thermal zone */ /* Unbind callback functions for thermal zone */
......
...@@ -68,7 +68,7 @@ struct phy_dev_entry { ...@@ -68,7 +68,7 @@ struct phy_dev_entry {
struct thermal_zone_device *tzone; struct thermal_zone_device *tzone;
}; };
static const struct thermal_zone_params pkg_temp_tz_params = { static struct thermal_zone_params pkg_temp_tz_params = {
.no_hwmon = true, .no_hwmon = true,
}; };
......
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
#include <linux/thermal.h> #include <linux/thermal.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
typedef int (*get_static_t)(cpumask_t *cpumask, int interval,
unsigned long voltage, u32 *power);
#ifdef CONFIG_CPU_THERMAL #ifdef CONFIG_CPU_THERMAL
/** /**
* cpufreq_cooling_register - function to create cpufreq cooling device. * cpufreq_cooling_register - function to create cpufreq cooling device.
...@@ -36,6 +39,10 @@ ...@@ -36,6 +39,10 @@
struct thermal_cooling_device * struct thermal_cooling_device *
cpufreq_cooling_register(const struct cpumask *clip_cpus); cpufreq_cooling_register(const struct cpumask *clip_cpus);
struct thermal_cooling_device *
cpufreq_power_cooling_register(const struct cpumask *clip_cpus,
u32 capacitance, get_static_t plat_static_func);
/** /**
* of_cpufreq_cooling_register - create cpufreq cooling device based on DT. * of_cpufreq_cooling_register - create cpufreq cooling device based on DT.
* @np: a valid struct device_node to the cooling device device tree node. * @np: a valid struct device_node to the cooling device device tree node.
...@@ -45,6 +52,12 @@ cpufreq_cooling_register(const struct cpumask *clip_cpus); ...@@ -45,6 +52,12 @@ cpufreq_cooling_register(const struct cpumask *clip_cpus);
struct thermal_cooling_device * struct thermal_cooling_device *
of_cpufreq_cooling_register(struct device_node *np, of_cpufreq_cooling_register(struct device_node *np,
const struct cpumask *clip_cpus); const struct cpumask *clip_cpus);
struct thermal_cooling_device *
of_cpufreq_power_cooling_register(struct device_node *np,
const struct cpumask *clip_cpus,
u32 capacitance,
get_static_t plat_static_func);
#else #else
static inline struct thermal_cooling_device * static inline struct thermal_cooling_device *
of_cpufreq_cooling_register(struct device_node *np, of_cpufreq_cooling_register(struct device_node *np,
...@@ -52,6 +65,15 @@ of_cpufreq_cooling_register(struct device_node *np, ...@@ -52,6 +65,15 @@ of_cpufreq_cooling_register(struct device_node *np,
{ {
return ERR_PTR(-ENOSYS); return ERR_PTR(-ENOSYS);
} }
static inline struct thermal_cooling_device *
of_cpufreq_power_cooling_register(struct device_node *np,
const struct cpumask *clip_cpus,
u32 capacitance,
get_static_t plat_static_func)
{
return NULL;
}
#endif #endif
/** /**
...@@ -67,12 +89,29 @@ cpufreq_cooling_register(const struct cpumask *clip_cpus) ...@@ -67,12 +89,29 @@ cpufreq_cooling_register(const struct cpumask *clip_cpus)
{ {
return ERR_PTR(-ENOSYS); return ERR_PTR(-ENOSYS);
} }
static inline struct thermal_cooling_device *
cpufreq_power_cooling_register(const struct cpumask *clip_cpus,
u32 capacitance, get_static_t plat_static_func)
{
return NULL;
}
static inline struct thermal_cooling_device * static inline struct thermal_cooling_device *
of_cpufreq_cooling_register(struct device_node *np, of_cpufreq_cooling_register(struct device_node *np,
const struct cpumask *clip_cpus) const struct cpumask *clip_cpus)
{ {
return ERR_PTR(-ENOSYS); return ERR_PTR(-ENOSYS);
} }
static inline struct thermal_cooling_device *
of_cpufreq_power_cooling_register(struct device_node *np,
const struct cpumask *clip_cpus,
u32 capacitance,
get_static_t plat_static_func)
{
return NULL;
}
static inline static inline
void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
{ {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment