[PATCH 1/3] gpio: at91: Implement GPIOF_FUNC in get_function()
Eugen Hristev
eugen.hristev at linaro.org
Tue Nov 12 14:13:26 CET 2024
Hello,
On 10/18/24 23:27, Zixun LI wrote:
> This patch adds support for determining whether a gpio pin is mapped as
> peripheral function.
>
> Signed-off-by: Zixun LI <admin at hifiphile.com>
> ---
> drivers/gpio/at91_gpio.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
> index 1409db5dc1..64a6e8a4a5 100644
> --- a/drivers/gpio/at91_gpio.c
> +++ b/drivers/gpio/at91_gpio.c
> @@ -220,6 +220,15 @@ static bool at91_get_port_output(struct at91_port *at91_port, int offset)
> val = readl(&at91_port->osr);
> return val & mask;
> }
> +
> +static bool at91_get_port_pio(struct at91_port *at91_port, int offset)
The name get_port_pio is a bit confusing, can you rename it to something
more meaningful, like maybe is_periph_func or something ?
> +{
> + u32 mask, val;
> +
> + mask = 1 << offset;
> + val = readl(&at91_port->psr);
> + return val & mask;
> +}
> #endif
>
> static void at91_set_port_input(struct at91_port *at91_port, int offset,
> @@ -550,7 +559,9 @@ static int at91_gpio_get_function(struct udevice *dev, unsigned offset)
> {
> struct at91_port_priv *port = dev_get_priv(dev);
>
> - /* GPIOF_FUNC is not implemented yet */
> + if (!at91_get_port_pio(port->regs, offset))
> + return GPIOF_FUNC;
> +
> if (at91_get_port_output(port->regs, offset))
> return GPIOF_OUTPUT;
> else
More information about the U-Boot
mailing list