| | 56 | |
| | 57 | |
| | 58 | [=#mapping] |
| | 59 | = GPIO mapping |
| | 60 | The various product hardware manuals will call out GPIO devices on the board and provide a table mapping the GPIO to a GPIO host controller, a function, and a connector pinout (if going off-board). |
| | 61 | |
| | 62 | This hardware mapping is defined in the following files depending on board/family: |
| | 63 | * Newport: Linux kernel device-tree (ie [http://github.com/Gateworks/dts-newport]) |
| | 64 | * Ventana: Linux kernel device-tree (ie [http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/imx6qdl-gw54xx.dtsi arch/arm/boot/dts/imx6qdl-gw54xx.dtsi]) |
| | 65 | * Laguna: Linux kernel board-support files (ie [https://github.com/Gateworks/openwrt/blob/16.02/target/linux/cns3xxx/files/arch/arm/mach-cns3xxx/laguna.c arch/arm/mach-cns3xxx/laguna.c]). |
| | 66 | |
| | 67 | ** Product Family specific notes: |
| | 68 | * Newport: |
| | 69 | - CN80XX GPIOs: The CN80XX has one 48bit GPIO controller |
| | 70 | - GPIO![0-48]: gpio-464 to gpio-511 |
| | 71 | * Ventana: |
| | 72 | - IMX6 GPIOs: The IMX6 has 7 32bit GPIO controllers for a possible 224 fast ARM based GPIO's |
| | 73 | - GPIO1_IO![0-31]: gpio0-gpio31 |
| | 74 | - GPIO2_IO![0-31]: gpio32-gpio63 |
| | 75 | - GPIO3_IO![0-31]: gpio64-gpio95 |
| | 76 | - GPIO4_IO![0-31]: gpio96-gpio127 |
| | 77 | - GPIO5_IO![0-31]: gpio128-gpio159 |
| | 78 | - GPIO6_IO![0-31]: gpio160-gpio191 |
| | 79 | - GPIO7_IO![0-31]: gpio192-gpio223 |
| | 80 | - [wiki:gsc GSC] GPIOs: |
| | 81 | - GSC_GPIO_P0![0-7]: gpio240-gpio247 |
| | 82 | - GSC_GPIO_P1![0-7]: gpio247-gpio255 |
| | 83 | - additional i2c based GPIO port-expanders present on some boards would begin at gpio116 |
| | 84 | * Laguna: |
| | 85 | - cns3xxx GPIOs: The CNS3xxx has 2 32bit GPIO controllers for a possible 64 fast ARM based GPIO's |
| | 86 | - GPIOA![0-31]: gpio0-gpio31 |
| | 87 | - GPIOB![0-31]: gpio32-gpio63 |
| | 88 | - [wiki:gsc GSC] GPIOs: |
| | 89 | - GSC_GPIO_P0![0-7]: gpio100-gpio107 |
| | 90 | - GSC_GPIO_P1![0-7]: gpio108-gpio115 |
| | 91 | - additional i2c based GPIO port-expanders present on some boards would begin at gpio116 |
| | 92 | |
| | 93 | Note that the Linux gpio mapping is not guaranteed to remain constant across kernel versions. Care should be taken to consult {{{/sys/kernel/debug/gpio}}} and {{{/sys/class/gpio}}} when changing kernel versions. |
| | 94 | |
| | 95 | When referring to [http://www.gateworks.com/usermanuals Gateworks board user hardware manuals] you will need to translate the hardware pin name to a gpio using the information above. Some examples: |
| | 96 | * Newport GPIO8 would be the 8th IO on the CN80XX GPIO controller thus map to gpio-472. |
| | 97 | * Laguna GPIOA8 would be the 9th IO on the GPIOA controller (the first is GPIOA0) thus map to gpio 0+8 = gpio-8 |
| | 98 | * Laguna GPIOB1 would be the 2nd IO on the GPIOB controller thus map to gpio 32+2 = gpio-34 |
| | 99 | * Ventana GPIO![1]:DIO16 is GPIO block 1 IO 16 thus maps to gpio0 + 16 (or 0*32+16) = gpio-16 |
| | 100 | * Ventana GPIO![2]:DIO9 is GPIO block 2 IO 9 thus maps to gpio32 + 9 (or 1*32+9) = gpio-41 |
| | 101 | * Equation: Ventana GPIO<x>__IO<y> is GPIO block x IO y thus maps to: gpio-((x-1)*32)+y |
| | 102 | |
| | 103 | |
| | 104 | Examples: |
| | 105 | * If libgpiod is installed (gpiod package in Ubuntu) the {{{gpioinfo}}} app will show you all gpio controllers and details about the GPIO lines each one offers. Note that using the Linux GPIO character device API and/or libgpiod is the preferred way to access GPIO in userspace: |
| | 106 | {{{#!bash |
| | 107 | root@bionic-newport:~/libgpiod# gpioinfo |
| | 108 | gpiochip0 - 48 lines: |
| | 109 | line 0: unnamed unused input active-high |
| | 110 | line 1: unnamed unused input active-high |
| | 111 | line 2: unnamed unused input active-high |
| | 112 | line 3: unnamed unused input active-high |
| | 113 | line 4: unnamed "interrupt" input active-high [used] |
| | 114 | line 5: unnamed unused input active-high |
| | 115 | line 6: unnamed unused input active-high |
| | 116 | line 7: unnamed unused input active-high |
| | 117 | line 8: unnamed "mmc_supply_3v3" output active-high [used] |
| | 118 | line 9: unnamed unused input active-high |
| | 119 | line 10: unnamed unused output active-high |
| | 120 | line 11: unnamed unused input active-high |
| | 121 | line 12: unnamed unused input active-high |
| | 122 | line 13: unnamed unused input active-high |
| | 123 | line 14: unnamed "user2" output active-high [used] |
| | 124 | line 15: unnamed unused output active-high |
| | 125 | line 16: unnamed unused output active-high |
| | 126 | line 17: unnamed unused output active-high |
| | 127 | line 18: unnamed unused output active-high |
| | 128 | line 19: unnamed unused output active-high |
| | 129 | line 20: unnamed unused input active-high |
| | 130 | line 21: unnamed unused input active-high |
| | 131 | line 22: unnamed unused input active-high |
| | 132 | line 23: unnamed unused output active-high |
| | 133 | line 24: unnamed unused input active-high |
| | 134 | line 25: unnamed unused input active-high |
| | 135 | line 26: unnamed unused input active-high |
| | 136 | line 27: unnamed unused input active-high |
| | 137 | line 28: unnamed unused output active-high |
| | 138 | line 29: unnamed unused input active-high |
| | 139 | line 30: unnamed "pps-gpio" input active-high [used] |
| | 140 | line 31: unnamed "user1" output active-high [used] |
| | 141 | line 32: unnamed unused input active-high |
| | 142 | line 33: unnamed unused input active-high |
| | 143 | line 34: unnamed unused input active-high |
| | 144 | line 35: unnamed unused input active-high |
| | 145 | line 36: unnamed unused input active-high |
| | 146 | line 37: unnamed unused input active-high |
| | 147 | line 38: unnamed unused input active-high |
| | 148 | line 39: unnamed unused input active-high |
| | 149 | line 40: unnamed unused input active-high |
| | 150 | line 41: unnamed unused input active-high |
| | 151 | line 42: unnamed unused input active-high |
| | 152 | line 43: unnamed unused input active-high |
| | 153 | line 44: unnamed unused input active-high |
| | 154 | line 45: unnamed unused input active-high |
| | 155 | line 46: unnamed unused input active-high |
| | 156 | line 47: unnamed unused input active-high |
| | 157 | gpiochip1 - 16 lines: |
| | 158 | line 0: unnamed unused output active-high |
| | 159 | line 1: unnamed unused input active-high |
| | 160 | line 2: unnamed "user_pb" input active-low [used] |
| | 161 | line 3: unnamed unused input active-high |
| | 162 | line 4: unnamed unused input active-high |
| | 163 | line 5: unnamed unused input active-high |
| | 164 | line 6: unnamed unused input active-high |
| | 165 | line 7: unnamed unused input active-high |
| | 166 | line 8: unnamed unused input active-high |
| | 167 | line 9: unnamed unused input active-high |
| | 168 | line 10: unnamed unused input active-high |
| | 169 | line 11: unnamed unused input active-high |
| | 170 | line 12: unnamed unused input active-high |
| | 171 | line 13: unnamed unused input active-high |
| | 172 | line 14: unnamed unused input active-high |
| | 173 | line 15: unnamed unused input active-high |
| | 174 | }}} |
| | 175 | * If debugfs is enabled in the kernel and mounted (as it is on Gateworks BSP's) you can see a nice table of {{{sysfsgpio}}} GPIO mapping via {{{/sys/kernel/debug/gpio}}}. Some examples: |
| | 176 | - Newport GW6400: |
| | 177 | {{{#!bash |
| | 178 | # cat /sys/kernel/debug/gpio |
| | 179 | gpiochip1: GPIOs 448-463, parent: i2c/0-0023, pca9555, can sleep: |
| | 180 | |
| | 181 | gpiochip0: GPIOs 464-511, parent: pci/0000:00:06.0, gpio_thunderx: |
| | 182 | gpio-472 ( |mmc_supply_3v3 ) out hi |
| | 183 | gpio-478 ( |user2 ) out lo |
| | 184 | gpio-495 ( |user1 ) out lo |
| | 185 | }}} |
| | 186 | - Ventana GW5400: |
| | 187 | {{{#!bash |
| | 188 | # cat /sys/kernel/debug/gpio |
| | 189 | GPIOs 0-31, platform/209c000.gpio, 209c000.gpio: |
| | 190 | gpio-26 (pps-gpio ) in lo |
| | 191 | gpio-29 (PCIe reset ) out lo |
| | 192 | gpio-30 (phy-reset ) out hi |
| | 193 | |
| | 194 | GPIOs 32-63, platform/20a0000.gpio, 20a0000.gpio: |
| | 195 | |
| | 196 | GPIOs 64-95, platform/20a4000.gpio, 20a4000.gpio: |
| | 197 | gpio-86 (usb_otg_vbus ) out lo |
| | 198 | |
| | 199 | GPIOs 96-127, platform/20a8000.gpio, 20a8000.gpio: |
| | 200 | gpio-102 (user1 ) out lo |
| | 201 | gpio-103 (user2 ) out lo |
| | 202 | gpio-111 (user3 ) out lo |
| | 203 | |
| | 204 | GPIOs 128-159, platform/20ac000.gpio, 20ac000.gpio: |
| | 205 | |
| | 206 | GPIOs 160-191, platform/20b0000.gpio, 20b0000.gpio: |
| | 207 | |
| | 208 | GPIOs 192-223, platform/20b4000.gpio, 20b4000.gpio: |
| | 209 | gpio-192 (2198000.usdhc cd ) in hi |
| | 210 | |
| | 211 | GPIOs 240-255, i2c/0-0023, pca9555, can sleep: |
| | 212 | gpio-240 (user_pb ) in hi |
| | 213 | }}} |
| | 214 | * Note that this does not show GPIO's that are not used by Linux drivers such as USB HUB reset, Ethernet PHY reset, etc. |
| | 215 | - Laguna GW2388: |
| | 216 | {{{#!bash |
| | 217 | # cat /sys/kernel/debug/gpio |
| | 218 | GPIOs 0-31, cns3xxx_gpio0: |
| | 219 | gpio-0 (GPS_PPS ) in hi |
| | 220 | gpio-3 (USB_FAULT# ) in hi |
| | 221 | gpio-6 (USB_VBUS_EN ) out hi |
| | 222 | gpio-7 (GSM_SEL0 ) out lo |
| | 223 | gpio-8 (GSM_SEL1 ) out lo |
| | 224 | gpio-9 (FP_SER_EN ) out lo |
| | 225 | |
| | 226 | GPIOs 32-63, cns3xxx_gpio1: |
| | 227 | |
| | 228 | GPIOs 100-115, i2c/0-0023, pca9555, can sleep: |
| | 229 | gpio-100 (USER_PB# ) in hi |
| | 230 | gpio-114 (user2 ) out hi |
| | 231 | gpio-115 (user1 ) out hi |
| | 232 | }}} |
| | 233 | - Laguna GW2387: |
| | 234 | {{{#!bash |
| | 235 | # cat /sys/kernel/debug/gpio |
| | 236 | GPIOs 0-31, cns3xxx_gpio0: |
| | 237 | gpio-0 (GPS_PPS ) in hi |
| | 238 | gpio-2 (USB_FAULT# ) in hi |
| | 239 | gpio-5 (USB_PCI_SEL ) out lo |
| | 240 | gpio-6 (USB_VBUS_EN ) out hi |
| | 241 | gpio-7 (GSM_SEL0 ) out lo |
| | 242 | gpio-8 (GSM_SEL1 ) out lo |
| | 243 | gpio-9 (FP_SER_EN ) out lo |
| | 244 | |
| | 245 | GPIOs 32-63, cns3xxx_gpio1: |
| | 246 | |
| | 247 | GPIOs 100-115, i2c/0-0023, pca9555, can sleep: |
| | 248 | gpio-100 (USER_PB# ) in hi |
| | 249 | gpio-114 (user2 ) out hi |
| | 250 | gpio-115 (user1 ) out hi |
| | 251 | }}} |
| | 252 | |
| | 253 | See also: |
| | 254 | * [wiki:newport/DigitalIO Newport Digital IO Mapping Page] |
| | 255 | * [wiki:ventana/DigitalIO Ventana Digital IO Mapping Page] |
| | 256 | * [wiki:laguna/DigitalIO Laguna Digital IO Mapping Page] |
| | 257 | |
| 191 | | [=#mapping] |
| 192 | | == GPIO mapping == |
| 193 | | The various product hardware manuals will call out GPIO devices on the board and provide a table mapping the GPIO to a GPIO host controller, a function, and a connector pinout (if going off-board). |
| 194 | | |
| 195 | | This hardware mapping is defined in the following files depending on board/family: |
| 196 | | * Newport: Linux kernel device-tree (ie [http://github.com/Gateworks/dts-newport]) |
| 197 | | * Ventana: Linux kernel device-tree (ie [http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/imx6qdl-gw54xx.dtsi arch/arm/boot/dts/imx6qdl-gw54xx.dtsi]) |
| 198 | | * Laguna: Linux kernel board-support files (ie [https://github.com/Gateworks/openwrt/blob/16.02/target/linux/cns3xxx/files/arch/arm/mach-cns3xxx/laguna.c arch/arm/mach-cns3xxx/laguna.c]). |
| 199 | | |
| 200 | | ** Product Family specific notes: |
| 201 | | * Newport: |
| 202 | | - CN80XX GPIOs: The CN80XX has one 48bit GPIO controller |
| 203 | | - GPIO![0-48]: gpio-464 to gpio-511 |
| 204 | | * Ventana: |
| 205 | | - IMX6 GPIOs: The IMX6 has 7 32bit GPIO controllers for a possible 224 fast ARM based GPIO's |
| 206 | | - GPIO1_IO![0-31]: gpio0-gpio31 |
| 207 | | - GPIO2_IO![0-31]: gpio32-gpio63 |
| 208 | | - GPIO3_IO![0-31]: gpio64-gpio95 |
| 209 | | - GPIO4_IO![0-31]: gpio96-gpio127 |
| 210 | | - GPIO5_IO![0-31]: gpio128-gpio159 |
| 211 | | - GPIO6_IO![0-31]: gpio160-gpio191 |
| 212 | | - GPIO7_IO![0-31]: gpio192-gpio223 |
| 213 | | - [wiki:gsc GSC] GPIOs: |
| 214 | | - GSC_GPIO_P0![0-7]: gpio240-gpio247 |
| 215 | | - GSC_GPIO_P1![0-7]: gpio247-gpio255 |
| 216 | | - additional i2c based GPIO port-expanders present on some boards would begin at gpio116 |
| 217 | | * Laguna: |
| 218 | | - cns3xxx GPIOs: The CNS3xxx has 2 32bit GPIO controllers for a possible 64 fast ARM based GPIO's |
| 219 | | - GPIOA![0-31]: gpio0-gpio31 |
| 220 | | - GPIOB![0-31]: gpio32-gpio63 |
| 221 | | - [wiki:gsc GSC] GPIOs: |
| 222 | | - GSC_GPIO_P0![0-7]: gpio100-gpio107 |
| 223 | | - GSC_GPIO_P1![0-7]: gpio108-gpio115 |
| 224 | | - additional i2c based GPIO port-expanders present on some boards would begin at gpio116 |
| 225 | | |
| 226 | | Note that the Linux gpio mapping is not guaranteed to remain constant across kernel versions. Care should be taken to consult {{{/sys/kernel/debug/gpio}}} and {{{/sys/class/gpio}}} when changing kernel versions. |
| 227 | | |
| 228 | | When referring to [http://www.gateworks.com/usermanuals Gateworks board user hardware manuals] you will need to translate the hardware pin name to a gpio using the information above. Some examples: |
| 229 | | * Newport GPIO8 would be the 8th IO on the CN80XX GPIO controller thus map to gpio-472. |
| 230 | | * Laguna GPIOA8 would be the 9th IO on the GPIOA controller (the first is GPIOA0) thus map to gpio 0+8 = gpio-8 |
| 231 | | * Laguna GPIOB1 would be the 2nd IO on the GPIOB controller thus map to gpio 32+2 = gpio-34 |
| 232 | | * Ventana GPIO![1]:DIO16 is GPIO block 1 IO 16 thus maps to gpio0 + 16 (or 0*32+16) = gpio-16 |
| 233 | | * Ventana GPIO![2]:DIO9 is GPIO block 2 IO 9 thus maps to gpio32 + 9 (or 1*32+9) = gpio-41 |
| 234 | | * Equation: Ventana GPIO<x>__IO<y> is GPIO block x IO y thus maps to: gpio-((x-1)*32)+y |
| 235 | | |
| 236 | | |
| 237 | | See also: |
| 238 | | * [wiki:ventana/DigitalIO Ventana Digital IO Mapping Page] |
| 239 | | |
| 240 | | === Examples === |
| 241 | | |
| 242 | | If debugfs is enabled in the kernel and mounted (as it is on Gateworks BSP's) you can see a nice table of GPIO mapping via {{{/sys/kernel/debug/gpio}}}. Some examples: |
| 243 | | * Newport GW6400: |
| 244 | | {{{#!bash |
| 245 | | # cat /sys/kernel/debug/gpio |
| 246 | | gpiochip1: GPIOs 448-463, parent: i2c/0-0023, pca9555, can sleep: |
| 247 | | |
| 248 | | gpiochip0: GPIOs 464-511, parent: pci/0000:00:06.0, gpio_thunderx: |
| 249 | | gpio-472 ( |mmc_supply_3v3 ) out hi |
| 250 | | gpio-478 ( |user2 ) out lo |
| 251 | | gpio-495 ( |user1 ) out lo |
| 252 | | }}} |
| 253 | | * Ventana GW5400: |
| 254 | | {{{#!bash |
| 255 | | # cat /sys/kernel/debug/gpio |
| 256 | | GPIOs 0-31, platform/209c000.gpio, 209c000.gpio: |
| 257 | | gpio-26 (pps-gpio ) in lo |
| 258 | | gpio-29 (PCIe reset ) out lo |
| 259 | | gpio-30 (phy-reset ) out hi |
| 260 | | |
| 261 | | GPIOs 32-63, platform/20a0000.gpio, 20a0000.gpio: |
| 262 | | |
| 263 | | GPIOs 64-95, platform/20a4000.gpio, 20a4000.gpio: |
| 264 | | gpio-86 (usb_otg_vbus ) out lo |
| 265 | | |
| 266 | | GPIOs 96-127, platform/20a8000.gpio, 20a8000.gpio: |
| 267 | | gpio-102 (user1 ) out lo |
| 268 | | gpio-103 (user2 ) out lo |
| 269 | | gpio-111 (user3 ) out lo |
| 270 | | |
| 271 | | GPIOs 128-159, platform/20ac000.gpio, 20ac000.gpio: |
| 272 | | |
| 273 | | GPIOs 160-191, platform/20b0000.gpio, 20b0000.gpio: |
| 274 | | |
| 275 | | GPIOs 192-223, platform/20b4000.gpio, 20b4000.gpio: |
| 276 | | gpio-192 (2198000.usdhc cd ) in hi |
| 277 | | |
| 278 | | GPIOs 240-255, i2c/0-0023, pca9555, can sleep: |
| 279 | | gpio-240 (user_pb ) in hi |
| 280 | | }}} |
| 281 | | * Note that this does not show GPIO's that are not used by Linux drivers such as USB HUB reset, Ethernet PHY reset, etc. |
| 282 | | * Laguna GW2388: |
| 283 | | {{{#!bash |
| 284 | | # cat /sys/kernel/debug/gpio |
| 285 | | GPIOs 0-31, cns3xxx_gpio0: |
| 286 | | gpio-0 (GPS_PPS ) in hi |
| 287 | | gpio-3 (USB_FAULT# ) in hi |
| 288 | | gpio-6 (USB_VBUS_EN ) out hi |
| 289 | | gpio-7 (GSM_SEL0 ) out lo |
| 290 | | gpio-8 (GSM_SEL1 ) out lo |
| 291 | | gpio-9 (FP_SER_EN ) out lo |
| 292 | | |
| 293 | | GPIOs 32-63, cns3xxx_gpio1: |
| 294 | | |
| 295 | | GPIOs 100-115, i2c/0-0023, pca9555, can sleep: |
| 296 | | gpio-100 (USER_PB# ) in hi |
| 297 | | gpio-114 (user2 ) out hi |
| 298 | | gpio-115 (user1 ) out hi |
| 299 | | }}} |
| 300 | | * Laguna GW2387: |
| 301 | | {{{#!bash |
| 302 | | # cat /sys/kernel/debug/gpio |
| 303 | | GPIOs 0-31, cns3xxx_gpio0: |
| 304 | | gpio-0 (GPS_PPS ) in hi |
| 305 | | gpio-2 (USB_FAULT# ) in hi |
| 306 | | gpio-5 (USB_PCI_SEL ) out lo |
| 307 | | gpio-6 (USB_VBUS_EN ) out hi |
| 308 | | gpio-7 (GSM_SEL0 ) out lo |
| 309 | | gpio-8 (GSM_SEL1 ) out lo |
| 310 | | gpio-9 (FP_SER_EN ) out lo |
| 311 | | |
| 312 | | GPIOs 32-63, cns3xxx_gpio1: |
| 313 | | |
| 314 | | GPIOs 100-115, i2c/0-0023, pca9555, can sleep: |
| 315 | | gpio-100 (USER_PB# ) in hi |
| 316 | | gpio-114 (user2 ) out hi |
| 317 | | gpio-115 (user1 ) out hi |
| 318 | | }}} |
| 319 | | |
| 320 | | |
| 321 | | |
| 322 | | |
| 323 | | |