* [PATCH v2 1/8] power: pmic: mtk-pwrap: fix file description
2026-04-09 20:30 [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
@ 2026-04-09 20:30 ` David Lechner
2026-04-09 20:30 ` [PATCH v2 2/8] power: pmic: mtk-pwrap: add PWRAP_CAP_WDT_SRC flag David Lechner
` (9 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: David Lechner @ 2026-04-09 20:30 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
GSS_MTK_Uboot_upstream, Jaehoon Chung, Peng Fan, Tom Rini
Cc: Julien Stephan, u-boot, David Lechner
Fix the comment at the start of the file to accurately describe what
this file does. The old description was likely copied from the related
regulator driver.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/power/pmic/mtk-pwrap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/power/pmic/mtk-pwrap.c b/drivers/power/pmic/mtk-pwrap.c
index 3e3a691d9e8..f4dfb48e93b 100644
--- a/drivers/power/pmic/mtk-pwrap.c
+++ b/drivers/power/pmic/mtk-pwrap.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
- * MT6357 regulator driver
+ * MediaTek PMIC Wrapper driver
*
* Copyright (c) 2026 BayLibre, SAS.
* Author: Julien Masson <jmasson@baylibre.com>
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v2 2/8] power: pmic: mtk-pwrap: add PWRAP_CAP_WDT_SRC flag
2026-04-09 20:30 [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
2026-04-09 20:30 ` [PATCH v2 1/8] power: pmic: mtk-pwrap: fix file description David Lechner
@ 2026-04-09 20:30 ` David Lechner
2026-04-09 20:30 ` [PATCH v2 3/8] power: pmic: mtk-pwrap: add init capability flag David Lechner
` (8 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: David Lechner @ 2026-04-09 20:30 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
GSS_MTK_Uboot_upstream, Jaehoon Chung, Peng Fan, Tom Rini
Cc: Julien Stephan, u-boot, David Lechner
Add a PWRAP_CAP_WDT_SRC flag to indicate if a PMIC wrapper has a WDT_SRC
or not. Then use this to conditionally enable the watchdog timer.
Prior to this change, since the register was not defined, it defaulted
to 0, so the wrong register (DONE2) was being written to.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/power/pmic/mtk-pwrap.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/power/pmic/mtk-pwrap.c b/drivers/power/pmic/mtk-pwrap.c
index f4dfb48e93b..3ed21dcf2ef 100644
--- a/drivers/power/pmic/mtk-pwrap.c
+++ b/drivers/power/pmic/mtk-pwrap.c
@@ -60,8 +60,9 @@ static const struct pmic_child_info mt6359_pmic_children_info[] = {
/* Group of bits used for shown pwrap capability */
#define PWRAP_CAP_INT1_EN BIT(3)
-#define PWRAP_CAP_WDT_SRC1 BIT(4)
-#define PWRAP_CAP_ARB BIT(5)
+#define PWRAP_CAP_WDT_SRC BIT(4)
+#define PWRAP_CAP_WDT_SRC1 BIT(5)
+#define PWRAP_CAP_ARB BIT(6)
/* defines for slave device wrapper registers */
enum dew_regs {
@@ -755,7 +756,8 @@ static int mtk_pwrap_probe(struct udevice *dev)
* Since STAUPD was not used on mt8173 platform,
* so STAUPD of WDT_SRC which should be turned off
*/
- pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN);
+ if (HAS_CAP(wrp->master->caps, PWRAP_CAP_WDT_SRC))
+ pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN);
if (HAS_CAP(wrp->master->caps, PWRAP_CAP_WDT_SRC1))
pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN_1);
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v2 3/8] power: pmic: mtk-pwrap: add init capability flag
2026-04-09 20:30 [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
2026-04-09 20:30 ` [PATCH v2 1/8] power: pmic: mtk-pwrap: fix file description David Lechner
2026-04-09 20:30 ` [PATCH v2 2/8] power: pmic: mtk-pwrap: add PWRAP_CAP_WDT_SRC flag David Lechner
@ 2026-04-09 20:30 ` David Lechner
2026-04-09 20:30 ` [PATCH v2 4/8] power: pmic: mtk-pwrap: drop PWRAP_SLV_CAP_DUALIO on mt6359 David Lechner
` (7 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: David Lechner @ 2026-04-09 20:30 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
GSS_MTK_Uboot_upstream, Jaehoon Chung, Peng Fan, Tom Rini
Cc: Julien Stephan, u-boot, David Lechner
Add a PWRAP_CAP_INIT capability flag to specify if it is safe to call
pwrap_init() or not. Not all targets define the registers accessed
by pwrap_init(). In that case, it is expected that an earlier bootloader
has already initialized the PMIC. If not, we now return an error instead
of trying to access undefined registers.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/power/pmic/mtk-pwrap.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/power/pmic/mtk-pwrap.c b/drivers/power/pmic/mtk-pwrap.c
index 3ed21dcf2ef..38ae44f0abf 100644
--- a/drivers/power/pmic/mtk-pwrap.c
+++ b/drivers/power/pmic/mtk-pwrap.c
@@ -63,6 +63,8 @@ static const struct pmic_child_info mt6359_pmic_children_info[] = {
#define PWRAP_CAP_WDT_SRC BIT(4)
#define PWRAP_CAP_WDT_SRC1 BIT(5)
#define PWRAP_CAP_ARB BIT(6)
+/* To implement this capability, the registers used in pwrap_init() must be defined. */
+#define PWRAP_CAP_INIT BIT(7)
/* defines for slave device wrapper registers */
enum dew_regs {
@@ -735,6 +737,11 @@ static int mtk_pwrap_probe(struct udevice *dev)
* 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, "initialization is required but not supported\n");
+ return -EOPNOTSUPP;
+ }
+
ret = pwrap_init(wrp);
if (ret) {
dev_err(dev, "init failed with %d\n", ret);
@@ -877,7 +884,7 @@ static const struct pmic_wrapper_type pwrap_mt8365 = {
.int1_en_all = 0x0,
.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
- .caps = PWRAP_CAP_INT1_EN | PWRAP_CAP_WDT_SRC1,
+ .caps = PWRAP_CAP_INT1_EN | PWRAP_CAP_WDT_SRC1 | PWRAP_CAP_INIT,
};
static const struct udevice_id mtk_pwrap_ids[] = {
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v2 4/8] power: pmic: mtk-pwrap: drop PWRAP_SLV_CAP_DUALIO on mt6359
2026-04-09 20:30 [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
` (2 preceding siblings ...)
2026-04-09 20:30 ` [PATCH v2 3/8] power: pmic: mtk-pwrap: add init capability flag David Lechner
@ 2026-04-09 20:30 ` David Lechner
2026-04-09 20:30 ` [PATCH v2 5/8] power: pmic: mtk-pwrap: remove interrupt related code David Lechner
` (6 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: David Lechner @ 2026-04-09 20:30 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
GSS_MTK_Uboot_upstream, Jaehoon Chung, Peng Fan, Tom Rini
Cc: Julien Stephan, u-boot, David Lechner
Drop the PWRAP_SLV_CAP_DUALIO flag from the mt6359 PMIC definition. The
mt6359p variant of the PMIC does support dual I/O.
Prior to this change, the driver would attempt to write to the
PWRAP_DEW_DIO_EN register, which was not defined, so would write
register 0 (DONE2).
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/power/pmic/mtk-pwrap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/power/pmic/mtk-pwrap.c b/drivers/power/pmic/mtk-pwrap.c
index 38ae44f0abf..64c483b2f3b 100644
--- a/drivers/power/pmic/mtk-pwrap.c
+++ b/drivers/power/pmic/mtk-pwrap.c
@@ -647,7 +647,7 @@ static const struct pwrap_slv_type pmic_mt6357 = {
static const struct pwrap_slv_type pmic_mt6359 = {
.dew_regs = mt6359_regs,
- .caps = PWRAP_SLV_CAP_DUALIO,
+ .caps = 0,
};
static const struct udevice_id mtk_pmic_ids[] = {
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v2 5/8] power: pmic: mtk-pwrap: remove interrupt related code
2026-04-09 20:30 [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
` (3 preceding siblings ...)
2026-04-09 20:30 ` [PATCH v2 4/8] power: pmic: mtk-pwrap: drop PWRAP_SLV_CAP_DUALIO on mt6359 David Lechner
@ 2026-04-09 20:30 ` David Lechner
2026-04-09 20:45 ` David Lechner
2026-04-09 20:30 ` [PATCH v2 6/8] power: pmic: mtk-pwrap: use pmic compatible to select child info David Lechner
` (5 subsequent siblings)
10 siblings, 1 reply; 14+ messages in thread
From: David Lechner @ 2026-04-09 20:30 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
GSS_MTK_Uboot_upstream, Jaehoon Chung, Peng Fan, Tom Rini
Cc: Julien Stephan, u-boot, David Lechner
Remove the interrupt related code in mtk-pwrap driver. This was just
enabling interrupts without any handler.
Even if we did have a handler, the only thing we could do is log a
message. Since U-Boot isn't long running, this likely wouldn't be very
useful.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/power/pmic/mtk-pwrap.c | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/drivers/power/pmic/mtk-pwrap.c b/drivers/power/pmic/mtk-pwrap.c
index 64c483b2f3b..c41ebeb62cc 100644
--- a/drivers/power/pmic/mtk-pwrap.c
+++ b/drivers/power/pmic/mtk-pwrap.c
@@ -367,8 +367,6 @@ struct pmic_wrapper_type {
int *regs;
enum pwrap_type type;
u32 arb_en_all;
- u32 int_en_all;
- u32 int1_en_all;
u32 spi_w;
u32 wdt_src;
/* Flags indicating the capability for the target pwrap */
@@ -774,15 +772,6 @@ static int mtk_pwrap_probe(struct udevice *dev)
else
pwrap_writel(wrp, 0x1, PWRAP_TIMER_EN);
- pwrap_writel(wrp, wrp->master->int_en_all, PWRAP_INT_EN);
-
- /*
- * We add INT1 interrupt to handle starvation and request exception
- * If we support it, we should enable it here.
- */
- if (HAS_CAP(wrp->master->caps, PWRAP_CAP_INT1_EN))
- pwrap_writel(wrp, wrp->master->int1_en_all, PWRAP_INT1_EN);
-
return 0;
}
@@ -859,8 +848,6 @@ static struct pmic_wrapper_type pwrap_mt8188 = {
.regs = mt8188_regs,
.type = PWRAP_MT8188,
.arb_en_all = 0x777f,
- .int_en_all = 0x180000,
- .int1_en_all = 0x0,
.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
.caps = PWRAP_CAP_INT1_EN | PWRAP_CAP_ARB,
@@ -870,7 +857,6 @@ static struct pmic_wrapper_type pwrap_mt8189 = {
.regs = mt8189_regs,
.type = PWRAP_MT8189,
.arb_en_all = 0x777f,
- .int_en_all = 0x180000,
.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
.caps = PWRAP_CAP_ARB,
@@ -880,8 +866,6 @@ static const struct pmic_wrapper_type pwrap_mt8365 = {
.regs = mt8365_regs,
.type = PWRAP_MT8365,
.arb_en_all = 0x3ffff,
- .int_en_all = 0x7f1fffff,
- .int1_en_all = 0x0,
.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
.caps = PWRAP_CAP_INT1_EN | PWRAP_CAP_WDT_SRC1 | PWRAP_CAP_INIT,
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v2 5/8] power: pmic: mtk-pwrap: remove interrupt related code
2026-04-09 20:30 ` [PATCH v2 5/8] power: pmic: mtk-pwrap: remove interrupt related code David Lechner
@ 2026-04-09 20:45 ` David Lechner
0 siblings, 0 replies; 14+ messages in thread
From: David Lechner @ 2026-04-09 20:45 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
GSS_MTK_Uboot_upstream, Jaehoon Chung, Peng Fan, Tom Rini
Cc: Julien Stephan, u-boot
On 4/9/26 3:30 PM, David Lechner wrote:
> Remove the interrupt related code in mtk-pwrap driver. This was just
> enabling interrupts without any handler.
>
Drat, I forgot to remove the PWRAP_CAP_INT1_EN flag.
If nothing else comes up, I can fix that up while applying
the patches.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 6/8] power: pmic: mtk-pwrap: use pmic compatible to select child info
2026-04-09 20:30 [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
` (4 preceding siblings ...)
2026-04-09 20:30 ` [PATCH v2 5/8] power: pmic: mtk-pwrap: remove interrupt related code David Lechner
@ 2026-04-09 20:30 ` David Lechner
2026-04-09 20:30 ` [PATCH v2 7/8] power: pmic: mtk-pwrap: use tabs for alignment David Lechner
` (4 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: David Lechner @ 2026-04-09 20:30 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
GSS_MTK_Uboot_upstream, Jaehoon Chung, Peng Fan, Tom Rini
Cc: Julien Stephan, u-boot, David Lechner
Change the logic for selecting pmic_children_info to use the compatible
string from the devicetree instead of expecting the pwrap (part of the
MCU) to correspond to the separate PMIC chip.
In addition to being more correct, it also saves a few lines of code for
each MCU type that is added by dropping the enum and type field.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/power/pmic/mtk-pwrap.c | 24 +++++-------------------
1 file changed, 5 insertions(+), 19 deletions(-)
diff --git a/drivers/power/pmic/mtk-pwrap.c b/drivers/power/pmic/mtk-pwrap.c
index c41ebeb62cc..7d84ab1f6d3 100644
--- a/drivers/power/pmic/mtk-pwrap.c
+++ b/drivers/power/pmic/mtk-pwrap.c
@@ -341,12 +341,6 @@ static int mt8365_regs[] = {
[PWRAP_WDT_SRC_EN_1] = 0xf8,
};
-enum pwrap_type {
- PWRAP_MT8188,
- PWRAP_MT8189,
- PWRAP_MT8365,
-};
-
struct pwrap_slv_type {
const u32 *dew_regs;
u32 caps;
@@ -365,7 +359,6 @@ struct pmic_wrapper {
struct pmic_wrapper_type {
int *regs;
- enum pwrap_type type;
u32 arb_en_all;
u32 spi_w;
u32 wdt_src;
@@ -780,7 +773,6 @@ static int mtk_pwrap_bind(struct udevice *dev)
ofnode pmic_node, regulators_node;
int children;
const struct pmic_child_info *pmic_children_info;
- struct pmic_wrapper_type *pw_type = (void *)dev_get_driver_data(dev);
pmic_node = dev_read_first_subnode(dev);
if (!ofnode_valid(pmic_node)) {
@@ -788,16 +780,13 @@ static int mtk_pwrap_bind(struct udevice *dev)
return -ENXIO;
}
- switch (pw_type->type) {
- case PWRAP_MT8365:
+ if (ofnode_device_is_compatible(pmic_node, "mediatek,mt6357")) {
pmic_children_info = mt6357_pmic_children_info;
- break;
- case PWRAP_MT8188:
- case PWRAP_MT8189:
+ } else if (ofnode_device_is_compatible(pmic_node, "mediatek,mt6359")) {
pmic_children_info = mt6359_pmic_children_info;
- break;
- default:
- dev_err(dev, "pwrap type %d not supported\n", pw_type->type);
+ } else {
+ dev_err(dev, "pmic type %s not supported\n",
+ ofnode_read_string(pmic_node, "compatible"));
return -ENXIO;
}
@@ -846,7 +835,6 @@ static struct dm_pmic_ops mtk_pwrap_ops = {
static struct pmic_wrapper_type pwrap_mt8188 = {
.regs = mt8188_regs,
- .type = PWRAP_MT8188,
.arb_en_all = 0x777f,
.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
@@ -855,7 +843,6 @@ static struct pmic_wrapper_type pwrap_mt8188 = {
static struct pmic_wrapper_type pwrap_mt8189 = {
.regs = mt8189_regs,
- .type = PWRAP_MT8189,
.arb_en_all = 0x777f,
.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
@@ -864,7 +851,6 @@ static struct pmic_wrapper_type pwrap_mt8189 = {
static const struct pmic_wrapper_type pwrap_mt8365 = {
.regs = mt8365_regs,
- .type = PWRAP_MT8365,
.arb_en_all = 0x3ffff,
.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v2 7/8] power: pmic: mtk-pwrap: use tabs for alignment
2026-04-09 20:30 [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
` (5 preceding siblings ...)
2026-04-09 20:30 ` [PATCH v2 6/8] power: pmic: mtk-pwrap: use pmic compatible to select child info David Lechner
@ 2026-04-09 20:30 ` David Lechner
2026-04-09 20:30 ` [PATCH v2 8/8] power: pmic: mtk-pwrap: add MT8195 support David Lechner
` (3 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: David Lechner @ 2026-04-09 20:30 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
GSS_MTK_Uboot_upstream, Jaehoon Chung, Peng Fan, Tom Rini
Cc: Julien Stephan, u-boot, David Lechner, Macpaul Lin
From: Julien Stephan <jstephan@baylibre.com>
Fix mt8188_regs definition to use tabs instead of spaces for alignment
to be consistent with other definitions.
Reviewed-by: Macpaul Lin <macpaul.lin@mediatek.com>
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/power/pmic/mtk-pwrap.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/power/pmic/mtk-pwrap.c b/drivers/power/pmic/mtk-pwrap.c
index 7d84ab1f6d3..b05c6b88157 100644
--- a/drivers/power/pmic/mtk-pwrap.c
+++ b/drivers/power/pmic/mtk-pwrap.c
@@ -252,20 +252,20 @@ enum pwrap_regs {
};
static int mt8188_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,
+ [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,
};
static int mt8189_regs[] = {
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v2 8/8] power: pmic: mtk-pwrap: add MT8195 support
2026-04-09 20:30 [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
` (6 preceding siblings ...)
2026-04-09 20:30 ` [PATCH v2 7/8] power: pmic: mtk-pwrap: use tabs for alignment David Lechner
@ 2026-04-09 20:30 ` David Lechner
2026-04-27 23:15 ` [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
` (2 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: David Lechner @ 2026-04-09 20:30 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
GSS_MTK_Uboot_upstream, Jaehoon Chung, Peng Fan, Tom Rini
Cc: Julien Stephan, u-boot, David Lechner
From: Julien Stephan <jstephan@baylibre.com>
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@baylibre.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/power/pmic/mtk-pwrap.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/power/pmic/mtk-pwrap.c b/drivers/power/pmic/mtk-pwrap.c
index b05c6b88157..88aa3dace29 100644
--- a/drivers/power/pmic/mtk-pwrap.c
+++ b/drivers/power/pmic/mtk-pwrap.c
@@ -279,6 +279,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,
+};
+
static int mt8365_regs[] = {
[PWRAP_MUX_SEL] = 0x0,
[PWRAP_WRAP_EN] = 0x4,
@@ -849,6 +866,14 @@ static struct pmic_wrapper_type pwrap_mt8189 = {
.caps = PWRAP_CAP_ARB,
};
+static const struct pmic_wrapper_type pwrap_mt8195 = {
+ .regs = mt8195_regs,
+ .arb_en_all = 0x777f, /* NEED CONFIRM */
+ .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,
.arb_en_all = 0x3ffff,
@@ -860,6 +885,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 },
{ }
};
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags
2026-04-09 20:30 [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
` (7 preceding siblings ...)
2026-04-09 20:30 ` [PATCH v2 8/8] power: pmic: mtk-pwrap: add MT8195 support David Lechner
@ 2026-04-27 23:15 ` David Lechner
2026-04-29 2:18 ` Peng Fan
2026-04-28 14:46 ` Julien Stephan
2026-04-29 14:23 ` David Lechner
10 siblings, 1 reply; 14+ messages in thread
From: David Lechner @ 2026-04-27 23:15 UTC (permalink / raw)
To: Jaehoon Chung
Cc: Julien Stephan, u-boot, Macpaul Lin, Ryder Lee, Weijie Gao,
Chunfeng Yun, Igor Belwon, GSS_MTK_Uboot_upstream, Peng Fan,
Tom Rini
On 4/9/26 3:30 PM, David Lechner wrote:
> After using the mtk-pwrap driver a bit, we noticed that there were a few
> places where it was writing to registers that were not defined on all
> platforms. The undefined registers are treated as 0, which is the DONE2
> register on the affected platforms. This could cause the DONE2 register
> to have an incorrect value, which could cause Linux to re-initialize the
> PMIC unnecessarily.
>
> To avoid this issue and ensure that we only write to registers that are
> defined on a given platform, we can add some more capability flags to
> conditionally call any register writes that aren't common to all
> platforms.
>
> There are also a couple of other cleanups that we do along the way. And
> in v2, I've picked up Julien's patch to add support for MT8195 and
> rebased on top of this.
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> Changes in v2:
> - Use EOPNOTSUPP.
> - Reorder patches to reduce churn.
> - Added new patch to fix driver description comment.
> - Added new patch to drop chip type enum.
> - Picked up Julien's patches from [1] and rebased on these changes.
> - Link to [1]: https://lore.kernel.org/u-boot/20260317-mt8195-add-ufs-support-v1-0-7d731ec438ae@baylibre.com/
> - Link to v1: https://patch.msgid.link/20260327-mtk-pmic-fixes-v1-0-ef874ca82409@baylibre.com
>
> ---
> David Lechner (6):
> power: pmic: mtk-pwrap: fix file description
> power: pmic: mtk-pwrap: add PWRAP_CAP_WDT_SRC flag
> power: pmic: mtk-pwrap: add init capability flag
> power: pmic: mtk-pwrap: drop PWRAP_SLV_CAP_DUALIO on mt6359
> power: pmic: mtk-pwrap: remove interrupt related code
> power: pmic: mtk-pwrap: use pmic compatible to select child info
>
> Julien Stephan (2):
> power: pmic: mtk-pwrap: use tabs for alignment
> power: pmic: mtk-pwrap: add MT8195 support
>
> drivers/power/pmic/mtk-pwrap.c | 115 +++++++++++++++++++++--------------------
> 1 file changed, 60 insertions(+), 55 deletions(-)
> ---
> base-commit: 2a1bcefce835b827bbf88a9e112d646c5c4af9c1
> change-id: 20260317-mtk-pmic-fixes-c1523b1b0dad
>
> Best regards,
> --
> David Lechner <dlechner@baylibre.com>
>
Hi Jaehoon,
Is it OK if I take this through the MediaTek tree? We need to
pick this up for v2026.07 to make sure the boards we added recently
are working correctly.
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags
2026-04-27 23:15 ` [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
@ 2026-04-29 2:18 ` Peng Fan
0 siblings, 0 replies; 14+ messages in thread
From: Peng Fan @ 2026-04-29 2:18 UTC (permalink / raw)
To: David Lechner
Cc: Jaehoon Chung, Julien Stephan, u-boot, Macpaul Lin, Ryder Lee,
Weijie Gao, Chunfeng Yun, Igor Belwon, GSS_MTK_Uboot_upstream,
Peng Fan, Tom Rini
On Mon, Apr 27, 2026 at 06:15:55PM -0500, David Lechner wrote:
>On 4/9/26 3:30 PM, David Lechner wrote:
>> After using the mtk-pwrap driver a bit, we noticed that there were a few
>> places where it was writing to registers that were not defined on all
>> platforms. The undefined registers are treated as 0, which is the DONE2
>> register on the affected platforms. This could cause the DONE2 register
>> to have an incorrect value, which could cause Linux to re-initialize the
>> PMIC unnecessarily.
>>
>> To avoid this issue and ensure that we only write to registers that are
>> defined on a given platform, we can add some more capability flags to
>> conditionally call any register writes that aren't common to all
>> platforms.
>>
>> There are also a couple of other cleanups that we do along the way. And
>> in v2, I've picked up Julien's patch to add support for MT8195 and
>> rebased on top of this.
>>
>> Signed-off-by: David Lechner <dlechner@baylibre.com>
>> ---
>> Changes in v2:
>> - Use EOPNOTSUPP.
>> - Reorder patches to reduce churn.
>> - Added new patch to fix driver description comment.
>> - Added new patch to drop chip type enum.
>> - Picked up Julien's patches from [1] and rebased on these changes.
>> - Link to [1]: https://lore.kernel.org/u-boot/20260317-mt8195-add-ufs-support-v1-0-7d731ec438ae@baylibre.com/
>> - Link to v1: https://patch.msgid.link/20260327-mtk-pmic-fixes-v1-0-ef874ca82409@baylibre.com
>>
>> ---
>> David Lechner (6):
>> power: pmic: mtk-pwrap: fix file description
>> power: pmic: mtk-pwrap: add PWRAP_CAP_WDT_SRC flag
>> power: pmic: mtk-pwrap: add init capability flag
>> power: pmic: mtk-pwrap: drop PWRAP_SLV_CAP_DUALIO on mt6359
>> power: pmic: mtk-pwrap: remove interrupt related code
>> power: pmic: mtk-pwrap: use pmic compatible to select child info
>>
>> Julien Stephan (2):
>> power: pmic: mtk-pwrap: use tabs for alignment
>> power: pmic: mtk-pwrap: add MT8195 support
>>
>> drivers/power/pmic/mtk-pwrap.c | 115 +++++++++++++++++++++--------------------
>> 1 file changed, 60 insertions(+), 55 deletions(-)
>> ---
>> base-commit: 2a1bcefce835b827bbf88a9e112d646c5c4af9c1
>> change-id: 20260317-mtk-pmic-fixes-c1523b1b0dad
>>
>> Best regards,
>> --
>> David Lechner <dlechner@baylibre.com>
>>
>
>Hi Jaehoon,
>
>Is it OK if I take this through the MediaTek tree? We need to
>pick this up for v2026.07 to make sure the boards we added recently
>are working correctly.
>
Feel free to take it through MTK tree.
Regards
Peng.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags
2026-04-09 20:30 [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
` (8 preceding siblings ...)
2026-04-27 23:15 ` [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
@ 2026-04-28 14:46 ` Julien Stephan
2026-04-29 14:23 ` David Lechner
10 siblings, 0 replies; 14+ messages in thread
From: Julien Stephan @ 2026-04-28 14:46 UTC (permalink / raw)
To: David Lechner
Cc: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
GSS_MTK_Uboot_upstream, Jaehoon Chung, Peng Fan, Tom Rini, u-boot,
Macpaul Lin
Le jeu. 9 avr. 2026 à 22:31, David Lechner <dlechner@baylibre.com> a écrit :
>
> After using the mtk-pwrap driver a bit, we noticed that there were a few
> places where it was writing to registers that were not defined on all
> platforms. The undefined registers are treated as 0, which is the DONE2
> register on the affected platforms. This could cause the DONE2 register
> to have an incorrect value, which could cause Linux to re-initialize the
> PMIC unnecessarily.
>
> To avoid this issue and ensure that we only write to registers that are
> defined on a given platform, we can add some more capability flags to
> conditionally call any register writes that aren't common to all
> platforms.
>
> There are also a couple of other cleanups that we do along the way. And
> in v2, I've picked up Julien's patch to add support for MT8195 and
> rebased on top of this.
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> Changes in v2:
> - Use EOPNOTSUPP.
> - Reorder patches to reduce churn.
> - Added new patch to fix driver description comment.
> - Added new patch to drop chip type enum.
> - Picked up Julien's patches from [1] and rebased on these changes.
> - Link to [1]: https://lore.kernel.org/u-boot/20260317-mt8195-add-ufs-support-v1-0-7d731ec438ae@baylibre.com/
> - Link to v1: https://patch.msgid.link/20260327-mtk-pmic-fixes-v1-0-ef874ca82409@baylibre.com
>
> ---
> David Lechner (6):
> power: pmic: mtk-pwrap: fix file description
> power: pmic: mtk-pwrap: add PWRAP_CAP_WDT_SRC flag
> power: pmic: mtk-pwrap: add init capability flag
> power: pmic: mtk-pwrap: drop PWRAP_SLV_CAP_DUALIO on mt6359
> power: pmic: mtk-pwrap: remove interrupt related code
> power: pmic: mtk-pwrap: use pmic compatible to select child info
>
> Julien Stephan (2):
> power: pmic: mtk-pwrap: use tabs for alignment
> power: pmic: mtk-pwrap: add MT8195 support
>
> drivers/power/pmic/mtk-pwrap.c | 115 +++++++++++++++++++++--------------------
> 1 file changed, 60 insertions(+), 55 deletions(-)
> ---
> base-commit: 2a1bcefce835b827bbf88a9e112d646c5c4af9c1
> change-id: 20260317-mtk-pmic-fixes-c1523b1b0dad
>
> Best regards,
> --
> David Lechner <dlechner@baylibre.com>
>
Thank you David for adding my patches on this series
Reviewed-by: Julien Stephan <jstephan@baylibre.com>
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags
2026-04-09 20:30 [PATCH v2 0/8] power: pmic: mtk-pwrap: add more capability flags David Lechner
` (9 preceding siblings ...)
2026-04-28 14:46 ` Julien Stephan
@ 2026-04-29 14:23 ` David Lechner
10 siblings, 0 replies; 14+ messages in thread
From: David Lechner @ 2026-04-29 14:23 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
GSS_MTK_Uboot_upstream, Jaehoon Chung, Peng Fan, Tom Rini,
David Lechner
Cc: Julien Stephan, u-boot, Macpaul Lin
On Thu, 09 Apr 2026 15:30:32 -0500, David Lechner wrote:
> power: pmic: mtk-pwrap: add more capability flags
>
> After using the mtk-pwrap driver a bit, we noticed that there were a few
> places where it was writing to registers that were not defined on all
> platforms. The undefined registers are treated as 0, which is the DONE2
> register on the affected platforms. This could cause the DONE2 register
> to have an incorrect value, which could cause Linux to re-initialize the
> PMIC unnecessarily.
>
> [...]
Applied to mediatek-for-master, thanks!
[1/8] power: pmic: mtk-pwrap: fix file description
commit: 0f50131f99a68b53c08c3c41c1a2e3e421d6fdad
[2/8] power: pmic: mtk-pwrap: add PWRAP_CAP_WDT_SRC flag
commit: 8fac923a5f15c3edd66bde274a80612387bb7bf8
[3/8] power: pmic: mtk-pwrap: add init capability flag
commit: 6fbc2ca84ec33df70a464e9a12d64115f1a2844c
[4/8] power: pmic: mtk-pwrap: drop PWRAP_SLV_CAP_DUALIO on mt6359
commit: 804e6702f3b33f8cfef15cdf45aafe77661c1a23
[5/8] power: pmic: mtk-pwrap: remove interrupt related code
commit: 095458ef73672857d1b09c666375679dd399e4d1
[6/8] power: pmic: mtk-pwrap: use pmic compatible to select child info
commit: 5f73fe49317db5ee348ee4daeadec3c082345e04
[7/8] power: pmic: mtk-pwrap: use tabs for alignment
commit: 3dede5fed1ec9847daabee87da61e162abda7ecc
[8/8] power: pmic: mtk-pwrap: add MT8195 support
commit: 4ddb07e24e7a13b0b9280c7cc6e0e2c816f32d25
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply [flat|nested] 14+ messages in thread