diff options
| author | Tom Rini <[email protected]> | 2026-07-06 12:00:26 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-07-06 12:00:26 -0600 |
| commit | a18265f1ccb7a272721ed4286ed3b5a6182ff424 (patch) | |
| tree | 208b16bf4bb56da3fd72dae6d67e18c224cb6e1a /drivers/gpio/mpc8xxx_gpio.c | |
| parent | 2569e25ddd5aa323cd87c7a3819c3a4f4b32302f (diff) | |
| parent | c9beb84a376853078e62f385447672fc7e8cd819 (diff) | |
Merge tag 'fsl-qoriq-next-2026-07-06' of https://source.denx.de/u-boot/custodians/u-boot-fsl-qoriq into nextnext
CI: https://source.denx.de/u-boot/custodians/u-boot-fsl-qoriq/-/pipelines/30622
- ls1028ardb: Move environment variables from header to .env file
- crypto: fsl: Hide CAAM_64BIT symbol behind FSL_CAAM dependency
- gpio: mpc8xxx: Add set_flags/get_flags ops
- power: domain: scmi: Allow failure in getting power domain attribute
Diffstat (limited to 'drivers/gpio/mpc8xxx_gpio.c')
| -rw-r--r-- | drivers/gpio/mpc8xxx_gpio.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/gpio/mpc8xxx_gpio.c b/drivers/gpio/mpc8xxx_gpio.c index 709d04017d1..40646407369 100644 --- a/drivers/gpio/mpc8xxx_gpio.c +++ b/drivers/gpio/mpc8xxx_gpio.c @@ -171,6 +171,58 @@ static int mpc8xxx_gpio_get_function(struct udevice *dev, uint gpio) return dir ? GPIOF_OUTPUT : GPIOF_INPUT; } +static int mpc8xxx_gpio_set_flags(struct udevice *dev, uint gpio, + ulong flags) +{ + u32 mask = gpio_mask(gpio); + int ret; + + /* The QorIQ GPIO pad supports open-drain only; open-source has + * no silicon counterpart, so reject it rather than silently + * pretending. + */ + if (flags & GPIOD_OPEN_SOURCE) + return -EOPNOTSUPP; + + /* GPODR is per-pin and meaningful in both directions (it stays + * latched when the pin is re-purposed), so apply it before the + * direction change. + */ + if (flags & GPIOD_OPEN_DRAIN) + mpc8xxx_gpio_open_drain_on(dev, mask); + else + mpc8xxx_gpio_open_drain_off(dev, mask); + + if (flags & GPIOD_IS_OUT) { + ret = mpc8xxx_gpio_direction_output(dev, gpio, + !!(flags & GPIOD_IS_OUT_ACTIVE)); + } else if (flags & GPIOD_IS_IN) { + ret = mpc8xxx_gpio_direction_input(dev, gpio); + } else { + ret = 0; + } + + return ret; +} + +static int mpc8xxx_gpio_get_flags(struct udevice *dev, uint gpio, + ulong *flagsp) +{ + u32 mask = gpio_mask(gpio); + ulong flags = 0; + + if (mpc8xxx_gpio_get_dir(dev, mask)) + flags |= GPIOD_IS_OUT; + else + flags |= GPIOD_IS_IN; + + if (mpc8xxx_gpio_open_drain_val(dev, mask)) + flags |= GPIOD_OPEN_DRAIN; + + *flagsp = flags; + return 0; +} + #if CONFIG_IS_ENABLED(OF_CONTROL) static int mpc8xxx_gpio_of_to_plat(struct udevice *dev) { @@ -255,6 +307,8 @@ static const struct dm_gpio_ops gpio_mpc8xxx_ops = { .get_value = mpc8xxx_gpio_get_value, .set_value = mpc8xxx_gpio_set_value, .get_function = mpc8xxx_gpio_get_function, + .set_flags = mpc8xxx_gpio_set_flags, + .get_flags = mpc8xxx_gpio_get_flags, }; static const struct udevice_id mpc8xxx_gpio_ids[] = { |
