1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 3 * linux/arch/arm/mach-omap1/mux.c 4 * 5 * OMAP1 pin multiplexing configurations 6 * 7 * Copyright (C) 2003 - 2008 Nokia Corporation 8 * 9 * Written by Tony Lindgren 10 */ 11 #include <linux/module.h> 12 #include <linux/init.h> 13 #include <linux/io.h> 14 #include <linux/spinlock.h> 15 #include <linux/soc/ti/omap1-io.h> 16 17 #include "hardware.h" 18 #include "mux.h" 19 20 #ifdef CONFIG_OMAP_MUX 21 22 static struct omap_mux_cfg arch_mux_cfg; 23 24 #if defined(CONFIG_ARCH_OMAP15XX) || defined(C 25 static struct pin_config omap1xxx_pins[] = { 26 /* 27 * description mux mode mu 28 * reg offset mo 29 */ 30 MUX_CFG("UART1_TX", 9, 21, 1 31 MUX_CFG("UART1_RTS", 9, 12, 1 32 33 /* UART2 (COM_UART_GATING), conflicts with USB 34 MUX_CFG("UART2_TX", C, 27, 1 35 MUX_CFG("UART2_RX", C, 18, 0 36 MUX_CFG("UART2_CTS", C, 21, 0 37 MUX_CFG("UART2_RTS", C, 24, 1 38 39 /* UART3 (GIGA_UART_GATING) */ 40 MUX_CFG("UART3_TX", 6, 0, 1 41 MUX_CFG("UART3_RX", 6, 3, 0 42 MUX_CFG("UART3_CTS", 5, 12, 2 43 MUX_CFG("UART3_RTS", 5, 15, 2 44 MUX_CFG("UART3_CLKREQ", 9, 27, 0 45 MUX_CFG("UART3_BCLK", A, 0, 0 46 MUX_CFG("Y15_1610_UART3_RTS", A, 0, 1 47 48 /* PWT & PWL, conflicts with UART3 */ 49 MUX_CFG("PWT", 6, 0, 2 50 MUX_CFG("PWL", 6, 3, 1 51 52 /* USB internal master generic */ 53 MUX_CFG("R18_USB_VBUS", 7, 9, 2 54 MUX_CFG("R18_1510_USB_GPIO0", 7, 9, 0 55 /* works around erratum: W4_USB_PUEN and W4_U 56 MUX_CFG("W4_USB_PUEN", D, 3, 3 57 MUX_CFG("W4_USB_CLKO", D, 3, 1 58 MUX_CFG("W4_USB_HIGHZ", D, 3, 4 59 MUX_CFG("W4_GPIO58", D, 3, 7 60 61 /* USB1 master */ 62 MUX_CFG("USB1_SUSP", 8, 27, 2 63 MUX_CFG("USB1_SE0", 9, 0, 2 64 MUX_CFG("W13_1610_USB1_SE0", 9, 0, 4 65 MUX_CFG("USB1_TXEN", 9, 3, 2 66 MUX_CFG("USB1_TXD", 9, 24, 1 67 MUX_CFG("USB1_VP", A, 3, 1 68 MUX_CFG("USB1_VM", A, 6, 1 69 MUX_CFG("USB1_RCV", A, 9, 1 70 MUX_CFG("USB1_SPEED", A, 12, 2 71 MUX_CFG("R13_1610_USB1_SPEED", A, 12, 5 72 MUX_CFG("R13_1710_USB1_SEO", A, 12, 5 73 74 /* USB2 master */ 75 MUX_CFG("USB2_SUSP", B, 3, 1 76 MUX_CFG("USB2_VP", B, 6, 1 77 MUX_CFG("USB2_TXEN", B, 9, 1 78 MUX_CFG("USB2_VM", C, 18, 1 79 MUX_CFG("USB2_RCV", C, 21, 1 80 MUX_CFG("USB2_SE0", C, 24, 2 81 MUX_CFG("USB2_TXD", C, 27, 2 82 83 /* OMAP-1510 GPIO */ 84 MUX_CFG("R18_1510_GPIO0", 7, 9, 0 85 MUX_CFG("R19_1510_GPIO1", 7, 6, 0 86 MUX_CFG("M14_1510_GPIO2", 7, 3, 0 87 88 /* OMAP1610 GPIO */ 89 MUX_CFG("P18_1610_GPIO3", 7, 0, 0 90 MUX_CFG("Y15_1610_GPIO17", A, 0, 7 91 92 /* OMAP-1710 GPIO */ 93 MUX_CFG("R18_1710_GPIO0", 7, 9, 0 94 MUX_CFG("V2_1710_GPIO10", F, 27, 1 95 MUX_CFG("N21_1710_GPIO14", 6, 9, 0 96 MUX_CFG("W15_1710_GPIO40", 9, 27, 7 97 98 /* MPUIO */ 99 MUX_CFG("MPUIO2", 7, 18, 0 100 MUX_CFG("N15_1610_MPUIO2", 7, 18, 0 101 MUX_CFG("MPUIO4", 7, 15, 0 102 MUX_CFG("MPUIO5", 7, 12, 0 103 104 MUX_CFG("T20_1610_MPUIO5", 7, 12, 0 105 MUX_CFG("W11_1610_MPUIO6", 10, 15, 2 106 MUX_CFG("V10_1610_MPUIO7", A, 24, 2 107 MUX_CFG("W11_1610_MPUIO9", 10, 15, 1 108 MUX_CFG("V10_1610_MPUIO10", A, 24, 1 109 MUX_CFG("W10_1610_MPUIO11", A, 18, 2 110 MUX_CFG("E20_1610_MPUIO13", 3, 21, 1 111 MUX_CFG("U20_1610_MPUIO14", 9, 6, 6 112 MUX_CFG("E19_1610_MPUIO15", 3, 18, 1 113 114 /* MCBSP2 */ 115 MUX_CFG("MCBSP2_CLKR", C, 6, 0 116 MUX_CFG("MCBSP2_CLKX", C, 9, 0 117 MUX_CFG("MCBSP2_DR", C, 0, 0 118 MUX_CFG("MCBSP2_DX", C, 15, 0 119 MUX_CFG("MCBSP2_FSR", C, 12, 0 120 MUX_CFG("MCBSP2_FSX", C, 3, 0 121 122 /* MCBSP3 NOTE: Mode must 1 for clock */ 123 MUX_CFG("MCBSP3_CLKX", 9, 3, 1 124 125 /* Misc ballouts */ 126 MUX_CFG("BALLOUT_V8_ARMIO3", B, 18, 0 127 MUX_CFG("N20_HDQ", 6, 18, 1 128 129 /* OMAP-1610 MMC2 */ 130 MUX_CFG("W8_1610_MMC2_DAT0", B, 21, 6 131 MUX_CFG("V8_1610_MMC2_DAT1", B, 27, 6 132 MUX_CFG("W15_1610_MMC2_DAT2", 9, 12, 6 133 MUX_CFG("R10_1610_MMC2_DAT3", B, 18, 6 134 MUX_CFG("Y10_1610_MMC2_CLK", B, 3, 6 135 MUX_CFG("Y8_1610_MMC2_CMD", B, 24, 6 136 MUX_CFG("V9_1610_MMC2_CMDDIR", B, 12, 6 137 MUX_CFG("V5_1610_MMC2_DATDIR0", B, 15, 6 138 MUX_CFG("W19_1610_MMC2_DATDIR1", 8, 15, 6 139 MUX_CFG("R18_1610_MMC2_CLKIN", 7, 9, 6 140 141 /* OMAP-1610 External Trace Interface */ 142 MUX_CFG("M19_1610_ETM_PSTAT0", 5, 27, 1 143 MUX_CFG("L15_1610_ETM_PSTAT1", 5, 24, 1 144 MUX_CFG("L18_1610_ETM_PSTAT2", 5, 21, 1 145 MUX_CFG("L19_1610_ETM_D0", 5, 18, 1 146 MUX_CFG("J19_1610_ETM_D6", 5, 0, 1 147 MUX_CFG("J18_1610_ETM_D7", 5, 27, 1 148 149 /* OMAP16XX GPIO */ 150 MUX_CFG("P20_1610_GPIO4", 6, 27, 0 151 MUX_CFG("V9_1610_GPIO7", B, 12, 1 152 MUX_CFG("W8_1610_GPIO9", B, 21, 0 153 MUX_CFG("N20_1610_GPIO11", 6, 18, 0 154 MUX_CFG("N19_1610_GPIO13", 6, 12, 0 155 MUX_CFG("P10_1610_GPIO22", C, 0, 7 156 MUX_CFG("V5_1610_GPIO24", B, 15, 7 157 MUX_CFG("AA20_1610_GPIO_41", 9, 9, 7 158 MUX_CFG("W19_1610_GPIO48", 8, 15, 7 159 MUX_CFG("M7_1610_GPIO62", 10, 0, 0 160 MUX_CFG("V14_16XX_GPIO37", 9, 18, 7 161 MUX_CFG("R9_16XX_GPIO18", C, 18, 7 162 MUX_CFG("L14_16XX_GPIO49", 6, 3, 7 163 164 /* OMAP-1610 uWire */ 165 MUX_CFG("V19_1610_UWIRE_SCLK", 8, 6, 0 166 MUX_CFG("U18_1610_UWIRE_SDI", 8, 0, 0 167 MUX_CFG("W21_1610_UWIRE_SDO", 8, 3, 0 168 MUX_CFG("N14_1610_UWIRE_CS0", 8, 9, 1 169 MUX_CFG("P15_1610_UWIRE_CS3", 8, 12, 1 170 MUX_CFG("N15_1610_UWIRE_CS1", 7, 18, 2 171 172 /* OMAP-1610 SPI */ 173 MUX_CFG("U19_1610_SPIF_SCK", 7, 21, 6 174 MUX_CFG("U18_1610_SPIF_DIN", 8, 0, 6 175 MUX_CFG("P20_1610_SPIF_DIN", 6, 27, 4 176 MUX_CFG("W21_1610_SPIF_DOUT", 8, 3, 6 177 MUX_CFG("R18_1610_SPIF_DOUT", 7, 9, 3 178 MUX_CFG("N14_1610_SPIF_CS0", 8, 9, 6 179 MUX_CFG("N15_1610_SPIF_CS1", 7, 18, 6 180 MUX_CFG("T19_1610_SPIF_CS2", 7, 15, 4 181 MUX_CFG("P15_1610_SPIF_CS3", 8, 12, 3 182 183 /* OMAP-1610 Flash */ 184 MUX_CFG("L3_1610_FLASH_CS2B_OE",10, 6, 1 185 MUX_CFG("M8_1610_FLASH_CS2B_WE",10, 3, 1 186 187 /* First MMC interface, same on 1510, 1610 and 188 MUX_CFG("MMC_CMD", A, 27, 0 189 MUX_CFG("MMC_DAT1", A, 24, 0 190 MUX_CFG("MMC_DAT2", A, 18, 0 191 MUX_CFG("MMC_DAT0", B, 0, 0 192 MUX_CFG("MMC_CLK", A, 21, 0 193 MUX_CFG("MMC_DAT3", 10, 15, 0 194 MUX_CFG("M15_1710_MMC_CLKI", 6, 21, 2 195 MUX_CFG("P19_1710_MMC_CMDDIR", 6, 24, 6 196 MUX_CFG("P20_1710_MMC_DATDIR0", 6, 27, 5 197 198 /* OMAP-1610 USB0 alternate configuration */ 199 MUX_CFG("W9_USB0_TXEN", B, 9, 5 200 MUX_CFG("AA9_USB0_VP", B, 6, 5 201 MUX_CFG("Y5_USB0_RCV", C, 21, 5 202 MUX_CFG("R9_USB0_VM", C, 18, 5 203 MUX_CFG("V6_USB0_TXD", C, 27, 5 204 MUX_CFG("W5_USB0_SE0", C, 24, 5 205 MUX_CFG("V9_USB0_SPEED", B, 12, 5 206 MUX_CFG("Y10_USB0_SUSP", B, 3, 5 207 208 /* USB2 interface */ 209 MUX_CFG("W9_USB2_TXEN", B, 9, 1 210 MUX_CFG("AA9_USB2_VP", B, 6, 1 211 MUX_CFG("Y5_USB2_RCV", C, 21, 1 212 MUX_CFG("R9_USB2_VM", C, 18, 1 213 MUX_CFG("V6_USB2_TXD", C, 27, 2 214 MUX_CFG("W5_USB2_SE0", C, 24, 2 215 216 /* 16XX UART */ 217 MUX_CFG("R13_1610_UART1_TX", A, 12, 6 218 MUX_CFG("V14_16XX_UART1_RX", 9, 18, 0 219 MUX_CFG("R14_1610_UART1_CTS", 9, 15, 0 220 MUX_CFG("AA15_1610_UART1_RTS", 9, 12, 1 221 MUX_CFG("R9_16XX_UART2_RX", C, 18, 0 222 MUX_CFG("L14_16XX_UART3_RX", 6, 3, 0 223 224 /* I2C interface */ 225 MUX_CFG("I2C_SCL", 7, 24, 0 226 MUX_CFG("I2C_SDA", 7, 27, 0 227 228 /* Keypad */ 229 MUX_CFG("F18_1610_KBC0", 3, 15, 0 230 MUX_CFG("D20_1610_KBC1", 3, 12, 0 231 MUX_CFG("D19_1610_KBC2", 3, 9, 0 232 MUX_CFG("E18_1610_KBC3", 3, 6, 0 233 MUX_CFG("C21_1610_KBC4", 3, 3, 0 234 MUX_CFG("G18_1610_KBR0", 4, 0, 0 235 MUX_CFG("F19_1610_KBR1", 3, 27, 0 236 MUX_CFG("H14_1610_KBR2", 3, 24, 0 237 MUX_CFG("E20_1610_KBR3", 3, 21, 0 238 MUX_CFG("E19_1610_KBR4", 3, 18, 0 239 MUX_CFG("N19_1610_KBR5", 6, 12, 1 240 241 /* Power management */ 242 MUX_CFG("T20_1610_LOW_PWR", 7, 12, 1 243 244 /* MCLK Settings */ 245 MUX_CFG("V5_1710_MCLK_ON", B, 15, 0 246 MUX_CFG("V5_1710_MCLK_OFF", B, 15, 6 247 MUX_CFG("R10_1610_MCLK_ON", B, 18, 0 248 MUX_CFG("R10_1610_MCLK_OFF", B, 18, 6 249 250 /* CompactFlash controller, conflicts with MMC 251 MUX_CFG("P11_1610_CF_CD2", A, 27, 3 252 MUX_CFG("R11_1610_CF_IOIS16", B, 0, 3 253 MUX_CFG("V10_1610_CF_IREQ", A, 24, 3 254 MUX_CFG("W10_1610_CF_RESET", A, 18, 3 255 MUX_CFG("W11_1610_CF_CD1", 10, 15, 3 256 257 /* parallel camera */ 258 MUX_CFG("J15_1610_CAM_LCLK", 4, 24, 0 259 MUX_CFG("J18_1610_CAM_D7", 4, 27, 0 260 MUX_CFG("J19_1610_CAM_D6", 5, 0, 0 261 MUX_CFG("J14_1610_CAM_D5", 5, 3, 0 262 MUX_CFG("K18_1610_CAM_D4", 5, 6, 0 263 MUX_CFG("K19_1610_CAM_D3", 5, 9, 0 264 MUX_CFG("K15_1610_CAM_D2", 5, 12, 0 265 MUX_CFG("K14_1610_CAM_D1", 5, 15, 0 266 MUX_CFG("L19_1610_CAM_D0", 5, 18, 0 267 MUX_CFG("L18_1610_CAM_VS", 5, 21, 0 268 MUX_CFG("L15_1610_CAM_HS", 5, 24, 0 269 MUX_CFG("M19_1610_CAM_RSTZ", 5, 27, 0 270 MUX_CFG("Y15_1610_CAM_OUTCLK", A, 0, 6 271 272 /* serial camera */ 273 MUX_CFG("H19_1610_CAM_EXCLK", 4, 21, 0 274 /* REVISIT 5912 spec sez CCP_* can't p 275 MUX_CFG("Y12_1610_CCP_CLKP", 8, 18, 6 276 MUX_CFG("W13_1610_CCP_CLKM", 9, 0, 6 277 MUX_CFG("W14_1610_CCP_DATAP", 9, 24, 6 278 MUX_CFG("Y14_1610_CCP_DATAM", 9, 21, 6 279 }; 280 #define OMAP1XXX_PINS_SZ ARRAY_SIZE(oma 281 #else 282 #define omap1xxx_pins NULL 283 #define OMAP1XXX_PINS_SZ 0 284 #endif /* CONFIG_ARCH_OMAP15XX || CONFIG_ARCH 285 286 static int omap1_cfg_reg(const struct pin_conf 287 { 288 static DEFINE_SPINLOCK(mux_spin_lock); 289 unsigned long flags; 290 unsigned int reg_orig = 0, reg = 0, pu 291 pull_orig = 0, pull = 0; 292 unsigned int mask, warn = 0; 293 294 /* Check the mux register in question 295 if (cfg->mux_reg) { 296 unsigned tmp1, tmp2; 297 298 spin_lock_irqsave(&mux_spin_lo 299 reg_orig = omap_readl(cfg->mux 300 301 /* The mux registers always se 302 mask = (0x7 << cfg->mask_offse 303 tmp1 = reg_orig & mask; 304 reg = reg_orig & ~mask; 305 306 tmp2 = (cfg->mask << cfg->mask 307 reg |= tmp2; 308 309 if (tmp1 != tmp2) 310 warn = 1; 311 312 omap_writel(reg, cfg->mux_reg) 313 spin_unlock_irqrestore(&mux_sp 314 } 315 316 /* Check for pull up or pull down sele 317 if (!cpu_is_omap15xx()) { 318 if (cfg->pu_pd_reg && cfg->pul 319 spin_lock_irqsave(&mux 320 pu_pd_orig = omap_read 321 mask = 1 << cfg->pull_ 322 323 if (cfg->pu_pd_val) { 324 if (!(pu_pd_or 325 warn = 326 /* Use pull up 327 pu_pd = pu_pd_ 328 } else { 329 if (pu_pd_orig 330 warn = 331 /* Use pull do 332 pu_pd = pu_pd_ 333 } 334 omap_writel(pu_pd, cfg 335 spin_unlock_irqrestore 336 } 337 } 338 339 /* Check for an associated pull down r 340 if (cfg->pull_reg) { 341 spin_lock_irqsave(&mux_spin_lo 342 pull_orig = omap_readl(cfg->pu 343 mask = 1 << cfg->pull_bit; 344 345 if (cfg->pull_val) { 346 if (pull_orig & mask) 347 warn = 1; 348 /* Low bit = pull enab 349 pull = pull_orig & ~ma 350 } else { 351 if (!(pull_orig & mask 352 warn = 1; 353 /* High bit = pull dis 354 pull = pull_orig | mas 355 } 356 357 omap_writel(pull, cfg->pull_re 358 spin_unlock_irqrestore(&mux_sp 359 } 360 361 if (warn) { 362 #ifdef CONFIG_OMAP_MUX_WARNINGS 363 printk(KERN_WARNING "MUX: init 364 #endif 365 } 366 367 #ifdef CONFIG_OMAP_MUX_DEBUG 368 if (cfg->debug || warn) { 369 printk("MUX: Setting register 370 printk(" %s (0x%08x) = 0x 371 cfg->mux_reg_name, cfg- 372 373 if (!cpu_is_omap15xx()) { 374 if (cfg->pu_pd_reg && 375 printk(" 376 cfg->pu 377 pu_pd_o 378 } 379 } 380 381 if (cfg->pull_reg) 382 printk(" %s (0x%0 383 cfg->pull_name, 384 } 385 #endif 386 387 #ifdef CONFIG_OMAP_MUX_WARNINGS 388 return warn ? -ETXTBSY : 0; 389 #else 390 return 0; 391 #endif 392 } 393 394 static struct omap_mux_cfg *mux_cfg; 395 396 int __init omap_mux_register(struct omap_mux_c 397 { 398 if (!arch_mux_cfg || !arch_mux_cfg->pi 399 || !arch_mux_cfg->cfg_ 400 printk(KERN_ERR "Invalid pin t 401 return -EINVAL; 402 } 403 404 mux_cfg = arch_mux_cfg; 405 406 return 0; 407 } 408 409 /* 410 * Sets the Omap MUX and PULL_DWN registers ba 411 */ 412 int omap_cfg_reg(const unsigned long index) 413 { 414 struct pin_config *reg; 415 416 if (!cpu_class_is_omap1()) { 417 printk(KERN_ERR "mux: Broken o 418 index); 419 WARN_ON(1); 420 return -EINVAL; 421 } 422 423 if (mux_cfg == NULL) { 424 printk(KERN_ERR "Pin mux table 425 return -ENODEV; 426 } 427 428 if (index >= mux_cfg->size) { 429 printk(KERN_ERR "Invalid pin m 430 index, mux_cfg->size); 431 dump_stack(); 432 return -ENODEV; 433 } 434 435 reg = &mux_cfg->pins[index]; 436 437 if (!mux_cfg->cfg_reg) 438 return -ENODEV; 439 440 return mux_cfg->cfg_reg(reg); 441 } 442 EXPORT_SYMBOL(omap_cfg_reg); 443 444 int __init omap1_mux_init(void) 445 { 446 if (cpu_is_omap15xx() || cpu_is_omap16 447 arch_mux_cfg.pins = omap 448 arch_mux_cfg.size = OMAP 449 arch_mux_cfg.cfg_reg = omap 450 } 451 452 return omap_mux_register(&arch_mux_cfg 453 } 454 455 #else 456 #define omap_mux_init() do {} while(0) 457 #define omap_cfg_reg(x) do {} while(0) 458 #endif /* CONFIG_OMAP_MUX */ 459 460
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.