aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/gpio
diff options
context:
space:
mode:
authorRojhalat Ibrahim <imr@rtschenk.de>2014-11-04 11:12:06 -0500
committerLinus Walleij <linus.walleij@linaro.org>2014-11-27 09:01:18 -0500
commit5f42424354f5b0ca5413b4fb8528d150692c85b7 (patch)
tree23ba183fa9976595adda4bceb006842a15eb3e19 /Documentation/gpio
parentb5b7b487431b01619f2947d91dadd7c7a233692e (diff)
gpiolib: allow simultaneous setting of multiple GPIO outputs
Introduce new functions gpiod_set_array & gpiod_set_raw_array to the consumer interface which allow setting multiple outputs with just one function call. Also add an optional set_multiple function to the driver interface. Without an implementation of that function in the chip driver outputs are set sequentially. Implementing the set_multiple function in a chip driver allows for: - Improved performance for certain use cases. The original motivation for this was the task of configuring an FPGA. In that specific case, where 9 GPIO lines have to be set many times, configuration time goes down from 48 s to 20 s when using the new function. - Simultaneous glitch-free setting of multiple pins on any kind of parallel bus attached to GPIOs provided they all reside on the same chip and bank. Limitations: Performance is only improved for normal high-low outputs. Open drain and open source outputs are always set separately from each other. Those kinds of outputs could probably be accelerated in a similar way if we could forgo the error checking when setting GPIO directions. Change log: v6: - rebase on current linux-gpio devel branch v5: - check can_sleep property per chip - remove superfluous checks - supplement documentation v4: - add gpiod_set_array function for setting logical values - change interface of the set_multiple driver function to use unsigned long as type for the bit fields - use generic bitops (which also use unsigned long for bit fields) - do not use ARCH_NR_GPIOS any more v3: - add documentation - change commit message v2: - use descriptor interface - allow arbitrary groups of GPIOs spanning multiple chips Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Mark Brown <broonie@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'Documentation/gpio')
-rw-r--r--Documentation/gpio/consumer.txt27
1 files changed, 27 insertions, 0 deletions
diff --git a/Documentation/gpio/consumer.txt b/Documentation/gpio/consumer.txt
index 6ce544191ca6..c67f806401a5 100644
--- a/Documentation/gpio/consumer.txt
+++ b/Documentation/gpio/consumer.txt
@@ -199,6 +199,33 @@ The active-low state of a GPIO can also be queried using the following call:
199Note that these functions should only be used with great moderation ; a driver 199Note that these functions should only be used with great moderation ; a driver
200should not have to care about the physical line level. 200should not have to care about the physical line level.
201 201
202
203Set multiple GPIO outputs with a single function call
204-----------------------------------------------------
205The following functions set the output values of an array of GPIOs:
206
207 void gpiod_set_array(unsigned int array_size,
208 struct gpio_desc **desc_array,
209 int *value_array)
210 void gpiod_set_raw_array(unsigned int array_size,
211 struct gpio_desc **desc_array,
212 int *value_array)
213 void gpiod_set_array_cansleep(unsigned int array_size,
214 struct gpio_desc **desc_array,
215 int *value_array)
216 void gpiod_set_raw_array_cansleep(unsigned int array_size,
217 struct gpio_desc **desc_array,
218 int *value_array)
219
220The array can be an arbitrary set of GPIOs. The functions will try to set
221GPIOs belonging to the same bank or chip simultaneously if supported by the
222corresponding chip driver. In that case a significantly improved performance
223can be expected. If simultaneous setting is not possible the GPIOs will be set
224sequentially.
225Note that for optimal performance GPIOs belonging to the same chip should be
226contiguous within the array of descriptors.
227
228
202GPIOs mapped to IRQs 229GPIOs mapped to IRQs
203-------------------- 230--------------------
204GPIO lines can quite often be used as IRQs. You can get the IRQ number 231GPIO lines can quite often be used as IRQs. You can get the IRQ number