[U-Boot] [PATCH RFT] gpio: vybrid: Fix up setting output value in vybrid_gpio_direction_output

Bhuvanchandra DV bhuvanchandra.dv at toradex.com
Tue Jun 9 14:58:23 CEST 2015


Hello Axel,

On 06/09/2015 02:45 PM, Axel Lin wrote:
> Pass correct gpio argument to gpio_set_value().
> The calcualation of gpio = gpio + (gpios->chip * VYBRID_GPIO_COUNT);
> is required for calling imx_iomux_gpio_* functions so move them close to
> improve readability.
>
> Signed-off-by: Axel Lin <axel.lin at ingics.com>
> ---
> Hi Bhuvanchandra,
> I think current code does not pass correct gpio argument to gpio_set_value()
> in vybrid_gpio_direction_output(). It only works if gpios->chip is 0.
> I don't have the h/w to test, can you double check this?
gpio_set_value() needs the actual gpio number to be passed not the gpio 
offset of gpio chip.

The calculation is for getting the actual gpio number from gpio offset, 
which we will need for both imx_iomux_gpio* and gpio_*_* functions.

Tested on Colibri VF50 and VF61 modules.
> Thanks,
> Axel
>   drivers/gpio/vybrid_gpio.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/vybrid_gpio.c b/drivers/gpio/vybrid_gpio.c
> index 6eaf0a9..33bbf54 100644
> --- a/drivers/gpio/vybrid_gpio.c
> +++ b/drivers/gpio/vybrid_gpio.c
> @@ -36,8 +36,9 @@ static int vybrid_gpio_direction_output(struct udevice *dev, unsigned gpio,
>   {
>   	const struct vybrid_gpios *gpios = dev_get_priv(dev);
>
> -	gpio = gpio + (gpios->chip * VYBRID_GPIO_COUNT);
>   	gpio_set_value(gpio, value);
> +
> +	gpio = gpio + (gpios->chip * VYBRID_GPIO_COUNT);
>   	imx_iomux_gpio_set_direction(gpio, VF610_GPIO_DIRECTION_OUT);
>
>   	return 0;
> @@ -54,6 +55,7 @@ static int vybrid_gpio_set_value(struct udevice *dev, unsigned gpio,
>   				  int value)
>   {
>   	const struct vybrid_gpios *gpios = dev_get_priv(dev);
> +
>   	if (value)
>   		writel((1 << gpio), &gpios->reg->gpio_psor);
>   	else
> @@ -68,7 +70,6 @@ static int vybrid_gpio_get_function(struct udevice *dev, unsigned gpio)
>   	u32 g_state = 0;
>
>   	gpio = gpio + (gpios->chip * VYBRID_GPIO_COUNT);
> -
>   	imx_iomux_gpio_get_function(gpio, &g_state);
>
>   	if (((g_state & (0x07 << PAD_MUX_MODE_SHIFT)) >> PAD_MUX_MODE_SHIFT) > 0)
>

Best regards,
Bhuvan


More information about the U-Boot mailing list