mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Gardner <gardner.ben@gmail.com>
To: Andres Salomon <dilinger@collabora.co.uk>
Cc: linux-kernel@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] OLPC: ALSA: fix cs5535audio's MIC GPIO to enable input
Date: Fri, 26 Feb 2010 11:47:35 -0600	[thread overview]
Message-ID: <808c8e9d1002260947k281782al889db51e20073648@mail.gmail.com> (raw)
In-Reply-To: <20100224184505.1d8d3380@droptest.queued.net>

Hi Andres,

> Previously the MIC GPIO was set to output mode, and when checking the status
> after setting it we were checking OUTPUT_VAL.  This worked, though I'm not
> quite sure why. Instead, if we actually check the READ_BACK value, it
> doesn't work unless the GPIO is in bidirectional mode.  Thus, enable
> input mode as well.

The cs5535-gpio driver was reading output value, not the sensed input value.
When that was fixed, this OLPC code failed because the input wasn't
enabled, so the gpio_get_value() call didn't return anything useful.
At reset the CS5535/6 GPIOs have both input and output disabled.

> Signed-off-by: Andres Salomon <dilinger@collabora.co.uk>
> ---
>  sound/pci/cs5535audio/cs5535audio_olpc.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c
> index 50da49b..f5574f2 100644
> --- a/sound/pci/cs5535audio/cs5535audio_olpc.c
> +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c
> @@ -157,6 +157,7 @@ int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
>                return -EIO;
>        }
>        gpio_direction_output(OLPC_GPIO_MIC_AC, 0);
> +       gpio_direction_input(OLPC_GPIO_MIC_AC);
>
>        /* drop the original AD1888 HPF control */
>        memset(&elem, 0, sizeof(elem));

This will only work because the cs5535-gpio driver and gpiolib are
both 'broken'.

The problem with gpiolib is that it only allows a GPIO pin to be
either an input or output, but not both.
It has two separate functions to configure the direction
(gpio_direction_input/gpio_direction_output), where one should do (ie,
gpio_set_direction).
>From what I can tell, when direction_input() is called, the GPIO chip
is expected to disable the output and enable the input. If that really
occurred, then the above code would still be broken.

The cs5535-gpio driver doesn't follow that input-or-output convention.
It never disables the direction that wasn't requested.

I'm working on a gpiolib patch that will combine gpio_direction_output
and gpio_direction_input into one function.  That would enable the
above driver to be 'obviously correct'.

Ben

  reply	other threads:[~2010-02-26 17:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-23 22:55 [PATCH] cs5535_gpio: gpio_chip.get should return the input value Ben Gardner
2010-02-24 22:58 ` Andrew Morton
2010-02-25  3:52   ` Ben Gardner
2010-02-25  4:05     ` Andrew Morton
2010-02-25  4:16       ` Ben Gardner
2010-02-25  5:04         ` Andres Salomon
2010-02-24 23:42 ` Andres Salomon
2010-02-24 23:45 ` [PATCH] OLPC: ALSA: fix cs5535audio's MIC GPIO to enable input Andres Salomon
2010-02-26 17:47   ` Ben Gardner [this message]
2010-02-26 21:07     ` Andres Salomon
2010-02-26 23:32       ` Ben Gardner
2010-03-01 14:55         ` Ben Gardner
2010-03-01 15:17           ` Andres Salomon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=808c8e9d1002260947k281782al889db51e20073648@mail.gmail.com \
    --to=gardner.ben@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dilinger@collabora.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®