summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-support/libgpiod
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-support/libgpiod')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-support/libgpiod/libgpiod/0001-Add-pass-through-setting-in-gpioset.patch266
-rw-r--r--meta-openbmc-mods/meta-common/recipes-support/libgpiod/libgpiod_%.bbappend7
2 files changed, 273 insertions, 0 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-support/libgpiod/libgpiod/0001-Add-pass-through-setting-in-gpioset.patch b/meta-openbmc-mods/meta-common/recipes-support/libgpiod/libgpiod/0001-Add-pass-through-setting-in-gpioset.patch
new file mode 100644
index 000000000..b9082468c
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-support/libgpiod/libgpiod/0001-Add-pass-through-setting-in-gpioset.patch
@@ -0,0 +1,266 @@
+From 0c393ec7a71f21506334caa3a321fa013a9723ef Mon Sep 17 00:00:00 2001
+From: Ed Tanous <ed.tanous@intel.com>
+Date: Mon, 8 Apr 2019 11:46:09 -0700
+Subject: [PATCH] [PATCH] Add pass through setting in gpioset
+
+Signed-off-by: Kuiying Wang <kuiying.wang@intel.com>
+Signed-off-by: Ed Tanous <ed.tanous@intel.com>
+---
+ aclocal.m4 | 2 +-
+ configure | 2 +-
+ include/gpiod.h | 10 ++++++++--
+ lib/core.c | 13 +++++++------
+ lib/ctxless.c | 8 +++++---
+ lib/helpers.c | 3 ++-
+ tests/tests-ctxless.c | 2 +-
+ tools/gpioset.c | 13 +++++++++----
+ 8 files changed, 34 insertions(+), 19 deletions(-)
+
+diff --git a/aclocal.m4 b/aclocal.m4
+index b0db596..a5e28ad 100644
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -911,7 +911,7 @@ AS_VAR_IF([$1], [""], [$5], [$4])dnl
+ # generated from the m4 files accompanying Automake X.Y.
+ # (This private macro should not be called outside this file.)
+ AC_DEFUN([AM_AUTOMAKE_VERSION],
+-[am__api_version='1.15'
++[am__api_version='1.16'
+ dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+ dnl require some minimum version. Point them to the right macro.
+ m4_if([$1], [1.15], [],
+diff --git a/configure b/configure
+index f5a0a23..c0cdbf1 100755
+--- a/configure
++++ b/configure
+@@ -2484,7 +2484,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+
+
+
+-am__api_version='1.15'
++am__api_version='1.16'
+
+ # Find a good install program. We prefer a C program (faster),
+ # so one script is as good as another. But avoid the broken or
+diff --git a/include/gpiod.h b/include/gpiod.h
+index 2679478..7b5c186 100644
+--- a/include/gpiod.h
++++ b/include/gpiod.h
+@@ -121,6 +121,7 @@ typedef void (*gpiod_ctxless_set_value_cb)(void *);
+ * @param offset The offset of the GPIO line.
+ * @param value New value (0 or 1).
+ * @param active_low The active state of this line - true if low.
++ * @param pass_through The pass-through state of the lines - true if enabled.
+ * @param consumer Name of the consumer.
+ * @param cb Optional callback function that will be called right after setting
+ * the value. Users can use this, for example, to pause the execution
+@@ -129,7 +130,7 @@ typedef void (*gpiod_ctxless_set_value_cb)(void *);
+ * @return 0 if the operation succeeds, -1 on error.
+ */
+ int gpiod_ctxless_set_value(const char *device, unsigned int offset, int value,
+- bool active_low, const char *consumer,
++ bool active_low, bool pass_through, const char *consumer,
+ gpiod_ctxless_set_value_cb cb,
+ void *data) GPIOD_API;
+
+@@ -140,6 +141,7 @@ int gpiod_ctxless_set_value(const char *device, unsigned int offset, int value,
+ * @param values Array of integers containing new values.
+ * @param num_lines Number of lines, must be > 0.
+ * @param active_low The active state of the lines - true if low.
++ * @param pass_through The pass-through state of the lines - true if enabled.
+ * @param consumer Name of the consumer.
+ * @param cb Optional callback function that will be called right after setting
+ * all values. Works the same as in ::gpiod_ctxless_set_value.
+@@ -149,7 +151,7 @@ int gpiod_ctxless_set_value(const char *device, unsigned int offset, int value,
+ int gpiod_ctxless_set_value_multiple(const char *device,
+ const unsigned int *offsets,
+ const int *values, unsigned int num_lines,
+- bool active_low, const char *consumer,
++ bool active_low, bool pass_through, const char *consumer,
+ gpiod_ctxless_set_value_cb cb,
+ void *data) GPIOD_API;
+
+@@ -766,6 +768,8 @@ enum {
+ /**< Request the line(s) for reading the GPIO line state. */
+ GPIOD_LINE_REQUEST_DIRECTION_OUTPUT,
+ /**< Request the line(s) for setting the GPIO line state. */
++ GPIOD_LINE_REQUEST_DIRECTION_PASS_THROUGH,
++ /**< Request the line(s) for setting the GPIO line state. */
+ GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE,
+ /**< Monitor both types of events. */
+ GPIOD_LINE_REQUEST_EVENT_RISING_EDGE,
+@@ -784,6 +788,8 @@ enum {
+ /**< The line is an open-source port. */
+ GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW = GPIOD_BIT(2),
+ /**< The active state of the line is low (high is the default). */
++ GPIOD_LINE_REQUEST_FLAG_PASS_THROUGH = GPIOD_BIT(5),
++ /**< The line is a pass-through port*/
+ };
+
+ /**
+diff --git a/lib/core.c b/lib/core.c
+index 05e5a46..635569c 100644
+--- a/lib/core.c
++++ b/lib/core.c
+@@ -470,7 +470,6 @@ static int line_request_values(struct gpiod_line_bulk *bulk,
+ struct gpiohandle_request req;
+ unsigned int i;
+ int rv, fd;
+-
+ if ((config->request_type != GPIOD_LINE_REQUEST_DIRECTION_OUTPUT) &&
+ (config->flags & (GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN |
+ GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE))) {
+@@ -497,14 +496,15 @@ static int line_request_values(struct gpiod_line_bulk *bulk,
+ req.flags |= GPIOHANDLE_REQUEST_INPUT;
+ else if (config->request_type == GPIOD_LINE_REQUEST_DIRECTION_OUTPUT)
+ req.flags |= GPIOHANDLE_REQUEST_OUTPUT;
+-
++ else if (config->request_type == GPIOD_LINE_REQUEST_DIRECTION_PASS_THROUGH)
++ req.flags |= GPIOHANDLE_REQUEST_PASS_THROUGH;
+ req.lines = gpiod_line_bulk_num_lines(bulk);
+
+ gpiod_line_bulk_foreach_line_off(bulk, line, i) {
+ req.lineoffsets[i] = gpiod_line_offset(line);
+- if (config->request_type ==
+- GPIOD_LINE_REQUEST_DIRECTION_OUTPUT &&
+- default_vals)
++ if ((config->request_type == GPIOD_LINE_REQUEST_DIRECTION_OUTPUT ||
++ config->request_type == GPIOD_LINE_REQUEST_DIRECTION_PASS_THROUGH)&&
++ default_vals)
+ req.default_values[i] = !!default_vals[i];
+ }
+
+@@ -615,7 +615,8 @@ static bool line_request_is_direction(int request)
+ {
+ return request == GPIOD_LINE_REQUEST_DIRECTION_AS_IS ||
+ request == GPIOD_LINE_REQUEST_DIRECTION_INPUT ||
+- request == GPIOD_LINE_REQUEST_DIRECTION_OUTPUT;
++ request == GPIOD_LINE_REQUEST_DIRECTION_OUTPUT ||
++ request == GPIOD_LINE_REQUEST_DIRECTION_PASS_THROUGH;
+ }
+
+ static bool line_request_is_events(int request)
+diff --git a/lib/ctxless.c b/lib/ctxless.c
+index ba85018..88b0388 100644
+--- a/lib/ctxless.c
++++ b/lib/ctxless.c
+@@ -76,17 +76,17 @@ int gpiod_ctxless_get_value_multiple(const char *device,
+ }
+
+ int gpiod_ctxless_set_value(const char *device, unsigned int offset, int value,
+- bool active_low, const char *consumer,
++ bool active_low, bool pass_through, const char *consumer,
+ gpiod_ctxless_set_value_cb cb, void *data)
+ {
+ return gpiod_ctxless_set_value_multiple(device, &offset, &value, 1,
+- active_low, consumer, cb, data);
++ active_low, pass_through, consumer, cb, data);
+ }
+
+ int gpiod_ctxless_set_value_multiple(const char *device,
+ const unsigned int *offsets,
+ const int *values, unsigned int num_lines,
+- bool active_low, const char *consumer,
++ bool active_low, bool pass_through, const char *consumer,
+ gpiod_ctxless_set_value_cb cb, void *data)
+ {
+ struct gpiod_line_bulk bulk;
+@@ -118,6 +118,8 @@ int gpiod_ctxless_set_value_multiple(const char *device,
+
+ flags = active_low ? GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW : 0;
+
++ flags |= pass_through ? GPIOD_LINE_REQUEST_FLAG_PASS_THROUGH : 0;
++
+ rv = gpiod_line_request_bulk_output_flags(&bulk, consumer,
+ flags, values);
+ if (rv < 0) {
+diff --git a/lib/helpers.c b/lib/helpers.c
+index 479f370..7b2884f 100644
+--- a/lib/helpers.c
++++ b/lib/helpers.c
+@@ -360,7 +360,8 @@ int gpiod_line_request_bulk_output_flags(struct gpiod_line_bulk *bulk,
+ .request_type = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT,
+ .flags = flags,
+ };
+-
++ if (flags & GPIOD_LINE_REQUEST_FLAG_PASS_THROUGH)
++ config.request_type = GPIOD_LINE_REQUEST_DIRECTION_PASS_THROUGH;
+ return gpiod_line_request_bulk(bulk, &config, default_vals);
+ }
+
+diff --git a/tests/tests-ctxless.c b/tests/tests-ctxless.c
+index 638274f..b215f9c 100644
+--- a/tests/tests-ctxless.c
++++ b/tests/tests-ctxless.c
+@@ -20,7 +20,7 @@ static void ctxless_set_get_value(void)
+ TEST_ASSERT_EQ(rv, 0);
+
+ rv = gpiod_ctxless_set_value(test_chip_name(0), 3, 1,
+- false, TEST_CONSUMER, NULL, NULL);
++ false, false, TEST_CONSUMER, NULL, NULL);
+ TEST_ASSERT_RET_OK(rv);
+
+ rv = gpiod_ctxless_get_value(test_chip_name(0), 3,
+diff --git a/tools/gpioset.c b/tools/gpioset.c
+index d9977a7..094d609 100644
+--- a/tools/gpioset.c
++++ b/tools/gpioset.c
+@@ -22,7 +22,8 @@
+ static const struct option longopts[] = {
+ { "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'v' },
+- { "active-low", no_argument, NULL, 'l' },
++ { "active-low", no_argument, NULL, 'l' },
++ { "pass-through", no_argument, NULL, 'p' },
+ { "mode", required_argument, NULL, 'm' },
+ { "sec", required_argument, NULL, 's' },
+ { "usec", required_argument, NULL, 'u' },
+@@ -30,7 +31,7 @@ static const struct option longopts[] = {
+ { GETOPT_NULL_LONGOPT },
+ };
+
+-static const char *const shortopts = "+hvlm:s:u:b";
++static const char *const shortopts = "+hvlpm:s:u:b";
+
+ static void print_help(void)
+ {
+@@ -40,8 +41,9 @@ static void print_help(void)
+ printf("\n");
+ printf("Options:\n");
+ printf(" -h, --help:\t\tdisplay this message and exit\n");
+- printf(" -v, --version:\tdisplay the version and exit\n");
+ printf(" -l, --active-low:\tset the line active state to low\n");
++ printf(" -v, --version:\tdisplay the version and exit\n");
++ printf(" -p, --pass-through:\tset it to pass through mode\n");
+ printf(" -m, --mode=[exit|wait|time|signal] (defaults to 'exit'):\n");
+ printf(" tell the program what to do after setting values\n");
+ printf(" -s, --sec=SEC:\tspecify the number of seconds to wait (only valid for --mode=time)\n");
+@@ -185,6 +187,7 @@ int main(int argc, char **argv)
+ int *values, rv, optc, opti;
+ struct callback_data cbdata;
+ bool active_low = false;
++ bool pass_through = false;
+ char *device, *end;
+
+ memset(&cbdata, 0, sizeof(cbdata));
+@@ -203,6 +206,8 @@ int main(int argc, char **argv)
+ return EXIT_SUCCESS;
+ case 'l':
+ active_low = true;
++ case 'p':
++ pass_through = true;
+ break;
+ case 'm':
+ mode = parse_mode(optarg);
+@@ -269,7 +274,7 @@ int main(int argc, char **argv)
+ }
+
+ rv = gpiod_ctxless_set_value_multiple(device, offsets, values,
+- num_lines, active_low, "gpioset",
++ num_lines, active_low, pass_through, "gpioset",
+ mode->callback, &cbdata);
+ if (rv < 0)
+ die_perror("error setting the GPIO line values");
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-common/recipes-support/libgpiod/libgpiod_%.bbappend b/meta-openbmc-mods/meta-common/recipes-support/libgpiod/libgpiod_%.bbappend
new file mode 100644
index 000000000..5c3c24ec5
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-support/libgpiod/libgpiod_%.bbappend
@@ -0,0 +1,7 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+PACKAGECONFIG += " cxx"
+
+SRC_URI += " \
+ file://0001-Add-pass-through-setting-in-gpioset.patch \
+ "