Skip to contentSkip to conversation

few small change for gpio-vf610

PATCH Applied [email protected] 3 participants 8 messages Aug 1, 2024 – Aug 5, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover few small change for gpio-vf610

From: Haibo Chen <[email protected]>

V2:
-add PATCH 1 to use u32 instead of unsigned long, to handle 32 pins -only one difference from V1, use u32 mask instead unsigned long.

Haibo Chen (2):
gpio: gpio-vf610: use u32 mask to handle 32 number gpios
gpio: vf610: add get_direction() support

 drivers/gpio/gpio-vf610.c | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/2 gpio: gpio-vf610: use u32 mask to handle 32 number gpios

From: Haibo Chen <[email protected]>

This gpio controller support up to 32 pins per port. And all the register width is 32 bit. So here use u32 to replace the original unsigned long.

---
 drivers/gpio/gpio-vf610.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpio/gpio-vf610.c +6 -6
index 07e5e6323e86..db68d8541597 100644
@@ -97,7 +97,7 @@ static inline u32 vf610_gpio_readl(void __iomem *reg)
 static int vf610_gpio_get(struct gpio_chip *gc, unsigned int gpio)
 {
 	struct vf610_gpio_port *port = gpiochip_get_data(gc);
-	unsigned long mask = BIT(gpio);
+	u32 mask = BIT(gpio);
 	unsigned long offset = GPIO_PDIR;
 
 	if (port->sdata->have_paddr) {
@@ -112,16 +112,16 @@ static int vf610_gpio_get(struct gpio_chip *gc, unsigned int gpio)
 static void vf610_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
 {
 	struct vf610_gpio_port *port = gpiochip_get_data(gc);
-	unsigned long mask = BIT(gpio);
+	u32 mask = BIT(gpio);
 	unsigned long offset = val ? GPIO_PSOR : GPIO_PCOR;
 
 	vf610_gpio_writel(mask, port->gpio_base + offset);
 }
 
-static int vf610_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
+static int vf610_gpio_direction_input(struct gpio_chip *chip, unsigned int gpio)
 {
 	struct vf610_gpio_port *port = gpiochip_get_data(chip);
-	unsigned long mask = BIT(gpio);
+	u32 mask = BIT(gpio);
 	u32 val;
 
 	if (port->sdata->have_paddr) {
@@ -133,11 +133,11 @@ static int vf610_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
 	return pinctrl_gpio_direction_input(chip, gpio);
 }
 
-static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned gpio,
+static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio,
 				       int value)
 {
 	struct vf610_gpio_port *port = gpiochip_get_data(chip);
-	unsigned long mask = BIT(gpio);
+	u32 mask = BIT(gpio);
 	u32 val;
 
 	vf610_gpio_set(chip, gpio, value);
Signature · 1 line
2.34.1
Reviewed-by on v2 1/2
#3 lore raw

Re: [PATCH v2 1/2] gpio: gpio-vf610: use u32 mask to handle 32 number gpios

In reply to [email protected]

Am 01.08.24 um 11:30 schrieb [email protected]:

Quoted 7 lines

From: Haibo Chen <[email protected]>

This gpio controller support up to 32 pins per port. And all the register width is 32 bit. So here use u32 to replace the original unsigned long.

#4 lore raw

PATCH v2 2/2 gpio: vf610: add get_direction() support

In reply to [email protected]

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
index db68d8541597..27eff741fe9a 100644
@@ -151,6 +151,19 @@ static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned int 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)
 {
 	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
#5 lore raw

Re: [PATCH v2 2/2] gpio: vf610: add get_direction() support

Hi Haibo,

Am 01.08.24 um 11:30 schrieb [email protected]:

Quoted 7 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 support get_direction(). So here add the GPIO get_direction() support only for the IP which has Port Data Direction Register (PDDR).

just a question about how things work:

fsl,imx7ulp-gpio and i.MX93 have PDDR, so GPIO get_direction is handled in gpio-vf610 driver
fsl,vf610-gpio doesn't have PDDR, so all GPIO direction stuff is handled in pinctrl-vf610 driver

Is this correct?

Best regards

author
#6 lore raw

RE: [PATCH v2 2/2] gpio: vf610: add get_direction() support

Quoted 20 lines

-----Original Message-----
From: Stefan Wahren <[email protected]>
Sent: 2024年8月2日 21:22
To: Bough Chen <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 2/2] gpio: vf610: add get_direction() support

Hi Haibo,

Am 01.08.24 um 11:30 schrieb [email protected]:

Quoted 7 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 support get_direction(). So here add the GPIO get_direction() support only for the IP which has Port Data Direction Register (PDDR).

Quoted 7 lines

just a question about how things work:

fsl,imx7ulp-gpio and i.MX93 have PDDR, so GPIO get_direction is handled in gpio-vf610 driver fsl,vf610-gpio doesn't have PDDR, so all GPIO direction stuff is handled in pinctrl-vf610 driver

Is this correct?

Yes, correct. vf610_pmx_gpio_set_direction() did that.

Best Regards
Haibo Chen

Quoted 2 lines

Best regards

#7 lore raw
In reply to [email protected]

From: Bartosz Golaszewski <[email protected]>

Quoted 11 lines · On Thu, 01 Aug 2024 17:30:26 +0800, [email protected] wrote:

From: Haibo Chen <[email protected]>

V2:

(quoted diff) +0 -2
-add PATCH 1 to use u32 instead of unsigned long, to handle 32 pins
-only one difference from V1, use u32 mask instead unsigned long.

Haibo Chen (2):
gpio: gpio-vf610: use u32 mask to handle 32 number gpios
gpio: vf610: add get_direction() support

[...]

Applied, thanks!

[1/2] gpio: gpio-vf610: use u32 mask to handle 32 number gpios

      commit: 3e7ebf271f935a316e9593d63f495498cde22f80
[2/2] gpio: vf610: add get_direction() support
      commit: 26b95b7b588d70b5075b597ff808543503d36ac6

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>