pinctrl-sun6i-a31-r.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Allwinner A31 SoCs special pins pinctrl driver.
  3. *
  4. * Copyright (C) 2014 Boris Brezillon
  5. * Boris Brezillon <boris.brezillon@free-electrons.com>
  6. *
  7. * Copyright (C) 2014 Maxime Ripard
  8. * Maxime Ripard <maxime.ripard@free-electrons.com>
  9. *
  10. * This file is licensed under the terms of the GNU General Public
  11. * License version 2. This program is licensed "as is" without any
  12. * warranty of any kind, whether express or implied.
  13. */
  14. #include <linux/module.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/of.h>
  17. #include <linux/of_device.h>
  18. #include <linux/pinctrl/pinctrl.h>
  19. #include <linux/reset.h>
  20. #include "pinctrl-sunxi.h"
  21. static const struct sunxi_desc_pin sun6i_a31_r_pins[] = {
  22. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 0),
  23. SUNXI_FUNCTION(0x0, "gpio_in"),
  24. SUNXI_FUNCTION(0x1, "gpio_out"),
  25. SUNXI_FUNCTION(0x2, "s_twi"), /* SCK */
  26. SUNXI_FUNCTION(0x3, "s_p2wi")), /* SCK */
  27. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 1),
  28. SUNXI_FUNCTION(0x0, "gpio_in"),
  29. SUNXI_FUNCTION(0x1, "gpio_out"),
  30. SUNXI_FUNCTION(0x2, "s_twi"), /* SDA */
  31. SUNXI_FUNCTION(0x3, "s_p2wi")), /* SDA */
  32. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 2),
  33. SUNXI_FUNCTION(0x0, "gpio_in"),
  34. SUNXI_FUNCTION(0x1, "gpio_out"),
  35. SUNXI_FUNCTION(0x2, "s_uart")), /* TX */
  36. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 3),
  37. SUNXI_FUNCTION(0x0, "gpio_in"),
  38. SUNXI_FUNCTION(0x1, "gpio_out"),
  39. SUNXI_FUNCTION(0x2, "s_uart")), /* RX */
  40. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 4),
  41. SUNXI_FUNCTION(0x0, "gpio_in"),
  42. SUNXI_FUNCTION(0x1, "gpio_out"),
  43. SUNXI_FUNCTION(0x2, "s_ir")), /* RX */
  44. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 5),
  45. SUNXI_FUNCTION(0x0, "gpio_in"),
  46. SUNXI_FUNCTION(0x1, "gpio_out"),
  47. SUNXI_FUNCTION_IRQ_BANK(0x2, 0, 0), /* PL_EINT0 */
  48. SUNXI_FUNCTION(0x3, "s_jtag")), /* MS */
  49. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 6),
  50. SUNXI_FUNCTION(0x0, "gpio_in"),
  51. SUNXI_FUNCTION(0x1, "gpio_out"),
  52. SUNXI_FUNCTION_IRQ_BANK(0x2, 0, 1), /* PL_EINT1 */
  53. SUNXI_FUNCTION(0x3, "s_jtag")), /* CK */
  54. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 7),
  55. SUNXI_FUNCTION(0x0, "gpio_in"),
  56. SUNXI_FUNCTION(0x1, "gpio_out"),
  57. SUNXI_FUNCTION_IRQ_BANK(0x2, 0, 2), /* PL_EINT2 */
  58. SUNXI_FUNCTION(0x3, "s_jtag")), /* DO */
  59. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 8),
  60. SUNXI_FUNCTION(0x0, "gpio_in"),
  61. SUNXI_FUNCTION(0x1, "gpio_out"),
  62. SUNXI_FUNCTION_IRQ_BANK(0x2, 0, 3), /* PL_EINT3 */
  63. SUNXI_FUNCTION(0x3, "s_jtag")), /* DI */
  64. /* Hole */
  65. SUNXI_PIN(SUNXI_PINCTRL_PIN(M, 0),
  66. SUNXI_FUNCTION(0x0, "gpio_in"),
  67. SUNXI_FUNCTION(0x1, "gpio_out"),
  68. SUNXI_FUNCTION_IRQ_BANK(0x2, 1, 0)), /* PM_EINT0 */
  69. SUNXI_PIN(SUNXI_PINCTRL_PIN(M, 1),
  70. SUNXI_FUNCTION(0x0, "gpio_in"),
  71. SUNXI_FUNCTION(0x1, "gpio_out"),
  72. SUNXI_FUNCTION_IRQ_BANK(0x2, 1, 1)), /* PM_EINT1 */
  73. SUNXI_PIN(SUNXI_PINCTRL_PIN(M, 2),
  74. SUNXI_FUNCTION(0x0, "gpio_in"),
  75. SUNXI_FUNCTION(0x1, "gpio_out"),
  76. SUNXI_FUNCTION_IRQ_BANK(0x2, 1, 2), /* PM_EINT2 */
  77. SUNXI_FUNCTION(0x3, "1wire")),
  78. SUNXI_PIN(SUNXI_PINCTRL_PIN(M, 3),
  79. SUNXI_FUNCTION(0x0, "gpio_in"),
  80. SUNXI_FUNCTION(0x1, "gpio_out"),
  81. SUNXI_FUNCTION_IRQ_BANK(0x2, 1, 3)), /* PM_EINT3 */
  82. SUNXI_PIN(SUNXI_PINCTRL_PIN(M, 4),
  83. SUNXI_FUNCTION(0x0, "gpio_in"),
  84. SUNXI_FUNCTION(0x1, "gpio_out"),
  85. SUNXI_FUNCTION_IRQ_BANK(0x2, 1, 4)), /* PM_EINT4 */
  86. SUNXI_PIN(SUNXI_PINCTRL_PIN(M, 5),
  87. SUNXI_FUNCTION(0x0, "gpio_in"),
  88. SUNXI_FUNCTION(0x1, "gpio_out"),
  89. SUNXI_FUNCTION_IRQ_BANK(0x2, 1, 5)), /* PM_EINT5 */
  90. SUNXI_PIN(SUNXI_PINCTRL_PIN(M, 6),
  91. SUNXI_FUNCTION(0x0, "gpio_in"),
  92. SUNXI_FUNCTION(0x1, "gpio_out"),
  93. SUNXI_FUNCTION_IRQ_BANK(0x2, 1, 6)), /* PM_EINT6 */
  94. SUNXI_PIN(SUNXI_PINCTRL_PIN(M, 7),
  95. SUNXI_FUNCTION(0x0, "gpio_in"),
  96. SUNXI_FUNCTION(0x1, "gpio_out"),
  97. SUNXI_FUNCTION_IRQ_BANK(0x2, 1, 7), /* PM_EINT7 */
  98. SUNXI_FUNCTION(0x3, "rtc")), /* CLKO */
  99. };
  100. static const struct sunxi_pinctrl_desc sun6i_a31_r_pinctrl_data = {
  101. .pins = sun6i_a31_r_pins,
  102. .npins = ARRAY_SIZE(sun6i_a31_r_pins),
  103. .pin_base = PL_BASE,
  104. .irq_banks = 2,
  105. };
  106. static int sun6i_a31_r_pinctrl_probe(struct platform_device *pdev)
  107. {
  108. struct reset_control *rstc;
  109. int ret;
  110. rstc = devm_reset_control_get(&pdev->dev, NULL);
  111. if (IS_ERR(rstc)) {
  112. dev_err(&pdev->dev, "Reset controller missing\n");
  113. return PTR_ERR(rstc);
  114. }
  115. ret = reset_control_deassert(rstc);
  116. if (ret)
  117. return ret;
  118. ret = sunxi_pinctrl_init(pdev,
  119. &sun6i_a31_r_pinctrl_data);
  120. if (ret)
  121. reset_control_assert(rstc);
  122. return ret;
  123. }
  124. static const struct of_device_id sun6i_a31_r_pinctrl_match[] = {
  125. { .compatible = "allwinner,sun6i-a31-r-pinctrl", },
  126. {}
  127. };
  128. MODULE_DEVICE_TABLE(of, sun6i_a31_r_pinctrl_match);
  129. static struct platform_driver sun6i_a31_r_pinctrl_driver = {
  130. .probe = sun6i_a31_r_pinctrl_probe,
  131. .driver = {
  132. .name = "sun6i-a31-r-pinctrl",
  133. .of_match_table = sun6i_a31_r_pinctrl_match,
  134. },
  135. };
  136. module_platform_driver(sun6i_a31_r_pinctrl_driver);
  137. MODULE_AUTHOR("Boris Brezillon <boris.brezillon@free-electrons.com");
  138. MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com");
  139. MODULE_DESCRIPTION("Allwinner A31 R_PIO pinctrl driver");
  140. MODULE_LICENSE("GPL");