Commit 26b95b7b authored by Haibo Chen's avatar Haibo Chen Committed by Bartosz Golaszewski

gpio: vf610: add get_direction() support

For IP which do not contain PDDR, currently use the pinmux API
pinctrl_gpio_direction_input() to config the output/input, pinmux
currently do not support get_direction(). So here add the GPIO
get_direction() support only for the IP which has Port Data
Direction Register (PDDR).
Signed-off-by: default avatarHaibo Chen <haibo.chen@nxp.com>
Link: https://lore.kernel.org/r/20240801093028.732338-3-haibo.chen@nxp.comSigned-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent 3e7ebf27
...@@ -151,6 +151,19 @@ static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio ...@@ -151,6 +151,19 @@ static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio
return pinctrl_gpio_direction_output(chip, gpio); return pinctrl_gpio_direction_output(chip, gpio);
} }
static int vf610_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)
{
struct vf610_gpio_port *port = gpiochip_get_data(gc);
u32 mask = BIT(gpio);
mask &= vf610_gpio_readl(port->gpio_base + GPIO_PDDR);
if (mask)
return GPIO_LINE_DIRECTION_OUT;
return GPIO_LINE_DIRECTION_IN;
}
static void vf610_gpio_irq_handler(struct irq_desc *desc) static void vf610_gpio_irq_handler(struct irq_desc *desc)
{ {
struct vf610_gpio_port *port = struct vf610_gpio_port *port =
...@@ -362,6 +375,12 @@ static int vf610_gpio_probe(struct platform_device *pdev) ...@@ -362,6 +375,12 @@ static int vf610_gpio_probe(struct platform_device *pdev)
gc->get = vf610_gpio_get; gc->get = vf610_gpio_get;
gc->direction_output = vf610_gpio_direction_output; gc->direction_output = vf610_gpio_direction_output;
gc->set = vf610_gpio_set; gc->set = vf610_gpio_set;
/*
* only IP has Port Data Direction Register(PDDR) can
* support get direction
*/
if (port->sdata->have_paddr)
gc->get_direction = vf610_gpio_get_direction;
/* Mask all GPIO interrupts */ /* Mask all GPIO interrupts */
for (i = 0; i < gc->ngpio; i++) for (i = 0; i < gc->ngpio; i++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment