pinmux.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /*
  2. * Copyright (c) 2010-2013, NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef _TEGRA30_PINMUX_H_
  17. #define _TEGRA30_PINMUX_H_
  18. /*
  19. * Pin groups which we adjust. There are three basic attributes of each pin
  20. * group which use this enum:
  21. *
  22. * - function
  23. * - pullup / pulldown
  24. * - tristate or normal
  25. */
  26. enum pmux_pingrp {
  27. PINGRP_ULPI_DATA0 = 0, /* offset 0x3000 */
  28. PINGRP_ULPI_DATA1,
  29. PINGRP_ULPI_DATA2,
  30. PINGRP_ULPI_DATA3,
  31. PINGRP_ULPI_DATA4,
  32. PINGRP_ULPI_DATA5,
  33. PINGRP_ULPI_DATA6,
  34. PINGRP_ULPI_DATA7,
  35. PINGRP_ULPI_CLK,
  36. PINGRP_ULPI_DIR,
  37. PINGRP_ULPI_NXT,
  38. PINGRP_ULPI_STP,
  39. PINGRP_DAP3_FS,
  40. PINGRP_DAP3_DIN,
  41. PINGRP_DAP3_DOUT,
  42. PINGRP_DAP3_SCLK,
  43. PINGRP_GPIO_PV0,
  44. PINGRP_GPIO_PV1,
  45. PINGRP_SDMMC1_CLK,
  46. PINGRP_SDMMC1_CMD,
  47. PINGRP_SDMMC1_DAT3,
  48. PINGRP_SDMMC1_DAT2,
  49. PINGRP_SDMMC1_DAT1,
  50. PINGRP_SDMMC1_DAT0,
  51. PINGRP_GPIO_PV2,
  52. PINGRP_GPIO_PV3,
  53. PINGRP_CLK2_OUT,
  54. PINGRP_CLK2_REQ,
  55. PINGRP_LCD_PWR1,
  56. PINGRP_LCD_PWR2,
  57. PINGRP_LCD_SDIN,
  58. PINGRP_LCD_SDOUT,
  59. PINGRP_LCD_WR_N,
  60. PINGRP_LCD_CS0_N,
  61. PINGRP_LCD_DC0,
  62. PINGRP_LCD_SCK,
  63. PINGRP_LCD_PWR0,
  64. PINGRP_LCD_PCLK,
  65. PINGRP_LCD_DE,
  66. PINGRP_LCD_HSYNC,
  67. PINGRP_LCD_VSYNC,
  68. PINGRP_LCD_D0,
  69. PINGRP_LCD_D1,
  70. PINGRP_LCD_D2,
  71. PINGRP_LCD_D3,
  72. PINGRP_LCD_D4,
  73. PINGRP_LCD_D5,
  74. PINGRP_LCD_D6,
  75. PINGRP_LCD_D7,
  76. PINGRP_LCD_D8,
  77. PINGRP_LCD_D9,
  78. PINGRP_LCD_D10,
  79. PINGRP_LCD_D11,
  80. PINGRP_LCD_D12,
  81. PINGRP_LCD_D13,
  82. PINGRP_LCD_D14,
  83. PINGRP_LCD_D15,
  84. PINGRP_LCD_D16,
  85. PINGRP_LCD_D17,
  86. PINGRP_LCD_D18,
  87. PINGRP_LCD_D19,
  88. PINGRP_LCD_D20,
  89. PINGRP_LCD_D21,
  90. PINGRP_LCD_D22,
  91. PINGRP_LCD_D23,
  92. PINGRP_LCD_CS1_N,
  93. PINGRP_LCD_M1,
  94. PINGRP_LCD_DC1,
  95. PINGRP_HDMI_INT,
  96. PINGRP_DDC_SCL,
  97. PINGRP_DDC_SDA,
  98. PINGRP_CRT_HSYNC,
  99. PINGRP_CRT_VSYNC,
  100. PINGRP_VI_D0,
  101. PINGRP_VI_D1,
  102. PINGRP_VI_D2,
  103. PINGRP_VI_D3,
  104. PINGRP_VI_D4,
  105. PINGRP_VI_D5,
  106. PINGRP_VI_D6,
  107. PINGRP_VI_D7,
  108. PINGRP_VI_D8,
  109. PINGRP_VI_D9,
  110. PINGRP_VI_D10,
  111. PINGRP_VI_D11,
  112. PINGRP_VI_PCLK,
  113. PINGRP_VI_MCLK,
  114. PINGRP_VI_VSYNC,
  115. PINGRP_VI_HSYNC,
  116. PINGRP_UART2_RXD,
  117. PINGRP_UART2_TXD,
  118. PINGRP_UART2_RTS_N,
  119. PINGRP_UART2_CTS_N,
  120. PINGRP_UART3_TXD,
  121. PINGRP_UART3_RXD,
  122. PINGRP_UART3_CTS_N,
  123. PINGRP_UART3_RTS_N,
  124. PINGRP_GPIO_PU0,
  125. PINGRP_GPIO_PU1,
  126. PINGRP_GPIO_PU2,
  127. PINGRP_GPIO_PU3,
  128. PINGRP_GPIO_PU4,
  129. PINGRP_GPIO_PU5,
  130. PINGRP_GPIO_PU6,
  131. PINGRP_GEN1_I2C_SDA,
  132. PINGRP_GEN1_I2C_SCL,
  133. PINGRP_DAP4_FS,
  134. PINGRP_DAP4_DIN,
  135. PINGRP_DAP4_DOUT,
  136. PINGRP_DAP4_SCLK,
  137. PINGRP_CLK3_OUT,
  138. PINGRP_CLK3_REQ,
  139. PINGRP_GMI_WP_N,
  140. PINGRP_GMI_IORDY,
  141. PINGRP_GMI_WAIT,
  142. PINGRP_GMI_ADV_N,
  143. PINGRP_GMI_CLK,
  144. PINGRP_GMI_CS0_N,
  145. PINGRP_GMI_CS1_N,
  146. PINGRP_GMI_CS2_N,
  147. PINGRP_GMI_CS3_N,
  148. PINGRP_GMI_CS4_N,
  149. PINGRP_GMI_CS6_N,
  150. PINGRP_GMI_CS7_N,
  151. PINGRP_GMI_AD0,
  152. PINGRP_GMI_AD1,
  153. PINGRP_GMI_AD2,
  154. PINGRP_GMI_AD3,
  155. PINGRP_GMI_AD4,
  156. PINGRP_GMI_AD5,
  157. PINGRP_GMI_AD6,
  158. PINGRP_GMI_AD7,
  159. PINGRP_GMI_AD8,
  160. PINGRP_GMI_AD9,
  161. PINGRP_GMI_AD10,
  162. PINGRP_GMI_AD11,
  163. PINGRP_GMI_AD12,
  164. PINGRP_GMI_AD13,
  165. PINGRP_GMI_AD14,
  166. PINGRP_GMI_AD15,
  167. PINGRP_GMI_A16,
  168. PINGRP_GMI_A17,
  169. PINGRP_GMI_A18,
  170. PINGRP_GMI_A19,
  171. PINGRP_GMI_WR_N,
  172. PINGRP_GMI_OE_N,
  173. PINGRP_GMI_DQS,
  174. PINGRP_GMI_RST_N,
  175. PINGRP_GEN2_I2C_SCL,
  176. PINGRP_GEN2_I2C_SDA,
  177. PINGRP_SDMMC4_CLK,
  178. PINGRP_SDMMC4_CMD,
  179. PINGRP_SDMMC4_DAT0,
  180. PINGRP_SDMMC4_DAT1,
  181. PINGRP_SDMMC4_DAT2,
  182. PINGRP_SDMMC4_DAT3,
  183. PINGRP_SDMMC4_DAT4,
  184. PINGRP_SDMMC4_DAT5,
  185. PINGRP_SDMMC4_DAT6,
  186. PINGRP_SDMMC4_DAT7,
  187. PINGRP_SDMMC4_RST_N,
  188. PINGRP_CAM_MCLK,
  189. PINGRP_GPIO_PCC1,
  190. PINGRP_GPIO_PBB0,
  191. PINGRP_CAM_I2C_SCL,
  192. PINGRP_CAM_I2C_SDA,
  193. PINGRP_GPIO_PBB3,
  194. PINGRP_GPIO_PBB4,
  195. PINGRP_GPIO_PBB5,
  196. PINGRP_GPIO_PBB6,
  197. PINGRP_GPIO_PBB7,
  198. PINGRP_GPIO_PCC2,
  199. PINGRP_JTAG_RTCK,
  200. PINGRP_PWR_I2C_SCL,
  201. PINGRP_PWR_I2C_SDA,
  202. PINGRP_KB_ROW0,
  203. PINGRP_KB_ROW1,
  204. PINGRP_KB_ROW2,
  205. PINGRP_KB_ROW3,
  206. PINGRP_KB_ROW4,
  207. PINGRP_KB_ROW5,
  208. PINGRP_KB_ROW6,
  209. PINGRP_KB_ROW7,
  210. PINGRP_KB_ROW8,
  211. PINGRP_KB_ROW9,
  212. PINGRP_KB_ROW10,
  213. PINGRP_KB_ROW11,
  214. PINGRP_KB_ROW12,
  215. PINGRP_KB_ROW13,
  216. PINGRP_KB_ROW14,
  217. PINGRP_KB_ROW15,
  218. PINGRP_KB_COL0,
  219. PINGRP_KB_COL1,
  220. PINGRP_KB_COL2,
  221. PINGRP_KB_COL3,
  222. PINGRP_KB_COL4,
  223. PINGRP_KB_COL5,
  224. PINGRP_KB_COL6,
  225. PINGRP_KB_COL7,
  226. PINGRP_CLK_32K_OUT,
  227. PINGRP_SYS_CLK_REQ,
  228. PINGRP_CORE_PWR_REQ,
  229. PINGRP_CPU_PWR_REQ,
  230. PINGRP_PWR_INT_N,
  231. PINGRP_CLK_32K_IN,
  232. PINGRP_OWR,
  233. PINGRP_DAP1_FS,
  234. PINGRP_DAP1_DIN,
  235. PINGRP_DAP1_DOUT,
  236. PINGRP_DAP1_SCLK,
  237. PINGRP_CLK1_REQ,
  238. PINGRP_CLK1_OUT,
  239. PINGRP_SPDIF_IN,
  240. PINGRP_SPDIF_OUT,
  241. PINGRP_DAP2_FS,
  242. PINGRP_DAP2_DIN,
  243. PINGRP_DAP2_DOUT,
  244. PINGRP_DAP2_SCLK,
  245. PINGRP_SPI2_MOSI,
  246. PINGRP_SPI2_MISO,
  247. PINGRP_SPI2_CS0_N,
  248. PINGRP_SPI2_SCK,
  249. PINGRP_SPI1_MOSI,
  250. PINGRP_SPI1_SCK,
  251. PINGRP_SPI1_CS0_N,
  252. PINGRP_SPI1_MISO,
  253. PINGRP_SPI2_CS1_N,
  254. PINGRP_SPI2_CS2_N,
  255. PINGRP_SDMMC3_CLK,
  256. PINGRP_SDMMC3_CMD,
  257. PINGRP_SDMMC3_DAT0,
  258. PINGRP_SDMMC3_DAT1,
  259. PINGRP_SDMMC3_DAT2,
  260. PINGRP_SDMMC3_DAT3,
  261. PINGRP_SDMMC3_DAT4,
  262. PINGRP_SDMMC3_DAT5,
  263. PINGRP_SDMMC3_DAT6,
  264. PINGRP_SDMMC3_DAT7,
  265. PINGRP_PEX_L0_PRSNT_N,
  266. PINGRP_PEX_L0_RST_N,
  267. PINGRP_PEX_L0_CLKREQ_N,
  268. PINGRP_PEX_WAKE_N,
  269. PINGRP_PEX_L1_PRSNT_N,
  270. PINGRP_PEX_L1_RST_N,
  271. PINGRP_PEX_L1_CLKREQ_N,
  272. PINGRP_PEX_L2_PRSNT_N,
  273. PINGRP_PEX_L2_RST_N,
  274. PINGRP_PEX_L2_CLKREQ_N,
  275. PINGRP_HDMI_CEC, /* offset 0x33e0 */
  276. PINGRP_COUNT,
  277. };
  278. enum pdrive_pingrp {
  279. PDRIVE_PINGROUP_AO1 = 0, /* offset 0x868 */
  280. PDRIVE_PINGROUP_AO2,
  281. PDRIVE_PINGROUP_AT1,
  282. PDRIVE_PINGROUP_AT2,
  283. PDRIVE_PINGROUP_AT3,
  284. PDRIVE_PINGROUP_AT4,
  285. PDRIVE_PINGROUP_AT5,
  286. PDRIVE_PINGROUP_CDEV1,
  287. PDRIVE_PINGROUP_CDEV2,
  288. PDRIVE_PINGROUP_CSUS,
  289. PDRIVE_PINGROUP_DAP1,
  290. PDRIVE_PINGROUP_DAP2,
  291. PDRIVE_PINGROUP_DAP3,
  292. PDRIVE_PINGROUP_DAP4,
  293. PDRIVE_PINGROUP_DBG,
  294. PDRIVE_PINGROUP_LCD1,
  295. PDRIVE_PINGROUP_LCD2,
  296. PDRIVE_PINGROUP_SDIO2,
  297. PDRIVE_PINGROUP_SDIO3,
  298. PDRIVE_PINGROUP_SPI,
  299. PDRIVE_PINGROUP_UAA,
  300. PDRIVE_PINGROUP_UAB,
  301. PDRIVE_PINGROUP_UART2,
  302. PDRIVE_PINGROUP_UART3,
  303. PDRIVE_PINGROUP_VI1 = 24, /* offset 0x8c8 */
  304. PDRIVE_PINGROUP_SDIO1 = 33, /* offset 0x8ec */
  305. PDRIVE_PINGROUP_CRT = 36, /* offset 0x8f8 */
  306. PDRIVE_PINGROUP_DDC,
  307. PDRIVE_PINGROUP_GMA,
  308. PDRIVE_PINGROUP_GMB,
  309. PDRIVE_PINGROUP_GMC,
  310. PDRIVE_PINGROUP_GMD,
  311. PDRIVE_PINGROUP_GME,
  312. PDRIVE_PINGROUP_GMF,
  313. PDRIVE_PINGROUP_GMG,
  314. PDRIVE_PINGROUP_GMH,
  315. PDRIVE_PINGROUP_OWR,
  316. PDRIVE_PINGROUP_UAD,
  317. PDRIVE_PINGROUP_GPV,
  318. PDRIVE_PINGROUP_DEV3 = 49, /* offset 0x92c */
  319. PDRIVE_PINGROUP_CEC = 52, /* offset 0x938 */
  320. PDRIVE_PINGROUP_COUNT,
  321. };
  322. /*
  323. * Functions which can be assigned to each of the pin groups. The values here
  324. * bear no relation to the values programmed into pinmux registers and are
  325. * purely a convenience. The translation is done through a table search.
  326. */
  327. enum pmux_func {
  328. PMUX_FUNC_AHB_CLK,
  329. PMUX_FUNC_APB_CLK,
  330. PMUX_FUNC_AUDIO_SYNC,
  331. PMUX_FUNC_CRT,
  332. PMUX_FUNC_DAP1,
  333. PMUX_FUNC_DAP2,
  334. PMUX_FUNC_DAP3,
  335. PMUX_FUNC_DAP4,
  336. PMUX_FUNC_DAP5,
  337. PMUX_FUNC_DISPA,
  338. PMUX_FUNC_DISPB,
  339. PMUX_FUNC_EMC_TEST0_DLL,
  340. PMUX_FUNC_EMC_TEST1_DLL,
  341. PMUX_FUNC_GMI,
  342. PMUX_FUNC_GMI_INT,
  343. PMUX_FUNC_HDMI,
  344. PMUX_FUNC_I2C1,
  345. PMUX_FUNC_I2C2,
  346. PMUX_FUNC_I2C3,
  347. PMUX_FUNC_IDE,
  348. PMUX_FUNC_KBC,
  349. PMUX_FUNC_MIO,
  350. PMUX_FUNC_MIPI_HS,
  351. PMUX_FUNC_NAND,
  352. PMUX_FUNC_OSC,
  353. PMUX_FUNC_OWR,
  354. PMUX_FUNC_PCIE,
  355. PMUX_FUNC_PLLA_OUT,
  356. PMUX_FUNC_PLLC_OUT1,
  357. PMUX_FUNC_PLLM_OUT1,
  358. PMUX_FUNC_PLLP_OUT2,
  359. PMUX_FUNC_PLLP_OUT3,
  360. PMUX_FUNC_PLLP_OUT4,
  361. PMUX_FUNC_PWM,
  362. PMUX_FUNC_PWR_INTR,
  363. PMUX_FUNC_PWR_ON,
  364. PMUX_FUNC_RTCK,
  365. PMUX_FUNC_SDMMC1,
  366. PMUX_FUNC_SDMMC2,
  367. PMUX_FUNC_SDMMC3,
  368. PMUX_FUNC_SDMMC4,
  369. PMUX_FUNC_SFLASH,
  370. PMUX_FUNC_SPDIF,
  371. PMUX_FUNC_SPI1,
  372. PMUX_FUNC_SPI2,
  373. PMUX_FUNC_SPI2_ALT,
  374. PMUX_FUNC_SPI3,
  375. PMUX_FUNC_SPI4,
  376. PMUX_FUNC_TRACE,
  377. PMUX_FUNC_TWC,
  378. PMUX_FUNC_UARTA,
  379. PMUX_FUNC_UARTB,
  380. PMUX_FUNC_UARTC,
  381. PMUX_FUNC_UARTD,
  382. PMUX_FUNC_UARTE,
  383. PMUX_FUNC_ULPI,
  384. PMUX_FUNC_VI,
  385. PMUX_FUNC_VI_SENSOR_CLK,
  386. PMUX_FUNC_XIO,
  387. PMUX_FUNC_BLINK,
  388. PMUX_FUNC_CEC,
  389. PMUX_FUNC_CLK12,
  390. PMUX_FUNC_DAP,
  391. PMUX_FUNC_DAPSDMMC2,
  392. PMUX_FUNC_DDR,
  393. PMUX_FUNC_DEV3,
  394. PMUX_FUNC_DTV,
  395. PMUX_FUNC_VI_ALT1,
  396. PMUX_FUNC_VI_ALT2,
  397. PMUX_FUNC_VI_ALT3,
  398. PMUX_FUNC_EMC_DLL,
  399. PMUX_FUNC_EXTPERIPH1,
  400. PMUX_FUNC_EXTPERIPH2,
  401. PMUX_FUNC_EXTPERIPH3,
  402. PMUX_FUNC_GMI_ALT,
  403. PMUX_FUNC_HDA,
  404. PMUX_FUNC_HSI,
  405. PMUX_FUNC_I2C4,
  406. PMUX_FUNC_I2C5,
  407. PMUX_FUNC_I2CPWR,
  408. PMUX_FUNC_I2S0,
  409. PMUX_FUNC_I2S1,
  410. PMUX_FUNC_I2S2,
  411. PMUX_FUNC_I2S3,
  412. PMUX_FUNC_I2S4,
  413. PMUX_FUNC_NAND_ALT,
  414. PMUX_FUNC_POPSDIO4,
  415. PMUX_FUNC_POPSDMMC4,
  416. PMUX_FUNC_PWM0,
  417. PMUX_FUNC_PWM1,
  418. PMUX_FUNC_PWM2,
  419. PMUX_FUNC_PWM3,
  420. PMUX_FUNC_SATA,
  421. PMUX_FUNC_SPI5,
  422. PMUX_FUNC_SPI6,
  423. PMUX_FUNC_SYSCLK,
  424. PMUX_FUNC_VGP1,
  425. PMUX_FUNC_VGP2,
  426. PMUX_FUNC_VGP3,
  427. PMUX_FUNC_VGP4,
  428. PMUX_FUNC_VGP5,
  429. PMUX_FUNC_VGP6,
  430. PMUX_FUNC_CLK_12M_OUT,
  431. PMUX_FUNC_HDCP,
  432. PMUX_FUNC_TEST,
  433. PMUX_FUNC_CORE_PWR_REQ,
  434. PMUX_FUNC_CPU_PWR_REQ,
  435. PMUX_FUNC_PWR_INT_N,
  436. PMUX_FUNC_CLK_32K_IN,
  437. PMUX_FUNC_SAFE,
  438. PMUX_FUNC_MAX,
  439. PMUX_FUNC_RSVD1 = 0x8000,
  440. PMUX_FUNC_RSVD2 = 0x8001,
  441. PMUX_FUNC_RSVD3 = 0x8002,
  442. PMUX_FUNC_RSVD4 = 0x8003,
  443. };
  444. /* return 1 if a pmux_func is in range */
  445. #define pmux_func_isvalid(func) ((((func) >= 0) && ((func) < PMUX_FUNC_MAX)) \
  446. || (((func) >= PMUX_FUNC_RSVD1) && ((func) <= PMUX_FUNC_RSVD4)))
  447. /* return 1 if a pingrp is in range */
  448. #define pmux_pingrp_isvalid(pin) (((pin) >= 0) && ((pin) < PINGRP_COUNT))
  449. /* The pullup/pulldown state of a pin group */
  450. enum pmux_pull {
  451. PMUX_PULL_NORMAL = 0,
  452. PMUX_PULL_DOWN,
  453. PMUX_PULL_UP,
  454. };
  455. /* return 1 if a pin_pupd_is in range */
  456. #define pmux_pin_pupd_isvalid(pupd) (((pupd) >= PMUX_PULL_NORMAL) && \
  457. ((pupd) <= PMUX_PULL_UP))
  458. /* Defines whether a pin group is tristated or in normal operation */
  459. enum pmux_tristate {
  460. PMUX_TRI_NORMAL = 0,
  461. PMUX_TRI_TRISTATE = 1,
  462. };
  463. /* return 1 if a pin_tristate_is in range */
  464. #define pmux_pin_tristate_isvalid(tristate) (((tristate) >= PMUX_TRI_NORMAL) \
  465. && ((tristate) <= PMUX_TRI_TRISTATE))
  466. enum pmux_pin_io {
  467. PMUX_PIN_OUTPUT = 0,
  468. PMUX_PIN_INPUT = 1,
  469. };
  470. /* return 1 if a pin_io_is in range */
  471. #define pmux_pin_io_isvalid(io) (((io) >= PMUX_PIN_OUTPUT) && \
  472. ((io) <= PMUX_PIN_INPUT))
  473. enum pmux_pin_lock {
  474. PMUX_PIN_LOCK_DEFAULT = 0,
  475. PMUX_PIN_LOCK_DISABLE,
  476. PMUX_PIN_LOCK_ENABLE,
  477. };
  478. /* return 1 if a pin_lock is in range */
  479. #define pmux_pin_lock_isvalid(lock) (((lock) >= PMUX_PIN_LOCK_DEFAULT) && \
  480. ((lock) <= PMUX_PIN_LOCK_ENABLE))
  481. enum pmux_pin_od {
  482. PMUX_PIN_OD_DEFAULT = 0,
  483. PMUX_PIN_OD_DISABLE,
  484. PMUX_PIN_OD_ENABLE,
  485. };
  486. /* return 1 if a pin_od is in range */
  487. #define pmux_pin_od_isvalid(od) (((od) >= PMUX_PIN_OD_DEFAULT) && \
  488. ((od) <= PMUX_PIN_OD_ENABLE))
  489. enum pmux_pin_ioreset {
  490. PMUX_PIN_IO_RESET_DEFAULT = 0,
  491. PMUX_PIN_IO_RESET_DISABLE,
  492. PMUX_PIN_IO_RESET_ENABLE,
  493. };
  494. /* return 1 if a pin_ioreset_is in range */
  495. #define pmux_pin_ioreset_isvalid(ioreset) \
  496. (((ioreset) >= PMUX_PIN_IO_RESET_DEFAULT) && \
  497. ((ioreset) <= PMUX_PIN_IO_RESET_ENABLE))
  498. /* Available power domains used by pin groups */
  499. enum pmux_vddio {
  500. PMUX_VDDIO_BB = 0,
  501. PMUX_VDDIO_LCD,
  502. PMUX_VDDIO_VI,
  503. PMUX_VDDIO_UART,
  504. PMUX_VDDIO_DDR,
  505. PMUX_VDDIO_NAND,
  506. PMUX_VDDIO_SYS,
  507. PMUX_VDDIO_AUDIO,
  508. PMUX_VDDIO_SD,
  509. PMUX_VDDIO_CAM,
  510. PMUX_VDDIO_GMI,
  511. PMUX_VDDIO_PEXCTL,
  512. PMUX_VDDIO_SDMMC1,
  513. PMUX_VDDIO_SDMMC3,
  514. PMUX_VDDIO_SDMMC4,
  515. PMUX_VDDIO_NONE
  516. };
  517. #define PGRP_SLWF_NONE -1
  518. #define PGRP_SLWF_MAX 3
  519. #define PGRP_SLWR_NONE PGRP_SLWF_NONE
  520. #define PGRP_SLWR_MAX PGRP_SLWF_MAX
  521. #define PGRP_DRVUP_NONE -1
  522. #define PGRP_DRVUP_MAX 127
  523. #define PGRP_DRVDN_NONE PGRP_DRVUP_NONE
  524. #define PGRP_DRVDN_MAX PGRP_DRVUP_MAX
  525. /* return 1 if a padgrp is in range */
  526. #define pmux_padgrp_isvalid(pd) (((pd) >= 0) && ((pd) < PDRIVE_PINGROUP_COUNT))
  527. /* return 1 if a slew-rate rising/falling edge value is in range */
  528. #define pmux_pad_slw_isvalid(slw) (((slw) >= 0) && ((slw) <= PGRP_SLWF_MAX))
  529. /* return 1 if a driver output pull-up/down strength code value is in range */
  530. #define pmux_pad_drv_isvalid(drv) (((drv) >= 0) && ((drv) <= PGRP_DRVUP_MAX))
  531. /* return 1 if a low-power mode value is in range */
  532. #define pmux_pad_lpmd_isvalid(lpm) (((lpm) >= 0) && ((lpm) <= PGRP_LPMD_X))
  533. /* Defines a pin group cfg's low-power mode select */
  534. enum pgrp_lpmd {
  535. PGRP_LPMD_X8 = 0,
  536. PGRP_LPMD_X4,
  537. PGRP_LPMD_X2,
  538. PGRP_LPMD_X,
  539. PGRP_LPMD_NONE = -1,
  540. };
  541. /* Defines whether a pin group cfg's schmidt is enabled or not */
  542. enum pgrp_schmt {
  543. PGRP_SCHMT_DISABLE = 0,
  544. PGRP_SCHMT_ENABLE = 1,
  545. };
  546. /* Defines whether a pin group cfg's high-speed mode is enabled or not */
  547. enum pgrp_hsm {
  548. PGRP_HSM_DISABLE = 0,
  549. PGRP_HSM_ENABLE = 1,
  550. };
  551. /*
  552. * This defines the configuration for a pin group's pad control config
  553. */
  554. struct padctrl_config {
  555. enum pdrive_pingrp padgrp; /* pin group PDRIVE_PINGRP_x */
  556. int slwf; /* falling edge slew */
  557. int slwr; /* rising edge slew */
  558. int drvup; /* pull-up drive strength */
  559. int drvdn; /* pull-down drive strength */
  560. enum pgrp_lpmd lpmd; /* low-power mode selection */
  561. enum pgrp_schmt schmt; /* schmidt enable */
  562. enum pgrp_hsm hsm; /* high-speed mode enable */
  563. };
  564. /* t30 pin drive group and pin mux registers */
  565. #define PDRIVE_PINGROUP_OFFSET (0x868 >> 2)
  566. #define PMUX_OFFSET ((0x3000 >> 2) - PDRIVE_PINGROUP_OFFSET - \
  567. PDRIVE_PINGROUP_COUNT)
  568. struct pmux_tri_ctlr {
  569. uint pmt_reserved0; /* ABP_MISC_PP_ reserved offset 00 */
  570. uint pmt_reserved1; /* ABP_MISC_PP_ reserved offset 04 */
  571. uint pmt_strap_opt_a; /* _STRAPPING_OPT_A_0, offset 08 */
  572. uint pmt_reserved2; /* ABP_MISC_PP_ reserved offset 0C */
  573. uint pmt_reserved3; /* ABP_MISC_PP_ reserved offset 10 */
  574. uint pmt_reserved4[4]; /* _TRI_STATE_REG_A/B/C/D in t20 */
  575. uint pmt_cfg_ctl; /* _CONFIG_CTL_0, offset 24 */
  576. uint pmt_reserved[528]; /* ABP_MISC_PP_ reserved offs 28-864 */
  577. uint pmt_drive[PDRIVE_PINGROUP_COUNT]; /* pin drive grps offs 868 */
  578. uint pmt_reserved5[PMUX_OFFSET];
  579. uint pmt_ctl[PINGRP_COUNT]; /* mux/pupd/tri regs, offset 0x3000 */
  580. };
  581. /*
  582. * This defines the configuration for a pin, including the function assigned,
  583. * pull up/down settings and tristate settings. Having set up one of these
  584. * you can call pinmux_config_pingroup() to configure a pin in one step. Also
  585. * available is pinmux_config_table() to configure a list of pins.
  586. */
  587. struct pingroup_config {
  588. enum pmux_pingrp pingroup; /* pin group PINGRP_... */
  589. enum pmux_func func; /* function to assign FUNC_... */
  590. enum pmux_pull pull; /* pull up/down/normal PMUX_PULL_...*/
  591. enum pmux_tristate tristate; /* tristate or normal PMUX_TRI_... */
  592. enum pmux_pin_io io; /* input or output PMUX_PIN_... */
  593. enum pmux_pin_lock lock; /* lock enable/disable PMUX_PIN... */
  594. enum pmux_pin_od od; /* open-drain or push-pull driver */
  595. enum pmux_pin_ioreset ioreset; /* input/output reset PMUX_PIN... */
  596. };
  597. /* Set a pin group to tristate */
  598. void pinmux_tristate_enable(enum pmux_pingrp pin);
  599. /* Set a pin group to normal (non tristate) */
  600. void pinmux_tristate_disable(enum pmux_pingrp pin);
  601. /* Set the pull up/down feature for a pin group */
  602. void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd);
  603. /* Set the mux function for a pin group */
  604. void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func);
  605. /* Set the complete configuration for a pin group */
  606. void pinmux_config_pingroup(struct pingroup_config *config);
  607. /* Set a pin group to tristate or normal */
  608. void pinmux_set_tristate(enum pmux_pingrp pin, int enable);
  609. /* Set a pin group as input or output */
  610. void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io);
  611. /**
  612. * Configure a list of pin groups
  613. *
  614. * @param config List of config items
  615. * @param len Number of config items in list
  616. */
  617. void pinmux_config_table(struct pingroup_config *config, int len);
  618. /* Set a group of pins from a table */
  619. void pinmux_init(void);
  620. /**
  621. * Set the GP pad configs
  622. *
  623. * @param config List of config items
  624. * @param len Number of config items in list
  625. */
  626. void padgrp_config_table(struct padctrl_config *config, int len);
  627. #endif /* _TEGRA30_PINMUX_H_ */