On 1/26/2014 5:37 AM, Charles Steinkuehler wrote: > I'm working on building a "universal" device tree overlay that can be > used to enable and switch between most of the various interesting pin > functions (uart, timers, spi, gpio, pru in/out, etc). One problem is > the BeagleBone specific gpio_of_helper driver designed to make it easy > to export GPIO pins via the device tree is forcing a fixed direction of > input or output on the GPIO pins. > > Before I start hacking on the driver, I'm wondering why the pins weren't > either exported with the GPIOF_EXPORT_CHANGEABLE flag set, or why some > provision wasn't made to allow specifying the direction could be changed.
I verified the attached minor patch does what I need and allows the user to change the GPIO direction after the pin is exported by the gpio-of-helper driver. Without this patch, any pins exported to sysfs by the gpio-of-helper driver are missing the /sys/class/gpio/gpio<N>/direction file and are stuck in either input or output mode. Comments? -- Charles Steinkuehler [email protected] -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
>From ffe6ad504f7b471fc006d1d4f8d54b1e5a9f0ff3 Mon Sep 17 00:00:00 2001 From: Charles Steinkuehler <[email protected]> Date: Sun, 26 Jan 2014 14:18:34 +0100 Subject: [PATCH] Allow direction change on gpio-of-helper exported pins Signed-off-by: Charles Steinkuehler <[email protected]> --- drivers/gpio/gpio-of-helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-of-helper.c b/drivers/gpio/gpio-of-helper.c index 16a607f..0f8e118 100644 --- a/drivers/gpio/gpio-of-helper.c +++ b/drivers/gpio/gpio-of-helper.c @@ -167,14 +167,14 @@ gpio_of_entry_create(struct gpio_of_helper_info *info, /* set the request flags */ switch (type) { case GPIO_TYPE_INPUT: - req_flags = GPIOF_DIR_IN | GPIOF_EXPORT; + req_flags = GPIOF_DIR_IN | GPIOF_EXPORT_DIR_CHANGEABLE; if (of_property_read_bool(node, "count-falling-edge")) count_flags |= COUNT_FALLING_EDGE; if (of_property_read_bool(node, "count-rising-edge")) count_flags |= COUNT_RISING_EDGE; break; case GPIO_TYPE_OUTPUT: - req_flags = GPIOF_DIR_OUT | GPIOF_EXPORT; + req_flags = GPIOF_DIR_OUT | GPIOF_EXPORT_DIR_CHANGEABLE; if (of_property_read_bool(node, "init-high")) req_flags |= GPIOF_OUT_INIT_HIGH; else if (of_property_read_bool(node, "init-low")) -- 1.7.10.4
