[PATCH 01/11] power: pmic: mtk-pwrap: add MT8195 support
David Lechner
dlechner at baylibre.com
Tue Mar 17 21:24:01 CET 2026
On 3/17/26 9:24 AM, Julien Stephan wrote:
> Add mt8195 support.
> Support comes directly from commit e88edc977b00 ("soc: mediatek: pwrap:
> add pwrap driver for MT8195 SoC") from the Linux Kernel
>
> Signed-off-by: Julien Stephan <jstephan at baylibre.com>
> ---
> drivers/power/pmic/mtk-pwrap.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/drivers/power/pmic/mtk-pwrap.c b/drivers/power/pmic/mtk-pwrap.c
> index 3e3a691d9e8..8ff6458a5f2 100644
> --- a/drivers/power/pmic/mtk-pwrap.c
> +++ b/drivers/power/pmic/mtk-pwrap.c
> @@ -276,6 +276,23 @@ static int mt8189_regs[] = {
> [PWRAP_WACS2_RDATA] = 0x8A8,
> };
>
> +static int mt8195_regs[] = {
> + [PWRAP_INIT_DONE2] = 0x0,
> + [PWRAP_STAUPD_CTRL] = 0x4C,
> + [PWRAP_TIMER_EN] = 0x3E4,
> + [PWRAP_INT_EN] = 0x420,
> + [PWRAP_INT_FLG] = 0x428,
> + [PWRAP_INT_CLR] = 0x42C,
> + [PWRAP_INT1_EN] = 0x450,
> + [PWRAP_INT1_FLG] = 0x458,
> + [PWRAP_INT1_CLR] = 0x45C,
> + [PWRAP_WACS2_CMD] = 0x880,
> + [PWRAP_SWINF_2_WDATA_31_0] = 0x884,
> + [PWRAP_SWINF_2_RDATA_31_0] = 0x894,
> + [PWRAP_WACS2_VLDCLR] = 0x8A4,
> + [PWRAP_WACS2_RDATA] = 0x8A8,
> +};
I think we need to take a harder look at the driver here. There are many
registers that are accessed unconditionally in the code that aren't defined
here. (It looks like the Linux driver has similar issues as well. And we
have the same problem with mt8188 and mt8189 here in U-Boot.)
So either the code is broken and should have more conditionals or the
register tables are incomplete.
Most of this is in pwrap_init() which is conditional on an earlier bootloader
doing the initialization. If that is the case, we could avoid the issue
by adding a capability flag PWRAP_CAP_INIT and use that to avoid calling
pwrap_init() when we don't have the registers defined and raise an error
instead.
/*
* The PMIC could already be initialized by the bootloader.
* Skip initialization here in this case.
*/
if (!pwrap_readl(wrp, PWRAP_INIT_DONE2)) {
+ if (!HAS_CAP(wrp->master->caps, PWRAP_CAP_INIT)) {
+ dev_err(dev, "PMIC is not initialized\n");
+ return -EINVAL;
+ }
+
ret = pwrap_init(wrp);
if (ret) {
dev_err(dev, "init failed with %d\n", ret);
return ret;
}
}
Then that leaves PWRAP_WDT_SRC_EN that is unconditionally set in the probe()
function.
> +
> static int mt8365_regs[] = {
> [PWRAP_MUX_SEL] = 0x0,
> [PWRAP_WRAP_EN] = 0x4,
> @@ -341,6 +358,7 @@ static int mt8365_regs[] = {
> enum pwrap_type {
> PWRAP_MT8188,
> PWRAP_MT8189,
> + PWRAP_MT8195,
> PWRAP_MT8365,
> };
>
> @@ -796,6 +814,7 @@ static int mtk_pwrap_bind(struct udevice *dev)
> break;
> case PWRAP_MT8188:
> case PWRAP_MT8189:
> + case PWRAP_MT8195:
> pmic_children_info = mt6359_pmic_children_info;
It would be nice to eventually drop this switch statement and the
enum pwrap_type. We can move the children_info to the
struct pmic_wrapper_type and get it from there instead.
We can save that for later though.
> break;
> default:
> @@ -867,6 +886,17 @@ static struct pmic_wrapper_type pwrap_mt8189 = {
> .caps = PWRAP_CAP_ARB,
> };
>
> +static const struct pmic_wrapper_type pwrap_mt8195 = {
> + .regs = mt8195_regs,
> + .type = PWRAP_MT8195,
> + .arb_en_all = 0x777f, /* NEED CONFIRM */
> + .int_en_all = 0x180000, /* NEED CONFIRM */
Maybe we can find a way to confirm these?
> + .int1_en_all = 0,
> + .spi_w = PWRAP_MAN_CMD_SPI_WRITE,
> + .wdt_src = PWRAP_WDT_SRC_MASK_ALL,
> + .caps = PWRAP_CAP_INT1_EN | PWRAP_CAP_ARB,
> +};
> +
> static const struct pmic_wrapper_type pwrap_mt8365 = {
> .regs = mt8365_regs,
> .type = PWRAP_MT8365,
> @@ -881,6 +911,7 @@ static const struct pmic_wrapper_type pwrap_mt8365 = {
> static const struct udevice_id mtk_pwrap_ids[] = {
> { .compatible = "mediatek,mt8188-pwrap", .data = (ulong)&pwrap_mt8188 },
> { .compatible = "mediatek,mt8189-pwrap", .data = (ulong)&pwrap_mt8189 },
> + { .compatible = "mediatek,mt8195-pwrap", .data = (ulong)&pwrap_mt8195 },
> { .compatible = "mediatek,mt8365-pwrap", .data = (ulong)&pwrap_mt8365 },
> { }
> };
>
More information about the U-Boot
mailing list