pinctrl-armada-xp.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. /*
  2. * Marvell Armada XP pinctrl driver based on mvebu pinctrl core
  3. *
  4. * Copyright (C) 2012 Marvell
  5. *
  6. * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This file supports the three variants of Armada XP SoCs that are
  14. * available: mv78230, mv78260 and mv78460. From a pin muxing
  15. * perspective, the mv78230 has 49 MPP pins. The mv78260 and mv78460
  16. * both have 67 MPP pins (more GPIOs and address lines for the memory
  17. * bus mainly).
  18. */
  19. #include <linux/err.h>
  20. #include <linux/init.h>
  21. #include <linux/io.h>
  22. #include <linux/module.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/clk.h>
  25. #include <linux/of.h>
  26. #include <linux/of_device.h>
  27. #include <linux/pinctrl/pinctrl.h>
  28. #include <linux/bitops.h>
  29. #include "pinctrl-mvebu.h"
  30. static void __iomem *mpp_base;
  31. static u32 *mpp_saved_regs;
  32. static int armada_xp_mpp_ctrl_get(unsigned pid, unsigned long *config)
  33. {
  34. return default_mpp_ctrl_get(mpp_base, pid, config);
  35. }
  36. static int armada_xp_mpp_ctrl_set(unsigned pid, unsigned long config)
  37. {
  38. return default_mpp_ctrl_set(mpp_base, pid, config);
  39. }
  40. enum armada_xp_variant {
  41. V_MV78230 = BIT(0),
  42. V_MV78260 = BIT(1),
  43. V_MV78460 = BIT(2),
  44. V_MV78230_PLUS = (V_MV78230 | V_MV78260 | V_MV78460),
  45. V_MV78260_PLUS = (V_MV78260 | V_MV78460),
  46. };
  47. static struct mvebu_mpp_mode armada_xp_mpp_modes[] = {
  48. MPP_MODE(0,
  49. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  50. MPP_VAR_FUNCTION(0x1, "ge0", "txclkout", V_MV78230_PLUS),
  51. MPP_VAR_FUNCTION(0x4, "lcd", "d0", V_MV78230_PLUS)),
  52. MPP_MODE(1,
  53. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  54. MPP_VAR_FUNCTION(0x1, "ge0", "txd0", V_MV78230_PLUS),
  55. MPP_VAR_FUNCTION(0x4, "lcd", "d1", V_MV78230_PLUS)),
  56. MPP_MODE(2,
  57. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  58. MPP_VAR_FUNCTION(0x1, "ge0", "txd1", V_MV78230_PLUS),
  59. MPP_VAR_FUNCTION(0x4, "lcd", "d2", V_MV78230_PLUS)),
  60. MPP_MODE(3,
  61. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  62. MPP_VAR_FUNCTION(0x1, "ge0", "txd2", V_MV78230_PLUS),
  63. MPP_VAR_FUNCTION(0x4, "lcd", "d3", V_MV78230_PLUS)),
  64. MPP_MODE(4,
  65. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  66. MPP_VAR_FUNCTION(0x1, "ge0", "txd3", V_MV78230_PLUS),
  67. MPP_VAR_FUNCTION(0x4, "lcd", "d4", V_MV78230_PLUS)),
  68. MPP_MODE(5,
  69. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  70. MPP_VAR_FUNCTION(0x1, "ge0", "txctl", V_MV78230_PLUS),
  71. MPP_VAR_FUNCTION(0x4, "lcd", "d5", V_MV78230_PLUS)),
  72. MPP_MODE(6,
  73. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  74. MPP_VAR_FUNCTION(0x1, "ge0", "rxd0", V_MV78230_PLUS),
  75. MPP_VAR_FUNCTION(0x4, "lcd", "d6", V_MV78230_PLUS)),
  76. MPP_MODE(7,
  77. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  78. MPP_VAR_FUNCTION(0x1, "ge0", "rxd1", V_MV78230_PLUS),
  79. MPP_VAR_FUNCTION(0x4, "lcd", "d7", V_MV78230_PLUS)),
  80. MPP_MODE(8,
  81. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  82. MPP_VAR_FUNCTION(0x1, "ge0", "rxd2", V_MV78230_PLUS),
  83. MPP_VAR_FUNCTION(0x4, "lcd", "d8", V_MV78230_PLUS)),
  84. MPP_MODE(9,
  85. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  86. MPP_VAR_FUNCTION(0x1, "ge0", "rxd3", V_MV78230_PLUS),
  87. MPP_VAR_FUNCTION(0x4, "lcd", "d9", V_MV78230_PLUS)),
  88. MPP_MODE(10,
  89. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  90. MPP_VAR_FUNCTION(0x1, "ge0", "rxctl", V_MV78230_PLUS),
  91. MPP_VAR_FUNCTION(0x4, "lcd", "d10", V_MV78230_PLUS)),
  92. MPP_MODE(11,
  93. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  94. MPP_VAR_FUNCTION(0x1, "ge0", "rxclk", V_MV78230_PLUS),
  95. MPP_VAR_FUNCTION(0x4, "lcd", "d11", V_MV78230_PLUS)),
  96. MPP_MODE(12,
  97. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  98. MPP_VAR_FUNCTION(0x1, "ge0", "txd4", V_MV78230_PLUS),
  99. MPP_VAR_FUNCTION(0x2, "ge1", "txclkout", V_MV78230_PLUS),
  100. MPP_VAR_FUNCTION(0x4, "lcd", "d12", V_MV78230_PLUS)),
  101. MPP_MODE(13,
  102. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  103. MPP_VAR_FUNCTION(0x1, "ge0", "txd5", V_MV78230_PLUS),
  104. MPP_VAR_FUNCTION(0x2, "ge1", "txd0", V_MV78230_PLUS),
  105. MPP_VAR_FUNCTION(0x3, "spi1", "mosi", V_MV78230_PLUS),
  106. MPP_VAR_FUNCTION(0x4, "lcd", "d13", V_MV78230_PLUS)),
  107. MPP_MODE(14,
  108. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  109. MPP_VAR_FUNCTION(0x1, "ge0", "txd6", V_MV78230_PLUS),
  110. MPP_VAR_FUNCTION(0x2, "ge1", "txd1", V_MV78230_PLUS),
  111. MPP_VAR_FUNCTION(0x3, "spi1", "sck", V_MV78230_PLUS),
  112. MPP_VAR_FUNCTION(0x4, "lcd", "d14", V_MV78230_PLUS)),
  113. MPP_MODE(15,
  114. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  115. MPP_VAR_FUNCTION(0x1, "ge0", "txd7", V_MV78230_PLUS),
  116. MPP_VAR_FUNCTION(0x2, "ge1", "txd2", V_MV78230_PLUS),
  117. MPP_VAR_FUNCTION(0x4, "lcd", "d15", V_MV78230_PLUS)),
  118. MPP_MODE(16,
  119. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  120. MPP_VAR_FUNCTION(0x1, "ge0", "txclk", V_MV78230_PLUS),
  121. MPP_VAR_FUNCTION(0x2, "ge1", "txd3", V_MV78230_PLUS),
  122. MPP_VAR_FUNCTION(0x3, "spi1", "cs0", V_MV78230_PLUS),
  123. MPP_VAR_FUNCTION(0x4, "lcd", "d16", V_MV78230_PLUS)),
  124. MPP_MODE(17,
  125. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  126. MPP_VAR_FUNCTION(0x1, "ge0", "col", V_MV78230_PLUS),
  127. MPP_VAR_FUNCTION(0x2, "ge1", "txctl", V_MV78230_PLUS),
  128. MPP_VAR_FUNCTION(0x3, "spi1", "miso", V_MV78230_PLUS),
  129. MPP_VAR_FUNCTION(0x4, "lcd", "d17", V_MV78230_PLUS)),
  130. MPP_MODE(18,
  131. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  132. MPP_VAR_FUNCTION(0x1, "ge0", "rxerr", V_MV78230_PLUS),
  133. MPP_VAR_FUNCTION(0x2, "ge1", "rxd0", V_MV78230_PLUS),
  134. MPP_VAR_FUNCTION(0x3, "ptp", "trig", V_MV78230_PLUS),
  135. MPP_VAR_FUNCTION(0x4, "lcd", "d18", V_MV78230_PLUS)),
  136. MPP_MODE(19,
  137. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  138. MPP_VAR_FUNCTION(0x1, "ge0", "crs", V_MV78230_PLUS),
  139. MPP_VAR_FUNCTION(0x2, "ge1", "rxd1", V_MV78230_PLUS),
  140. MPP_VAR_FUNCTION(0x3, "ptp", "evreq", V_MV78230_PLUS),
  141. MPP_VAR_FUNCTION(0x4, "lcd", "d19", V_MV78230_PLUS)),
  142. MPP_MODE(20,
  143. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  144. MPP_VAR_FUNCTION(0x1, "ge0", "rxd4", V_MV78230_PLUS),
  145. MPP_VAR_FUNCTION(0x2, "ge1", "rxd2", V_MV78230_PLUS),
  146. MPP_VAR_FUNCTION(0x3, "ptp", "clk", V_MV78230_PLUS),
  147. MPP_VAR_FUNCTION(0x4, "lcd", "d20", V_MV78230_PLUS)),
  148. MPP_MODE(21,
  149. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  150. MPP_VAR_FUNCTION(0x1, "ge0", "rxd5", V_MV78230_PLUS),
  151. MPP_VAR_FUNCTION(0x2, "ge1", "rxd3", V_MV78230_PLUS),
  152. MPP_VAR_FUNCTION(0x3, "dram", "bat", V_MV78230_PLUS),
  153. MPP_VAR_FUNCTION(0x4, "lcd", "d21", V_MV78230_PLUS)),
  154. MPP_MODE(22,
  155. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  156. MPP_VAR_FUNCTION(0x1, "ge0", "rxd6", V_MV78230_PLUS),
  157. MPP_VAR_FUNCTION(0x2, "ge1", "rxctl", V_MV78230_PLUS),
  158. MPP_VAR_FUNCTION(0x3, "sata0", "prsnt", V_MV78230_PLUS),
  159. MPP_VAR_FUNCTION(0x4, "lcd", "d22", V_MV78230_PLUS)),
  160. MPP_MODE(23,
  161. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  162. MPP_VAR_FUNCTION(0x1, "ge0", "rxd7", V_MV78230_PLUS),
  163. MPP_VAR_FUNCTION(0x2, "ge1", "rxclk", V_MV78230_PLUS),
  164. MPP_VAR_FUNCTION(0x3, "sata1", "prsnt", V_MV78230_PLUS),
  165. MPP_VAR_FUNCTION(0x4, "lcd", "d23", V_MV78230_PLUS)),
  166. MPP_MODE(24,
  167. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  168. MPP_VAR_FUNCTION(0x1, "sata1", "prsnt", V_MV78230_PLUS),
  169. MPP_VAR_FUNCTION(0x3, "tdm", "rst", V_MV78230_PLUS),
  170. MPP_VAR_FUNCTION(0x4, "lcd", "hsync", V_MV78230_PLUS)),
  171. MPP_MODE(25,
  172. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  173. MPP_VAR_FUNCTION(0x1, "sata0", "prsnt", V_MV78230_PLUS),
  174. MPP_VAR_FUNCTION(0x3, "tdm", "pclk", V_MV78230_PLUS),
  175. MPP_VAR_FUNCTION(0x4, "lcd", "vsync", V_MV78230_PLUS)),
  176. MPP_MODE(26,
  177. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  178. MPP_VAR_FUNCTION(0x3, "tdm", "fsync", V_MV78230_PLUS),
  179. MPP_VAR_FUNCTION(0x4, "lcd", "clk", V_MV78230_PLUS)),
  180. MPP_MODE(27,
  181. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  182. MPP_VAR_FUNCTION(0x1, "ptp", "trig", V_MV78230_PLUS),
  183. MPP_VAR_FUNCTION(0x3, "tdm", "dtx", V_MV78230_PLUS),
  184. MPP_VAR_FUNCTION(0x4, "lcd", "e", V_MV78230_PLUS)),
  185. MPP_MODE(28,
  186. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  187. MPP_VAR_FUNCTION(0x1, "ptp", "evreq", V_MV78230_PLUS),
  188. MPP_VAR_FUNCTION(0x3, "tdm", "drx", V_MV78230_PLUS),
  189. MPP_VAR_FUNCTION(0x4, "lcd", "pwm", V_MV78230_PLUS)),
  190. MPP_MODE(29,
  191. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  192. MPP_VAR_FUNCTION(0x1, "ptp", "clk", V_MV78230_PLUS),
  193. MPP_VAR_FUNCTION(0x3, "tdm", "int0", V_MV78230_PLUS),
  194. MPP_VAR_FUNCTION(0x4, "lcd", "ref-clk", V_MV78230_PLUS)),
  195. MPP_MODE(30,
  196. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  197. MPP_VAR_FUNCTION(0x1, "sd0", "clk", V_MV78230_PLUS),
  198. MPP_VAR_FUNCTION(0x3, "tdm", "int1", V_MV78230_PLUS)),
  199. MPP_MODE(31,
  200. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  201. MPP_VAR_FUNCTION(0x1, "sd0", "cmd", V_MV78230_PLUS),
  202. MPP_VAR_FUNCTION(0x3, "tdm", "int2", V_MV78230_PLUS)),
  203. MPP_MODE(32,
  204. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  205. MPP_VAR_FUNCTION(0x1, "sd0", "d0", V_MV78230_PLUS),
  206. MPP_VAR_FUNCTION(0x3, "tdm", "int3", V_MV78230_PLUS)),
  207. MPP_MODE(33,
  208. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  209. MPP_VAR_FUNCTION(0x1, "sd0", "d1", V_MV78230_PLUS),
  210. MPP_VAR_FUNCTION(0x3, "tdm", "int4", V_MV78230_PLUS),
  211. MPP_VAR_FUNCTION(0x4, "dram", "bat", V_MV78230_PLUS),
  212. MPP_VAR_FUNCTION(0x5, "dram", "vttctrl", V_MV78230_PLUS)),
  213. MPP_MODE(34,
  214. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  215. MPP_VAR_FUNCTION(0x1, "sd0", "d2", V_MV78230_PLUS),
  216. MPP_VAR_FUNCTION(0x2, "sata0", "prsnt", V_MV78230_PLUS),
  217. MPP_VAR_FUNCTION(0x3, "tdm", "int5", V_MV78230_PLUS),
  218. MPP_VAR_FUNCTION(0x4, "dram", "deccerr", V_MV78230_PLUS)),
  219. MPP_MODE(35,
  220. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  221. MPP_VAR_FUNCTION(0x1, "sd0", "d3", V_MV78230_PLUS),
  222. MPP_VAR_FUNCTION(0x2, "sata1", "prsnt", V_MV78230_PLUS),
  223. MPP_VAR_FUNCTION(0x3, "tdm", "int6", V_MV78230_PLUS)),
  224. MPP_MODE(36,
  225. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  226. MPP_VAR_FUNCTION(0x1, "spi0", "mosi", V_MV78230_PLUS)),
  227. MPP_MODE(37,
  228. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  229. MPP_VAR_FUNCTION(0x1, "spi0", "miso", V_MV78230_PLUS)),
  230. MPP_MODE(38,
  231. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  232. MPP_VAR_FUNCTION(0x1, "spi0", "sck", V_MV78230_PLUS)),
  233. MPP_MODE(39,
  234. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  235. MPP_VAR_FUNCTION(0x1, "spi0", "cs0", V_MV78230_PLUS)),
  236. MPP_MODE(40,
  237. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  238. MPP_VAR_FUNCTION(0x1, "spi0", "cs1", V_MV78230_PLUS),
  239. MPP_VAR_FUNCTION(0x2, "uart2", "cts", V_MV78230_PLUS),
  240. MPP_VAR_FUNCTION(0x4, "lcd", "vga-hsync", V_MV78230_PLUS),
  241. MPP_VAR_FUNCTION(0x5, "pcie", "clkreq0", V_MV78230_PLUS),
  242. MPP_VAR_FUNCTION(0x6, "spi1", "cs1", V_MV78230_PLUS)),
  243. MPP_MODE(41,
  244. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  245. MPP_VAR_FUNCTION(0x1, "spi0", "cs2", V_MV78230_PLUS),
  246. MPP_VAR_FUNCTION(0x2, "uart2", "rts", V_MV78230_PLUS),
  247. MPP_VAR_FUNCTION(0x3, "sata1", "prsnt", V_MV78230_PLUS),
  248. MPP_VAR_FUNCTION(0x4, "lcd", "vga-vsync", V_MV78230_PLUS),
  249. MPP_VAR_FUNCTION(0x5, "pcie", "clkreq1", V_MV78230_PLUS),
  250. MPP_VAR_FUNCTION(0x6, "spi1", "cs2", V_MV78230_PLUS)),
  251. MPP_MODE(42,
  252. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  253. MPP_VAR_FUNCTION(0x1, "uart2", "rxd", V_MV78230_PLUS),
  254. MPP_VAR_FUNCTION(0x2, "uart0", "cts", V_MV78230_PLUS),
  255. MPP_VAR_FUNCTION(0x3, "tdm", "int7", V_MV78230_PLUS),
  256. MPP_VAR_FUNCTION(0x4, "tdm", "timer", V_MV78230_PLUS)),
  257. MPP_MODE(43,
  258. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  259. MPP_VAR_FUNCTION(0x1, "uart2", "txd", V_MV78230_PLUS),
  260. MPP_VAR_FUNCTION(0x2, "uart0", "rts", V_MV78230_PLUS),
  261. MPP_VAR_FUNCTION(0x3, "spi0", "cs3", V_MV78230_PLUS),
  262. MPP_VAR_FUNCTION(0x4, "pcie", "rstout", V_MV78230_PLUS),
  263. MPP_VAR_FUNCTION(0x6, "spi1", "cs3", V_MV78230_PLUS)),
  264. MPP_MODE(44,
  265. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  266. MPP_VAR_FUNCTION(0x1, "uart2", "cts", V_MV78230_PLUS),
  267. MPP_VAR_FUNCTION(0x2, "uart3", "rxd", V_MV78230_PLUS),
  268. MPP_VAR_FUNCTION(0x3, "spi0", "cs4", V_MV78230_PLUS),
  269. MPP_VAR_FUNCTION(0x4, "dram", "bat", V_MV78230_PLUS),
  270. MPP_VAR_FUNCTION(0x5, "pcie", "clkreq2", V_MV78230_PLUS),
  271. MPP_VAR_FUNCTION(0x6, "spi1", "cs4", V_MV78230_PLUS)),
  272. MPP_MODE(45,
  273. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  274. MPP_VAR_FUNCTION(0x1, "uart2", "rts", V_MV78230_PLUS),
  275. MPP_VAR_FUNCTION(0x2, "uart3", "txd", V_MV78230_PLUS),
  276. MPP_VAR_FUNCTION(0x3, "spi0", "cs5", V_MV78230_PLUS),
  277. MPP_VAR_FUNCTION(0x4, "sata1", "prsnt", V_MV78230_PLUS),
  278. MPP_VAR_FUNCTION(0x5, "dram", "vttctrl", V_MV78230_PLUS),
  279. MPP_VAR_FUNCTION(0x6, "spi1", "cs5", V_MV78230_PLUS)),
  280. MPP_MODE(46,
  281. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  282. MPP_VAR_FUNCTION(0x1, "uart3", "rts", V_MV78230_PLUS),
  283. MPP_VAR_FUNCTION(0x2, "uart1", "rts", V_MV78230_PLUS),
  284. MPP_VAR_FUNCTION(0x3, "spi0", "cs6", V_MV78230_PLUS),
  285. MPP_VAR_FUNCTION(0x4, "sata0", "prsnt", V_MV78230_PLUS),
  286. MPP_VAR_FUNCTION(0x6, "spi1", "cs6", V_MV78230_PLUS)),
  287. MPP_MODE(47,
  288. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  289. MPP_VAR_FUNCTION(0x1, "uart3", "cts", V_MV78230_PLUS),
  290. MPP_VAR_FUNCTION(0x2, "uart1", "cts", V_MV78230_PLUS),
  291. MPP_VAR_FUNCTION(0x3, "spi0", "cs7", V_MV78230_PLUS),
  292. MPP_VAR_FUNCTION(0x4, "ref", "clkout", V_MV78230_PLUS),
  293. MPP_VAR_FUNCTION(0x5, "pcie", "clkreq3", V_MV78230_PLUS),
  294. MPP_VAR_FUNCTION(0x6, "spi1", "cs7", V_MV78230_PLUS)),
  295. MPP_MODE(48,
  296. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78230_PLUS),
  297. MPP_VAR_FUNCTION(0x1, "dev", "clkout", V_MV78230_PLUS),
  298. MPP_VAR_FUNCTION(0x2, "dev", "burst/last", V_MV78230_PLUS),
  299. MPP_VAR_FUNCTION(0x3, "nand", "rb", V_MV78230_PLUS)),
  300. MPP_MODE(49,
  301. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  302. MPP_VAR_FUNCTION(0x1, "dev", "we3", V_MV78260_PLUS)),
  303. MPP_MODE(50,
  304. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  305. MPP_VAR_FUNCTION(0x1, "dev", "we2", V_MV78260_PLUS)),
  306. MPP_MODE(51,
  307. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  308. MPP_VAR_FUNCTION(0x1, "dev", "ad16", V_MV78260_PLUS)),
  309. MPP_MODE(52,
  310. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  311. MPP_VAR_FUNCTION(0x1, "dev", "ad17", V_MV78260_PLUS)),
  312. MPP_MODE(53,
  313. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  314. MPP_VAR_FUNCTION(0x1, "dev", "ad18", V_MV78260_PLUS)),
  315. MPP_MODE(54,
  316. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  317. MPP_VAR_FUNCTION(0x1, "dev", "ad19", V_MV78260_PLUS)),
  318. MPP_MODE(55,
  319. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  320. MPP_VAR_FUNCTION(0x1, "dev", "ad20", V_MV78260_PLUS)),
  321. MPP_MODE(56,
  322. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  323. MPP_VAR_FUNCTION(0x1, "dev", "ad21", V_MV78260_PLUS)),
  324. MPP_MODE(57,
  325. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  326. MPP_VAR_FUNCTION(0x1, "dev", "ad22", V_MV78260_PLUS)),
  327. MPP_MODE(58,
  328. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  329. MPP_VAR_FUNCTION(0x1, "dev", "ad23", V_MV78260_PLUS)),
  330. MPP_MODE(59,
  331. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  332. MPP_VAR_FUNCTION(0x1, "dev", "ad24", V_MV78260_PLUS)),
  333. MPP_MODE(60,
  334. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  335. MPP_VAR_FUNCTION(0x1, "dev", "ad25", V_MV78260_PLUS)),
  336. MPP_MODE(61,
  337. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  338. MPP_VAR_FUNCTION(0x1, "dev", "ad26", V_MV78260_PLUS)),
  339. MPP_MODE(62,
  340. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  341. MPP_VAR_FUNCTION(0x1, "dev", "ad27", V_MV78260_PLUS)),
  342. MPP_MODE(63,
  343. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  344. MPP_VAR_FUNCTION(0x1, "dev", "ad28", V_MV78260_PLUS)),
  345. MPP_MODE(64,
  346. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  347. MPP_VAR_FUNCTION(0x1, "dev", "ad29", V_MV78260_PLUS)),
  348. MPP_MODE(65,
  349. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  350. MPP_VAR_FUNCTION(0x1, "dev", "ad30", V_MV78260_PLUS)),
  351. MPP_MODE(66,
  352. MPP_VAR_FUNCTION(0x0, "gpio", NULL, V_MV78260_PLUS),
  353. MPP_VAR_FUNCTION(0x1, "dev", "ad31", V_MV78260_PLUS)),
  354. };
  355. static struct mvebu_pinctrl_soc_info armada_xp_pinctrl_info;
  356. static const struct of_device_id armada_xp_pinctrl_of_match[] = {
  357. {
  358. .compatible = "marvell,mv78230-pinctrl",
  359. .data = (void *) V_MV78230,
  360. },
  361. {
  362. .compatible = "marvell,mv78260-pinctrl",
  363. .data = (void *) V_MV78260,
  364. },
  365. {
  366. .compatible = "marvell,mv78460-pinctrl",
  367. .data = (void *) V_MV78460,
  368. },
  369. { },
  370. };
  371. static struct mvebu_mpp_ctrl mv78230_mpp_controls[] = {
  372. MPP_FUNC_CTRL(0, 48, NULL, armada_xp_mpp_ctrl),
  373. };
  374. static struct pinctrl_gpio_range mv78230_mpp_gpio_ranges[] = {
  375. MPP_GPIO_RANGE(0, 0, 0, 32),
  376. MPP_GPIO_RANGE(1, 32, 32, 17),
  377. };
  378. static struct mvebu_mpp_ctrl mv78260_mpp_controls[] = {
  379. MPP_FUNC_CTRL(0, 66, NULL, armada_xp_mpp_ctrl),
  380. };
  381. static struct pinctrl_gpio_range mv78260_mpp_gpio_ranges[] = {
  382. MPP_GPIO_RANGE(0, 0, 0, 32),
  383. MPP_GPIO_RANGE(1, 32, 32, 32),
  384. MPP_GPIO_RANGE(2, 64, 64, 3),
  385. };
  386. static struct mvebu_mpp_ctrl mv78460_mpp_controls[] = {
  387. MPP_FUNC_CTRL(0, 66, NULL, armada_xp_mpp_ctrl),
  388. };
  389. static struct pinctrl_gpio_range mv78460_mpp_gpio_ranges[] = {
  390. MPP_GPIO_RANGE(0, 0, 0, 32),
  391. MPP_GPIO_RANGE(1, 32, 32, 32),
  392. MPP_GPIO_RANGE(2, 64, 64, 3),
  393. };
  394. static int armada_xp_pinctrl_suspend(struct platform_device *pdev,
  395. pm_message_t state)
  396. {
  397. struct mvebu_pinctrl_soc_info *soc =
  398. platform_get_drvdata(pdev);
  399. int i, nregs;
  400. nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG);
  401. for (i = 0; i < nregs; i++)
  402. mpp_saved_regs[i] = readl(mpp_base + i * 4);
  403. return 0;
  404. }
  405. static int armada_xp_pinctrl_resume(struct platform_device *pdev)
  406. {
  407. struct mvebu_pinctrl_soc_info *soc =
  408. platform_get_drvdata(pdev);
  409. int i, nregs;
  410. nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG);
  411. for (i = 0; i < nregs; i++)
  412. writel(mpp_saved_regs[i], mpp_base + i * 4);
  413. return 0;
  414. }
  415. static int armada_xp_pinctrl_probe(struct platform_device *pdev)
  416. {
  417. struct mvebu_pinctrl_soc_info *soc = &armada_xp_pinctrl_info;
  418. const struct of_device_id *match =
  419. of_match_device(armada_xp_pinctrl_of_match, &pdev->dev);
  420. struct resource *res;
  421. int nregs;
  422. if (!match)
  423. return -ENODEV;
  424. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  425. mpp_base = devm_ioremap_resource(&pdev->dev, res);
  426. if (IS_ERR(mpp_base))
  427. return PTR_ERR(mpp_base);
  428. soc->variant = (unsigned) match->data & 0xff;
  429. switch (soc->variant) {
  430. case V_MV78230:
  431. soc->controls = mv78230_mpp_controls;
  432. soc->ncontrols = ARRAY_SIZE(mv78230_mpp_controls);
  433. soc->modes = armada_xp_mpp_modes;
  434. /* We don't necessarily want the full list of the
  435. * armada_xp_mpp_modes, but only the first 'n' ones
  436. * that are available on this SoC */
  437. soc->nmodes = mv78230_mpp_controls[0].npins;
  438. soc->gpioranges = mv78230_mpp_gpio_ranges;
  439. soc->ngpioranges = ARRAY_SIZE(mv78230_mpp_gpio_ranges);
  440. break;
  441. case V_MV78260:
  442. soc->controls = mv78260_mpp_controls;
  443. soc->ncontrols = ARRAY_SIZE(mv78260_mpp_controls);
  444. soc->modes = armada_xp_mpp_modes;
  445. /* We don't necessarily want the full list of the
  446. * armada_xp_mpp_modes, but only the first 'n' ones
  447. * that are available on this SoC */
  448. soc->nmodes = mv78260_mpp_controls[0].npins;
  449. soc->gpioranges = mv78260_mpp_gpio_ranges;
  450. soc->ngpioranges = ARRAY_SIZE(mv78260_mpp_gpio_ranges);
  451. break;
  452. case V_MV78460:
  453. soc->controls = mv78460_mpp_controls;
  454. soc->ncontrols = ARRAY_SIZE(mv78460_mpp_controls);
  455. soc->modes = armada_xp_mpp_modes;
  456. /* We don't necessarily want the full list of the
  457. * armada_xp_mpp_modes, but only the first 'n' ones
  458. * that are available on this SoC */
  459. soc->nmodes = mv78460_mpp_controls[0].npins;
  460. soc->gpioranges = mv78460_mpp_gpio_ranges;
  461. soc->ngpioranges = ARRAY_SIZE(mv78460_mpp_gpio_ranges);
  462. break;
  463. }
  464. nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG);
  465. mpp_saved_regs = devm_kmalloc(&pdev->dev, nregs * sizeof(u32),
  466. GFP_KERNEL);
  467. if (!mpp_saved_regs)
  468. return -ENOMEM;
  469. pdev->dev.platform_data = soc;
  470. return mvebu_pinctrl_probe(pdev);
  471. }
  472. static int armada_xp_pinctrl_remove(struct platform_device *pdev)
  473. {
  474. return mvebu_pinctrl_remove(pdev);
  475. }
  476. static struct platform_driver armada_xp_pinctrl_driver = {
  477. .driver = {
  478. .name = "armada-xp-pinctrl",
  479. .of_match_table = armada_xp_pinctrl_of_match,
  480. },
  481. .probe = armada_xp_pinctrl_probe,
  482. .remove = armada_xp_pinctrl_remove,
  483. .suspend = armada_xp_pinctrl_suspend,
  484. .resume = armada_xp_pinctrl_resume,
  485. };
  486. module_platform_driver(armada_xp_pinctrl_driver);
  487. MODULE_AUTHOR("Thomas Petazzoni <thomas.petazzoni@free-electrons.com>");
  488. MODULE_DESCRIPTION("Marvell Armada XP pinctrl driver");
  489. MODULE_LICENSE("GPL v2");