Skip to contentSkip to conversation

ARM: bcm2835: Add names for the Raspberry Pi GPIO lines

PATCH Superseded Eric Anholt 2 participants 2 messages Oct 18, 2016 – Oct 19, 2016

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ARM: bcm2835: Add names for the Raspberry Pi GPIO lines

From: Linus Walleij <[email protected]>

The idea is to give useful names to GPIO lines that an implementer will be using from userspace, e.g. for maker type projects. These are user-visible using tools/gpio/lsgpio.c

v2: Major rewrite by anholt: Flatten each GPIO line to a line in the
file for better diffing, prefix all expansion header pins with "P<number>" or "P5HEADER_P<number>" and drop the mostly-unused GPIO_GEN<smallnumber> names in favor of GPIO<socgpionumber>, fix extra '[]' on a couple of lines, fix locations of SD_CARD_DETECT, CAM_GPIO and STATUS_LED, fix HDMI_HPD polarities, rewrite A+ using unreleased schematics.

---

Note: I haven't actually booted these and checked that the names line up, just tried to visually review them. Hopefully with more GPIO<number> values, it's easier to spot errors.

The only other thing here I think I would do is drop the [] around names for behavior when pinmuxed. I find it more confusing than helpful.

Linus, are these names considered ABI? Will we be locked into whatever set of names we merge and release? My assumption would be "yes".

 arch/arm/boot/dts/bcm2835-rpi-a-plus.dts | 66 +++++++++++++++++++++++++++++++
 arch/arm/boot/dts/bcm2835-rpi-a.dts      | 68 ++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/bcm2835-rpi-b-plus.dts | 67 +++++++++++++++++++++++++++++++
 arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts | 67 +++++++++++++++++++++++++++++++
 arch/arm/boot/dts/bcm2835-rpi-b.dts      | 68 ++++++++++++++++++++++++++++++++
 5 files changed, 336 insertions(+)
arch/arm/boot/dts/bcm2835-rpi-a-plus.dts +66 -0
index 21507c922783..cec4c6e49e7b 100644
@@ -22,6 +22,72 @@
 };
 
 &gpio {
+	/*
+	 * This is based on the unreleased schematic for the Model A+.
+	 *
+	 * Legend:
+	 * "NC" = not connected (no rail from the SoC)
+	 * "[FOO]" = pin is muxed for peripheral FOO (not GPIO)
+	 * "FOO" = GPIO line named "FOO" on the schematic
+	 * "FOO_N" = GPIO line named "FOO" on schematic, active low
+	 */
+	gpio-line-names = "[SDA0]",
+			  "[SCL0]",
+			  "[P3_SDA1]",
+			  "[P5_SCL1]",
+			  "[P7_GPIO_GCLK]",
+			  "P29_GPIO5",
+			  "P31_GPIO6",
+			  "[P26_SPI_CE1_N]",
+			  "[P24_SPI_CE0_N]",
+			  "[P21_SPI_MISO]",
+			  "[P19_SPI_MOSI]",
+			  "[P23_SPI_SCLK]",
+			  "P32_GPIO12",
+			  "P33_GPIO13",
+			  /* Serial port */
+			  "[P8_TXD0]",
+			  "[P10_RXD0]",
+			  "P36_GPIO16",
+			  "P11_GPIO17",
+			  "P12_GPIO18",
+			  "P35_GPIO19",
+			  "P38_GPIO20",
+			  "P40_GPIO21",
+			  "P15_GPIO22",
+			  "P16_GPIO23",
+			  "P18_GPIO24",
+			  "P22_GPIO25",
+			  "P37_GPIO26",
+			  "P13_GPIO27",
+			  "[SDA0]",
+			  "[SCL0]",
+			  "NC", /* GPIO30 */
+			  "NC", /* GPIO31 */
+			  "NC", /* GPIO32 */
+			  "NC", /* GPIO33 */
+			  "NC", /* GPIO34 */
+			  "PWR_LOW_N", /* GPIO35 */
+			  "NC", /* GPIO36 */
+			  "NC", /* GPIO37 */
+			  "NC", /* GPIO38 */
+			  "NC", /* GPIO39 */
+			  "[PWM0_OUT]", /* GPIO40 */
+			  "CAM_GPIO0", /* GPIO41 */
+			  "NC", /* GPIO42 */
+			  "NC", /* GPIO43 */
+			  "NC", /* GPIO44 */
+			  "[PWM1_OUT]", /* GPIO45 */
+			  "HDMI_HPD_N",
+			  "STATUS_LED",
+			  /* Used by SD Card */
+			  "[SD_CLK_R]",
+			  "[SD_CMD_R]",
+			  "[SD_DATA0_R]",
+			  "[SD_DATA1_R]",
+			  "[SD_DATA2_R]",
+			  "[SD_DATA3_R]";
+
 	pinctrl-0 = <&gpioout &alt0 &i2s_alt0>;
 
 	/* I2S interface */
arch/arm/boot/dts/bcm2835-rpi-a.dts +68 -0

74 lines not on this page · raw message

arch/arm/boot/dts/bcm2835-rpi-b-plus.dts +67 -0

73 lines not on this page · raw message

arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts +67 -0

73 lines not on this page · raw message

arch/arm/boot/dts/bcm2835-rpi-b.dts +68 -0

74 lines not on this page · raw message

Signature · 1 line
2.9.3
#1 lore raw
Quoted 14 lines · Eric Anholt

From: Linus Walleij <[email protected]>

The idea is to give useful names to GPIO lines that an implementer will be using from userspace, e.g. for maker type projects. These are user-visible using tools/gpio/lsgpio.c

v2: Major rewrite by anholt: Flatten each GPIO line to a line in the
file for better diffing, prefix all expansion header pins with "P<number>" or "P5HEADER_P<number>" and drop the mostly-unused GPIO_GEN<smallnumber> names in favor of GPIO<socgpionumber>, fix extra '[]' on a couple of lines, fix locations of SD_CARD_DETECT, CAM_GPIO and STATUS_LED, fix HDMI_HPD polarities, rewrite A+ using unreleased schematics.

Quoted 2 lines

Generally looks good!

I fully trust your usage of he Pnn_* prefix, I assume this makes a lot of sense to RPi users.

Quoted 7 lines

Note: I haven't actually booted these and checked that the names line up, just tried to visually review them. Hopefully with more GPIO<number> values, it's easier to spot errors.

The only other thing here I think I would do is drop the [] around names for behavior when pinmuxed. I find it more confusing than helpful.

I added this on the 96board HiKey instead of just leaving it blank.

The idea was to distinguish somehow between GPIO proper and a GPIO line that is actually not used as GPIO. It is only really reflecting the schematic, so whatever makes sense for someone familiar with the schematics apply.

I think it is up to the .dts file maintainer to decide. May even be different things that make sense on different boards.

Quoted 3 lines

Linus, are these names considered ABI? Will we be locked into whatever set of names we merge and release? My assumption would be "yes".

It is ABI if there is a userspace making use of it. So once libs like libmraa (is that the name?) and similar things that do userspace GPIO start using it, it becomes ABI.

Yours,
Linus Walleij