* [PATCH 0/3] Add the MT8196 GPU temperature sensor
@ 2026-11-30 14:19 Alexandre Mergnat
2026-11-30 14:19 ` [PATCH 1/3] dt-bindings: power: mt8196-gpufreq: Add #thermal-sensor-cells Alexandre Mergnat
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Alexandre Mergnat @ 2026-11-30 14:19 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Nicolas Frattaroli, Ulf Hansson,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-pm, Alexandre Mergnat, Moudy Ho
No mainline driver reports the temperature of the MT8196 GPU, so a
thermal zone cannot throttle the GPU when it heats up. This series
takes the temperature that the GPUEB, the microcontroller managing
the GPU power and frequency, reports to the kernel, and makes it a
thermal sensor that a device tree thermal zone can use.
The usual way to get this temperature would be to extend the driver of
the SoC thermal controller (LVTS) to its GPU sensors. This series uses
the value that the GPU firmware reports instead, because the firmware
already reads these sensors. Any read clears the flag that marks a new
measurement, so this flag cannot be shared by two readers: a read by
one makes the other miss that a new measurement is there. A prototype
Linux reader of these sensors often found the flag already cleared
without having read it. On the test board, the value that the firmware
reported stayed within one degree of the average of these sensors.
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
Alexandre Mergnat (2):
pmdomain: mediatek: mfg: Expose GPU temperature
thermal/drivers/mediatek: Add GPUEB thermal driver
Moudy Ho (1):
dt-bindings: power: mt8196-gpufreq: Add #thermal-sensor-cells
.../bindings/power/mediatek,mt8196-gpufreq.yaml | 4 ++
drivers/pmdomain/mediatek/Kconfig | 1 +
drivers/pmdomain/mediatek/mtk-mfg-pmdomain.c | 29 ++++++++++++
drivers/thermal/mediatek/Kconfig | 9 ++++
drivers/thermal/mediatek/Makefile | 1 +
drivers/thermal/mediatek/gpueb_thermal.c | 52 ++++++++++++++++++++++
include/linux/soc/mediatek/mtk-mfg.h | 13 ++++++
7 files changed, 109 insertions(+)
---
base-commit: f66469d9905b39d2c260a15d7d6db450f4db67c1
change-id: 20261115-mtk-mfg-thermal-9f4a7cc786ae
Best regards,
--
Alexandre Mergnat <amergnat@baylibre.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] dt-bindings: power: mt8196-gpufreq: Add #thermal-sensor-cells
2026-11-30 14:19 [PATCH 0/3] Add the MT8196 GPU temperature sensor Alexandre Mergnat
@ 2026-11-30 14:19 ` Alexandre Mergnat
2026-11-30 14:19 ` [PATCH 2/3] pmdomain: mediatek: mfg: Expose GPU temperature Alexandre Mergnat
2026-11-30 14:19 ` [PATCH 3/3] thermal/drivers/mediatek: Add GPUEB thermal driver Alexandre Mergnat
2 siblings, 0 replies; 5+ messages in thread
From: Alexandre Mergnat @ 2026-11-30 14:19 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Nicolas Frattaroli, Ulf Hansson,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-pm, Alexandre Mergnat, Moudy Ho
From: Moudy Ho <moudy.ho@mediatek.com>
The gpufreq binding does not allow #thermal-sensor-cells, which a
thermal zone requires in the node it names as its sensor. A device
tree therefore cannot use the GPU temperature that the GPUEB reports
in a thermal zone without failing the schema check.
Allow the property, with no cells since the node provides one sensor.
Signed-off-by: Moudy Ho <moudy.ho@mediatek.com>
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
Documentation/devicetree/bindings/power/mediatek,mt8196-gpufreq.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/power/mediatek,mt8196-gpufreq.yaml b/Documentation/devicetree/bindings/power/mediatek,mt8196-gpufreq.yaml
index ba7f506dee9e..173a5a72ecfd 100644
--- a/Documentation/devicetree/bindings/power/mediatek,mt8196-gpufreq.yaml
+++ b/Documentation/devicetree/bindings/power/mediatek,mt8196-gpufreq.yaml
@@ -89,6 +89,9 @@ properties:
"#power-domain-cells":
const: 0
+ "#thermal-sensor-cells":
+ const: 0
+
shader-present:
type: object
@@ -133,6 +136,7 @@ examples:
#clock-cells = <1>;
#nvmem-cell-cells = <0>;
#power-domain-cells = <0>;
+ #thermal-sensor-cells = <0>;
shader-present {
};
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] pmdomain: mediatek: mfg: Expose GPU temperature
2026-11-30 14:19 [PATCH 0/3] Add the MT8196 GPU temperature sensor Alexandre Mergnat
2026-11-30 14:19 ` [PATCH 1/3] dt-bindings: power: mt8196-gpufreq: Add #thermal-sensor-cells Alexandre Mergnat
@ 2026-11-30 14:19 ` Alexandre Mergnat
2026-11-30 14:19 ` [PATCH 3/3] thermal/drivers/mediatek: Add GPUEB thermal driver Alexandre Mergnat
2 siblings, 0 replies; 5+ messages in thread
From: Alexandre Mergnat @ 2026-11-30 14:19 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Nicolas Frattaroli, Ulf Hansson,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-pm, Alexandre Mergnat
The GPUEB reports the GPU temperature in the shared memory that
mtk-mfg maps, but mtk-mfg does not read it, so no thermal zone can
use it.
Create an auxiliary device for a thermal driver, and export to it
a function that returns the temperature reported by the GPUEB.
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
drivers/pmdomain/mediatek/Kconfig | 1 +
drivers/pmdomain/mediatek/mtk-mfg-pmdomain.c | 29 ++++++++++++++++++++++++++++
include/linux/soc/mediatek/mtk-mfg.h | 13 +++++++++++++
3 files changed, 43 insertions(+)
diff --git a/drivers/pmdomain/mediatek/Kconfig b/drivers/pmdomain/mediatek/Kconfig
index a2eb704a773c..b7c0fa40b9cf 100644
--- a/drivers/pmdomain/mediatek/Kconfig
+++ b/drivers/pmdomain/mediatek/Kconfig
@@ -32,6 +32,7 @@ config MTK_MFG_PM_DOMAIN
depends on PM
depends on OF
depends on COMMON_CLK
+ select AUXILIARY_BUS
select MAILBOX
select PM_GENERIC_DOMAINS
imply MTK_GPUEB_MBOX
diff --git a/drivers/pmdomain/mediatek/mtk-mfg-pmdomain.c b/drivers/pmdomain/mediatek/mtk-mfg-pmdomain.c
index 1417ffc22b3e..28f6d84a2774 100644
--- a/drivers/pmdomain/mediatek/mtk-mfg-pmdomain.c
+++ b/drivers/pmdomain/mediatek/mtk-mfg-pmdomain.c
@@ -5,6 +5,7 @@
* Copyright (C) 2025, Collabora Ltd.
*/
+#include <linux/auxiliary_bus.h>
#include <linux/completion.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
@@ -22,6 +23,7 @@
#include <linux/pm_domain.h>
#include <linux/pm_opp.h>
#include <linux/regulator/consumer.h>
+#include <linux/soc/mediatek/mtk-mfg.h>
#include <linux/units.h>
#define GPR_LP_STATE 0x0028
@@ -908,6 +910,28 @@ static int mtk_mfg_init_nvmem_provider(struct mtk_mfg *mfg)
return 0;
}
+/**
+ * mtk_mfg_get_temp() - Get the GPU temperature reported by the GPUEB
+ * @adev: the auxiliary device created by mtk-mfg
+ * @temp: the temperature in millidegrees Celsius
+ *
+ * Return: 0 on success, -ENODATA while the GPU is off, as the GPUEB does not
+ * update the temperature then.
+ */
+int mtk_mfg_get_temp(struct auxiliary_device *adev, int *temp)
+{
+ struct mtk_mfg *mfg = dev_get_drvdata(adev->dev.parent);
+
+ if (READ_ONCE(mfg->pd.status) != GENPD_STATE_ON)
+ return -ENODATA;
+
+ *temp = (s32)readl(mfg->shared_mem + GF_REG_TEMP_RAW) *
+ MILLIDEGREE_PER_DEGREE;
+
+ return 0;
+}
+EXPORT_SYMBOL_NS_GPL(mtk_mfg_get_temp, "MTK_MFG_PM_DOMAIN");
+
static int mtk_mfg_probe(struct platform_device *pdev)
{
struct mtk_mfg *mfg;
@@ -1024,6 +1048,11 @@ static int mtk_mfg_probe(struct platform_device *pdev)
if (ret)
goto err_power_off;
+ if (!devm_auxiliary_device_create(dev, "thermal", NULL)) {
+ ret = -ENODEV;
+ goto err_power_off;
+ }
+
ret = of_genpd_add_provider_simple(dev->of_node, &mfg->pd);
if (ret) {
dev_err_probe(dev, ret, "Failed to add pmdomain provider\n");
diff --git a/include/linux/soc/mediatek/mtk-mfg.h b/include/linux/soc/mediatek/mtk-mfg.h
new file mode 100644
index 000000000000..8ca41b7faffd
--- /dev/null
+++ b/include/linux/soc/mediatek/mtk-mfg.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2026 BayLibre, SAS
+ */
+
+#ifndef __MTK_MFG_H
+#define __MTK_MFG_H
+
+struct auxiliary_device;
+
+int mtk_mfg_get_temp(struct auxiliary_device *adev, int *temp);
+
+#endif /* __MTK_MFG_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] thermal/drivers/mediatek: Add GPUEB thermal driver
2026-11-30 14:19 [PATCH 0/3] Add the MT8196 GPU temperature sensor Alexandre Mergnat
2026-11-30 14:19 ` [PATCH 1/3] dt-bindings: power: mt8196-gpufreq: Add #thermal-sensor-cells Alexandre Mergnat
2026-11-30 14:19 ` [PATCH 2/3] pmdomain: mediatek: mfg: Expose GPU temperature Alexandre Mergnat
@ 2026-11-30 14:19 ` Alexandre Mergnat
2026-11-30 15:31 ` Uwe Kleine-König
2 siblings, 1 reply; 5+ messages in thread
From: Alexandre Mergnat @ 2026-11-30 14:19 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Nicolas Frattaroli, Ulf Hansson,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-pm, Alexandre Mergnat
Add a driver for the auxiliary device that the mtk-mfg power domain
driver creates on MT8196. It registers the GPU temperature that the
GPUEB reports as a thermal sensor, so that a thermal zone can monitor
the GPU.
The auxiliary device shares the device tree node of the gpufreq device,
so a thermal zone selects this sensor by referring to that node.
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
drivers/thermal/mediatek/Kconfig | 9 ++++++
drivers/thermal/mediatek/Makefile | 1 +
drivers/thermal/mediatek/gpueb_thermal.c | 52 ++++++++++++++++++++++++++++++++
3 files changed, 62 insertions(+)
diff --git a/drivers/thermal/mediatek/Kconfig b/drivers/thermal/mediatek/Kconfig
index d82c86d9be56..a721b75d0790 100644
--- a/drivers/thermal/mediatek/Kconfig
+++ b/drivers/thermal/mediatek/Kconfig
@@ -34,4 +34,13 @@ config MTK_LVTS_THERMAL_DEBUGFS
help
Enable this option to debug the internals of the device driver.
+config MTK_GPUEB_THERMAL
+ tristate "GPUEB GPU temperature driver for MediaTek SoCs"
+ depends on MTK_MFG_PM_DOMAIN
+ help
+ Enable this option if you want to get GPU temperature
+ information for MediaTek SoCs such as the MT8196.
+ The temperature is reported by the GPUEB, the microcontroller
+ that manages the GPU power and frequency.
+
endif
diff --git a/drivers/thermal/mediatek/Makefile b/drivers/thermal/mediatek/Makefile
index 1c6daa1e644b..3ec5295e8514 100644
--- a/drivers/thermal/mediatek/Makefile
+++ b/drivers/thermal/mediatek/Makefile
@@ -1,2 +1,3 @@
obj-$(CONFIG_MTK_SOC_THERMAL) += auxadc_thermal.o
obj-$(CONFIG_MTK_LVTS_THERMAL) += lvts_thermal.o
+obj-$(CONFIG_MTK_GPUEB_THERMAL) += gpueb_thermal.o
diff --git a/drivers/thermal/mediatek/gpueb_thermal.c b/drivers/thermal/mediatek/gpueb_thermal.c
new file mode 100644
index 000000000000..f63b5751a0c0
--- /dev/null
+++ b/drivers/thermal/mediatek/gpueb_thermal.c
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2026 BayLibre, SAS
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/err.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/soc/mediatek/mtk-mfg.h>
+#include <linux/thermal.h>
+
+static int gpueb_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
+{
+ /* GPU off: -ENODATA would get the zone disabled by the thermal core */
+ if (mtk_mfg_get_temp(thermal_zone_device_priv(tz), temp))
+ *temp = THERMAL_TEMP_INVALID;
+
+ return 0;
+}
+
+static const struct thermal_zone_device_ops gpueb_thermal_ops = {
+ .get_temp = gpueb_thermal_get_temp,
+};
+
+static int gpueb_thermal_probe(struct auxiliary_device *adev,
+ const struct auxiliary_device_id *id)
+{
+ struct thermal_zone_device *tz;
+
+ tz = devm_thermal_of_zone_register(&adev->dev, 0, adev,
+ &gpueb_thermal_ops);
+
+ return PTR_ERR_OR_ZERO(tz);
+}
+
+static const struct auxiliary_device_id gpueb_thermal_id_table[] = {
+ { .name = "mtk_mfg_pmdomain.thermal" },
+ { }
+};
+MODULE_DEVICE_TABLE(auxiliary, gpueb_thermal_id_table);
+
+static struct auxiliary_driver gpueb_thermal_driver = {
+ .id_table = gpueb_thermal_id_table,
+ .probe = gpueb_thermal_probe,
+};
+module_auxiliary_driver(gpueb_thermal_driver);
+
+MODULE_AUTHOR("Alexandre Mergnat <amergnat@baylibre.com>");
+MODULE_DESCRIPTION("MediaTek GPUEB thermal sensor driver");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("MTK_MFG_PM_DOMAIN");
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] thermal/drivers/mediatek: Add GPUEB thermal driver
2026-11-30 14:19 ` [PATCH 3/3] thermal/drivers/mediatek: Add GPUEB thermal driver Alexandre Mergnat
@ 2026-11-30 15:31 ` Uwe Kleine-König
0 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2026-11-30 15:31 UTC (permalink / raw)
To: Alexandre Mergnat
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Nicolas Frattaroli, Ulf Hansson,
Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-pm
[-- Attachment #1: Type: text/plain, Size: 2673 bytes --]
On Mon, Nov 30, 2026 at 02:19:33PM +0000, Alexandre Mergnat wrote:
> Add a driver for the auxiliary device that the mtk-mfg power domain
> driver creates on MT8196. It registers the GPU temperature that the
> GPUEB reports as a thermal sensor, so that a thermal zone can monitor
> the GPU.
>
> The auxiliary device shares the device tree node of the gpufreq device,
> so a thermal zone selects this sensor by referring to that node.
>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
> ---
> drivers/thermal/mediatek/Kconfig | 9 ++++++
> drivers/thermal/mediatek/Makefile | 1 +
> drivers/thermal/mediatek/gpueb_thermal.c | 52 ++++++++++++++++++++++++++++++++
> 3 files changed, 62 insertions(+)
>
> diff --git a/drivers/thermal/mediatek/Kconfig b/drivers/thermal/mediatek/Kconfig
> index d82c86d9be56..a721b75d0790 100644
> --- a/drivers/thermal/mediatek/Kconfig
> +++ b/drivers/thermal/mediatek/Kconfig
> @@ -34,4 +34,13 @@ config MTK_LVTS_THERMAL_DEBUGFS
> help
> Enable this option to debug the internals of the device driver.
>
> +config MTK_GPUEB_THERMAL
> + tristate "GPUEB GPU temperature driver for MediaTek SoCs"
> + depends on MTK_MFG_PM_DOMAIN
> + help
> + Enable this option if you want to get GPU temperature
> + information for MediaTek SoCs such as the MT8196.
> + The temperature is reported by the GPUEB, the microcontroller
> + that manages the GPU power and frequency.
> +
> endif
> diff --git a/drivers/thermal/mediatek/Makefile b/drivers/thermal/mediatek/Makefile
> index 1c6daa1e644b..3ec5295e8514 100644
> --- a/drivers/thermal/mediatek/Makefile
> +++ b/drivers/thermal/mediatek/Makefile
> @@ -1,2 +1,3 @@
> obj-$(CONFIG_MTK_SOC_THERMAL) += auxadc_thermal.o
> obj-$(CONFIG_MTK_LVTS_THERMAL) += lvts_thermal.o
> +obj-$(CONFIG_MTK_GPUEB_THERMAL) += gpueb_thermal.o
> diff --git a/drivers/thermal/mediatek/gpueb_thermal.c b/drivers/thermal/mediatek/gpueb_thermal.c
> new file mode 100644
> index 000000000000..f63b5751a0c0
> --- /dev/null
> +++ b/drivers/thermal/mediatek/gpueb_thermal.c
> @@ -0,0 +1,52 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (C) 2026 BayLibre, SAS
> + */
> +
> +#include <linux/auxiliary_bus.h>
> +#include <linux/err.h>
> +#include <linux/mod_devicetable.h>
<linux/auxiliary_bus.h> already provides auxiliary_device_id with much
less overhead than <linux/mod_devicetable.h>.
So to reduce build time (a tiny bit) and build dependencies and not
fight against my quest to remove <linux/mod_devicetable.h>, please drop
the #include for <linux/mod_devicetable.h>.
Thanks
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-30 16:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 14:19 [PATCH 0/3] Add the MT8196 GPU temperature sensor Alexandre Mergnat
2026-11-30 14:19 ` [PATCH 1/3] dt-bindings: power: mt8196-gpufreq: Add #thermal-sensor-cells Alexandre Mergnat
2026-11-30 14:19 ` [PATCH 2/3] pmdomain: mediatek: mfg: Expose GPU temperature Alexandre Mergnat
2026-11-30 14:19 ` [PATCH 3/3] thermal/drivers/mediatek: Add GPUEB thermal driver Alexandre Mergnat
2026-11-30 15:31 ` Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox