Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable hwmon for thermal zones #3307

Merged
merged 9 commits into from
May 28, 2020
Merged

Enable hwmon for thermal zones #3307

merged 9 commits into from
May 28, 2020

Conversation

wens
Copy link
Contributor

@wens wens commented Oct 29, 2019

It would be nice to be able to use standard hwmon interfaces to read the temperature of the CPU thermal zone. This is accomplished by enabling CONFIG_THERMAL_HWMON, and also having the brcmstb_thermal driver add the hwmon sysfs entries. The older bcm2835_thermal driver already has support for this.

The thermal driver patch does not directly apply to upstream, which has seen a change to devm_thermal_zone_of_sensor_register(), removing the remove() driver callback.

@popcornmix
Copy link
Collaborator

The change to brcmstb_thermal.c should be submitted upstream first.
Assuming they are happy then we can apply it here (even if that requires a little fixing up).
That way when we bump to a newer kernel version we should be able to have this feature without a downstream patch.

@wens
Copy link
Contributor Author

wens commented Oct 29, 2019

Ah. Ok. I'll see what I can do, given the current state of RPi 4 upstream.

@wens
Copy link
Contributor Author

wens commented Oct 31, 2019

Patch submitted upstream: https://lkml.org/lkml/2019/10/30/767
I suggest also backporting adad7c7d6a0c ("thermal: broadcom: use devm_thermal_zone_of_sensor_register") with it, once its in of course.

@popcornmix
Copy link
Collaborator

Thanks. Can you ping here when it is merged upstream.

@wens
Copy link
Contributor Author

wens commented Nov 4, 2019

So it looks like the upstream brcmstb_thermal driver doesn't actually support BCM2711, as it targets a slightly different hardware block.

@lategoodbye posted a new BCM2711 thermal driver [1] a few days ago. We'll see how that goes, or if it converges on the existing brcmstb_thermal driver.

[1] https://www.spinics.net/lists/devicetree/msg317462.html

@wens
Copy link
Contributor Author

wens commented Jan 15, 2020

Looks like the new driver is on track to be included in v5.6. See
https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git/log/?h=thermal/linux-next

@lategoodbye
Copy link
Contributor

Yes, but i'm not sure it make sense to backport it to 4.19, i suggest to rebase it on Linux 5.4 (#3385) which has a much smaller diff.

@wens
Copy link
Contributor Author

wens commented May 13, 2020

The DT bindings in upstream don't match what is in the 5.4 branch. I assume a backport would include both the device tree stuff as well as the driver?

@lategoodbye
Copy link
Contributor

Yes, you will need to backport the devicetree parts & driver from Linux 5.6. But also enable the different driver in the config.

@wens wens changed the base branch from rpi-4.19.y to rpi-5.4.y May 15, 2020 08:23
@wens
Copy link
Contributor Author

wens commented May 15, 2020

Done. The branch is now based on the commit b66e1e760f4c5f7cd783c1ca4c590765274e2cbe,
which is the current kernel found at https://github.com/raspberrypi/firmware

@lategoodbye
Copy link
Contributor

@wens LGTM

lategoodbye and others added 9 commits May 22, 2020 00:07
Commit ee31ff3 upstream.

Since the BCM2711 doesn't have a AVS TMON block, the thermal information
must be retrieved from the AVS ring oscillator block. This block is part
of the AVS monitor which contains a bunch of raw sensors.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1578941778-23321-2-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Commit 59b7813 upstream.

This adds the thermal sensor driver for the Broadcom BCM2711 SoC,
which is placed on the Raspberry Pi 4. The driver only provides
SoC temperature reading so far.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1578941778-23321-3-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Commit a1d6989 upstream.

This enables thermal for the BCM2711 (used on Raspberry Pi 4) by adding
the AVS monitor and a subnode for the thermal part.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1578941778-23321-4-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Commit 1a90e73 upstream.

This builds the BCM2711 thermal driver as module for the Raspberry Pi 4.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1578941778-23321-5-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
This reverts commit 6642a4f.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
This reverts commit 9d62448.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
To expose thermal regions as hwmon devices, the HWMON core has to be
built-in, so that THERMAL_HWMON can be enabled.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
@wens
Copy link
Contributor Author

wens commented May 21, 2020

Rebased onto latest rpi-5.4.y branch and fixed up commit hashes for the revert commits.

@lategoodbye
Copy link
Contributor

@popcornmix ping

@popcornmix
Copy link
Collaborator

@pelwell this looks good to me and compiled and appeared to work correctly. Any concerns?

@pelwell
Copy link
Contributor

pelwell commented May 28, 2020

They're all reverts and back-ports, so if it compiles and appears to work then I have no problem with it.

@popcornmix popcornmix merged commit ae4d85d into raspberrypi:rpi-5.4.y May 28, 2020
@popcornmix
Copy link
Collaborator

@wens @lategoodbye thanks!

@wens wens deleted the brcmstb-thermal-hwmon branch May 28, 2020 16:21
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Jun 3, 2020
kernel: vc4: Set driver_name for card
See: raspberrypi/linux#3656

kernel: configs: Add SND_SOC_MAX98357A=m
See: https://www.raspberrypi.org/forums/viewtopic.php?f=107&t=275919

kernel: Add Micro Crystal RV-1805 to i2c-rtc overlays
See: raspberrypi/linux#3651

kernel: media: bcm2835-isp: fix bytes per line calculations for some image formats
See: raspberrypi/linux#3645

kernel: media: bcm2835-unicam: change minimum number of vb2_queue buffers to 1
See: raspberrypi/linux#3638

kernel: media: i2c: imx477: Return correct result on sensor id verification
See: raspberrypi/linux#3630

kernel: Clean up the VCHIQ 2711 DMA support
See: raspberrypi/linux#3629

kernel: overlays: i2c-rtc-gpio: Fix trickle-resistor-ohms param
See: raspberrypi/linux#3642

kernel: Enable hwmon for thermal zones
See: raspberrypi/linux#3307
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this pull request Jun 3, 2020
kernel: vc4: Set driver_name for card
See: raspberrypi/linux#3656

kernel: configs: Add SND_SOC_MAX98357A=m
See: https://www.raspberrypi.org/forums/viewtopic.php?f=107&t=275919

kernel: Add Micro Crystal RV-1805 to i2c-rtc overlays
See: raspberrypi/linux#3651

kernel: media: bcm2835-isp: fix bytes per line calculations for some image formats
See: raspberrypi/linux#3645

kernel: media: bcm2835-unicam: change minimum number of vb2_queue buffers to 1
See: raspberrypi/linux#3638

kernel: media: i2c: imx477: Return correct result on sensor id verification
See: raspberrypi/linux#3630

kernel: Clean up the VCHIQ 2711 DMA support
See: raspberrypi/linux#3629

kernel: overlays: i2c-rtc-gpio: Fix trickle-resistor-ohms param
See: raspberrypi/linux#3642

kernel: Enable hwmon for thermal zones
See: raspberrypi/linux#3307
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants