2023-09-26 15:58:17

by Duje Mihanović

[permalink] [raw]
Subject: [PATCH RFC v2 5/6] ARM: pxa: Convert Spitz hsync to GPIO descriptors

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ć <[email protected]>
---
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



2023-09-26 16:43:16

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH RFC v2 5/6] ARM: pxa: Convert Spitz hsync to GPIO descriptors

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


2023-09-27 13:11:38

by Duje Mihanović

[permalink] [raw]
Subject: Re: [PATCH RFC v2 5/6] ARM: pxa: Convert Spitz hsync to GPIO descriptors

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