pinctrl-vf610.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. /*
  2. * VF610 pinctrl driver based on imx pinmux and pinconf core
  3. *
  4. * Copyright 2013 Freescale Semiconductor, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #include <linux/err.h>
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <linux/of.h>
  15. #include <linux/of_device.h>
  16. #include <linux/pinctrl/pinctrl.h>
  17. #include "pinctrl-imx.h"
  18. enum vf610_pads {
  19. VF610_PAD_PTA6 = 0,
  20. VF610_PAD_PTA8 = 1,
  21. VF610_PAD_PTA9 = 2,
  22. VF610_PAD_PTA10 = 3,
  23. VF610_PAD_PTA11 = 4,
  24. VF610_PAD_PTA12 = 5,
  25. VF610_PAD_PTA16 = 6,
  26. VF610_PAD_PTA17 = 7,
  27. VF610_PAD_PTA18 = 8,
  28. VF610_PAD_PTA19 = 9,
  29. VF610_PAD_PTA20 = 10,
  30. VF610_PAD_PTA21 = 11,
  31. VF610_PAD_PTA22 = 12,
  32. VF610_PAD_PTA23 = 13,
  33. VF610_PAD_PTA24 = 14,
  34. VF610_PAD_PTA25 = 15,
  35. VF610_PAD_PTA26 = 16,
  36. VF610_PAD_PTA27 = 17,
  37. VF610_PAD_PTA28 = 18,
  38. VF610_PAD_PTA29 = 19,
  39. VF610_PAD_PTA30 = 20,
  40. VF610_PAD_PTA31 = 21,
  41. VF610_PAD_PTB0 = 22,
  42. VF610_PAD_PTB1 = 23,
  43. VF610_PAD_PTB2 = 24,
  44. VF610_PAD_PTB3 = 25,
  45. VF610_PAD_PTB4 = 26,
  46. VF610_PAD_PTB5 = 27,
  47. VF610_PAD_PTB6 = 28,
  48. VF610_PAD_PTB7 = 29,
  49. VF610_PAD_PTB8 = 30,
  50. VF610_PAD_PTB9 = 31,
  51. VF610_PAD_PTB10 = 32,
  52. VF610_PAD_PTB11 = 33,
  53. VF610_PAD_PTB12 = 34,
  54. VF610_PAD_PTB13 = 35,
  55. VF610_PAD_PTB14 = 36,
  56. VF610_PAD_PTB15 = 37,
  57. VF610_PAD_PTB16 = 38,
  58. VF610_PAD_PTB17 = 39,
  59. VF610_PAD_PTB18 = 40,
  60. VF610_PAD_PTB19 = 41,
  61. VF610_PAD_PTB20 = 42,
  62. VF610_PAD_PTB21 = 43,
  63. VF610_PAD_PTB22 = 44,
  64. VF610_PAD_PTC0 = 45,
  65. VF610_PAD_PTC1 = 46,
  66. VF610_PAD_PTC2 = 47,
  67. VF610_PAD_PTC3 = 48,
  68. VF610_PAD_PTC4 = 49,
  69. VF610_PAD_PTC5 = 50,
  70. VF610_PAD_PTC6 = 51,
  71. VF610_PAD_PTC7 = 52,
  72. VF610_PAD_PTC8 = 53,
  73. VF610_PAD_PTC9 = 54,
  74. VF610_PAD_PTC10 = 55,
  75. VF610_PAD_PTC11 = 56,
  76. VF610_PAD_PTC12 = 57,
  77. VF610_PAD_PTC13 = 58,
  78. VF610_PAD_PTC14 = 59,
  79. VF610_PAD_PTC15 = 60,
  80. VF610_PAD_PTC16 = 61,
  81. VF610_PAD_PTC17 = 62,
  82. VF610_PAD_PTD31 = 63,
  83. VF610_PAD_PTD30 = 64,
  84. VF610_PAD_PTD29 = 65,
  85. VF610_PAD_PTD28 = 66,
  86. VF610_PAD_PTD27 = 67,
  87. VF610_PAD_PTD26 = 68,
  88. VF610_PAD_PTD25 = 69,
  89. VF610_PAD_PTD24 = 70,
  90. VF610_PAD_PTD23 = 71,
  91. VF610_PAD_PTD22 = 72,
  92. VF610_PAD_PTD21 = 73,
  93. VF610_PAD_PTD20 = 74,
  94. VF610_PAD_PTD19 = 75,
  95. VF610_PAD_PTD18 = 76,
  96. VF610_PAD_PTD17 = 77,
  97. VF610_PAD_PTD16 = 78,
  98. VF610_PAD_PTD0 = 79,
  99. VF610_PAD_PTD1 = 80,
  100. VF610_PAD_PTD2 = 81,
  101. VF610_PAD_PTD3 = 82,
  102. VF610_PAD_PTD4 = 83,
  103. VF610_PAD_PTD5 = 84,
  104. VF610_PAD_PTD6 = 85,
  105. VF610_PAD_PTD7 = 86,
  106. VF610_PAD_PTD8 = 87,
  107. VF610_PAD_PTD9 = 88,
  108. VF610_PAD_PTD10 = 89,
  109. VF610_PAD_PTD11 = 90,
  110. VF610_PAD_PTD12 = 91,
  111. VF610_PAD_PTD13 = 92,
  112. VF610_PAD_PTB23 = 93,
  113. VF610_PAD_PTB24 = 94,
  114. VF610_PAD_PTB25 = 95,
  115. VF610_PAD_PTB26 = 96,
  116. VF610_PAD_PTB27 = 97,
  117. VF610_PAD_PTB28 = 98,
  118. VF610_PAD_PTC26 = 99,
  119. VF610_PAD_PTC27 = 100,
  120. VF610_PAD_PTC28 = 101,
  121. VF610_PAD_PTC29 = 102,
  122. VF610_PAD_PTC30 = 103,
  123. VF610_PAD_PTC31 = 104,
  124. VF610_PAD_PTE0 = 105,
  125. VF610_PAD_PTE1 = 106,
  126. VF610_PAD_PTE2 = 107,
  127. VF610_PAD_PTE3 = 108,
  128. VF610_PAD_PTE4 = 109,
  129. VF610_PAD_PTE5 = 110,
  130. VF610_PAD_PTE6 = 111,
  131. VF610_PAD_PTE7 = 112,
  132. VF610_PAD_PTE8 = 113,
  133. VF610_PAD_PTE9 = 114,
  134. VF610_PAD_PTE10 = 115,
  135. VF610_PAD_PTE11 = 116,
  136. VF610_PAD_PTE12 = 117,
  137. VF610_PAD_PTE13 = 118,
  138. VF610_PAD_PTE14 = 119,
  139. VF610_PAD_PTE15 = 120,
  140. VF610_PAD_PTE16 = 121,
  141. VF610_PAD_PTE17 = 122,
  142. VF610_PAD_PTE18 = 123,
  143. VF610_PAD_PTE19 = 124,
  144. VF610_PAD_PTE20 = 125,
  145. VF610_PAD_PTE21 = 126,
  146. VF610_PAD_PTE22 = 127,
  147. VF610_PAD_PTE23 = 128,
  148. VF610_PAD_PTE24 = 129,
  149. VF610_PAD_PTE25 = 130,
  150. VF610_PAD_PTE26 = 131,
  151. VF610_PAD_PTE27 = 132,
  152. VF610_PAD_PTE28 = 133,
  153. VF610_PAD_PTA7 = 134,
  154. };
  155. /* Pad names for the pinmux subsystem */
  156. static const struct pinctrl_pin_desc vf610_pinctrl_pads[] = {
  157. IMX_PINCTRL_PIN(VF610_PAD_PTA6),
  158. IMX_PINCTRL_PIN(VF610_PAD_PTA8),
  159. IMX_PINCTRL_PIN(VF610_PAD_PTA9),
  160. IMX_PINCTRL_PIN(VF610_PAD_PTA10),
  161. IMX_PINCTRL_PIN(VF610_PAD_PTA11),
  162. IMX_PINCTRL_PIN(VF610_PAD_PTA12),
  163. IMX_PINCTRL_PIN(VF610_PAD_PTA16),
  164. IMX_PINCTRL_PIN(VF610_PAD_PTA17),
  165. IMX_PINCTRL_PIN(VF610_PAD_PTA18),
  166. IMX_PINCTRL_PIN(VF610_PAD_PTA19),
  167. IMX_PINCTRL_PIN(VF610_PAD_PTA20),
  168. IMX_PINCTRL_PIN(VF610_PAD_PTA21),
  169. IMX_PINCTRL_PIN(VF610_PAD_PTA22),
  170. IMX_PINCTRL_PIN(VF610_PAD_PTA23),
  171. IMX_PINCTRL_PIN(VF610_PAD_PTA24),
  172. IMX_PINCTRL_PIN(VF610_PAD_PTA25),
  173. IMX_PINCTRL_PIN(VF610_PAD_PTA26),
  174. IMX_PINCTRL_PIN(VF610_PAD_PTA27),
  175. IMX_PINCTRL_PIN(VF610_PAD_PTA28),
  176. IMX_PINCTRL_PIN(VF610_PAD_PTA29),
  177. IMX_PINCTRL_PIN(VF610_PAD_PTA30),
  178. IMX_PINCTRL_PIN(VF610_PAD_PTA31),
  179. IMX_PINCTRL_PIN(VF610_PAD_PTB0),
  180. IMX_PINCTRL_PIN(VF610_PAD_PTB1),
  181. IMX_PINCTRL_PIN(VF610_PAD_PTB2),
  182. IMX_PINCTRL_PIN(VF610_PAD_PTB3),
  183. IMX_PINCTRL_PIN(VF610_PAD_PTB4),
  184. IMX_PINCTRL_PIN(VF610_PAD_PTB5),
  185. IMX_PINCTRL_PIN(VF610_PAD_PTB6),
  186. IMX_PINCTRL_PIN(VF610_PAD_PTB7),
  187. IMX_PINCTRL_PIN(VF610_PAD_PTB8),
  188. IMX_PINCTRL_PIN(VF610_PAD_PTB9),
  189. IMX_PINCTRL_PIN(VF610_PAD_PTB10),
  190. IMX_PINCTRL_PIN(VF610_PAD_PTB11),
  191. IMX_PINCTRL_PIN(VF610_PAD_PTB12),
  192. IMX_PINCTRL_PIN(VF610_PAD_PTB13),
  193. IMX_PINCTRL_PIN(VF610_PAD_PTB14),
  194. IMX_PINCTRL_PIN(VF610_PAD_PTB15),
  195. IMX_PINCTRL_PIN(VF610_PAD_PTB16),
  196. IMX_PINCTRL_PIN(VF610_PAD_PTB17),
  197. IMX_PINCTRL_PIN(VF610_PAD_PTB18),
  198. IMX_PINCTRL_PIN(VF610_PAD_PTB19),
  199. IMX_PINCTRL_PIN(VF610_PAD_PTB20),
  200. IMX_PINCTRL_PIN(VF610_PAD_PTB21),
  201. IMX_PINCTRL_PIN(VF610_PAD_PTB22),
  202. IMX_PINCTRL_PIN(VF610_PAD_PTC0),
  203. IMX_PINCTRL_PIN(VF610_PAD_PTC1),
  204. IMX_PINCTRL_PIN(VF610_PAD_PTC2),
  205. IMX_PINCTRL_PIN(VF610_PAD_PTC3),
  206. IMX_PINCTRL_PIN(VF610_PAD_PTC4),
  207. IMX_PINCTRL_PIN(VF610_PAD_PTC5),
  208. IMX_PINCTRL_PIN(VF610_PAD_PTC6),
  209. IMX_PINCTRL_PIN(VF610_PAD_PTC7),
  210. IMX_PINCTRL_PIN(VF610_PAD_PTC8),
  211. IMX_PINCTRL_PIN(VF610_PAD_PTC9),
  212. IMX_PINCTRL_PIN(VF610_PAD_PTC10),
  213. IMX_PINCTRL_PIN(VF610_PAD_PTC11),
  214. IMX_PINCTRL_PIN(VF610_PAD_PTC12),
  215. IMX_PINCTRL_PIN(VF610_PAD_PTC13),
  216. IMX_PINCTRL_PIN(VF610_PAD_PTC14),
  217. IMX_PINCTRL_PIN(VF610_PAD_PTC15),
  218. IMX_PINCTRL_PIN(VF610_PAD_PTC16),
  219. IMX_PINCTRL_PIN(VF610_PAD_PTC17),
  220. IMX_PINCTRL_PIN(VF610_PAD_PTD31),
  221. IMX_PINCTRL_PIN(VF610_PAD_PTD30),
  222. IMX_PINCTRL_PIN(VF610_PAD_PTD29),
  223. IMX_PINCTRL_PIN(VF610_PAD_PTD28),
  224. IMX_PINCTRL_PIN(VF610_PAD_PTD27),
  225. IMX_PINCTRL_PIN(VF610_PAD_PTD26),
  226. IMX_PINCTRL_PIN(VF610_PAD_PTD25),
  227. IMX_PINCTRL_PIN(VF610_PAD_PTD24),
  228. IMX_PINCTRL_PIN(VF610_PAD_PTD23),
  229. IMX_PINCTRL_PIN(VF610_PAD_PTD22),
  230. IMX_PINCTRL_PIN(VF610_PAD_PTD21),
  231. IMX_PINCTRL_PIN(VF610_PAD_PTD20),
  232. IMX_PINCTRL_PIN(VF610_PAD_PTD19),
  233. IMX_PINCTRL_PIN(VF610_PAD_PTD18),
  234. IMX_PINCTRL_PIN(VF610_PAD_PTD17),
  235. IMX_PINCTRL_PIN(VF610_PAD_PTD16),
  236. IMX_PINCTRL_PIN(VF610_PAD_PTD0),
  237. IMX_PINCTRL_PIN(VF610_PAD_PTD1),
  238. IMX_PINCTRL_PIN(VF610_PAD_PTD2),
  239. IMX_PINCTRL_PIN(VF610_PAD_PTD3),
  240. IMX_PINCTRL_PIN(VF610_PAD_PTD4),
  241. IMX_PINCTRL_PIN(VF610_PAD_PTD5),
  242. IMX_PINCTRL_PIN(VF610_PAD_PTD6),
  243. IMX_PINCTRL_PIN(VF610_PAD_PTD7),
  244. IMX_PINCTRL_PIN(VF610_PAD_PTD8),
  245. IMX_PINCTRL_PIN(VF610_PAD_PTD9),
  246. IMX_PINCTRL_PIN(VF610_PAD_PTD10),
  247. IMX_PINCTRL_PIN(VF610_PAD_PTD11),
  248. IMX_PINCTRL_PIN(VF610_PAD_PTD12),
  249. IMX_PINCTRL_PIN(VF610_PAD_PTD13),
  250. IMX_PINCTRL_PIN(VF610_PAD_PTB23),
  251. IMX_PINCTRL_PIN(VF610_PAD_PTB24),
  252. IMX_PINCTRL_PIN(VF610_PAD_PTB25),
  253. IMX_PINCTRL_PIN(VF610_PAD_PTB26),
  254. IMX_PINCTRL_PIN(VF610_PAD_PTB27),
  255. IMX_PINCTRL_PIN(VF610_PAD_PTB28),
  256. IMX_PINCTRL_PIN(VF610_PAD_PTC26),
  257. IMX_PINCTRL_PIN(VF610_PAD_PTC27),
  258. IMX_PINCTRL_PIN(VF610_PAD_PTC28),
  259. IMX_PINCTRL_PIN(VF610_PAD_PTC29),
  260. IMX_PINCTRL_PIN(VF610_PAD_PTC30),
  261. IMX_PINCTRL_PIN(VF610_PAD_PTC31),
  262. IMX_PINCTRL_PIN(VF610_PAD_PTE0),
  263. IMX_PINCTRL_PIN(VF610_PAD_PTE1),
  264. IMX_PINCTRL_PIN(VF610_PAD_PTE2),
  265. IMX_PINCTRL_PIN(VF610_PAD_PTE3),
  266. IMX_PINCTRL_PIN(VF610_PAD_PTE4),
  267. IMX_PINCTRL_PIN(VF610_PAD_PTE5),
  268. IMX_PINCTRL_PIN(VF610_PAD_PTE6),
  269. IMX_PINCTRL_PIN(VF610_PAD_PTE7),
  270. IMX_PINCTRL_PIN(VF610_PAD_PTE8),
  271. IMX_PINCTRL_PIN(VF610_PAD_PTE9),
  272. IMX_PINCTRL_PIN(VF610_PAD_PTE10),
  273. IMX_PINCTRL_PIN(VF610_PAD_PTE11),
  274. IMX_PINCTRL_PIN(VF610_PAD_PTE12),
  275. IMX_PINCTRL_PIN(VF610_PAD_PTE13),
  276. IMX_PINCTRL_PIN(VF610_PAD_PTE14),
  277. IMX_PINCTRL_PIN(VF610_PAD_PTE15),
  278. IMX_PINCTRL_PIN(VF610_PAD_PTE16),
  279. IMX_PINCTRL_PIN(VF610_PAD_PTE17),
  280. IMX_PINCTRL_PIN(VF610_PAD_PTE18),
  281. IMX_PINCTRL_PIN(VF610_PAD_PTE19),
  282. IMX_PINCTRL_PIN(VF610_PAD_PTE20),
  283. IMX_PINCTRL_PIN(VF610_PAD_PTE21),
  284. IMX_PINCTRL_PIN(VF610_PAD_PTE22),
  285. IMX_PINCTRL_PIN(VF610_PAD_PTE23),
  286. IMX_PINCTRL_PIN(VF610_PAD_PTE24),
  287. IMX_PINCTRL_PIN(VF610_PAD_PTE25),
  288. IMX_PINCTRL_PIN(VF610_PAD_PTE26),
  289. IMX_PINCTRL_PIN(VF610_PAD_PTE27),
  290. IMX_PINCTRL_PIN(VF610_PAD_PTE28),
  291. IMX_PINCTRL_PIN(VF610_PAD_PTA7),
  292. };
  293. static int vf610_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
  294. struct pinctrl_gpio_range *range,
  295. unsigned offset, bool input)
  296. {
  297. struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
  298. struct imx_pinctrl_soc_info *info = ipctl->info;
  299. const struct imx_pin_reg *pin_reg;
  300. u32 reg;
  301. pin_reg = &info->pin_regs[offset];
  302. if (pin_reg->mux_reg == -1)
  303. return -EINVAL;
  304. /* IBE always enabled allows us to read the value "on the wire" */
  305. reg = readl(ipctl->base + pin_reg->mux_reg);
  306. if (input)
  307. reg &= ~0x2;
  308. else
  309. reg |= 0x2;
  310. writel(reg, ipctl->base + pin_reg->mux_reg);
  311. return 0;
  312. }
  313. static struct imx_pinctrl_soc_info vf610_pinctrl_info = {
  314. .pins = vf610_pinctrl_pads,
  315. .npins = ARRAY_SIZE(vf610_pinctrl_pads),
  316. .flags = SHARE_MUX_CONF_REG | ZERO_OFFSET_VALID,
  317. .gpio_set_direction = vf610_pmx_gpio_set_direction,
  318. .mux_mask = 0x700000,
  319. .mux_shift = 20,
  320. };
  321. static const struct of_device_id vf610_pinctrl_of_match[] = {
  322. { .compatible = "fsl,vf610-iomuxc", },
  323. { /* sentinel */ }
  324. };
  325. static int vf610_pinctrl_probe(struct platform_device *pdev)
  326. {
  327. return imx_pinctrl_probe(pdev, &vf610_pinctrl_info);
  328. }
  329. static struct platform_driver vf610_pinctrl_driver = {
  330. .driver = {
  331. .name = "vf610-pinctrl",
  332. .of_match_table = vf610_pinctrl_of_match,
  333. },
  334. .probe = vf610_pinctrl_probe,
  335. };
  336. static int __init vf610_pinctrl_init(void)
  337. {
  338. return platform_driver_register(&vf610_pinctrl_driver);
  339. }
  340. arch_initcall(vf610_pinctrl_init);