diff options
author | Janusz Uzycki <j.uzycki@elproma.com.pl> | 2014-11-19 03:55:22 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-11-28 05:28:22 -0500 |
commit | c8aaa1bf068f76c84111671a7c13ad7b06b21997 (patch) | |
tree | ee05bf63d009085b8752a8c5ce350300e190219f | |
parent | fcb8bd47027a2a8dbf6a0212ae09fc86fbe71627 (diff) |
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 <j.uzycki@elproma.com.pl>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-mxs.c | 13 |
1 files changed, 13 insertions, 0 deletions
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) | |||
227 | return irq_find_mapping(port->domain, offset); | 227 | return irq_find_mapping(port->domain, offset); |
228 | } | 228 | } |
229 | 229 | ||
230 | static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset) | ||
231 | { | ||
232 | struct bgpio_chip *bgc = to_bgpio_chip(gc); | ||
233 | struct mxs_gpio_port *port = | ||
234 | container_of(bgc, struct mxs_gpio_port, bgc); | ||
235 | u32 mask = 1 << offset; | ||
236 | u32 dir; | ||
237 | |||
238 | dir = readl(port->base + PINCTRL_DOE(port)); | ||
239 | return !(dir & mask); | ||
240 | } | ||
241 | |||
230 | static struct platform_device_id mxs_gpio_ids[] = { | 242 | static struct platform_device_id mxs_gpio_ids[] = { |
231 | { | 243 | { |
232 | .name = "imx23-gpio", | 244 | .name = "imx23-gpio", |
@@ -320,6 +332,7 @@ static int mxs_gpio_probe(struct platform_device *pdev) | |||
320 | goto out_irqdesc_free; | 332 | goto out_irqdesc_free; |
321 | 333 | ||
322 | port->bgc.gc.to_irq = mxs_gpio_to_irq; | 334 | port->bgc.gc.to_irq = mxs_gpio_to_irq; |
335 | port->bgc.gc.get_direction = mxs_gpio_get_direction; | ||
323 | port->bgc.gc.base = port->id * 32; | 336 | port->bgc.gc.base = port->id * 32; |
324 | 337 | ||
325 | err = gpiochip_add(&port->bgc.gc); | 338 | err = gpiochip_add(&port->bgc.gc); |