Skip to content

Commit

Permalink
gpio: mxs: implement get_direction callback
Browse files Browse the repository at this point in the history
gpiolib's gpiod_get_direction() function returns the EINVAL error
if .get_direction callback is not defined.
The patch implements the callback for mxs chip which is useful
for debugging.

Inspired by arch/arm/mach-at91/gpio.c

On the moment the patch is required to get the patch
"serial: mxs-auart: enable PPS support" working.
It is planned to introduce new mctrl_gpio helpers to avoid
gpiod_get_direction() function.

Signed-off-by: Janusz Uzycki <j.uzycki@elproma.com.pl>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Janusz Uzycki authored and Linus Walleij committed Nov 28, 2014
1 parent fcb8bd4 commit c8aaa1b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/gpio/gpio-mxs.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,18 @@ static int mxs_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
return irq_find_mapping(port->domain, offset);
}

static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
{
struct bgpio_chip *bgc = to_bgpio_chip(gc);
struct mxs_gpio_port *port =
container_of(bgc, struct mxs_gpio_port, bgc);
u32 mask = 1 << offset;
u32 dir;

dir = readl(port->base + PINCTRL_DOE(port));
return !(dir & mask);
}

static struct platform_device_id mxs_gpio_ids[] = {
{
.name = "imx23-gpio",
Expand Down Expand Up @@ -320,6 +332,7 @@ static int mxs_gpio_probe(struct platform_device *pdev)
goto out_irqdesc_free;

port->bgc.gc.to_irq = mxs_gpio_to_irq;
port->bgc.gc.get_direction = mxs_gpio_get_direction;
port->bgc.gc.base = port->id * 32;

err = gpiochip_add(&port->bgc.gc);
Expand Down

0 comments on commit c8aaa1b

Please sign in to comment.