mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Mergnat <amergnat@baylibre.com>
To: Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	 Matthias Brugger <matthias.bgg@gmail.com>,
	 AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	 Nicolas Frattaroli <nicolas.frattaroli@collabora.com>,
	 Ulf Hansson <ulfh@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	 Daniel Lezcano <daniel.lezcano@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	 Lukasz Luba <lukasz.luba@arm.com>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,  linux-pm@vger.kernel.org,
	Alexandre Mergnat <amergnat@baylibre.com>
Subject: [PATCH 3/3] thermal/drivers/mediatek: Add GPUEB thermal driver
Date: Mon, 30 Nov 2026 14:19:33 +0000	[thread overview]
Message-ID: <20261130-mtk-mfg-thermal-v1-3-e0617e26f902@baylibre.com> (raw)
In-Reply-To: <20261130-mtk-mfg-thermal-v1-0-e0617e26f902@baylibre.com>

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


  parent reply	other threads:[~2026-11-30 14:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-11-30 15:31   ` [PATCH 3/3] thermal/drivers/mediatek: Add GPUEB thermal driver Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130-mtk-mfg-thermal-v1-3-e0617e26f902@baylibre.com \
    --to=amergnat@baylibre.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=conor+dt@kernel.org \
    --cc=daniel.lezcano@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=nicolas.frattaroli@collabora.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=ulfh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®