* [PATCH RFC v2 1/6] ARM: pxa: Convert Spitz OHCI to GPIO descriptors
2023-09-26 15:46 [PATCH RFC v2 0/6] ARM: pxa: GPIO descriptor conversions Duje Mihanović
@ 2023-09-26 15:46 ` Duje Mihanović
2023-09-26 16:09 ` Andy Shevchenko
2023-09-26 15:46 ` [PATCH RFC v2 2/6] ARM: pxa: Convert Spitz LEDs " Duje Mihanović
` (4 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Duje Mihanović @ 2023-09-26 15:46 UTC (permalink / raw)
To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, Andy Shevchenko
Cc: linux-arm-kernel, linux-kernel, linux-usb, linux-gpio,
Duje Mihanović
Sharp's Spitz board still uses the legacy GPIO interface for controlling
a GPIO pin related to the USB host controller.
Convert this function to use the new GPIO descriptor interface.
Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
---
arch/arm/mach-pxa/spitz.c | 13 ++++++-------
drivers/usb/host/ohci-pxa27x.c | 7 +++++++
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index cc691b199429..535e2b2e997b 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -649,23 +649,22 @@ static inline void spitz_mmc_init(void) {}
* USB Host
******************************************************************************/
#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
+GPIO_LOOKUP_SINGLE(spitz_usb_host_gpio_table, "pxa27x-ohci", "gpio-pxa",
+ SPITZ_GPIO_USB_HOST, "usb-host", GPIO_ACTIVE_LOW);
+
static int spitz_ohci_init(struct device *dev)
{
- int err;
-
- err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
- if (err)
- return err;
+ gpiod_add_lookup_table(&spitz_usb_host_gpio_table);
/* Only Port 2 is connected, setup USB Port 2 Output Control Register */
UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
- return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
+ return 0;
}
static void spitz_ohci_exit(struct device *dev)
{
- gpio_free(SPITZ_GPIO_USB_HOST);
+ gpiod_remove_lookup_table(&spitz_usb_host_gpio_table);
}
static struct pxaohci_platform_data spitz_ohci_platform_data = {
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 357d9aee38a3..b70d452ca7c2 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -121,6 +121,7 @@ struct pxa27x_ohci {
void __iomem *mmio_base;
struct regulator *vbus[3];
bool vbus_enabled[3];
+ struct gpio_desc *usb_host;
};
#define to_pxa27x_ohci(hcd) (struct pxa27x_ohci *)(hcd_to_ohci(hcd)->priv)
@@ -447,6 +448,10 @@ static int ohci_hcd_pxa27x_probe(struct platform_device *pdev)
pxa_ohci = to_pxa27x_ohci(hcd);
pxa_ohci->clk = usb_clk;
pxa_ohci->mmio_base = (void __iomem *)hcd->regs;
+ pxa_ohci->usb_host = gpiod_get_optional(&pdev->dev, "usb-host", GPIOD_OUT_LOW);
+ if (IS_ERR(pxa_ohci->usb_host))
+ dev_warn(&pdev->dev, "failed to get USB host GPIO with %pe\n",
+ pxa_ohci->usb_host);
for (i = 0; i < 3; ++i) {
char name[6];
@@ -512,6 +517,8 @@ static void ohci_hcd_pxa27x_remove(struct platform_device *pdev)
for (i = 0; i < 3; ++i)
pxa27x_ohci_set_vbus_power(pxa_ohci, i, false);
+ gpiod_put(pxa_ohci->usb_host);
+
usb_put_hcd(hcd);
}
--
2.42.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RFC v2 1/6] ARM: pxa: Convert Spitz OHCI to GPIO descriptors
2023-09-26 15:46 ` [PATCH RFC v2 1/6] ARM: pxa: Convert Spitz OHCI to GPIO descriptors Duje Mihanović
@ 2023-09-26 16:09 ` Andy Shevchenko
0 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2023-09-26 16:09 UTC (permalink / raw)
To: Duje Mihanović
Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, linux-arm-kernel, linux-kernel, linux-usb,
linux-gpio
On Tue, Sep 26, 2023 at 05:46:22PM +0200, Duje Mihanović wrote:
> Sharp's Spitz board still uses the legacy GPIO interface for controlling
> a GPIO pin related to the USB host controller.
>
> Convert this function to use the new GPIO descriptor interface.
...
> + pxa_ohci->usb_host = gpiod_get_optional(&pdev->dev, "usb-host", GPIOD_OUT_LOW);
> + if (IS_ERR(pxa_ohci->usb_host))
> + dev_warn(&pdev->dev, "failed to get USB host GPIO with %pe\n",
> + pxa_ohci->usb_host);
No, with _optional() you should terminate the execution and bail out. The idea
behind *optional* is that we skip errors only for the cases when GPIO is not
provided. Otherwise we need to handle the errors (yes, the dev_err() has to
be used).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RFC v2 2/6] ARM: pxa: Convert Spitz LEDs to GPIO descriptors
2023-09-26 15:46 [PATCH RFC v2 0/6] ARM: pxa: GPIO descriptor conversions Duje Mihanović
2023-09-26 15:46 ` [PATCH RFC v2 1/6] ARM: pxa: Convert Spitz OHCI to GPIO descriptors Duje Mihanović
@ 2023-09-26 15:46 ` Duje Mihanović
2023-09-26 20:21 ` Linus Walleij
2023-09-26 15:46 ` [PATCH RFC v2 3/6] ARM: pxa: Convert Spitz CF power control " Duje Mihanović
` (3 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Duje Mihanović @ 2023-09-26 15:46 UTC (permalink / raw)
To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, Andy Shevchenko
Cc: linux-arm-kernel, linux-kernel, linux-usb, linux-gpio,
Duje Mihanović
Sharp's Spitz board still uses the legacy GPIO interface for configuring
its two onboard LEDs.
Convert them to use the GPIO descriptor interface.
Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
---
arch/arm/mach-pxa/spitz.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 535e2b2e997b..91c4b208973c 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -452,16 +452,25 @@ static inline void spitz_keys_init(void) {}
* LEDs
******************************************************************************/
#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
+static struct gpiod_lookup_table spitz_led_gpio_table = {
+ .dev_id = "leds-gpio",
+ .table = {
+ GPIO_LOOKUP("pxa-gpio", SPITZ_GPIO_LED_ORANGE, "led_orange",
+ GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP("pxa-gpio", SPITZ_GPIO_LED_GREEN, "led_green",
+ GPIO_ACTIVE_HIGH),
+ { }
+ }
+};
+
static struct gpio_led spitz_gpio_leds[] = {
{
.name = "spitz:amber:charge",
.default_trigger = "sharpsl-charge",
- .gpio = SPITZ_GPIO_LED_ORANGE,
},
{
.name = "spitz:green:hddactivity",
.default_trigger = "disk-activity",
- .gpio = SPITZ_GPIO_LED_GREEN,
},
};
@@ -480,6 +489,11 @@ static struct platform_device spitz_led_device = {
static void __init spitz_leds_init(void)
{
+ gpiod_add_lookup_table(&spitz_led_gpio_table);
+ spitz_gpio_leds[0].gpiod = gpiod_get(&spitz_led_device.dev,
+ "led_orange", GPIOD_ASIS);
+ spitz_gpio_leds[1].gpiod = gpiod_get(&spitz_led_device.dev,
+ "led_green", GPIOD_ASIS);
platform_device_register(&spitz_led_device);
}
#else
--
2.42.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RFC v2 2/6] ARM: pxa: Convert Spitz LEDs to GPIO descriptors
2023-09-26 15:46 ` [PATCH RFC v2 2/6] ARM: pxa: Convert Spitz LEDs " Duje Mihanović
@ 2023-09-26 20:21 ` Linus Walleij
0 siblings, 0 replies; 17+ messages in thread
From: Linus Walleij @ 2023-09-26 20:21 UTC (permalink / raw)
To: Duje Mihanović
Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Bartosz Golaszewski,
Andy Shevchenko, linux-arm-kernel, linux-kernel, linux-usb,
linux-gpio
Hi Duje,
thanks for your patch!
On Tue, Sep 26, 2023 at 5:46 PM Duje Mihanović <duje.mihanovic@skole.hr> wrote:
> Sharp's Spitz board still uses the legacy GPIO interface for configuring
> its two onboard LEDs.
>
> Convert them to use the GPIO descriptor interface.
>
> Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
(...)
> +static struct gpiod_lookup_table spitz_led_gpio_table = {
> + .dev_id = "leds-gpio",
> + .table = {
> + GPIO_LOOKUP("pxa-gpio", SPITZ_GPIO_LED_ORANGE, "led_orange",
> + GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("pxa-gpio", SPITZ_GPIO_LED_GREEN, "led_green",
> + GPIO_ACTIVE_HIGH),
Unfortunately this is not how leds-gpio works.
You have to have the name be NULL instead of "led_orange" etc, and
put the LEDs in index order, in this case something like;
+ .dev_id = "leds-gpio",
+ .table = {
+ GPIO_LOOKUP_IDX("pxa-gpio", SPITZ_GPIO_LED_ORANGE,
NULL, 0, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("pxa-gpio", SPITZ_GPIO_LED_GREEN,
NULL, 1, GPIO_ACTIVE_HIGH),
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RFC v2 3/6] ARM: pxa: Convert Spitz CF power control to GPIO descriptors
2023-09-26 15:46 [PATCH RFC v2 0/6] ARM: pxa: GPIO descriptor conversions Duje Mihanović
2023-09-26 15:46 ` [PATCH RFC v2 1/6] ARM: pxa: Convert Spitz OHCI to GPIO descriptors Duje Mihanović
2023-09-26 15:46 ` [PATCH RFC v2 2/6] ARM: pxa: Convert Spitz LEDs " Duje Mihanović
@ 2023-09-26 15:46 ` Duje Mihanović
2023-09-26 16:15 ` Andy Shevchenko
2023-09-26 20:26 ` Linus Walleij
2023-09-26 15:46 ` [PATCH RFC v2 4/6] ARM: pxa: Convert reset driver " Duje Mihanović
` (2 subsequent siblings)
5 siblings, 2 replies; 17+ messages in thread
From: Duje Mihanović @ 2023-09-26 15:46 UTC (permalink / raw)
To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, Andy Shevchenko
Cc: linux-arm-kernel, linux-kernel, linux-usb, linux-gpio,
Duje Mihanović
Sharp's Spitz board still uses the legacy GPIO interface for controlling
the power supply to its CF and SD card slots.
Convert it to use the GPIO descriptor interface.
Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
---
arch/arm/mach-pxa/spitz.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 91c4b208973c..616305978727 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -133,6 +133,10 @@ static unsigned long spitz_pin_config[] __initdata = {
* Scoop GPIO expander
******************************************************************************/
#if defined(CONFIG_SHARP_SCOOP) || defined(CONFIG_SHARP_SCOOP_MODULE)
+GPIO_LOOKUP_SINGLE(spitz_card_pwr_ctrl_gpio_table, "pxa2xx-mci.0",
+ "sharp-scoop", SPITZ_GPIO_CF_POWER, "cf_power",
+ GPIO_ACTIVE_HIGH);
+
/* SCOOP Device #1 */
static struct resource spitz_scoop_1_resources[] = {
[0] = {
@@ -190,6 +194,7 @@ struct platform_device spitz_scoop_2_device = {
static void __init spitz_scoop_init(void)
{
platform_device_register(&spitz_scoop_1_device);
+ gpiod_add_lookup_table(&spitz_card_pwr_ctrl_gpio_table);
/* Akita doesn't have the second SCOOP chip */
if (!machine_is_akita())
@@ -201,9 +206,18 @@ static void __maybe_unused spitz_card_pwr_ctrl(uint8_t enable, uint8_t new_cpr)
{
unsigned short cpr;
unsigned long flags;
+ struct gpio_desc *cf_power;
+
+ cf_power = gpiod_get(&pxa_device_mci.dev, "cf_power", GPIOD_ASIS);
+ if (IS_ERR(cf_power)) {
+ dev_err(&pxa_device_mci.dev,
+ "failed to get power control GPIO with %ld\n",
+ PTR_ERR(cf_power));
+ return;
+ }
if (new_cpr & 0x7) {
- gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
+ gpiod_direction_output(cf_power, 1);
mdelay(5);
}
@@ -222,8 +236,10 @@ static void __maybe_unused spitz_card_pwr_ctrl(uint8_t enable, uint8_t new_cpr)
if (!(cpr & 0x7)) {
mdelay(1);
- gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
+ gpiod_direction_output(cf_power, 0);
}
+
+ gpiod_put(cf_power);
}
#else
--
2.42.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RFC v2 3/6] ARM: pxa: Convert Spitz CF power control to GPIO descriptors
2023-09-26 15:46 ` [PATCH RFC v2 3/6] ARM: pxa: Convert Spitz CF power control " Duje Mihanović
@ 2023-09-26 16:15 ` Andy Shevchenko
2023-09-27 12:56 ` Duje Mihanović
2023-09-26 20:26 ` Linus Walleij
1 sibling, 1 reply; 17+ messages in thread
From: Andy Shevchenko @ 2023-09-26 16:15 UTC (permalink / raw)
To: Duje Mihanović
Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, linux-arm-kernel, linux-kernel, linux-usb,
linux-gpio
On Tue, Sep 26, 2023 at 05:46:24PM +0200, Duje Mihanović wrote:
> Sharp's Spitz board still uses the legacy GPIO interface for controlling
> the power supply to its CF and SD card slots.
>
> Convert it to use the GPIO descriptor interface.
...
> + cf_power = gpiod_get(&pxa_device_mci.dev, "cf_power", GPIOD_ASIS);
> + if (IS_ERR(cf_power)) {
> + dev_err(&pxa_device_mci.dev,
> + "failed to get power control GPIO with %ld\n",
> + PTR_ERR(cf_power));
> + return;
> + }
> + gpiod_put(cf_power);
Don't you want to use guarded gpiod_get()?
Okay, it seems not yet in the pending list, but we can survive without that.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RFC v2 3/6] ARM: pxa: Convert Spitz CF power control to GPIO descriptors
2023-09-26 16:15 ` Andy Shevchenko
@ 2023-09-27 12:56 ` Duje Mihanović
2023-09-27 13:46 ` Andy Shevchenko
0 siblings, 1 reply; 17+ messages in thread
From: Duje Mihanović @ 2023-09-27 12:56 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, linux-arm-kernel, linux-kernel, linux-usb,
linux-gpio
On Tuesday, September 26, 2023 6:15:37 PM CEST Andy Shevchenko wrote:
> On Tue, Sep 26, 2023 at 05:46:24PM +0200, Duje Mihanović wrote:
> > Sharp's Spitz board still uses the legacy GPIO interface for controlling
> > the power supply to its CF and SD card slots.
> >
> > Convert it to use the GPIO descriptor interface.
>
> ...
>
> > + cf_power = gpiod_get(&pxa_device_mci.dev, "cf_power", GPIOD_ASIS);
> > + if (IS_ERR(cf_power)) {
> > + dev_err(&pxa_device_mci.dev,
> > + "failed to get power control GPIO with
%ld\n",
> > + PTR_ERR(cf_power));
> > + return;
> > + }
> >
> > + gpiod_put(cf_power);
>
> Don't you want to use guarded gpiod_get()?
> Okay, it seems not yet in the pending list, but we can survive without that.
Can you please elaborate? If I understand correctly, the if statement right
after gpiod_get is a guard.
Regards,
Duje
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RFC v2 3/6] ARM: pxa: Convert Spitz CF power control to GPIO descriptors
2023-09-27 12:56 ` Duje Mihanović
@ 2023-09-27 13:46 ` Andy Shevchenko
0 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2023-09-27 13:46 UTC (permalink / raw)
To: Duje Mihanović
Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, linux-arm-kernel, linux-kernel, linux-usb,
linux-gpio
On Wed, Sep 27, 2023 at 02:56:07PM +0200, Duje Mihanović wrote:
> On Tuesday, September 26, 2023 6:15:37 PM CEST Andy Shevchenko wrote:
> > On Tue, Sep 26, 2023 at 05:46:24PM +0200, Duje Mihanović wrote:
...
> > > + cf_power = gpiod_get(&pxa_device_mci.dev, "cf_power", GPIOD_ASIS);
> > > + if (IS_ERR(cf_power)) {
> > > + dev_err(&pxa_device_mci.dev,
> > > + "failed to get power control GPIO with
> %ld\n",
> > > + PTR_ERR(cf_power));
> > > + return;
> > > + }
> > >
> > > + gpiod_put(cf_power);
> >
> > Don't you want to use guarded gpiod_get()?
> > Okay, it seems not yet in the pending list, but we can survive without that.
>
> Can you please elaborate? If I understand correctly, the if statement right
> after gpiod_get is a guard.
It's about RAII version of the gpiod_get(). It's quite a new thing
in the Linux kernel.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RFC v2 3/6] ARM: pxa: Convert Spitz CF power control to GPIO descriptors
2023-09-26 15:46 ` [PATCH RFC v2 3/6] ARM: pxa: Convert Spitz CF power control " Duje Mihanović
2023-09-26 16:15 ` Andy Shevchenko
@ 2023-09-26 20:26 ` Linus Walleij
1 sibling, 0 replies; 17+ messages in thread
From: Linus Walleij @ 2023-09-26 20:26 UTC (permalink / raw)
To: Duje Mihanović
Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Bartosz Golaszewski,
Andy Shevchenko, linux-arm-kernel, linux-kernel, linux-usb,
linux-gpio
On Tue, Sep 26, 2023 at 5:46 PM Duje Mihanović <duje.mihanovic@skole.hr> wrote:
> Sharp's Spitz board still uses the legacy GPIO interface for controlling
> the power supply to its CF and SD card slots.
>
> Convert it to use the GPIO descriptor interface.
>
> Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RFC v2 4/6] ARM: pxa: Convert reset driver to GPIO descriptors
2023-09-26 15:46 [PATCH RFC v2 0/6] ARM: pxa: GPIO descriptor conversions Duje Mihanović
` (2 preceding siblings ...)
2023-09-26 15:46 ` [PATCH RFC v2 3/6] ARM: pxa: Convert Spitz CF power control " Duje Mihanović
@ 2023-09-26 15:46 ` Duje Mihanović
2023-09-26 16:17 ` Andy Shevchenko
2023-09-26 20:26 ` Linus Walleij
2023-09-26 15:46 ` [PATCH RFC v2 5/6] ARM: pxa: Convert Spitz hsync " Duje Mihanović
2023-09-26 15:46 ` [PATCH RFC v2 6/6] ARM: pxa: Convert gumstix Bluetooth " Duje Mihanović
5 siblings, 2 replies; 17+ messages in thread
From: Duje Mihanović @ 2023-09-26 15:46 UTC (permalink / raw)
To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, Andy Shevchenko
Cc: linux-arm-kernel, linux-kernel, linux-usb, linux-gpio,
Duje Mihanović
The PXA reset driver still uses the legacy GPIO interface for
configuring and asserting the reset pin.
Convert it to use the GPIO descriptor interface.
Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
---
arch/arm/mach-pxa/reset.c | 39 +++++++++++++--------------------------
arch/arm/mach-pxa/reset.h | 3 +--
arch/arm/mach-pxa/spitz.c | 6 +++++-
3 files changed, 19 insertions(+), 29 deletions(-)
diff --git a/arch/arm/mach-pxa/reset.c b/arch/arm/mach-pxa/reset.c
index 27293549f8ad..dfcd6c45398d 100644
--- a/arch/arm/mach-pxa/reset.c
+++ b/arch/arm/mach-pxa/reset.c
@@ -2,7 +2,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/io.h>
#include <asm/proc-fns.h>
#include <asm/system_misc.h>
@@ -14,33 +14,20 @@
static void do_hw_reset(void);
-static int reset_gpio = -1;
+static struct gpio_desc *reset_gpio = NULL;
-int init_gpio_reset(int gpio, int output, int level)
+int init_gpio_reset(int output, int level)
{
- int rc;
-
- rc = gpio_request(gpio, "reset generator");
- if (rc) {
- printk(KERN_ERR "Can't request reset_gpio\n");
- goto out;
+ reset_gpio = gpiod_get(NULL, "reset generator", GPIOD_ASIS);
+ if (IS_ERR(reset_gpio)) {
+ pr_err("Can't request reset_gpio: %pe\n", reset_gpio);
+ return PTR_ERR(reset_gpio);
}
if (output)
- rc = gpio_direction_output(gpio, level);
+ return gpiod_direction_output(reset_gpio, level);
else
- rc = gpio_direction_input(gpio);
- if (rc) {
- printk(KERN_ERR "Can't configure reset_gpio\n");
- gpio_free(gpio);
- goto out;
- }
-
-out:
- if (!rc)
- reset_gpio = gpio;
-
- return rc;
+ return gpiod_direction_input(reset_gpio);
}
/*
@@ -50,16 +37,16 @@ int init_gpio_reset(int gpio, int output, int level)
*/
static void do_gpio_reset(void)
{
- BUG_ON(reset_gpio == -1);
+ BUG_ON(IS_ERR(reset_gpio));
/* drive it low */
- gpio_direction_output(reset_gpio, 0);
+ gpiod_direction_output(reset_gpio, 0);
mdelay(2);
/* rising edge or drive high */
- gpio_set_value(reset_gpio, 1);
+ gpiod_set_value(reset_gpio, 1);
mdelay(2);
/* falling edge */
- gpio_set_value(reset_gpio, 0);
+ gpiod_set_value(reset_gpio, 0);
/* give it some time */
mdelay(10);
diff --git a/arch/arm/mach-pxa/reset.h b/arch/arm/mach-pxa/reset.h
index 963dd190bc13..5864f61a0e94 100644
--- a/arch/arm/mach-pxa/reset.h
+++ b/arch/arm/mach-pxa/reset.h
@@ -13,10 +13,9 @@ extern void pxa_register_wdt(unsigned int reset_status);
/**
* init_gpio_reset() - register GPIO as reset generator
- * @gpio: gpio nr
* @output: set gpio as output instead of input during normal work
* @level: output level
*/
-extern int init_gpio_reset(int gpio, int output, int level);
+extern int init_gpio_reset(int output, int level);
#endif /* __ASM_ARCH_RESET_H */
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 616305978727..94bcb187713b 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -1024,9 +1024,13 @@ static void spitz_restart(enum reboot_mode mode, const char *cmd)
spitz_poweroff();
}
+GPIO_LOOKUP_SINGLE(spitz_reset_gpio_table, NULL, "pxa-gpio",
+ SPITZ_GPIO_ON_RESET, "reset generator", GPIO_ACTIVE_HIGH);
+
static void __init spitz_init(void)
{
- init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0);
+ gpiod_add_lookup_table(&spitz_reset_gpio_table);
+ init_gpio_reset(1, 0);
pm_power_off = spitz_poweroff;
PMCR = 0x00;
--
2.42.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RFC v2 4/6] ARM: pxa: Convert reset driver to GPIO descriptors
2023-09-26 15:46 ` [PATCH RFC v2 4/6] ARM: pxa: Convert reset driver " Duje Mihanović
@ 2023-09-26 16:17 ` Andy Shevchenko
2023-09-26 20:26 ` Linus Walleij
1 sibling, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2023-09-26 16:17 UTC (permalink / raw)
To: Duje Mihanović
Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, linux-arm-kernel, linux-kernel, linux-usb,
linux-gpio
On Tue, Sep 26, 2023 at 05:46:25PM +0200, Duje Mihanović wrote:
> The PXA reset driver still uses the legacy GPIO interface for
> configuring and asserting the reset pin.
>
> Convert it to use the GPIO descriptor interface.
...
> +static struct gpio_desc *reset_gpio = NULL;
Assignment is not needed, it's guaranteed to be NULL by the C standard.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RFC v2 4/6] ARM: pxa: Convert reset driver to GPIO descriptors
2023-09-26 15:46 ` [PATCH RFC v2 4/6] ARM: pxa: Convert reset driver " Duje Mihanović
2023-09-26 16:17 ` Andy Shevchenko
@ 2023-09-26 20:26 ` Linus Walleij
1 sibling, 0 replies; 17+ messages in thread
From: Linus Walleij @ 2023-09-26 20:26 UTC (permalink / raw)
To: Duje Mihanović
Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Bartosz Golaszewski,
Andy Shevchenko, linux-arm-kernel, linux-kernel, linux-usb,
linux-gpio
On Tue, Sep 26, 2023 at 5:46 PM Duje Mihanović <duje.mihanovic@skole.hr> wrote:
> The PXA reset driver still uses the legacy GPIO interface for
> configuring and asserting the reset pin.
>
> Convert it to use the GPIO descriptor interface.
>
> Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
Looks OK to me, there are details I would do differently,
but hey: I'm just happy this gets done.
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RFC v2 5/6] ARM: pxa: Convert Spitz hsync to GPIO descriptors
2023-09-26 15:46 [PATCH RFC v2 0/6] ARM: pxa: GPIO descriptor conversions Duje Mihanović
` (3 preceding siblings ...)
2023-09-26 15:46 ` [PATCH RFC v2 4/6] ARM: pxa: Convert reset driver " Duje Mihanović
@ 2023-09-26 15:46 ` Duje Mihanović
2023-09-26 16:19 ` Andy Shevchenko
2023-09-26 15:46 ` [PATCH RFC v2 6/6] ARM: pxa: Convert gumstix Bluetooth " Duje Mihanović
5 siblings, 1 reply; 17+ messages in thread
From: Duje Mihanović @ 2023-09-26 15:46 UTC (permalink / raw)
To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, Andy Shevchenko
Cc: linux-arm-kernel, linux-kernel, linux-usb, linux-gpio,
Duje Mihanović
Sharp's Spitz still uses the legacy GPIO interface in its
wait_for_hsync() function.
Convert it to use the GPIO descriptor interface.
Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
---
arch/arm/mach-pxa/spitz.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 94bcb187713b..5c8f497b71ec 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -520,12 +520,14 @@ static inline void spitz_leds_init(void) {}
* SSP Devices
******************************************************************************/
#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
+static struct gpio_desc *hsync = NULL;
+
static void spitz_ads7846_wait_for_hsync(void)
{
- while (gpio_get_value(SPITZ_GPIO_HSYNC))
+ while (gpiod_get_value(hsync))
cpu_relax();
- while (!gpio_get_value(SPITZ_GPIO_HSYNC))
+ while (!gpiod_get_value(hsync))
cpu_relax();
}
@@ -543,6 +545,8 @@ static struct gpiod_lookup_table spitz_ads7846_gpio_table = {
.table = {
GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_TP_INT,
"pendown", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_HSYNC,
+ "hsync", GPIO_ACTIVE_LOW),
{ }
},
};
@@ -622,6 +626,11 @@ static void __init spitz_spi_init(void)
gpiod_add_lookup_table(&spitz_ads7846_gpio_table);
gpiod_add_lookup_table(&spitz_spi_gpio_table);
+ hsync = gpiod_get(NULL, "hsync", GPIOD_IN);
+ if (IS_ERR(hsync)) {
+ pr_err("Failed to get hsync GPIO: %ld\n", PTR_ERR(hsync));
+ return;
+ }
pxa2xx_set_spi_info(2, &spitz_spi_info);
spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
}
--
2.42.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RFC v2 5/6] ARM: pxa: Convert Spitz hsync to GPIO descriptors
2023-09-26 15:46 ` [PATCH RFC v2 5/6] ARM: pxa: Convert Spitz hsync " Duje Mihanović
@ 2023-09-26 16:19 ` Andy Shevchenko
2023-09-27 12:54 ` Duje Mihanović
0 siblings, 1 reply; 17+ messages in thread
From: Andy Shevchenko @ 2023-09-26 16:19 UTC (permalink / raw)
To: Duje Mihanović
Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, linux-arm-kernel, linux-kernel, linux-usb,
linux-gpio
On Tue, Sep 26, 2023 at 05:46:26PM +0200, Duje Mihanović wrote:
> Sharp's Spitz still uses the legacy GPIO interface in its
> wait_for_hsync() function.
>
> Convert it to use the GPIO descriptor interface.
...
> +static struct gpio_desc *hsync = NULL;
Assignment is redundant.
...
> gpiod_add_lookup_table(&spitz_ads7846_gpio_table);
> gpiod_add_lookup_table(&spitz_spi_gpio_table);
> + hsync = gpiod_get(NULL, "hsync", GPIOD_IN);
> + if (IS_ERR(hsync)) {
> + pr_err("Failed to get hsync GPIO: %ld\n", PTR_ERR(hsync));
> + return;
> + }
> pxa2xx_set_spi_info(2, &spitz_spi_info);
> spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
Yeah, but the question is, if GPIO request fails, can we instantiate at least
one device and move on?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RFC v2 5/6] ARM: pxa: Convert Spitz hsync to GPIO descriptors
2023-09-26 16:19 ` Andy Shevchenko
@ 2023-09-27 12:54 ` Duje Mihanović
0 siblings, 0 replies; 17+ messages in thread
From: Duje Mihanović @ 2023-09-27 12:54 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, linux-arm-kernel, linux-kernel, linux-usb,
linux-gpio
On Tuesday, September 26, 2023 6:19:23 PM CEST Andy Shevchenko wrote:
> On Tue, Sep 26, 2023 at 05:46:26PM +0200, Duje Mihanović wrote:
> > gpiod_add_lookup_table(&spitz_ads7846_gpio_table);
> > gpiod_add_lookup_table(&spitz_spi_gpio_table);
> >
> > + hsync = gpiod_get(NULL, "hsync", GPIOD_IN);
> > + if (IS_ERR(hsync)) {
> > + pr_err("Failed to get hsync GPIO: %ld\n", PTR_ERR(hsync));
> > + return;
> > + }
> >
> > pxa2xx_set_spi_info(2, &spitz_spi_info);
> > spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
>
> Yeah, but the question is, if GPIO request fails, can we instantiate at
least one device and move on?
I see. If the touchscreen is the first out of 3 devices in that array, would
something like this do:
spi_register_board_info(ARRAY_AND_SIZE(&spitz_spi_devices[1]));
Regards,
Duje
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RFC v2 6/6] ARM: pxa: Convert gumstix Bluetooth to GPIO descriptors
2023-09-26 15:46 [PATCH RFC v2 0/6] ARM: pxa: GPIO descriptor conversions Duje Mihanović
` (4 preceding siblings ...)
2023-09-26 15:46 ` [PATCH RFC v2 5/6] ARM: pxa: Convert Spitz hsync " Duje Mihanović
@ 2023-09-26 15:46 ` Duje Mihanović
5 siblings, 0 replies; 17+ messages in thread
From: Duje Mihanović @ 2023-09-26 15:46 UTC (permalink / raw)
To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
Alan Stern, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, Andy Shevchenko
Cc: linux-arm-kernel, linux-kernel, linux-usb, linux-gpio,
Duje Mihanović
Gumstix still uses the legacy GPIO interface for resetting the Bluetooth
device.
Convert it to use the GPIO descriptor interface.
Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
---
arch/arm/mach-pxa/gumstix.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/arch/arm/mach-pxa/gumstix.c b/arch/arm/mach-pxa/gumstix.c
index c9f0f62187bd..14e1b9274d7a 100644
--- a/arch/arm/mach-pxa/gumstix.c
+++ b/arch/arm/mach-pxa/gumstix.c
@@ -20,8 +20,8 @@
#include <linux/delay.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
+#include <linux/gpio/consumer.h>
#include <linux/gpio/machine.h>
-#include <linux/gpio.h>
#include <linux/err.h>
#include <linux/clk.h>
@@ -129,6 +129,9 @@ static void gumstix_udc_init(void)
#endif
#ifdef CONFIG_BT
+GPIO_LOOKUP_SINGLE(gumstix_bt_gpio_table, "pxa2xx-uart.1", "pxa-gpio",
+ GPIO_GUMSTIX_BTRESET, "BTRST", GPIO_ACTIVE_LOW);
+
/* Normally, the bootloader would have enabled this 32kHz clock but many
** boards still have u-boot 1.1.4 so we check if it has been turned on and
** if not, we turn it on with a warning message. */
@@ -153,24 +156,23 @@ static void gumstix_setup_bt_clock(void)
static void __init gumstix_bluetooth_init(void)
{
- int err;
+ struct gpio_desc *desc;
+
+ gpiod_add_lookup_table(&gumstix_bt_gpio_table);
gumstix_setup_bt_clock();
- err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
- if (err) {
+ desc = gpiod_get(&pxa_device_btuart.dev, "BTRST", GPIOD_OUT_HIGH);
+ if (IS_ERR(desc)) {
pr_err("gumstix: failed request gpio for bluetooth reset\n");
return;
}
- err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
- if (err) {
- pr_err("gumstix: can't reset bluetooth\n");
- return;
- }
- gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
+ gpiod_set_value(desc, 0);
udelay(100);
- gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
+ gpiod_set_value(desc, 1);
+
+ gpiod_put(desc);
}
#else
static void gumstix_bluetooth_init(void)
--
2.42.0
^ permalink raw reply related [flat|nested] 17+ messages in thread