[PATCH] RFC: name the Raspberry Pi GPIO lines

Eric Anholt eric at anholt.net
Thu Oct 6 11:26:36 PDT 2016


Linus Walleij <linus.walleij at linaro.org> writes:

> This is a scratch idea on how to properly name the GPIO lines
> on the various Raspberry Pi models.
>
> The idea is to give useful names to GPIO lines that an
> implementer will be using from userspace, e.g. for maker type
> projects.
>
> See:
> commit 521a2ad6f862
> ("gpio: add userspace ABI for GPIO line information")
> commit fd9c55315db9
> ("gpio: of: make it possible to name GPIO lines")

Nice.  I really like this idea.  I'll spend some time reviewing these
against the schematics I have and send some updates.

I took my 2B, copied the B-rev2 hunk over to its DTS just to see what
things generally look like, and the new output from lsgpio is:

GPIO chip: gpiochip0, "pinctrl-bcm2835", 54 GPIO lines
	line  0: "[SDA0]" unused
	line  1: "[SCL0]" unused
	line  2: "[SDA1]" unused
	line  3: "[SCL1]" unused
	line  4: "GPIO_GCLK" unused
	line  5: "[CAM_CLK]" unused
	line  6: "LAN_RUN" unused
	line  7: "[SPI_CE1_N]" unused
	line  8: "[SPI_CE0_N]" unused
	line  9: "[SPI_MISO]" unused
	line 10: "[SPI_MOSI]" unused
	line 11: "[SPI_SCLK]" unused
	line 12: "NC" unused
	line 13: "NC" unused
	line 14: "[TXD0]" unused
	line 15: "[RXD0]" unused
	line 16: "STATUS_LED_N" unused
	line 17: "GPIO_GEN0" unused
	line 18: "GPIO_GEN1" unused
	line 19: "NC" unused
	line 20: "NC" unused
	line 21: "CAM_GPIO" unused
	line 22: "GPIO_GEN3" unused
	line 23: "GPIO_GEN4" unused
	line 24: "GPIO_GEN5" unused
	line 25: "GPIO_GEN6" unused
	line 26: "NC" unused
	line 27: "GPIO_GEN2" unused
	line 28: "GPIO_GEN7" unused
	line 29: "GPIO_GEN8" unused
	line 30: "GPIO_GEN9" unused
	line 31: "GPIO_GEN10" unused [output]
	line 32: "NC" unused [output]
	line 33: "NC" unused
	line 34: "NC" unused
	line 35: "NC" "?" [kernel output]
	line 36: "NC" unused
	line 37: "NC" unused
	line 38: "NC" unused [output]
	line 39: "NC" unused
	line 40: "[PWM0_OUT]" unused
	line 41: "NC" unused [output]
	line 42: "NC" unused
	line 43: "NC" unused
	line 44: "NC" unused
	line 45: "[PWM1_OUT]" unused
	line 46: "HDMI_HPD_P" unused
	line 47: "SD_CARD_DET" "?" [kernel output]
	line 48: "[SD_CLK_R]" unused
	line 49: "[SD_CMD_R]" unused
	line 50: "[SD_DATA0_R]" unused
	line 51: "[SD_DATA1_R]" unused
	line 52: "[SD_DATA2_R]" unused
	line 53: "[SD_DATA3_R]" unused

So we've got nice names now, but everything is showing up as unused.  I
know the HDMI HPD has been grabbed by the DRM, and my SD lines are
obviously in use by my SD card.  What does "unused" mean here?  Are we
doing something wrong in our platform?

The thing I want most when trying to debug gpio/pinctrl issues is
something that shows me what the current pinmux is and what the state of
the line is.  /debug/pinctrl/3f200000.gpio/pins is promising, but it
doesn't get the new names:

...
pin 44 (gpio44) function alt0 in lo; irq 138 (none)
pin 45 (gpio45) function alt0 in lo; irq 139 (none)
pin 46 (gpio46) function gpio_in in lo; irq 140 (none)
pin 47 (gpio47) function gpio_out in lo; irq 141 (none)
pin 48 (gpio48) function alt3 in hi; irq 142 (none)
...


/debug/gpio is also promising, but it doesn't have the mux or the state
of HDMI HPD:

...
 gpio-503 ([PWM1_OUT]          )
 gpio-504 (HDMI_HPD_P          )
 gpio-505 (SD_CARD_DET         |?                   ) out lo    
 gpio-506 ([SD_CLK_R]          )
 gpio-507 ([SD_CMD_R]          )
...

What I'm looking for is something where I can ask a user "please plug
and unplug your HDMI monitor while 'watch grep HDMI
/debug/gpio/whatever' is running" and see what happens.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-rpi-kernel/attachments/20161006/127ee1f3/attachment.sig>


More information about the linux-rpi-kernel mailing list