Commit 7fd34722 authored by Audun Korneliussen's avatar Audun Korneliussen Committed by Benjamin Cabé
Browse files

drivers: mfd: npm2100: Add hibernate_pt mode support

Extend mfd_npm2100_hibernate function with pass_through argument,
which is used to differentiate between hibernate and hibernate_pt
modes.

Signed-off-by: default avatarAudun Korneliussen <audun.korneliussen@nordicsemi.no>
parent db4d24df
Loading
Loading
Loading
Loading
+4 −2
Changes for drivers/mfd/mfd_npm2100.c: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#define SHPHLD_WAKEUP         0xC1U
#define SHPHLD_SHPHLD         0xC2U
#define HIBERNATE_TASKS_HIBER 0xC8U
#define HIBERNATE_TASKS_HIBERPT 0xC9U
#define RESET_TASKS_RESET     0xD0U
#define RESET_BUTTON          0xD2U
#define RESET_PIN             0xD3U
@@ -337,7 +338,7 @@ int mfd_npm2100_reset(const struct device *dev)
	return i2c_reg_write_byte_dt(&config->i2c, RESET_TASKS_RESET, 1U);
}

int mfd_npm2100_hibernate(const struct device *dev, uint32_t time_ms)
int mfd_npm2100_hibernate(const struct device *dev, uint32_t time_ms, bool pass_through)
{
	const struct mfd_npm2100_config *config = dev->config;
	int ret;
@@ -365,7 +366,8 @@ int mfd_npm2100_hibernate(const struct device *dev, uint32_t time_ms)
		return ret;
	}

	return i2c_reg_write_byte_dt(&config->i2c, HIBERNATE_TASKS_HIBER, 1U);
	return i2c_reg_write_byte_dt(
		&config->i2c, pass_through ? HIBERNATE_TASKS_HIBERPT : HIBERNATE_TASKS_HIBER, 1U);
}

int mfd_npm2100_add_callback(const struct device *dev, struct gpio_callback *callback)
+4 −1
Changes for include/zephyr/drivers/mfd/npm2100.h: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -92,15 +92,18 @@ int mfd_npm2100_reset(const struct device *dev);
 * @brief npm2100 hibernate
 *
 * Enters low power state, and wakes after specified time or "shphld" pin signal.
 * Pass-through mode can be used when the battery voltage is high enough to supply the pmic directly
 * without boosting. This lowers the power consumption of the pmic when hibernate mode is active.
 *
 * @param dev npm2100 mfd device
 * @param time_ms timer value in ms. Set to 0 to disable timer.
 * @param pass_through set to use pass-through hibernate mode.
 * @retval 0 If successful
 * @retval -EINVAL if time value is too large
 * @retval -EBUSY if the timer is already in use.
 * @retval -errno In case of any bus error (see i2c_write_dt())
 */
int mfd_npm2100_hibernate(const struct device *dev, uint32_t time_ms);
int mfd_npm2100_hibernate(const struct device *dev, uint32_t time_ms, bool pass_through);

/**
 * @brief Add npm2100 event callback