Skip to content

Commit

Permalink
pinctrl: lynxpoint: Implement intel_gpio_get_direction callback
Browse files Browse the repository at this point in the history
Allows querying GPIO direction from the pad config register.
If the pad is not in GPIO mode, return an error.

Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Acked-by: Mika Westerberg <[email protected]>
  • Loading branch information
andy-shev committed Dec 13, 2019
1 parent 5931e6e commit 54d371c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/pinctrl/intel/pinctrl-lynxpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ static int lp_gpio_direction_output(struct gpio_chip *chip, unsigned int offset,
return 0;
}

static int lp_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
{
void __iomem *reg = lp_gpio_reg(chip, offset, LP_CONFIG1);

if (ioread32(reg) & DIR_BIT)
return GPIO_LINE_DIRECTION_IN;

return GPIO_LINE_DIRECTION_OUT;
}

static void lp_gpio_irq_handler(struct irq_desc *desc)
{
struct irq_data *data = irq_desc_get_irq_data(desc);
Expand Down Expand Up @@ -391,6 +401,7 @@ static int lp_gpio_probe(struct platform_device *pdev)
gc->direction_output = lp_gpio_direction_output;
gc->get = lp_gpio_get;
gc->set = lp_gpio_set;
gc->get_direction = lp_gpio_get_direction;
gc->base = -1;
gc->ngpio = LP_NUM_GPIO;
gc->can_sleep = false;
Expand Down

0 comments on commit 54d371c

Please sign in to comment.