pinmux.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. /*
  2. * (C) Copyright 2010,2011
  3. * NVIDIA Corporation <www.nvidia.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef _PINMUX_H_
  24. #define _PINMUX_H_
  25. /*
  26. * Pin groups which we adjust. There are three basic attributes of each pin
  27. * group which use this enum:
  28. *
  29. * - function
  30. * - pullup / pulldown
  31. * - tristate or normal
  32. */
  33. enum pmux_pingrp {
  34. /* APB_MISC_PP_TRISTATE_REG_A_0 */
  35. PINGRP_ATA,
  36. PINGRP_ATB,
  37. PINGRP_ATC,
  38. PINGRP_ATD,
  39. PINGRP_CDEV1,
  40. PINGRP_CDEV2,
  41. PINGRP_CSUS,
  42. PINGRP_DAP1,
  43. PINGRP_DAP2,
  44. PINGRP_DAP3,
  45. PINGRP_DAP4,
  46. PINGRP_DTA,
  47. PINGRP_DTB,
  48. PINGRP_DTC,
  49. PINGRP_DTD,
  50. PINGRP_DTE,
  51. PINGRP_GPU,
  52. PINGRP_GPV,
  53. PINGRP_I2CP,
  54. PINGRP_IRTX,
  55. PINGRP_IRRX,
  56. PINGRP_KBCB,
  57. PINGRP_KBCA,
  58. PINGRP_PMC,
  59. PINGRP_PTA,
  60. PINGRP_RM,
  61. PINGRP_KBCE,
  62. PINGRP_KBCF,
  63. PINGRP_GMA,
  64. PINGRP_GMC,
  65. PINGRP_SDIO1,
  66. PINGRP_OWC,
  67. /* 32: APB_MISC_PP_TRISTATE_REG_B_0 */
  68. PINGRP_GME,
  69. PINGRP_SDC,
  70. PINGRP_SDD,
  71. PINGRP_RESERVED0,
  72. PINGRP_SLXA,
  73. PINGRP_SLXC,
  74. PINGRP_SLXD,
  75. PINGRP_SLXK,
  76. PINGRP_SPDI,
  77. PINGRP_SPDO,
  78. PINGRP_SPIA,
  79. PINGRP_SPIB,
  80. PINGRP_SPIC,
  81. PINGRP_SPID,
  82. PINGRP_SPIE,
  83. PINGRP_SPIF,
  84. PINGRP_SPIG,
  85. PINGRP_SPIH,
  86. PINGRP_UAA,
  87. PINGRP_UAB,
  88. PINGRP_UAC,
  89. PINGRP_UAD,
  90. PINGRP_UCA,
  91. PINGRP_UCB,
  92. PINGRP_RESERVED1,
  93. PINGRP_ATE,
  94. PINGRP_KBCC,
  95. PINGRP_RESERVED2,
  96. PINGRP_RESERVED3,
  97. PINGRP_GMB,
  98. PINGRP_GMD,
  99. PINGRP_DDC,
  100. /* 64: APB_MISC_PP_TRISTATE_REG_C_0 */
  101. PINGRP_LD0,
  102. PINGRP_LD1,
  103. PINGRP_LD2,
  104. PINGRP_LD3,
  105. PINGRP_LD4,
  106. PINGRP_LD5,
  107. PINGRP_LD6,
  108. PINGRP_LD7,
  109. PINGRP_LD8,
  110. PINGRP_LD9,
  111. PINGRP_LD10,
  112. PINGRP_LD11,
  113. PINGRP_LD12,
  114. PINGRP_LD13,
  115. PINGRP_LD14,
  116. PINGRP_LD15,
  117. PINGRP_LD16,
  118. PINGRP_LD17,
  119. PINGRP_LHP0,
  120. PINGRP_LHP1,
  121. PINGRP_LHP2,
  122. PINGRP_LVP0,
  123. PINGRP_LVP1,
  124. PINGRP_HDINT,
  125. PINGRP_LM0,
  126. PINGRP_LM1,
  127. PINGRP_LVS,
  128. PINGRP_LSC0,
  129. PINGRP_LSC1,
  130. PINGRP_LSCK,
  131. PINGRP_LDC,
  132. PINGRP_LCSN,
  133. /* 96: APB_MISC_PP_TRISTATE_REG_D_0 */
  134. PINGRP_LSPI,
  135. PINGRP_LSDA,
  136. PINGRP_LSDI,
  137. PINGRP_LPW0,
  138. PINGRP_LPW1,
  139. PINGRP_LPW2,
  140. PINGRP_LDI,
  141. PINGRP_LHS,
  142. PINGRP_LPP,
  143. PINGRP_RESERVED4,
  144. PINGRP_KBCD,
  145. PINGRP_GPU7,
  146. PINGRP_DTF,
  147. PINGRP_UDA,
  148. PINGRP_CRTP,
  149. PINGRP_SDB,
  150. /* these pin groups only have pullup and pull down control */
  151. PINGRP_FIRST_NO_MUX,
  152. PINGRP_CK32 = PINGRP_FIRST_NO_MUX,
  153. PINGRP_DDRC,
  154. PINGRP_PMCA,
  155. PINGRP_PMCB,
  156. PINGRP_PMCC,
  157. PINGRP_PMCD,
  158. PINGRP_PMCE,
  159. PINGRP_XM2C,
  160. PINGRP_XM2D,
  161. PINGRP_COUNT,
  162. };
  163. /*
  164. * Functions which can be assigned to each of the pin groups. The values here
  165. * bear no relation to the values programmed into pinmux registers and are
  166. * purely a convenience. The translation is done through a table search.
  167. */
  168. enum pmux_func {
  169. PMUX_FUNC_AHB_CLK,
  170. PMUX_FUNC_APB_CLK,
  171. PMUX_FUNC_AUDIO_SYNC,
  172. PMUX_FUNC_CRT,
  173. PMUX_FUNC_DAP1,
  174. PMUX_FUNC_DAP2,
  175. PMUX_FUNC_DAP3,
  176. PMUX_FUNC_DAP4,
  177. PMUX_FUNC_DAP5,
  178. PMUX_FUNC_DISPA,
  179. PMUX_FUNC_DISPB,
  180. PMUX_FUNC_EMC_TEST0_DLL,
  181. PMUX_FUNC_EMC_TEST1_DLL,
  182. PMUX_FUNC_GMI,
  183. PMUX_FUNC_GMI_INT,
  184. PMUX_FUNC_HDMI,
  185. PMUX_FUNC_I2C,
  186. PMUX_FUNC_I2C2,
  187. PMUX_FUNC_I2C3,
  188. PMUX_FUNC_IDE,
  189. PMUX_FUNC_IRDA,
  190. PMUX_FUNC_KBC,
  191. PMUX_FUNC_MIO,
  192. PMUX_FUNC_MIPI_HS,
  193. PMUX_FUNC_NAND,
  194. PMUX_FUNC_OSC,
  195. PMUX_FUNC_OWR,
  196. PMUX_FUNC_PCIE,
  197. PMUX_FUNC_PLLA_OUT,
  198. PMUX_FUNC_PLLC_OUT1,
  199. PMUX_FUNC_PLLM_OUT1,
  200. PMUX_FUNC_PLLP_OUT2,
  201. PMUX_FUNC_PLLP_OUT3,
  202. PMUX_FUNC_PLLP_OUT4,
  203. PMUX_FUNC_PWM,
  204. PMUX_FUNC_PWR_INTR,
  205. PMUX_FUNC_PWR_ON,
  206. PMUX_FUNC_RTCK,
  207. PMUX_FUNC_SDIO1,
  208. PMUX_FUNC_SDIO2,
  209. PMUX_FUNC_SDIO3,
  210. PMUX_FUNC_SDIO4,
  211. PMUX_FUNC_SFLASH,
  212. PMUX_FUNC_SPDIF,
  213. PMUX_FUNC_SPI1,
  214. PMUX_FUNC_SPI2,
  215. PMUX_FUNC_SPI2_ALT,
  216. PMUX_FUNC_SPI3,
  217. PMUX_FUNC_SPI4,
  218. PMUX_FUNC_TRACE,
  219. PMUX_FUNC_TWC,
  220. PMUX_FUNC_UARTA,
  221. PMUX_FUNC_UARTB,
  222. PMUX_FUNC_UARTC,
  223. PMUX_FUNC_UARTD,
  224. PMUX_FUNC_UARTE,
  225. PMUX_FUNC_ULPI,
  226. PMUX_FUNC_VI,
  227. PMUX_FUNC_VI_SENSOR_CLK,
  228. PMUX_FUNC_XIO,
  229. PMUX_FUNC_SAFE,
  230. /* These don't have a name, but can be used in the table */
  231. PMUX_FUNC_RSVD1,
  232. PMUX_FUNC_RSVD2,
  233. PMUX_FUNC_RSVD3,
  234. PMUX_FUNC_RSVD4,
  235. PMUX_FUNC_RSVD, /* Not valid and should not be used */
  236. PMUX_FUNC_COUNT,
  237. PMUX_FUNC_NONE = -1,
  238. };
  239. /* return 1 if a pmux_func is in range */
  240. #define pmux_func_isvalid(func) ((func) >= 0 && (func) < PMUX_FUNC_COUNT && \
  241. (func) != PMUX_FUNC_RSVD)
  242. /* The pullup/pulldown state of a pin group */
  243. enum pmux_pull {
  244. PMUX_PULL_NORMAL = 0,
  245. PMUX_PULL_DOWN,
  246. PMUX_PULL_UP,
  247. };
  248. /* Defines whether a pin group is tristated or in normal operation */
  249. enum pmux_tristate {
  250. PMUX_TRI_NORMAL = 0,
  251. PMUX_TRI_TRISTATE = 1,
  252. };
  253. /* Available power domains used by pin groups */
  254. enum pmux_vddio {
  255. PMUX_VDDIO_BB = 0,
  256. PMUX_VDDIO_LCD,
  257. PMUX_VDDIO_VI,
  258. PMUX_VDDIO_UART,
  259. PMUX_VDDIO_DDR,
  260. PMUX_VDDIO_NAND,
  261. PMUX_VDDIO_SYS,
  262. PMUX_VDDIO_AUDIO,
  263. PMUX_VDDIO_SD,
  264. PMUX_VDDIO_NONE
  265. };
  266. enum {
  267. PMUX_TRISTATE_REGS = 4,
  268. PMUX_MUX_REGS = 7,
  269. PMUX_PULL_REGS = 5,
  270. };
  271. /* APB MISC Pin Mux and Tristate (APB_MISC_PP_) registers */
  272. struct pmux_tri_ctlr {
  273. uint pmt_reserved0; /* ABP_MISC_PP_ reserved offset 00 */
  274. uint pmt_reserved1; /* ABP_MISC_PP_ reserved offset 04 */
  275. uint pmt_strap_opt_a; /* _STRAPPING_OPT_A_0, offset 08 */
  276. uint pmt_reserved2; /* ABP_MISC_PP_ reserved offset 0C */
  277. uint pmt_reserved3; /* ABP_MISC_PP_ reserved offset 10 */
  278. uint pmt_tri[PMUX_TRISTATE_REGS];/* _TRI_STATE_REG_A/B/C/D_0 14-20 */
  279. uint pmt_cfg_ctl; /* _CONFIG_CTL_0, offset 24 */
  280. uint pmt_reserved[22]; /* ABP_MISC_PP_ reserved offs 28-7C */
  281. uint pmt_ctl[PMUX_MUX_REGS]; /* _PIN_MUX_CTL_A-G_0, offset 80 */
  282. uint pmt_reserved4; /* ABP_MISC_PP_ reserved offset 9c */
  283. uint pmt_pull[PMUX_PULL_REGS]; /* APB_MISC_PP_PULLUPDOWN_REG_A-E */
  284. };
  285. /*
  286. * This defines the configuration for a pin, including the function assigned,
  287. * pull up/down settings and tristate settings. Having set up one of these
  288. * you can call pinmux_config_pingroup() to configure a pin in one step. Also
  289. * available is pinmux_config_table() to configure a list of pins.
  290. */
  291. struct pingroup_config {
  292. enum pmux_pingrp pingroup; /* pin group PINGRP_... */
  293. enum pmux_func func; /* function to assign FUNC_... */
  294. enum pmux_pull pull; /* pull up/down/normal PMUX_PULL_...*/
  295. enum pmux_tristate tristate; /* tristate or normal PMUX_TRI_... */
  296. };
  297. /* Set a pin group to tristate */
  298. void pinmux_tristate_enable(enum pmux_pingrp pin);
  299. /* Set a pin group to normal (non tristate) */
  300. void pinmux_tristate_disable(enum pmux_pingrp pin);
  301. /* Set the pull up/down feature for a pin group */
  302. void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd);
  303. /* Set the mux function for a pin group */
  304. void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func);
  305. /* Set the complete configuration for a pin group */
  306. void pinmux_config_pingroup(struct pingroup_config *config);
  307. void pinmux_set_tristate(enum pmux_pingrp pin, int enable);
  308. /**
  309. * Configuure a list of pin groups
  310. *
  311. * @param config List of config items
  312. * @param len Number of config items in list
  313. */
  314. void pinmux_config_table(struct pingroup_config *config, int len);
  315. #endif /* PINMUX_H */