mirror of
https://github.com/smaeul/u-boot.git
synced 2025-10-13 20:36:02 +01:00
gpio: axp: Add pull-down support for AXP22x/AXP8xx variant
The AXP221 and newer PMICs support a pull-down function on their GPIOs. Add support for it. Signed-off-by: Samuel Holland <samuel@sholland.org>
This commit is contained in:
parent
071d04bb86
commit
0c91ce4c05
@ -25,6 +25,7 @@ struct axp_gpio_desc {
|
||||
u8 npins;
|
||||
u8 status_reg;
|
||||
u8 status_offset;
|
||||
u8 pull_reg;
|
||||
u8 input_mux;
|
||||
};
|
||||
|
||||
@ -61,10 +62,21 @@ static int axp_gpio_get_function(struct udevice *dev, unsigned pin)
|
||||
static int axp_gpio_set_flags(struct udevice *dev, unsigned pin, ulong flags)
|
||||
{
|
||||
const struct axp_gpio_desc *desc = dev_get_priv(dev);
|
||||
bool pull_down = flags & GPIOD_PULL_DOWN;
|
||||
int ret;
|
||||
u8 mux;
|
||||
|
||||
if (flags & (GPIOD_MASK_DSTYPE | GPIOD_MASK_PULL))
|
||||
if (flags & (GPIOD_MASK_DSTYPE | GPIOD_PULL_UP))
|
||||
return -EINVAL;
|
||||
if (pull_down && !desc->pull_reg)
|
||||
return -EINVAL;
|
||||
|
||||
if (desc->pull_reg) {
|
||||
ret = pmic_clrsetbits(dev->parent, desc->pull_reg,
|
||||
BIT(pin), pull_down ? BIT(pin) : 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (flags & GPIOD_IS_IN)
|
||||
mux = desc->input_mux;
|
||||
@ -130,6 +142,7 @@ static const struct axp_gpio_desc axp221_gpio_desc = {
|
||||
.pins = axp221_gpio_pins,
|
||||
.npins = ARRAY_SIZE(axp221_gpio_pins),
|
||||
.status_reg = 0x94,
|
||||
.pull_reg = 0x97,
|
||||
.input_mux = 2,
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user