ec6a5192 | 11-Aug-2023 |
Andrei Coardos <aboutphysycs@gmail.com> |
thermal/drivers/mediatek/auxadc_thermal: Removed call to platform_set_drvdata()
This function call was found to be unnecessary as there is no equivalent platform_get_drvdata() call to access the pri
thermal/drivers/mediatek/auxadc_thermal: Removed call to platform_set_drvdata()
This function call was found to be unnecessary as there is no equivalent platform_get_drvdata() call to access the private data of the driver. Also, the private data is defined in this driver, so there is no risk of it being accessed outside of this driver file.
Signed-off-by: Andrei Coardos <aboutphysycs@gmail.com> Reviewed-by: Alexandru Ardelean <alex@shruggie.ro> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230811192847.3838-1-aboutphysycs@gmail.com
show more ...
|
185673ca | 13-Jul-2023 |
Nícolas F. R. A. Prado <nfraprado@collabora.com> |
thermal/drivers/mediatek/lvts_thermal: Make readings valid in filtered mode
Currently, when a controller is configured to use filtered mode, thermal readings are valid only about 30% of the time.
U
thermal/drivers/mediatek/lvts_thermal: Make readings valid in filtered mode
Currently, when a controller is configured to use filtered mode, thermal readings are valid only about 30% of the time.
Upon testing, it was noticed that lowering any of the interval settings resulted in an improved rate of valid data. The same was observed when decreasing the number of samples for each sensor (which also results in quicker measurements).
Retrying the read with a timeout longer than the time it takes to resample (about 344us with these settings and 4 sensors) also improves the rate.
Lower all timing settings to the minimum, configure the filtering to single sample, and poll the measurement register for at least one period to improve the data validity on filtered mode. With these changes in place, out of 100000 reads, a single one failed, ie 99.999% of the data was valid.
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Tested-by: Chen-Yu Tsai <wenst@chromium.org> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230713154743.611870-1-nfraprado@collabora.com
show more ...
|
e9b1de73 | 02-Aug-2023 |
Chen Jiahao <chenjiahao16@huawei.com> |
thermal/drivers/mediatek: Clean up redundant dev_err_probe()
Referring to platform_get_irq()'s definition, the return value has already been checked if ret < 0, and printed via dev_err_probe(). Call
thermal/drivers/mediatek: Clean up redundant dev_err_probe()
Referring to platform_get_irq()'s definition, the return value has already been checked if ret < 0, and printed via dev_err_probe(). Calling dev_err_probe() one more time outside platform_get_irq() is obviously redundant.
Removing dev_err_probe() outside platform_get_irq() to clean up above problem.
Signed-off-by: Chen Jiahao <chenjiahao16@huawei.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230802094527.988842-1-chenjiahao16@huawei.com
show more ...
|
19ad9f29 | 12-Jul-2023 |
Minjie Du <duminjie@vivo.com> |
thermal/drivers/mediatek/lvts: Fix parameter check in lvts_debugfs_init()
The documentation says "If an error occurs, ERR_PTR(-ERROR) will be returned" but the current code checks against a NULL poi
thermal/drivers/mediatek/lvts: Fix parameter check in lvts_debugfs_init()
The documentation says "If an error occurs, ERR_PTR(-ERROR) will be returned" but the current code checks against a NULL pointer returned.
Fix this by checking if IS_ERR().
Signed-off-by: Minjie Du <duminjie@vivo.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230713042413.2519-1-duminjie@vivo.com
show more ...
|
2bba1acf | 06-Jul-2023 |
Nícolas F. R. A. Prado <nfraprado@collabora.com> |
thermal/drivers/mediatek/lvts_thermal: Manage threshold between sensors
Each LVTS thermal controller can have up to four sensors, each capable of triggering its own interrupt when its measured tempe
thermal/drivers/mediatek/lvts_thermal: Manage threshold between sensors
Each LVTS thermal controller can have up to four sensors, each capable of triggering its own interrupt when its measured temperature crosses the configured threshold. The threshold for each sensor is handled separately by the thermal framework, since each one is registered with its own thermal zone and trips. However, the temperature thresholds are configured on the controller, and therefore are shared between all sensors on that controller.
When the temperature measured by the sensors is different enough to cause the thermal framework to configure different thresholds for each one, interrupts start triggering on sensors outside the last threshold configured.
To address the issue, track the thresholds required by each sensor and only actually set the highest one in the hardware, and disable interrupts for all sensors outside the current configured range.
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver") Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230706153823.201943-7-nfraprado@collabora.com
show more ...
|
77354eae | 06-Jul-2023 |
Nícolas F. R. A. Prado <nfraprado@collabora.com> |
thermal/drivers/mediatek/lvts_thermal: Don't leave threshold zeroed
The thermal framework might leave the low threshold unset if there aren't any lower trip points. This leaves the register zeroed,
thermal/drivers/mediatek/lvts_thermal: Don't leave threshold zeroed
The thermal framework might leave the low threshold unset if there aren't any lower trip points. This leaves the register zeroed, which translates to a very high temperature for the low threshold. The interrupt for this threshold is then immediately triggered, and the state machine gets stuck, preventing any other temperature monitoring interrupts to ever trigger.
(The same happens by not setting the Cold or Hot to Normal thresholds when using those)
Set the unused threshold to a valid low value. This value was chosen so that for any valid golden temperature read from the efuse, when the value is converted to raw and back again to milliCelsius, the result doesn't underflow.
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver") Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230706153823.201943-6-nfraprado@collabora.com
show more ...
|
487bf099 | 06-Jul-2023 |
Nícolas F. R. A. Prado <nfraprado@collabora.com> |
thermal/drivers/mediatek/lvts_thermal: Disable undesired interrupts
Out of the many interrupts supported by the hardware, the only ones of interest to the driver currently are: * The temperature wen
thermal/drivers/mediatek/lvts_thermal: Disable undesired interrupts
Out of the many interrupts supported by the hardware, the only ones of interest to the driver currently are: * The temperature went over the high offset threshold, for any of the sensors * The temperature went below the low offset threshold, for any of the sensors * The temperature went over the stage3 threshold
These are the only thresholds configured by the driver through the OFFSETH, OFFSETL, and PROTTC registers, respectively.
The current interrupt mask in LVTS_MONINT_CONF, enables many more interrupts, including data ready on sensors for both filtered and immediate mode. These are not only not handled by the driver, but they are also triggered too often, causing unneeded overhead. Disable these unnecessary interrupts.
The meaning of each bit can be seen in the comment describing LVTS_MONINTST in the IRQ handler.
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver") Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230706153823.201943-5-nfraprado@collabora.com
show more ...
|
f79e996c | 06-Jul-2023 |
Nícolas F. R. A. Prado <nfraprado@collabora.com> |
thermal/drivers/mediatek/lvts_thermal: Use offset threshold for IRQ
There are two kinds of temperature monitoring interrupts available: * High Offset, Low Offset * Hot, Hot to normal, Cold
The code
thermal/drivers/mediatek/lvts_thermal: Use offset threshold for IRQ
There are two kinds of temperature monitoring interrupts available: * High Offset, Low Offset * Hot, Hot to normal, Cold
The code currently uses the hot/h2n/cold interrupts, however in a way that doesn't work: the cold threshold is left uninitialized, which prevents the other thresholds from ever triggering, and the h2n interrupt is used as the lower threshold, which prevents the hot interrupt from triggering again after the thresholds are updated by the thermal framework, since a hot interrupt can only trigger again after the hot to normal interrupt has been triggered.
But better yet than addressing those issues, is to use the high/low offset interrupts instead. This way only two thresholds need to be managed, which have a simpler state machine, making them a better match to the thermal framework's high and low thresholds.
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver") Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230706153823.201943-4-nfraprado@collabora.com
show more ...
|
64de162e | 06-Jul-2023 |
Nícolas F. R. A. Prado <nfraprado@collabora.com> |
thermal/drivers/mediatek/lvts_thermal: Honor sensors in immediate mode
Each controller can be configured to operate on immediate or filtered mode. On filtered mode, the sensors are enabled by settin
thermal/drivers/mediatek/lvts_thermal: Honor sensors in immediate mode
Each controller can be configured to operate on immediate or filtered mode. On filtered mode, the sensors are enabled by setting the corresponding bits in MONCTL0, while on immediate mode, by setting MSRCTL1.
Previously, the code would set MSRCTL1 for all four sensors when configured to immediate mode, but given that the controller might not have all four sensors connected, this would cause interrupts to trigger for non-existent sensors. Fix this by handling the MSRCTL1 register analogously to the MONCTL0: only enable the sensors that were declared.
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver") Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Tested-by: Chen-Yu Tsai <wenst@chromium.org> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230706153823.201943-3-nfraprado@collabora.com
show more ...
|
cbd8c5aa | 06-Jul-2023 |
Nícolas F. R. A. Prado <nfraprado@collabora.com> |
thermal/drivers/mediatek/lvts_thermal: Handle IRQ on all controllers
There is a single IRQ handler for each LVTS thermal domain, and it is supposed to check each of its underlying controllers for th
thermal/drivers/mediatek/lvts_thermal: Handle IRQ on all controllers
There is a single IRQ handler for each LVTS thermal domain, and it is supposed to check each of its underlying controllers for the origin of the interrupt and clear its status. However due to a typo, only the first controller was ever being handled, which resulted in the interrupt never being cleared when it happened on the other controllers. Add the missing index so interrupts are handled for all controllers.
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver") Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Tested-by: Chen-Yu Tsai <wenst@chromium.org> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230706153823.201943-2-nfraprado@collabora.com
show more ...
|
51c8e119 | 13-Jun-2023 |
Chen-Yu Tsai <wenst@chromium.org> |
thermal/drivers/mediatek/lvts_thermal: Register thermal zones as hwmon sensors
Register thermal zones as hwmon sensors to let userspace read temperatures using standard hwmon interface.
Signed-off-
thermal/drivers/mediatek/lvts_thermal: Register thermal zones as hwmon sensors
Register thermal zones as hwmon sensors to let userspace read temperatures using standard hwmon interface.
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230613091317.1691247-1-wenst@chromium.org
show more ...
|
f0fb67c2 | 19-Mar-2023 |
Rob Herring <robh@kernel.org> |
thermal/drivers/mediatek: Use of_address_to_resource()
Replace of_get_address() and of_translate_address() calls with single call to of_address_to_resource().
Signed-off-by: Rob Herring <robh@kerne
thermal/drivers/mediatek: Use of_address_to_resource()
Replace of_get_address() and of_translate_address() calls with single call to of_address_to_resource().
Signed-off-by: Rob Herring <robh@kernel.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230319163231.226738-1-robh@kernel.org
show more ...
|
a3e9a9a5 | 18-Apr-2023 |
Kang Chen <void0red@hust.edu.cn> |
thermal/drivers/mediatek: Change clk_prepare_enable to devm_clk_get_enabled in mtk_thermal_probe
Use devm_clk_get_enabled to do automatic resource management. Meanwhile, remove error handling labels
thermal/drivers/mediatek: Change clk_prepare_enable to devm_clk_get_enabled in mtk_thermal_probe
Use devm_clk_get_enabled to do automatic resource management. Meanwhile, remove error handling labels in the probe function and the whole remove function.
Signed-off-by: Kang Chen <void0red@hust.edu.cn> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230419020749.621257-2-void0red@hust.edu.cn
show more ...
|
f05c7b7d | 18-Apr-2023 |
Kang Chen <void0red@hust.edu.cn> |
thermal/drivers/mediatek: Use devm_of_iomap to avoid resource leak in mtk_thermal_probe
Smatch reports: 1. mtk_thermal_probe() warn: 'apmixed_base' from of_iomap() not released. 2. mtk_thermal_probe
thermal/drivers/mediatek: Use devm_of_iomap to avoid resource leak in mtk_thermal_probe
Smatch reports: 1. mtk_thermal_probe() warn: 'apmixed_base' from of_iomap() not released. 2. mtk_thermal_probe() warn: 'auxadc_base' from of_iomap() not released.
The original code forgets to release iomap resource when handling errors, fix it by switch to devm_of_iomap.
Fixes: 89945047b166 ("thermal: mediatek: Add tsensor support for V2 thermal system") Signed-off-by: Kang Chen <void0red@hust.edu.cn> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230419020749.621257-1-void0red@hust.edu.cn
show more ...
|
47cbb046 | 19-Apr-2023 |
AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> |
thermal/drivers/mediatek: Add temperature constraints to validate read
The AUXADC thermal v1 allows reading temperature range between -20°C to 150°C and any value out of this range is invalid.
Add
thermal/drivers/mediatek: Add temperature constraints to validate read
The AUXADC thermal v1 allows reading temperature range between -20°C to 150°C and any value out of this range is invalid.
Add new definitions for MT8173_TEMP_{MIN_MAX} and a new small helper mtk_thermal_temp_is_valid() to check if new readings are in range: if not, we tell to the API that the reading is invalid by returning THERMAL_TEMP_INVALID.
It was chosen to introduce the helper function because, even though this temperature range is realistically ok for all, it comes from a downstream kernel driver for version 1, but here we also support v2 and v3 which may may have wider constraints.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230419061146.22246-3-angelogioacchino.delregno@collabora.com
show more ...
|
561538f7 | 07-Mar-2023 |
Balsam CHIHI <bchihi@baylibre.com> |
thermal/drivers/mediatek/lvts_thermal: Add AP domain for mt8195
Add MT8195 AP Domain support to LVTS Driver.
Take the opportunity to update the comments to show calibration data information related
thermal/drivers/mediatek/lvts_thermal: Add AP domain for mt8195
Add MT8195 AP Domain support to LVTS Driver.
Take the opportunity to update the comments to show calibration data information related to the new domain.
[dlezcano]: Massaged a bit the changelog
Signed-off-by: Balsam CHIHI <bchihi@baylibre.com> Tested-by: Chen-Yu Tsai <wenst@chromium.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230307154524.118541-3-bchihi@baylibre.com
show more ...
|