• Home
  • Raw
  • Download

Lines Matching +full:gpio +full:- +full:lines

1 // SPDX-License-Identifier: GPL-2.0-only
3 * GPIO tools - helpers library for the GPIO tools
17 #include <linux/gpio.h>
18 #include "gpio-utils.h"
20 #define CONSUMER "gpio-utils"
23 * doc: Operation of gpio
27 * ioctl, including request and release for lines of gpio, read/write
28 * the value of gpio. If the user want to do lots of read and write of
29 * lines of gpio, user should use this type of api.
32 * following api will request gpio lines, do the operation and then
33 * release these lines.
36 * gpiotools_request_linehandle() - request gpio lines in a gpiochip
39 * @lines: An array desired lines, specified by offset
40 * index for the associated GPIO device.
41 * @num_lines: The number of lines to request.
42 * @flag: The new flag for requsted gpio. Reference
43 * "linux/gpio.h" for the meaning of flag.
44 * @data: Default value will be set to gpio when flag is
50 * Request gpio lines through the ioctl provided by chardev. User
53 * gpiotools_release_linehandle() to release these lines after that.
58 int gpiotools_request_linehandle(const char *device_name, unsigned int *lines, in gpiotools_request_linehandle() argument
71 return -ENOMEM; in gpiotools_request_linehandle()
74 if (fd == -1) { in gpiotools_request_linehandle()
75 ret = -errno; in gpiotools_request_linehandle()
82 req.lineoffsets[i] = lines[i]; in gpiotools_request_linehandle()
86 req.lines = num_lines; in gpiotools_request_linehandle()
91 if (ret == -1) { in gpiotools_request_linehandle()
92 ret = -errno; in gpiotools_request_linehandle()
97 if (close(fd) == -1) in gpiotools_request_linehandle()
98 perror("Failed to close GPIO character device file"); in gpiotools_request_linehandle()
105 * gpiotools_request_line() - request gpio lines in a gpiochip
108 * @lines: An array desired lines, specified by offset
109 * index for the associated GPIO device.
110 * @num_lines: The number of lines to request.
111 * @config: The new config for requested gpio. Reference
112 * "linux/gpio.h" for config details.
117 * Request gpio lines through the ioctl provided by chardev. User
120 * gpiotools_release_line() to release these lines after that.
125 int gpiotools_request_line(const char *device_name, unsigned int *lines, in gpiotools_request_line() argument
138 return -ENOMEM; in gpiotools_request_line()
141 if (fd == -1) { in gpiotools_request_line()
142 ret = -errno; in gpiotools_request_line()
150 req.offsets[i] = lines[i]; in gpiotools_request_line()
157 if (ret == -1) { in gpiotools_request_line()
158 ret = -errno; in gpiotools_request_line()
163 if (close(fd) == -1) in gpiotools_request_line()
164 perror("Failed to close GPIO character device file"); in gpiotools_request_line()
171 * gpiotools_set_values(): Set the value of gpio(s)
184 if (ret == -1) { in gpiotools_set_values()
185 ret = -errno; in gpiotools_set_values()
195 * gpiotools_get_values(): Get the value of gpio(s)
208 if (ret == -1) { in gpiotools_get_values()
209 ret = -errno; in gpiotools_get_values()
231 if (ret == -1) { in gpiotools_release_linehandle()
232 perror("Failed to close GPIO LINEHANDLE device file"); in gpiotools_release_linehandle()
233 ret = -errno; in gpiotools_release_linehandle()
252 if (ret == -1) { in gpiotools_release_line()
253 perror("Failed to close GPIO LINE device file"); in gpiotools_release_line()
254 ret = -errno; in gpiotools_release_line()
273 unsigned int lines[] = {line}; in gpiotools_get() local
275 ret = gpiotools_gets(device_name, lines, 1, &value); in gpiotools_get()
283 * gpiotools_gets(): Get values from specific lines.
286 * @lines: An array desired lines, specified by offset
287 * index for the associated GPIO device.
288 * @num_lines: The number of lines to request.
294 int gpiotools_gets(const char *device_name, unsigned int *lines, in gpiotools_gets() argument
305 ret = gpiotools_request_line(device_name, lines, num_lines, in gpiotools_gets()
326 * @value: The value of gpio, must be 0(low) or 1(high).
334 unsigned int lines[] = {line}; in gpiotools_set() local
336 return gpiotools_sets(device_name, lines, 1, &value); in gpiotools_set()
340 * gpiotools_sets(): Set values to specific lines.
343 * @lines: An array desired lines, specified by offset
344 * index for the associated GPIO device.
345 * @num_lines: The number of lines to request.
352 int gpiotools_sets(const char *device_name, unsigned int *lines, in gpiotools_sets() argument
367 ret = gpiotools_request_line(device_name, lines, num_lines, in gpiotools_sets()