[PATCH v2 2/2] power: pmic: pca9450: Add support for reset status
Paul Geurts
paul.geurts at prodrive-technologies.com
Mon Aug 18 09:43:29 CEST 2025
> PCA9450 PMIC supports reading the reset status from the PWRON_STAT
> register. Bits 7-4 give indication of the PMIC reset cause:
>
> - PWRON (BIT7) - Power ON triggered by PMIC_ON_REQ input line,
> - WDOGB (BIT6) - Boot after cold reset by WDOGB pin (watchdog reset),
> - SW_RST (BIT5) - Boot after cold reset initiated by the software,
> - PMIC_RST (BIT4) - Boot after PMIC_RST_B input line trigger.
>
> Add support for reading reset status via the sysreset framework in a
> convenient printable format.
>
> Signed-off-by: Primoz Fiser <primoz.fiser at norik.com>
Reviewed-by: Paul Geurts <paul.geurts at prodrive-technologies.com>
> ---
> Change in v2:
> - new patch as suggested by Paul Geurts
>
> Link to v1: https://lore.kernel.org/all/20250716114547.1343797-1-primoz.fiser@norik.com/
>
> drivers/power/pmic/pca9450.c | 38 ++++++++++++++++++++++++++++++++++++
> include/power/pca9450.h | 5 +++++
> 2 files changed, 43 insertions(+)
>
> diff --git a/drivers/power/pmic/pca9450.c b/drivers/power/pmic/pca9450.c
> index abc39d0a1946..24426df1a49f 100644
> --- a/drivers/power/pmic/pca9450.c
> +++ b/drivers/power/pmic/pca9450.c
> @@ -166,8 +166,46 @@ static int pca9450_sysreset_request(struct udevice *dev, enum sysreset_t type)
> return -EINPROGRESS;
> }
>
> +int pca9450_sysreset_get_status(struct udevice *dev, char *buf, int size)
> +{
> + const char *reason;
> + int ret;
> + u8 reg;
> +
> + ret = pmic_read(dev->parent, PCA9450_PWRON_STAT, ®, 1);
> + if (ret)
> + return ret;
> +
> + switch (reg) {
> + case PCA9450_PWRON_STAT_PWRON_MASK:
> + reason = "PWRON";
> + break;
> + case PCA9450_PWRON_STAT_WDOG_MASK:
> + reason = "WDOGB";
> + break;
> + case PCA9450_PWRON_STAT_SW_RST_MASK:
> + reason = "SW_RST";
> + break;
> + case PCA9450_PWRON_STAT_PMIC_RST_MASK:
> + reason = "PMIC_RST";
> + break;
> + default:
> + reason = "UNKNOWN";
> + break;
> + }
> +
> + ret = snprintf(buf, size, "Reset Status: %s\n", reason);
> + if (ret < 0) {
> + dev_err(dev, "Write reset status error (err = %d)\n", ret);
> + return -EIO;
> + }
> +
> + return 0;
> +}
> +
> static struct sysreset_ops pca9450_sysreset_ops = {
> .request = pca9450_sysreset_request,
> + .get_status = pca9450_sysreset_get_status,
> };
>
> U_BOOT_DRIVER(pca9450_sysreset) = {
> diff --git a/include/power/pca9450.h b/include/power/pca9450.h
> index 9119ef793b1f..41b7f95c0340 100644
> --- a/include/power/pca9450.h
> +++ b/include/power/pca9450.h
> @@ -75,6 +75,11 @@ enum {
> #define PCA9450_PMIC_RESET_WDOG_B_CFG_WARM 0x40
> #define PCA9450_PMIC_RESET_WDOG_B_CFG_COLD_LDO12 0x80
>
> +#define PCA9450_PWRON_STAT_PWRON_MASK 0x80
> +#define PCA9450_PWRON_STAT_WDOG_MASK 0x40
> +#define PCA9450_PWRON_STAT_SW_RST_MASK 0x20
> +#define PCA9450_PWRON_STAT_PMIC_RST_MASK 0x10
> +
> #define PCA9450_SW_RST_COLD_RST 0x14
>
> #endif
> --
> 2.34.1
br,
Paul
More information about the U-Boot
mailing list