pinmux.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors.
  3. * See file CREDITS for list of people who contributed to this
  4. * project.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  19. * MA 02111-1307 USA
  20. */
  21. /* Tegra20 pin multiplexing functions */
  22. #include <common.h>
  23. #include <asm/io.h>
  24. #include <asm/arch/tegra.h>
  25. #include <asm/arch/pinmux.h>
  26. /*
  27. * This defines the order of the pin mux control bits in the registers. For
  28. * some reason there is no correspendence between the tristate, pin mux and
  29. * pullup/pulldown registers.
  30. */
  31. enum pmux_ctlid {
  32. /* 0: APB_MISC_PP_PIN_MUX_CTL_A_0 */
  33. MUXCTL_UAA,
  34. MUXCTL_UAB,
  35. MUXCTL_UAC,
  36. MUXCTL_UAD,
  37. MUXCTL_UDA,
  38. MUXCTL_RESERVED5,
  39. MUXCTL_ATE,
  40. MUXCTL_RM,
  41. MUXCTL_ATB,
  42. MUXCTL_RESERVED9,
  43. MUXCTL_ATD,
  44. MUXCTL_ATC,
  45. MUXCTL_ATA,
  46. MUXCTL_KBCF,
  47. MUXCTL_KBCE,
  48. MUXCTL_SDMMC1,
  49. /* 16: APB_MISC_PP_PIN_MUX_CTL_B_0 */
  50. MUXCTL_GMA,
  51. MUXCTL_GMC,
  52. MUXCTL_HDINT,
  53. MUXCTL_SLXA,
  54. MUXCTL_OWC,
  55. MUXCTL_SLXC,
  56. MUXCTL_SLXD,
  57. MUXCTL_SLXK,
  58. MUXCTL_UCA,
  59. MUXCTL_UCB,
  60. MUXCTL_DTA,
  61. MUXCTL_DTB,
  62. MUXCTL_RESERVED28,
  63. MUXCTL_DTC,
  64. MUXCTL_DTD,
  65. MUXCTL_DTE,
  66. /* 32: APB_MISC_PP_PIN_MUX_CTL_C_0 */
  67. MUXCTL_DDC,
  68. MUXCTL_CDEV1,
  69. MUXCTL_CDEV2,
  70. MUXCTL_CSUS,
  71. MUXCTL_I2CP,
  72. MUXCTL_KBCA,
  73. MUXCTL_KBCB,
  74. MUXCTL_KBCC,
  75. MUXCTL_IRTX,
  76. MUXCTL_IRRX,
  77. MUXCTL_DAP1,
  78. MUXCTL_DAP2,
  79. MUXCTL_DAP3,
  80. MUXCTL_DAP4,
  81. MUXCTL_GMB,
  82. MUXCTL_GMD,
  83. /* 48: APB_MISC_PP_PIN_MUX_CTL_D_0 */
  84. MUXCTL_GME,
  85. MUXCTL_GPV,
  86. MUXCTL_GPU,
  87. MUXCTL_SPDO,
  88. MUXCTL_SPDI,
  89. MUXCTL_SDB,
  90. MUXCTL_SDC,
  91. MUXCTL_SDD,
  92. MUXCTL_SPIH,
  93. MUXCTL_SPIG,
  94. MUXCTL_SPIF,
  95. MUXCTL_SPIE,
  96. MUXCTL_SPID,
  97. MUXCTL_SPIC,
  98. MUXCTL_SPIB,
  99. MUXCTL_SPIA,
  100. /* 64: APB_MISC_PP_PIN_MUX_CTL_E_0 */
  101. MUXCTL_LPW0,
  102. MUXCTL_LPW1,
  103. MUXCTL_LPW2,
  104. MUXCTL_LSDI,
  105. MUXCTL_LSDA,
  106. MUXCTL_LSPI,
  107. MUXCTL_LCSN,
  108. MUXCTL_LDC,
  109. MUXCTL_LSCK,
  110. MUXCTL_LSC0,
  111. MUXCTL_LSC1,
  112. MUXCTL_LHS,
  113. MUXCTL_LVS,
  114. MUXCTL_LM0,
  115. MUXCTL_LM1,
  116. MUXCTL_LVP0,
  117. /* 80: APB_MISC_PP_PIN_MUX_CTL_F_0 */
  118. MUXCTL_LD0,
  119. MUXCTL_LD1,
  120. MUXCTL_LD2,
  121. MUXCTL_LD3,
  122. MUXCTL_LD4,
  123. MUXCTL_LD5,
  124. MUXCTL_LD6,
  125. MUXCTL_LD7,
  126. MUXCTL_LD8,
  127. MUXCTL_LD9,
  128. MUXCTL_LD10,
  129. MUXCTL_LD11,
  130. MUXCTL_LD12,
  131. MUXCTL_LD13,
  132. MUXCTL_LD14,
  133. MUXCTL_LD15,
  134. /* 96: APB_MISC_PP_PIN_MUX_CTL_G_0 */
  135. MUXCTL_LD16,
  136. MUXCTL_LD17,
  137. MUXCTL_LHP1,
  138. MUXCTL_LHP2,
  139. MUXCTL_LVP1,
  140. MUXCTL_LHP0,
  141. MUXCTL_RESERVED102,
  142. MUXCTL_LPP,
  143. MUXCTL_LDI,
  144. MUXCTL_PMC,
  145. MUXCTL_CRTP,
  146. MUXCTL_PTA,
  147. MUXCTL_RESERVED108,
  148. MUXCTL_KBCD,
  149. MUXCTL_GPU7,
  150. MUXCTL_DTF,
  151. MUXCTL_NONE = -1,
  152. };
  153. /*
  154. * And this defines the order of the pullup/pulldown controls which are again
  155. * in a different order
  156. */
  157. enum pmux_pullid {
  158. /* 0: APB_MISC_PP_PULLUPDOWN_REG_A_0 */
  159. PUCTL_ATA,
  160. PUCTL_ATB,
  161. PUCTL_ATC,
  162. PUCTL_ATD,
  163. PUCTL_ATE,
  164. PUCTL_DAP1,
  165. PUCTL_DAP2,
  166. PUCTL_DAP3,
  167. PUCTL_DAP4,
  168. PUCTL_DTA,
  169. PUCTL_DTB,
  170. PUCTL_DTC,
  171. PUCTL_DTD,
  172. PUCTL_DTE,
  173. PUCTL_DTF,
  174. PUCTL_GPV,
  175. /* 16: APB_MISC_PP_PULLUPDOWN_REG_B_0 */
  176. PUCTL_RM,
  177. PUCTL_I2CP,
  178. PUCTL_PTA,
  179. PUCTL_GPU7,
  180. PUCTL_KBCA,
  181. PUCTL_KBCB,
  182. PUCTL_KBCC,
  183. PUCTL_KBCD,
  184. PUCTL_SPDI,
  185. PUCTL_SPDO,
  186. PUCTL_GPSLXAU,
  187. PUCTL_CRTP,
  188. PUCTL_SLXC,
  189. PUCTL_SLXD,
  190. PUCTL_SLXK,
  191. /* 32: APB_MISC_PP_PULLUPDOWN_REG_C_0 */
  192. PUCTL_CDEV1,
  193. PUCTL_CDEV2,
  194. PUCTL_SPIA,
  195. PUCTL_SPIB,
  196. PUCTL_SPIC,
  197. PUCTL_SPID,
  198. PUCTL_SPIE,
  199. PUCTL_SPIF,
  200. PUCTL_SPIG,
  201. PUCTL_SPIH,
  202. PUCTL_IRTX,
  203. PUCTL_IRRX,
  204. PUCTL_GME,
  205. PUCTL_RESERVED45,
  206. PUCTL_XM2D,
  207. PUCTL_XM2C,
  208. /* 48: APB_MISC_PP_PULLUPDOWN_REG_D_0 */
  209. PUCTL_UAA,
  210. PUCTL_UAB,
  211. PUCTL_UAC,
  212. PUCTL_UAD,
  213. PUCTL_UCA,
  214. PUCTL_UCB,
  215. PUCTL_LD17,
  216. PUCTL_LD19_18,
  217. PUCTL_LD21_20,
  218. PUCTL_LD23_22,
  219. PUCTL_LS,
  220. PUCTL_LC,
  221. PUCTL_CSUS,
  222. PUCTL_DDRC,
  223. PUCTL_SDC,
  224. PUCTL_SDD,
  225. /* 64: APB_MISC_PP_PULLUPDOWN_REG_E_0 */
  226. PUCTL_KBCF,
  227. PUCTL_KBCE,
  228. PUCTL_PMCA,
  229. PUCTL_PMCB,
  230. PUCTL_PMCC,
  231. PUCTL_PMCD,
  232. PUCTL_PMCE,
  233. PUCTL_CK32,
  234. PUCTL_UDA,
  235. PUCTL_SDMMC1,
  236. PUCTL_GMA,
  237. PUCTL_GMB,
  238. PUCTL_GMC,
  239. PUCTL_GMD,
  240. PUCTL_DDC,
  241. PUCTL_OWC,
  242. PUCTL_NONE = -1
  243. };
  244. struct tegra_pingroup_desc {
  245. const char *name;
  246. enum pmux_func funcs[4];
  247. enum pmux_func func_safe;
  248. enum pmux_vddio vddio;
  249. enum pmux_ctlid ctl_id;
  250. enum pmux_pullid pull_id;
  251. };
  252. /* Converts a pmux_pingrp number to a tristate register: 0=A, 1=B, 2=C, 3=D */
  253. #define TRISTATE_REG(pmux_pingrp) ((pmux_pingrp) >> 5)
  254. /* Mask value for a tristate (within TRISTATE_REG(id)) */
  255. #define TRISTATE_MASK(pmux_pingrp) (1 << ((pmux_pingrp) & 0x1f))
  256. /* Converts a PUCTL id to a pull register: 0=A, 1=B...4=E */
  257. #define PULL_REG(pmux_pullid) ((pmux_pullid) >> 4)
  258. /* Converts a PUCTL id to a shift position */
  259. #define PULL_SHIFT(pmux_pullid) ((pmux_pullid << 1) & 0x1f)
  260. /* Converts a MUXCTL id to a ctl register: 0=A, 1=B...6=G */
  261. #define MUXCTL_REG(pmux_ctlid) ((pmux_ctlid) >> 4)
  262. /* Converts a MUXCTL id to a shift position */
  263. #define MUXCTL_SHIFT(pmux_ctlid) ((pmux_ctlid << 1) & 0x1f)
  264. /* Convenient macro for defining pin group properties */
  265. #define PINALL(pg_name, vdd, f0, f1, f2, f3, f_safe, mux, pupd) \
  266. { \
  267. .vddio = PMUX_VDDIO_ ## vdd, \
  268. .funcs = { \
  269. PMUX_FUNC_ ## f0, \
  270. PMUX_FUNC_ ## f1, \
  271. PMUX_FUNC_ ## f2, \
  272. PMUX_FUNC_ ## f3, \
  273. }, \
  274. .func_safe = PMUX_FUNC_ ## f_safe, \
  275. .ctl_id = mux, \
  276. .pull_id = pupd \
  277. }
  278. /* A normal pin group where the mux name and pull-up name match */
  279. #define PIN(pg_name, vdd, f0, f1, f2, f3, f_safe) \
  280. PINALL(pg_name, vdd, f0, f1, f2, f3, f_safe, \
  281. MUXCTL_ ## pg_name, PUCTL_ ## pg_name)
  282. /* A pin group where the pull-up name doesn't have a 1-1 mapping */
  283. #define PINP(pg_name, vdd, f0, f1, f2, f3, f_safe, pupd) \
  284. PINALL(pg_name, vdd, f0, f1, f2, f3, f_safe, \
  285. MUXCTL_ ## pg_name, PUCTL_ ## pupd)
  286. /* A pin group number which is not used */
  287. #define PIN_RESERVED \
  288. PIN(NONE, NONE, NONE, NONE, NONE, NONE, NONE)
  289. const struct tegra_pingroup_desc tegra_soc_pingroups[PINGRP_COUNT] = {
  290. PIN(ATA, NAND, IDE, NAND, GMI, RSVD, IDE),
  291. PIN(ATB, NAND, IDE, NAND, GMI, SDIO4, IDE),
  292. PIN(ATC, NAND, IDE, NAND, GMI, SDIO4, IDE),
  293. PIN(ATD, NAND, IDE, NAND, GMI, SDIO4, IDE),
  294. PIN(CDEV1, AUDIO, OSC, PLLA_OUT, PLLM_OUT1, AUDIO_SYNC, OSC),
  295. PIN(CDEV2, AUDIO, OSC, AHB_CLK, APB_CLK, PLLP_OUT4, OSC),
  296. PIN(CSUS, VI, PLLC_OUT1, PLLP_OUT2, PLLP_OUT3, VI_SENSOR_CLK,
  297. PLLC_OUT1),
  298. PIN(DAP1, AUDIO, DAP1, RSVD, GMI, SDIO2, DAP1),
  299. PIN(DAP2, AUDIO, DAP2, TWC, RSVD, GMI, DAP2),
  300. PIN(DAP3, BB, DAP3, RSVD, RSVD, RSVD, DAP3),
  301. PIN(DAP4, UART, DAP4, RSVD, GMI, RSVD, DAP4),
  302. PIN(DTA, VI, RSVD, SDIO2, VI, RSVD, RSVD4),
  303. PIN(DTB, VI, RSVD, RSVD, VI, SPI1, RSVD1),
  304. PIN(DTC, VI, RSVD, RSVD, VI, RSVD, RSVD1),
  305. PIN(DTD, VI, RSVD, SDIO2, VI, RSVD, RSVD1),
  306. PIN(DTE, VI, RSVD, RSVD, VI, SPI1, RSVD1),
  307. PINP(GPU, UART, PWM, UARTA, GMI, RSVD, RSVD4,
  308. GPSLXAU),
  309. PIN(GPV, SD, PCIE, RSVD, RSVD, RSVD, PCIE),
  310. PIN(I2CP, SYS, I2C, RSVD, RSVD, RSVD, RSVD4),
  311. PIN(IRTX, UART, UARTA, UARTB, GMI, SPI4, UARTB),
  312. PIN(IRRX, UART, UARTA, UARTB, GMI, SPI4, UARTB),
  313. PIN(KBCB, SYS, KBC, NAND, SDIO2, MIO, KBC),
  314. PIN(KBCA, SYS, KBC, NAND, SDIO2, EMC_TEST0_DLL, KBC),
  315. PINP(PMC, SYS, PWR_ON, PWR_INTR, RSVD, RSVD, PWR_ON, NONE),
  316. PIN(PTA, NAND, I2C2, HDMI, GMI, RSVD, RSVD4),
  317. PIN(RM, UART, I2C, RSVD, RSVD, RSVD, RSVD4),
  318. PIN(KBCE, SYS, KBC, NAND, OWR, RSVD, KBC),
  319. PIN(KBCF, SYS, KBC, NAND, TRACE, MIO, KBC),
  320. PIN(GMA, NAND, UARTE, SPI3, GMI, SDIO4, SPI3),
  321. PIN(GMC, NAND, UARTD, SPI4, GMI, SFLASH, SPI4),
  322. PIN(SDMMC1, BB, SDIO1, RSVD, UARTE, UARTA, RSVD2),
  323. PIN(OWC, SYS, OWR, RSVD, RSVD, RSVD, OWR),
  324. PIN(GME, NAND, RSVD, DAP5, GMI, SDIO4, GMI),
  325. PIN(SDC, SD, PWM, TWC, SDIO3, SPI3, TWC),
  326. PIN(SDD, SD, UARTA, PWM, SDIO3, SPI3, PWM),
  327. PIN_RESERVED,
  328. PINP(SLXA, SD, PCIE, SPI4, SDIO3, SPI2, PCIE, CRTP),
  329. PIN(SLXC, SD, SPDIF, SPI4, SDIO3, SPI2, SPI4),
  330. PIN(SLXD, SD, SPDIF, SPI4, SDIO3, SPI2, SPI4),
  331. PIN(SLXK, SD, PCIE, SPI4, SDIO3, SPI2, PCIE),
  332. PIN(SPDI, AUDIO, SPDIF, RSVD, I2C, SDIO2, RSVD2),
  333. PIN(SPDO, AUDIO, SPDIF, RSVD, I2C, SDIO2, RSVD2),
  334. PIN(SPIA, AUDIO, SPI1, SPI2, SPI3, GMI, GMI),
  335. PIN(SPIB, AUDIO, SPI1, SPI2, SPI3, GMI, GMI),
  336. PIN(SPIC, AUDIO, SPI1, SPI2, SPI3, GMI, GMI),
  337. PIN(SPID, AUDIO, SPI2, SPI1, SPI2_ALT, GMI, GMI),
  338. PIN(SPIE, AUDIO, SPI2, SPI1, SPI2_ALT, GMI, GMI),
  339. PIN(SPIF, AUDIO, SPI3, SPI1, SPI2, RSVD, RSVD4),
  340. PIN(SPIG, AUDIO, SPI3, SPI2, SPI2_ALT, I2C, SPI2_ALT),
  341. PIN(SPIH, AUDIO, SPI3, SPI2, SPI2_ALT, I2C, SPI2_ALT),
  342. PIN(UAA, BB, SPI3, MIPI_HS, UARTA, ULPI, MIPI_HS),
  343. PIN(UAB, BB, SPI2, MIPI_HS, UARTA, ULPI, MIPI_HS),
  344. PIN(UAC, BB, OWR, RSVD, RSVD, RSVD, RSVD4),
  345. PIN(UAD, UART, UARTB, SPDIF, UARTA, SPI4, SPDIF),
  346. PIN(UCA, UART, UARTC, RSVD, GMI, RSVD, RSVD4),
  347. PIN(UCB, UART, UARTC, PWM, GMI, RSVD, RSVD4),
  348. PIN_RESERVED,
  349. PIN(ATE, NAND, IDE, NAND, GMI, RSVD, IDE),
  350. PIN(KBCC, SYS, KBC, NAND, TRACE, EMC_TEST1_DLL, KBC),
  351. PIN_RESERVED,
  352. PIN_RESERVED,
  353. PIN(GMB, NAND, IDE, NAND, GMI, GMI_INT, GMI),
  354. PIN(GMD, NAND, RSVD, NAND, GMI, SFLASH, GMI),
  355. PIN(DDC, LCD, I2C2, RSVD, RSVD, RSVD, RSVD4),
  356. /* 64 */
  357. PINP(LD0, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  358. PINP(LD1, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  359. PINP(LD2, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  360. PINP(LD3, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  361. PINP(LD4, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  362. PINP(LD5, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  363. PINP(LD6, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  364. PINP(LD7, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  365. PINP(LD8, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  366. PINP(LD9, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  367. PINP(LD10, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  368. PINP(LD11, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  369. PINP(LD12, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  370. PINP(LD13, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  371. PINP(LD14, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  372. PINP(LD15, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  373. PINP(LD16, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
  374. PINP(LD17, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD17),
  375. PINP(LHP0, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD21_20),
  376. PINP(LHP1, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD19_18),
  377. PINP(LHP2, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD19_18),
  378. PINP(LVP0, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LC),
  379. PINP(LVP1, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD21_20),
  380. PINP(HDINT, LCD, HDMI, RSVD, RSVD, RSVD, HDMI , LC),
  381. PINP(LM0, LCD, DISPA, DISPB, SPI3, RSVD, RSVD4, LC),
  382. PINP(LM1, LCD, DISPA, DISPB, RSVD, CRT, RSVD3, LC),
  383. PINP(LVS, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LC),
  384. PINP(LSC0, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LC),
  385. PINP(LSC1, LCD, DISPA, DISPB, SPI3, HDMI, DISPA, LS),
  386. PINP(LSCK, LCD, DISPA, DISPB, SPI3, HDMI, DISPA, LS),
  387. PINP(LDC, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LS),
  388. PINP(LCSN, LCD, DISPA, DISPB, SPI3, RSVD, RSVD4, LS),
  389. /* 96 */
  390. PINP(LSPI, LCD, DISPA, DISPB, XIO, HDMI, DISPA, LC),
  391. PINP(LSDA, LCD, DISPA, DISPB, SPI3, HDMI, DISPA, LS),
  392. PINP(LSDI, LCD, DISPA, DISPB, SPI3, RSVD, DISPA, LS),
  393. PINP(LPW0, LCD, DISPA, DISPB, SPI3, HDMI, DISPA, LS),
  394. PINP(LPW1, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LS),
  395. PINP(LPW2, LCD, DISPA, DISPB, SPI3, HDMI, DISPA, LS),
  396. PINP(LDI, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD23_22),
  397. PINP(LHS, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LC),
  398. PINP(LPP, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD23_22),
  399. PIN_RESERVED,
  400. PIN(KBCD, SYS, KBC, NAND, SDIO2, MIO, KBC),
  401. PIN(GPU7, SYS, RTCK, RSVD, RSVD, RSVD, RTCK),
  402. PIN(DTF, VI, I2C3, RSVD, VI, RSVD, RSVD4),
  403. PIN(UDA, BB, SPI1, RSVD, UARTD, ULPI, RSVD2),
  404. PIN(CRTP, LCD, CRT, RSVD, RSVD, RSVD, RSVD),
  405. PINP(SDB, SD, UARTA, PWM, SDIO3, SPI2, PWM, NONE),
  406. /* these pin groups only have pullup and pull down control */
  407. PINALL(CK32, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
  408. PUCTL_NONE),
  409. PINALL(DDRC, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
  410. PUCTL_NONE),
  411. PINALL(PMCA, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
  412. PUCTL_NONE),
  413. PINALL(PMCB, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
  414. PUCTL_NONE),
  415. PINALL(PMCC, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
  416. PUCTL_NONE),
  417. PINALL(PMCD, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
  418. PUCTL_NONE),
  419. PINALL(PMCE, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
  420. PUCTL_NONE),
  421. PINALL(XM2C, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
  422. PUCTL_NONE),
  423. PINALL(XM2D, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
  424. PUCTL_NONE),
  425. };
  426. void pinmux_set_tristate(enum pmux_pingrp pin, int enable)
  427. {
  428. struct pmux_tri_ctlr *pmt =
  429. (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
  430. u32 *tri = &pmt->pmt_tri[TRISTATE_REG(pin)];
  431. u32 reg;
  432. reg = readl(tri);
  433. if (enable)
  434. reg |= TRISTATE_MASK(pin);
  435. else
  436. reg &= ~TRISTATE_MASK(pin);
  437. writel(reg, tri);
  438. }
  439. void pinmux_tristate_enable(enum pmux_pingrp pin)
  440. {
  441. pinmux_set_tristate(pin, 1);
  442. }
  443. void pinmux_tristate_disable(enum pmux_pingrp pin)
  444. {
  445. pinmux_set_tristate(pin, 0);
  446. }
  447. void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd)
  448. {
  449. struct pmux_tri_ctlr *pmt =
  450. (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
  451. enum pmux_pullid pull_id = tegra_soc_pingroups[pin].pull_id;
  452. u32 *pull = &pmt->pmt_pull[PULL_REG(pull_id)];
  453. u32 mask_bit;
  454. u32 reg;
  455. mask_bit = PULL_SHIFT(pull_id);
  456. reg = readl(pull);
  457. reg &= ~(0x3 << mask_bit);
  458. reg |= pupd << mask_bit;
  459. writel(reg, pull);
  460. }
  461. void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func)
  462. {
  463. struct pmux_tri_ctlr *pmt =
  464. (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
  465. enum pmux_ctlid mux_id = tegra_soc_pingroups[pin].ctl_id;
  466. u32 *muxctl = &pmt->pmt_ctl[MUXCTL_REG(mux_id)];
  467. u32 mask_bit;
  468. int i, mux = -1;
  469. u32 reg;
  470. assert(pmux_func_isvalid(func));
  471. /* Handle special values */
  472. if (func >= PMUX_FUNC_RSVD1) {
  473. mux = (func - PMUX_FUNC_RSVD1) & 0x3;
  474. } else {
  475. /* Search for the appropriate function */
  476. for (i = 0; i < 4; i++) {
  477. if (tegra_soc_pingroups[pin].funcs[i] == func) {
  478. mux = i;
  479. break;
  480. }
  481. }
  482. }
  483. assert(mux != -1);
  484. mask_bit = MUXCTL_SHIFT(mux_id);
  485. reg = readl(muxctl);
  486. reg &= ~(0x3 << mask_bit);
  487. reg |= mux << mask_bit;
  488. writel(reg, muxctl);
  489. }
  490. void pinmux_config_pingroup(const struct pingroup_config *config)
  491. {
  492. enum pmux_pingrp pin = config->pingroup;
  493. pinmux_set_func(pin, config->func);
  494. pinmux_set_pullupdown(pin, config->pull);
  495. pinmux_set_tristate(pin, config->tristate);
  496. }
  497. void pinmux_config_table(const struct pingroup_config *config, int len)
  498. {
  499. int i;
  500. for (i = 0; i < len; i++)
  501. pinmux_config_pingroup(&config[i]);
  502. }