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
37 * gpiotools_request_line() - request gpio lines in a gpiochip
41 * index for the associated GPIO device.
43 * @config: The new config for requested gpio. Reference
44 * "linux/gpio.h" for config details.
49 * Request gpio lines through the ioctl provided by chardev. User
59 struct gpio_v2_line_config *config, in gpiotools_request_line() argument
70 return -ENOMEM; in gpiotools_request_line()
73 if (fd == -1) { in gpiotools_request_line()
74 ret = -errno; in gpiotools_request_line()
84 req.config = *config; in gpiotools_request_line()
89 if (ret == -1) { in gpiotools_request_line()
90 ret = -errno; in gpiotools_request_line()
95 if (close(fd) == -1) in gpiotools_request_line()
96 perror("Failed to close GPIO character device file"); in gpiotools_request_line()
103 * gpiotools_set_values() - Set the value of gpio(s)
116 if (ret == -1) { in gpiotools_set_values()
117 ret = -errno; in gpiotools_set_values()
127 * gpiotools_get_values() - Get the value of gpio(s)
140 if (ret == -1) { in gpiotools_get_values()
141 ret = -errno; in gpiotools_get_values()
151 * gpiotools_release_line() - Release the line(s) of gpiochip
163 if (ret == -1) { in gpiotools_release_line()
164 perror("Failed to close GPIO LINE device file"); in gpiotools_release_line()
165 ret = -errno; in gpiotools_release_line()
172 * gpiotools_get() - Get value from specific line
194 * gpiotools_gets() - Get values from specific lines.
198 * index for the associated GPIO device.
211 struct gpio_v2_line_config config; in gpiotools_gets() local
214 memset(&config, 0, sizeof(config)); in gpiotools_gets()
215 config.flags = GPIO_V2_LINE_FLAG_INPUT; in gpiotools_gets()
217 &config, CONSUMER); in gpiotools_gets()
233 * gpiotools_set() - Set value to specific line
237 * @value: The value of gpio, must be 0(low) or 1(high).
251 * gpiotools_sets() - Set values to specific lines.
255 * index for the associated GPIO device.
267 struct gpio_v2_line_config config; in gpiotools_sets() local
269 memset(&config, 0, sizeof(config)); in gpiotools_sets()
270 config.flags = GPIO_V2_LINE_FLAG_OUTPUT; in gpiotools_sets()
271 config.num_attrs = 1; in gpiotools_sets()
272 config.attrs[0].attr.id = GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES; in gpiotools_sets()
274 gpiotools_set_bit(&config.attrs[0].mask, i); in gpiotools_sets()
275 gpiotools_assign_bit(&config.attrs[0].attr.values, in gpiotools_sets()
279 &config, CONSUMER); in gpiotools_sets()