Message ID | 20191104001819.2300-3-chris.packham@alliedtelesis.co.nz (mailing list archive) |
---|---|
State | Mainlined |
Commit | 574dce894bbe97bffb9bffb14973ed3d44e446fc |
Headers | show |
Series | pinctrl: bcm: nsp: gpio improvements | expand |
On Mon, Nov 4, 2019 at 1:18 AM Chris Packham <chris.packham@alliedtelesis.co.nz> wrote: > The get_direction api is strongly recommended to be implemented. In fact > if it is not implemented gpio-hogs will not get the correct direction. > Add an implementation of get_direction for the nsp-gpio driver. > > Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> > Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> > --- > > Notes: > Changes in v3: > - add revew from Florian > Changes in v2: > - New Patch applied. Yours, Linus Walleij
On Mon, Nov 4, 2019 at 1:18 AM Chris Packham <chris.packham@alliedtelesis.co.nz> wrote: > The get_direction api is strongly recommended to be implemented. In fact > if it is not implemented gpio-hogs will not get the correct direction. > Add an implementation of get_direction for the nsp-gpio driver. > > Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> > Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> BTW I think it looks like this the GPIO part of this driver can be converted to use GPIO_GENERIC. Compare to other drivers such as drivers/gpio/gpio-ftgpio010.c. It's a fun way to cut down lines if you have time to check and test! Yours, Linus Walleij
On Mon, 2019-11-04 at 16:24 +0100, Linus Walleij wrote: > On Mon, Nov 4, 2019 at 1:18 AM Chris Packham > <chris.packham@alliedtelesis.co.nz> wrote: > > > The get_direction api is strongly recommended to be implemented. In fact > > if it is not implemented gpio-hogs will not get the correct direction. > > Add an implementation of get_direction for the nsp-gpio driver. > > > > Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> > > Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> > > BTW I think it looks like this the GPIO part of this driver can be > converted to use GPIO_GENERIC. Compare to other > drivers such as drivers/gpio/gpio-ftgpio010.c. > > It's a fun way to cut down lines if you have time to check > and test! > I'll see if I can fit it in. Got another problem I'm chasing on the same platform.
diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c index 45ae29b22548..bed0124388c0 100644 --- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c +++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c @@ -297,6 +297,19 @@ static int nsp_gpio_direction_output(struct gpio_chip *gc, unsigned gpio, return 0; } +static int nsp_gpio_get_direction(struct gpio_chip *gc, unsigned gpio) +{ + struct nsp_gpio *chip = gpiochip_get_data(gc); + unsigned long flags; + int val; + + raw_spin_lock_irqsave(&chip->lock, flags); + val = nsp_get_bit(chip, REG, NSP_GPIO_OUT_EN, gpio); + raw_spin_unlock_irqrestore(&chip->lock, flags); + + return !val; +} + static void nsp_gpio_set(struct gpio_chip *gc, unsigned gpio, int val) { struct nsp_gpio *chip = gpiochip_get_data(gc); @@ -641,6 +654,7 @@ static int nsp_gpio_probe(struct platform_device *pdev) gc->free = gpiochip_generic_free; gc->direction_input = nsp_gpio_direction_input; gc->direction_output = nsp_gpio_direction_output; + gc->get_direction = nsp_gpio_get_direction; gc->set = nsp_gpio_set; gc->get = nsp_gpio_get;