1 .. SPDX-License-Identifier: GPL-2.0-only 2 3 Virtual GPIO Consumer 4 ===================== 5 6 The virtual GPIO Consumer module allows users 7 that request GPIOs and then control their beha 8 consumer devices can be instantiated from devi 9 10 A virtual consumer uses the driver-facing GPIO 11 automated tests driven by user-space. The GPIO 12 ``gpiod_get_array()`` and so we support multip 13 14 Creating GPIO consumers 15 ----------------------- 16 17 The gpio-consumer module registers a configfs 18 ``'gpio-virtuser'``. For details of the config 19 the configfs documentation. 20 21 The user can create a hierarchy of configfs gr 22 values of exposed attributes. Once the consume 23 will be translated to appropriate device prope 24 25 **Group:** ``/config/gpio-virtuser`` 26 27 This is the top directory of the gpio-consumer 28 29 **Group:** ``/config/gpio-consumer/example-nam 30 31 **Attribute:** ``/config/gpio-consumer/example 32 33 **Attribute:** ``/config/gpio-consumer/example 34 35 This is a directory representing a GPIO consum 36 37 The read-only ``dev_name`` attribute exposes t 38 appear in the system on the platform bus. This 39 associated debugfs directory under 40 ``/sys/kernel/debug/gpio-virtuser/$dev_name``. 41 42 The ``'live'`` attribute allows to trigger the 43 once it's fully configured. The accepted value 44 virtual device and ``'0'`` to disable and tear 45 46 Creating GPIO lookup tables 47 --------------------------- 48 49 Users can create a number of configfs groups u 50 51 **Group:** ``/config/gpio-consumer/example-nam 52 53 The ``'con_id'`` directory represents a single 54 to the ``'con_id'`` argument of the ``gpiod_ge 55 ``con_id`` == ``'reset'`` maps to the ``reset- 56 57 Users can assign a number of GPIOs to each loo 58 with a user-defined name under the ``'con_id'` 59 60 **Attribute:** ``/config/gpio-consumer/example 61 62 **Attribute:** ``/config/gpio-consumer/example 63 64 **Attribute:** ``/config/gpio-consumer/example 65 66 **Attribute:** ``/config/gpio-consumer/example 67 68 **Attribute:** ``/config/gpio-consumer/example 69 70 **Attribute:** ``/config/gpio-consumer/example 71 72 This is a group describing a single GPIO in th 73 74 For virtual consumers created using configfs w 75 this group can be considered as a mapping betw 76 of a single entry in ``'struct gpiod_lookup'`` 77 78 The ``'key'`` attribute represents either the 79 belongs to or the GPIO line name. This depends 80 attribute: if its value is >= 0, then ``'key'` 81 chip to lookup while ``'offset'`` represents t 82 chip. If ``'offset'`` is < 0, then ``'key'`` r 83 84 The remaining attributes map to the ``'flags'` 85 struct. The first two take string values as ar 86 87 **``'drive'``:** ``'push-pull'``, ``'open-drai 88 **``'pull'``:** ``'pull-up'``, ``'pull-down'`` 89 90 ``'active_low'`` and ``'transitory'`` are bool 91 92 Activating GPIO consumers 93 ------------------------- 94 95 Once the confiuration is complete, the ``'live 96 order to instantiate the consumer. It can be s 97 virtual device. The module will synchronously 98 to be successfully probed and if this doesn't 99 result in an error. 100 101 Device-tree 102 ----------- 103 104 Virtual GPIO consumers can also be defined in 105 must be: ``"gpio-virtuser"`` with at least one 106 standardized GPIO pattern. 107 108 An example device-tree code defining a virtual 109 110 .. code-block :: none 111 112 gpio-virt-consumer { 113 compatible = "gpio-virtuser"; 114 115 foo-gpios = <&gpio0 5 GPIO_ACTIVE_LOW> 116 bar-gpios = <&gpio0 6 0>; 117 }; 118 119 Controlling virtual GPIO consumers 120 ---------------------------------- 121 122 Once active, the device will export debugfs at 123 arrays as well as each requested GPIO line sep 124 following device property: ``foo-gpios = <&gpi 125 126 The following debugfs attribute groups will be 127 128 **Group:** ``/sys/kernel/debug/gpio-virtuser/$ 129 130 This is the group that will contain the attrib 131 132 **Attribute:** ``/sys/kernel/debug/gpio-virtus 133 134 **Attribute:** ``/sys/kernel/debug/gpio-virtus 135 136 Both attributes allow to read and set arrays o 137 exactly the number of values that the array co 138 containing zeroes and ones representing inacti 139 respectively. In this example: ``echo 11 > val 140 141 The ``values_atomic`` attribute works the same 142 will execute the GPIO driver callbacks in inte 143 144 **Group:** ``/sys/kernel/debug/gpio-virtuser/$ 145 146 This is a group that represents a single GPIO 147 in the array. 148 149 **Attribute:** ``/sys/kernel/debug/gpio-virtus 150 151 Allows to set and read the consumer label of t 152 153 **Attribute:** ``/sys/kernel/debug/gpio-virtus 154 155 Allows to set and read the debounce period of 156 157 **Attribute:** ``/sys/kernel/debug/gpio-virtus 158 159 **Attribute:** ``/sys/kernel/debug/gpio-virtus 160 161 These two attributes allow to set the directio 162 "input" and "output" as values. The atomic var 163 in interrupt context. 164 165 **Attribute:** ``/sys/kernel/debug/gpio-virtus 166 167 If the line is requested in input mode, writin 168 make the module listen for edge interrupts on 169 the monitoring. Reading this attribute returns 170 interrupts (both edges). 171 172 **Attribute:** ``/sys/kernel/debug/gpio-virtus 173 174 **Attribute:** ``/sys/kernel/debug/gpio-virtus 175 176 Both attributes allow to read and set values o 177 They accept the following values: ``1`` and ``
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.