0022-PINCTRL-add-gpio_irq-support.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From ea78e25b769740a801e259f4f6cb93fa92faa244 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <[email protected]>
  3. Date: Sat, 29 Jun 2013 19:32:08 +0200
  4. Subject: [PATCH 22/22] PINCTRL: add gpio_irq support
  5. ---
  6. drivers/pinctrl/pinctrl-xway.c | 28 ++++++++++++++++++++++++++--
  7. 1 file changed, 26 insertions(+), 2 deletions(-)
  8. --- a/drivers/pinctrl/pinctrl-xway.c
  9. +++ b/drivers/pinctrl/pinctrl-xway.c
  10. @@ -564,10 +564,9 @@ static struct pinctrl_desc xway_pctrl_de
  11. .confops = &xway_pinconf_ops,
  12. };
  13. -static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
  14. +static int mux_apply(struct ltq_pinmux_info *info,
  15. int pin, int mux)
  16. {
  17. - struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
  18. int port = PORT(pin);
  19. u32 alt1_reg = GPIO_ALT1(pin);
  20. @@ -587,6 +586,14 @@ static inline int xway_mux_apply(struct
  21. return 0;
  22. }
  23. +static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
  24. + int pin, int mux)
  25. +{
  26. + struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
  27. +
  28. + return mux_apply(info, pin, mux);
  29. +}
  30. +
  31. static const struct ltq_cfg_param xway_cfg_params[] = {
  32. {"lantiq,pull", LTQ_PINCONF_PARAM_PULL},
  33. {"lantiq,open-drain", LTQ_PINCONF_PARAM_OPEN_DRAIN},
  34. @@ -631,6 +638,10 @@ static int xway_gpio_dir_out(struct gpio
  35. {
  36. struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
  37. + if (PORT(pin) == PORT3)
  38. + gpio_setbit(info->membase[0], GPIO3_OD, PORT_PIN(pin));
  39. + else
  40. + gpio_setbit(info->membase[0], GPIO_OD(pin), PORT_PIN(pin));
  41. gpio_setbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin));
  42. xway_gpio_set(chip, pin, val);
  43. @@ -651,6 +662,18 @@ static void xway_gpio_free(struct gpio_c
  44. pinctrl_free_gpio(gpio);
  45. }
  46. +static int xway_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
  47. +{
  48. + struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
  49. + int i;
  50. +
  51. + for (i = 0; i < info->num_exin; i++)
  52. + if (info->exin[i] == offset)
  53. + return ltq_eiu_get_irq(i);
  54. +
  55. + return -1;
  56. +}
  57. +
  58. static struct gpio_chip xway_chip = {
  59. .label = "gpio-xway",
  60. .direction_input = xway_gpio_dir_in,
  61. @@ -659,6 +682,7 @@ static struct gpio_chip xway_chip = {
  62. .set = xway_gpio_set,
  63. .request = xway_gpio_req,
  64. .free = xway_gpio_free,
  65. + .to_irq = xway_gpio_to_irq,
  66. .base = -1,
  67. };