EBC Exercise 51 GPIO aggregator

From eLinux.org
Revision as of 09:01, 29 July 2022 by Yoder (talk | contribs) (Install: Switched to group gpio)
Jump to: navigation, search

thumb‎ Embedded Linux Class by Mark A. Yoder


Here are some quick notes on the GPIO aggregator which allows one to group a number of GPIOs into a virtual GPIO chip, visible as an additional /dev/gpiochip*. Its documentation can be found in Documentation/admin-guide/gpio/gpio-aggregator.rst.

My info comes from:

https://bootlin.com/blog/gpio-aggregator-a-virtual-gpio-chip/

https://elixir.bootlin.com/linux/v5.12/source/Documentation/admin-guide/gpio/gpio-aggregator.rst

https://elinux.org/images/c/cb/Linux_GPIO-Evolution_and_Current_State_of_the_User_API.pdf

Install

bone$ grep -i gpio_agg /boot/config-5.10.120-ti-r48 
CONFIG_GPIO_AGGREGATOR=m
bone$ sudo modprobe gpio-aggregator
bone$ cd /sys/bus/platform/drivers/gpio-aggregator
bone$ ls -ls
total 0
0 --w------- 1 root root 4096 Jul 29 10:57 bind
0 --w------- 1 root root 4096 Jul 29 10:57 delete_device
0 lrwxrwxrwx 1 root root    0 Jul 29 10:57 module -> ../../../../module/gpio_aggregator
0 --w------- 1 root root 4096 Jul 29 10:57 new_device
0 --w------- 1 root root 4096 Jul 29 10:56 uevent
0 --w------- 1 root root 4096 Jul 29 10:57 unbind
bone$ sudo chgrp gpio *
bone$ sudo chmod g+w *
bone$ ls -ls
total 0
0 --w--w---- 1 root debian 4096 Jul 29 11:09 bind
0 --w--w---- 1 root debian 4096 Jul 29 11:09 delete_device
0 lrwxrwxrwx 1 root root      0 Jul 29 10:57 module -> ../../../../module/gpio_aggregator
0 --w--w---- 1 root debian 4096 Jul 29 11:09 new_device
0 --w--w---- 1 root debian 4096 Jul 29 11:09 uevent
0 --w--w---- 1 root debian 4096 Jul 29 11:09 unbind
bone$ gpiodetect 
gpiochip0 [gpio-0-31] (32 lines)
gpiochip1 [gpio-32-63] (32 lines)
gpiochip2 [gpio-64-95] (32 lines)
gpiochip3 [gpio-96-127] (32 lines)
bone$ echo "gpio-0-31 0,2 gpio-32-63 1" > new_device 
bone$ ls
bind  delete_device  gpio-aggregator.0  module  new_device  uevent  unbind
bone$ ls gpio-aggregator.0
driver  driver_override  gpio  gpiochip4  modalias  power  subsystem  uevent
bone$ gpioinfo | tail -6
	line  30:         "NC"       unused   input  active-high  
	line  31:         "NC"       unused   input  active-high 
gpiochip4 - 3 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high
bone$ gpiodetect 
gpiochip0 [gpio-0-31] (32 lines)
gpiochip1 [gpio-32-63] (32 lines)
gpiochip2 [gpio-64-95] (32 lines)
gpiochip3 [gpio-96-127] (32 lines)
gpiochip4 [gpio-aggregator.0] (3 lines)
bone$ echo gpio-aggregator.0 > delete_device 




thumb‎ Embedded Linux Class by Mark A. Yoder