[AM335x] device tree leds{} and /sys/kernel/debug/gpio

Hi,
Custom board based upon BBB.
Kernel 5.11.10
snippets from my custom device tree

leds {
	pinctrl-names = "default";
	pinctrl-0 = <&user_leds_s0>;

	compatible = "gpio-leds";

	led1 {
		label = "zcpu:red:led"; /* ONBOARD RED LED */
		gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
		linux,default-trigger = "none";
		default-state = "off";
	};

	led2 {
		label = "zcpu:green:led"; /* ONBOARD GREEN LED */
		gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
		linux,default-trigger = "none";
		default-state = "off";
	};

	led3 {
		label = "zcpu:blue:led"; /* ONBOARD BLUE LED */
		gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>;
		linux,default-trigger = "heartbeat";
		default-state = "off";
	};
};

and

	user_leds_s0: user_leds_s0 {
		pinctrl-single,pins = <
			AM33XX_IOPAD(0x8d0, PIN_OUTPUT | MUX_MODE7)        /* (V2)  lcd_data12.gpio0[8]    (GPIO_8) ONBOARD RED LED*/
			AM33XX_IOPAD(0x8d4, PIN_OUTPUT | MUX_MODE7)        /* (V3)  lcd_data13.gpio1[9]    (GPIO_9) ONBOARD GREEN LED*/
			AM33XX_IOPAD(0x8dc, PIN_OUTPUT | MUX_MODE7)        /* (T5)  ldc_data15.gpio1[11]   (GPIO_11) ONBOARD BLUE LED*/
		>;
	};

The onboard leds work without a problem. They show up in /sys/class/leds.
ls /sys/class/leds
mmc0:: mmc1:: zcpu:blue:led zcpu:green:led zcpu:red:led

The RED led is GPIO0 pin 8.
The GREEN is GPIO0 pin 9.
The BLUE is GPIO0 pin 11.

Now I run this command,
cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/4804c000.gpio, gpio-0-31:
gpio-23 ( |sysfs ) out hi

gpiochip1: GPIOs 32-63, parent: platform/481ac000.gpio, gpio-32-63:
gpio-33 ( |sysfs ) out hi

gpiochip2: GPIOs 64-95, parent: platform/481ae000.gpio, gpio-64-95:

gpiochip3: GPIOs 96-127, parent: platform/44e07000.gpio, gpio-96-127:
gpio-104 ( |zcpu:red:led ) out lo
gpio-105 ( |zcpu:green:led ) out lo
gpio-107 ( |zcpu:blue:led ) out lo

I would expect the led(s) would show up under gpiochip0 pins 8, 9 and 11.
Now my question.
Why do the led(s) show up as pins under gpiochip3 pins 102, 104 and 107?

Thank you,

They were probed and put under control of the gpio-led driver at those locations.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/leds/leds-gpio.c?h=v6.1-rc3#n194

Regards,

RCN,
Referring to https://www.ti.com/lit/ug/spruh73q/spruh73q.pdf
Memory Map chapter
GPIO0 address start is 0x44E0_7000
GPIO1 0x4804_C000
GPIO2 0x481A_C000
GPIO3 0x481A_D000

The result of cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/4804c000.gpio, gpio-0-31:
gpiochip1: GPIOs 32-63, parent: platform/481ac000.gpio, gpio-32-63:
gpiochip2: GPIOs 64-95, parent: platform/481ae000.gpio, gpio-64-95:
gpiochip3: GPIOs 96-127, parent: platform/44e07000.gpio, gpio-96-127:

I was matching the addresses listed in the spruh with the platform/addresses reported by cat.
I noticed that the gpiochipx numbers are not aligned with the GPIOx number.
gpiochip0 = GPIO1
gpiochip1 = GPIO2
gpiochip2 = GPIO3
gpiochip3 = GPIO0

This misalignment explains a lot about why 0-31 exports to GPIO1 but there must be some history why the number are not aligned.
Why are they not aligned?

Thank you,

The kernel probes and loads them asynchronous… Thus in theory it should be more random, but usually always end up the same…

Regards,