Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0-only
0002 
0003 GPIO Testing Driver
0004 ===================
0005 
0006 The GPIO Testing Driver (gpio-mockup) provides a way to create simulated GPIO
0007 chips for testing purposes. The lines exposed by these chips can be accessed
0008 using the standard GPIO character device interface as well as manipulated
0009 using the dedicated debugfs directory structure.
0010 
0011 Creating simulated chips using module params
0012 --------------------------------------------
0013 
0014 When loading the gpio-mockup driver a number of parameters can be passed to the
0015 module.
0016 
0017     gpio_mockup_ranges
0018 
0019         This parameter takes an argument in the form of an array of integer
0020         pairs. Each pair defines the base GPIO number (non-negative integer)
0021         and the first number after the last of this chip. If the base GPIO
0022         is -1, the gpiolib will assign it automatically. while the following
0023         parameter is the number of lines exposed by the chip.
0024 
0025         Example: gpio_mockup_ranges=-1,8,-1,16,405,409
0026 
0027         The line above creates three chips. The first one will expose 8 lines,
0028         the second 16 and the third 4. The base GPIO for the third chip is set
0029         to 405 while for two first chips it will be assigned automatically.
0030 
0031     gpio_mockup_named_lines
0032 
0033         This parameter doesn't take any arguments. It lets the driver know that
0034         GPIO lines exposed by it should be named.
0035 
0036         The name format is: gpio-mockup-X-Y where X is mockup chip's ID
0037         and Y is the line offset.
0038 
0039 Manipulating simulated lines
0040 ----------------------------
0041 
0042 Each mockup chip creates its own subdirectory in /sys/kernel/debug/gpio-mockup/.
0043 The directory is named after the chip's label. A symlink is also created, named
0044 after the chip's name, which points to the label directory.
0045 
0046 Inside each subdirectory, there's a separate attribute for each GPIO line. The
0047 name of the attribute represents the line's offset in the chip.
0048 
0049 Reading from a line attribute returns the current value. Writing to it (0 or 1)
0050 changes the configuration of the simulated pull-up/pull-down resistor
0051 (1 - pull-up, 0 - pull-down).