gpio.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * <linux/gpio.h> - userspace ABI for the GPIO character devices
  4. *
  5. * Copyright (C) 2016 Linus Walleij
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. */
  11. #ifndef _UAPI_GPIO_H_
  12. #define _UAPI_GPIO_H_
  13. #include <linux/const.h>
  14. #include <linux/ioctl.h>
  15. #include <linux/types.h>
  16. /*
  17. * The maximum size of name and label arrays.
  18. *
  19. * Must be a multiple of 8 to ensure 32/64-bit alignment of structs.
  20. */
  21. #define GPIO_MAX_NAME_SIZE 32
  22. /**
  23. * struct gpiochip_info - Information about a certain GPIO chip
  24. * @name: the Linux kernel name of this GPIO chip
  25. * @label: a functional name for this GPIO chip, such as a product
  26. * number, may be empty (i.e. label[0] == '\0')
  27. * @lines: number of GPIO lines on this chip
  28. */
  29. struct gpiochip_info {
  30. char name[GPIO_MAX_NAME_SIZE];
  31. char label[GPIO_MAX_NAME_SIZE];
  32. __u32 lines;
  33. };
  34. /*
  35. * Maximum number of requested lines.
  36. *
  37. * Must be no greater than 64, as bitmaps are restricted here to 64-bits
  38. * for simplicity, and a multiple of 2 to ensure 32/64-bit alignment of
  39. * structs.
  40. */
  41. #define GPIO_V2_LINES_MAX 64
  42. /*
  43. * The maximum number of configuration attributes associated with a line
  44. * request.
  45. */
  46. #define GPIO_V2_LINE_NUM_ATTRS_MAX 10
  47. /**
  48. * enum gpio_v2_line_flag - &struct gpio_v2_line_attribute.flags values
  49. * @GPIO_V2_LINE_FLAG_USED: line is not available for request
  50. * @GPIO_V2_LINE_FLAG_ACTIVE_LOW: line active state is physical low
  51. * @GPIO_V2_LINE_FLAG_INPUT: line is an input
  52. * @GPIO_V2_LINE_FLAG_OUTPUT: line is an output
  53. * @GPIO_V2_LINE_FLAG_EDGE_RISING: line detects rising (inactive to active)
  54. * edges
  55. * @GPIO_V2_LINE_FLAG_EDGE_FALLING: line detects falling (active to
  56. * inactive) edges
  57. * @GPIO_V2_LINE_FLAG_OPEN_DRAIN: line is an open drain output
  58. * @GPIO_V2_LINE_FLAG_OPEN_SOURCE: line is an open source output
  59. * @GPIO_V2_LINE_FLAG_BIAS_PULL_UP: line has pull-up bias enabled
  60. * @GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN: line has pull-down bias enabled
  61. * @GPIO_V2_LINE_FLAG_BIAS_DISABLED: line has bias disabled
  62. * @GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME: line events contain REALTIME timestamps
  63. * @GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE: line events contain timestamps from
  64. * hardware timestamp engine
  65. */
  66. enum gpio_v2_line_flag {
  67. GPIO_V2_LINE_FLAG_USED = _BITULL(0),
  68. GPIO_V2_LINE_FLAG_ACTIVE_LOW = _BITULL(1),
  69. GPIO_V2_LINE_FLAG_INPUT = _BITULL(2),
  70. GPIO_V2_LINE_FLAG_OUTPUT = _BITULL(3),
  71. GPIO_V2_LINE_FLAG_EDGE_RISING = _BITULL(4),
  72. GPIO_V2_LINE_FLAG_EDGE_FALLING = _BITULL(5),
  73. GPIO_V2_LINE_FLAG_OPEN_DRAIN = _BITULL(6),
  74. GPIO_V2_LINE_FLAG_OPEN_SOURCE = _BITULL(7),
  75. GPIO_V2_LINE_FLAG_BIAS_PULL_UP = _BITULL(8),
  76. GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN = _BITULL(9),
  77. GPIO_V2_LINE_FLAG_BIAS_DISABLED = _BITULL(10),
  78. GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME = _BITULL(11),
  79. GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE = _BITULL(12),
  80. };
  81. /**
  82. * struct gpio_v2_line_values - Values of GPIO lines
  83. * @bits: a bitmap containing the value of the lines, set to 1 for active
  84. * and 0 for inactive.
  85. * @mask: a bitmap identifying the lines to get or set, with each bit
  86. * number corresponding to the index into &struct
  87. * gpio_v2_line_request.offsets.
  88. */
  89. struct gpio_v2_line_values {
  90. __aligned_u64 bits;
  91. __aligned_u64 mask;
  92. };
  93. /**
  94. * enum gpio_v2_line_attr_id - &struct gpio_v2_line_attribute.id values
  95. * identifying which field of the attribute union is in use.
  96. * @GPIO_V2_LINE_ATTR_ID_FLAGS: flags field is in use
  97. * @GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES: values field is in use
  98. * @GPIO_V2_LINE_ATTR_ID_DEBOUNCE: debounce_period_us field is in use
  99. */
  100. enum gpio_v2_line_attr_id {
  101. GPIO_V2_LINE_ATTR_ID_FLAGS = 1,
  102. GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES = 2,
  103. GPIO_V2_LINE_ATTR_ID_DEBOUNCE = 3,
  104. };
  105. /**
  106. * struct gpio_v2_line_attribute - a configurable attribute of a line
  107. * @id: attribute identifier with value from &enum gpio_v2_line_attr_id
  108. * @padding: reserved for future use and must be zero filled
  109. * @flags: if id is %GPIO_V2_LINE_ATTR_ID_FLAGS, the flags for the GPIO
  110. * line, with values from &enum gpio_v2_line_flag, such as
  111. * %GPIO_V2_LINE_FLAG_ACTIVE_LOW, %GPIO_V2_LINE_FLAG_OUTPUT etc, added
  112. * together. This overrides the default flags contained in the &struct
  113. * gpio_v2_line_config for the associated line.
  114. * @values: if id is %GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES, a bitmap
  115. * containing the values to which the lines will be set, with each bit
  116. * number corresponding to the index into &struct
  117. * gpio_v2_line_request.offsets.
  118. * @debounce_period_us: if id is %GPIO_V2_LINE_ATTR_ID_DEBOUNCE, the
  119. * desired debounce period, in microseconds
  120. */
  121. struct gpio_v2_line_attribute {
  122. __u32 id;
  123. __u32 padding;
  124. union {
  125. __aligned_u64 flags;
  126. __aligned_u64 values;
  127. __u32 debounce_period_us;
  128. };
  129. };
  130. /**
  131. * struct gpio_v2_line_config_attribute - a configuration attribute
  132. * associated with one or more of the requested lines.
  133. * @attr: the configurable attribute
  134. * @mask: a bitmap identifying the lines to which the attribute applies,
  135. * with each bit number corresponding to the index into &struct
  136. * gpio_v2_line_request.offsets.
  137. */
  138. struct gpio_v2_line_config_attribute {
  139. struct gpio_v2_line_attribute attr;
  140. __aligned_u64 mask;
  141. };
  142. /**
  143. * struct gpio_v2_line_config - Configuration for GPIO lines
  144. * @flags: flags for the GPIO lines, with values from &enum
  145. * gpio_v2_line_flag, such as %GPIO_V2_LINE_FLAG_ACTIVE_LOW,
  146. * %GPIO_V2_LINE_FLAG_OUTPUT etc, added together. This is the default for
  147. * all requested lines but may be overridden for particular lines using
  148. * @attrs.
  149. * @num_attrs: the number of attributes in @attrs
  150. * @padding: reserved for future use and must be zero filled
  151. * @attrs: the configuration attributes associated with the requested
  152. * lines. Any attribute should only be associated with a particular line
  153. * once. If an attribute is associated with a line multiple times then the
  154. * first occurrence (i.e. lowest index) has precedence.
  155. */
  156. struct gpio_v2_line_config {
  157. __aligned_u64 flags;
  158. __u32 num_attrs;
  159. /* Pad to fill implicit padding and reserve space for future use. */
  160. __u32 padding[5];
  161. struct gpio_v2_line_config_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX];
  162. };
  163. /**
  164. * struct gpio_v2_line_request - Information about a request for GPIO lines
  165. * @offsets: an array of desired lines, specified by offset index for the
  166. * associated GPIO chip
  167. * @consumer: a desired consumer label for the selected GPIO lines such as
  168. * "my-bitbanged-relay"
  169. * @config: requested configuration for the lines.
  170. * @num_lines: number of lines requested in this request, i.e. the number
  171. * of valid fields in the %GPIO_V2_LINES_MAX sized arrays, set to 1 to
  172. * request a single line
  173. * @event_buffer_size: a suggested minimum number of line events that the
  174. * kernel should buffer. This is only relevant if edge detection is
  175. * enabled in the configuration. Note that this is only a suggested value
  176. * and the kernel may allocate a larger buffer or cap the size of the
  177. * buffer. If this field is zero then the buffer size defaults to a minimum
  178. * of @num_lines * 16.
  179. * @padding: reserved for future use and must be zero filled
  180. * @fd: if successful this field will contain a valid anonymous file handle
  181. * after a %GPIO_GET_LINE_IOCTL operation, zero or negative value means
  182. * error
  183. */
  184. struct gpio_v2_line_request {
  185. __u32 offsets[GPIO_V2_LINES_MAX];
  186. char consumer[GPIO_MAX_NAME_SIZE];
  187. struct gpio_v2_line_config config;
  188. __u32 num_lines;
  189. __u32 event_buffer_size;
  190. /* Pad to fill implicit padding and reserve space for future use. */
  191. __u32 padding[5];
  192. __s32 fd;
  193. };
  194. /**
  195. * struct gpio_v2_line_info - Information about a certain GPIO line
  196. * @name: the name of this GPIO line, such as the output pin of the line on
  197. * the chip, a rail or a pin header name on a board, as specified by the
  198. * GPIO chip, may be empty (i.e. name[0] == '\0')
  199. * @consumer: a functional name for the consumer of this GPIO line as set
  200. * by whatever is using it, will be empty if there is no current user but
  201. * may also be empty if the consumer doesn't set this up
  202. * @offset: the local offset on this GPIO chip, fill this in when
  203. * requesting the line information from the kernel
  204. * @num_attrs: the number of attributes in @attrs
  205. * @flags: flags for this GPIO line, with values from &enum
  206. * gpio_v2_line_flag, such as %GPIO_V2_LINE_FLAG_ACTIVE_LOW,
  207. * %GPIO_V2_LINE_FLAG_OUTPUT etc, added together.
  208. * @attrs: the configuration attributes associated with the line
  209. * @padding: reserved for future use
  210. */
  211. struct gpio_v2_line_info {
  212. char name[GPIO_MAX_NAME_SIZE];
  213. char consumer[GPIO_MAX_NAME_SIZE];
  214. __u32 offset;
  215. __u32 num_attrs;
  216. __aligned_u64 flags;
  217. struct gpio_v2_line_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX];
  218. /* Space reserved for future use. */
  219. __u32 padding[4];
  220. };
  221. /**
  222. * enum gpio_v2_line_changed_type - &struct gpio_v2_line_changed.event_type
  223. * values
  224. * @GPIO_V2_LINE_CHANGED_REQUESTED: line has been requested
  225. * @GPIO_V2_LINE_CHANGED_RELEASED: line has been released
  226. * @GPIO_V2_LINE_CHANGED_CONFIG: line has been reconfigured
  227. */
  228. enum gpio_v2_line_changed_type {
  229. GPIO_V2_LINE_CHANGED_REQUESTED = 1,
  230. GPIO_V2_LINE_CHANGED_RELEASED = 2,
  231. GPIO_V2_LINE_CHANGED_CONFIG = 3,
  232. };
  233. /**
  234. * struct gpio_v2_line_info_changed - Information about a change in status
  235. * of a GPIO line
  236. * @info: updated line information
  237. * @timestamp_ns: estimate of time of status change occurrence, in nanoseconds
  238. * @event_type: the type of change with a value from &enum
  239. * gpio_v2_line_changed_type
  240. * @padding: reserved for future use
  241. */
  242. struct gpio_v2_line_info_changed {
  243. struct gpio_v2_line_info info;
  244. __aligned_u64 timestamp_ns;
  245. __u32 event_type;
  246. /* Pad struct to 64-bit boundary and reserve space for future use. */
  247. __u32 padding[5];
  248. };
  249. /**
  250. * enum gpio_v2_line_event_id - &struct gpio_v2_line_event.id values
  251. * @GPIO_V2_LINE_EVENT_RISING_EDGE: event triggered by a rising edge
  252. * @GPIO_V2_LINE_EVENT_FALLING_EDGE: event triggered by a falling edge
  253. */
  254. enum gpio_v2_line_event_id {
  255. GPIO_V2_LINE_EVENT_RISING_EDGE = 1,
  256. GPIO_V2_LINE_EVENT_FALLING_EDGE = 2,
  257. };
  258. /**
  259. * struct gpio_v2_line_event - The actual event being pushed to userspace
  260. * @timestamp_ns: best estimate of time of event occurrence, in nanoseconds.
  261. * @id: event identifier with value from &enum gpio_v2_line_event_id
  262. * @offset: the offset of the line that triggered the event
  263. * @seqno: the sequence number for this event in the sequence of events for
  264. * all the lines in this line request
  265. * @line_seqno: the sequence number for this event in the sequence of
  266. * events on this particular line
  267. * @padding: reserved for future use
  268. *
  269. * By default the @timestamp_ns is read from %CLOCK_MONOTONIC and is
  270. * intended to allow the accurate measurement of the time between events.
  271. * It does not provide the wall-clock time.
  272. *
  273. * If the %GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME flag is set then the
  274. * @timestamp_ns is read from %CLOCK_REALTIME.
  275. */
  276. struct gpio_v2_line_event {
  277. __aligned_u64 timestamp_ns;
  278. __u32 id;
  279. __u32 offset;
  280. __u32 seqno;
  281. __u32 line_seqno;
  282. /* Space reserved for future use. */
  283. __u32 padding[6];
  284. };
  285. /*
  286. * ABI v1
  287. *
  288. * This version of the ABI is deprecated.
  289. * Use the latest version of the ABI, defined above, instead.
  290. */
  291. /* Informational flags */
  292. #define GPIOLINE_FLAG_KERNEL (1UL << 0) /* Line used by the kernel */
  293. #define GPIOLINE_FLAG_IS_OUT (1UL << 1)
  294. #define GPIOLINE_FLAG_ACTIVE_LOW (1UL << 2)
  295. #define GPIOLINE_FLAG_OPEN_DRAIN (1UL << 3)
  296. #define GPIOLINE_FLAG_OPEN_SOURCE (1UL << 4)
  297. #define GPIOLINE_FLAG_BIAS_PULL_UP (1UL << 5)
  298. #define GPIOLINE_FLAG_BIAS_PULL_DOWN (1UL << 6)
  299. #define GPIOLINE_FLAG_BIAS_DISABLE (1UL << 7)
  300. /**
  301. * struct gpioline_info - Information about a certain GPIO line
  302. * @line_offset: the local offset on this GPIO device, fill this in when
  303. * requesting the line information from the kernel
  304. * @flags: various flags for this line
  305. * @name: the name of this GPIO line, such as the output pin of the line on the
  306. * chip, a rail or a pin header name on a board, as specified by the gpio
  307. * chip, may be empty (i.e. name[0] == '\0')
  308. * @consumer: a functional name for the consumer of this GPIO line as set by
  309. * whatever is using it, will be empty if there is no current user but may
  310. * also be empty if the consumer doesn't set this up
  311. *
  312. * Note: This struct is part of ABI v1 and is deprecated.
  313. * Use &struct gpio_v2_line_info instead.
  314. */
  315. struct gpioline_info {
  316. __u32 line_offset;
  317. __u32 flags;
  318. char name[GPIO_MAX_NAME_SIZE];
  319. char consumer[GPIO_MAX_NAME_SIZE];
  320. };
  321. /* Maximum number of requested handles */
  322. #define GPIOHANDLES_MAX 64
  323. /* Possible line status change events */
  324. enum {
  325. GPIOLINE_CHANGED_REQUESTED = 1,
  326. GPIOLINE_CHANGED_RELEASED,
  327. GPIOLINE_CHANGED_CONFIG,
  328. };
  329. /**
  330. * struct gpioline_info_changed - Information about a change in status
  331. * of a GPIO line
  332. * @info: updated line information
  333. * @timestamp: estimate of time of status change occurrence, in nanoseconds
  334. * @event_type: one of %GPIOLINE_CHANGED_REQUESTED,
  335. * %GPIOLINE_CHANGED_RELEASED and %GPIOLINE_CHANGED_CONFIG
  336. * @padding: reserved for future use
  337. *
  338. * The &struct gpioline_info embedded here has 32-bit alignment on its own,
  339. * but it works fine with 64-bit alignment too. With its 72 byte size, we can
  340. * guarantee there are no implicit holes between it and subsequent members.
  341. * The 20-byte padding at the end makes sure we don't add any implicit padding
  342. * at the end of the structure on 64-bit architectures.
  343. *
  344. * Note: This struct is part of ABI v1 and is deprecated.
  345. * Use &struct gpio_v2_line_info_changed instead.
  346. */
  347. struct gpioline_info_changed {
  348. struct gpioline_info info;
  349. __u64 timestamp;
  350. __u32 event_type;
  351. __u32 padding[5]; /* for future use */
  352. };
  353. /* Linerequest flags */
  354. #define GPIOHANDLE_REQUEST_INPUT (1UL << 0)
  355. #define GPIOHANDLE_REQUEST_OUTPUT (1UL << 1)
  356. #define GPIOHANDLE_REQUEST_ACTIVE_LOW (1UL << 2)
  357. #define GPIOHANDLE_REQUEST_OPEN_DRAIN (1UL << 3)
  358. #define GPIOHANDLE_REQUEST_OPEN_SOURCE (1UL << 4)
  359. #define GPIOHANDLE_REQUEST_BIAS_PULL_UP (1UL << 5)
  360. #define GPIOHANDLE_REQUEST_BIAS_PULL_DOWN (1UL << 6)
  361. #define GPIOHANDLE_REQUEST_BIAS_DISABLE (1UL << 7)
  362. /**
  363. * struct gpiohandle_request - Information about a GPIO handle request
  364. * @lineoffsets: an array of desired lines, specified by offset index for the
  365. * associated GPIO device
  366. * @flags: desired flags for the desired GPIO lines, such as
  367. * %GPIOHANDLE_REQUEST_OUTPUT, %GPIOHANDLE_REQUEST_ACTIVE_LOW etc, added
  368. * together. Note that even if multiple lines are requested, the same flags
  369. * must be applicable to all of them, if you want lines with individual
  370. * flags set, request them one by one. It is possible to select
  371. * a batch of input or output lines, but they must all have the same
  372. * characteristics, i.e. all inputs or all outputs, all active low etc
  373. * @default_values: if the %GPIOHANDLE_REQUEST_OUTPUT is set for a requested
  374. * line, this specifies the default output value, should be 0 (low) or
  375. * 1 (high), anything else than 0 or 1 will be interpreted as 1 (high)
  376. * @consumer_label: a desired consumer label for the selected GPIO line(s)
  377. * such as "my-bitbanged-relay"
  378. * @lines: number of lines requested in this request, i.e. the number of
  379. * valid fields in the above arrays, set to 1 to request a single line
  380. * @fd: if successful this field will contain a valid anonymous file handle
  381. * after a %GPIO_GET_LINEHANDLE_IOCTL operation, zero or negative value
  382. * means error
  383. *
  384. * Note: This struct is part of ABI v1 and is deprecated.
  385. * Use &struct gpio_v2_line_request instead.
  386. */
  387. struct gpiohandle_request {
  388. __u32 lineoffsets[GPIOHANDLES_MAX];
  389. __u32 flags;
  390. __u8 default_values[GPIOHANDLES_MAX];
  391. char consumer_label[GPIO_MAX_NAME_SIZE];
  392. __u32 lines;
  393. int fd;
  394. };
  395. /**
  396. * struct gpiohandle_config - Configuration for a GPIO handle request
  397. * @flags: updated flags for the requested GPIO lines, such as
  398. * %GPIOHANDLE_REQUEST_OUTPUT, %GPIOHANDLE_REQUEST_ACTIVE_LOW etc, added
  399. * together
  400. * @default_values: if the %GPIOHANDLE_REQUEST_OUTPUT is set in flags,
  401. * this specifies the default output value, should be 0 (low) or
  402. * 1 (high), anything else than 0 or 1 will be interpreted as 1 (high)
  403. * @padding: reserved for future use and should be zero filled
  404. *
  405. * Note: This struct is part of ABI v1 and is deprecated.
  406. * Use &struct gpio_v2_line_config instead.
  407. */
  408. struct gpiohandle_config {
  409. __u32 flags;
  410. __u8 default_values[GPIOHANDLES_MAX];
  411. __u32 padding[4]; /* padding for future use */
  412. };
  413. /**
  414. * struct gpiohandle_data - Information of values on a GPIO handle
  415. * @values: when getting the state of lines this contains the current
  416. * state of a line, when setting the state of lines these should contain
  417. * the desired target state
  418. *
  419. * Note: This struct is part of ABI v1 and is deprecated.
  420. * Use &struct gpio_v2_line_values instead.
  421. */
  422. struct gpiohandle_data {
  423. __u8 values[GPIOHANDLES_MAX];
  424. };
  425. /* Eventrequest flags */
  426. #define GPIOEVENT_REQUEST_RISING_EDGE (1UL << 0)
  427. #define GPIOEVENT_REQUEST_FALLING_EDGE (1UL << 1)
  428. #define GPIOEVENT_REQUEST_BOTH_EDGES ((1UL << 0) | (1UL << 1))
  429. /**
  430. * struct gpioevent_request - Information about a GPIO event request
  431. * @lineoffset: the desired line to subscribe to events from, specified by
  432. * offset index for the associated GPIO device
  433. * @handleflags: desired handle flags for the desired GPIO line, such as
  434. * %GPIOHANDLE_REQUEST_ACTIVE_LOW or %GPIOHANDLE_REQUEST_OPEN_DRAIN
  435. * @eventflags: desired flags for the desired GPIO event line, such as
  436. * %GPIOEVENT_REQUEST_RISING_EDGE or %GPIOEVENT_REQUEST_FALLING_EDGE
  437. * @consumer_label: a desired consumer label for the selected GPIO line(s)
  438. * such as "my-listener"
  439. * @fd: if successful this field will contain a valid anonymous file handle
  440. * after a %GPIO_GET_LINEEVENT_IOCTL operation, zero or negative value
  441. * means error
  442. *
  443. * Note: This struct is part of ABI v1 and is deprecated.
  444. * Use &struct gpio_v2_line_request instead.
  445. */
  446. struct gpioevent_request {
  447. __u32 lineoffset;
  448. __u32 handleflags;
  449. __u32 eventflags;
  450. char consumer_label[GPIO_MAX_NAME_SIZE];
  451. int fd;
  452. };
  453. /*
  454. * GPIO event types
  455. */
  456. #define GPIOEVENT_EVENT_RISING_EDGE 0x01
  457. #define GPIOEVENT_EVENT_FALLING_EDGE 0x02
  458. /**
  459. * struct gpioevent_data - The actual event being pushed to userspace
  460. * @timestamp: best estimate of time of event occurrence, in nanoseconds
  461. * @id: event identifier
  462. *
  463. * Note: This struct is part of ABI v1 and is deprecated.
  464. * Use &struct gpio_v2_line_event instead.
  465. */
  466. struct gpioevent_data {
  467. __u64 timestamp;
  468. __u32 id;
  469. };
  470. /*
  471. * v1 and v2 ioctl()s
  472. */
  473. #define GPIO_GET_CHIPINFO_IOCTL _IOR(0xB4, 0x01, struct gpiochip_info)
  474. #define GPIO_GET_LINEINFO_UNWATCH_IOCTL _IOWR(0xB4, 0x0C, __u32)
  475. /*
  476. * v2 ioctl()s
  477. */
  478. #define GPIO_V2_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x05, struct gpio_v2_line_info)
  479. #define GPIO_V2_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x06, struct gpio_v2_line_info)
  480. #define GPIO_V2_GET_LINE_IOCTL _IOWR(0xB4, 0x07, struct gpio_v2_line_request)
  481. #define GPIO_V2_LINE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0D, struct gpio_v2_line_config)
  482. #define GPIO_V2_LINE_GET_VALUES_IOCTL _IOWR(0xB4, 0x0E, struct gpio_v2_line_values)
  483. #define GPIO_V2_LINE_SET_VALUES_IOCTL _IOWR(0xB4, 0x0F, struct gpio_v2_line_values)
  484. /*
  485. * v1 ioctl()s
  486. *
  487. * These ioctl()s are deprecated. Use the v2 equivalent instead.
  488. */
  489. #define GPIO_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x02, struct gpioline_info)
  490. #define GPIO_GET_LINEHANDLE_IOCTL _IOWR(0xB4, 0x03, struct gpiohandle_request)
  491. #define GPIO_GET_LINEEVENT_IOCTL _IOWR(0xB4, 0x04, struct gpioevent_request)
  492. #define GPIOHANDLE_GET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x08, struct gpiohandle_data)
  493. #define GPIOHANDLE_SET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x09, struct gpiohandle_data)
  494. #define GPIOHANDLE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0A, struct gpiohandle_config)
  495. #define GPIO_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x0B, struct gpioline_info)
  496. #endif /* _UAPI_GPIO_H_ */