aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/thermal/rcar_gen3_thermal.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-03-20thermal: rcar_gen3_thermal: Add r8a77961 supportGeert Uytterhoeven1-0/+4
Add support for the Thermal Sensor/Chip Internal Voltage Monitor in the R-Car M3-W+ (R8A77961) SoC. According to the R-Car Gen3 Hardware Manual Errata for Revision 2.00 of Jan 31, 2020, the thermal parameters for R-Car M3-W+ are the same as for R-Car M3-W. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20200306105503.24267-3-geert+renesas@glider.be
2020-03-12thermal: rcar_gen3_thermal: Generate interrupt when temperature changesNiklas Söderlund1-12/+12
The desired behavior of the driver is to generate an interrupt and call thermal_zone_device_update() as soon as the temperature have changed more then one degree. When the set_trips operation was implemented it was believed that the trip window set by the framework would move around the current temperature and the hysteresis value described in devicetree. The behavior of the framework is however to set a window based on the trip points described in devicetree. Remove the set_trips operation which was not used correctly and update the temperatures that triggers interrupts directly from the interrupt handler. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20200212224917.737314-1-niklas.soderlund+renesas@ragnatech.se
2020-03-12thermal: rcar_gen3_thermal: Remove unneeded curly bracketsNiklas Söderlund1-2/+1
When devm_add_action() was turned into devm_add_action_or_reset() the curly brackets for the error case where kept but are not needed, remove them to match the style of the driver. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20200212224732.736785-1-niklas.soderlund+renesas@ragnatech.se
2020-01-27thermal: rcar_gen3_thermal: Remove temperature boundNiklas Söderlund1-3/+1
The hardware manual states that the operation of the sensor is not guaranteed with temperatures above 125°C, not that the readings are invalid. Remove the bound check and try to deliver temperature readings even if we are outside the guaranteed operation range. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20200117160554.3812787-3-niklas.soderlund+renesas@ragnatech.se
2019-11-07thermal: rcar_gen3_thermal: Add r8a774b1 supportBiju Das1-0/+4
Add r8a774b1 specific compatible string. Signed-off-by: Biju Das <biju.das@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/1569248746-56718-1-git-send-email-biju.das@bp.renesas.com
2019-08-28thermal: rcar_gen3_thermal: Replace devm_add_action() followed by failure action with devm_add_action_or_reset()Fuqian Huang1-2/+1
devm_add_action_or_reset() is introduced as a helper function which internally calls devm_add_action(). If devm_add_action() fails then it will execute the action mentioned and return the error code. This reduce source code size (avoid writing the action twice) and reduce the likelyhood of bugs. Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2019-05-23thermal: rcar_gen3_thermal: Update temperature conversion methodYoshihiro Kaneko1-10/+18
Update the formula to calculate temperature: Currently, current TEMP is calculated as average of val1 (is calculated by formula 1) and val2 (is calculated by formula 2). But, as description in HWM (chapter 10A.3.1.2 Normal Mode.) If (TEMP_CODE < THCODE2[11:0]) CTEMP value should be val1. If (TEMP_CODE > THCODE2[11:0]) CTEMP value should be val2. Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2019-05-23thermal: rcar_gen3_thermal: Update calculation formula of IRQTEMPYoshihiro Kaneko1-16/+17
Update the formula to calculate CTEMP: Currently, the CTEMP is average of val1 (is calculated by formula 1) and val2 (is calculated by formula 2). But, as description in HWM (chapter 10A.3.1.1 Setting of Normal Mode) If (STEMP < Tj_T) CTEMP value should be val1. If (STEMP > Tj_T) CTEMP value should be val2. Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2019-05-23thermal: rcar_gen3_thermal: Update value of Tj_1Yoshihiro Kaneko1-11/+30
As evaluation of hardware team, temperature calculation formula of M3-W is difference from all other SoCs as below: - M3-W: Tj_1: 116 (so Tj_1 - Tj_3 = 157) - Others: Tj_1: 126 (so Tj_1 - Tj_3 = 167) Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2019-05-14thermal: rcar_gen3_thermal: Fix to show correct trip points numberJiada Wang1-4/+4
Currently after store trip points number in 'ret', it is overwritten afterwards, this cause incorrect trip point number always be shown in the debug information after register of each thermal zone. This patch fix this issue by moving get of trip number to end of thermal zone registration. Fixes: 6269e9f790e8d ("thermal: rcar_gen3_thermal: Register hwmon sysfs interface") Signed-off-by: Jiada Wang <jiada_wang@mentor.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2019-05-14thermal: rcar_gen3_thermal: disable interrupt in .removeJiada Wang1-0/+3
Currently IRQ remains enabled after .remove, later if device is probed, IRQ is requested before .thermal_init, this may cause IRQ function be called before device is initialized. this patch disables interrupt in .remove, to ensure irq function only be called after device is fully initialized. Signed-off-by: Jiada Wang <jiada_wang@mentor.com> 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>
2019-05-14thermal: rcar_gen3_thermal: fix interrupt typeJiada Wang1-32/+6
Currently IRQF_SHARED type interrupt line is allocated, but it is not appropriate, as the interrupt line isn't shared between different devices, instead IRQF_ONESHOT is the proper type. By changing interrupt type to IRQF_ONESHOT, now irq handler is no longer needed, as clear of interrupt status can be done in threaded interrupt context. Because IRQF_ONESHOT type interrupt line is kept disabled until the threaded handler has been run, so there is no need to protect read/write of REG_GEN3_IRQSTR with lock. Fixes: 7d4b269776ec6 ("enable hardware interrupts for trip points") Signed-off-by: Jiada Wang <jiada_wang@mentor.com> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Tested-by: Simon Horman <horms+renesas@verge.net.au> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2019-05-14thermal: rcar_gen3_thermal: Fix init value of IRQCTL registerHoan Nguyen An1-1/+1
Fix setting value for IRQCTL register. We are setting the last 6 bits of (IRQCTL) to be 1 (0x3f), this is only suitable for H3ES1.*, according to Hardware manual values 1 are "setting prohibited" for Gen3. Signed-off-by: Hoan Nguyen An <na-hoan@jinso.co.jp> Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2019-02-20thermal: rcar_gen3_thermal: Register hwmon sysfs interfaceMarek Vasut1-0/+19
Register the hwmon sysfs interface on R-Car Gen3 thermal driver to align it with Gen2 driver. Use devm_add_action() to unregister the hwmon interface automatically. Cc: Eduardo Valentin <edubezval@gmail.com> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com> Cc: linux-renesas-soc@vger.kernel.org To: linux-pm@vger.kernel.org From: Marek Vasut <marek.vasut+renesas@gmail.com> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2018-10-26Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermalLinus Torvalds1-0/+2
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-25thermal: rcar_gen3_thermal: add R8A77980 supportSergei Shtylyov1-0/+1
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-08-24thermal: rcar_gen3_thermal: Add r8a774a1 supportFabrizio Castro1-0/+1
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-20thermal: rcar_gen3_thermal: convert to SPDX identifiersKuninori Morimoto1-10/+1
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-05-06thermal: rcar_gen3_thermal: add r8a77965 supportNiklas Söderlund1-0/+1
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> 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-05-06thermal: rcar_gen3_thermal: update max temperature clampNiklas Söderlund1-2/+2
Change the upper limit to clamp the high temperature value to 120C when setting trip points. Signed-off-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-05-06thermal: rcar_gen3_thermal: Update calculation formula due to HW evaluationHien Dang1-6/+6
Due to hardware evaluation result, Max temperature is changed from 96 to 116 degree Celsius. Also, calculation formula and pseudo FUSE values are changed accordingly. Signed-off-by: Dien Pham <dien.pham.ry@renesas.com> Signed-off-by: Hien Dang <hien.dang.eb@renesas.com> Signed-off-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>
2017-10-31thermal: rcar_gen3_thermal: fix initialization sequence for H3 ES2.0Niklas Söderlund1-19/+15
The initialization sequence for H3 (r8a7795) ES1.x and ES2.0 is different. H3 ES2.0 and later uses the same sequence as M3 (r8a7796) ES1.0. Fix this by not looking at compatible strings and instead defaulting to the r8a7796 initialization sequence and use soc_device_match() to check for H3 ES1.x. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2017-08-11thermal: rcar_gen3_thermal: constify thermal_zone_of_device_ops structuresJulia Lawall1-1/+1
The thermal_zone_of_device_ops structure is only passed as the fourth argument to devm_thermal_zone_of_sensor_register, which is declared as const. Thus the thermal_zone_of_device_ops structure itself can be const. Done with the help of Coccinelle. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2017-03-30thermal: rcar_gen3_thermal: add suspend and resume supportNiklas Söderlund1-0/+35
To restore operation it's easiest to reinitialise all TSCs. In order to do this the current trip window needs to be stored in the TSC structure so that it can be restored upon resume. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2017-03-30thermal: rcar_gen3_thermal: store device match data in private structureNiklas Söderlund1-3/+4
The device match data needs to be accessible outside the probe function, store it in the private data structure. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2017-03-30thermal: rcar_gen3_thermal: enable hardware interrupts for trip pointsNiklas Söderlund1-1/+131
Enable hardware trip points by implementing the set_trips callback. The thermal core will take care of setting the initial trip point window and to update it once the driver reports a TSC has moved outside it. The interrupt structure for this device is a bit odd. There is not a dedicated IRQ for each TSC, instead the interrupts are shared between all TSCs. IRQn is fired if the temp monitored in IRQTEMPn is reached in any of the TSCs, example IRQ3 is fired if temperature in IRQTEMP3 is reached in either TSC0, TSC1 or TSC2. For this reason the usage of interrupts in this driver is an all-on or all-off design. When an interrupt happens all TSCs are checked and all thermal zones are updated. This could be refined to be more fine grained but the thermal core takes care of only updating the thermal zones that have left their trip point window. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2017-03-30thermal: rcar_gen3_thermal: record and check number of TSCs foundNiklas Söderlund1-0/+8
Record how many TSCs are found in struct rcar_gen3_thermal_priv, this is needed to be able to add hardware interrupts for trip points later. Also add a check to make sure at least one TSC is found. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2017-03-30thermal: rcar_gen3_thermal: check that TSC exists before memory allocationNiklas Söderlund1-4/+4
Move the check for a TSC resource before allocating memory for a new TSC. If no TSC is found there is little point in allocating memory for it. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2017-03-30thermal: rcar_gen3_thermal: remove unneeded mutexNiklas Söderlund1-7/+0
There is no point in protecting a register read with a lock. This is most likely a leftover from when the driver was reworked before being submitted for upstream. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2017-03-30thermal: rcar_gen3_thermal: add delay in .thermal_init on r8a7796Niklas Söderlund1-0/+2
The .thermal_init needs to be delayed a short amount of time to allow for the TEMP register to contain something useful. If it's not delayed these warnings are common during boot: thermal thermal_zone0: failed to read out thermal zone (-5) thermal thermal_zone1: failed to read out thermal zone (-5) thermal thermal_zone2: failed to read out thermal zone (-5) The warnings are triggered by the first call to .get_temp() while the TEMP register contains 0 and rcar_gen3_thermal_get_temp() returns -EIO since a TEMP value of 0 will result in a temperature reading which is out of specifications. This should have been done in the initial commit which adds the driver as the same issue was found and corrected for r8a7795. Fixes: 564e73d283af9d4c ("thermal: rcar_gen3_thermal: Add R-Car Gen3 thermal driver") Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2017-01-19thermal: rcar_gen3_thermal: Add R-Car Gen3 thermal driverWolfram Sang1-0/+335
Add support for R-Car Gen3 thermal sensors. Polling only for now, interrupts will be added incrementally. Same goes for reading fuses. This is documented already, but no hardware available for now. Signed-off-by: Hien Dang <hien.dang.eb@renesas.com> Signed-off-by: Thao Nguyen <thao.nguyen.yb@rvc.renesas.com> Signed-off-by: Khiem Nguyen <khiem.nguyen.xt@renesas.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> [Niklas: document and rework temperature calculation] Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>