summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/stm32
diff options
context:
space:
mode:
authorAlexandre TORGUE <alexandre.torgue@st.com>2017-05-29 12:17:32 -0400
committerLinus Walleij <linus.walleij@linaro.org>2017-05-30 20:05:49 -0400
commitacaa037970f610dcd643cc80b3245b683f66d0bc (patch)
tree930347281c81486b20db7b969222e52aab55ca6a /drivers/pinctrl/stm32
parent9efa6d1a1eaa1ef392dec8fa68a5de8258dd8e5d (diff)
pinctrl: stm32: Implement .get_direction gpio_chip callback
Add .get_direction() gpiochip callback in STM32 pinctrl driver. Signed-off-by: Alexandre TORGUE <alexandre.torgue@st.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/stm32')
-rw-r--r--drivers/pinctrl/stm32/pinctrl-stm32.c23
-rw-r--r--drivers/pinctrl/stm32/pinctrl-stm32.h5
2 files changed, 25 insertions, 3 deletions
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index 5a15c7deea78..814f76c371c8 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -209,6 +209,24 @@ static int stm32_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
209 return irq_create_fwspec_mapping(&fwspec); 209 return irq_create_fwspec_mapping(&fwspec);
210} 210}
211 211
212static int stm32_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
213{
214 struct stm32_gpio_bank *bank = gpiochip_get_data(chip);
215 int pin = stm32_gpio_pin(offset);
216 int ret;
217 u32 mode, alt;
218
219 stm32_pmx_get_mode(bank, pin, &mode, &alt);
220 if ((alt == 0) && (mode == 0))
221 ret = 1;
222 else if ((alt == 0) && (mode == 1))
223 ret = 0;
224 else
225 ret = -EINVAL;
226
227 return ret;
228}
229
212static const struct gpio_chip stm32_gpio_template = { 230static const struct gpio_chip stm32_gpio_template = {
213 .request = stm32_gpio_request, 231 .request = stm32_gpio_request,
214 .free = stm32_gpio_free, 232 .free = stm32_gpio_free,
@@ -217,6 +235,7 @@ static const struct gpio_chip stm32_gpio_template = {
217 .direction_input = stm32_gpio_direction_input, 235 .direction_input = stm32_gpio_direction_input,
218 .direction_output = stm32_gpio_direction_output, 236 .direction_output = stm32_gpio_direction_output,
219 .to_irq = stm32_gpio_to_irq, 237 .to_irq = stm32_gpio_to_irq,
238 .get_direction = stm32_gpio_get_direction,
220}; 239};
221 240
222static int stm32_gpio_irq_request_resources(struct irq_data *irq_data) 241static int stm32_gpio_irq_request_resources(struct irq_data *irq_data)
@@ -577,8 +596,8 @@ static void stm32_pmx_set_mode(struct stm32_gpio_bank *bank,
577 clk_disable(bank->clk); 596 clk_disable(bank->clk);
578} 597}
579 598
580static void stm32_pmx_get_mode(struct stm32_gpio_bank *bank, 599void stm32_pmx_get_mode(struct stm32_gpio_bank *bank, int pin, u32 *mode,
581 int pin, u32 *mode, u32 *alt) 600 u32 *alt)
582{ 601{
583 u32 val; 602 u32 val;
584 int alt_shift = (pin % 8) * 4; 603 int alt_shift = (pin % 8) * 4;
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.h b/drivers/pinctrl/stm32/pinctrl-stm32.h
index 35ebc94c01e4..8702a9992ce5 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.h
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.h
@@ -45,7 +45,10 @@ struct stm32_pinctrl_match_data {
45 const unsigned int npins; 45 const unsigned int npins;
46}; 46};
47 47
48int stm32_pctl_probe(struct platform_device *pdev); 48struct stm32_gpio_bank;
49 49
50int stm32_pctl_probe(struct platform_device *pdev);
51void stm32_pmx_get_mode(struct stm32_gpio_bank *bank,
52 int pin, u32 *mode, u32 *alt);
50#endif /* __PINCTRL_STM32_H */ 53#endif /* __PINCTRL_STM32_H */
51 54