Message ID | 1462091530-27288-1-git-send-email-linus.walleij@linaro.org |
---|---|
State | New |
Headers | show |
On Sun, May 1, 2016 at 1:32 AM, Linus Walleij <linus.walleij@linaro.org> wrote: > This implements the .get_direction() callback for the xgene GPIO > controller. Thanks, Linus. I tested your patch with sysfs interface and it works great. Please feel free to add: Tested-by: Duc Dang <dhdang@apm.com> Regards, Duc Dang. > > Cc: Duc Dang <dhdang@apm.com> > Cc: Feng Kan <fkan@apm.com> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > drivers/gpio/gpio-xgene.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c > index 46faecd1f580..dc85dcd47d19 100644 > --- a/drivers/gpio/gpio-xgene.c > +++ b/drivers/gpio/gpio-xgene.c > @@ -85,6 +85,17 @@ static void xgene_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) > spin_unlock_irqrestore(&chip->lock, flags); > } > > +static int xgene_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) > +{ > + struct xgene_gpio *chip = gpiochip_get_data(gc); > + unsigned long bank_offset, bit_offset; > + > + bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset); > + bit_offset = GPIO_BIT_OFFSET(offset); > + > + return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset)); > +} > + > static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset) > { > struct xgene_gpio *chip = gpiochip_get_data(gc); > @@ -184,6 +195,7 @@ static int xgene_gpio_probe(struct platform_device *pdev) > > spin_lock_init(&gpio->lock); > gpio->chip.parent = &pdev->dev; > + gpio->chip.get_direction = xgene_gpio_get_direction; > gpio->chip.direction_input = xgene_gpio_dir_in; > gpio->chip.direction_output = xgene_gpio_dir_out; > gpio->chip.get = xgene_gpio_get; > -- > 2.4.11 > -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c index 46faecd1f580..dc85dcd47d19 100644 --- a/drivers/gpio/gpio-xgene.c +++ b/drivers/gpio/gpio-xgene.c @@ -85,6 +85,17 @@ static void xgene_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) spin_unlock_irqrestore(&chip->lock, flags); } +static int xgene_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) +{ + struct xgene_gpio *chip = gpiochip_get_data(gc); + unsigned long bank_offset, bit_offset; + + bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset); + bit_offset = GPIO_BIT_OFFSET(offset); + + return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset)); +} + static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset) { struct xgene_gpio *chip = gpiochip_get_data(gc); @@ -184,6 +195,7 @@ static int xgene_gpio_probe(struct platform_device *pdev) spin_lock_init(&gpio->lock); gpio->chip.parent = &pdev->dev; + gpio->chip.get_direction = xgene_gpio_get_direction; gpio->chip.direction_input = xgene_gpio_dir_in; gpio->chip.direction_output = xgene_gpio_dir_out; gpio->chip.get = xgene_gpio_get;
This implements the .get_direction() callback for the xgene GPIO controller. Cc: Duc Dang <dhdang@apm.com> Cc: Feng Kan <fkan@apm.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- drivers/gpio/gpio-xgene.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)