pinmux.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. /*
  2. * linux/arch/arm/mach-tegra/pinmux.c
  3. *
  4. * Copyright (C) 2010 Google, Inc.
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/errno.h>
  18. #include <linux/spinlock.h>
  19. #include <linux/io.h>
  20. #include <mach/iomap.h>
  21. #include <mach/pinmux.h>
  22. #define TEGRA_TRI_STATE(x) (0x14 + (4 * (x)))
  23. #define TEGRA_PP_MUX_CTL(x) (0x80 + (4 * (x)))
  24. #define TEGRA_PP_PU_PD(x) (0xa0 + (4 * (x)))
  25. #define REG_A 0
  26. #define REG_B 1
  27. #define REG_C 2
  28. #define REG_D 3
  29. #define REG_E 4
  30. #define REG_F 5
  31. #define REG_G 6
  32. #define REG_N -1
  33. #define HSM_EN(reg) (((reg) >> 2) & 0x1)
  34. #define SCHMT_EN(reg) (((reg) >> 3) & 0x1)
  35. #define LPMD(reg) (((reg) >> 4) & 0x3)
  36. #define DRVDN(reg) (((reg) >> 12) & 0x1f)
  37. #define DRVUP(reg) (((reg) >> 20) & 0x1f)
  38. #define SLWR(reg) (((reg) >> 28) & 0x3)
  39. #define SLWF(reg) (((reg) >> 30) & 0x3)
  40. struct tegra_pingroup_desc {
  41. const char *name;
  42. int funcs[4];
  43. s8 tri_reg; /* offset into the TRISTATE_REG_* register bank */
  44. s8 tri_bit; /* offset into the TRISTATE_REG_* register bit */
  45. s8 mux_reg; /* offset into the PIN_MUX_CTL_* register bank */
  46. s8 mux_bit; /* offset into the PIN_MUX_CTL_* register bit */
  47. s8 pupd_reg; /* offset into the PULL_UPDOWN_REG_* register bank */
  48. s8 pupd_bit; /* offset into the PULL_UPDOWN_REG_* register bit */
  49. };
  50. #define PINGROUP(pg_name, f0, f1, f2, f3, \
  51. tri_r, tri_b, mux_r, mux_b, pupd_r, pupd_b) \
  52. [TEGRA_PINGROUP_ ## pg_name] = { \
  53. .name = #pg_name, \
  54. .funcs = { \
  55. TEGRA_MUX_ ## f0, \
  56. TEGRA_MUX_ ## f1, \
  57. TEGRA_MUX_ ## f2, \
  58. TEGRA_MUX_ ## f3, \
  59. }, \
  60. .tri_reg = REG_ ## tri_r, \
  61. .tri_bit = tri_b, \
  62. .mux_reg = REG_ ## mux_r, \
  63. .mux_bit = mux_b, \
  64. .pupd_reg = REG_ ## pupd_r, \
  65. .pupd_bit = pupd_b, \
  66. }
  67. static const struct tegra_pingroup_desc pingroups[TEGRA_MAX_PINGROUP] = {
  68. PINGROUP(ATA, IDE, NAND, GMI, RSVD, A, 0, A, 24, A, 0),
  69. PINGROUP(ATB, IDE, NAND, GMI, SDIO4, A, 1, A, 16, A, 2),
  70. PINGROUP(ATC, IDE, NAND, GMI, SDIO4, A, 2, A, 22, A, 4),
  71. PINGROUP(ATD, IDE, NAND, GMI, SDIO4, A, 3, A, 20, A, 6),
  72. PINGROUP(ATE, IDE, NAND, GMI, RSVD, B, 25, A, 12, A, 8),
  73. PINGROUP(CDEV1, OSC, PLLA_OUT, PLLM_OUT1, AUDIO_SYNC, A, 4, C, 2, C, 0),
  74. PINGROUP(CDEV2, OSC, AHB_CLK, APB_CLK, PLLP_OUT4, A, 5, C, 4, C, 2),
  75. PINGROUP(CRTP, CRT, RSVD, RSVD, RSVD, D, 14, G, 20, B, 24),
  76. PINGROUP(CSUS, PLLC_OUT1, PLLP_OUT2, PLLP_OUT3, VI_SENSOR_CLK, A, 6, C, 6, D, 24),
  77. PINGROUP(DAP1, DAP1, RSVD, GMI, SDIO2, A, 7, C, 20, A, 10),
  78. PINGROUP(DAP2, DAP2, TWC, RSVD, GMI, A, 8, C, 22, A, 12),
  79. PINGROUP(DAP3, DAP3, RSVD, RSVD, RSVD, A, 9, C, 24, A, 14),
  80. PINGROUP(DAP4, DAP4, RSVD, GMI, RSVD, A, 10, C, 26, A, 16),
  81. PINGROUP(DDC, I2C2, RSVD, RSVD, RSVD, B, 31, C, 0, E, 28),
  82. PINGROUP(DTA, RSVD, SDIO2, VI, RSVD, A, 11, B, 20, A, 18),
  83. PINGROUP(DTB, RSVD, RSVD, VI, SPI1, A, 12, B, 22, A, 20),
  84. PINGROUP(DTC, RSVD, RSVD, VI, RSVD, A, 13, B, 26, A, 22),
  85. PINGROUP(DTD, RSVD, SDIO2, VI, RSVD, A, 14, B, 28, A, 24),
  86. PINGROUP(DTE, RSVD, RSVD, VI, SPI1, A, 15, B, 30, A, 26),
  87. PINGROUP(DTF, I2C3, RSVD, VI, RSVD, D, 12, G, 30, A, 28),
  88. PINGROUP(GMA, UARTE, SPI3, GMI, SDIO4, A, 28, B, 0, E, 20),
  89. PINGROUP(GMB, IDE, NAND, GMI, GMI_INT, B, 29, C, 28, E, 22),
  90. PINGROUP(GMC, UARTD, SPI4, GMI, SFLASH, A, 29, B, 2, E, 24),
  91. PINGROUP(GMD, RSVD, NAND, GMI, SFLASH, B, 30, C, 30, E, 26),
  92. PINGROUP(GME, RSVD, DAP5, GMI, SDIO4, B, 0, D, 0, C, 24),
  93. PINGROUP(GPU, PWM, UARTA, GMI, RSVD, A, 16, D, 4, B, 20),
  94. PINGROUP(GPU7, RTCK, RSVD, RSVD, RSVD, D, 11, G, 28, B, 6),
  95. PINGROUP(GPV, PCIE, RSVD, RSVD, RSVD, A, 17, D, 2, A, 30),
  96. PINGROUP(HDINT, HDMI, RSVD, RSVD, RSVD, C, 23, B, 4, D, 22),
  97. PINGROUP(I2CP, I2C, RSVD, RSVD, RSVD, A, 18, C, 8, B, 2),
  98. PINGROUP(IRRX, UARTA, UARTB, GMI, SPI4, A, 20, C, 18, C, 22),
  99. PINGROUP(IRTX, UARTA, UARTB, GMI, SPI4, A, 19, C, 16, C, 20),
  100. PINGROUP(KBCA, KBC, NAND, SDIO2, EMC_TEST0_DLL, A, 22, C, 10, B, 8),
  101. PINGROUP(KBCB, KBC, NAND, SDIO2, MIO, A, 21, C, 12, B, 10),
  102. PINGROUP(KBCC, KBC, NAND, TRACE, EMC_TEST1_DLL, B, 26, C, 14, B, 12),
  103. PINGROUP(KBCD, KBC, NAND, SDIO2, MIO, D, 10, G, 26, B, 14),
  104. PINGROUP(KBCE, KBC, NAND, OWR, RSVD, A, 26, A, 28, E, 2),
  105. PINGROUP(KBCF, KBC, NAND, TRACE, MIO, A, 27, A, 26, E, 0),
  106. PINGROUP(LCSN, DISPLAYA, DISPLAYB, SPI3, RSVD, C, 31, E, 12, D, 20),
  107. PINGROUP(LD0, DISPLAYA, DISPLAYB, XIO, RSVD, C, 0, F, 0, D, 12),
  108. PINGROUP(LD1, DISPLAYA, DISPLAYB, XIO, RSVD, C, 1, F, 2, D, 12),
  109. PINGROUP(LD10, DISPLAYA, DISPLAYB, XIO, RSVD, C, 10, F, 20, D, 12),
  110. PINGROUP(LD11, DISPLAYA, DISPLAYB, XIO, RSVD, C, 11, F, 22, D, 12),
  111. PINGROUP(LD12, DISPLAYA, DISPLAYB, XIO, RSVD, C, 12, F, 24, D, 12),
  112. PINGROUP(LD13, DISPLAYA, DISPLAYB, XIO, RSVD, C, 13, F, 26, D, 12),
  113. PINGROUP(LD14, DISPLAYA, DISPLAYB, XIO, RSVD, C, 14, F, 28, D, 12),
  114. PINGROUP(LD15, DISPLAYA, DISPLAYB, XIO, RSVD, C, 15, F, 30, D, 12),
  115. PINGROUP(LD16, DISPLAYA, DISPLAYB, XIO, RSVD, C, 16, G, 0, D, 12),
  116. PINGROUP(LD17, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 17, G, 2, D, 12),
  117. PINGROUP(LD2, DISPLAYA, DISPLAYB, XIO, RSVD, C, 2, F, 4, D, 12),
  118. PINGROUP(LD3, DISPLAYA, DISPLAYB, XIO, RSVD, C, 3, F, 6, D, 12),
  119. PINGROUP(LD4, DISPLAYA, DISPLAYB, XIO, RSVD, C, 4, F, 8, D, 12),
  120. PINGROUP(LD5, DISPLAYA, DISPLAYB, XIO, RSVD, C, 5, F, 10, D, 12),
  121. PINGROUP(LD6, DISPLAYA, DISPLAYB, XIO, RSVD, C, 6, F, 12, D, 12),
  122. PINGROUP(LD7, DISPLAYA, DISPLAYB, XIO, RSVD, C, 7, F, 14, D, 12),
  123. PINGROUP(LD8, DISPLAYA, DISPLAYB, XIO, RSVD, C, 8, F, 16, D, 12),
  124. PINGROUP(LD9, DISPLAYA, DISPLAYB, XIO, RSVD, C, 9, F, 18, D, 12),
  125. PINGROUP(LDC, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 30, E, 14, D, 20),
  126. PINGROUP(LDI, DISPLAYA, DISPLAYB, RSVD, RSVD, D, 6, G, 16, D, 18),
  127. PINGROUP(LHP0, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 18, G, 10, D, 16),
  128. PINGROUP(LHP1, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 19, G, 4, D, 14),
  129. PINGROUP(LHP2, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 20, G, 6, D, 14),
  130. PINGROUP(LHS, DISPLAYA, DISPLAYB, XIO, RSVD, D, 7, E, 22, D, 22),
  131. PINGROUP(LM0, DISPLAYA, DISPLAYB, SPI3, RSVD, C, 24, E, 26, D, 22),
  132. PINGROUP(LM1, DISPLAYA, DISPLAYB, RSVD, CRT, C, 25, E, 28, D, 22),
  133. PINGROUP(LPP, DISPLAYA, DISPLAYB, RSVD, RSVD, D, 8, G, 14, D, 18),
  134. PINGROUP(LPW0, DISPLAYA, DISPLAYB, SPI3, HDMI, D, 3, E, 0, D, 20),
  135. PINGROUP(LPW1, DISPLAYA, DISPLAYB, RSVD, RSVD, D, 4, E, 2, D, 20),
  136. PINGROUP(LPW2, DISPLAYA, DISPLAYB, SPI3, HDMI, D, 5, E, 4, D, 20),
  137. PINGROUP(LSC0, DISPLAYA, DISPLAYB, XIO, RSVD, C, 27, E, 18, D, 22),
  138. PINGROUP(LSC1, DISPLAYA, DISPLAYB, SPI3, HDMI, C, 28, E, 20, D, 20),
  139. PINGROUP(LSCK, DISPLAYA, DISPLAYB, SPI3, HDMI, C, 29, E, 16, D, 20),
  140. PINGROUP(LSDA, DISPLAYA, DISPLAYB, SPI3, HDMI, D, 1, E, 8, D, 20),
  141. PINGROUP(LSDI, DISPLAYA, DISPLAYB, SPI3, RSVD, D, 2, E, 6, D, 20),
  142. PINGROUP(LSPI, DISPLAYA, DISPLAYB, XIO, HDMI, D, 0, E, 10, D, 22),
  143. PINGROUP(LVP0, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 21, E, 30, D, 22),
  144. PINGROUP(LVP1, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 22, G, 8, D, 16),
  145. PINGROUP(LVS, DISPLAYA, DISPLAYB, XIO, RSVD, C, 26, E, 24, D, 22),
  146. PINGROUP(OWC, OWR, RSVD, RSVD, RSVD, A, 31, B, 8, E, 30),
  147. PINGROUP(PMC, PWR_ON, PWR_INTR, RSVD, RSVD, A, 23, G, 18, N, -1),
  148. PINGROUP(PTA, I2C2, HDMI, GMI, RSVD, A, 24, G, 22, B, 4),
  149. PINGROUP(RM, I2C, RSVD, RSVD, RSVD, A, 25, A, 14, B, 0),
  150. PINGROUP(SDB, UARTA, PWM, SDIO3, SPI2, D, 15, D, 10, N, -1),
  151. PINGROUP(SDC, PWM, TWC, SDIO3, SPI3, B, 1, D, 12, D, 28),
  152. PINGROUP(SDD, UARTA, PWM, SDIO3, SPI3, B, 2, D, 14, D, 30),
  153. PINGROUP(SDIO1, SDIO1, RSVD, UARTE, UARTA, A, 30, A, 30, E, 18),
  154. PINGROUP(SLXA, PCIE, SPI4, SDIO3, SPI2, B, 3, B, 6, B, 22),
  155. PINGROUP(SLXC, SPDIF, SPI4, SDIO3, SPI2, B, 5, B, 10, B, 26),
  156. PINGROUP(SLXD, SPDIF, SPI4, SDIO3, SPI2, B, 6, B, 12, B, 28),
  157. PINGROUP(SLXK, PCIE, SPI4, SDIO3, SPI2, B, 7, B, 14, B, 30),
  158. PINGROUP(SPDI, SPDIF, RSVD, I2C, SDIO2, B, 8, D, 8, B, 16),
  159. PINGROUP(SPDO, SPDIF, RSVD, I2C, SDIO2, B, 9, D, 6, B, 18),
  160. PINGROUP(SPIA, SPI1, SPI2, SPI3, GMI, B, 10, D, 30, C, 4),
  161. PINGROUP(SPIB, SPI1, SPI2, SPI3, GMI, B, 11, D, 28, C, 6),
  162. PINGROUP(SPIC, SPI1, SPI2, SPI3, GMI, B, 12, D, 26, C, 8),
  163. PINGROUP(SPID, SPI2, SPI1, SPI2_ALT, GMI, B, 13, D, 24, C, 10),
  164. PINGROUP(SPIE, SPI2, SPI1, SPI2_ALT, GMI, B, 14, D, 22, C, 12),
  165. PINGROUP(SPIF, SPI3, SPI1, SPI2, RSVD, B, 15, D, 20, C, 14),
  166. PINGROUP(SPIG, SPI3, SPI2, SPI2_ALT, I2C, B, 16, D, 18, C, 16),
  167. PINGROUP(SPIH, SPI3, SPI2, SPI2_ALT, I2C, B, 17, D, 16, C, 18),
  168. PINGROUP(UAA, SPI3, MIPI_HS, UARTA, ULPI, B, 18, A, 0, D, 0),
  169. PINGROUP(UAB, SPI2, MIPI_HS, UARTA, ULPI, B, 19, A, 2, D, 2),
  170. PINGROUP(UAC, OWR, RSVD, RSVD, RSVD, B, 20, A, 4, D, 4),
  171. PINGROUP(UAD, IRDA, SPDIF, UARTA, SPI4, B, 21, A, 6, D, 6),
  172. PINGROUP(UCA, UARTC, RSVD, GMI, RSVD, B, 22, B, 16, D, 8),
  173. PINGROUP(UCB, UARTC, PWM, GMI, RSVD, B, 23, B, 18, D, 10),
  174. PINGROUP(UDA, SPI1, RSVD, UARTD, ULPI, D, 13, A, 8, E, 16),
  175. /* these pin groups only have pullup and pull down control */
  176. PINGROUP(CK32, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, E, 14),
  177. PINGROUP(DDRC, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, D, 26),
  178. PINGROUP(PMCA, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, E, 4),
  179. PINGROUP(PMCB, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, E, 6),
  180. PINGROUP(PMCC, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, E, 8),
  181. PINGROUP(PMCD, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, E, 10),
  182. PINGROUP(PMCE, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, E, 12),
  183. PINGROUP(XM2C, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, C, 30),
  184. PINGROUP(XM2D, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, C, 28),
  185. };
  186. static char *tegra_mux_names[TEGRA_MAX_MUX] = {
  187. [TEGRA_MUX_AHB_CLK] = "AHB_CLK",
  188. [TEGRA_MUX_APB_CLK] = "APB_CLK",
  189. [TEGRA_MUX_AUDIO_SYNC] = "AUDIO_SYNC",
  190. [TEGRA_MUX_CRT] = "CRT",
  191. [TEGRA_MUX_DAP1] = "DAP1",
  192. [TEGRA_MUX_DAP2] = "DAP2",
  193. [TEGRA_MUX_DAP3] = "DAP3",
  194. [TEGRA_MUX_DAP4] = "DAP4",
  195. [TEGRA_MUX_DAP5] = "DAP5",
  196. [TEGRA_MUX_DISPLAYA] = "DISPLAYA",
  197. [TEGRA_MUX_DISPLAYB] = "DISPLAYB",
  198. [TEGRA_MUX_EMC_TEST0_DLL] = "EMC_TEST0_DLL",
  199. [TEGRA_MUX_EMC_TEST1_DLL] = "EMC_TEST1_DLL",
  200. [TEGRA_MUX_GMI] = "GMI",
  201. [TEGRA_MUX_GMI_INT] = "GMI_INT",
  202. [TEGRA_MUX_HDMI] = "HDMI",
  203. [TEGRA_MUX_I2C] = "I2C",
  204. [TEGRA_MUX_I2C2] = "I2C2",
  205. [TEGRA_MUX_I2C3] = "I2C3",
  206. [TEGRA_MUX_IDE] = "IDE",
  207. [TEGRA_MUX_IRDA] = "IRDA",
  208. [TEGRA_MUX_KBC] = "KBC",
  209. [TEGRA_MUX_MIO] = "MIO",
  210. [TEGRA_MUX_MIPI_HS] = "MIPI_HS",
  211. [TEGRA_MUX_NAND] = "NAND",
  212. [TEGRA_MUX_OSC] = "OSC",
  213. [TEGRA_MUX_OWR] = "OWR",
  214. [TEGRA_MUX_PCIE] = "PCIE",
  215. [TEGRA_MUX_PLLA_OUT] = "PLLA_OUT",
  216. [TEGRA_MUX_PLLC_OUT1] = "PLLC_OUT1",
  217. [TEGRA_MUX_PLLM_OUT1] = "PLLM_OUT1",
  218. [TEGRA_MUX_PLLP_OUT2] = "PLLP_OUT2",
  219. [TEGRA_MUX_PLLP_OUT3] = "PLLP_OUT3",
  220. [TEGRA_MUX_PLLP_OUT4] = "PLLP_OUT4",
  221. [TEGRA_MUX_PWM] = "PWM",
  222. [TEGRA_MUX_PWR_INTR] = "PWR_INTR",
  223. [TEGRA_MUX_PWR_ON] = "PWR_ON",
  224. [TEGRA_MUX_RTCK] = "RTCK",
  225. [TEGRA_MUX_SDIO1] = "SDIO1",
  226. [TEGRA_MUX_SDIO2] = "SDIO2",
  227. [TEGRA_MUX_SDIO3] = "SDIO3",
  228. [TEGRA_MUX_SDIO4] = "SDIO4",
  229. [TEGRA_MUX_SFLASH] = "SFLASH",
  230. [TEGRA_MUX_SPDIF] = "SPDIF",
  231. [TEGRA_MUX_SPI1] = "SPI1",
  232. [TEGRA_MUX_SPI2] = "SPI2",
  233. [TEGRA_MUX_SPI2_ALT] = "SPI2_ALT",
  234. [TEGRA_MUX_SPI3] = "SPI3",
  235. [TEGRA_MUX_SPI4] = "SPI4",
  236. [TEGRA_MUX_TRACE] = "TRACE",
  237. [TEGRA_MUX_TWC] = "TWC",
  238. [TEGRA_MUX_UARTA] = "UARTA",
  239. [TEGRA_MUX_UARTB] = "UARTB",
  240. [TEGRA_MUX_UARTC] = "UARTC",
  241. [TEGRA_MUX_UARTD] = "UARTD",
  242. [TEGRA_MUX_UARTE] = "UARTE",
  243. [TEGRA_MUX_ULPI] = "ULPI",
  244. [TEGRA_MUX_VI] = "VI",
  245. [TEGRA_MUX_VI_SENSOR_CLK] = "VI_SENSOR_CLK",
  246. [TEGRA_MUX_XIO] = "XIO",
  247. };
  248. struct tegra_drive_pingroup_desc {
  249. const char *name;
  250. s16 reg;
  251. };
  252. #define DRIVE_PINGROUP(pg_name, r) \
  253. [TEGRA_DRIVE_PINGROUP_ ## pg_name] = { \
  254. .name = #pg_name, \
  255. .reg = r \
  256. }
  257. static const struct tegra_drive_pingroup_desc drive_pingroups[TEGRA_MAX_PINGROUP] = {
  258. DRIVE_PINGROUP(AO1, 0x868),
  259. DRIVE_PINGROUP(AO2, 0x86c),
  260. DRIVE_PINGROUP(AT1, 0x870),
  261. DRIVE_PINGROUP(AT2, 0x874),
  262. DRIVE_PINGROUP(CDEV1, 0x878),
  263. DRIVE_PINGROUP(CDEV2, 0x87c),
  264. DRIVE_PINGROUP(CSUS, 0x880),
  265. DRIVE_PINGROUP(DAP1, 0x884),
  266. DRIVE_PINGROUP(DAP2, 0x888),
  267. DRIVE_PINGROUP(DAP3, 0x88c),
  268. DRIVE_PINGROUP(DAP4, 0x890),
  269. DRIVE_PINGROUP(DBG, 0x894),
  270. DRIVE_PINGROUP(LCD1, 0x898),
  271. DRIVE_PINGROUP(LCD2, 0x89c),
  272. DRIVE_PINGROUP(SDMMC2, 0x8a0),
  273. DRIVE_PINGROUP(SDMMC3, 0x8a4),
  274. DRIVE_PINGROUP(SPI, 0x8a8),
  275. DRIVE_PINGROUP(UAA, 0x8ac),
  276. DRIVE_PINGROUP(UAB, 0x8b0),
  277. DRIVE_PINGROUP(UART2, 0x8b4),
  278. DRIVE_PINGROUP(UART3, 0x8b8),
  279. DRIVE_PINGROUP(VI1, 0x8bc),
  280. DRIVE_PINGROUP(VI2, 0x8c0),
  281. DRIVE_PINGROUP(XM2A, 0x8c4),
  282. DRIVE_PINGROUP(XM2C, 0x8c8),
  283. DRIVE_PINGROUP(XM2D, 0x8cc),
  284. DRIVE_PINGROUP(XM2CLK, 0x8d0),
  285. DRIVE_PINGROUP(MEMCOMP, 0x8d4),
  286. };
  287. static const char *tegra_drive_names[TEGRA_MAX_DRIVE] = {
  288. [TEGRA_DRIVE_DIV_8] = "DIV_8",
  289. [TEGRA_DRIVE_DIV_4] = "DIV_4",
  290. [TEGRA_DRIVE_DIV_2] = "DIV_2",
  291. [TEGRA_DRIVE_DIV_1] = "DIV_1",
  292. };
  293. static const char *tegra_slew_names[TEGRA_MAX_SLEW] = {
  294. [TEGRA_SLEW_FASTEST] = "FASTEST",
  295. [TEGRA_SLEW_FAST] = "FAST",
  296. [TEGRA_SLEW_SLOW] = "SLOW",
  297. [TEGRA_SLEW_SLOWEST] = "SLOWEST",
  298. };
  299. static DEFINE_SPINLOCK(mux_lock);
  300. static const char *pingroup_name(enum tegra_pingroup pg)
  301. {
  302. if (pg < 0 || pg >= TEGRA_MAX_PINGROUP)
  303. return "<UNKNOWN>";
  304. return pingroups[pg].name;
  305. }
  306. static const char *func_name(enum tegra_mux_func func)
  307. {
  308. if (func == TEGRA_MUX_RSVD1)
  309. return "RSVD1";
  310. if (func == TEGRA_MUX_RSVD2)
  311. return "RSVD2";
  312. if (func == TEGRA_MUX_RSVD3)
  313. return "RSVD3";
  314. if (func == TEGRA_MUX_RSVD4)
  315. return "RSVD4";
  316. if (func == TEGRA_MUX_NONE)
  317. return "NONE";
  318. if (func < 0 || func >= TEGRA_MAX_MUX)
  319. return "<UNKNOWN>";
  320. return tegra_mux_names[func];
  321. }
  322. static const char *tri_name(unsigned long val)
  323. {
  324. return val ? "TRISTATE" : "NORMAL";
  325. }
  326. static const char *pupd_name(unsigned long val)
  327. {
  328. switch (val) {
  329. case 0:
  330. return "NORMAL";
  331. case 1:
  332. return "PULL_DOWN";
  333. case 2:
  334. return "PULL_UP";
  335. default:
  336. return "RSVD";
  337. }
  338. }
  339. static inline unsigned long pg_readl(unsigned long offset)
  340. {
  341. return readl(IO_TO_VIRT(TEGRA_APB_MISC_BASE + offset));
  342. }
  343. static inline void pg_writel(unsigned long value, unsigned long offset)
  344. {
  345. writel(value, IO_TO_VIRT(TEGRA_APB_MISC_BASE + offset));
  346. }
  347. int tegra_pinmux_set_func(enum tegra_pingroup pg, enum tegra_mux_func func)
  348. {
  349. int mux = -1;
  350. int i;
  351. unsigned long reg;
  352. unsigned long flags;
  353. if (pg < 0 || pg >= TEGRA_MAX_PINGROUP)
  354. return -ERANGE;
  355. if (pingroups[pg].mux_reg == REG_N)
  356. return -EINVAL;
  357. if (func < 0)
  358. return -ERANGE;
  359. if (func & TEGRA_MUX_RSVD) {
  360. mux = func & 0x3;
  361. } else {
  362. for (i = 0; i < 4; i++) {
  363. if (pingroups[pg].funcs[i] == func) {
  364. mux = i;
  365. break;
  366. }
  367. }
  368. }
  369. if (mux < 0)
  370. return -EINVAL;
  371. spin_lock_irqsave(&mux_lock, flags);
  372. reg = pg_readl(TEGRA_PP_MUX_CTL(pingroups[pg].mux_reg));
  373. reg &= ~(0x3 << pingroups[pg].mux_bit);
  374. reg |= mux << pingroups[pg].mux_bit;
  375. pg_writel(reg, TEGRA_PP_MUX_CTL(pingroups[pg].mux_reg));
  376. spin_unlock_irqrestore(&mux_lock, flags);
  377. return 0;
  378. }
  379. int tegra_pinmux_set_tristate(enum tegra_pingroup pg,
  380. enum tegra_tristate tristate)
  381. {
  382. unsigned long reg;
  383. unsigned long flags;
  384. if (pg < 0 || pg >= TEGRA_MAX_PINGROUP)
  385. return -ERANGE;
  386. if (pingroups[pg].tri_reg == REG_N)
  387. return -EINVAL;
  388. spin_lock_irqsave(&mux_lock, flags);
  389. reg = pg_readl(TEGRA_TRI_STATE(pingroups[pg].tri_reg));
  390. reg &= ~(0x1 << pingroups[pg].tri_bit);
  391. if (tristate)
  392. reg |= 1 << pingroups[pg].tri_bit;
  393. pg_writel(reg, TEGRA_TRI_STATE(pingroups[pg].tri_reg));
  394. spin_unlock_irqrestore(&mux_lock, flags);
  395. return 0;
  396. }
  397. int tegra_pinmux_set_pullupdown(enum tegra_pingroup pg,
  398. enum tegra_pullupdown pupd)
  399. {
  400. unsigned long reg;
  401. unsigned long flags;
  402. if (pg < 0 || pg >= TEGRA_MAX_PINGROUP)
  403. return -ERANGE;
  404. if (pingroups[pg].pupd_reg == REG_N)
  405. return -EINVAL;
  406. if (pupd != TEGRA_PUPD_NORMAL &&
  407. pupd != TEGRA_PUPD_PULL_DOWN &&
  408. pupd != TEGRA_PUPD_PULL_UP)
  409. return -EINVAL;
  410. spin_lock_irqsave(&mux_lock, flags);
  411. reg = pg_readl(TEGRA_PP_PU_PD(pingroups[pg].pupd_reg));
  412. reg &= ~(0x3 << pingroups[pg].pupd_bit);
  413. reg |= pupd << pingroups[pg].pupd_bit;
  414. pg_writel(reg, TEGRA_PP_PU_PD(pingroups[pg].pupd_reg));
  415. spin_unlock_irqrestore(&mux_lock, flags);
  416. return 0;
  417. }
  418. void tegra_pinmux_config_pingroup(enum tegra_pingroup pingroup,
  419. enum tegra_mux_func func,
  420. enum tegra_pullupdown pupd,
  421. enum tegra_tristate tristate)
  422. {
  423. int err;
  424. if (pingroups[pingroup].mux_reg != REG_N) {
  425. err = tegra_pinmux_set_func(pingroup, func);
  426. if (err < 0)
  427. pr_err("pinmux: can't set pingroup %s func to %s: %d\n",
  428. pingroup_name(pingroup), func_name(func), err);
  429. }
  430. if (pingroups[pingroup].pupd_reg != REG_N) {
  431. err = tegra_pinmux_set_pullupdown(pingroup, pupd);
  432. if (err < 0)
  433. pr_err("pinmux: can't set pingroup %s pullupdown to %s: %d\n",
  434. pingroup_name(pingroup), pupd_name(pupd), err);
  435. }
  436. if (pingroups[pingroup].tri_reg != REG_N) {
  437. err = tegra_pinmux_set_tristate(pingroup, tristate);
  438. if (err < 0)
  439. pr_err("pinmux: can't set pingroup %s tristate to %s: %d\n",
  440. pingroup_name(pingroup), tri_name(func), err);
  441. }
  442. }
  443. void tegra_pinmux_config_table(struct tegra_pingroup_config *config, int len)
  444. {
  445. int i;
  446. for (i = 0; i < len; i++)
  447. tegra_pinmux_config_pingroup(config[i].pingroup,
  448. config[i].func,
  449. config[i].pupd,
  450. config[i].tristate);
  451. }
  452. static const char *drive_pinmux_name(enum tegra_drive_pingroup pg)
  453. {
  454. if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP)
  455. return "<UNKNOWN>";
  456. return drive_pingroups[pg].name;
  457. }
  458. static const char *enable_name(unsigned long val)
  459. {
  460. return val ? "ENABLE" : "DISABLE";
  461. }
  462. static const char *drive_name(unsigned long val)
  463. {
  464. if (val >= TEGRA_MAX_DRIVE)
  465. return "<UNKNOWN>";
  466. return tegra_drive_names[val];
  467. }
  468. static const char *slew_name(unsigned long val)
  469. {
  470. if (val >= TEGRA_MAX_SLEW)
  471. return "<UNKNOWN>";
  472. return tegra_slew_names[val];
  473. }
  474. static int tegra_drive_pinmux_set_hsm(enum tegra_drive_pingroup pg,
  475. enum tegra_hsm hsm)
  476. {
  477. unsigned long flags;
  478. u32 reg;
  479. if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP)
  480. return -ERANGE;
  481. if (hsm != TEGRA_HSM_ENABLE && hsm != TEGRA_HSM_DISABLE)
  482. return -EINVAL;
  483. spin_lock_irqsave(&mux_lock, flags);
  484. reg = pg_readl(drive_pingroups[pg].reg);
  485. if (hsm == TEGRA_HSM_ENABLE)
  486. reg |= (1 << 2);
  487. else
  488. reg &= ~(1 << 2);
  489. pg_writel(reg, drive_pingroups[pg].reg);
  490. spin_unlock_irqrestore(&mux_lock, flags);
  491. return 0;
  492. }
  493. static int tegra_drive_pinmux_set_schmitt(enum tegra_drive_pingroup pg,
  494. enum tegra_schmitt schmitt)
  495. {
  496. unsigned long flags;
  497. u32 reg;
  498. if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP)
  499. return -ERANGE;
  500. if (schmitt != TEGRA_SCHMITT_ENABLE && schmitt != TEGRA_SCHMITT_DISABLE)
  501. return -EINVAL;
  502. spin_lock_irqsave(&mux_lock, flags);
  503. reg = pg_readl(drive_pingroups[pg].reg);
  504. if (schmitt == TEGRA_SCHMITT_ENABLE)
  505. reg |= (1 << 3);
  506. else
  507. reg &= ~(1 << 3);
  508. pg_writel(reg, drive_pingroups[pg].reg);
  509. spin_unlock_irqrestore(&mux_lock, flags);
  510. return 0;
  511. }
  512. static int tegra_drive_pinmux_set_drive(enum tegra_drive_pingroup pg,
  513. enum tegra_drive drive)
  514. {
  515. unsigned long flags;
  516. u32 reg;
  517. if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP)
  518. return -ERANGE;
  519. if (drive < 0 || drive >= TEGRA_MAX_DRIVE)
  520. return -EINVAL;
  521. spin_lock_irqsave(&mux_lock, flags);
  522. reg = pg_readl(drive_pingroups[pg].reg);
  523. reg &= ~(0x3 << 4);
  524. reg |= drive << 4;
  525. pg_writel(reg, drive_pingroups[pg].reg);
  526. spin_unlock_irqrestore(&mux_lock, flags);
  527. return 0;
  528. }
  529. static int tegra_drive_pinmux_set_pull_down(enum tegra_drive_pingroup pg,
  530. enum tegra_pull_strength pull_down)
  531. {
  532. unsigned long flags;
  533. u32 reg;
  534. if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP)
  535. return -ERANGE;
  536. if (pull_down < 0 || pull_down >= TEGRA_MAX_PULL)
  537. return -EINVAL;
  538. spin_lock_irqsave(&mux_lock, flags);
  539. reg = pg_readl(drive_pingroups[pg].reg);
  540. reg &= ~(0x1f << 12);
  541. reg |= pull_down << 12;
  542. pg_writel(reg, drive_pingroups[pg].reg);
  543. spin_unlock_irqrestore(&mux_lock, flags);
  544. return 0;
  545. }
  546. static int tegra_drive_pinmux_set_pull_up(enum tegra_drive_pingroup pg,
  547. enum tegra_pull_strength pull_up)
  548. {
  549. unsigned long flags;
  550. u32 reg;
  551. if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP)
  552. return -ERANGE;
  553. if (pull_up < 0 || pull_up >= TEGRA_MAX_PULL)
  554. return -EINVAL;
  555. spin_lock_irqsave(&mux_lock, flags);
  556. reg = pg_readl(drive_pingroups[pg].reg);
  557. reg &= ~(0x1f << 12);
  558. reg |= pull_up << 12;
  559. pg_writel(reg, drive_pingroups[pg].reg);
  560. spin_unlock_irqrestore(&mux_lock, flags);
  561. return 0;
  562. }
  563. static int tegra_drive_pinmux_set_slew_rising(enum tegra_drive_pingroup pg,
  564. enum tegra_slew slew_rising)
  565. {
  566. unsigned long flags;
  567. u32 reg;
  568. if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP)
  569. return -ERANGE;
  570. if (slew_rising < 0 || slew_rising >= TEGRA_MAX_SLEW)
  571. return -EINVAL;
  572. spin_lock_irqsave(&mux_lock, flags);
  573. reg = pg_readl(drive_pingroups[pg].reg);
  574. reg &= ~(0x3 << 28);
  575. reg |= slew_rising << 28;
  576. pg_writel(reg, drive_pingroups[pg].reg);
  577. spin_unlock_irqrestore(&mux_lock, flags);
  578. return 0;
  579. }
  580. static int tegra_drive_pinmux_set_slew_falling(enum tegra_drive_pingroup pg,
  581. enum tegra_slew slew_falling)
  582. {
  583. unsigned long flags;
  584. u32 reg;
  585. if (pg < 0 || pg >= TEGRA_MAX_DRIVE_PINGROUP)
  586. return -ERANGE;
  587. if (slew_falling < 0 || slew_falling >= TEGRA_MAX_SLEW)
  588. return -EINVAL;
  589. spin_lock_irqsave(&mux_lock, flags);
  590. reg = pg_readl(drive_pingroups[pg].reg);
  591. reg &= ~(0x3 << 30);
  592. reg |= slew_falling << 30;
  593. pg_writel(reg, drive_pingroups[pg].reg);
  594. spin_unlock_irqrestore(&mux_lock, flags);
  595. return 0;
  596. }
  597. static void tegra_drive_pinmux_config_pingroup(enum tegra_drive_pingroup pingroup,
  598. enum tegra_hsm hsm,
  599. enum tegra_schmitt schmitt,
  600. enum tegra_drive drive,
  601. enum tegra_pull_strength pull_down,
  602. enum tegra_pull_strength pull_up,
  603. enum tegra_slew slew_rising,
  604. enum tegra_slew slew_falling)
  605. {
  606. int err;
  607. err = tegra_drive_pinmux_set_hsm(pingroup, hsm);
  608. if (err < 0)
  609. pr_err("pinmux: can't set pingroup %s hsm to %s: %d\n",
  610. drive_pinmux_name(pingroup),
  611. enable_name(hsm), err);
  612. err = tegra_drive_pinmux_set_schmitt(pingroup, schmitt);
  613. if (err < 0)
  614. pr_err("pinmux: can't set pingroup %s schmitt to %s: %d\n",
  615. drive_pinmux_name(pingroup),
  616. enable_name(schmitt), err);
  617. err = tegra_drive_pinmux_set_drive(pingroup, drive);
  618. if (err < 0)
  619. pr_err("pinmux: can't set pingroup %s drive to %s: %d\n",
  620. drive_pinmux_name(pingroup),
  621. drive_name(drive), err);
  622. err = tegra_drive_pinmux_set_pull_down(pingroup, pull_down);
  623. if (err < 0)
  624. pr_err("pinmux: can't set pingroup %s pull down to %d: %d\n",
  625. drive_pinmux_name(pingroup),
  626. pull_down, err);
  627. err = tegra_drive_pinmux_set_pull_up(pingroup, pull_up);
  628. if (err < 0)
  629. pr_err("pinmux: can't set pingroup %s pull up to %d: %d\n",
  630. drive_pinmux_name(pingroup),
  631. pull_up, err);
  632. err = tegra_drive_pinmux_set_slew_rising(pingroup, slew_rising);
  633. if (err < 0)
  634. pr_err("pinmux: can't set pingroup %s rising slew to %s: %d\n",
  635. drive_pinmux_name(pingroup),
  636. slew_name(slew_rising), err);
  637. err = tegra_drive_pinmux_set_slew_falling(pingroup, slew_falling);
  638. if (err < 0)
  639. pr_err("pinmux: can't set pingroup %s falling slew to %s: %d\n",
  640. drive_pinmux_name(pingroup),
  641. slew_name(slew_falling), err);
  642. }
  643. void tegra_drive_pinmux_config_table(struct tegra_drive_pingroup_config *config,
  644. int len)
  645. {
  646. int i;
  647. for (i = 0; i < len; i++)
  648. tegra_drive_pinmux_config_pingroup(config[i].pingroup,
  649. config[i].hsm,
  650. config[i].schmitt,
  651. config[i].drive,
  652. config[i].pull_down,
  653. config[i].pull_up,
  654. config[i].slew_rising,
  655. config[i].slew_falling);
  656. }
  657. #ifdef CONFIG_DEBUG_FS
  658. #include <linux/debugfs.h>
  659. #include <linux/seq_file.h>
  660. static void dbg_pad_field(struct seq_file *s, int len)
  661. {
  662. seq_putc(s, ',');
  663. while (len-- > -1)
  664. seq_putc(s, ' ');
  665. }
  666. static int dbg_pinmux_show(struct seq_file *s, void *unused)
  667. {
  668. int i;
  669. int len;
  670. for (i = 0; i < TEGRA_MAX_PINGROUP; i++) {
  671. unsigned long tri;
  672. unsigned long mux;
  673. unsigned long pupd;
  674. seq_printf(s, "\t{TEGRA_PINGROUP_%s", pingroups[i].name);
  675. len = strlen(pingroups[i].name);
  676. dbg_pad_field(s, 5 - len);
  677. if (pingroups[i].mux_reg == REG_N) {
  678. seq_printf(s, "TEGRA_MUX_NONE");
  679. len = strlen("NONE");
  680. } else {
  681. mux = (pg_readl(TEGRA_PP_MUX_CTL(pingroups[i].mux_reg)) >>
  682. pingroups[i].mux_bit) & 0x3;
  683. if (pingroups[i].funcs[mux] == TEGRA_MUX_RSVD) {
  684. seq_printf(s, "TEGRA_MUX_RSVD%1lu", mux+1);
  685. len = 5;
  686. } else {
  687. seq_printf(s, "TEGRA_MUX_%s",
  688. tegra_mux_names[pingroups[i].funcs[mux]]);
  689. len = strlen(tegra_mux_names[pingroups[i].funcs[mux]]);
  690. }
  691. }
  692. dbg_pad_field(s, 13-len);
  693. if (pingroups[i].mux_reg == REG_N) {
  694. seq_printf(s, "TEGRA_PUPD_NORMAL");
  695. len = strlen("NORMAL");
  696. } else {
  697. pupd = (pg_readl(TEGRA_PP_PU_PD(pingroups[i].pupd_reg)) >>
  698. pingroups[i].pupd_bit) & 0x3;
  699. seq_printf(s, "TEGRA_PUPD_%s", pupd_name(pupd));
  700. len = strlen(pupd_name(pupd));
  701. }
  702. dbg_pad_field(s, 9 - len);
  703. if (pingroups[i].tri_reg == REG_N) {
  704. seq_printf(s, "TEGRA_TRI_NORMAL");
  705. } else {
  706. tri = (pg_readl(TEGRA_TRI_STATE(pingroups[i].tri_reg)) >>
  707. pingroups[i].tri_bit) & 0x1;
  708. seq_printf(s, "TEGRA_TRI_%s", tri_name(tri));
  709. }
  710. seq_printf(s, "},\n");
  711. }
  712. return 0;
  713. }
  714. static int dbg_pinmux_open(struct inode *inode, struct file *file)
  715. {
  716. return single_open(file, dbg_pinmux_show, &inode->i_private);
  717. }
  718. static const struct file_operations debug_fops = {
  719. .open = dbg_pinmux_open,
  720. .read = seq_read,
  721. .llseek = seq_lseek,
  722. .release = single_release,
  723. };
  724. static int dbg_drive_pinmux_show(struct seq_file *s, void *unused)
  725. {
  726. int i;
  727. int len;
  728. for (i = 0; i < TEGRA_MAX_DRIVE_PINGROUP; i++) {
  729. u32 reg;
  730. seq_printf(s, "\t{TEGRA_DRIVE_PINGROUP_%s",
  731. drive_pingroups[i].name);
  732. len = strlen(drive_pingroups[i].name);
  733. dbg_pad_field(s, 7 - len);
  734. reg = pg_readl(drive_pingroups[i].reg);
  735. if (HSM_EN(reg)) {
  736. seq_printf(s, "TEGRA_HSM_ENABLE");
  737. len = 16;
  738. } else {
  739. seq_printf(s, "TEGRA_HSM_DISABLE");
  740. len = 17;
  741. }
  742. dbg_pad_field(s, 17 - len);
  743. if (SCHMT_EN(reg)) {
  744. seq_printf(s, "TEGRA_SCHMITT_ENABLE");
  745. len = 21;
  746. } else {
  747. seq_printf(s, "TEGRA_SCHMITT_DISABLE");
  748. len = 22;
  749. }
  750. dbg_pad_field(s, 22 - len);
  751. seq_printf(s, "TEGRA_DRIVE_%s", drive_name(LPMD(reg)));
  752. len = strlen(drive_name(LPMD(reg)));
  753. dbg_pad_field(s, 5 - len);
  754. seq_printf(s, "TEGRA_PULL_%d", DRVDN(reg));
  755. len = DRVDN(reg) < 10 ? 1 : 2;
  756. dbg_pad_field(s, 2 - len);
  757. seq_printf(s, "TEGRA_PULL_%d", DRVUP(reg));
  758. len = DRVUP(reg) < 10 ? 1 : 2;
  759. dbg_pad_field(s, 2 - len);
  760. seq_printf(s, "TEGRA_SLEW_%s", slew_name(SLWR(reg)));
  761. len = strlen(slew_name(SLWR(reg)));
  762. dbg_pad_field(s, 7 - len);
  763. seq_printf(s, "TEGRA_SLEW_%s", slew_name(SLWF(reg)));
  764. seq_printf(s, "},\n");
  765. }
  766. return 0;
  767. }
  768. static int dbg_drive_pinmux_open(struct inode *inode, struct file *file)
  769. {
  770. return single_open(file, dbg_drive_pinmux_show, &inode->i_private);
  771. }
  772. static const struct file_operations debug_drive_fops = {
  773. .open = dbg_drive_pinmux_open,
  774. .read = seq_read,
  775. .llseek = seq_lseek,
  776. .release = single_release,
  777. };
  778. static int __init tegra_pinmux_debuginit(void)
  779. {
  780. (void) debugfs_create_file("tegra_pinmux", S_IRUGO,
  781. NULL, NULL, &debug_fops);
  782. (void) debugfs_create_file("tegra_pinmux_drive", S_IRUGO,
  783. NULL, NULL, &debug_drive_fops);
  784. return 0;
  785. }
  786. late_initcall(tegra_pinmux_debuginit);
  787. #endif