diff options
| author | David Lechner <[email protected]> | 2026-04-09 15:30:35 -0500 |
|---|---|---|
| committer | David Lechner <[email protected]> | 2026-04-29 09:08:18 -0500 |
| commit | 8c5f5ef2c913209bc9f3f44e4bba30c911570ea6 (patch) | |
| tree | fbdec66260c31d0655c1b1fedb2bf1cee969dc56 | |
| parent | 3996c209562bd17ee11672c763b76421ffe917f2 (diff) | |
power: pmic: mtk-pwrap: add init capability flag
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 <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: David Lechner <[email protected]>
| -rw-r--r-- | drivers/power/pmic/mtk-pwrap.c | 9 |
1 files changed, 8 insertions, 1 deletions
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[] = { |
