Re: gpio: rdc321x: Question about rdc_gpio_direction_input implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Axel,

2014-04-10 20:28 GMT-07:00 Axel Lin <axel.lin@xxxxxxxxxx>:
> Hi Florian,
> Current implementation in rdc_gpio_direction_input() looks wrong to me
> because calling rdc_gpio_config(chip, gpio, 1) actually set the gpio to
> OUTPUT HIGH rather than set the direction to INPUT.
>
> I cannot find the datasheet, I'm wondering if below diff works.
> Any chance to test it? I can send a formal patch if it works.

The datasheet is available here:
http://www.atekmicro.com/download/r8610/R8610-G.pdf

I do not have access to the hardware at this very moment, but I should
be able to give this a try. I do not think GPIO input was tested at
all, the GPIO LEDs and such were driven as active outputs.

>
> diff --git a/drivers/gpio/gpio-rdc321x.c b/drivers/gpio/gpio-rdc321x.c
> index 88577c3..ccef383 100644
> --- a/drivers/gpio/gpio-rdc321x.c
> +++ b/drivers/gpio/gpio-rdc321x.c
> @@ -119,10 +119,29 @@ unlock:
>         return err;
>  }
>
> -/* configure GPIO pin as input */
>  static int rdc_gpio_direction_input(struct gpio_chip *chip, unsigned
> gpio)
>  {
> -       return rdc_gpio_config(chip, gpio, 1);
> +       struct rdc321x_gpio *gpch;
> +       int reg, err;
> +       u32 val;
> +
> +       gpch = container_of(chip, struct rdc321x_gpio, chip);
> +       reg = gpio < 32 ? gpch->reg1_ctrl_base : gpch->reg2_ctrl_base;
> +
> +       spin_lock(&gpch->lock);
> +
> +       err = pci_read_config_dword(gpch->sb_pdev, reg, &val);
> +       if (err)
> +               goto unlock;
> +
> +       val &= ~(1 << (gpio & 0x1f));
> +
> +       err = pci_write_config_dword(gpch->sb_pdev, reg, val);
> +
> +unlock:
> +       spin_unlock(&gpch->lock);
> +
> +       return err;
>  }
>
>  /*

-- 
Florian
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux