1 .. SPDX-License-Identifier: GPL-2.0-or-later 2 3 Configfs GPIO Simulator 4 ======================= 5 6 The configfs GPIO Simulator (gpio-sim) provide 7 chips for testing purposes. The lines exposed 8 using the standard GPIO character device inter 9 using sysfs attributes. 10 11 Creating simulated chips 12 ------------------------ 13 14 The gpio-sim module registers a configfs subsy 15 details of the configfs filesystem, please ref 16 17 The user can create a hierarchy of configfs gr 18 values of exposed attributes. Once the chip is 19 will be translated to appropriate device prope 20 21 **Group:** ``/config/gpio-sim`` 22 23 This is the top directory of the gpio-sim conf 24 25 **Group:** ``/config/gpio-sim/gpio-device`` 26 27 **Attribute:** ``/config/gpio-sim/gpio-device/ 28 29 **Attribute:** ``/config/gpio-sim/gpio-device/ 30 31 This is a directory representing a GPIO platfo 32 attribute is read-only and allows the user-spa 33 name (e.g. ``'gpio-sim.0'``). The ``'live'`` a 34 actual creation of the device once it's fully 35 are: ``'1'`` to enable the simulated device an 36 it down. 37 38 **Group:** ``/config/gpio-sim/gpio-device/gpio 39 40 **Attribute:** ``/config/gpio-sim/gpio-device/ 41 42 **Attribute:** ``/config/gpio-sim/gpio-device/ 43 44 This group represents a bank of GPIOs under th 45 ``'chip_name'`` attribute is read-only and all 46 device name of the bank device. The ``'num_lin 47 the number of lines exposed by this bank. 48 49 **Group:** ``/config/gpio-sim/gpio-device/gpio 50 51 **Attribute:** ``/config/gpio-sim/gpio-device/ 52 53 This group represents a single line at the off 54 allows to set the line name as represented by 55 56 **Item:** ``/config/gpio-sim/gpio-device/gpio- 57 58 **Attribute:** ``/config/gpio-sim/gpio-device/ 59 60 **Attribute:** ``/config/gpio-sim/gpio-device/ 61 62 This item makes the gpio-sim module hog the as 63 attribute specifies the in-kernel consumer nam 64 attribute specifies the hog direction and must 65 ``'output-high'`` and ``'output-low'``. 66 67 Inside each bank directory, there's a set of a 68 configure the new chip. Additionally the user 69 inside the chip's directory that allow to pass 70 specific lines. The name of those subdirectori 71 ``'line<offset>'`` (e.g. ``'line0'``, ``'line2 72 used by the module to assign the config to the 73 74 Once the confiuration is complete, the ``'live 75 order to instantiate the chip. It can be set b 76 chip. The module will synchronously wait for t 77 successfully probed and if this doesn't happen 78 result in an error. 79 80 Simulated GPIO chips can also be defined in de 81 must be: ``"gpio-simulator"``. Supported prope 82 83 ``"gpio-sim,label"`` - chip label 84 85 Other standard GPIO properties (like ``"gpio-l 86 ``"gpio-hog"``) are also supported. Please ref 87 details. 88 89 An example device-tree code defining a GPIO si 90 91 .. code-block :: none 92 93 gpio-sim { 94 compatible = "gpio-simulator"; 95 96 bank0 { 97 gpio-controller; 98 #gpio-cells = <2>; 99 ngpios = <16>; 100 gpio-sim,label = "dt-bank0"; 101 gpio-line-names = "", "sim-foo", " 102 }; 103 104 bank1 { 105 gpio-controller; 106 #gpio-cells = <2>; 107 ngpios = <8>; 108 gpio-sim,label = "dt-bank1"; 109 110 line3 { 111 gpio-hog; 112 gpios = <3 0>; 113 output-high; 114 line-name = "sim-hog-from-dt"; 115 }; 116 }; 117 }; 118 119 Manipulating simulated lines 120 ---------------------------- 121 122 Each simulated GPIO chip creates a separate sy 123 directory for each exposed line 124 (e.g. ``/sys/devices/platform/gpio-sim.X/gpioc 125 is of the form: ``'sim_gpioX'`` where X is the 126 group there are two attributes: 127 128 ``pull`` - allows to read and set the curr 129 every line, when writing the va 130 ``'pull-down'`` 131 132 ``value`` - allows to read the current val 133 different from the pull if the 134 user-space
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.