[alsa-devel] [PATCH v2 1/4] ASoC: WM8903: Expose GPIOs through gpiolib

Mark Brown broonie at opensource.wolfsonmicro.com
Thu Jan 20 12:53:17 CET 2011


On Wed, Jan 19, 2011 at 01:50:02PM -0700, Stephen Warren wrote:

This looks good, one query and one minor omission though.

>  /* Used to enable configuration of a GPIO to all zeros */
> -#define WM8903_GPIO_NO_CONFIG 0x8000
> +#define WM8903_GPIO_NO_CONFIG 0x10000

Why this change?  The top bit in the registers is never actually used,
really they're all 15 bit.

> +static int wm8903_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
> +{
> +	struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
> +	struct snd_soc_codec *codec = wm8903->codec;
> +
> +	return snd_soc_update_bits(codec, WM8903_GPIO_CONTROL_1 + offset,
> +				   WM8903_GP1_DIR_MASK, WM8903_GP1_DIR);
> +}

> +static int wm8903_gpio_direction_out(struct gpio_chip *chip,
> +				     unsigned offset, int value)
> +{
> +	struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
> +	struct snd_soc_codec *codec = wm8903->codec;
> +
> +	return snd_soc_update_bits(codec, WM8903_GPIO_CONTROL_1 + offset,
> +				   WM8903_GP1_DIR_MASK | WM8903_GP1_LVL_MASK,
> +				   value << WM8903_GP2_LVL_SHIFT);
> +}

These should also set GPn_FN - to zero for GPIO output, 3 for GPIO
input.  Otherwise changing between input and output mode at runtime
won't do the right thing.  As a side effect of that you probably
wouldn't need to specify the GPIO configuration in platform data.


More information about the Alsa-devel mailing list