pinctrl-bcm281xx.c 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455
  1. /*
  2. * Copyright (C) 2013 Broadcom Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation version 2.
  7. *
  8. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  9. * kind, whether express or implied; without even the implied warranty
  10. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/err.h>
  14. #include <linux/io.h>
  15. #include <linux/module.h>
  16. #include <linux/of.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/pinctrl/pinctrl.h>
  19. #include <linux/pinctrl/pinmux.h>
  20. #include <linux/pinctrl/pinconf.h>
  21. #include <linux/pinctrl/pinconf-generic.h>
  22. #include <linux/regmap.h>
  23. #include <linux/slab.h>
  24. #include "../core.h"
  25. #include "../pinctrl-utils.h"
  26. /* BCM281XX Pin Control Registers Definitions */
  27. /* Function Select bits are the same for all pin control registers */
  28. #define BCM281XX_PIN_REG_F_SEL_MASK 0x0700
  29. #define BCM281XX_PIN_REG_F_SEL_SHIFT 8
  30. /* Standard pin register */
  31. #define BCM281XX_STD_PIN_REG_DRV_STR_MASK 0x0007
  32. #define BCM281XX_STD_PIN_REG_DRV_STR_SHIFT 0
  33. #define BCM281XX_STD_PIN_REG_INPUT_DIS_MASK 0x0008
  34. #define BCM281XX_STD_PIN_REG_INPUT_DIS_SHIFT 3
  35. #define BCM281XX_STD_PIN_REG_SLEW_MASK 0x0010
  36. #define BCM281XX_STD_PIN_REG_SLEW_SHIFT 4
  37. #define BCM281XX_STD_PIN_REG_PULL_UP_MASK 0x0020
  38. #define BCM281XX_STD_PIN_REG_PULL_UP_SHIFT 5
  39. #define BCM281XX_STD_PIN_REG_PULL_DN_MASK 0x0040
  40. #define BCM281XX_STD_PIN_REG_PULL_DN_SHIFT 6
  41. #define BCM281XX_STD_PIN_REG_HYST_MASK 0x0080
  42. #define BCM281XX_STD_PIN_REG_HYST_SHIFT 7
  43. /* I2C pin register */
  44. #define BCM281XX_I2C_PIN_REG_INPUT_DIS_MASK 0x0004
  45. #define BCM281XX_I2C_PIN_REG_INPUT_DIS_SHIFT 2
  46. #define BCM281XX_I2C_PIN_REG_SLEW_MASK 0x0008
  47. #define BCM281XX_I2C_PIN_REG_SLEW_SHIFT 3
  48. #define BCM281XX_I2C_PIN_REG_PULL_UP_STR_MASK 0x0070
  49. #define BCM281XX_I2C_PIN_REG_PULL_UP_STR_SHIFT 4
  50. /* HDMI pin register */
  51. #define BCM281XX_HDMI_PIN_REG_INPUT_DIS_MASK 0x0008
  52. #define BCM281XX_HDMI_PIN_REG_INPUT_DIS_SHIFT 3
  53. #define BCM281XX_HDMI_PIN_REG_MODE_MASK 0x0010
  54. #define BCM281XX_HDMI_PIN_REG_MODE_SHIFT 4
  55. /**
  56. * bcm281xx_pin_type - types of pin register
  57. */
  58. enum bcm281xx_pin_type {
  59. BCM281XX_PIN_TYPE_UNKNOWN = 0,
  60. BCM281XX_PIN_TYPE_STD,
  61. BCM281XX_PIN_TYPE_I2C,
  62. BCM281XX_PIN_TYPE_HDMI,
  63. };
  64. static enum bcm281xx_pin_type std_pin = BCM281XX_PIN_TYPE_STD;
  65. static enum bcm281xx_pin_type i2c_pin = BCM281XX_PIN_TYPE_I2C;
  66. static enum bcm281xx_pin_type hdmi_pin = BCM281XX_PIN_TYPE_HDMI;
  67. /**
  68. * bcm281xx_pin_function- define pin function
  69. */
  70. struct bcm281xx_pin_function {
  71. const char *name;
  72. const char * const *groups;
  73. const unsigned ngroups;
  74. };
  75. /**
  76. * bcm281xx_pinctrl_data - Broadcom-specific pinctrl data
  77. * @reg_base - base of pinctrl registers
  78. */
  79. struct bcm281xx_pinctrl_data {
  80. void __iomem *reg_base;
  81. /* List of all pins */
  82. const struct pinctrl_pin_desc *pins;
  83. const unsigned npins;
  84. const struct bcm281xx_pin_function *functions;
  85. const unsigned nfunctions;
  86. struct regmap *regmap;
  87. };
  88. /*
  89. * Pin number definition. The order here must be the same as defined in the
  90. * PADCTRLREG block in the RDB.
  91. */
  92. #define BCM281XX_PIN_ADCSYNC 0
  93. #define BCM281XX_PIN_BAT_RM 1
  94. #define BCM281XX_PIN_BSC1_SCL 2
  95. #define BCM281XX_PIN_BSC1_SDA 3
  96. #define BCM281XX_PIN_BSC2_SCL 4
  97. #define BCM281XX_PIN_BSC2_SDA 5
  98. #define BCM281XX_PIN_CLASSGPWR 6
  99. #define BCM281XX_PIN_CLK_CX8 7
  100. #define BCM281XX_PIN_CLKOUT_0 8
  101. #define BCM281XX_PIN_CLKOUT_1 9
  102. #define BCM281XX_PIN_CLKOUT_2 10
  103. #define BCM281XX_PIN_CLKOUT_3 11
  104. #define BCM281XX_PIN_CLKREQ_IN_0 12
  105. #define BCM281XX_PIN_CLKREQ_IN_1 13
  106. #define BCM281XX_PIN_CWS_SYS_REQ1 14
  107. #define BCM281XX_PIN_CWS_SYS_REQ2 15
  108. #define BCM281XX_PIN_CWS_SYS_REQ3 16
  109. #define BCM281XX_PIN_DIGMIC1_CLK 17
  110. #define BCM281XX_PIN_DIGMIC1_DQ 18
  111. #define BCM281XX_PIN_DIGMIC2_CLK 19
  112. #define BCM281XX_PIN_DIGMIC2_DQ 20
  113. #define BCM281XX_PIN_GPEN13 21
  114. #define BCM281XX_PIN_GPEN14 22
  115. #define BCM281XX_PIN_GPEN15 23
  116. #define BCM281XX_PIN_GPIO00 24
  117. #define BCM281XX_PIN_GPIO01 25
  118. #define BCM281XX_PIN_GPIO02 26
  119. #define BCM281XX_PIN_GPIO03 27
  120. #define BCM281XX_PIN_GPIO04 28
  121. #define BCM281XX_PIN_GPIO05 29
  122. #define BCM281XX_PIN_GPIO06 30
  123. #define BCM281XX_PIN_GPIO07 31
  124. #define BCM281XX_PIN_GPIO08 32
  125. #define BCM281XX_PIN_GPIO09 33
  126. #define BCM281XX_PIN_GPIO10 34
  127. #define BCM281XX_PIN_GPIO11 35
  128. #define BCM281XX_PIN_GPIO12 36
  129. #define BCM281XX_PIN_GPIO13 37
  130. #define BCM281XX_PIN_GPIO14 38
  131. #define BCM281XX_PIN_GPS_PABLANK 39
  132. #define BCM281XX_PIN_GPS_TMARK 40
  133. #define BCM281XX_PIN_HDMI_SCL 41
  134. #define BCM281XX_PIN_HDMI_SDA 42
  135. #define BCM281XX_PIN_IC_DM 43
  136. #define BCM281XX_PIN_IC_DP 44
  137. #define BCM281XX_PIN_KP_COL_IP_0 45
  138. #define BCM281XX_PIN_KP_COL_IP_1 46
  139. #define BCM281XX_PIN_KP_COL_IP_2 47
  140. #define BCM281XX_PIN_KP_COL_IP_3 48
  141. #define BCM281XX_PIN_KP_ROW_OP_0 49
  142. #define BCM281XX_PIN_KP_ROW_OP_1 50
  143. #define BCM281XX_PIN_KP_ROW_OP_2 51
  144. #define BCM281XX_PIN_KP_ROW_OP_3 52
  145. #define BCM281XX_PIN_LCD_B_0 53
  146. #define BCM281XX_PIN_LCD_B_1 54
  147. #define BCM281XX_PIN_LCD_B_2 55
  148. #define BCM281XX_PIN_LCD_B_3 56
  149. #define BCM281XX_PIN_LCD_B_4 57
  150. #define BCM281XX_PIN_LCD_B_5 58
  151. #define BCM281XX_PIN_LCD_B_6 59
  152. #define BCM281XX_PIN_LCD_B_7 60
  153. #define BCM281XX_PIN_LCD_G_0 61
  154. #define BCM281XX_PIN_LCD_G_1 62
  155. #define BCM281XX_PIN_LCD_G_2 63
  156. #define BCM281XX_PIN_LCD_G_3 64
  157. #define BCM281XX_PIN_LCD_G_4 65
  158. #define BCM281XX_PIN_LCD_G_5 66
  159. #define BCM281XX_PIN_LCD_G_6 67
  160. #define BCM281XX_PIN_LCD_G_7 68
  161. #define BCM281XX_PIN_LCD_HSYNC 69
  162. #define BCM281XX_PIN_LCD_OE 70
  163. #define BCM281XX_PIN_LCD_PCLK 71
  164. #define BCM281XX_PIN_LCD_R_0 72
  165. #define BCM281XX_PIN_LCD_R_1 73
  166. #define BCM281XX_PIN_LCD_R_2 74
  167. #define BCM281XX_PIN_LCD_R_3 75
  168. #define BCM281XX_PIN_LCD_R_4 76
  169. #define BCM281XX_PIN_LCD_R_5 77
  170. #define BCM281XX_PIN_LCD_R_6 78
  171. #define BCM281XX_PIN_LCD_R_7 79
  172. #define BCM281XX_PIN_LCD_VSYNC 80
  173. #define BCM281XX_PIN_MDMGPIO0 81
  174. #define BCM281XX_PIN_MDMGPIO1 82
  175. #define BCM281XX_PIN_MDMGPIO2 83
  176. #define BCM281XX_PIN_MDMGPIO3 84
  177. #define BCM281XX_PIN_MDMGPIO4 85
  178. #define BCM281XX_PIN_MDMGPIO5 86
  179. #define BCM281XX_PIN_MDMGPIO6 87
  180. #define BCM281XX_PIN_MDMGPIO7 88
  181. #define BCM281XX_PIN_MDMGPIO8 89
  182. #define BCM281XX_PIN_MPHI_DATA_0 90
  183. #define BCM281XX_PIN_MPHI_DATA_1 91
  184. #define BCM281XX_PIN_MPHI_DATA_2 92
  185. #define BCM281XX_PIN_MPHI_DATA_3 93
  186. #define BCM281XX_PIN_MPHI_DATA_4 94
  187. #define BCM281XX_PIN_MPHI_DATA_5 95
  188. #define BCM281XX_PIN_MPHI_DATA_6 96
  189. #define BCM281XX_PIN_MPHI_DATA_7 97
  190. #define BCM281XX_PIN_MPHI_DATA_8 98
  191. #define BCM281XX_PIN_MPHI_DATA_9 99
  192. #define BCM281XX_PIN_MPHI_DATA_10 100
  193. #define BCM281XX_PIN_MPHI_DATA_11 101
  194. #define BCM281XX_PIN_MPHI_DATA_12 102
  195. #define BCM281XX_PIN_MPHI_DATA_13 103
  196. #define BCM281XX_PIN_MPHI_DATA_14 104
  197. #define BCM281XX_PIN_MPHI_DATA_15 105
  198. #define BCM281XX_PIN_MPHI_HA0 106
  199. #define BCM281XX_PIN_MPHI_HAT0 107
  200. #define BCM281XX_PIN_MPHI_HAT1 108
  201. #define BCM281XX_PIN_MPHI_HCE0_N 109
  202. #define BCM281XX_PIN_MPHI_HCE1_N 110
  203. #define BCM281XX_PIN_MPHI_HRD_N 111
  204. #define BCM281XX_PIN_MPHI_HWR_N 112
  205. #define BCM281XX_PIN_MPHI_RUN0 113
  206. #define BCM281XX_PIN_MPHI_RUN1 114
  207. #define BCM281XX_PIN_MTX_SCAN_CLK 115
  208. #define BCM281XX_PIN_MTX_SCAN_DATA 116
  209. #define BCM281XX_PIN_NAND_AD_0 117
  210. #define BCM281XX_PIN_NAND_AD_1 118
  211. #define BCM281XX_PIN_NAND_AD_2 119
  212. #define BCM281XX_PIN_NAND_AD_3 120
  213. #define BCM281XX_PIN_NAND_AD_4 121
  214. #define BCM281XX_PIN_NAND_AD_5 122
  215. #define BCM281XX_PIN_NAND_AD_6 123
  216. #define BCM281XX_PIN_NAND_AD_7 124
  217. #define BCM281XX_PIN_NAND_ALE 125
  218. #define BCM281XX_PIN_NAND_CEN_0 126
  219. #define BCM281XX_PIN_NAND_CEN_1 127
  220. #define BCM281XX_PIN_NAND_CLE 128
  221. #define BCM281XX_PIN_NAND_OEN 129
  222. #define BCM281XX_PIN_NAND_RDY_0 130
  223. #define BCM281XX_PIN_NAND_RDY_1 131
  224. #define BCM281XX_PIN_NAND_WEN 132
  225. #define BCM281XX_PIN_NAND_WP 133
  226. #define BCM281XX_PIN_PC1 134
  227. #define BCM281XX_PIN_PC2 135
  228. #define BCM281XX_PIN_PMU_INT 136
  229. #define BCM281XX_PIN_PMU_SCL 137
  230. #define BCM281XX_PIN_PMU_SDA 138
  231. #define BCM281XX_PIN_RFST2G_MTSLOTEN3G 139
  232. #define BCM281XX_PIN_RGMII_0_RX_CTL 140
  233. #define BCM281XX_PIN_RGMII_0_RXC 141
  234. #define BCM281XX_PIN_RGMII_0_RXD_0 142
  235. #define BCM281XX_PIN_RGMII_0_RXD_1 143
  236. #define BCM281XX_PIN_RGMII_0_RXD_2 144
  237. #define BCM281XX_PIN_RGMII_0_RXD_3 145
  238. #define BCM281XX_PIN_RGMII_0_TX_CTL 146
  239. #define BCM281XX_PIN_RGMII_0_TXC 147
  240. #define BCM281XX_PIN_RGMII_0_TXD_0 148
  241. #define BCM281XX_PIN_RGMII_0_TXD_1 149
  242. #define BCM281XX_PIN_RGMII_0_TXD_2 150
  243. #define BCM281XX_PIN_RGMII_0_TXD_3 151
  244. #define BCM281XX_PIN_RGMII_1_RX_CTL 152
  245. #define BCM281XX_PIN_RGMII_1_RXC 153
  246. #define BCM281XX_PIN_RGMII_1_RXD_0 154
  247. #define BCM281XX_PIN_RGMII_1_RXD_1 155
  248. #define BCM281XX_PIN_RGMII_1_RXD_2 156
  249. #define BCM281XX_PIN_RGMII_1_RXD_3 157
  250. #define BCM281XX_PIN_RGMII_1_TX_CTL 158
  251. #define BCM281XX_PIN_RGMII_1_TXC 159
  252. #define BCM281XX_PIN_RGMII_1_TXD_0 160
  253. #define BCM281XX_PIN_RGMII_1_TXD_1 161
  254. #define BCM281XX_PIN_RGMII_1_TXD_2 162
  255. #define BCM281XX_PIN_RGMII_1_TXD_3 163
  256. #define BCM281XX_PIN_RGMII_GPIO_0 164
  257. #define BCM281XX_PIN_RGMII_GPIO_1 165
  258. #define BCM281XX_PIN_RGMII_GPIO_2 166
  259. #define BCM281XX_PIN_RGMII_GPIO_3 167
  260. #define BCM281XX_PIN_RTXDATA2G_TXDATA3G1 168
  261. #define BCM281XX_PIN_RTXEN2G_TXDATA3G2 169
  262. #define BCM281XX_PIN_RXDATA3G0 170
  263. #define BCM281XX_PIN_RXDATA3G1 171
  264. #define BCM281XX_PIN_RXDATA3G2 172
  265. #define BCM281XX_PIN_SDIO1_CLK 173
  266. #define BCM281XX_PIN_SDIO1_CMD 174
  267. #define BCM281XX_PIN_SDIO1_DATA_0 175
  268. #define BCM281XX_PIN_SDIO1_DATA_1 176
  269. #define BCM281XX_PIN_SDIO1_DATA_2 177
  270. #define BCM281XX_PIN_SDIO1_DATA_3 178
  271. #define BCM281XX_PIN_SDIO4_CLK 179
  272. #define BCM281XX_PIN_SDIO4_CMD 180
  273. #define BCM281XX_PIN_SDIO4_DATA_0 181
  274. #define BCM281XX_PIN_SDIO4_DATA_1 182
  275. #define BCM281XX_PIN_SDIO4_DATA_2 183
  276. #define BCM281XX_PIN_SDIO4_DATA_3 184
  277. #define BCM281XX_PIN_SIM_CLK 185
  278. #define BCM281XX_PIN_SIM_DATA 186
  279. #define BCM281XX_PIN_SIM_DET 187
  280. #define BCM281XX_PIN_SIM_RESETN 188
  281. #define BCM281XX_PIN_SIM2_CLK 189
  282. #define BCM281XX_PIN_SIM2_DATA 190
  283. #define BCM281XX_PIN_SIM2_DET 191
  284. #define BCM281XX_PIN_SIM2_RESETN 192
  285. #define BCM281XX_PIN_SRI_C 193
  286. #define BCM281XX_PIN_SRI_D 194
  287. #define BCM281XX_PIN_SRI_E 195
  288. #define BCM281XX_PIN_SSP_EXTCLK 196
  289. #define BCM281XX_PIN_SSP0_CLK 197
  290. #define BCM281XX_PIN_SSP0_FS 198
  291. #define BCM281XX_PIN_SSP0_RXD 199
  292. #define BCM281XX_PIN_SSP0_TXD 200
  293. #define BCM281XX_PIN_SSP2_CLK 201
  294. #define BCM281XX_PIN_SSP2_FS_0 202
  295. #define BCM281XX_PIN_SSP2_FS_1 203
  296. #define BCM281XX_PIN_SSP2_FS_2 204
  297. #define BCM281XX_PIN_SSP2_FS_3 205
  298. #define BCM281XX_PIN_SSP2_RXD_0 206
  299. #define BCM281XX_PIN_SSP2_RXD_1 207
  300. #define BCM281XX_PIN_SSP2_TXD_0 208
  301. #define BCM281XX_PIN_SSP2_TXD_1 209
  302. #define BCM281XX_PIN_SSP3_CLK 210
  303. #define BCM281XX_PIN_SSP3_FS 211
  304. #define BCM281XX_PIN_SSP3_RXD 212
  305. #define BCM281XX_PIN_SSP3_TXD 213
  306. #define BCM281XX_PIN_SSP4_CLK 214
  307. #define BCM281XX_PIN_SSP4_FS 215
  308. #define BCM281XX_PIN_SSP4_RXD 216
  309. #define BCM281XX_PIN_SSP4_TXD 217
  310. #define BCM281XX_PIN_SSP5_CLK 218
  311. #define BCM281XX_PIN_SSP5_FS 219
  312. #define BCM281XX_PIN_SSP5_RXD 220
  313. #define BCM281XX_PIN_SSP5_TXD 221
  314. #define BCM281XX_PIN_SSP6_CLK 222
  315. #define BCM281XX_PIN_SSP6_FS 223
  316. #define BCM281XX_PIN_SSP6_RXD 224
  317. #define BCM281XX_PIN_SSP6_TXD 225
  318. #define BCM281XX_PIN_STAT_1 226
  319. #define BCM281XX_PIN_STAT_2 227
  320. #define BCM281XX_PIN_SYSCLKEN 228
  321. #define BCM281XX_PIN_TRACECLK 229
  322. #define BCM281XX_PIN_TRACEDT00 230
  323. #define BCM281XX_PIN_TRACEDT01 231
  324. #define BCM281XX_PIN_TRACEDT02 232
  325. #define BCM281XX_PIN_TRACEDT03 233
  326. #define BCM281XX_PIN_TRACEDT04 234
  327. #define BCM281XX_PIN_TRACEDT05 235
  328. #define BCM281XX_PIN_TRACEDT06 236
  329. #define BCM281XX_PIN_TRACEDT07 237
  330. #define BCM281XX_PIN_TRACEDT08 238
  331. #define BCM281XX_PIN_TRACEDT09 239
  332. #define BCM281XX_PIN_TRACEDT10 240
  333. #define BCM281XX_PIN_TRACEDT11 241
  334. #define BCM281XX_PIN_TRACEDT12 242
  335. #define BCM281XX_PIN_TRACEDT13 243
  336. #define BCM281XX_PIN_TRACEDT14 244
  337. #define BCM281XX_PIN_TRACEDT15 245
  338. #define BCM281XX_PIN_TXDATA3G0 246
  339. #define BCM281XX_PIN_TXPWRIND 247
  340. #define BCM281XX_PIN_UARTB1_UCTS 248
  341. #define BCM281XX_PIN_UARTB1_URTS 249
  342. #define BCM281XX_PIN_UARTB1_URXD 250
  343. #define BCM281XX_PIN_UARTB1_UTXD 251
  344. #define BCM281XX_PIN_UARTB2_URXD 252
  345. #define BCM281XX_PIN_UARTB2_UTXD 253
  346. #define BCM281XX_PIN_UARTB3_UCTS 254
  347. #define BCM281XX_PIN_UARTB3_URTS 255
  348. #define BCM281XX_PIN_UARTB3_URXD 256
  349. #define BCM281XX_PIN_UARTB3_UTXD 257
  350. #define BCM281XX_PIN_UARTB4_UCTS 258
  351. #define BCM281XX_PIN_UARTB4_URTS 259
  352. #define BCM281XX_PIN_UARTB4_URXD 260
  353. #define BCM281XX_PIN_UARTB4_UTXD 261
  354. #define BCM281XX_PIN_VC_CAM1_SCL 262
  355. #define BCM281XX_PIN_VC_CAM1_SDA 263
  356. #define BCM281XX_PIN_VC_CAM2_SCL 264
  357. #define BCM281XX_PIN_VC_CAM2_SDA 265
  358. #define BCM281XX_PIN_VC_CAM3_SCL 266
  359. #define BCM281XX_PIN_VC_CAM3_SDA 267
  360. #define BCM281XX_PIN_DESC(a, b, c) \
  361. { .number = a, .name = b, .drv_data = &c##_pin }
  362. /*
  363. * Pin description definition. The order here must be the same as defined in
  364. * the PADCTRLREG block in the RDB, since the pin number is used as an index
  365. * into this array.
  366. */
  367. static const struct pinctrl_pin_desc bcm281xx_pinctrl_pins[] = {
  368. BCM281XX_PIN_DESC(BCM281XX_PIN_ADCSYNC, "adcsync", std),
  369. BCM281XX_PIN_DESC(BCM281XX_PIN_BAT_RM, "bat_rm", std),
  370. BCM281XX_PIN_DESC(BCM281XX_PIN_BSC1_SCL, "bsc1_scl", i2c),
  371. BCM281XX_PIN_DESC(BCM281XX_PIN_BSC1_SDA, "bsc1_sda", i2c),
  372. BCM281XX_PIN_DESC(BCM281XX_PIN_BSC2_SCL, "bsc2_scl", i2c),
  373. BCM281XX_PIN_DESC(BCM281XX_PIN_BSC2_SDA, "bsc2_sda", i2c),
  374. BCM281XX_PIN_DESC(BCM281XX_PIN_CLASSGPWR, "classgpwr", std),
  375. BCM281XX_PIN_DESC(BCM281XX_PIN_CLK_CX8, "clk_cx8", std),
  376. BCM281XX_PIN_DESC(BCM281XX_PIN_CLKOUT_0, "clkout_0", std),
  377. BCM281XX_PIN_DESC(BCM281XX_PIN_CLKOUT_1, "clkout_1", std),
  378. BCM281XX_PIN_DESC(BCM281XX_PIN_CLKOUT_2, "clkout_2", std),
  379. BCM281XX_PIN_DESC(BCM281XX_PIN_CLKOUT_3, "clkout_3", std),
  380. BCM281XX_PIN_DESC(BCM281XX_PIN_CLKREQ_IN_0, "clkreq_in_0", std),
  381. BCM281XX_PIN_DESC(BCM281XX_PIN_CLKREQ_IN_1, "clkreq_in_1", std),
  382. BCM281XX_PIN_DESC(BCM281XX_PIN_CWS_SYS_REQ1, "cws_sys_req1", std),
  383. BCM281XX_PIN_DESC(BCM281XX_PIN_CWS_SYS_REQ2, "cws_sys_req2", std),
  384. BCM281XX_PIN_DESC(BCM281XX_PIN_CWS_SYS_REQ3, "cws_sys_req3", std),
  385. BCM281XX_PIN_DESC(BCM281XX_PIN_DIGMIC1_CLK, "digmic1_clk", std),
  386. BCM281XX_PIN_DESC(BCM281XX_PIN_DIGMIC1_DQ, "digmic1_dq", std),
  387. BCM281XX_PIN_DESC(BCM281XX_PIN_DIGMIC2_CLK, "digmic2_clk", std),
  388. BCM281XX_PIN_DESC(BCM281XX_PIN_DIGMIC2_DQ, "digmic2_dq", std),
  389. BCM281XX_PIN_DESC(BCM281XX_PIN_GPEN13, "gpen13", std),
  390. BCM281XX_PIN_DESC(BCM281XX_PIN_GPEN14, "gpen14", std),
  391. BCM281XX_PIN_DESC(BCM281XX_PIN_GPEN15, "gpen15", std),
  392. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO00, "gpio00", std),
  393. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO01, "gpio01", std),
  394. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO02, "gpio02", std),
  395. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO03, "gpio03", std),
  396. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO04, "gpio04", std),
  397. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO05, "gpio05", std),
  398. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO06, "gpio06", std),
  399. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO07, "gpio07", std),
  400. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO08, "gpio08", std),
  401. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO09, "gpio09", std),
  402. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO10, "gpio10", std),
  403. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO11, "gpio11", std),
  404. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO12, "gpio12", std),
  405. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO13, "gpio13", std),
  406. BCM281XX_PIN_DESC(BCM281XX_PIN_GPIO14, "gpio14", std),
  407. BCM281XX_PIN_DESC(BCM281XX_PIN_GPS_PABLANK, "gps_pablank", std),
  408. BCM281XX_PIN_DESC(BCM281XX_PIN_GPS_TMARK, "gps_tmark", std),
  409. BCM281XX_PIN_DESC(BCM281XX_PIN_HDMI_SCL, "hdmi_scl", hdmi),
  410. BCM281XX_PIN_DESC(BCM281XX_PIN_HDMI_SDA, "hdmi_sda", hdmi),
  411. BCM281XX_PIN_DESC(BCM281XX_PIN_IC_DM, "ic_dm", std),
  412. BCM281XX_PIN_DESC(BCM281XX_PIN_IC_DP, "ic_dp", std),
  413. BCM281XX_PIN_DESC(BCM281XX_PIN_KP_COL_IP_0, "kp_col_ip_0", std),
  414. BCM281XX_PIN_DESC(BCM281XX_PIN_KP_COL_IP_1, "kp_col_ip_1", std),
  415. BCM281XX_PIN_DESC(BCM281XX_PIN_KP_COL_IP_2, "kp_col_ip_2", std),
  416. BCM281XX_PIN_DESC(BCM281XX_PIN_KP_COL_IP_3, "kp_col_ip_3", std),
  417. BCM281XX_PIN_DESC(BCM281XX_PIN_KP_ROW_OP_0, "kp_row_op_0", std),
  418. BCM281XX_PIN_DESC(BCM281XX_PIN_KP_ROW_OP_1, "kp_row_op_1", std),
  419. BCM281XX_PIN_DESC(BCM281XX_PIN_KP_ROW_OP_2, "kp_row_op_2", std),
  420. BCM281XX_PIN_DESC(BCM281XX_PIN_KP_ROW_OP_3, "kp_row_op_3", std),
  421. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_B_0, "lcd_b_0", std),
  422. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_B_1, "lcd_b_1", std),
  423. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_B_2, "lcd_b_2", std),
  424. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_B_3, "lcd_b_3", std),
  425. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_B_4, "lcd_b_4", std),
  426. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_B_5, "lcd_b_5", std),
  427. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_B_6, "lcd_b_6", std),
  428. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_B_7, "lcd_b_7", std),
  429. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_G_0, "lcd_g_0", std),
  430. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_G_1, "lcd_g_1", std),
  431. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_G_2, "lcd_g_2", std),
  432. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_G_3, "lcd_g_3", std),
  433. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_G_4, "lcd_g_4", std),
  434. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_G_5, "lcd_g_5", std),
  435. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_G_6, "lcd_g_6", std),
  436. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_G_7, "lcd_g_7", std),
  437. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_HSYNC, "lcd_hsync", std),
  438. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_OE, "lcd_oe", std),
  439. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_PCLK, "lcd_pclk", std),
  440. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_R_0, "lcd_r_0", std),
  441. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_R_1, "lcd_r_1", std),
  442. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_R_2, "lcd_r_2", std),
  443. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_R_3, "lcd_r_3", std),
  444. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_R_4, "lcd_r_4", std),
  445. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_R_5, "lcd_r_5", std),
  446. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_R_6, "lcd_r_6", std),
  447. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_R_7, "lcd_r_7", std),
  448. BCM281XX_PIN_DESC(BCM281XX_PIN_LCD_VSYNC, "lcd_vsync", std),
  449. BCM281XX_PIN_DESC(BCM281XX_PIN_MDMGPIO0, "mdmgpio0", std),
  450. BCM281XX_PIN_DESC(BCM281XX_PIN_MDMGPIO1, "mdmgpio1", std),
  451. BCM281XX_PIN_DESC(BCM281XX_PIN_MDMGPIO2, "mdmgpio2", std),
  452. BCM281XX_PIN_DESC(BCM281XX_PIN_MDMGPIO3, "mdmgpio3", std),
  453. BCM281XX_PIN_DESC(BCM281XX_PIN_MDMGPIO4, "mdmgpio4", std),
  454. BCM281XX_PIN_DESC(BCM281XX_PIN_MDMGPIO5, "mdmgpio5", std),
  455. BCM281XX_PIN_DESC(BCM281XX_PIN_MDMGPIO6, "mdmgpio6", std),
  456. BCM281XX_PIN_DESC(BCM281XX_PIN_MDMGPIO7, "mdmgpio7", std),
  457. BCM281XX_PIN_DESC(BCM281XX_PIN_MDMGPIO8, "mdmgpio8", std),
  458. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_0, "mphi_data_0", std),
  459. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_1, "mphi_data_1", std),
  460. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_2, "mphi_data_2", std),
  461. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_3, "mphi_data_3", std),
  462. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_4, "mphi_data_4", std),
  463. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_5, "mphi_data_5", std),
  464. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_6, "mphi_data_6", std),
  465. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_7, "mphi_data_7", std),
  466. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_8, "mphi_data_8", std),
  467. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_9, "mphi_data_9", std),
  468. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_10, "mphi_data_10", std),
  469. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_11, "mphi_data_11", std),
  470. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_12, "mphi_data_12", std),
  471. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_13, "mphi_data_13", std),
  472. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_14, "mphi_data_14", std),
  473. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_DATA_15, "mphi_data_15", std),
  474. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_HA0, "mphi_ha0", std),
  475. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_HAT0, "mphi_hat0", std),
  476. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_HAT1, "mphi_hat1", std),
  477. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_HCE0_N, "mphi_hce0_n", std),
  478. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_HCE1_N, "mphi_hce1_n", std),
  479. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_HRD_N, "mphi_hrd_n", std),
  480. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_HWR_N, "mphi_hwr_n", std),
  481. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_RUN0, "mphi_run0", std),
  482. BCM281XX_PIN_DESC(BCM281XX_PIN_MPHI_RUN1, "mphi_run1", std),
  483. BCM281XX_PIN_DESC(BCM281XX_PIN_MTX_SCAN_CLK, "mtx_scan_clk", std),
  484. BCM281XX_PIN_DESC(BCM281XX_PIN_MTX_SCAN_DATA, "mtx_scan_data", std),
  485. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_AD_0, "nand_ad_0", std),
  486. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_AD_1, "nand_ad_1", std),
  487. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_AD_2, "nand_ad_2", std),
  488. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_AD_3, "nand_ad_3", std),
  489. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_AD_4, "nand_ad_4", std),
  490. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_AD_5, "nand_ad_5", std),
  491. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_AD_6, "nand_ad_6", std),
  492. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_AD_7, "nand_ad_7", std),
  493. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_ALE, "nand_ale", std),
  494. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_CEN_0, "nand_cen_0", std),
  495. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_CEN_1, "nand_cen_1", std),
  496. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_CLE, "nand_cle", std),
  497. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_OEN, "nand_oen", std),
  498. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_RDY_0, "nand_rdy_0", std),
  499. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_RDY_1, "nand_rdy_1", std),
  500. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_WEN, "nand_wen", std),
  501. BCM281XX_PIN_DESC(BCM281XX_PIN_NAND_WP, "nand_wp", std),
  502. BCM281XX_PIN_DESC(BCM281XX_PIN_PC1, "pc1", std),
  503. BCM281XX_PIN_DESC(BCM281XX_PIN_PC2, "pc2", std),
  504. BCM281XX_PIN_DESC(BCM281XX_PIN_PMU_INT, "pmu_int", std),
  505. BCM281XX_PIN_DESC(BCM281XX_PIN_PMU_SCL, "pmu_scl", i2c),
  506. BCM281XX_PIN_DESC(BCM281XX_PIN_PMU_SDA, "pmu_sda", i2c),
  507. BCM281XX_PIN_DESC(BCM281XX_PIN_RFST2G_MTSLOTEN3G, "rfst2g_mtsloten3g",
  508. std),
  509. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_0_RX_CTL, "rgmii_0_rx_ctl", std),
  510. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_0_RXC, "rgmii_0_rxc", std),
  511. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_0_RXD_0, "rgmii_0_rxd_0", std),
  512. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_0_RXD_1, "rgmii_0_rxd_1", std),
  513. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_0_RXD_2, "rgmii_0_rxd_2", std),
  514. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_0_RXD_3, "rgmii_0_rxd_3", std),
  515. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_0_TX_CTL, "rgmii_0_tx_ctl", std),
  516. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_0_TXC, "rgmii_0_txc", std),
  517. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_0_TXD_0, "rgmii_0_txd_0", std),
  518. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_0_TXD_1, "rgmii_0_txd_1", std),
  519. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_0_TXD_2, "rgmii_0_txd_2", std),
  520. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_0_TXD_3, "rgmii_0_txd_3", std),
  521. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_1_RX_CTL, "rgmii_1_rx_ctl", std),
  522. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_1_RXC, "rgmii_1_rxc", std),
  523. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_1_RXD_0, "rgmii_1_rxd_0", std),
  524. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_1_RXD_1, "rgmii_1_rxd_1", std),
  525. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_1_RXD_2, "rgmii_1_rxd_2", std),
  526. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_1_RXD_3, "rgmii_1_rxd_3", std),
  527. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_1_TX_CTL, "rgmii_1_tx_ctl", std),
  528. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_1_TXC, "rgmii_1_txc", std),
  529. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_1_TXD_0, "rgmii_1_txd_0", std),
  530. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_1_TXD_1, "rgmii_1_txd_1", std),
  531. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_1_TXD_2, "rgmii_1_txd_2", std),
  532. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_1_TXD_3, "rgmii_1_txd_3", std),
  533. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_GPIO_0, "rgmii_gpio_0", std),
  534. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_GPIO_1, "rgmii_gpio_1", std),
  535. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_GPIO_2, "rgmii_gpio_2", std),
  536. BCM281XX_PIN_DESC(BCM281XX_PIN_RGMII_GPIO_3, "rgmii_gpio_3", std),
  537. BCM281XX_PIN_DESC(BCM281XX_PIN_RTXDATA2G_TXDATA3G1,
  538. "rtxdata2g_txdata3g1", std),
  539. BCM281XX_PIN_DESC(BCM281XX_PIN_RTXEN2G_TXDATA3G2, "rtxen2g_txdata3g2",
  540. std),
  541. BCM281XX_PIN_DESC(BCM281XX_PIN_RXDATA3G0, "rxdata3g0", std),
  542. BCM281XX_PIN_DESC(BCM281XX_PIN_RXDATA3G1, "rxdata3g1", std),
  543. BCM281XX_PIN_DESC(BCM281XX_PIN_RXDATA3G2, "rxdata3g2", std),
  544. BCM281XX_PIN_DESC(BCM281XX_PIN_SDIO1_CLK, "sdio1_clk", std),
  545. BCM281XX_PIN_DESC(BCM281XX_PIN_SDIO1_CMD, "sdio1_cmd", std),
  546. BCM281XX_PIN_DESC(BCM281XX_PIN_SDIO1_DATA_0, "sdio1_data_0", std),
  547. BCM281XX_PIN_DESC(BCM281XX_PIN_SDIO1_DATA_1, "sdio1_data_1", std),
  548. BCM281XX_PIN_DESC(BCM281XX_PIN_SDIO1_DATA_2, "sdio1_data_2", std),
  549. BCM281XX_PIN_DESC(BCM281XX_PIN_SDIO1_DATA_3, "sdio1_data_3", std),
  550. BCM281XX_PIN_DESC(BCM281XX_PIN_SDIO4_CLK, "sdio4_clk", std),
  551. BCM281XX_PIN_DESC(BCM281XX_PIN_SDIO4_CMD, "sdio4_cmd", std),
  552. BCM281XX_PIN_DESC(BCM281XX_PIN_SDIO4_DATA_0, "sdio4_data_0", std),
  553. BCM281XX_PIN_DESC(BCM281XX_PIN_SDIO4_DATA_1, "sdio4_data_1", std),
  554. BCM281XX_PIN_DESC(BCM281XX_PIN_SDIO4_DATA_2, "sdio4_data_2", std),
  555. BCM281XX_PIN_DESC(BCM281XX_PIN_SDIO4_DATA_3, "sdio4_data_3", std),
  556. BCM281XX_PIN_DESC(BCM281XX_PIN_SIM_CLK, "sim_clk", std),
  557. BCM281XX_PIN_DESC(BCM281XX_PIN_SIM_DATA, "sim_data", std),
  558. BCM281XX_PIN_DESC(BCM281XX_PIN_SIM_DET, "sim_det", std),
  559. BCM281XX_PIN_DESC(BCM281XX_PIN_SIM_RESETN, "sim_resetn", std),
  560. BCM281XX_PIN_DESC(BCM281XX_PIN_SIM2_CLK, "sim2_clk", std),
  561. BCM281XX_PIN_DESC(BCM281XX_PIN_SIM2_DATA, "sim2_data", std),
  562. BCM281XX_PIN_DESC(BCM281XX_PIN_SIM2_DET, "sim2_det", std),
  563. BCM281XX_PIN_DESC(BCM281XX_PIN_SIM2_RESETN, "sim2_resetn", std),
  564. BCM281XX_PIN_DESC(BCM281XX_PIN_SRI_C, "sri_c", std),
  565. BCM281XX_PIN_DESC(BCM281XX_PIN_SRI_D, "sri_d", std),
  566. BCM281XX_PIN_DESC(BCM281XX_PIN_SRI_E, "sri_e", std),
  567. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP_EXTCLK, "ssp_extclk", std),
  568. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP0_CLK, "ssp0_clk", std),
  569. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP0_FS, "ssp0_fs", std),
  570. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP0_RXD, "ssp0_rxd", std),
  571. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP0_TXD, "ssp0_txd", std),
  572. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP2_CLK, "ssp2_clk", std),
  573. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP2_FS_0, "ssp2_fs_0", std),
  574. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP2_FS_1, "ssp2_fs_1", std),
  575. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP2_FS_2, "ssp2_fs_2", std),
  576. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP2_FS_3, "ssp2_fs_3", std),
  577. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP2_RXD_0, "ssp2_rxd_0", std),
  578. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP2_RXD_1, "ssp2_rxd_1", std),
  579. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP2_TXD_0, "ssp2_txd_0", std),
  580. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP2_TXD_1, "ssp2_txd_1", std),
  581. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP3_CLK, "ssp3_clk", std),
  582. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP3_FS, "ssp3_fs", std),
  583. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP3_RXD, "ssp3_rxd", std),
  584. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP3_TXD, "ssp3_txd", std),
  585. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP4_CLK, "ssp4_clk", std),
  586. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP4_FS, "ssp4_fs", std),
  587. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP4_RXD, "ssp4_rxd", std),
  588. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP4_TXD, "ssp4_txd", std),
  589. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP5_CLK, "ssp5_clk", std),
  590. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP5_FS, "ssp5_fs", std),
  591. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP5_RXD, "ssp5_rxd", std),
  592. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP5_TXD, "ssp5_txd", std),
  593. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP6_CLK, "ssp6_clk", std),
  594. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP6_FS, "ssp6_fs", std),
  595. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP6_RXD, "ssp6_rxd", std),
  596. BCM281XX_PIN_DESC(BCM281XX_PIN_SSP6_TXD, "ssp6_txd", std),
  597. BCM281XX_PIN_DESC(BCM281XX_PIN_STAT_1, "stat_1", std),
  598. BCM281XX_PIN_DESC(BCM281XX_PIN_STAT_2, "stat_2", std),
  599. BCM281XX_PIN_DESC(BCM281XX_PIN_SYSCLKEN, "sysclken", std),
  600. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACECLK, "traceclk", std),
  601. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT00, "tracedt00", std),
  602. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT01, "tracedt01", std),
  603. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT02, "tracedt02", std),
  604. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT03, "tracedt03", std),
  605. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT04, "tracedt04", std),
  606. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT05, "tracedt05", std),
  607. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT06, "tracedt06", std),
  608. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT07, "tracedt07", std),
  609. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT08, "tracedt08", std),
  610. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT09, "tracedt09", std),
  611. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT10, "tracedt10", std),
  612. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT11, "tracedt11", std),
  613. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT12, "tracedt12", std),
  614. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT13, "tracedt13", std),
  615. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT14, "tracedt14", std),
  616. BCM281XX_PIN_DESC(BCM281XX_PIN_TRACEDT15, "tracedt15", std),
  617. BCM281XX_PIN_DESC(BCM281XX_PIN_TXDATA3G0, "txdata3g0", std),
  618. BCM281XX_PIN_DESC(BCM281XX_PIN_TXPWRIND, "txpwrind", std),
  619. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB1_UCTS, "uartb1_ucts", std),
  620. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB1_URTS, "uartb1_urts", std),
  621. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB1_URXD, "uartb1_urxd", std),
  622. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB1_UTXD, "uartb1_utxd", std),
  623. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB2_URXD, "uartb2_urxd", std),
  624. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB2_UTXD, "uartb2_utxd", std),
  625. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB3_UCTS, "uartb3_ucts", std),
  626. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB3_URTS, "uartb3_urts", std),
  627. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB3_URXD, "uartb3_urxd", std),
  628. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB3_UTXD, "uartb3_utxd", std),
  629. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB4_UCTS, "uartb4_ucts", std),
  630. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB4_URTS, "uartb4_urts", std),
  631. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB4_URXD, "uartb4_urxd", std),
  632. BCM281XX_PIN_DESC(BCM281XX_PIN_UARTB4_UTXD, "uartb4_utxd", std),
  633. BCM281XX_PIN_DESC(BCM281XX_PIN_VC_CAM1_SCL, "vc_cam1_scl", i2c),
  634. BCM281XX_PIN_DESC(BCM281XX_PIN_VC_CAM1_SDA, "vc_cam1_sda", i2c),
  635. BCM281XX_PIN_DESC(BCM281XX_PIN_VC_CAM2_SCL, "vc_cam2_scl", i2c),
  636. BCM281XX_PIN_DESC(BCM281XX_PIN_VC_CAM2_SDA, "vc_cam2_sda", i2c),
  637. BCM281XX_PIN_DESC(BCM281XX_PIN_VC_CAM3_SCL, "vc_cam3_scl", i2c),
  638. BCM281XX_PIN_DESC(BCM281XX_PIN_VC_CAM3_SDA, "vc_cam3_sda", i2c),
  639. };
  640. static const char * const bcm281xx_alt_groups[] = {
  641. "adcsync",
  642. "bat_rm",
  643. "bsc1_scl",
  644. "bsc1_sda",
  645. "bsc2_scl",
  646. "bsc2_sda",
  647. "classgpwr",
  648. "clk_cx8",
  649. "clkout_0",
  650. "clkout_1",
  651. "clkout_2",
  652. "clkout_3",
  653. "clkreq_in_0",
  654. "clkreq_in_1",
  655. "cws_sys_req1",
  656. "cws_sys_req2",
  657. "cws_sys_req3",
  658. "digmic1_clk",
  659. "digmic1_dq",
  660. "digmic2_clk",
  661. "digmic2_dq",
  662. "gpen13",
  663. "gpen14",
  664. "gpen15",
  665. "gpio00",
  666. "gpio01",
  667. "gpio02",
  668. "gpio03",
  669. "gpio04",
  670. "gpio05",
  671. "gpio06",
  672. "gpio07",
  673. "gpio08",
  674. "gpio09",
  675. "gpio10",
  676. "gpio11",
  677. "gpio12",
  678. "gpio13",
  679. "gpio14",
  680. "gps_pablank",
  681. "gps_tmark",
  682. "hdmi_scl",
  683. "hdmi_sda",
  684. "ic_dm",
  685. "ic_dp",
  686. "kp_col_ip_0",
  687. "kp_col_ip_1",
  688. "kp_col_ip_2",
  689. "kp_col_ip_3",
  690. "kp_row_op_0",
  691. "kp_row_op_1",
  692. "kp_row_op_2",
  693. "kp_row_op_3",
  694. "lcd_b_0",
  695. "lcd_b_1",
  696. "lcd_b_2",
  697. "lcd_b_3",
  698. "lcd_b_4",
  699. "lcd_b_5",
  700. "lcd_b_6",
  701. "lcd_b_7",
  702. "lcd_g_0",
  703. "lcd_g_1",
  704. "lcd_g_2",
  705. "lcd_g_3",
  706. "lcd_g_4",
  707. "lcd_g_5",
  708. "lcd_g_6",
  709. "lcd_g_7",
  710. "lcd_hsync",
  711. "lcd_oe",
  712. "lcd_pclk",
  713. "lcd_r_0",
  714. "lcd_r_1",
  715. "lcd_r_2",
  716. "lcd_r_3",
  717. "lcd_r_4",
  718. "lcd_r_5",
  719. "lcd_r_6",
  720. "lcd_r_7",
  721. "lcd_vsync",
  722. "mdmgpio0",
  723. "mdmgpio1",
  724. "mdmgpio2",
  725. "mdmgpio3",
  726. "mdmgpio4",
  727. "mdmgpio5",
  728. "mdmgpio6",
  729. "mdmgpio7",
  730. "mdmgpio8",
  731. "mphi_data_0",
  732. "mphi_data_1",
  733. "mphi_data_2",
  734. "mphi_data_3",
  735. "mphi_data_4",
  736. "mphi_data_5",
  737. "mphi_data_6",
  738. "mphi_data_7",
  739. "mphi_data_8",
  740. "mphi_data_9",
  741. "mphi_data_10",
  742. "mphi_data_11",
  743. "mphi_data_12",
  744. "mphi_data_13",
  745. "mphi_data_14",
  746. "mphi_data_15",
  747. "mphi_ha0",
  748. "mphi_hat0",
  749. "mphi_hat1",
  750. "mphi_hce0_n",
  751. "mphi_hce1_n",
  752. "mphi_hrd_n",
  753. "mphi_hwr_n",
  754. "mphi_run0",
  755. "mphi_run1",
  756. "mtx_scan_clk",
  757. "mtx_scan_data",
  758. "nand_ad_0",
  759. "nand_ad_1",
  760. "nand_ad_2",
  761. "nand_ad_3",
  762. "nand_ad_4",
  763. "nand_ad_5",
  764. "nand_ad_6",
  765. "nand_ad_7",
  766. "nand_ale",
  767. "nand_cen_0",
  768. "nand_cen_1",
  769. "nand_cle",
  770. "nand_oen",
  771. "nand_rdy_0",
  772. "nand_rdy_1",
  773. "nand_wen",
  774. "nand_wp",
  775. "pc1",
  776. "pc2",
  777. "pmu_int",
  778. "pmu_scl",
  779. "pmu_sda",
  780. "rfst2g_mtsloten3g",
  781. "rgmii_0_rx_ctl",
  782. "rgmii_0_rxc",
  783. "rgmii_0_rxd_0",
  784. "rgmii_0_rxd_1",
  785. "rgmii_0_rxd_2",
  786. "rgmii_0_rxd_3",
  787. "rgmii_0_tx_ctl",
  788. "rgmii_0_txc",
  789. "rgmii_0_txd_0",
  790. "rgmii_0_txd_1",
  791. "rgmii_0_txd_2",
  792. "rgmii_0_txd_3",
  793. "rgmii_1_rx_ctl",
  794. "rgmii_1_rxc",
  795. "rgmii_1_rxd_0",
  796. "rgmii_1_rxd_1",
  797. "rgmii_1_rxd_2",
  798. "rgmii_1_rxd_3",
  799. "rgmii_1_tx_ctl",
  800. "rgmii_1_txc",
  801. "rgmii_1_txd_0",
  802. "rgmii_1_txd_1",
  803. "rgmii_1_txd_2",
  804. "rgmii_1_txd_3",
  805. "rgmii_gpio_0",
  806. "rgmii_gpio_1",
  807. "rgmii_gpio_2",
  808. "rgmii_gpio_3",
  809. "rtxdata2g_txdata3g1",
  810. "rtxen2g_txdata3g2",
  811. "rxdata3g0",
  812. "rxdata3g1",
  813. "rxdata3g2",
  814. "sdio1_clk",
  815. "sdio1_cmd",
  816. "sdio1_data_0",
  817. "sdio1_data_1",
  818. "sdio1_data_2",
  819. "sdio1_data_3",
  820. "sdio4_clk",
  821. "sdio4_cmd",
  822. "sdio4_data_0",
  823. "sdio4_data_1",
  824. "sdio4_data_2",
  825. "sdio4_data_3",
  826. "sim_clk",
  827. "sim_data",
  828. "sim_det",
  829. "sim_resetn",
  830. "sim2_clk",
  831. "sim2_data",
  832. "sim2_det",
  833. "sim2_resetn",
  834. "sri_c",
  835. "sri_d",
  836. "sri_e",
  837. "ssp_extclk",
  838. "ssp0_clk",
  839. "ssp0_fs",
  840. "ssp0_rxd",
  841. "ssp0_txd",
  842. "ssp2_clk",
  843. "ssp2_fs_0",
  844. "ssp2_fs_1",
  845. "ssp2_fs_2",
  846. "ssp2_fs_3",
  847. "ssp2_rxd_0",
  848. "ssp2_rxd_1",
  849. "ssp2_txd_0",
  850. "ssp2_txd_1",
  851. "ssp3_clk",
  852. "ssp3_fs",
  853. "ssp3_rxd",
  854. "ssp3_txd",
  855. "ssp4_clk",
  856. "ssp4_fs",
  857. "ssp4_rxd",
  858. "ssp4_txd",
  859. "ssp5_clk",
  860. "ssp5_fs",
  861. "ssp5_rxd",
  862. "ssp5_txd",
  863. "ssp6_clk",
  864. "ssp6_fs",
  865. "ssp6_rxd",
  866. "ssp6_txd",
  867. "stat_1",
  868. "stat_2",
  869. "sysclken",
  870. "traceclk",
  871. "tracedt00",
  872. "tracedt01",
  873. "tracedt02",
  874. "tracedt03",
  875. "tracedt04",
  876. "tracedt05",
  877. "tracedt06",
  878. "tracedt07",
  879. "tracedt08",
  880. "tracedt09",
  881. "tracedt10",
  882. "tracedt11",
  883. "tracedt12",
  884. "tracedt13",
  885. "tracedt14",
  886. "tracedt15",
  887. "txdata3g0",
  888. "txpwrind",
  889. "uartb1_ucts",
  890. "uartb1_urts",
  891. "uartb1_urxd",
  892. "uartb1_utxd",
  893. "uartb2_urxd",
  894. "uartb2_utxd",
  895. "uartb3_ucts",
  896. "uartb3_urts",
  897. "uartb3_urxd",
  898. "uartb3_utxd",
  899. "uartb4_ucts",
  900. "uartb4_urts",
  901. "uartb4_urxd",
  902. "uartb4_utxd",
  903. "vc_cam1_scl",
  904. "vc_cam1_sda",
  905. "vc_cam2_scl",
  906. "vc_cam2_sda",
  907. "vc_cam3_scl",
  908. "vc_cam3_sda",
  909. };
  910. /* Every pin can implement all ALT1-ALT4 functions */
  911. #define BCM281XX_PIN_FUNCTION(fcn_name) \
  912. { \
  913. .name = #fcn_name, \
  914. .groups = bcm281xx_alt_groups, \
  915. .ngroups = ARRAY_SIZE(bcm281xx_alt_groups), \
  916. }
  917. static const struct bcm281xx_pin_function bcm281xx_functions[] = {
  918. BCM281XX_PIN_FUNCTION(alt1),
  919. BCM281XX_PIN_FUNCTION(alt2),
  920. BCM281XX_PIN_FUNCTION(alt3),
  921. BCM281XX_PIN_FUNCTION(alt4),
  922. };
  923. static struct bcm281xx_pinctrl_data bcm281xx_pinctrl = {
  924. .pins = bcm281xx_pinctrl_pins,
  925. .npins = ARRAY_SIZE(bcm281xx_pinctrl_pins),
  926. .functions = bcm281xx_functions,
  927. .nfunctions = ARRAY_SIZE(bcm281xx_functions),
  928. };
  929. static inline enum bcm281xx_pin_type pin_type_get(struct pinctrl_dev *pctldev,
  930. unsigned pin)
  931. {
  932. struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
  933. if (pin >= pdata->npins)
  934. return BCM281XX_PIN_TYPE_UNKNOWN;
  935. return *(enum bcm281xx_pin_type *)(pdata->pins[pin].drv_data);
  936. }
  937. #define BCM281XX_PIN_SHIFT(type, param) \
  938. (BCM281XX_ ## type ## _PIN_REG_ ## param ## _SHIFT)
  939. #define BCM281XX_PIN_MASK(type, param) \
  940. (BCM281XX_ ## type ## _PIN_REG_ ## param ## _MASK)
  941. /*
  942. * This helper function is used to build up the value and mask used to write to
  943. * a pin register, but does not actually write to the register.
  944. */
  945. static inline void bcm281xx_pin_update(u32 *reg_val, u32 *reg_mask,
  946. u32 param_val, u32 param_shift,
  947. u32 param_mask)
  948. {
  949. *reg_val &= ~param_mask;
  950. *reg_val |= (param_val << param_shift) & param_mask;
  951. *reg_mask |= param_mask;
  952. }
  953. static const struct regmap_config bcm281xx_pinctrl_regmap_config = {
  954. .reg_bits = 32,
  955. .reg_stride = 4,
  956. .val_bits = 32,
  957. .max_register = BCM281XX_PIN_VC_CAM3_SDA,
  958. };
  959. static int bcm281xx_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
  960. {
  961. struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
  962. return pdata->npins;
  963. }
  964. static const char *bcm281xx_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
  965. unsigned group)
  966. {
  967. struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
  968. return pdata->pins[group].name;
  969. }
  970. static int bcm281xx_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
  971. unsigned group,
  972. const unsigned **pins,
  973. unsigned *num_pins)
  974. {
  975. struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
  976. *pins = &pdata->pins[group].number;
  977. *num_pins = 1;
  978. return 0;
  979. }
  980. static void bcm281xx_pinctrl_pin_dbg_show(struct pinctrl_dev *pctldev,
  981. struct seq_file *s,
  982. unsigned offset)
  983. {
  984. seq_printf(s, " %s", dev_name(pctldev->dev));
  985. }
  986. static struct pinctrl_ops bcm281xx_pinctrl_ops = {
  987. .get_groups_count = bcm281xx_pinctrl_get_groups_count,
  988. .get_group_name = bcm281xx_pinctrl_get_group_name,
  989. .get_group_pins = bcm281xx_pinctrl_get_group_pins,
  990. .pin_dbg_show = bcm281xx_pinctrl_pin_dbg_show,
  991. .dt_node_to_map = pinconf_generic_dt_node_to_map_pin,
  992. .dt_free_map = pinctrl_utils_dt_free_map,
  993. };
  994. static int bcm281xx_pinctrl_get_fcns_count(struct pinctrl_dev *pctldev)
  995. {
  996. struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
  997. return pdata->nfunctions;
  998. }
  999. static const char *bcm281xx_pinctrl_get_fcn_name(struct pinctrl_dev *pctldev,
  1000. unsigned function)
  1001. {
  1002. struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
  1003. return pdata->functions[function].name;
  1004. }
  1005. static int bcm281xx_pinctrl_get_fcn_groups(struct pinctrl_dev *pctldev,
  1006. unsigned function,
  1007. const char * const **groups,
  1008. unsigned * const num_groups)
  1009. {
  1010. struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
  1011. *groups = pdata->functions[function].groups;
  1012. *num_groups = pdata->functions[function].ngroups;
  1013. return 0;
  1014. }
  1015. static int bcm281xx_pinmux_set(struct pinctrl_dev *pctldev,
  1016. unsigned function,
  1017. unsigned group)
  1018. {
  1019. struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
  1020. const struct bcm281xx_pin_function *f = &pdata->functions[function];
  1021. u32 offset = 4 * pdata->pins[group].number;
  1022. int rc = 0;
  1023. dev_dbg(pctldev->dev,
  1024. "%s(): Enable function %s (%d) of pin %s (%d) @offset 0x%x.\n",
  1025. __func__, f->name, function, pdata->pins[group].name,
  1026. pdata->pins[group].number, offset);
  1027. rc = regmap_update_bits(pdata->regmap, offset,
  1028. BCM281XX_PIN_REG_F_SEL_MASK,
  1029. function << BCM281XX_PIN_REG_F_SEL_SHIFT);
  1030. if (rc)
  1031. dev_err(pctldev->dev,
  1032. "Error updating register for pin %s (%d).\n",
  1033. pdata->pins[group].name, pdata->pins[group].number);
  1034. return rc;
  1035. }
  1036. static struct pinmux_ops bcm281xx_pinctrl_pinmux_ops = {
  1037. .get_functions_count = bcm281xx_pinctrl_get_fcns_count,
  1038. .get_function_name = bcm281xx_pinctrl_get_fcn_name,
  1039. .get_function_groups = bcm281xx_pinctrl_get_fcn_groups,
  1040. .set_mux = bcm281xx_pinmux_set,
  1041. };
  1042. static int bcm281xx_pinctrl_pin_config_get(struct pinctrl_dev *pctldev,
  1043. unsigned pin,
  1044. unsigned long *config)
  1045. {
  1046. return -ENOTSUPP;
  1047. }
  1048. /* Goes through the configs and update register val/mask */
  1049. static int bcm281xx_std_pin_update(struct pinctrl_dev *pctldev,
  1050. unsigned pin,
  1051. unsigned long *configs,
  1052. unsigned num_configs,
  1053. u32 *val,
  1054. u32 *mask)
  1055. {
  1056. struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
  1057. int i;
  1058. enum pin_config_param param;
  1059. u16 arg;
  1060. for (i = 0; i < num_configs; i++) {
  1061. param = pinconf_to_config_param(configs[i]);
  1062. arg = pinconf_to_config_argument(configs[i]);
  1063. switch (param) {
  1064. case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
  1065. arg = (arg >= 1 ? 1 : 0);
  1066. bcm281xx_pin_update(val, mask, arg,
  1067. BCM281XX_PIN_SHIFT(STD, HYST),
  1068. BCM281XX_PIN_MASK(STD, HYST));
  1069. break;
  1070. /*
  1071. * The pin bias can only be one of pull-up, pull-down, or
  1072. * disable. The user does not need to specify a value for the
  1073. * property, and the default value from pinconf-generic is
  1074. * ignored.
  1075. */
  1076. case PIN_CONFIG_BIAS_DISABLE:
  1077. bcm281xx_pin_update(val, mask, 0,
  1078. BCM281XX_PIN_SHIFT(STD, PULL_UP),
  1079. BCM281XX_PIN_MASK(STD, PULL_UP));
  1080. bcm281xx_pin_update(val, mask, 0,
  1081. BCM281XX_PIN_SHIFT(STD, PULL_DN),
  1082. BCM281XX_PIN_MASK(STD, PULL_DN));
  1083. break;
  1084. case PIN_CONFIG_BIAS_PULL_UP:
  1085. bcm281xx_pin_update(val, mask, 1,
  1086. BCM281XX_PIN_SHIFT(STD, PULL_UP),
  1087. BCM281XX_PIN_MASK(STD, PULL_UP));
  1088. bcm281xx_pin_update(val, mask, 0,
  1089. BCM281XX_PIN_SHIFT(STD, PULL_DN),
  1090. BCM281XX_PIN_MASK(STD, PULL_DN));
  1091. break;
  1092. case PIN_CONFIG_BIAS_PULL_DOWN:
  1093. bcm281xx_pin_update(val, mask, 0,
  1094. BCM281XX_PIN_SHIFT(STD, PULL_UP),
  1095. BCM281XX_PIN_MASK(STD, PULL_UP));
  1096. bcm281xx_pin_update(val, mask, 1,
  1097. BCM281XX_PIN_SHIFT(STD, PULL_DN),
  1098. BCM281XX_PIN_MASK(STD, PULL_DN));
  1099. break;
  1100. case PIN_CONFIG_SLEW_RATE:
  1101. arg = (arg >= 1 ? 1 : 0);
  1102. bcm281xx_pin_update(val, mask, arg,
  1103. BCM281XX_PIN_SHIFT(STD, SLEW),
  1104. BCM281XX_PIN_MASK(STD, SLEW));
  1105. break;
  1106. case PIN_CONFIG_INPUT_ENABLE:
  1107. /* inversed since register is for input _disable_ */
  1108. arg = (arg >= 1 ? 0 : 1);
  1109. bcm281xx_pin_update(val, mask, arg,
  1110. BCM281XX_PIN_SHIFT(STD, INPUT_DIS),
  1111. BCM281XX_PIN_MASK(STD, INPUT_DIS));
  1112. break;
  1113. case PIN_CONFIG_DRIVE_STRENGTH:
  1114. /* Valid range is 2-16 mA, even numbers only */
  1115. if ((arg < 2) || (arg > 16) || (arg % 2)) {
  1116. dev_err(pctldev->dev,
  1117. "Invalid Drive Strength value (%d) for "
  1118. "pin %s (%d). Valid values are "
  1119. "(2..16) mA, even numbers only.\n",
  1120. arg, pdata->pins[pin].name, pin);
  1121. return -EINVAL;
  1122. }
  1123. bcm281xx_pin_update(val, mask, (arg/2)-1,
  1124. BCM281XX_PIN_SHIFT(STD, DRV_STR),
  1125. BCM281XX_PIN_MASK(STD, DRV_STR));
  1126. break;
  1127. default:
  1128. dev_err(pctldev->dev,
  1129. "Unrecognized pin config %d for pin %s (%d).\n",
  1130. param, pdata->pins[pin].name, pin);
  1131. return -EINVAL;
  1132. } /* switch config */
  1133. } /* for each config */
  1134. return 0;
  1135. }
  1136. /*
  1137. * The pull-up strength for an I2C pin is represented by bits 4-6 in the
  1138. * register with the following mapping:
  1139. * 0b000: No pull-up
  1140. * 0b001: 1200 Ohm
  1141. * 0b010: 1800 Ohm
  1142. * 0b011: 720 Ohm
  1143. * 0b100: 2700 Ohm
  1144. * 0b101: 831 Ohm
  1145. * 0b110: 1080 Ohm
  1146. * 0b111: 568 Ohm
  1147. * This array maps pull-up strength in Ohms to register values (1+index).
  1148. */
  1149. static const u16 bcm281xx_pullup_map[] = {
  1150. 1200, 1800, 720, 2700, 831, 1080, 568
  1151. };
  1152. /* Goes through the configs and update register val/mask */
  1153. static int bcm281xx_i2c_pin_update(struct pinctrl_dev *pctldev,
  1154. unsigned pin,
  1155. unsigned long *configs,
  1156. unsigned num_configs,
  1157. u32 *val,
  1158. u32 *mask)
  1159. {
  1160. struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
  1161. int i, j;
  1162. enum pin_config_param param;
  1163. u16 arg;
  1164. for (i = 0; i < num_configs; i++) {
  1165. param = pinconf_to_config_param(configs[i]);
  1166. arg = pinconf_to_config_argument(configs[i]);
  1167. switch (param) {
  1168. case PIN_CONFIG_BIAS_PULL_UP:
  1169. for (j = 0; j < ARRAY_SIZE(bcm281xx_pullup_map); j++)
  1170. if (bcm281xx_pullup_map[j] == arg)
  1171. break;
  1172. if (j == ARRAY_SIZE(bcm281xx_pullup_map)) {
  1173. dev_err(pctldev->dev,
  1174. "Invalid pull-up value (%d) for pin %s "
  1175. "(%d). Valid values are 568, 720, 831, "
  1176. "1080, 1200, 1800, 2700 Ohms.\n",
  1177. arg, pdata->pins[pin].name, pin);
  1178. return -EINVAL;
  1179. }
  1180. bcm281xx_pin_update(val, mask, j+1,
  1181. BCM281XX_PIN_SHIFT(I2C, PULL_UP_STR),
  1182. BCM281XX_PIN_MASK(I2C, PULL_UP_STR));
  1183. break;
  1184. case PIN_CONFIG_BIAS_DISABLE:
  1185. bcm281xx_pin_update(val, mask, 0,
  1186. BCM281XX_PIN_SHIFT(I2C, PULL_UP_STR),
  1187. BCM281XX_PIN_MASK(I2C, PULL_UP_STR));
  1188. break;
  1189. case PIN_CONFIG_SLEW_RATE:
  1190. arg = (arg >= 1 ? 1 : 0);
  1191. bcm281xx_pin_update(val, mask, arg,
  1192. BCM281XX_PIN_SHIFT(I2C, SLEW),
  1193. BCM281XX_PIN_MASK(I2C, SLEW));
  1194. break;
  1195. case PIN_CONFIG_INPUT_ENABLE:
  1196. /* inversed since register is for input _disable_ */
  1197. arg = (arg >= 1 ? 0 : 1);
  1198. bcm281xx_pin_update(val, mask, arg,
  1199. BCM281XX_PIN_SHIFT(I2C, INPUT_DIS),
  1200. BCM281XX_PIN_MASK(I2C, INPUT_DIS));
  1201. break;
  1202. default:
  1203. dev_err(pctldev->dev,
  1204. "Unrecognized pin config %d for pin %s (%d).\n",
  1205. param, pdata->pins[pin].name, pin);
  1206. return -EINVAL;
  1207. } /* switch config */
  1208. } /* for each config */
  1209. return 0;
  1210. }
  1211. /* Goes through the configs and update register val/mask */
  1212. static int bcm281xx_hdmi_pin_update(struct pinctrl_dev *pctldev,
  1213. unsigned pin,
  1214. unsigned long *configs,
  1215. unsigned num_configs,
  1216. u32 *val,
  1217. u32 *mask)
  1218. {
  1219. struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
  1220. int i;
  1221. enum pin_config_param param;
  1222. u16 arg;
  1223. for (i = 0; i < num_configs; i++) {
  1224. param = pinconf_to_config_param(configs[i]);
  1225. arg = pinconf_to_config_argument(configs[i]);
  1226. switch (param) {
  1227. case PIN_CONFIG_SLEW_RATE:
  1228. arg = (arg >= 1 ? 1 : 0);
  1229. bcm281xx_pin_update(val, mask, arg,
  1230. BCM281XX_PIN_SHIFT(HDMI, MODE),
  1231. BCM281XX_PIN_MASK(HDMI, MODE));
  1232. break;
  1233. case PIN_CONFIG_INPUT_ENABLE:
  1234. /* inversed since register is for input _disable_ */
  1235. arg = (arg >= 1 ? 0 : 1);
  1236. bcm281xx_pin_update(val, mask, arg,
  1237. BCM281XX_PIN_SHIFT(HDMI, INPUT_DIS),
  1238. BCM281XX_PIN_MASK(HDMI, INPUT_DIS));
  1239. break;
  1240. default:
  1241. dev_err(pctldev->dev,
  1242. "Unrecognized pin config %d for pin %s (%d).\n",
  1243. param, pdata->pins[pin].name, pin);
  1244. return -EINVAL;
  1245. } /* switch config */
  1246. } /* for each config */
  1247. return 0;
  1248. }
  1249. static int bcm281xx_pinctrl_pin_config_set(struct pinctrl_dev *pctldev,
  1250. unsigned pin,
  1251. unsigned long *configs,
  1252. unsigned num_configs)
  1253. {
  1254. struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
  1255. enum bcm281xx_pin_type pin_type;
  1256. u32 offset = 4 * pin;
  1257. u32 cfg_val, cfg_mask;
  1258. int rc;
  1259. cfg_val = 0;
  1260. cfg_mask = 0;
  1261. pin_type = pin_type_get(pctldev, pin);
  1262. /* Different pins have different configuration options */
  1263. switch (pin_type) {
  1264. case BCM281XX_PIN_TYPE_STD:
  1265. rc = bcm281xx_std_pin_update(pctldev, pin, configs,
  1266. num_configs, &cfg_val, &cfg_mask);
  1267. break;
  1268. case BCM281XX_PIN_TYPE_I2C:
  1269. rc = bcm281xx_i2c_pin_update(pctldev, pin, configs,
  1270. num_configs, &cfg_val, &cfg_mask);
  1271. break;
  1272. case BCM281XX_PIN_TYPE_HDMI:
  1273. rc = bcm281xx_hdmi_pin_update(pctldev, pin, configs,
  1274. num_configs, &cfg_val, &cfg_mask);
  1275. break;
  1276. default:
  1277. dev_err(pctldev->dev, "Unknown pin type for pin %s (%d).\n",
  1278. pdata->pins[pin].name, pin);
  1279. return -EINVAL;
  1280. } /* switch pin type */
  1281. if (rc)
  1282. return rc;
  1283. dev_dbg(pctldev->dev,
  1284. "%s(): Set pin %s (%d) with config 0x%x, mask 0x%x\n",
  1285. __func__, pdata->pins[pin].name, pin, cfg_val, cfg_mask);
  1286. rc = regmap_update_bits(pdata->regmap, offset, cfg_mask, cfg_val);
  1287. if (rc) {
  1288. dev_err(pctldev->dev,
  1289. "Error updating register for pin %s (%d).\n",
  1290. pdata->pins[pin].name, pin);
  1291. return rc;
  1292. }
  1293. return 0;
  1294. }
  1295. static struct pinconf_ops bcm281xx_pinctrl_pinconf_ops = {
  1296. .pin_config_get = bcm281xx_pinctrl_pin_config_get,
  1297. .pin_config_set = bcm281xx_pinctrl_pin_config_set,
  1298. };
  1299. static struct pinctrl_desc bcm281xx_pinctrl_desc = {
  1300. /* name, pins, npins members initialized in probe function */
  1301. .pctlops = &bcm281xx_pinctrl_ops,
  1302. .pmxops = &bcm281xx_pinctrl_pinmux_ops,
  1303. .confops = &bcm281xx_pinctrl_pinconf_ops,
  1304. .owner = THIS_MODULE,
  1305. };
  1306. static int __init bcm281xx_pinctrl_probe(struct platform_device *pdev)
  1307. {
  1308. struct bcm281xx_pinctrl_data *pdata = &bcm281xx_pinctrl;
  1309. struct resource *res;
  1310. struct pinctrl_dev *pctl;
  1311. /* So far We can assume there is only 1 bank of registers */
  1312. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1313. pdata->reg_base = devm_ioremap_resource(&pdev->dev, res);
  1314. if (IS_ERR(pdata->reg_base)) {
  1315. dev_err(&pdev->dev, "Failed to ioremap MEM resource\n");
  1316. return -ENODEV;
  1317. }
  1318. /* Initialize the dynamic part of pinctrl_desc */
  1319. pdata->regmap = devm_regmap_init_mmio(&pdev->dev, pdata->reg_base,
  1320. &bcm281xx_pinctrl_regmap_config);
  1321. if (IS_ERR(pdata->regmap)) {
  1322. dev_err(&pdev->dev, "Regmap MMIO init failed.\n");
  1323. return -ENODEV;
  1324. }
  1325. bcm281xx_pinctrl_desc.name = dev_name(&pdev->dev);
  1326. bcm281xx_pinctrl_desc.pins = bcm281xx_pinctrl.pins;
  1327. bcm281xx_pinctrl_desc.npins = bcm281xx_pinctrl.npins;
  1328. pctl = pinctrl_register(&bcm281xx_pinctrl_desc,
  1329. &pdev->dev,
  1330. pdata);
  1331. if (IS_ERR(pctl)) {
  1332. dev_err(&pdev->dev, "Failed to register pinctrl\n");
  1333. return PTR_ERR(pctl);
  1334. }
  1335. platform_set_drvdata(pdev, pdata);
  1336. return 0;
  1337. }
  1338. static const struct of_device_id bcm281xx_pinctrl_of_match[] = {
  1339. { .compatible = "brcm,bcm11351-pinctrl", },
  1340. { },
  1341. };
  1342. static struct platform_driver bcm281xx_pinctrl_driver = {
  1343. .driver = {
  1344. .name = "bcm281xx-pinctrl",
  1345. .of_match_table = bcm281xx_pinctrl_of_match,
  1346. },
  1347. };
  1348. module_platform_driver_probe(bcm281xx_pinctrl_driver, bcm281xx_pinctrl_probe);
  1349. MODULE_AUTHOR("Broadcom Corporation <bcm-kernel-feedback-list@broadcom.com>");
  1350. MODULE_AUTHOR("Sherman Yin <syin@broadcom.com>");
  1351. MODULE_DESCRIPTION("Broadcom BCM281xx pinctrl driver");
  1352. MODULE_LICENSE("GPL v2");