Skip to content

Commit 9c961c0

Browse files
seov-nordicgmarull
authored andcommitted
[nrf fromtree] drivers: mfd: mfd_npm2100: add open drain and pull up config to int pin
Add possibility to configure open drain and pull up on nPM2100's interrupt output through DTS flags. Signed-off-by: Sergei Ovchinnikov <[email protected]> (cherry picked from commit 32b79cf)
1 parent 60cd202 commit 9c961c0

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

drivers/mfd/mfd_npm2100.c

+13-5
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@
5555

5656
#define EVENTS_SIZE 5U
5757

58-
#define GPIO_USAGE_INTLO 0x01U
59-
#define GPIO_USAGE_INTHI 0x02U
60-
#define GPIO_CONFIG_OUTPUT 0x02U
58+
#define GPIO_USAGE_INTLO 0x01U
59+
#define GPIO_USAGE_INTHI 0x02U
60+
#define GPIO_CONFIG_OUTPUT 0x02U
61+
#define GPIO_CONFIG_OPENDRAIN 0x04U
62+
#define GPIO_CONFIG_PULLUP 0x10U
6163

6264
#define RESET_STICKY_PWRBUT 0x04U
6365

@@ -171,10 +173,17 @@ static int config_pmic_int(const struct device *dev)
171173
{
172174
const struct mfd_npm2100_config *config = dev->config;
173175
uint8_t usage = GPIO_USAGE_INTHI;
176+
uint8_t gpio_config = GPIO_CONFIG_OUTPUT;
174177

175178
if (config->pmic_int_flags & GPIO_ACTIVE_LOW) {
176179
usage = GPIO_USAGE_INTLO;
177180
}
181+
if ((config->pmic_int_flags & GPIO_SINGLE_ENDED) != 0U) {
182+
gpio_config |= GPIO_CONFIG_OPENDRAIN;
183+
}
184+
if (config->pmic_int_flags & GPIO_PULL_UP) {
185+
gpio_config |= GPIO_CONFIG_PULLUP;
186+
}
178187

179188
/* Set specified PMIC pin to be interrupt output */
180189
int ret = i2c_reg_write_byte_dt(&config->i2c, GPIO_USAGE + config->pmic_int_pin, usage);
@@ -184,8 +193,7 @@ static int config_pmic_int(const struct device *dev)
184193
}
185194

186195
/* Configure PMIC output pin */
187-
return i2c_reg_write_byte_dt(&config->i2c, GPIO_CONFIG + config->pmic_int_pin,
188-
GPIO_CONFIG_OUTPUT);
196+
return i2c_reg_write_byte_dt(&config->i2c, GPIO_CONFIG + config->pmic_int_pin, gpio_config);
189197
}
190198

191199
static int config_shphold(const struct device *dev)

0 commit comments

Comments
 (0)