pinctrl-ac5.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Marvell ac5 pinctrl driver based on mvebu pinctrl core
  4. *
  5. * Copyright (C) 2021 Marvell
  6. *
  7. * Noam Liron <[email protected]>
  8. */
  9. #include <linux/err.h>
  10. #include <linux/init.h>
  11. #include <linux/io.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/of.h>
  14. #include <linux/of_device.h>
  15. #include <linux/pinctrl/pinctrl.h>
  16. #include "pinctrl-mvebu.h"
  17. static struct mvebu_mpp_mode ac5_mpp_modes[] = {
  18. MPP_MODE(0,
  19. MPP_FUNCTION(0, "gpio", NULL),
  20. MPP_FUNCTION(1, "sdio", "d0"),
  21. MPP_FUNCTION(2, "nand", "io4")),
  22. MPP_MODE(1,
  23. MPP_FUNCTION(0, "gpio", NULL),
  24. MPP_FUNCTION(1, "sdio", "d1"),
  25. MPP_FUNCTION(2, "nand", "io3")),
  26. MPP_MODE(2,
  27. MPP_FUNCTION(0, "gpio", NULL),
  28. MPP_FUNCTION(1, "sdio", "d2"),
  29. MPP_FUNCTION(2, "nand", "io2")),
  30. MPP_MODE(3,
  31. MPP_FUNCTION(0, "gpio", NULL),
  32. MPP_FUNCTION(1, "sdio", "d3"),
  33. MPP_FUNCTION(2, "nand", "io7")),
  34. MPP_MODE(4,
  35. MPP_FUNCTION(0, "gpio", NULL),
  36. MPP_FUNCTION(1, "sdio", "d4"),
  37. MPP_FUNCTION(2, "nand", "io6"),
  38. MPP_FUNCTION(3, "uart3", "txd"),
  39. MPP_FUNCTION(4, "uart2", "txd")),
  40. MPP_MODE(5,
  41. MPP_FUNCTION(0, "gpio", NULL),
  42. MPP_FUNCTION(1, "sdio", "d5"),
  43. MPP_FUNCTION(2, "nand", "io5"),
  44. MPP_FUNCTION(3, "uart3", "rxd"),
  45. MPP_FUNCTION(4, "uart2", "rxd")),
  46. MPP_MODE(6,
  47. MPP_FUNCTION(0, "gpio", NULL),
  48. MPP_FUNCTION(1, "sdio", "d6"),
  49. MPP_FUNCTION(2, "nand", "io0"),
  50. MPP_FUNCTION(3, "i2c1", "sck")),
  51. MPP_MODE(7,
  52. MPP_FUNCTION(0, "gpio", NULL),
  53. MPP_FUNCTION(1, "sdio", "d7"),
  54. MPP_FUNCTION(2, "nand", "io1"),
  55. MPP_FUNCTION(3, "i2c1", "sda")),
  56. MPP_MODE(8,
  57. MPP_FUNCTION(0, "gpio", NULL),
  58. MPP_FUNCTION(1, "sdio", "clk"),
  59. MPP_FUNCTION(2, "nand", "wen")),
  60. MPP_MODE(9,
  61. MPP_FUNCTION(0, "gpio", NULL),
  62. MPP_FUNCTION(1, "sdio", "cmd"),
  63. MPP_FUNCTION(2, "nand", "ale")),
  64. MPP_MODE(10,
  65. MPP_FUNCTION(0, "gpio", NULL),
  66. MPP_FUNCTION(1, "sdio", "ds"),
  67. MPP_FUNCTION(2, "nand", "cle")),
  68. MPP_MODE(11,
  69. MPP_FUNCTION(0, "gpio", NULL),
  70. MPP_FUNCTION(1, "sdio", "rst"),
  71. MPP_FUNCTION(2, "nand", "cen")),
  72. MPP_MODE(12,
  73. MPP_FUNCTION(0, "gpio", NULL),
  74. MPP_FUNCTION(1, "spi0", "clk")),
  75. MPP_MODE(13,
  76. MPP_FUNCTION(0, "gpio", NULL),
  77. MPP_FUNCTION(1, "spi0", "csn")),
  78. MPP_MODE(14,
  79. MPP_FUNCTION(0, "gpio", NULL),
  80. MPP_FUNCTION(1, "spi0", "mosi")),
  81. MPP_MODE(15,
  82. MPP_FUNCTION(0, "gpio", NULL),
  83. MPP_FUNCTION(1, "spi0", "miso")),
  84. MPP_MODE(16,
  85. MPP_FUNCTION(0, "gpio", NULL),
  86. MPP_FUNCTION(1, "spi0", "wpn"),
  87. MPP_FUNCTION(2, "nand", "ren"),
  88. MPP_FUNCTION(3, "uart1", "txd")),
  89. MPP_MODE(17,
  90. MPP_FUNCTION(0, "gpio", NULL),
  91. MPP_FUNCTION(1, "spi0", "hold"),
  92. MPP_FUNCTION(2, "nand", "rb"),
  93. MPP_FUNCTION(3, "uart1", "rxd")),
  94. MPP_MODE(18,
  95. MPP_FUNCTION(0, "gpio", NULL),
  96. MPP_FUNCTION(1, "tsen_int", NULL),
  97. MPP_FUNCTION(2, "uart2", "rxd"),
  98. MPP_FUNCTION(3, "wd_int", NULL)),
  99. MPP_MODE(19,
  100. MPP_FUNCTION(0, "gpio", NULL),
  101. MPP_FUNCTION(1, "dev_init_done", NULL),
  102. MPP_FUNCTION(2, "uart2", "txd")),
  103. MPP_MODE(20,
  104. MPP_FUNCTION(0, "gpio", NULL),
  105. MPP_FUNCTION(2, "i2c1", "sck"),
  106. MPP_FUNCTION(3, "spi1", "clk"),
  107. MPP_FUNCTION(4, "uart3", "txd")),
  108. MPP_MODE(21,
  109. MPP_FUNCTION(0, "gpio", NULL),
  110. MPP_FUNCTION(2, "i2c1", "sda"),
  111. MPP_FUNCTION(3, "spi1", "csn"),
  112. MPP_FUNCTION(4, "uart3", "rxd")),
  113. MPP_MODE(22,
  114. MPP_FUNCTION(0, "gpio", NULL),
  115. MPP_FUNCTION(3, "spi1", "mosi")),
  116. MPP_MODE(23,
  117. MPP_FUNCTION(0, "gpio", NULL),
  118. MPP_FUNCTION(3, "spi1", "miso")),
  119. MPP_MODE(24,
  120. MPP_FUNCTION(0, "gpio", NULL),
  121. MPP_FUNCTION(1, "wd_int", NULL),
  122. MPP_FUNCTION(2, "uart2", "txd"),
  123. MPP_FUNCTION(3, "uartsd", "txd")),
  124. MPP_MODE(25,
  125. MPP_FUNCTION(0, "gpio", NULL),
  126. MPP_FUNCTION(1, "int_out", NULL),
  127. MPP_FUNCTION(2, "uart2", "rxd"),
  128. MPP_FUNCTION(3, "uartsd", "rxd")),
  129. MPP_MODE(26,
  130. MPP_FUNCTION(0, "gpio", NULL),
  131. MPP_FUNCTION(1, "i2c0", "sck"),
  132. MPP_FUNCTION(2, "ptp", "clk1"),
  133. MPP_FUNCTION(3, "uart3", "txd")),
  134. MPP_MODE(27,
  135. MPP_FUNCTION(0, "gpio", NULL),
  136. MPP_FUNCTION(1, "i2c0", "sda"),
  137. MPP_FUNCTION(2, "ptp", "pulse"),
  138. MPP_FUNCTION(3, "uart3", "rxd")),
  139. MPP_MODE(28,
  140. MPP_FUNCTION(0, "gpio", NULL),
  141. MPP_FUNCTION(1, "xg", "mdio"),
  142. MPP_FUNCTION(2, "ge", "mdio"),
  143. MPP_FUNCTION(3, "uart3", "txd")),
  144. MPP_MODE(29,
  145. MPP_FUNCTION(0, "gpio", NULL),
  146. MPP_FUNCTION(1, "xg", "mdio"),
  147. MPP_FUNCTION(2, "ge", "mdio"),
  148. MPP_FUNCTION(3, "uart3", "rxd")),
  149. MPP_MODE(30,
  150. MPP_FUNCTION(0, "gpio", NULL),
  151. MPP_FUNCTION(1, "xg", "mdio"),
  152. MPP_FUNCTION(2, "ge", "mdio"),
  153. MPP_FUNCTION(3, "ge", "mdio")),
  154. MPP_MODE(31,
  155. MPP_FUNCTION(0, "gpio", NULL),
  156. MPP_FUNCTION(1, "xg", "mdio"),
  157. MPP_FUNCTION(2, "ge", "mdio"),
  158. MPP_FUNCTION(3, "ge", "mdio")),
  159. MPP_MODE(32,
  160. MPP_FUNCTION(0, "gpio", NULL),
  161. MPP_FUNCTION(1, "uart0", "txd")),
  162. MPP_MODE(33,
  163. MPP_FUNCTION(0, "gpio", NULL),
  164. MPP_FUNCTION(1, "uart0", "rxd"),
  165. MPP_FUNCTION(2, "ptp", "clk1"),
  166. MPP_FUNCTION(3, "ptp", "pulse")),
  167. MPP_MODE(34,
  168. MPP_FUNCTION(0, "gpio", NULL),
  169. MPP_FUNCTION(1, "ge", "mdio"),
  170. MPP_FUNCTION(2, "uart3", "rxd")),
  171. MPP_MODE(35,
  172. MPP_FUNCTION(0, "gpio", NULL),
  173. MPP_FUNCTION(1, "ge", "mdio"),
  174. MPP_FUNCTION(2, "uart3", "txd"),
  175. MPP_FUNCTION(3, "pcie", "rstoutn")),
  176. MPP_MODE(36,
  177. MPP_FUNCTION(0, "gpio", NULL),
  178. MPP_FUNCTION(1, "ptp", "clk0_tp"),
  179. MPP_FUNCTION(2, "ptp", "clk1_tp")),
  180. MPP_MODE(37,
  181. MPP_FUNCTION(0, "gpio", NULL),
  182. MPP_FUNCTION(1, "ptp", "pulse_tp"),
  183. MPP_FUNCTION(2, "wd_int", NULL)),
  184. MPP_MODE(38,
  185. MPP_FUNCTION(0, "gpio", NULL),
  186. MPP_FUNCTION(1, "synce", "clk_out0")),
  187. MPP_MODE(39,
  188. MPP_FUNCTION(0, "gpio", NULL),
  189. MPP_FUNCTION(1, "synce", "clk_out1")),
  190. MPP_MODE(40,
  191. MPP_FUNCTION(0, "gpio", NULL),
  192. MPP_FUNCTION(1, "ptp", "pclk_out0"),
  193. MPP_FUNCTION(2, "ptp", "pclk_out1")),
  194. MPP_MODE(41,
  195. MPP_FUNCTION(0, "gpio", NULL),
  196. MPP_FUNCTION(1, "ptp", "ref_clk"),
  197. MPP_FUNCTION(2, "ptp", "clk1"),
  198. MPP_FUNCTION(3, "ptp", "pulse"),
  199. MPP_FUNCTION(4, "uart2", "txd"),
  200. MPP_FUNCTION(5, "i2c1", "sck")),
  201. MPP_MODE(42,
  202. MPP_FUNCTION(0, "gpio", NULL),
  203. MPP_FUNCTION(1, "ptp", "clk0"),
  204. MPP_FUNCTION(2, "ptp", "clk1"),
  205. MPP_FUNCTION(3, "ptp", "pulse"),
  206. MPP_FUNCTION(4, "uart2", "rxd"),
  207. MPP_FUNCTION(5, "i2c1", "sda")),
  208. MPP_MODE(43,
  209. MPP_FUNCTION(0, "gpio", NULL),
  210. MPP_FUNCTION(1, "led", "clk")),
  211. MPP_MODE(44,
  212. MPP_FUNCTION(0, "gpio", NULL),
  213. MPP_FUNCTION(1, "led", "stb")),
  214. MPP_MODE(45,
  215. MPP_FUNCTION(0, "gpio", NULL),
  216. MPP_FUNCTION(1, "led", "data")),
  217. };
  218. static struct mvebu_pinctrl_soc_info ac5_pinctrl_info;
  219. static const struct of_device_id ac5_pinctrl_of_match[] = {
  220. {
  221. .compatible = "marvell,ac5-pinctrl",
  222. },
  223. { },
  224. };
  225. static const struct mvebu_mpp_ctrl ac5_mpp_controls[] = {
  226. MPP_FUNC_CTRL(0, 45, NULL, mvebu_mmio_mpp_ctrl), };
  227. static struct pinctrl_gpio_range ac5_mpp_gpio_ranges[] = {
  228. MPP_GPIO_RANGE(0, 0, 0, 46), };
  229. static int ac5_pinctrl_probe(struct platform_device *pdev)
  230. {
  231. struct mvebu_pinctrl_soc_info *soc = &ac5_pinctrl_info;
  232. soc->variant = 0; /* no variants for ac5 */
  233. soc->controls = ac5_mpp_controls;
  234. soc->ncontrols = ARRAY_SIZE(ac5_mpp_controls);
  235. soc->gpioranges = ac5_mpp_gpio_ranges;
  236. soc->ngpioranges = ARRAY_SIZE(ac5_mpp_gpio_ranges);
  237. soc->modes = ac5_mpp_modes;
  238. soc->nmodes = ac5_mpp_controls[0].npins;
  239. pdev->dev.platform_data = soc;
  240. return mvebu_pinctrl_simple_mmio_probe(pdev);
  241. }
  242. static struct platform_driver ac5_pinctrl_driver = {
  243. .driver = {
  244. .name = "ac5-pinctrl",
  245. .of_match_table = of_match_ptr(ac5_pinctrl_of_match),
  246. },
  247. .probe = ac5_pinctrl_probe,
  248. };
  249. builtin_platform_driver(ac5_pinctrl_driver);