aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/gpio
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-03-22 05:51:16 -0400
committerLinus Walleij <linus.walleij@linaro.org>2016-04-05 10:57:15 -0400
commitc663e5f56737757db4d0b317c510ab505f93cecb (patch)
treefbccce2fb9c115fc5f42869cae744dcbc816ea9c /include/linux/gpio
parent6e66a6599a813abfc9ebe2e295c9d557c434812a (diff)
gpio: support native single-ended hardware drivers
Some GPIO controllers has a special hardware bit we can flip to support open drain / source. This means that on these hardwares we do not need to emulate OD/OS by setting the line to input instead of actively driving it high/low. Add an optional vtable callback to the driver set_single_ended() so that driver can implement this in hardware if they have it. We may need a pinctrl_gpio_set_config() call at some point to propagate this down to a backing pin control device on systems with split GPIO/pin control. Reported-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux/gpio')
-rw-r--r--include/linux/gpio/driver.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index bee976f82788..50882e09289b 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -20,6 +20,18 @@ struct gpio_device;
20#ifdef CONFIG_GPIOLIB 20#ifdef CONFIG_GPIOLIB
21 21
22/** 22/**
23 * enum single_ended_mode - mode for single ended operation
24 * @LINE_MODE_PUSH_PULL: normal mode for a GPIO line, drive actively high/low
25 * @LINE_MODE_OPEN_DRAIN: set line to be open drain
26 * @LINE_MODE_OPEN_SOURCE: set line to be open source
27 */
28enum single_ended_mode {
29 LINE_MODE_PUSH_PULL,
30 LINE_MODE_OPEN_DRAIN,
31 LINE_MODE_OPEN_SOURCE,
32};
33
34/**
23 * struct gpio_chip - abstract a GPIO controller 35 * struct gpio_chip - abstract a GPIO controller
24 * @label: a functional name for the GPIO device, such as a part 36 * @label: a functional name for the GPIO device, such as a part
25 * number or the name of the SoC IP-block implementing it. 37 * number or the name of the SoC IP-block implementing it.
@@ -38,7 +50,15 @@ struct gpio_device;
38 * @set: assigns output value for signal "offset" 50 * @set: assigns output value for signal "offset"
39 * @set_multiple: assigns output values for multiple signals defined by "mask" 51 * @set_multiple: assigns output values for multiple signals defined by "mask"
40 * @set_debounce: optional hook for setting debounce time for specified gpio in 52 * @set_debounce: optional hook for setting debounce time for specified gpio in
41 * interrupt triggered gpio chips 53 * interrupt triggered gpio chips
54 * @set_single_ended: optional hook for setting a line as open drain, open
55 * source, or non-single ended (restore from open drain/source to normal
56 * push-pull mode) this should be implemented if the hardware supports
57 * open drain or open source settings. The GPIOlib will otherwise try
58 * to emulate open drain/source by not actively driving lines high/low
59 * if a consumer request this. The driver may return -ENOTSUPP if e.g.
60 * it supports just open drain but not open source and is called
61 * with LINE_MODE_OPEN_SOURCE as mode argument.
42 * @to_irq: optional hook supporting non-static gpio_to_irq() mappings; 62 * @to_irq: optional hook supporting non-static gpio_to_irq() mappings;
43 * implementation may not sleep 63 * implementation may not sleep
44 * @dbg_show: optional routine to show contents in debugfs; default code 64 * @dbg_show: optional routine to show contents in debugfs; default code
@@ -130,6 +150,9 @@ struct gpio_chip {
130 int (*set_debounce)(struct gpio_chip *chip, 150 int (*set_debounce)(struct gpio_chip *chip,
131 unsigned offset, 151 unsigned offset,
132 unsigned debounce); 152 unsigned debounce);
153 int (*set_single_ended)(struct gpio_chip *chip,
154 unsigned offset,
155 enum single_ended_mode mode);
133 156
134 int (*to_irq)(struct gpio_chip *chip, 157 int (*to_irq)(struct gpio_chip *chip,
135 unsigned offset); 158 unsigned offset);