Skip to contentSkip to conversation

backlight: corgi: Fix gpio numbers for backlight controls

PATCH In review Laurence de Bruxelles 4 participants 13 messages Jun 17, 2022 – Jul 5, 2022

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

PATCH 1/1 backlight: corgi: Fix gpio numbers for backlight controls

With recent stable kernels on my Zaurus Akita I am unable to change the backlight brightness, as the necessary files are not in the sys filesystem, and at startup I get the following errors:

corgi-lcd spi2.1: requested GPIO 0 (207) is out of range [0..120] for chip gpio-pxa
corgi-lcd: probe of spi2.1 failed with error -22

Looking at recent changes to the Corgi backlight driver, I found that commit ee0c8e494cc3 ("backlight: corgi: Convert to use GPIO descriptors") replaced the use of the deprecated integer-based GPIO interface, but didn't convert the GPIO numbers in the platform header to match this. I think this is what causes the error, as the GPIOs for the backlight are part of an expander chip with a GPIO base number larger than the number of GPIOs for the gpio-pxa device.

This patch fixes things by updating the GPIO numbers for the backlight, simply by dropping the GPIO base. It also updates the GPIO lookups to look in the table for the appropriate expander. For the Akita platform the expander with i2c address 0-0018 is used, for Spitz and Borzoi the second Sharp SCOOP expander is used.

I've tested this patch with real Akita and Spitz handhelds, as well as with QEMU.

Fixes ee0c8e494cc3 ("backlight: corgi: Convert to use GPIO descriptors")
---
 arch/arm/mach-pxa/spitz.c |  8 ++++----
 arch/arm/mach-pxa/spitz.h | 34 +++++++++++++++++-----------------
 2 files changed, 21 insertions(+), 21 deletions(-)
arch/arm/mach-pxa/spitz.c +4 -4
index dd88953adc9d..ede3727fc91d 100644
@@ -524,9 +524,9 @@ static void spitz_bl_kick_battery(void)
 static struct gpiod_lookup_table spitz_lcdcon_gpio_table = {
 	.dev_id = "spi2.1",
 	.table = {
-		GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_BACKLIGHT_CONT,
+		GPIO_LOOKUP("sharp-scoop.1", SPITZ_GPIO_BACKLIGHT_CONT,
 			    "BL_CONT", GPIO_ACTIVE_LOW),
-		GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_BACKLIGHT_ON,
+		GPIO_LOOKUP("sharp-scoop.1", SPITZ_GPIO_BACKLIGHT_ON,
 			    "BL_ON", GPIO_ACTIVE_HIGH),
 		{ },
 	},
@@ -535,9 +535,9 @@ static struct gpiod_lookup_table spitz_lcdcon_gpio_table = {
 static struct gpiod_lookup_table akita_lcdcon_gpio_table = {
 	.dev_id = "spi2.1",
 	.table = {
-		GPIO_LOOKUP("gpio-pxa", AKITA_GPIO_BACKLIGHT_CONT,
+		GPIO_LOOKUP("0-0018", AKITA_GPIO_BACKLIGHT_CONT,
 			    "BL_CONT", GPIO_ACTIVE_LOW),
-		GPIO_LOOKUP("gpio-pxa", AKITA_GPIO_BACKLIGHT_ON,
+		GPIO_LOOKUP("0-0018", AKITA_GPIO_BACKLIGHT_ON,
 			    "BL_ON", GPIO_ACTIVE_HIGH),
 		{ },
 	},
arch/arm/mach-pxa/spitz.h +17 -17
index 04828d8918aa..4def79ee6df0 100644
@@ -137,26 +137,26 @@
 #define SPITZ_SCP2_SUS_SET  (SPITZ_SCP2_IR_ON | SPITZ_SCP2_RESERVED_1)
 
 #define SPITZ_SCP2_GPIO_BASE		(PXA_NR_BUILTIN_GPIO + 12)
-#define SPITZ_GPIO_IR_ON		(SPITZ_SCP2_GPIO_BASE + 0)
-#define SPITZ_GPIO_AKIN_PULLUP		(SPITZ_SCP2_GPIO_BASE + 1)
-#define SPITZ_GPIO_RESERVED_1		(SPITZ_SCP2_GPIO_BASE + 2)
-#define SPITZ_GPIO_RESERVED_2		(SPITZ_SCP2_GPIO_BASE + 3)
-#define SPITZ_GPIO_RESERVED_3		(SPITZ_SCP2_GPIO_BASE + 4)
-#define SPITZ_GPIO_RESERVED_4		(SPITZ_SCP2_GPIO_BASE + 5)
-#define SPITZ_GPIO_BACKLIGHT_CONT	(SPITZ_SCP2_GPIO_BASE + 6)
-#define SPITZ_GPIO_BACKLIGHT_ON		(SPITZ_SCP2_GPIO_BASE + 7)
-#define SPITZ_GPIO_MIC_BIAS		(SPITZ_SCP2_GPIO_BASE + 8)
+#define SPITZ_GPIO_IR_ON		0
+#define SPITZ_GPIO_AKIN_PULLUP		1
+#define SPITZ_GPIO_RESERVED_1		2
+#define SPITZ_GPIO_RESERVED_2		3
+#define SPITZ_GPIO_RESERVED_3		4
+#define SPITZ_GPIO_RESERVED_4		5
+#define SPITZ_GPIO_BACKLIGHT_CONT	6
+#define SPITZ_GPIO_BACKLIGHT_ON		7
+#define SPITZ_GPIO_MIC_BIAS		8
 
 /* Akita IO Expander GPIOs */
 #define AKITA_IOEXP_GPIO_BASE		(PXA_NR_BUILTIN_GPIO + 12)
-#define AKITA_GPIO_RESERVED_0		(AKITA_IOEXP_GPIO_BASE + 0)
-#define AKITA_GPIO_RESERVED_1		(AKITA_IOEXP_GPIO_BASE + 1)
-#define AKITA_GPIO_MIC_BIAS		(AKITA_IOEXP_GPIO_BASE + 2)
-#define AKITA_GPIO_BACKLIGHT_ON		(AKITA_IOEXP_GPIO_BASE + 3)
-#define AKITA_GPIO_BACKLIGHT_CONT	(AKITA_IOEXP_GPIO_BASE + 4)
-#define AKITA_GPIO_AKIN_PULLUP		(AKITA_IOEXP_GPIO_BASE + 5)
-#define AKITA_GPIO_IR_ON		(AKITA_IOEXP_GPIO_BASE + 6)
-#define AKITA_GPIO_RESERVED_7		(AKITA_IOEXP_GPIO_BASE + 7)
+#define AKITA_GPIO_RESERVED_0		0
+#define AKITA_GPIO_RESERVED_1		1
+#define AKITA_GPIO_MIC_BIAS		2
+#define AKITA_GPIO_BACKLIGHT_ON		3
+#define AKITA_GPIO_BACKLIGHT_CONT	4
+#define AKITA_GPIO_AKIN_PULLUP		5
+#define AKITA_GPIO_IR_ON		6
+#define AKITA_GPIO_RESERVED_7		7
 
 /* Spitz IRQ Definitions */
 
Signature · 7 lines
2.36.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Laurence de Bruxelles

With recent stable kernels on my Zaurus Akita I am unable to change the backlight brightness, as the necessary files are not in the sys filesystem, and at startup I get the following errors:

corgi-lcd spi2.1: requested GPIO 0 (207) is out of range [0..120] for chip gpio-pxa
corgi-lcd: probe of spi2.1 failed with error -22

Looking at recent changes to the Corgi backlight driver, I found that commit ee0c8e494cc3 ("backlight: corgi: Convert to use GPIO descriptors") replaced the use of the deprecated integer-based GPIO interface, but didn't convert the GPIO numbers in the platform header to match this. I think this is what causes the error, as the GPIOs for the backlight are part of an expander chip with a GPIO base number larger than the number of GPIOs for the gpio-pxa device.

This patch fixes things by updating the GPIO numbers for the backlight, simply by dropping the GPIO base. It also updates the GPIO lookups to look in the table for the appropriate expander. For the Akita platform the expander with i2c address 0-0018 is used, for Spitz and Borzoi the second Sharp SCOOP expander is used.

Quoted 5 lines

I've tested this patch with real Akita and Spitz handhelds, as well as with QEMU.

Fixes ee0c8e494cc3 ("backlight: corgi: Convert to use GPIO descriptors")

Looks correct, my mistakes (nothing to test on, that's why...) Thanks a lot for fixing this!

I would just send the patch directly to the SoC tree for fixes.

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#2 lore raw
Quoted 3 lines

Looks correct, my mistakes (nothing to test on, that's why...) Thanks a lot for fixing this!

No worries!

Quoted 1 line

I would just send the patch directly to the SoC tree for fixes.

Ah, sorry, I'm new to Linux kernel development, not sure of the correct way to do things. I sent this patch email to the list suggested by scripts/get_maintainer.pl, is there another way to send fixes to the SoC tree?

Many thanks
Laurence

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw
Quoted 4 lines · Laurence de Bruxelles
Quoted 3 lines

Looks correct, my mistakes (nothing to test on, that's why...) Thanks a lot for fixing this!

Quoted 8 lines

No worries!

Quoted 1 line

I would just send the patch directly to the SoC tree for fixes.

Ah, sorry, I'm new to Linux kernel development, not sure of the correct way to do things. I sent this patch email to the list suggested by scripts/get_maintainer.pl, is there another way to send fixes to the SoC tree?

You did? Something must have gone wrong somewhere:

$ ./scripts/get_maintainer.pl -f arch/arm/mach-pxa/spitz.c
Daniel Mack <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Haojian Zhuang <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Robert Jarzmik <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Russell King <[email protected]> (odd fixer:ARM PORT)
[email protected] (moderated list:PXA2xx/PXA3xx SUPPORT)
[email protected] (open list)
Signature · 9 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#4 lore raw
Quoted 18 lines · Lee Jones
Quoted 4 lines · Laurence de Bruxelles
Quoted 3 lines

Looks correct, my mistakes (nothing to test on, that's why...) Thanks a lot for fixing this!

Quoted 8 lines

No worries!

Quoted 1 line

I would just send the patch directly to the SoC tree for fixes.

Ah, sorry, I'm new to Linux kernel development, not sure of the correct way to do things. I sent this patch email to the list suggested by scripts/get_maintainer.pl, is there another way to send fixes to the SoC tree?

You did? Something must have gone wrong somewhere:

Quoted 8 lines
$ ./scripts/get_maintainer.pl -f arch/arm/mach-pxa/spitz.c
Daniel Mack <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Haojian Zhuang <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Robert Jarzmik <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Russell King <[email protected]> (odd fixer:ARM PORT)
[email protected] (moderated list:PXA2xx/PXA3xx SUPPORT)
[email protected] (open list)

I get something slightly different when I run the script.

I think because the commit description has a 'Fixes' line in it.

$ ./scripts/get_maintainer.pl
0001-backlight-corgi-Fix-gpio-numbers-for-backlight-contr.patch
Daniel Mack <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Haojian Zhuang <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Robert Jarzmik <[email protected]> (maintainer:PXA2xx/PXA3xx
SUPPORT,blamed_fixes:1/1=100%)
Russell King <[email protected]> (odd fixer:ARM PORT)
Daniel Thompson <[email protected]> (blamed_fixes:1/1=100%)
Lee Jones <[email protected]> (blamed_fixes:1/1=100%)
Linus Walleij <[email protected]> (blamed_fixes:1/1=100%)
[email protected] (moderated list:PXA2xx/PXA3xx SUPPORT)
[email protected] (open list)

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw
Quoted 33 lines · Laurence de Bruxelles
Quoted 18 lines · Lee Jones
Quoted 4 lines · Laurence de Bruxelles
Quoted 3 lines

Looks correct, my mistakes (nothing to test on, that's why...) Thanks a lot for fixing this!

Quoted 8 lines

No worries!

Quoted 1 line

I would just send the patch directly to the SoC tree for fixes.

Ah, sorry, I'm new to Linux kernel development, not sure of the correct way to do things. I sent this patch email to the list suggested by scripts/get_maintainer.pl, is there another way to send fixes to the SoC tree?

You did? Something must have gone wrong somewhere:

Quoted 8 lines
$ ./scripts/get_maintainer.pl -f arch/arm/mach-pxa/spitz.c
Daniel Mack <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Haojian Zhuang <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Robert Jarzmik <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Russell King <[email protected]> (odd fixer:ARM PORT)
[email protected] (moderated list:PXA2xx/PXA3xx SUPPORT)
[email protected] (open list)

I get something slightly different when I run the script.

I think because the commit description has a 'Fixes' line in it.

Quoted 12 lines
$ ./scripts/get_maintainer.pl
0001-backlight-corgi-Fix-gpio-numbers-for-backlight-contr.patch
Daniel Mack <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Haojian Zhuang <[email protected]> (maintainer:PXA2xx/PXA3xx SUPPORT)
Robert Jarzmik <[email protected]> (maintainer:PXA2xx/PXA3xx
SUPPORT,blamed_fixes:1/1=100%)
Russell King <[email protected]> (odd fixer:ARM PORT)
Daniel Thompson <[email protected]> (blamed_fixes:1/1=100%)
Lee Jones <[email protected]> (blamed_fixes:1/1=100%)
Linus Walleij <[email protected]> (blamed_fixes:1/1=100%)
[email protected] (moderated list:PXA2xx/PXA3xx SUPPORT)
[email protected] (open list)

The CC list is fine, but it's missing the SoC mail address which is what actually get it queued. It's one of these things you just have to know because we don't want to spam that address with random reviews, just with finished patches to be merged.

When you are finished with the patch, send it to [email protected] simply. Then it will appear here:
https://patchwork.kernel.org/project/linux-soc/list/

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#6 lore raw
Quoted 10 lines · Linus Walleij

The CC list is fine, but it's missing the SoC mail address which is what actually get it queued. It's one of these things you just have to know because we don't want to spam that address with random reviews, just with finished patches to be merged.

When you are finished with the patch, send it to [email protected] simply. Then it will appear here:
https://patchwork.kernel.org/project/linux-soc/list/

Got it, thank you!

I think I've done that now, thanks for all your help!

Laurence

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#7 lore raw
In reply to Laurence de Bruxelles
Quoted 25 lines · Laurence de Bruxelles

With recent stable kernels on my Zaurus Akita I am unable to change the backlight brightness, as the necessary files are not in the sys filesystem, and at startup I get the following errors:

corgi-lcd spi2.1: requested GPIO 0 (207) is out of range [0..120] for chip gpio-pxa
corgi-lcd: probe of spi2.1 failed with error -22

Looking at recent changes to the Corgi backlight driver, I found that commit ee0c8e494cc3 ("backlight: corgi: Convert to use GPIO descriptors") replaced the use of the deprecated integer-based GPIO interface, but didn't convert the GPIO numbers in the platform header to match this. I think this is what causes the error, as the GPIOs for the backlight are part of an expander chip with a GPIO base number larger than the number of GPIOs for the gpio-pxa device.

This patch fixes things by updating the GPIO numbers for the backlight, simply by dropping the GPIO base. It also updates the GPIO lookups to look in the table for the appropriate expander. For the Akita platform the expander with i2c address 0-0018 is used, for Spitz and Borzoi the second Sharp SCOOP expander is used.

I've tested this patch with real Akita and Spitz handhelds, as well as with QEMU.

Quoted 6 lines
Fixes ee0c8e494cc3 ("backlight: corgi: Convert to use GPIO descriptors")
---
 arch/arm/mach-pxa/spitz.c |  8 ++++----
 arch/arm/mach-pxa/spitz.h | 34 +++++++++++++++++-----------------
 2 files changed, 21 insertions(+), 21 deletions(-)

Subject line should not be "backlight: ".

Try "ARM: pxa: " instead please.

Signature · 9 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#9 lore raw
Quoted 9 lines · Laurence de Bruxelles
Quoted 5 lines · Lee Jones

Subject line should not be "backlight: ".

Try "ARM: pxa: " instead please.

Got it, will resubmit with that subject line once I know the right place to submit to (see thread with Linus Walleij). Thanks for your comment!

This should give you what you need:

git show <commit_ref> | ./scripts/get_maintainer.pl

Signature · 9 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#10 lore raw
In reply to Laurence de Bruxelles
Quoted 8 lines · Laurence de Bruxelles

With recent stable kernels on my Zaurus Akita I am unable to change the backlight brightness, as the necessary files are not in the sys filesystem, and at startup I get the following errors:

corgi-lcd spi2.1: requested GPIO 0 (207) is out of range [0..120] for chip gpio-pxa
corgi-lcd: probe of spi2.1 failed with error -22

I already commented on version 2 of the patch, but that was missing the linux-arm-kernel mailing list on Cc, so I'll reply here as well with a more general remark:

We are currently planning the removal of non-DT board support for a lot of platforms, and spitz is currently on the list I have noted down for getting removed in early 2023, see the thread at

https://lore.kernel.org/linux-arm-kernel/[email protected]/

Are you actively using this machine, and planning to keep using it in the future? Are you interested in working on or testing a DT conversion?

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#11 lore raw

4 Jul 2022 14:09:18 Arnd Bergmann <[email protected]>:

Quoted 4 lines

I already commented on version 2 of the patch, but that was missing the linux-arm-kernel mailing list on Cc, so I'll reply here as well with a more general remark:

Ah, sorry for missing the linux-arm-kernel mailing list, I'm still getting the hang of this. Thanks for the comments on version 2 of the patch, I will respond once I've done some testing.

Quoted 10 lines

We are currently planning the removal of non-DT board support for a lot of platforms, and spitz is currently on the list I have noted down for getting removed in early 2023, see the thread at

https://lore.kernel.org/linux-arm-kernel/[email protected]/

Are you actively using this machine, and planning to keep using it in the future? Are you interested in working on or testing a DT conversion?

Yes to all :) How can I get involved?

---

Many thanks
Laurence de Bruxelles

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#12 lore raw
Quoted 7 lines · Laurence de Bruxelles

4 Jul 2022 14:09:18 Arnd Bergmann <[email protected]>:

Quoted 6 lines

We are currently planning the removal of non-DT board support for a lot of platforms, and spitz is currently on the list I have noted down for
getting removed in early 2023, see the thread at

Quoted 7 lines
Quoted 5 lines

https://lore.kernel.org/linux-arm-kernel/[email protected]/

Are you actively using this machine, and planning to keep using it in the future? Are you interested in working on or testing a DT conversion?

Yes to all :)

Great!

Quoted 1 line

How can I get involved?

I don't think anyone else is currently working on further DT conversion, though Robert Jarzmik and Daniel Mack have done the important preparation work for this in the past, and Linus Walleij is looking at it across multiple platforms, so
they can probably give more helpful advice than I can.

There is a pxa27x.dtsi file that you can include in a new pxa270-spitz.dts file, but there are no other dts files that include this, so it's likely that there are
mistakes in the description.

The approach I would use is to start with a minimal dts file and get the console uart working in qemu, then add more devices one at a time by creating nodes for the devices that already have DT support, and after that create DT bindings for devices that don't have one yet, using the raumfeld files as a template.

Feel free to ask on the #armlinux IRC channel on irc.libera.chat when you run into problems.

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel