gpio: vf610: add get_direction() support
Subsystems (2)
PATCH 1/1 gpio: vf610: add get_direction() support
From: Haibo Chen <[email protected]>
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).
--- drivers/gpio/gpio-vf610.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/gpio/gpio-vf610.c +19 -0
@@ -151,6 +151,19 @@ static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned 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); +unsigned long 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) { struct vf610_gpio_port *port =
@@ -362,6 +375,12 @@ static int vf610_gpio_probe(struct platform_device *pdev) gc->get = vf610_gpio_get; gc->direction_output = vf610_gpio_direction_output; 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 */ for (i =0 ; i < gc->ngpio; i++)
Signature · 1 line
2.34.1
Hi Haibo,
Am 22.07.24 um 08:28 schrieb [email protected]:
Quoted 18 lines
From: Haibo Chen <[email protected]>
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 supportget_direction(). So here add the GPIOget_direction()support only for the IP which has Port Data Direction Register (PDDR).Signed-off-by Haibo Chen <[email protected]>--- drivers/gpio/gpio-vf610.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/gpio/gpio-vf610.c +0
-0
drivers/gpio/gpio-vf610.c static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, · line 157
Quoted 7 lines
drivers/gpio/gpio-vf610.c +4
-0@@ -151,6 +151,19 @@ static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned 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); +unsigned long mask =BIT (gpio);
thanks for sending this patch. I'm fine with this patch, but could we use u32 to make it clear about the range of the mask?
Regards
Quoted 25 lines
drivers/gpio/gpio-vf610.c +15
-0+ + 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) { struct vf610_gpio_port *port =@@ -362,6 +375,12 @@ static int vf610_gpio_probe(struct platform_device *pdev) gc->get = vf610_gpio_get; gc->direction_output = vf610_gpio_direction_output; 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 */ for (i =0 ; i < gc->ngpio; i++)
Quoted 34 lines
-----Original Message-----
From: Stefan Wahren <[email protected]>
Sent: 2024年7月22日 18:32
To: Bough Chen <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] gpio: vf610: addget_direction()supportHi Haibo,
Am 22.07.24 um 08:28 schrieb [email protected]:
drivers/gpio/gpio-vf610.c static int vf610_gpio_direction_output(struct
Quoted 18 lines
From: Haibo Chen <[email protected]>
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 supportget_direction(). So here add the GPIOget_direction()support only for the IP which has Port Data Direction Register (PDDR).Signed-off-by Haibo Chen <[email protected]>--- drivers/gpio/gpio-vf610.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/gpio/gpio-vf610.c +0
-0@@ -151,6 +151,19 @@ static int vf610_gpio_direction_output(struct
gpio_chip*chip, unsigned gpio,Quoted 3 lines
drivers/gpio/gpio-vf610.c +0
-0return pinctrl_gpio_direction_output (chip, gpio); }
Quoted 6 lines
drivers/gpio/gpio-vf610.c static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, · line 157
Quoted 4 lines
drivers/gpio/gpio-vf610.c +4
-0+static int vf610_gpio_get_direction (struct gpio_chip *gc,unsigned +int gpio) { +struct vf610_gpio_port *port =gpiochip_get_data (gc); +unsigned long mask =BIT (gpio);thanks for sending this patch. I'm fine with this patch, but could we use u32 to make it clear about the range of the mask?
Yes, u32 seems more clear here, but I notice all other place use unsigned long, so I keep the same code style. I go through the history of this driver, seems no specific explanation about the unsigned long. If anyone know the reason, please comment.
Best Regards
Haibo Chen
Quoted 28 lines
Regards
drivers/gpio/gpio-vf610.c static int vf610_gpio_probe(struct platform_device
Quoted 13 lines
drivers/gpio/gpio-vf610.c +9
-0+ + 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) { struct vf610_gpio_port *port =@@ -362,6 +375,12 @@ static int vf610_gpio_probe(struct platform_device*pdev)
Quoted 12 lines
drivers/gpio/gpio-vf610.c +6
-0gc->get = vf610_gpio_get; gc->direction_output = vf610_gpio_direction_output; 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 */ for (i =0 ; i < gc->ngpio; i++)
Am 23.07.24 um 04:45 schrieb Bough Chen:
Quoted 34 lines
Quoted 34 lines
-----Original Message-----
From: Stefan Wahren <[email protected]>
Sent: 2024年7月22日 18:32
To: Bough Chen <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] gpio: vf610: addget_direction()supportHi Haibo,
Am 22.07.24 um 08:28 schrieb [email protected]:
drivers/gpio/gpio-vf610.c static int vf610_gpio_direction_output(struct
Quoted 18 lines
From: Haibo Chen <[email protected]>
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 supportget_direction(). So here add the GPIOget_direction()support only for the IP which has Port Data Direction Register (PDDR).Signed-off-by Haibo Chen <[email protected]>--- drivers/gpio/gpio-vf610.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/gpio/gpio-vf610.c +0
-0@@ -151,6 +151,19 @@ static int vf610_gpio_direction_output(struct
gpio_chip*chip, unsigned gpio,Quoted 3 lines
drivers/gpio/gpio-vf610.c +0
-0return pinctrl_gpio_direction_output (chip, gpio); }
Quoted 8 lines
Quoted 6 lines
drivers/gpio/gpio-vf610.c static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, · line 157
Quoted 4 lines
drivers/gpio/gpio-vf610.c +4
-0+static int vf610_gpio_get_direction (struct gpio_chip *gc,unsigned +int gpio) { +struct vf610_gpio_port *port =gpiochip_get_data (gc); +unsigned long mask =BIT (gpio);thanks for sending this patch. I'm fine with this patch, but could we use u32 to make it clear about the range of the mask?
Yes, u32 seems more clear here, but I notice all other place use unsigned long, so I keep the same code style. I go through the history of this driver, seems no specific explanation about the unsigned long.
I understand, but i don't think there is a reason for using unsigned long. So maybe this is a good opportunity to clean this up.
Regards