chardev_v1.rst 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ========================================
  3. GPIO Character Device Userspace API (v1)
  4. ========================================
  5. .. warning::
  6. This API is obsoleted by chardev.rst (v2).
  7. New developments should use the v2 API, and existing developments are
  8. encouraged to migrate as soon as possible, as this API will be removed
  9. in the future. The v2 API is a functional superset of the v1 API so any
  10. v1 call can be directly translated to a v2 equivalent.
  11. This interface will continue to be maintained for the migration period,
  12. but new features will only be added to the new API.
  13. First added in 4.8.
  14. The API is based around three major objects, the :ref:`gpio-v1-chip`, the
  15. :ref:`gpio-v1-line-handle`, and the :ref:`gpio-v1-line-event`.
  16. Where "line event" is used in this document it refers to the request that can
  17. monitor a line for edge events, not the edge events themselves.
  18. .. _gpio-v1-chip:
  19. Chip
  20. ====
  21. The Chip represents a single GPIO chip and is exposed to userspace using device
  22. files of the form ``/dev/gpiochipX``.
  23. Each chip supports a number of GPIO lines,
  24. :c:type:`chip.lines<gpiochip_info>`. Lines on the chip are identified by an
  25. ``offset`` in the range from 0 to ``chip.lines - 1``, i.e. `[0,chip.lines)`.
  26. Lines are requested from the chip using either gpio-get-linehandle-ioctl.rst
  27. and the resulting line handle is used to access the GPIO chip's lines, or
  28. gpio-get-lineevent-ioctl.rst and the resulting line event is used to monitor
  29. a GPIO line for edge events.
  30. Within this documentation, the file descriptor returned by calling `open()`
  31. on the GPIO device file is referred to as ``chip_fd``.
  32. Operations
  33. ----------
  34. The following operations may be performed on the chip:
  35. .. toctree::
  36. :titlesonly:
  37. Get Line Handle <gpio-get-linehandle-ioctl>
  38. Get Line Event <gpio-get-lineevent-ioctl>
  39. Get Chip Info <gpio-get-chipinfo-ioctl>
  40. Get Line Info <gpio-get-lineinfo-ioctl>
  41. Watch Line Info <gpio-get-lineinfo-watch-ioctl>
  42. Unwatch Line Info <gpio-get-lineinfo-unwatch-ioctl>
  43. Read Line Info Changed Events <gpio-lineinfo-changed-read>
  44. .. _gpio-v1-line-handle:
  45. Line Handle
  46. ===========
  47. Line handles are created by gpio-get-linehandle-ioctl.rst and provide
  48. access to a set of requested lines. The line handle is exposed to userspace
  49. via the anonymous file descriptor returned in
  50. :c:type:`request.fd<gpiohandle_request>` by gpio-get-linehandle-ioctl.rst.
  51. Within this documentation, the line handle file descriptor is referred to
  52. as ``handle_fd``.
  53. Operations
  54. ----------
  55. The following operations may be performed on the line handle:
  56. .. toctree::
  57. :titlesonly:
  58. Get Line Values <gpio-handle-get-line-values-ioctl>
  59. Set Line Values <gpio-handle-set-line-values-ioctl>
  60. Reconfigure Lines <gpio-handle-set-config-ioctl>
  61. .. _gpio-v1-line-event:
  62. Line Event
  63. ==========
  64. Line events are created by gpio-get-lineevent-ioctl.rst and provide
  65. access to a requested line. The line event is exposed to userspace
  66. via the anonymous file descriptor returned in
  67. :c:type:`request.fd<gpioevent_request>` by gpio-get-lineevent-ioctl.rst.
  68. Within this documentation, the line event file descriptor is referred to
  69. as ``event_fd``.
  70. Operations
  71. ----------
  72. The following operations may be performed on the line event:
  73. .. toctree::
  74. :titlesonly:
  75. Get Line Value <gpio-handle-get-line-values-ioctl>
  76. Read Line Edge Events <gpio-lineevent-data-read>
  77. Types
  78. =====
  79. This section contains the structs that are referenced by the ABI v1.
  80. The :c:type:`struct gpiochip_info<gpiochip_info>` is common to ABI v1 and v2.
  81. .. kernel-doc:: include/uapi/linux/gpio.h
  82. :identifiers:
  83. gpioevent_data
  84. gpioevent_request
  85. gpiohandle_config
  86. gpiohandle_data
  87. gpiohandle_request
  88. gpioline_info
  89. gpioline_info_changed
  90. .. toctree::
  91. :hidden:
  92. error-codes