pinctrl-sun8i-h3-r.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Allwinner H3 SoCs pinctrl driver.
  3. *
  4. * Copyright (C) 2016 Krzysztof Adamski <k@japko.eu>
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/of.h>
  13. #include <linux/of_device.h>
  14. #include <linux/pinctrl/pinctrl.h>
  15. #include "pinctrl-sunxi.h"
  16. static const struct sunxi_desc_pin sun8i_h3_r_pins[] = {
  17. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 0),
  18. SUNXI_FUNCTION(0x0, "gpio_in"),
  19. SUNXI_FUNCTION(0x1, "gpio_out"),
  20. SUNXI_FUNCTION(0x2, "s_twi"), /* SCK */
  21. SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 0)), /* PL_EINT0 */
  22. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 1),
  23. SUNXI_FUNCTION(0x0, "gpio_in"),
  24. SUNXI_FUNCTION(0x1, "gpio_out"),
  25. SUNXI_FUNCTION(0x2, "s_twi"), /* SDA */
  26. SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 1)), /* PL_EINT1 */
  27. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 2),
  28. SUNXI_FUNCTION(0x0, "gpio_in"),
  29. SUNXI_FUNCTION(0x1, "gpio_out"),
  30. SUNXI_FUNCTION(0x2, "s_uart"), /* TX */
  31. SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 2)), /* PL_EINT2 */
  32. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 3),
  33. SUNXI_FUNCTION(0x0, "gpio_in"),
  34. SUNXI_FUNCTION(0x1, "gpio_out"),
  35. SUNXI_FUNCTION(0x2, "s_uart"), /* RX */
  36. SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 3)), /* PL_EINT3 */
  37. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 4),
  38. SUNXI_FUNCTION(0x0, "gpio_in"),
  39. SUNXI_FUNCTION(0x1, "gpio_out"),
  40. SUNXI_FUNCTION(0x2, "s_jtag"), /* MS */
  41. SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 4)), /* PL_EINT4 */
  42. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 5),
  43. SUNXI_FUNCTION(0x0, "gpio_in"),
  44. SUNXI_FUNCTION(0x1, "gpio_out"),
  45. SUNXI_FUNCTION(0x2, "s_jtag"), /* CK */
  46. SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 5)), /* PL_EINT5 */
  47. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 6),
  48. SUNXI_FUNCTION(0x0, "gpio_in"),
  49. SUNXI_FUNCTION(0x1, "gpio_out"),
  50. SUNXI_FUNCTION(0x2, "s_jtag"), /* DO */
  51. SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 6)), /* PL_EINT6 */
  52. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 7),
  53. SUNXI_FUNCTION(0x0, "gpio_in"),
  54. SUNXI_FUNCTION(0x1, "gpio_out"),
  55. SUNXI_FUNCTION(0x2, "s_jtag"), /* DI */
  56. SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 7)), /* PL_EINT7 */
  57. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 8),
  58. SUNXI_FUNCTION(0x0, "gpio_in"),
  59. SUNXI_FUNCTION(0x1, "gpio_out"),
  60. SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 8)), /* PL_EINT8 */
  61. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 9),
  62. SUNXI_FUNCTION(0x0, "gpio_in"),
  63. SUNXI_FUNCTION(0x1, "gpio_out"),
  64. SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 9)), /* PL_EINT9 */
  65. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 10),
  66. SUNXI_FUNCTION(0x0, "gpio_in"),
  67. SUNXI_FUNCTION(0x1, "gpio_out"),
  68. SUNXI_FUNCTION(0x2, "s_pwm"),
  69. SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 10)), /* PL_EINT10 */
  70. SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 11),
  71. SUNXI_FUNCTION(0x0, "gpio_in"),
  72. SUNXI_FUNCTION(0x1, "gpio_out"),
  73. SUNXI_FUNCTION(0x2, "s_cir_rx"),
  74. SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 11)), /* PL_EINT11 */
  75. };
  76. static const struct sunxi_pinctrl_desc sun8i_h3_r_pinctrl_data = {
  77. .pins = sun8i_h3_r_pins,
  78. .npins = ARRAY_SIZE(sun8i_h3_r_pins),
  79. .irq_banks = 1,
  80. .pin_base = PL_BASE,
  81. .irq_read_needs_mux = true
  82. };
  83. static int sun8i_h3_r_pinctrl_probe(struct platform_device *pdev)
  84. {
  85. return sunxi_pinctrl_init(pdev,
  86. &sun8i_h3_r_pinctrl_data);
  87. }
  88. static const struct of_device_id sun8i_h3_r_pinctrl_match[] = {
  89. { .compatible = "allwinner,sun8i-h3-r-pinctrl", },
  90. {}
  91. };
  92. static struct platform_driver sun8i_h3_r_pinctrl_driver = {
  93. .probe = sun8i_h3_r_pinctrl_probe,
  94. .driver = {
  95. .name = "sun8i-h3-r-pinctrl",
  96. .of_match_table = sun8i_h3_r_pinctrl_match,
  97. },
  98. };
  99. builtin_platform_driver(sun8i_h3_r_pinctrl_driver);