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