1
0
Fork 0
Commit Graph

1352 Commits (4800bf7bc8c725e955fcbc6191cc872f43f506d3)

Author SHA1 Message Date
Linus Torvalds d547d44e5c Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
Pull thermal management updates from Zhang Rui:

 - Fix a use-after-free issue when unregistering a thermal cooling
   device (Dmitry Osipenko)

 - use power_efficient_wq for thermal worker to save more power (Jeson
   Gao)

* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
  thermal: core: using power_efficient_wq for thermal worker
  thermal: core: Fix use-after-free in thermal_cooling_device_destroy_sysfs
2018-10-31 11:28:12 -07:00
Linus Torvalds 0ef7791e2b Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal
Pull thermal SoC updates from Eduardo Valentin:
 "Several new things coming up. Specifics:

   - Rework of tsens and hisi thermal drivers

   - OF-thermal now allows sharing multiple cooling devices on maps

   - Added support for r8a7744 and R8A77970 on rcar thermal driver

   - Added support for r8a774a1 on rcar_gen3 thermal driver

   - New thermal driver stm32

   - Fixes on multiple thermal drivers: of-thermal, imx, qoriq, armada,
     qcom-spmi, rcar, da9062/61"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal: (41 commits)
  thermal: da9062/61: Prevent hardware access during system suspend
  thermal: rcar_thermal: Prevent doing work after unbind
  thermal: rcar_thermal: Prevent hardware access during system suspend
  thermal: rcar_gen3_thermal: add R8A77980 support
  dt-bindings: thermal: rcar-gen3-thermal: document R8A77980 bindings
  thermal: add stm32 thermal driver
  dt-bindings: stm32-thermal: add binding documentation
  thermal: rcar_thermal: add R8A77970 support
  dt-bindings: thermal: rcar-thermal: document R8A77970 bindings
  thermal: rcar_thermal: fix duplicate IRQ request
  dt-bindings: thermal: rcar: Add device tree support for r8a7744
  thermal/drivers/hisi: Add the dual clusters sensors for hi3660
  thermal/drivers/hisi: Add more sensors channel
  thermal/drivers/hisi: Remove pointless irq field
  thermal/drivers/hisi: Use platform_get_irq_byname
  thermal/drivers/hisi: Replace macro name with relevant sensor location
  thermal/drivers/hisi: Add multiple sensors support
  thermal/drivers/hisi: Prepare to support multiple sensors
  thermal/drivers/hisi: Factor out the probe functions
  thermal/drivers/hisi: Set the thermal zone private data to the sensor pointer
  ...
2018-10-26 12:04:29 -07:00
Geert Uytterhoeven 760eea43f8 thermal: da9062/61: Prevent hardware access during system suspend
The workqueue used for monitoring the hardware may run while the device
is already suspended.  Fix this by using the freezable system workqueue
instead, cfr. commit 51e20d0e3a ("thermal: Prevent polling from
happening during system suspend").

Fixes: 608567aac3 ("thermal: da9062/61: Thermal junction temperature monitoring driver")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-25 10:44:55 -07:00
Geert Uytterhoeven 697ee786f1 thermal: rcar_thermal: Prevent doing work after unbind
When testing bind/unbind on r8a7791/koelsch:

    WARNING: CPU: 1 PID: 697 at lib/debugobjects.c:329 debug_print_object+0x8c/0xb4
    ODEBUG: free active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x10

This happens if the workqueue runs after the device has been unbound.
Fix this by cancelling any queued work during remove.

Fixes: e0a5172e9e ("thermal: rcar: add interrupt support")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-25 10:44:55 -07:00
Geert Uytterhoeven 3a31386217 thermal: rcar_thermal: Prevent hardware access during system suspend
On r8a7791/koelsch, sometimes the following message is printed during
system suspend:

    rcar_thermal e61f0000.thermal: thermal sensor was broken

This happens if the workqueue runs while the device is already
suspended.  Fix this by using the freezable system workqueue instead,
cfr. commit 51e20d0e3a ("thermal: Prevent polling from happening
during system suspend").

Fixes: e0a5172e9e ("thermal: rcar: add interrupt support")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-25 10:44:54 -07:00
Sergei Shtylyov 853cbc1f2d thermal: rcar_gen3_thermal: add R8A77980 support
Add the R-Car V3H (R8A77980) SoC support to the R-Car gen3 thermal driver.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-25 10:44:53 -07:00
David HERNANDEZ SANCHEZ 1d69315560 thermal: add stm32 thermal driver
Add support for DTS thermal sensor that can be
found on some STM32 platforms.

This driver is based on OF and works in interrupt
mode.

It offers two temperature trip points:
passive and critical. The first is intended for
passive cooling notification while the second is
used for over-temperature reset.

Signed-off-by: David Hernandez Sanchez <david.hernandezsanchez@st.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-25 10:44:52 -07:00
Sergei Shtylyov 92ca366e9b thermal: rcar_thermal: add R8A77970 support
Add the R-Car V3M (R8A77970) SoC support to the R-Car gen2 thermal driver.
The hardware is the same as in the R-Car D3 (R8A77995) plus the CIVM status
register (we don't use).

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-25 10:44:51 -07:00
Sergei Shtylyov df016bbba6 thermal: rcar_thermal: fix duplicate IRQ request
The driver on R8A77995 requests the same IRQ twice since
platform_get_resource() is always called for the 1st IRQ resource.

Fixes: 1969d9dc20 ("thermal: rcar_thermal: add r8a77995 support")
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-25 10:44:49 -07:00
Daniel Lezcano 8c6c36846f thermal/drivers/hisi: Add the dual clusters sensors for hi3660
The code is ready to support multiple sensors on the hi3660. The DT
defines a thermal zone per cluster.

Add the little cluster sensor and let it bind with the thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:52:11 -07:00
Daniel Lezcano ce8c0700dc thermal/drivers/hisi: Add more sensors channel
Add the sensor channels id for the little, g3d and modem.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:50:41 -07:00
Daniel Lezcano a18e83e772 thermal/drivers/hisi: Remove pointless irq field
The irq field in the data structure is pointless as the scope of its
usage is just to request the interrupt. It can be replaced by a local
variable.

Use the 'ret' variable to get the interrupt number.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:50:08 -07:00
Daniel Lezcano 2cffaeff08 thermal/drivers/hisi: Use platform_get_irq_byname
As we have the interrupt names defines, replace platform_get_irq() by
platform_get_irq_byname(), so no confusion can be made when getting
the interrupt with the sensor id.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:46:29 -07:00
Daniel Lezcano a849eecee7 thermal/drivers/hisi: Replace macro name with relevant sensor location
Change the macro name in order to give a better indication of the
sensor location.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:46:08 -07:00
Daniel Lezcano 7edc5e406f thermal/drivers/hisi: Add multiple sensors support
Change the code as it is dealing with several sensors.

For git-bisect compatibility (compilation and booting), assume the DT
is not yet changed and we have a single interrupt.

Next changes will support multiple interrupt sorted by their name.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:45:12 -07:00
Daniel Lezcano 8c0ffc8f9a thermal/drivers/hisi: Prepare to support multiple sensors
Convert the 'sensor' field to a pointer and propagate the change in
the file. Havintg a pointer, gives us the opportunity to define
multiple sensors.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:44:23 -07:00
Daniel Lezcano 9bb4ec8d9e thermal/drivers/hisi: Factor out the probe functions
The hi6220 and the hi3660 probe functions are doing almost the same
operations, they can share 90% of their code.

Factor out the probe functions by moving the common code in the common
probe function.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:43:41 -07:00
Daniel Lezcano 49e778d1c7 thermal/drivers/hisi: Set the thermal zone private data to the sensor pointer
Store the sensor pointer in the thermal zone private data and use it
in the callback functions. That allows to continue the conversion to
sensor oriented code where the pointers are the sensors.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:42:41 -07:00
Daniel Lezcano 9c9ae8da71 thermal/drivers/hisi: Change the driver to be sensor oriented
In order to support multiple sensors, we have to change the code to
deal with sensors and not the hisi thermal structure.

Add a back pointer to the hisi thermal structure (containerof is not a
good option because later we convert the sensor field to a pointer).

Change the functions parameters to take a sensor instead of this hisi
thermal 'data' structure.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:42:19 -07:00
Daniel Lezcano c90aaeccc7 thermal/drivers/hisi: Change the platform data pointer to sensor ops
Group the temperature sensor specific ops into a single structure and
assign it to hisi thermal data structure.

Change the platform data pointer to reference the specific sensor ops
instead of the probe functions.

Moving out those allow to split the code to self-encapsulate the
sensor object.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:41:48 -07:00
Dan Carpenter d1d2c290b3 thermal: armada: fix a test in probe()
The platform_get_resource() function doesn't return error pointers, it
returns NULL on error.

Fixes: 3d4e51844a ("thermal: armada: convert driver to syscon register accesses")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:38:24 -07:00
Anson Huang b6ad3981ff thermal: imx: handle error path in one place to save duplicated code
During probe phase, the error path can be handled in one place and
use goto method to save many duplicated code.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:37:05 -07:00
Anson Huang 337a4aecda thermal: imx: improve error message
Remove the duplicated "from" to improve the error message.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:36:41 -07:00
Amit Kucheria c8c3b091b6 thermal: tsens: Check if the IP is correctly enabled by firmware
The SROT registers are initialised by the secure firmware at boot. We
don't have write access to the registers. Check if the block is enabled
before continuing.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:35:30 -07:00
Amit Kucheria c130a7602e thermal: tsens: Pass register offsets as private data
Registers have moved around across TSENS generations. For example, the
CTRL register was at offset 0x0 in the SROT region on msm8916 but is at
offset 0x4 in newer v2 based TSENS HW blocks.

Allow passing offsets of important registers so that we can continue to
use common functions.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:34:33 -07:00
Amit Kucheria a15525b5d9 thermal: tsens: Add the SROT address map
On platforms whose device trees specify two address spaces for TSENS, the
second one points to the SROT registers. Initialise the SROT map on those
platforms.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:33:48 -07:00
Amit Kucheria 67b0f5e064 thermal: tsens: Rename map field in order to add a second address map
The TSENS driver currently only uses a limited set of registers from the TM
address space. So it was ok to map just that set of registers and call it
"map".

We'd now like to map a second set: SROT registers to introduce new
functionality. Rename the "map" field to a more appropriate "tm_map".

The 8960 doesn't have a clear split between TM and SROT registers. To avoid
complicating the data structure, it will switchover to using tm_map for its
maps.

There is no functional change with this patch.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:33:23 -07:00
Amit Kucheria caac52bce6 thermal: tsens: Get rid of dead code
hw_id is dynamically allocated but not used anywhere. Get rid of dead
code.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:32:38 -07:00
Amit Kucheria 2d71d8ded5 thermal: tsens: Add SPDX license identifiers
The TSENS drivers use a GPL-2.0 license. Replace with equivalent SPDX
tags and delete the full license text.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:32:03 -07:00
Amit Kucheria bd7557f55a thermal: tsens: Prepare 8916 and 8974 tsens to use SROT and TM address space
We've already converted over the devicetree of platforms using v2
version of the TSENS IP to use two address spaces. Now prepare to
convert over the 8916 and 8974 platforms to use separate SROT and TM
address spaces.

This patch will work with device trees with one or two address spaces
because we set the tm_offset in commit 5b1283984f ("thermal: tsens:
Add support to split up register address space into two").

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:31:15 -07:00
Anson Huang 6017e2a9d7 thermal: qoriq: add i.mx8mq support
Add i.mx8mq specific compatible string.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:29:47 -07:00
Rob Herring 9b96566063 thermal: Convert to using %pOFn instead of device_node.name
In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-22 17:28:36 -07:00
Jeson Gao c2b59d279d thermal: core: using power_efficient_wq for thermal worker
For SMP systems, thermal worker should use power_efficient_wq in power
saving mode, that will make scheduler more flexible on selecting an active
core for running work handler to avoid keeping work handler always
running on a single core, that will save some power.

Even if 'power_efficient_wq' relevant configs are disabled
'system_freezable_power_efficient_wq' is identical to system_freezable_wq,
behavior is unchanged.

Signed-off-by: Jeson Gao <jeson.gao@unisoc.com>
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2018-10-10 21:48:50 +08:00
Dmitry Osipenko 3c58776827 thermal: core: Fix use-after-free in thermal_cooling_device_destroy_sysfs
This patch fixes use-after-free that was detected by KASAN. The bug is
triggered on a CPUFreq driver module unload by freeing 'cdev' on device
unregister and then using the freed structure during of the cdev's sysfs
data destruction. The solution is to unregister the sysfs at first, then
destroy sysfs data and finally release the cooling device.

Cc: <stable@vger.kernel.org> # v4.17+
Fixes: 8ea229511e ("thermal: Add cooling device's statistics in sysfs")
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2018-10-10 11:44:52 +08:00
Peter Zijlstra f2c4db1bd8 x86/cpu: Sanitize FAM6_ATOM naming
Going primarily by:

  https://en.wikipedia.org/wiki/List_of_Intel_Atom_microprocessors

with additional information gleaned from other related pages; notably:

 - Bonnell shrink was called Saltwell
 - Moorefield is the Merriefield refresh which makes it Airmont

The general naming scheme is: FAM6_ATOM_UARCH_SOCTYPE

  for i in `git grep -l FAM6_ATOM` ; do
	sed -i  -e 's/ATOM_PINEVIEW/ATOM_BONNELL/g'		\
		-e 's/ATOM_LINCROFT/ATOM_BONNELL_MID/'		\
		-e 's/ATOM_PENWELL/ATOM_SALTWELL_MID/g'		\
		-e 's/ATOM_CLOVERVIEW/ATOM_SALTWELL_TABLET/g'	\
		-e 's/ATOM_CEDARVIEW/ATOM_SALTWELL/g'		\
		-e 's/ATOM_SILVERMONT1/ATOM_SILVERMONT/g'	\
		-e 's/ATOM_SILVERMONT2/ATOM_SILVERMONT_X/g'	\
		-e 's/ATOM_MERRIFIELD/ATOM_SILVERMONT_MID/g'	\
		-e 's/ATOM_MOOREFIELD/ATOM_AIRMONT_MID/g'	\
		-e 's/ATOM_DENVERTON/ATOM_GOLDMONT_X/g'		\
		-e 's/ATOM_GEMINI_LAKE/ATOM_GOLDMONT_PLUS/g' ${i}
  done

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: dave.hansen@linux.intel.com
Cc: len.brown@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-10-02 10:14:32 +02:00
Linus Torvalds 3f16503b7d Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal
Pull thermal fixes from Eduardo Valentin:
 "Minor fixes to OF thermal, qoriq, and rcar drivers"

* 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal:
  thermal: of-thermal: disable passive polling when thermal zone is disabled
  thermal: rcar_gen3_thermal: convert to SPDX identifiers
  thermal: rcar_thermal: convert to SPDX identifiers
  thermal: qoriq: Switch to SPDX identifier
  thermal: qoriq: Simplify the 'site' variable assignment
  thermal: qoriq: Use devm_thermal_zone_of_sensor_register()
2018-08-28 16:11:34 -07:00
Fabrizio Castro 1d9e6cf3c8 thermal: rcar_gen3_thermal: Add r8a774a1 support
Add r8a774a1 specific compatible string.

Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Reviewed-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-08-24 16:34:50 -07:00
Viresh Kumar a92bab8919 of: thermal: Allow multiple devices to share cooling map
A cooling map entry may now contain a list of phandles and their
arguments representing multiple devices which share the trip point.

This patch updates the thermal OF core to parse them properly. The trip
point and contribution value is shared by multiple cooling devices now
and so a new structure is created, struct __thermal_cooling_bind_param,
which represents a cooling device and its min/max states and the
existing struct __thermal_bind_params now contains an array of this new
cooling device structure.

Tested on Hikey960.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-08-24 16:14:31 -07:00
Matthias Kaehlcke f1599f9e4c thermal: qcom-spmi: Use PMIC thermal stage 2 for critical trip points
There are three thermal stages defined in the PMIC:

stage 1: warning
stage 2: system should shut down
stage 3: emergency shut down

By default the PMIC assumes that the OS isn't doing anything and thus
at stage 2 it does a partial PMIC shutdown and at stage 3 it kills
all power. When switching between thermal stages the PMIC generates an
interrupt which is handled by the driver. The partial PMIC shutdown at
stage 2 can be disabled by software, which allows the OS to initiate a
shutdown at stage 2 with a thermal zone configured accordingly.

If a critical trip point is configured in the thermal zone the driver
adjusts the stage 1-3 temperature thresholds to (closely) match the
critical temperature with a stage 2 threshold (125/130/135/140 °C).
If a suitable match is found the partial shutdown at stage 2 is
disabled. If for some reason the system doesn't shutdown at stage 2
the emergency shutdown at stage 3 kicks in.

The partial shutdown at stage 2 remains enabled in these cases:
- no critical trip point defined
- the temperature of the critical trip point is < 125°C
- the temperature of the critical trip point is > 140°C and no
  ADC channel is configured (thus the OS is not notified when the critical
  temperature is reached)

Suggested-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-08-24 15:59:52 -07:00
Linus Torvalds d972604f6f Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
Pull thermal management updates from Zhang Rui:

 - Add Daniel Lezcano as the reviewer of thermal framework and SoC
   driver changes (Daniel Lezcano).

 - Fix a bug in intel_dts_soc_thermal driver, which does not translate
   IO-APIC GSI (Global System Interrupt) into Linux irq number (Hans de
   Goede).

 - For device tree bindings, allow cooling devices sharing same trip
   point with same contribution value to share cooling map (Viresh
   Kumar).

* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
  dt-bindings: thermal: Allow multiple devices to share cooling map
  MAINTAINERS: Add Daniel Lezcano as designated reviewer for thermal
  Thermal: Intel SoC DTS: Translate IO-APIC GSI number to linux irq number
2018-08-24 13:03:51 -07:00
Finn Thain 3cc97bea60 treewide: correct "differenciate" and "instanciate" typos
Also add these typos to spelling.txt so checkpatch.pl will look for them.

Link: http://lkml.kernel.org/r/88af06b9de34d870cb0afc46cfd24e0458be2575.1529471371.git.fthain@telegraphics.com.au
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-23 18:48:43 -07:00
Anson Huang 152395fd03 thermal: of-thermal: disable passive polling when thermal zone is disabled
When thermal zone is in passive mode, disabling its mode from
sysfs is NOT taking effect at all, it is still polling the
temperature of the disabled thermal zone and handling all thermal
trips, it makes user confused. The disabling operation should
disable the thermal zone behavior completely, for both active and
passive mode, this patch clears the passive_delay when thermal
zone is disabled and restores it when it is enabled.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-08-20 12:00:40 -07:00
Kuninori Morimoto d316522d06 thermal: rcar_gen3_thermal: convert to SPDX identifiers
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-08-20 11:42:35 -07:00
Kuninori Morimoto c954579087 thermal: rcar_thermal: convert to SPDX identifiers
As original license mentioned, it is GPL-2.0 in SPDX.
Then, MODULE_LICENSE() should be "GPL v2" instead of "GPL".
See ${LINUX}/include/linux/module.h

	"GPL"           [GNU Public License v2 or later]
	"GPL v2"        [GNU Public License v2]

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-08-20 11:35:43 -07:00
Fabio Estevam 2dfef65021 thermal: qoriq: Switch to SPDX identifier
Adopt the SPDX license identifier headers to ease license compliance
management.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-08-20 11:32:55 -07:00
Fabio Estevam 1a893a5a19 thermal: qoriq: Simplify the 'site' variable assignment
There is no need to assign zero to the variable 'site' and then
perform a compound bitwise OR operation afterwards.

Make it simpler by assigning the final 'site' value directly.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-08-20 11:31:29 -07:00
Fabio Estevam f1506a69e3 thermal: qoriq: Use devm_thermal_zone_of_sensor_register()
By using the managed devm_thermal_zone_of_sensor_register() we can
drop the explicit call to thermal_zone_of_sensor_unregister() in the
qoriq_tmu_remove() function, which simplifies the code a bit.

So switch to devm_thermal_zone_of_sensor_register().

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-08-20 11:29:42 -07:00
Linus Torvalds d01e12dd3f Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal
Pull thermal management updates from Eduardo Valentin:

 - rework tsens driver to add support for tsens-v2 (Amit Kucheria)

 - rework armada thermal driver to use syscon and multichannel support
   (Miquel Raynal)

 - fixes to TI SoC, IMX, Exynos, RCar, and hwmon drivers

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal: (34 commits)
  thermal: armada: fix copy-paste error in armada_thermal_probe()
  thermal: rcar_thermal: avoid NULL dereference in absence of IRQ resources
  thermal: samsung: Remove Exynos5440 clock handling left-overs
  thermal: tsens: Fix negative temperature reporting
  thermal: tsens: switch from of_iomap() to devm_ioremap_resource()
  thermal: tsens: Rename variable
  thermal: tsens: Add generic support for TSENS v2 IP
  thermal: tsens: Rename tsens-8996 to tsens-v2 for reuse
  thermal: tsens: Add support to split up register address space into two
  dt: thermal: tsens: Document the fallback DT property for v2 of TSENS IP
  thermal: tsens: Get rid of unused fields in structure
  thermal_hwmon: Pass the originating device down to hwmon_device_register_with_info
  thermal_hwmon: Sanitize attribute name passed to hwmon
  dt-bindings: thermal: armada: add reference to new bindings
  dt-bindings: cp110: add the thermal node in the syscon file
  dt-bindings: cp110: update documentation since DT de-duplication
  dt-bindings: ap806: add the thermal node in the syscon file
  dt-bindings: cp110: prepare the syscon file to list other syscons nodes
  dt-bindings: ap806: prepare the syscon file to list other syscons nodes
  dt-bindings: cp110: rename cp110 syscon file
  ...
2018-08-16 10:21:18 -07:00
Wei Yongjun 84b64de597 thermal: armada: fix copy-paste error in armada_thermal_probe()
The return value from devm_kzalloc() is not checked correctly. The
test is done against a wrong variable. Fix it.

Fixes: e72f03ef2543 ("thermal: armada: use the resource managed registration helper alternative")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-08-01 09:56:12 -07:00
Simon Horman 542cdf4068 thermal: rcar_thermal: avoid NULL dereference in absence of IRQ resources
Ensure that the base address used by a call to rcar_thermal_common_write()
may be NULL if the SOC supports interrupts for use with the thermal device
but none are defined in DT as is the case for R-Car H1 (r8a7779). Guard
against this condition to prevent a NULL dereference when the device is
probed.

Tested on:
* R-Mobile APE6 (r8a73a4) / APE6EVM
* R-Car H1 (r8a7779) / Marzen
* R-Car H2 (r8a7790) / Lager
* R-Car M2-W (r8a7791) / Koelsch
* R-Car M2-N (r8a7793) / Gose
* R-Car D3 ES1.0 (r8a77995) / Draak

Fixes: 1969d9dc20 ("thermal: rcar_thermal: add r8a77995 support")
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-07-27 16:45:36 -07:00