From c8aaa1bf068f76c84111671a7c13ad7b06b21997 Mon Sep 17 00:00:00 2001 From: Janusz Uzycki Date: Wed, 19 Nov 2014 09:55:22 +0100 Subject: gpio: mxs: implement get_direction callback 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 Acked-by: Alexandre Courbot Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mxs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers/gpio/gpio-mxs.c') diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c index 8ffdd7d2bade..56052c285714 100644 --- a/drivers/gpio/gpio-mxs.c +++ b/drivers/gpio/gpio-mxs.c @@ -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", @@ -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); -- cgit v1.2.3