]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
power: pmic: mtk-pwrap: add init capability flag
authorDavid Lechner <dlechner@baylibre.com>
Thu, 9 Apr 2026 20:30:35 +0000 (15:30 -0500)
committerDavid Lechner <dlechner@baylibre.com>
Wed, 29 Apr 2026 14:08:18 +0000 (09:08 -0500)
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.

Reviewed-by: Julien Stephan <jstephan@baylibre.com>
Link: https://patch.msgid.link/20260409-mtk-pmic-fixes-v2-3-73e83aa6345b@baylibre.com
Signed-off-by: David Lechner <dlechner@baylibre.com>
drivers/power/pmic/mtk-pwrap.c

index 3ed21dcf2efe367bcd0b31f079a7441c94c15cee..38ae44f0abffee64f318a737cc5483dc0da6b7e2 100644 (file)
@@ -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[] = {