1 .. SPDX-License-Identifier: BSD-3-Clause
2 Copyright(c) 2021 Marvell.
4 Marvell CNXK GPIO Driver
5 ========================
7 CNXK GPIO PMD configures and manages GPIOs available on the system using
8 standard enqueue/dequeue mechanism offered by raw device abstraction. PMD relies
9 both on standard sysfs GPIO interface provided by the Linux kernel and GPIO
10 kernel driver custom interface allowing one to install userspace interrupt
16 Following features are available:
18 - export/unexport a GPIO
19 - read/write specific value from/to exported GPIO
21 - set GPIO edge that triggers interrupt
23 - register interrupt handler for specific GPIO
28 PMD relies on modified kernel GPIO driver which exposes ``ioctl()`` interface
29 for installing interrupt handlers for low latency signal processing.
31 Driver is shipped with Marvell SDK.
36 CNXK GPIO PMD binds to virtual device which gets created by passing
37 `--vdev=cnxk_gpio,gpiochip=<number>` command line to EAL. `gpiochip` parameter
38 tells PMD which GPIO controller should be used. Available controllers are
39 available under `/sys/class/gpio`. For further details on how Linux represents
40 GPIOs in userspace please refer to
41 `sysfs.txt <https://www.kernel.org/doc/Documentation/gpio/sysfs.txt>`_.
43 If `gpiochip=<number>` was omitted then first gpiochip from the alphabetically
44 sort list of available gpiochips is used.
46 .. code-block:: console
49 export gpiochip448 unexport
51 In above scenario only one GPIO controller is present hence
52 `--vdev=cnxk_gpio,gpiochip=448` should be passed to EAL.
54 Before performing actual data transfer one needs to call
55 ``rte_rawdev_queue_count()`` followed by ``rte_rawdev_queue_conf_get()``. The
56 former returns number GPIOs available in the system irrespective of GPIOs
57 being controllable or not. Thus it is user responsibility to pick the proper
58 ones. The latter call simply returns queue capacity.
60 Respective queue needs to be configured with ``rte_rawdev_queue_setup()``. This
61 call barely exports GPIO to userspace.
63 To perform actual data transfer use standard ``rte_rawdev_enqueue_buffers()``
64 and ``rte_rawdev_dequeue_buffers()`` APIs. Not all messages produce sensible
65 responses hence dequeueing is not always necessary.
70 PMD accepts ``struct cnxk_gpio_msg`` messages which differ by type and payload.
71 Message types along with description are listed below. As for the usage examples
72 please refer to ``cnxk_gpio_selftest()``. There's a set of convenient wrappers
73 available, one for each existing command.
78 Message is used to set output to low or high. This does not work for GPIOs
81 Message must have type set to ``CNXK_GPIO_MSG_TYPE_SET_PIN_VALUE``.
83 Payload must be an integer set to 0 (low) or 1 (high).
85 Consider using ``rte_pmd_gpio_set_pin_value()`` wrapper.
90 Message is used to set edge that triggers interrupt.
92 Message must have type set to ``CNXK_GPIO_MSG_TYPE_SET_PIN_EDGE``.
94 Payload must be `enum cnxk_gpio_pin_edge`.
96 Consider using ``rte_pmd_gpio_set_pin_edge()`` wrapper.
101 Message is used to change GPIO direction to either input or output.
103 Message must have type set to ``CNXK_GPIO_MSG_TYPE_SET_PIN_DIR``.
105 Payload must be `enum cnxk_gpio_pin_dir`.
107 Consider using ``rte_pmd_gpio_set_pin_dir()`` wrapper.
112 Message is used to set whether pin is active low.
114 Message must have type set to ``CNXK_GPIO_MSG_TYPE_SET_PIN_ACTIVE_LOW``.
116 Payload must be an integer set to 0 or 1. The latter activates inversion.
118 Consider using ``rte_pmd_gpio_set_pin_active_low()`` wrapper.
123 Message is used to read GPIO value. Value can be 0 (low) or 1 (high).
125 Message must have type set to ``CNXK_GPIO_MSG_TYPE_GET_PIN_VALUE``.
127 Payload contains integer set to either 0 or 1.
129 Consider using ``rte_pmd_gpio_get_pin_value()`` wrapper.
134 Message is used to read GPIO edge.
136 Message must have type set to ``CNXK_GPIO_MSG_TYPE_GET_PIN_EDGE``.
138 Payload contains `enum cnxk_gpio_pin_edge`.
140 Consider using ``rte_pmd_gpio_get_pin_edge()`` wrapper.
145 Message is used to read GPIO direction.
147 Message must have type set to ``CNXK_GPIO_MSG_TYPE_GET_PIN_DIR``.
149 Payload contains `enum cnxk_gpio_pin_dir`.
151 Consider using ``rte_pmd_gpio_get_pin_dir()`` wrapper.
156 Message is used check whether inverted logic is active.
158 Message must have type set to ``CNXK_GPIO_MSG_TYPE_GET_PIN_ACTIVE_LOW``.
160 Payload contains an integer set to 0 or 1. The latter means inverted logic
163 Consider using ``rte_pmd_gpio_get_pin_active_low()`` wrapper.