• Home
  • Raw
  • Download

Lines Matching +full:gpio +full:- +full:config

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
36 * gpiotools_request_linehandle() - request gpio lines in a gpiochip
40 * index for the associated GPIO device.
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
71 return -ENOMEM; in gpiotools_request_linehandle()
74 if (fd == -1) { in gpiotools_request_linehandle()
75 ret = -errno; 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
109 * index for the associated GPIO device.
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
127 struct gpio_v2_line_config *config, 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()
152 req.config = *config; 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()
287 * index for the associated GPIO device.
300 struct gpio_v2_line_config config; in gpiotools_gets() local
303 memset(&config, 0, sizeof(config)); in gpiotools_gets()
304 config.flags = GPIO_V2_LINE_FLAG_INPUT; in gpiotools_gets()
306 &config, CONSUMER); in gpiotools_gets()
326 * @value: The value of gpio, must be 0(low) or 1(high).
344 * index for the associated GPIO device.
356 struct gpio_v2_line_config config; in gpiotools_sets() local
358 memset(&config, 0, sizeof(config)); in gpiotools_sets()
359 config.flags = GPIO_V2_LINE_FLAG_OUTPUT; in gpiotools_sets()
360 config.num_attrs = 1; in gpiotools_sets()
361 config.attrs[0].attr.id = GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES; in gpiotools_sets()
363 gpiotools_set_bit(&config.attrs[0].mask, i); in gpiotools_sets()
364 gpiotools_assign_bit(&config.attrs[0].attr.values, in gpiotools_sets()
368 &config, CONSUMER); in gpiotools_sets()