* [PATCH v4 1/1] soc: mediatek: mtk-regulator-coupler: Add support for MT8189
2025-11-05 3:38 niklaus.liu
@ 2025-11-05 3:38 ` niklaus.liu
2025-11-05 8:56 ` AngeloGioacchino Del Regno
1 sibling, 0 replies; 3+ messages in thread
From: niklaus.liu @ 2025-11-05 3:38 UTC (permalink / raw)
To: Matthias Brugger, AngeloGioacchino Del Regno
Cc: linux-kernel, linux-arm-kernel, linux-mediatek,
Project_Global_Chrome_Upstream_Group, sirius.wang, vince-wl.liu,
jh.hsu, zhigang.qin, sen.chu, Niklaus Liu
From: Niklaus Liu <niklaus.liu@mediatek.com>
Enhance the regulator coupler driver to support GPU power control on the
MediaTek MT8189 platform. This update ensures proper coordination of
multiple regulators required for GPU operation,improving power management
and system stability.
Signed-off-by: Niklaus Liu <niklaus.liu@mediatek.com>
---
drivers/soc/mediatek/mtk-regulator-coupler.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/soc/mediatek/mtk-regulator-coupler.c b/drivers/soc/mediatek/mtk-regulator-coupler.c
index 0b6a2884145e..e2a1fb459e42 100644
--- a/drivers/soc/mediatek/mtk-regulator-coupler.c
+++ b/drivers/soc/mediatek/mtk-regulator-coupler.c
@@ -42,6 +42,18 @@ static int mediatek_regulator_balance_voltage(struct regulator_coupler *coupler,
int max_uV = INT_MAX;
int ret;
+ /*
+ * When vsram_gpu is enabled or disabled and the use_count of the
+ * vsram_gpu regulator is zero, the regulator coupler driver will
+ * execute regulator_do_balance_voltage, which adjusts the vsram_gpu
+ * voltage to the minimum value. This may result in vsram_gpu being
+ * lower than vgpu. Therefore, when enabling or disabling vsram_gpu,
+ * the 8189 temporarily skips the regulator coupler driver's modification
+ * of the vsram_gpu voltage.
+ */
+ if (of_machine_is_compatible("mediatek,mt8189") && rdev == mrc->vsram_rdev)
+ return 0;
+
/*
* If the target device is on, setting the SRAM voltage directly
* is not supported as it scales through its coupled supply voltage.
@@ -148,6 +160,7 @@ static int mediatek_regulator_coupler_init(void)
if (!of_machine_is_compatible("mediatek,mt8183") &&
!of_machine_is_compatible("mediatek,mt8186") &&
!of_machine_is_compatible("mediatek,mt8188") &&
+ !of_machine_is_compatible("mediatek,mt8189") &&
!of_machine_is_compatible("mediatek,mt8192"))
return 0;
--
2.46.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re:
2025-11-05 3:38 niklaus.liu
2025-11-05 3:38 ` [PATCH v4 1/1] soc: mediatek: mtk-regulator-coupler: Add support for MT8189 niklaus.liu
@ 2025-11-05 8:56 ` AngeloGioacchino Del Regno
1 sibling, 0 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-11-05 8:56 UTC (permalink / raw)
To: niklaus.liu, Matthias Brugger
Cc: linux-kernel, linux-arm-kernel, linux-mediatek,
Project_Global_Chrome_Upstream_Group, sirius.wang, vince-wl.liu,
jh.hsu, zhigang.qin, sen.chu
Il 05/11/25 04:38, niklaus.liu ha scritto:
> Refer to the discussion in the link:
> v3: https://patchwork.kernel.org/project/linux-mediatek/patch/20251104071252.12539-2-Niklaus.Liu@mediatek.com/
>
> Subject: [PATCH v4 0/1] soc: mediatek: mtk-regulator-coupler: Add support for MT8189
The subject of this email is .. empty. That's really bad, and it's the second time
that it happens. Please make sure that you're sending emails the right way, and/or
fix your client.
While at it, please also fix your name, as it should appear as "Niklaus Liu" and
not as "niklaus.liu".
>
> changes in v4:
> - reply comment:
Niklaus, please just reply inline to the emails instead of sending an entirely new
version just for a reply: it's easier for everyone to follow, and it's also easier
for me to read, and for you to send a reply by clicking one button :-)
> 1. MTK hardware requires that vsram_gpu must be higher than vgpu; this rule must be satisfied.
>
> 2. When the GPU powers on, the mtcmos driver first calls regulator_enable to turn on vgpu, then calls regulator_enable to
> turn on vsram_gpu. When enabling vgpu, mediatek_regulator_balance_voltage sets the voltages for both vgpu and vsram_gpu.
> However, when enabling vsram_gpu, mediatek_regulator_balance_voltage is also executed, and at this time, the vsram_gpu voltage
> is set to the minimum voltage specified in the DTS, which does not comply with the requirement that vsram_gpu must be higher than vgpu.
>
2. -> There's your problem! VSRAM_GPU has to be turned on *first*, VGPU has to be
turned on *last* instead.
Logically, you need SRAM up before the GPU is up as if the GPU tries to use SRAM
it'll produce unpowered access issues: even though it's *very* unlikely for that
to happen on older Mali, it's still a logical mistake that might, one day, come
back at us and create instabilities.
Now, the easy fix is to just invert the regulators in MFG nodes. As I explained
*multiple* times, you have a misconfiguration in your DT.
GPU subsystem main MFG -> VSRAM
GPU core complex MFG -> VGPU
GPU per-core MFG -> nothing
> 3.During suspend, the voltages of vgpu and vsram_gpu should remain unchanged, and when resuming, vgpu and vsram_gpu should be
> restored to their previous voltages. When the vgpu voltage is adjusted, mediatek_regulator_balance_voltage already synchronizes the
> adjustment of vsram_gpu voltage. Therefore, adjusting the vsram_gpu voltage again in mediatek_regulator_balance_voltage is redundant.
If you fix your DT, N.3 won't happen.
Regards,
Angelo
>
>
> changes in v3:
> - modify for comment[add the new entry by alphabetical order]
>
> changes in v2:
> - change title for patch
> - reply comment: This is a software regulator coupler mechanism, and the regulator-coupled-with
> configuration has been added in the MT8189 device tree. This patchaddresses an issue reported by a
> Chromebook customer. When the GPU regulator is turned on, mediatek_regulator_balance_voltage already
> sets both the GPU and GPU_SRAM voltages at the same time, so there is no need to adjust the GPU_SRAM
> voltage again in a second round. Therefore, a return is set for MT8189.
> If the user calls mediatek_regulator_balance_voltage again for GPU_SRAM, it may cause abnormal behavior of GPU_SRAM.
>
>
> changes in v1:
> - mediatek-regulator-coupler mechanism for platform MT8189
>
> *** BLURB HERE ***
>
> Niklaus Liu (1):
> soc: mediatek: mtk-regulator-coupler: Add support for MT8189
>
> drivers/soc/mediatek/mtk-regulator-coupler.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
^ permalink raw reply [flat|nested] 3+ messages in thread