berlin-bg4ct.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. /*
  2. * Marvell berlin4ct pinctrl driver
  3. *
  4. * Copyright (C) 2015 Marvell Technology Group Ltd.
  5. *
  6. * Author: Jisheng Zhang <jszhang@marvell.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2, as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <linux/init.h>
  21. #include <linux/of_device.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/regmap.h>
  24. #include "berlin.h"
  25. static const struct berlin_desc_group berlin4ct_soc_pinctrl_groups[] = {
  26. BERLIN_PINCTRL_GROUP("EMMC_RSTn", 0x0, 0x3, 0x00,
  27. BERLIN_PINCTRL_FUNCTION(0x0, "emmc"), /* RSTn */
  28. BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* GPIO47 */
  29. BERLIN_PINCTRL_GROUP("NAND_IO0", 0x0, 0x3, 0x03,
  30. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO0 */
  31. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXD0 */
  32. BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* CLK */
  33. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO0 */
  34. BERLIN_PINCTRL_GROUP("NAND_IO1", 0x0, 0x3, 0x06,
  35. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO1 */
  36. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXD1 */
  37. BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* CDn */
  38. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO1 */
  39. BERLIN_PINCTRL_GROUP("NAND_IO2", 0x0, 0x3, 0x09,
  40. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO2 */
  41. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXD2 */
  42. BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* DAT0 */
  43. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO2 */
  44. BERLIN_PINCTRL_GROUP("NAND_IO3", 0x0, 0x3, 0x0c,
  45. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO3 */
  46. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXD3 */
  47. BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* DAT1 */
  48. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO3 */
  49. BERLIN_PINCTRL_GROUP("NAND_IO4", 0x0, 0x3, 0x0f,
  50. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO4 */
  51. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXC */
  52. BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* DAT2 */
  53. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO4 */
  54. BERLIN_PINCTRL_GROUP("NAND_IO5", 0x0, 0x3, 0x12,
  55. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO5 */
  56. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXCTL */
  57. BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* DAT3 */
  58. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO5 */
  59. BERLIN_PINCTRL_GROUP("NAND_IO6", 0x0, 0x3, 0x15,
  60. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO6 */
  61. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* MDC */
  62. BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* CMD */
  63. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO6 */
  64. BERLIN_PINCTRL_GROUP("NAND_IO7", 0x0, 0x3, 0x18,
  65. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO7 */
  66. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* MDIO */
  67. BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* WP */
  68. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO7 */
  69. BERLIN_PINCTRL_GROUP("NAND_ALE", 0x0, 0x3, 0x1b,
  70. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* ALE */
  71. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXD0 */
  72. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO8 */
  73. BERLIN_PINCTRL_GROUP("NAND_CLE", 0x4, 0x3, 0x00,
  74. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* CLE */
  75. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXD1 */
  76. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO9 */
  77. BERLIN_PINCTRL_GROUP("NAND_WEn", 0x4, 0x3, 0x03,
  78. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* WEn */
  79. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXD2 */
  80. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO10 */
  81. BERLIN_PINCTRL_GROUP("NAND_REn", 0x4, 0x3, 0x06,
  82. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* REn */
  83. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXD3 */
  84. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO11 */
  85. BERLIN_PINCTRL_GROUP("NAND_WPn", 0x4, 0x3, 0x09,
  86. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* WPn */
  87. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO12 */
  88. BERLIN_PINCTRL_GROUP("NAND_CEn", 0x4, 0x3, 0x0c,
  89. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* CEn */
  90. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXC */
  91. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO13 */
  92. BERLIN_PINCTRL_GROUP("NAND_RDY", 0x4, 0x3, 0x0f,
  93. BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* RDY */
  94. BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXCTL */
  95. BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO14 */
  96. BERLIN_PINCTRL_GROUP("SD0_CLK", 0x4, 0x3, 0x12,
  97. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO29 */
  98. BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* CLK*/
  99. BERLIN_PINCTRL_FUNCTION(0x2, "sts4"), /* CLK */
  100. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG8 */
  101. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG8 */
  102. BERLIN_PINCTRL_GROUP("SD0_DAT0", 0x4, 0x3, 0x15,
  103. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO30 */
  104. BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT0 */
  105. BERLIN_PINCTRL_FUNCTION(0x2, "sts4"), /* SOP */
  106. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG9 */
  107. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG9 */
  108. BERLIN_PINCTRL_GROUP("SD0_DAT1", 0x4, 0x3, 0x18,
  109. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO31 */
  110. BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT1 */
  111. BERLIN_PINCTRL_FUNCTION(0x2, "sts4"), /* SD */
  112. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG10 */
  113. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG10 */
  114. BERLIN_PINCTRL_GROUP("SD0_DAT2", 0x4, 0x3, 0x1b,
  115. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO32 */
  116. BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT2 */
  117. BERLIN_PINCTRL_FUNCTION(0x2, "sts4"), /* VALD */
  118. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG11 */
  119. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG11 */
  120. BERLIN_PINCTRL_GROUP("SD0_DAT3", 0x8, 0x3, 0x00,
  121. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO33 */
  122. BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT3 */
  123. BERLIN_PINCTRL_FUNCTION(0x2, "sts5"), /* CLK */
  124. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG12 */
  125. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG12 */
  126. BERLIN_PINCTRL_GROUP("SD0_CDn", 0x8, 0x3, 0x03,
  127. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO34 */
  128. BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* CDn */
  129. BERLIN_PINCTRL_FUNCTION(0x2, "sts5"), /* SOP */
  130. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG13 */
  131. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG13 */
  132. BERLIN_PINCTRL_GROUP("SD0_CMD", 0x8, 0x3, 0x06,
  133. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO35 */
  134. BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* CMD */
  135. BERLIN_PINCTRL_FUNCTION(0x2, "sts5"), /* SD */
  136. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG14 */
  137. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG14 */
  138. BERLIN_PINCTRL_GROUP("SD0_WP", 0x8, 0x3, 0x09,
  139. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO36 */
  140. BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* WP */
  141. BERLIN_PINCTRL_FUNCTION(0x2, "sts5"), /* VALD */
  142. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG15 */
  143. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG15 */
  144. BERLIN_PINCTRL_GROUP("STS0_CLK", 0x8, 0x3, 0x0c,
  145. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO21 */
  146. BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), /* CLK */
  147. BERLIN_PINCTRL_FUNCTION(0x2, "cpupll"), /* CLKO */
  148. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG0 */
  149. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG0 */
  150. BERLIN_PINCTRL_GROUP("STS0_SOP", 0x8, 0x3, 0x0f,
  151. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO22 */
  152. BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), /* SOP */
  153. BERLIN_PINCTRL_FUNCTION(0x2, "syspll"), /* CLKO */
  154. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG1 */
  155. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG1 */
  156. BERLIN_PINCTRL_GROUP("STS0_SD", 0x8, 0x3, 0x12,
  157. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO23 */
  158. BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), /* SD */
  159. BERLIN_PINCTRL_FUNCTION(0x2, "mempll"), /* CLKO */
  160. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG2 */
  161. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG2 */
  162. BERLIN_PINCTRL_GROUP("STS0_VALD", 0x8, 0x3, 0x15,
  163. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO24 */
  164. BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), /* VALD */
  165. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG3 */
  166. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG3 */
  167. BERLIN_PINCTRL_GROUP("STS1_CLK", 0x8, 0x3, 0x18,
  168. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO25 */
  169. BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), /* CLK */
  170. BERLIN_PINCTRL_FUNCTION(0x2, "pwm0"),
  171. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG4 */
  172. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG4 */
  173. BERLIN_PINCTRL_GROUP("STS1_SOP", 0x8, 0x3, 0x1b,
  174. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO26 */
  175. BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), /* SOP */
  176. BERLIN_PINCTRL_FUNCTION(0x2, "pwm1"),
  177. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG5 */
  178. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG5 */
  179. BERLIN_PINCTRL_GROUP("STS1_SD", 0xc, 0x3, 0x00,
  180. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO27 */
  181. BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), /* SD */
  182. BERLIN_PINCTRL_FUNCTION(0x2, "pwm2"),
  183. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG6 */
  184. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG6 */
  185. BERLIN_PINCTRL_GROUP("STS1_VALD", 0xc, 0x3, 0x03,
  186. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO28 */
  187. BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), /* VALD */
  188. BERLIN_PINCTRL_FUNCTION(0x2, "pwm3"),
  189. BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG7 */
  190. BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG7 */
  191. BERLIN_PINCTRL_GROUP("SCRD0_RST", 0xc, 0x3, 0x06,
  192. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO15 */
  193. BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* RST */
  194. BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* CLK */
  195. BERLIN_PINCTRL_GROUP("SCRD0_DCLK", 0xc, 0x3, 0x09,
  196. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO16 */
  197. BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* DCLK */
  198. BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* CMD */
  199. BERLIN_PINCTRL_GROUP("SCRD0_GPIO0", 0xc, 0x3, 0x0c,
  200. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO17 */
  201. BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* SCRD0 GPIO0 */
  202. BERLIN_PINCTRL_FUNCTION(0x2, "sif"), /* DIO */
  203. BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT0 */
  204. BERLIN_PINCTRL_GROUP("SCRD0_GPIO1", 0xc, 0x3, 0x0f,
  205. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO18 */
  206. BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* SCRD0 GPIO1 */
  207. BERLIN_PINCTRL_FUNCTION(0x2, "sif"), /* CLK */
  208. BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT1 */
  209. BERLIN_PINCTRL_GROUP("SCRD0_DIO", 0xc, 0x3, 0x12,
  210. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO19 */
  211. BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* DIO */
  212. BERLIN_PINCTRL_FUNCTION(0x2, "sif"), /* DEN */
  213. BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT2 */
  214. BERLIN_PINCTRL_GROUP("SCRD0_CRD_PRES", 0xc, 0x3, 0x15,
  215. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO20 */
  216. BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* crd pres */
  217. BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT3 */
  218. BERLIN_PINCTRL_GROUP("SPI1_SS0n", 0xc, 0x3, 0x18,
  219. BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS0n */
  220. BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO37 */
  221. BERLIN_PINCTRL_FUNCTION(0x2, "sts2")), /* CLK */
  222. BERLIN_PINCTRL_GROUP("SPI1_SS1n", 0xc, 0x3, 0x1b,
  223. BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS1n */
  224. BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO38 */
  225. BERLIN_PINCTRL_FUNCTION(0x2, "sts2"), /* SOP */
  226. BERLIN_PINCTRL_FUNCTION(0x4, "pwm1")),
  227. BERLIN_PINCTRL_GROUP("SPI1_SS2n", 0x10, 0x3, 0x00,
  228. BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS2n */
  229. BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO39 */
  230. BERLIN_PINCTRL_FUNCTION(0x2, "sts2"), /* SD */
  231. BERLIN_PINCTRL_FUNCTION(0x4, "pwm0")),
  232. BERLIN_PINCTRL_GROUP("SPI1_SS3n", 0x10, 0x3, 0x03,
  233. BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS3n */
  234. BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO40 */
  235. BERLIN_PINCTRL_FUNCTION(0x2, "sts2")), /* VALD */
  236. BERLIN_PINCTRL_GROUP("SPI1_SCLK", 0x10, 0x3, 0x06,
  237. BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SCLK */
  238. BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO41 */
  239. BERLIN_PINCTRL_FUNCTION(0x2, "sts3")), /* CLK */
  240. BERLIN_PINCTRL_GROUP("SPI1_SDO", 0x10, 0x3, 0x09,
  241. BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SDO */
  242. BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO42 */
  243. BERLIN_PINCTRL_FUNCTION(0x2, "sts3")), /* SOP */
  244. BERLIN_PINCTRL_GROUP("SPI1_SDI", 0x10, 0x3, 0x0c,
  245. BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SDI */
  246. BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO43 */
  247. BERLIN_PINCTRL_FUNCTION(0x2, "sts3")), /* SD */
  248. BERLIN_PINCTRL_GROUP("USB0_DRV_VBUS", 0x10, 0x3, 0x0f,
  249. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO44 */
  250. BERLIN_PINCTRL_FUNCTION(0x1, "usb0"), /* VBUS */
  251. BERLIN_PINCTRL_FUNCTION(0x2, "sts3")), /* VALD */
  252. BERLIN_PINCTRL_GROUP("TW0_SCL", 0x10, 0x3, 0x12,
  253. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO45 */
  254. BERLIN_PINCTRL_FUNCTION(0x1, "tw0")), /* SCL */
  255. BERLIN_PINCTRL_GROUP("TW0_SDA", 0x10, 0x3, 0x15,
  256. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO46 */
  257. BERLIN_PINCTRL_FUNCTION(0x1, "tw0")), /* SDA */
  258. };
  259. static const struct berlin_desc_group berlin4ct_avio_pinctrl_groups[] = {
  260. BERLIN_PINCTRL_GROUP("TX_EDDC_SCL", 0x0, 0x3, 0x00,
  261. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO0 */
  262. BERLIN_PINCTRL_FUNCTION(0x1, "tx_eddc"), /* SCL */
  263. BERLIN_PINCTRL_FUNCTION(0x2, "tw1")), /* SCL */
  264. BERLIN_PINCTRL_GROUP("TX_EDDC_SDA", 0x0, 0x3, 0x03,
  265. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO1 */
  266. BERLIN_PINCTRL_FUNCTION(0x1, "tx_eddc"), /* SDA */
  267. BERLIN_PINCTRL_FUNCTION(0x2, "tw1")), /* SDA */
  268. BERLIN_PINCTRL_GROUP("I2S1_LRCKO", 0x0, 0x3, 0x06,
  269. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO2 */
  270. BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* LRCKO */
  271. BERLIN_PINCTRL_FUNCTION(0x3, "sts6"), /* CLK */
  272. BERLIN_PINCTRL_FUNCTION(0x4, "adac"), /* DBG0 */
  273. BERLIN_PINCTRL_FUNCTION(0x6, "sd1b"), /* CLK */
  274. BERLIN_PINCTRL_FUNCTION(0x7, "avio")), /* DBG0 */
  275. BERLIN_PINCTRL_GROUP("I2S1_BCLKO", 0x0, 0x3, 0x09,
  276. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO3 */
  277. BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* BCLKO */
  278. BERLIN_PINCTRL_FUNCTION(0x3, "sts6"), /* SOP */
  279. BERLIN_PINCTRL_FUNCTION(0x4, "adac"), /* DBG1 */
  280. BERLIN_PINCTRL_FUNCTION(0x6, "sd1b"), /* CMD */
  281. BERLIN_PINCTRL_FUNCTION(0x7, "avio")), /* DBG1 */
  282. BERLIN_PINCTRL_GROUP("I2S1_DO", 0x0, 0x3, 0x0c,
  283. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO4 */
  284. BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* DO */
  285. BERLIN_PINCTRL_FUNCTION(0x3, "sts6"), /* SD */
  286. BERLIN_PINCTRL_FUNCTION(0x4, "adac"), /* DBG2 */
  287. BERLIN_PINCTRL_FUNCTION(0x6, "sd1b"), /* DAT0 */
  288. BERLIN_PINCTRL_FUNCTION(0x7, "avio")), /* DBG2 */
  289. BERLIN_PINCTRL_GROUP("I2S1_MCLK", 0x0, 0x3, 0x0f,
  290. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO5 */
  291. BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* MCLK */
  292. BERLIN_PINCTRL_FUNCTION(0x3, "sts6"), /* VALD */
  293. BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* MCLK */
  294. BERLIN_PINCTRL_FUNCTION(0x6, "sd1b"), /* DAT1 */
  295. BERLIN_PINCTRL_FUNCTION(0x7, "avio")), /* DBG3 */
  296. BERLIN_PINCTRL_GROUP("SPDIFO", 0x0, 0x3, 0x12,
  297. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO6 */
  298. BERLIN_PINCTRL_FUNCTION(0x1, "spdifo"),
  299. BERLIN_PINCTRL_FUNCTION(0x2, "avpll"), /* CLKO */
  300. BERLIN_PINCTRL_FUNCTION(0x4, "adac")), /* DBG3 */
  301. BERLIN_PINCTRL_GROUP("I2S2_MCLK", 0x0, 0x3, 0x15,
  302. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO7 */
  303. BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* MCLK */
  304. BERLIN_PINCTRL_FUNCTION(0x4, "hdmi"), /* FBCLK */
  305. BERLIN_PINCTRL_FUNCTION(0x5, "pdm")), /* CLKO */
  306. BERLIN_PINCTRL_GROUP("I2S2_LRCKI", 0x0, 0x3, 0x18,
  307. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO8 */
  308. BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* LRCKI */
  309. BERLIN_PINCTRL_FUNCTION(0x2, "pwm0"),
  310. BERLIN_PINCTRL_FUNCTION(0x3, "sts7"), /* CLK */
  311. BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* LRCK */
  312. BERLIN_PINCTRL_FUNCTION(0x6, "sd1b")), /* DAT2 */
  313. BERLIN_PINCTRL_GROUP("I2S2_BCLKI", 0x0, 0x3, 0x1b,
  314. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO9 */
  315. BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* BCLKI */
  316. BERLIN_PINCTRL_FUNCTION(0x2, "pwm1"),
  317. BERLIN_PINCTRL_FUNCTION(0x3, "sts7"), /* SOP */
  318. BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* BCLK */
  319. BERLIN_PINCTRL_FUNCTION(0x6, "sd1b")), /* DAT3 */
  320. BERLIN_PINCTRL_GROUP("I2S2_DI0", 0x4, 0x3, 0x00,
  321. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO10 */
  322. BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* DI0 */
  323. BERLIN_PINCTRL_FUNCTION(0x2, "pwm2"),
  324. BERLIN_PINCTRL_FUNCTION(0x3, "sts7"), /* SD */
  325. BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* SDIN */
  326. BERLIN_PINCTRL_FUNCTION(0x5, "pdm"), /* DI0 */
  327. BERLIN_PINCTRL_FUNCTION(0x6, "sd1b")), /* CDn */
  328. BERLIN_PINCTRL_GROUP("I2S2_DI1", 0x4, 0x3, 0x03,
  329. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO11 */
  330. BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* DI1 */
  331. BERLIN_PINCTRL_FUNCTION(0x2, "pwm3"),
  332. BERLIN_PINCTRL_FUNCTION(0x3, "sts7"), /* VALD */
  333. BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* PWMCLK */
  334. BERLIN_PINCTRL_FUNCTION(0x5, "pdm"), /* DI1 */
  335. BERLIN_PINCTRL_FUNCTION(0x6, "sd1b")), /* WP */
  336. };
  337. static const struct berlin_desc_group berlin4ct_sysmgr_pinctrl_groups[] = {
  338. BERLIN_PINCTRL_GROUP("SM_TW2_SCL", 0x0, 0x3, 0x00,
  339. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO19 */
  340. BERLIN_PINCTRL_FUNCTION(0x1, "tw2")), /* SCL */
  341. BERLIN_PINCTRL_GROUP("SM_TW2_SDA", 0x0, 0x3, 0x03,
  342. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO20 */
  343. BERLIN_PINCTRL_FUNCTION(0x1, "tw2")), /* SDA */
  344. BERLIN_PINCTRL_GROUP("SM_TW3_SCL", 0x0, 0x3, 0x06,
  345. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO21 */
  346. BERLIN_PINCTRL_FUNCTION(0x1, "tw3")), /* SCL */
  347. BERLIN_PINCTRL_GROUP("SM_TW3_SDA", 0x0, 0x3, 0x09,
  348. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO22 */
  349. BERLIN_PINCTRL_FUNCTION(0x1, "tw3")), /* SDA */
  350. BERLIN_PINCTRL_GROUP("SM_TMS", 0x0, 0x3, 0x0c,
  351. BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), /* TMS */
  352. BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* SM GPIO0 */
  353. BERLIN_PINCTRL_FUNCTION(0x2, "pwm0")),
  354. BERLIN_PINCTRL_GROUP("SM_TDI", 0x0, 0x3, 0x0f,
  355. BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), /* TDI */
  356. BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* SM GPIO1 */
  357. BERLIN_PINCTRL_FUNCTION(0x2, "pwm1")),
  358. BERLIN_PINCTRL_GROUP("SM_TDO", 0x0, 0x3, 0x12,
  359. BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), /* TDO */
  360. BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO2 */
  361. BERLIN_PINCTRL_GROUP("SM_URT0_TXD", 0x0, 0x3, 0x15,
  362. BERLIN_PINCTRL_FUNCTION(0x0, "uart0"), /* TXD */
  363. BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO3 */
  364. BERLIN_PINCTRL_GROUP("SM_URT0_RXD", 0x0, 0x3, 0x18,
  365. BERLIN_PINCTRL_FUNCTION(0x0, "uart0"), /* RXD */
  366. BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO4 */
  367. BERLIN_PINCTRL_GROUP("SM_URT1_TXD", 0x0, 0x3, 0x1b,
  368. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO5 */
  369. BERLIN_PINCTRL_FUNCTION(0x1, "uart1"), /* TXD */
  370. BERLIN_PINCTRL_FUNCTION(0x2, "eth1"), /* RXCLK */
  371. BERLIN_PINCTRL_FUNCTION(0x3, "pwm2"),
  372. BERLIN_PINCTRL_FUNCTION(0x4, "timer0"),
  373. BERLIN_PINCTRL_FUNCTION(0x5, "clk_25m")),
  374. BERLIN_PINCTRL_GROUP("SM_URT1_RXD", 0x4, 0x3, 0x00,
  375. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO6 */
  376. BERLIN_PINCTRL_FUNCTION(0x1, "uart1"), /* RXD */
  377. BERLIN_PINCTRL_FUNCTION(0x3, "pwm3"),
  378. BERLIN_PINCTRL_FUNCTION(0x4, "timer1")),
  379. BERLIN_PINCTRL_GROUP("SM_SPI2_SS0n", 0x4, 0x3, 0x03,
  380. BERLIN_PINCTRL_FUNCTION(0x0, "spi2"), /* SS0 n*/
  381. BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO7 */
  382. BERLIN_PINCTRL_GROUP("SM_SPI2_SS1n", 0x4, 0x3, 0x06,
  383. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO8 */
  384. BERLIN_PINCTRL_FUNCTION(0x1, "spi2")), /* SS1n */
  385. BERLIN_PINCTRL_GROUP("SM_SPI2_SS2n", 0x4, 0x3, 0x09,
  386. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO9 */
  387. BERLIN_PINCTRL_FUNCTION(0x1, "spi2"), /* SS2n */
  388. BERLIN_PINCTRL_FUNCTION(0x2, "eth1"), /* MDC */
  389. BERLIN_PINCTRL_FUNCTION(0x3, "pwm0"),
  390. BERLIN_PINCTRL_FUNCTION(0x4, "timer0"),
  391. BERLIN_PINCTRL_FUNCTION(0x5, "clk_25m")),
  392. BERLIN_PINCTRL_GROUP("SM_SPI2_SS3n", 0x4, 0x3, 0x0c,
  393. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO10 */
  394. BERLIN_PINCTRL_FUNCTION(0x1, "spi2"), /* SS3n */
  395. BERLIN_PINCTRL_FUNCTION(0x2, "eth1"), /* MDIO */
  396. BERLIN_PINCTRL_FUNCTION(0x3, "pwm1"),
  397. BERLIN_PINCTRL_FUNCTION(0x4, "timer1")),
  398. BERLIN_PINCTRL_GROUP("SM_SPI2_SDO", 0x4, 0x3, 0x0f,
  399. BERLIN_PINCTRL_FUNCTION(0x0, "spi2"), /* SDO */
  400. BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO11 */
  401. BERLIN_PINCTRL_GROUP("SM_SPI2_SDI", 0x4, 0x3, 0x12,
  402. BERLIN_PINCTRL_FUNCTION(0x0, "spi2"), /* SDI */
  403. BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO12 */
  404. BERLIN_PINCTRL_GROUP("SM_SPI2_SCLK", 0x4, 0x3, 0x15,
  405. BERLIN_PINCTRL_FUNCTION(0x0, "spi2"), /* SCLK */
  406. BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO13 */
  407. BERLIN_PINCTRL_GROUP("SM_FE_LED0", 0x4, 0x3, 0x18,
  408. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO14 */
  409. BERLIN_PINCTRL_FUNCTION(0x2, "led")), /* LED0 */
  410. BERLIN_PINCTRL_GROUP("SM_FE_LED1", 0x4, 0x3, 0x1b,
  411. BERLIN_PINCTRL_FUNCTION(0x0, "pwr"),
  412. BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* SM GPIO 15 */
  413. BERLIN_PINCTRL_FUNCTION(0x2, "led")), /* LED1 */
  414. BERLIN_PINCTRL_GROUP("SM_FE_LED2", 0x8, 0x3, 0x00,
  415. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO16 */
  416. BERLIN_PINCTRL_FUNCTION(0x2, "led")), /* LED2 */
  417. BERLIN_PINCTRL_GROUP("SM_HDMI_HPD", 0x8, 0x3, 0x03,
  418. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO17 */
  419. BERLIN_PINCTRL_FUNCTION(0x1, "hdmi")), /* HPD */
  420. BERLIN_PINCTRL_GROUP("SM_HDMI_CEC", 0x8, 0x3, 0x06,
  421. BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO18 */
  422. BERLIN_PINCTRL_FUNCTION(0x1, "hdmi")), /* CEC */
  423. };
  424. static const struct berlin_pinctrl_desc berlin4ct_soc_pinctrl_data = {
  425. .groups = berlin4ct_soc_pinctrl_groups,
  426. .ngroups = ARRAY_SIZE(berlin4ct_soc_pinctrl_groups),
  427. };
  428. static const struct berlin_pinctrl_desc berlin4ct_avio_pinctrl_data = {
  429. .groups = berlin4ct_avio_pinctrl_groups,
  430. .ngroups = ARRAY_SIZE(berlin4ct_avio_pinctrl_groups),
  431. };
  432. static const struct berlin_pinctrl_desc berlin4ct_sysmgr_pinctrl_data = {
  433. .groups = berlin4ct_sysmgr_pinctrl_groups,
  434. .ngroups = ARRAY_SIZE(berlin4ct_sysmgr_pinctrl_groups),
  435. };
  436. static const struct of_device_id berlin4ct_pinctrl_match[] = {
  437. {
  438. .compatible = "marvell,berlin4ct-soc-pinctrl",
  439. .data = &berlin4ct_soc_pinctrl_data,
  440. },
  441. {
  442. .compatible = "marvell,berlin4ct-avio-pinctrl",
  443. .data = &berlin4ct_avio_pinctrl_data,
  444. },
  445. {
  446. .compatible = "marvell,berlin4ct-system-pinctrl",
  447. .data = &berlin4ct_sysmgr_pinctrl_data,
  448. },
  449. {}
  450. };
  451. static int berlin4ct_pinctrl_probe(struct platform_device *pdev)
  452. {
  453. const struct of_device_id *match =
  454. of_match_device(berlin4ct_pinctrl_match, &pdev->dev);
  455. struct regmap_config *rmconfig;
  456. struct regmap *regmap;
  457. struct resource *res;
  458. void __iomem *base;
  459. rmconfig = devm_kzalloc(&pdev->dev, sizeof(*rmconfig), GFP_KERNEL);
  460. if (!rmconfig)
  461. return -ENOMEM;
  462. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  463. base = devm_ioremap_resource(&pdev->dev, res);
  464. if (IS_ERR(base))
  465. return PTR_ERR(base);
  466. rmconfig->reg_bits = 32,
  467. rmconfig->val_bits = 32,
  468. rmconfig->reg_stride = 4,
  469. rmconfig->max_register = resource_size(res);
  470. regmap = devm_regmap_init_mmio(&pdev->dev, base, rmconfig);
  471. if (IS_ERR(regmap))
  472. return PTR_ERR(regmap);
  473. return berlin_pinctrl_probe_regmap(pdev, match->data, regmap);
  474. }
  475. static struct platform_driver berlin4ct_pinctrl_driver = {
  476. .probe = berlin4ct_pinctrl_probe,
  477. .driver = {
  478. .name = "berlin4ct-pinctrl",
  479. .of_match_table = berlin4ct_pinctrl_match,
  480. },
  481. };
  482. builtin_platform_driver(berlin4ct_pinctrl_driver);