Lines Matching +full:gpio +full:- +full:lines
1 // SPDX-License-Identifier: GPL-2.0-only
3 * gpio-event-mon - monitor GPIO line events from userspace
8 * gpio-event-mon -n <device-name> -o <offset>
25 #include <linux/gpio.h>
26 #include "gpio-utils.h"
29 unsigned int *lines, in monitor_device() argument
42 return -ENOMEM; in monitor_device()
45 if (cfd == -1) { in monitor_device()
46 ret = -errno; in monitor_device()
51 ret = gpiotools_request_line(device_name, lines, num_lines, config, in monitor_device()
52 "gpio-event-mon"); in monitor_device()
66 "Failed to issue GPIO LINE GET VALUES IOCTL (%d)\n", in monitor_device()
72 fprintf(stdout, "Monitoring line %d on %s\n", lines[0], device_name); in monitor_device()
76 fprintf(stdout, "Monitoring lines %d", lines[0]); in monitor_device()
77 for (i = 1; i < num_lines - 1; i++) in monitor_device()
78 fprintf(stdout, ", %d", lines[i]); in monitor_device()
79 fprintf(stdout, " and %d on %s\n", lines[i], device_name); in monitor_device()
82 for (i = 1; i < num_lines - 1; i++) in monitor_device()
93 if (ret == -1) { in monitor_device()
94 if (errno == -EAGAIN) { in monitor_device()
98 ret = -errno; in monitor_device()
107 ret = -EIO; in monitor_device()
110 fprintf(stdout, "GPIO EVENT at %" PRIu64 " on line %d (%d|%d) ", in monitor_device()
131 if (close(lfd) == -1) in monitor_device()
134 if (close(cfd) == -1) in monitor_device()
135 perror("Failed to close GPIO character device file"); in monitor_device()
143 fprintf(stderr, "Usage: gpio-event-mon [options]...\n" in print_usage()
144 "Listen to events on GPIO lines, 0->1 1->0\n" in print_usage()
145 " -n <name> Listen on GPIOs on a named device (must be stated)\n" in print_usage()
146 " -o <n> Offset of line to monitor (may be repeated)\n" in print_usage()
147 " -d Set line as open drain\n" in print_usage()
148 " -s Set line as open source\n" in print_usage()
149 " -r Listen for rising edges\n" in print_usage()
150 " -f Listen for falling edges\n" in print_usage()
151 " -w Report the wall-clock time for events\n" in print_usage()
152 " -t Report the hardware timestamp for events\n" in print_usage()
153 " -b <n> Debounce the line with period n microseconds\n" in print_usage()
154 " [-c <n>] Do <n> loops (optional, infinite loop if not stated)\n" in print_usage()
155 " -? This helptext\n" in print_usage()
158 "gpio-event-mon -n gpiochip0 -o 4 -r -f -b 10000\n" in print_usage()
169 unsigned int lines[GPIO_V2_LINES_MAX]; in main() local
178 while ((c = getopt(argc, argv, "c:n:o:b:dsrfwt?")) != -1) { in main()
189 return -1; in main()
191 lines[num_lines] = strtoul(optarg, NULL, 10); in main()
217 return -1; in main()
232 return -1; in main()
239 return monitor_device(device_name, lines, num_lines, &config, loops); in main()