GPIO on the BBB

From Crashcourse Wiki

Jump to: navigation, search

Contents

Overview (work in progress)

Discussion of GPIO manipulation on the BBB, using example of playing with the LEDs, and using the kernel source from building for the BBB using OpenEmbedded.

Relevant kernel config values

Arch-related OMAP values

$ grep OMAP2 include/generated/autoconf.h
#define CONFIG_ARCH_OMAP2PLUS_TYPICAL 1
#define CONFIG_FB_OMAP2_NUM_FBS 3
#define CONFIG_FB_OMAP2_DEBUG_SUPPORT 1
#define CONFIG_OMAP2_DSS_MODULE 1
#define CONFIG_OMAP2_VRFB 1
#define CONFIG_MTD_ONENAND_OMAP2 1
#define CONFIG_MTD_NAND_OMAP2 1
#define CONFIG_OMAP2_DSS_SDI 1
#define CONFIG_OMAP2_DSS_DSI 1
#define CONFIG_OMAP2_DSS_VENC 1
#define CONFIG_OMAP2_DSS_SLEEP_AFTER_VENC_RESET 1
#define CONFIG_FB_OMAP2_MODULE 1
#define CONFIG_OMAP2_DSS_MIN_FCK_PER_PCK 0
#define CONFIG_ARCH_OMAP2PLUS 1
#define CONFIG_SPI_OMAP24XX 1
#define CONFIG_OMAP2_DSS_DPI 1
#define CONFIG_SOC_HAS_OMAP2_SDRC 1
#define CONFIG_OMAP2_DSS_RFBI 1
$

GPIO-related values

$ grep GPIO include/generated/autoconf.h
#define CONFIG_IIO_GPIO_TRIGGER_MODULE 1
#define CONFIG_USB_GPIO_VBUS_MODULE 1
#define CONFIG_GPIO_PCF857X 1
#define CONFIG_GENERIC_GPIO 1                       <-----
#define CONFIG_SENSORS_GPIO_FAN_MODULE 1
#define CONFIG_DEBUG_GPIO 1
#define CONFIG_RFKILL_GPIO_MODULE 1
#define CONFIG_CHARGER_GPIO_MODULE 1
#define CONFIG_W1_MASTER_GPIO 1
#define CONFIG_I2C_MUX_GPIO 1
#define CONFIG_ARCH_REQUIRE_GPIOLIB 1
#define CONFIG_KEYBOARD_GPIO 1
#define CONFIG_LEDS_TRIGGER_GPIO 1
#define CONFIG_GPIO_SYSFS 1
#define CONFIG_GPIOLIB 1
#define CONFIG_RSTCTL_GPIO 1
#define CONFIG_ARCH_NR_GPIO 0
#define CONFIG_REGULATOR_GPIO 1
#define CONFIG_OF_GPIO 1
#define CONFIG_IR_GPIO_CIR_MODULE 1
#define CONFIG_ARCH_HAVE_CUSTOM_GPIO_H 1            <-----
#define CONFIG_INPUT_GPIO_ROTARY_ENCODER_MODULE 1
#define CONFIG_LEDS_GPIO 1
#define CONFIG_GPIO_TWL4030 1
$

The initial /sys entries

First, there's:

# cd /sys/class/gpio
# ls -l
total 0
--w------- 1 root root 4096 Jan  1 00:00 export
lrwxrwxrwx 1 root root    0 Jan  1 00:00 gpiochip0 -> ../../devices/virtual/gpio/gpiochip0
lrwxrwxrwx 1 root root    0 Jan  1 00:00 gpiochip32 -> ../../devices/virtual/gpio/gpiochip32
lrwxrwxrwx 1 root root    0 Jan  1 00:00 gpiochip64 -> ../../devices/virtual/gpio/gpiochip64
lrwxrwxrwx 1 root root    0 Jan  1 00:00 gpiochip96 -> ../../devices/virtual/gpio/gpiochip96
--w------- 1 root root 4096 Jan  1 00:00 unexport
#

and there's the current mapping (as long as you have the debugfs mounted) where you can see the associated LEDs:

# cat /sys/kernel/debug/gpio
GPIOs 0-31, gpio:

GPIOs 32-63, gpio:
 gpio-52  (eMMC_RSTn           ) out lo
 gpio-53  (beaglebone:green:usr) out lo
 gpio-54  (beaglebone:green:usr) out lo
 gpio-55  (beaglebone:green:usr) out hi
 gpio-56  (beaglebone:green:usr) out lo
 gpio-59  (McASP Clock Enable P) out hi

GPIOs 64-95, gpio:

GPIOs 96-127, gpio:
#

More coming ...



(Back to BeagleBone Black page.)

Personal tools