pinctrl-wm8650.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. /*
  2. * Pinctrl data for Wondermedia WM8650 SoC
  3. *
  4. * Copyright (c) 2013 Tony Prisk <linux@prisktech.co.nz>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. */
  15. #include <linux/io.h>
  16. #include <linux/module.h>
  17. #include <linux/pinctrl/pinctrl.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/slab.h>
  20. #include "pinctrl-wmt.h"
  21. /*
  22. * Describe the register offsets within the GPIO memory space
  23. * The dedicated external GPIO's should always be listed in bank 0
  24. * so they are exported in the 0..31 range which is what users
  25. * expect.
  26. *
  27. * Do not reorder these banks as it will change the pin numbering
  28. */
  29. static const struct wmt_pinctrl_bank_registers wm8650_banks[] = {
  30. WMT_PINCTRL_BANK(0x40, 0x80, 0xC0, 0x00, 0x480, 0x4C0), /* 0 */
  31. WMT_PINCTRL_BANK(0x44, 0x84, 0xC4, 0x04, 0x484, 0x4C4), /* 1 */
  32. WMT_PINCTRL_BANK(0x48, 0x88, 0xC8, 0x08, 0x488, 0x4C8), /* 2 */
  33. WMT_PINCTRL_BANK(0x4C, 0x8C, 0xCC, 0x0C, 0x48C, 0x4CC), /* 3 */
  34. WMT_PINCTRL_BANK(0x50, 0x90, 0xD0, 0x10, 0x490, 0x4D0), /* 4 */
  35. WMT_PINCTRL_BANK(0x54, 0x94, 0xD4, 0x14, 0x494, 0x4D4), /* 5 */
  36. WMT_PINCTRL_BANK(0x58, 0x98, 0xD8, 0x18, 0x498, 0x4D8), /* 6 */
  37. WMT_PINCTRL_BANK(0x5C, 0x9C, 0xDC, 0x1C, 0x49C, 0x4DC), /* 7 */
  38. };
  39. /* Please keep sorted by bank/bit */
  40. #define WMT_PIN_EXTGPIO0 WMT_PIN(0, 0)
  41. #define WMT_PIN_EXTGPIO1 WMT_PIN(0, 1)
  42. #define WMT_PIN_EXTGPIO2 WMT_PIN(0, 2)
  43. #define WMT_PIN_EXTGPIO3 WMT_PIN(0, 3)
  44. #define WMT_PIN_EXTGPIO4 WMT_PIN(0, 4)
  45. #define WMT_PIN_EXTGPIO5 WMT_PIN(0, 5)
  46. #define WMT_PIN_EXTGPIO6 WMT_PIN(0, 6)
  47. #define WMT_PIN_EXTGPIO7 WMT_PIN(0, 7)
  48. #define WMT_PIN_WAKEUP0 WMT_PIN(0, 16)
  49. #define WMT_PIN_WAKEUP1 WMT_PIN(0, 17)
  50. #define WMT_PIN_SUSGPIO0 WMT_PIN(0, 21)
  51. #define WMT_PIN_SD0CD WMT_PIN(0, 28)
  52. #define WMT_PIN_SD1CD WMT_PIN(0, 29)
  53. #define WMT_PIN_VDOUT0 WMT_PIN(1, 0)
  54. #define WMT_PIN_VDOUT1 WMT_PIN(1, 1)
  55. #define WMT_PIN_VDOUT2 WMT_PIN(1, 2)
  56. #define WMT_PIN_VDOUT3 WMT_PIN(1, 3)
  57. #define WMT_PIN_VDOUT4 WMT_PIN(1, 4)
  58. #define WMT_PIN_VDOUT5 WMT_PIN(1, 5)
  59. #define WMT_PIN_VDOUT6 WMT_PIN(1, 6)
  60. #define WMT_PIN_VDOUT7 WMT_PIN(1, 7)
  61. #define WMT_PIN_VDOUT8 WMT_PIN(1, 8)
  62. #define WMT_PIN_VDOUT9 WMT_PIN(1, 9)
  63. #define WMT_PIN_VDOUT10 WMT_PIN(1, 10)
  64. #define WMT_PIN_VDOUT11 WMT_PIN(1, 11)
  65. #define WMT_PIN_VDOUT12 WMT_PIN(1, 12)
  66. #define WMT_PIN_VDOUT13 WMT_PIN(1, 13)
  67. #define WMT_PIN_VDOUT14 WMT_PIN(1, 14)
  68. #define WMT_PIN_VDOUT15 WMT_PIN(1, 15)
  69. #define WMT_PIN_VDOUT16 WMT_PIN(1, 16)
  70. #define WMT_PIN_VDOUT17 WMT_PIN(1, 17)
  71. #define WMT_PIN_VDOUT18 WMT_PIN(1, 18)
  72. #define WMT_PIN_VDOUT19 WMT_PIN(1, 19)
  73. #define WMT_PIN_VDOUT20 WMT_PIN(1, 20)
  74. #define WMT_PIN_VDOUT21 WMT_PIN(1, 21)
  75. #define WMT_PIN_VDOUT22 WMT_PIN(1, 22)
  76. #define WMT_PIN_VDOUT23 WMT_PIN(1, 23)
  77. #define WMT_PIN_VDIN0 WMT_PIN(2, 0)
  78. #define WMT_PIN_VDIN1 WMT_PIN(2, 1)
  79. #define WMT_PIN_VDIN2 WMT_PIN(2, 2)
  80. #define WMT_PIN_VDIN3 WMT_PIN(2, 3)
  81. #define WMT_PIN_VDIN4 WMT_PIN(2, 4)
  82. #define WMT_PIN_VDIN5 WMT_PIN(2, 5)
  83. #define WMT_PIN_VDIN6 WMT_PIN(2, 6)
  84. #define WMT_PIN_VDIN7 WMT_PIN(2, 7)
  85. #define WMT_PIN_I2C1SCL WMT_PIN(2, 12)
  86. #define WMT_PIN_I2C1SDA WMT_PIN(2, 13)
  87. #define WMT_PIN_SPI0MOSI WMT_PIN(2, 24)
  88. #define WMT_PIN_SPI0MISO WMT_PIN(2, 25)
  89. #define WMT_PIN_SPI0SS0 WMT_PIN(2, 26)
  90. #define WMT_PIN_SPI0CLK WMT_PIN(2, 27)
  91. #define WMT_PIN_SD0DATA0 WMT_PIN(3, 8)
  92. #define WMT_PIN_SD0DATA1 WMT_PIN(3, 9)
  93. #define WMT_PIN_SD0DATA2 WMT_PIN(3, 10)
  94. #define WMT_PIN_SD0DATA3 WMT_PIN(3, 11)
  95. #define WMT_PIN_SD0CLK WMT_PIN(3, 12)
  96. #define WMT_PIN_SD0WP WMT_PIN(3, 13)
  97. #define WMT_PIN_SD0CMD WMT_PIN(3, 14)
  98. #define WMT_PIN_SD1DATA0 WMT_PIN(3, 24)
  99. #define WMT_PIN_SD1DATA1 WMT_PIN(3, 25)
  100. #define WMT_PIN_SD1DATA2 WMT_PIN(3, 26)
  101. #define WMT_PIN_SD1DATA3 WMT_PIN(3, 27)
  102. #define WMT_PIN_SD1DATA4 WMT_PIN(3, 28)
  103. #define WMT_PIN_SD1DATA5 WMT_PIN(3, 29)
  104. #define WMT_PIN_SD1DATA6 WMT_PIN(3, 30)
  105. #define WMT_PIN_SD1DATA7 WMT_PIN(3, 31)
  106. #define WMT_PIN_I2C0SCL WMT_PIN(5, 8)
  107. #define WMT_PIN_I2C0SDA WMT_PIN(5, 9)
  108. #define WMT_PIN_UART0RTS WMT_PIN(5, 16)
  109. #define WMT_PIN_UART0TXD WMT_PIN(5, 17)
  110. #define WMT_PIN_UART0CTS WMT_PIN(5, 18)
  111. #define WMT_PIN_UART0RXD WMT_PIN(5, 19)
  112. #define WMT_PIN_UART1RTS WMT_PIN(5, 20)
  113. #define WMT_PIN_UART1TXD WMT_PIN(5, 21)
  114. #define WMT_PIN_UART1CTS WMT_PIN(5, 22)
  115. #define WMT_PIN_UART1RXD WMT_PIN(5, 23)
  116. #define WMT_PIN_UART2RTS WMT_PIN(5, 24)
  117. #define WMT_PIN_UART2TXD WMT_PIN(5, 25)
  118. #define WMT_PIN_UART2CTS WMT_PIN(5, 26)
  119. #define WMT_PIN_UART2RXD WMT_PIN(5, 27)
  120. #define WMT_PIN_UART3RTS WMT_PIN(5, 28)
  121. #define WMT_PIN_UART3TXD WMT_PIN(5, 29)
  122. #define WMT_PIN_UART3CTS WMT_PIN(5, 30)
  123. #define WMT_PIN_UART3RXD WMT_PIN(5, 31)
  124. #define WMT_PIN_KPADROW0 WMT_PIN(6, 16)
  125. #define WMT_PIN_KPADROW1 WMT_PIN(6, 17)
  126. #define WMT_PIN_KPADCOL0 WMT_PIN(6, 18)
  127. #define WMT_PIN_KPADCOL1 WMT_PIN(6, 19)
  128. #define WMT_PIN_SD1CLK WMT_PIN(7, 0)
  129. #define WMT_PIN_SD1CMD WMT_PIN(7, 1)
  130. #define WMT_PIN_SD1WP WMT_PIN(7, 13)
  131. static const struct pinctrl_pin_desc wm8650_pins[] = {
  132. PINCTRL_PIN(WMT_PIN_EXTGPIO0, "extgpio0"),
  133. PINCTRL_PIN(WMT_PIN_EXTGPIO1, "extgpio1"),
  134. PINCTRL_PIN(WMT_PIN_EXTGPIO2, "extgpio2"),
  135. PINCTRL_PIN(WMT_PIN_EXTGPIO3, "extgpio3"),
  136. PINCTRL_PIN(WMT_PIN_EXTGPIO4, "extgpio4"),
  137. PINCTRL_PIN(WMT_PIN_EXTGPIO5, "extgpio5"),
  138. PINCTRL_PIN(WMT_PIN_EXTGPIO6, "extgpio6"),
  139. PINCTRL_PIN(WMT_PIN_EXTGPIO7, "extgpio7"),
  140. PINCTRL_PIN(WMT_PIN_WAKEUP0, "wakeup0"),
  141. PINCTRL_PIN(WMT_PIN_WAKEUP1, "wakeup1"),
  142. PINCTRL_PIN(WMT_PIN_SUSGPIO0, "susgpio0"),
  143. PINCTRL_PIN(WMT_PIN_SD0CD, "sd0_cd"),
  144. PINCTRL_PIN(WMT_PIN_SD1CD, "sd1_cd"),
  145. PINCTRL_PIN(WMT_PIN_VDOUT0, "vdout0"),
  146. PINCTRL_PIN(WMT_PIN_VDOUT1, "vdout1"),
  147. PINCTRL_PIN(WMT_PIN_VDOUT2, "vdout2"),
  148. PINCTRL_PIN(WMT_PIN_VDOUT3, "vdout3"),
  149. PINCTRL_PIN(WMT_PIN_VDOUT4, "vdout4"),
  150. PINCTRL_PIN(WMT_PIN_VDOUT5, "vdout5"),
  151. PINCTRL_PIN(WMT_PIN_VDOUT6, "vdout6"),
  152. PINCTRL_PIN(WMT_PIN_VDOUT7, "vdout7"),
  153. PINCTRL_PIN(WMT_PIN_VDOUT8, "vdout8"),
  154. PINCTRL_PIN(WMT_PIN_VDOUT9, "vdout9"),
  155. PINCTRL_PIN(WMT_PIN_VDOUT10, "vdout10"),
  156. PINCTRL_PIN(WMT_PIN_VDOUT11, "vdout11"),
  157. PINCTRL_PIN(WMT_PIN_VDOUT12, "vdout12"),
  158. PINCTRL_PIN(WMT_PIN_VDOUT13, "vdout13"),
  159. PINCTRL_PIN(WMT_PIN_VDOUT14, "vdout14"),
  160. PINCTRL_PIN(WMT_PIN_VDOUT15, "vdout15"),
  161. PINCTRL_PIN(WMT_PIN_VDOUT16, "vdout16"),
  162. PINCTRL_PIN(WMT_PIN_VDOUT17, "vdout17"),
  163. PINCTRL_PIN(WMT_PIN_VDOUT18, "vdout18"),
  164. PINCTRL_PIN(WMT_PIN_VDOUT19, "vdout19"),
  165. PINCTRL_PIN(WMT_PIN_VDOUT20, "vdout20"),
  166. PINCTRL_PIN(WMT_PIN_VDOUT21, "vdout21"),
  167. PINCTRL_PIN(WMT_PIN_VDOUT22, "vdout22"),
  168. PINCTRL_PIN(WMT_PIN_VDOUT23, "vdout23"),
  169. PINCTRL_PIN(WMT_PIN_VDIN0, "vdin0"),
  170. PINCTRL_PIN(WMT_PIN_VDIN1, "vdin1"),
  171. PINCTRL_PIN(WMT_PIN_VDIN2, "vdin2"),
  172. PINCTRL_PIN(WMT_PIN_VDIN3, "vdin3"),
  173. PINCTRL_PIN(WMT_PIN_VDIN4, "vdin4"),
  174. PINCTRL_PIN(WMT_PIN_VDIN5, "vdin5"),
  175. PINCTRL_PIN(WMT_PIN_VDIN6, "vdin6"),
  176. PINCTRL_PIN(WMT_PIN_VDIN7, "vdin7"),
  177. PINCTRL_PIN(WMT_PIN_I2C1SCL, "i2c1_scl"),
  178. PINCTRL_PIN(WMT_PIN_I2C1SDA, "i2c1_sda"),
  179. PINCTRL_PIN(WMT_PIN_SPI0MOSI, "spi0_mosi"),
  180. PINCTRL_PIN(WMT_PIN_SPI0MISO, "spi0_miso"),
  181. PINCTRL_PIN(WMT_PIN_SPI0SS0, "spi0_ss0"),
  182. PINCTRL_PIN(WMT_PIN_SPI0CLK, "spi0_clk"),
  183. PINCTRL_PIN(WMT_PIN_SD0DATA0, "sd0_data0"),
  184. PINCTRL_PIN(WMT_PIN_SD0DATA1, "sd0_data1"),
  185. PINCTRL_PIN(WMT_PIN_SD0DATA2, "sd0_data2"),
  186. PINCTRL_PIN(WMT_PIN_SD0DATA3, "sd0_data3"),
  187. PINCTRL_PIN(WMT_PIN_SD0CLK, "sd0_clk"),
  188. PINCTRL_PIN(WMT_PIN_SD0WP, "sd0_wp"),
  189. PINCTRL_PIN(WMT_PIN_SD0CMD, "sd0_cmd"),
  190. PINCTRL_PIN(WMT_PIN_SD1DATA0, "sd1_data0"),
  191. PINCTRL_PIN(WMT_PIN_SD1DATA1, "sd1_data1"),
  192. PINCTRL_PIN(WMT_PIN_SD1DATA2, "sd1_data2"),
  193. PINCTRL_PIN(WMT_PIN_SD1DATA3, "sd1_data3"),
  194. PINCTRL_PIN(WMT_PIN_SD1DATA4, "sd1_data4"),
  195. PINCTRL_PIN(WMT_PIN_SD1DATA5, "sd1_data5"),
  196. PINCTRL_PIN(WMT_PIN_SD1DATA6, "sd1_data6"),
  197. PINCTRL_PIN(WMT_PIN_SD1DATA7, "sd1_data7"),
  198. PINCTRL_PIN(WMT_PIN_I2C0SCL, "i2c0_scl"),
  199. PINCTRL_PIN(WMT_PIN_I2C0SDA, "i2c0_sda"),
  200. PINCTRL_PIN(WMT_PIN_UART0RTS, "uart0_rts"),
  201. PINCTRL_PIN(WMT_PIN_UART0TXD, "uart0_txd"),
  202. PINCTRL_PIN(WMT_PIN_UART0CTS, "uart0_cts"),
  203. PINCTRL_PIN(WMT_PIN_UART0RXD, "uart0_rxd"),
  204. PINCTRL_PIN(WMT_PIN_UART1RTS, "uart1_rts"),
  205. PINCTRL_PIN(WMT_PIN_UART1TXD, "uart1_txd"),
  206. PINCTRL_PIN(WMT_PIN_UART1CTS, "uart1_cts"),
  207. PINCTRL_PIN(WMT_PIN_UART1RXD, "uart1_rxd"),
  208. PINCTRL_PIN(WMT_PIN_UART2RTS, "uart2_rts"),
  209. PINCTRL_PIN(WMT_PIN_UART2TXD, "uart2_txd"),
  210. PINCTRL_PIN(WMT_PIN_UART2CTS, "uart2_cts"),
  211. PINCTRL_PIN(WMT_PIN_UART2RXD, "uart2_rxd"),
  212. PINCTRL_PIN(WMT_PIN_UART3RTS, "uart3_rts"),
  213. PINCTRL_PIN(WMT_PIN_UART3TXD, "uart3_txd"),
  214. PINCTRL_PIN(WMT_PIN_UART3CTS, "uart3_cts"),
  215. PINCTRL_PIN(WMT_PIN_UART3RXD, "uart3_rxd"),
  216. PINCTRL_PIN(WMT_PIN_KPADROW0, "kpadrow0"),
  217. PINCTRL_PIN(WMT_PIN_KPADROW1, "kpadrow1"),
  218. PINCTRL_PIN(WMT_PIN_KPADCOL0, "kpadcol0"),
  219. PINCTRL_PIN(WMT_PIN_KPADCOL1, "kpadcol1"),
  220. PINCTRL_PIN(WMT_PIN_SD1CLK, "sd1_clk"),
  221. PINCTRL_PIN(WMT_PIN_SD1CMD, "sd1_cmd"),
  222. PINCTRL_PIN(WMT_PIN_SD1WP, "sd1_wp"),
  223. };
  224. /* Order of these names must match the above list */
  225. static const char * const wm8650_groups[] = {
  226. "extgpio0",
  227. "extgpio1",
  228. "extgpio2",
  229. "extgpio3",
  230. "extgpio4",
  231. "extgpio5",
  232. "extgpio6",
  233. "extgpio7",
  234. "wakeup0",
  235. "wakeup1",
  236. "susgpio0",
  237. "sd0_cd",
  238. "sd1_cd",
  239. "vdout0",
  240. "vdout1",
  241. "vdout2",
  242. "vdout3",
  243. "vdout4",
  244. "vdout5",
  245. "vdout6",
  246. "vdout7",
  247. "vdout8",
  248. "vdout9",
  249. "vdout10",
  250. "vdout11",
  251. "vdout12",
  252. "vdout13",
  253. "vdout14",
  254. "vdout15",
  255. "vdout16",
  256. "vdout17",
  257. "vdout18",
  258. "vdout19",
  259. "vdout20",
  260. "vdout21",
  261. "vdout22",
  262. "vdout23",
  263. "vdin0",
  264. "vdin1",
  265. "vdin2",
  266. "vdin3",
  267. "vdin4",
  268. "vdin5",
  269. "vdin6",
  270. "vdin7",
  271. "i2c1_scl",
  272. "i2c1_sda",
  273. "spi0_mosi",
  274. "spi0_miso",
  275. "spi0_ss0",
  276. "spi0_clk",
  277. "sd0_data0",
  278. "sd0_data1",
  279. "sd0_data2",
  280. "sd0_data3",
  281. "sd0_clk",
  282. "sd0_wp",
  283. "sd0_cmd",
  284. "sd1_data0",
  285. "sd1_data1",
  286. "sd1_data2",
  287. "sd1_data3",
  288. "sd1_data4",
  289. "sd1_data5",
  290. "sd1_data6",
  291. "sd1_data7",
  292. "i2c0_scl",
  293. "i2c0_sda",
  294. "uart0_rts",
  295. "uart0_txd",
  296. "uart0_cts",
  297. "uart0_rxd",
  298. "uart1_rts",
  299. "uart1_txd",
  300. "uart1_cts",
  301. "uart1_rxd",
  302. "uart2_rts",
  303. "uart2_txd",
  304. "uart2_cts",
  305. "uart2_rxd",
  306. "uart3_rts",
  307. "uart3_txd",
  308. "uart3_cts",
  309. "uart3_rxd",
  310. "kpadrow0",
  311. "kpadrow1",
  312. "kpadcol0",
  313. "kpadcol1",
  314. "sd1_clk",
  315. "sd1_cmd",
  316. "sd1_wp",
  317. };
  318. static int wm8650_pinctrl_probe(struct platform_device *pdev)
  319. {
  320. struct wmt_pinctrl_data *data;
  321. data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
  322. if (!data) {
  323. dev_err(&pdev->dev, "failed to allocate data\n");
  324. return -ENOMEM;
  325. }
  326. data->banks = wm8650_banks;
  327. data->nbanks = ARRAY_SIZE(wm8650_banks);
  328. data->pins = wm8650_pins;
  329. data->npins = ARRAY_SIZE(wm8650_pins);
  330. data->groups = wm8650_groups;
  331. data->ngroups = ARRAY_SIZE(wm8650_groups);
  332. return wmt_pinctrl_probe(pdev, data);
  333. }
  334. static int wm8650_pinctrl_remove(struct platform_device *pdev)
  335. {
  336. return wmt_pinctrl_remove(pdev);
  337. }
  338. static const struct of_device_id wmt_pinctrl_of_match[] = {
  339. { .compatible = "wm,wm8650-pinctrl" },
  340. { /* sentinel */ },
  341. };
  342. static struct platform_driver wmt_pinctrl_driver = {
  343. .probe = wm8650_pinctrl_probe,
  344. .remove = wm8650_pinctrl_remove,
  345. .driver = {
  346. .name = "pinctrl-wm8650",
  347. .of_match_table = wmt_pinctrl_of_match,
  348. },
  349. };
  350. module_platform_driver(wmt_pinctrl_driver);
  351. MODULE_AUTHOR("Tony Prisk <linux@prisktech.co.nz>");
  352. MODULE_DESCRIPTION("Wondermedia WM8650 Pincontrol driver");
  353. MODULE_LICENSE("GPL v2");
  354. MODULE_DEVICE_TABLE(of, wmt_pinctrl_of_match);