Skip to content

gpio: add gpio_set_direction

Ben Gardner lkml 1 version NAK

Status from this message: NAK.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 13 repliesNAK

Patches in v1

#Subject and filesSizeRepliesApplied
1/3gpiolib: add gpio_set_direction()drivers/gpio/gpiolib.c include/asm-generic/gpio.h include/linux/gpio.h+73 -6114 replies
2/3cs5535-gpio: Use set_directiondrivers/gpio/cs5535-gpio.c+15 -192 replies
3/3OLPC: ALSA: fix cs5535audio's MIC GPIO to enable inputsound/pci/cs5535audio/cs5535audio_olpc.c+1 -11 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] gpio: add gpio_set_direction

The OLPC uses a GPIO output to enable/disable the MIC input. The code uses gpio_get_value() to retrive the current MIC enabled status. Due to a recent fix to cs5535-gpio, that function returns the input value. Since the input is not enabled, the input value does not match the output. gpiolib doesn't currently have the ability to enable both input and output. Nor does gpiolib have the ability to retrieve the current output value.

There are several ways to fix this MIC problem.
1) keep track of the output value in the audio driver and do not use gpio_get_value().

2) add a new gpiolib function to retrieve the output value.

3) add a way to set the GPIO bidirectional, so the read retrieves the real value that the MIC circuitry would see.

Since the CS5535 GPIO pins has independant control of the input and output, I went with the last option.

This patchset merges the gpio_direction_input() and gpio_direction_output() function into gpio_set_direction().
The direction parameter is a bit field, so the direction can be one of none, in, out, inout.
The cs5535-gpio driver is updated to support set_direction() and cs5535audio_olpc is updated to set the GPIO in bidirectional mode.

Ben Gardner (3):
gpiolib: add gpio_set_direction()
cs5535-gpio: Use set_direction
OLPC: ALSA: fix cs5535audio's MIC GPIO to enable input

 drivers/gpio/cs5535-gpio.c               |   34 ++++-----
 drivers/gpio/gpiolib.c                   |  123 +++++++++++++++---------------
 include/asm-generic/gpio.h               |    6 ++
 include/linux/gpio.h                     |    5 +
 sound/pci/cs5535audio/cs5535audio_olpc.c |    2 +-
 5 files changed, 89 insertions(+), 81 deletions(-)