Skip to content

Commit c8aaa1b

Browse files
juzycki-elpromalinusw
authored andcommitted
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>
1 parent fcb8bd4 commit c8aaa1b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/gpio/gpio-mxs.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,18 @@ static int mxs_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
227227
return irq_find_mapping(port->domain, offset);
228228
}
229229

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+
230242
static struct platform_device_id mxs_gpio_ids[] = {
231243
{
232244
.name = "imx23-gpio",
@@ -320,6 +332,7 @@ static int mxs_gpio_probe(struct platform_device *pdev)
320332
goto out_irqdesc_free;
321333

322334
port->bgc.gc.to_irq = mxs_gpio_to_irq;
335+
port->bgc.gc.get_direction = mxs_gpio_get_direction;
323336
port->bgc.gc.base = port->id * 32;
324337

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

0 commit comments

Comments
 (0)