0012-pinctrl-lantiq-fix-up-pinmux.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From 25494c55a4007a1409f53ddbafd661636e47ea34 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Fri, 9 Aug 2013 20:38:15 +0200
  4. Subject: [PATCH 12/36] pinctrl/lantiq: fix up pinmux
  5. We found out how to set the gphy led pinmuxing.
  6. Signed-off-by: John Crispin <blogic@openwrt.org>
  7. ---
  8. drivers/pinctrl/pinctrl-xway.c | 28 ++++++++++++++++++++++++++--
  9. 1 file changed, 26 insertions(+), 2 deletions(-)
  10. --- a/drivers/pinctrl/pinctrl-xway.c
  11. +++ b/drivers/pinctrl/pinctrl-xway.c
  12. @@ -609,10 +609,9 @@ static struct pinctrl_desc xway_pctrl_de
  13. .confops = &xway_pinconf_ops,
  14. };
  15. -static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
  16. +static int mux_apply(struct ltq_pinmux_info *info,
  17. int pin, int mux)
  18. {
  19. - struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
  20. int port = PORT(pin);
  21. u32 alt1_reg = GPIO_ALT1(pin);
  22. @@ -632,6 +631,14 @@ static inline int xway_mux_apply(struct
  23. return 0;
  24. }
  25. +static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
  26. + int pin, int mux)
  27. +{
  28. + struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
  29. +
  30. + return mux_apply(info, pin, mux);
  31. +}
  32. +
  33. static const struct ltq_cfg_param xway_cfg_params[] = {
  34. {"lantiq,pull", LTQ_PINCONF_PARAM_PULL},
  35. {"lantiq,open-drain", LTQ_PINCONF_PARAM_OPEN_DRAIN},
  36. @@ -676,6 +683,10 @@ static int xway_gpio_dir_out(struct gpio
  37. {
  38. struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
  39. + if (PORT(pin) == PORT3)
  40. + gpio_setbit(info->membase[0], GPIO3_OD, PORT_PIN(pin));
  41. + else
  42. + gpio_setbit(info->membase[0], GPIO_OD(pin), PORT_PIN(pin));
  43. gpio_setbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin));
  44. xway_gpio_set(chip, pin, val);
  45. @@ -696,6 +707,18 @@ static void xway_gpio_free(struct gpio_c
  46. pinctrl_free_gpio(gpio);
  47. }
  48. +static int xway_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
  49. +{
  50. + struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
  51. + int i;
  52. +
  53. + for (i = 0; i < info->num_exin; i++)
  54. + if (info->exin[i] == offset)
  55. + return ltq_eiu_get_irq(i);
  56. +
  57. + return -1;
  58. +}
  59. +
  60. static struct gpio_chip xway_chip = {
  61. .label = "gpio-xway",
  62. .direction_input = xway_gpio_dir_in,
  63. @@ -704,6 +727,7 @@ static struct gpio_chip xway_chip = {
  64. .set = xway_gpio_set,
  65. .request = xway_gpio_req,
  66. .free = xway_gpio_free,
  67. + .to_irq = xway_gpio_to_irq,
  68. .base = -1,
  69. };