Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 Samsung Electronics. |
| 3 | * Abhilash Kesavan <a.kesavan@samsung.com> |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Rajeshwari Shinde | 28bae82 | 2012-12-26 20:03:11 +0000 | [diff] [blame] | 9 | #include <fdtdec.h> |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 10 | #include <asm/arch/gpio.h> |
| 11 | #include <asm/arch/pinmux.h> |
| 12 | #include <asm/arch/sromc.h> |
| 13 | |
| 14 | static void exynos5_uart_config(int peripheral) |
| 15 | { |
| 16 | struct exynos5_gpio_part1 *gpio1 = |
| 17 | (struct exynos5_gpio_part1 *) samsung_get_base_gpio_part1(); |
| 18 | struct s5p_gpio_bank *bank; |
| 19 | int i, start, count; |
| 20 | |
| 21 | switch (peripheral) { |
| 22 | case PERIPH_ID_UART0: |
| 23 | bank = &gpio1->a0; |
| 24 | start = 0; |
| 25 | count = 4; |
| 26 | break; |
| 27 | case PERIPH_ID_UART1: |
Rajeshwari Shinde | ab337bc | 2012-07-03 20:02:59 +0000 | [diff] [blame] | 28 | bank = &gpio1->d0; |
| 29 | start = 0; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 30 | count = 4; |
| 31 | break; |
| 32 | case PERIPH_ID_UART2: |
| 33 | bank = &gpio1->a1; |
| 34 | start = 0; |
| 35 | count = 4; |
| 36 | break; |
| 37 | case PERIPH_ID_UART3: |
| 38 | bank = &gpio1->a1; |
| 39 | start = 4; |
| 40 | count = 2; |
| 41 | break; |
| 42 | } |
| 43 | for (i = start; i < start + count; i++) { |
| 44 | s5p_gpio_set_pull(bank, i, GPIO_PULL_NONE); |
| 45 | s5p_gpio_cfg_pin(bank, i, GPIO_FUNC(0x2)); |
| 46 | } |
| 47 | } |
| 48 | |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 49 | static void exynos5420_uart_config(int peripheral) |
| 50 | { |
| 51 | struct exynos5420_gpio_part1 *gpio1 = |
| 52 | (struct exynos5420_gpio_part1 *)samsung_get_base_gpio_part1(); |
| 53 | struct s5p_gpio_bank *bank; |
| 54 | int i, start, count; |
| 55 | |
| 56 | switch (peripheral) { |
| 57 | case PERIPH_ID_UART0: |
| 58 | bank = &gpio1->a0; |
| 59 | start = 0; |
| 60 | count = 4; |
| 61 | break; |
| 62 | case PERIPH_ID_UART1: |
| 63 | bank = &gpio1->a0; |
| 64 | start = 4; |
| 65 | count = 4; |
| 66 | break; |
| 67 | case PERIPH_ID_UART2: |
| 68 | bank = &gpio1->a1; |
| 69 | start = 0; |
| 70 | count = 4; |
| 71 | break; |
| 72 | case PERIPH_ID_UART3: |
| 73 | bank = &gpio1->a1; |
| 74 | start = 4; |
| 75 | count = 2; |
| 76 | break; |
| 77 | } |
| 78 | |
| 79 | for (i = start; i < start + count; i++) { |
| 80 | s5p_gpio_set_pull(bank, i, GPIO_PULL_NONE); |
| 81 | s5p_gpio_cfg_pin(bank, i, GPIO_FUNC(0x2)); |
| 82 | } |
| 83 | } |
| 84 | |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 85 | static int exynos5_mmc_config(int peripheral, int flags) |
| 86 | { |
| 87 | struct exynos5_gpio_part1 *gpio1 = |
| 88 | (struct exynos5_gpio_part1 *) samsung_get_base_gpio_part1(); |
| 89 | struct s5p_gpio_bank *bank, *bank_ext; |
Jaehoon Chung | 0fc779c | 2012-07-09 21:20:34 +0000 | [diff] [blame] | 90 | int i, start = 0, gpio_func = 0; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 91 | |
| 92 | switch (peripheral) { |
| 93 | case PERIPH_ID_SDMMC0: |
| 94 | bank = &gpio1->c0; |
| 95 | bank_ext = &gpio1->c1; |
Rajeshwari Shinde | ab337bc | 2012-07-03 20:02:59 +0000 | [diff] [blame] | 96 | start = 0; |
| 97 | gpio_func = GPIO_FUNC(0x2); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 98 | break; |
| 99 | case PERIPH_ID_SDMMC1: |
Rajeshwari Shinde | ab337bc | 2012-07-03 20:02:59 +0000 | [diff] [blame] | 100 | bank = &gpio1->c2; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 101 | bank_ext = NULL; |
| 102 | break; |
| 103 | case PERIPH_ID_SDMMC2: |
Rajeshwari Shinde | ab337bc | 2012-07-03 20:02:59 +0000 | [diff] [blame] | 104 | bank = &gpio1->c3; |
| 105 | bank_ext = &gpio1->c4; |
| 106 | start = 3; |
| 107 | gpio_func = GPIO_FUNC(0x3); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 108 | break; |
| 109 | case PERIPH_ID_SDMMC3: |
Rajeshwari Shinde | ab337bc | 2012-07-03 20:02:59 +0000 | [diff] [blame] | 110 | bank = &gpio1->c4; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 111 | bank_ext = NULL; |
| 112 | break; |
| 113 | } |
| 114 | if ((flags & PINMUX_FLAG_8BIT_MODE) && !bank_ext) { |
| 115 | debug("SDMMC device %d does not support 8bit mode", |
| 116 | peripheral); |
| 117 | return -1; |
| 118 | } |
| 119 | if (flags & PINMUX_FLAG_8BIT_MODE) { |
Rajeshwari Shinde | ab337bc | 2012-07-03 20:02:59 +0000 | [diff] [blame] | 120 | for (i = start; i <= (start + 3); i++) { |
| 121 | s5p_gpio_cfg_pin(bank_ext, i, gpio_func); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 122 | s5p_gpio_set_pull(bank_ext, i, GPIO_PULL_UP); |
| 123 | s5p_gpio_set_drv(bank_ext, i, GPIO_DRV_4X); |
| 124 | } |
| 125 | } |
| 126 | for (i = 0; i < 2; i++) { |
| 127 | s5p_gpio_cfg_pin(bank, i, GPIO_FUNC(0x2)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 128 | s5p_gpio_set_pull(bank, i, GPIO_PULL_NONE); |
| 129 | s5p_gpio_set_drv(bank, i, GPIO_DRV_4X); |
| 130 | } |
| 131 | for (i = 3; i <= 6; i++) { |
| 132 | s5p_gpio_cfg_pin(bank, i, GPIO_FUNC(0x2)); |
| 133 | s5p_gpio_set_pull(bank, i, GPIO_PULL_UP); |
| 134 | s5p_gpio_set_drv(bank, i, GPIO_DRV_4X); |
| 135 | } |
| 136 | |
| 137 | return 0; |
| 138 | } |
| 139 | |
| 140 | static int exynos5420_mmc_config(int peripheral, int flags) |
| 141 | { |
| 142 | struct exynos5420_gpio_part3 *gpio3 = |
| 143 | (struct exynos5420_gpio_part3 *)samsung_get_base_gpio_part3(); |
| 144 | struct s5p_gpio_bank *bank = NULL, *bank_ext = NULL; |
| 145 | int i, start; |
| 146 | |
| 147 | switch (peripheral) { |
| 148 | case PERIPH_ID_SDMMC0: |
| 149 | bank = &gpio3->c0; |
| 150 | bank_ext = &gpio3->c3; |
| 151 | start = 0; |
| 152 | break; |
| 153 | case PERIPH_ID_SDMMC1: |
| 154 | bank = &gpio3->c1; |
| 155 | bank_ext = &gpio3->d1; |
| 156 | start = 4; |
| 157 | break; |
| 158 | case PERIPH_ID_SDMMC2: |
| 159 | bank = &gpio3->c2; |
| 160 | bank_ext = NULL; |
| 161 | start = 0; |
| 162 | break; |
| 163 | default: |
| 164 | start = 0; |
| 165 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 166 | return -1; |
| 167 | } |
| 168 | |
| 169 | if ((flags & PINMUX_FLAG_8BIT_MODE) && !bank_ext) { |
| 170 | debug("SDMMC device %d does not support 8bit mode", |
| 171 | peripheral); |
| 172 | return -1; |
| 173 | } |
| 174 | |
| 175 | if (flags & PINMUX_FLAG_8BIT_MODE) { |
| 176 | for (i = start; i <= (start + 3); i++) { |
| 177 | s5p_gpio_cfg_pin(bank_ext, i, GPIO_FUNC(0x2)); |
| 178 | s5p_gpio_set_pull(bank_ext, i, GPIO_PULL_UP); |
| 179 | s5p_gpio_set_drv(bank_ext, i, GPIO_DRV_4X); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | for (i = 0; i < 3; i++) { |
| 184 | /* |
| 185 | * MMC0 is intended to be used for eMMC. The |
| 186 | * card detect pin is used as a VDDEN signal to |
| 187 | * power on the eMMC. The 5420 iROM makes |
| 188 | * this same assumption. |
| 189 | */ |
| 190 | if ((peripheral == PERIPH_ID_SDMMC0) && (i == 2)) { |
| 191 | s5p_gpio_set_value(bank, i, 1); |
| 192 | s5p_gpio_cfg_pin(bank, i, GPIO_OUTPUT); |
| 193 | } else { |
| 194 | s5p_gpio_cfg_pin(bank, i, GPIO_FUNC(0x2)); |
| 195 | } |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 196 | s5p_gpio_set_pull(bank, i, GPIO_PULL_NONE); |
| 197 | s5p_gpio_set_drv(bank, i, GPIO_DRV_4X); |
| 198 | } |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 199 | |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 200 | for (i = 3; i <= 6; i++) { |
| 201 | s5p_gpio_cfg_pin(bank, i, GPIO_FUNC(0x2)); |
| 202 | s5p_gpio_set_pull(bank, i, GPIO_PULL_UP); |
| 203 | s5p_gpio_set_drv(bank, i, GPIO_DRV_4X); |
| 204 | } |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 205 | |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | static void exynos5_sromc_config(int flags) |
| 210 | { |
| 211 | struct exynos5_gpio_part1 *gpio1 = |
| 212 | (struct exynos5_gpio_part1 *) samsung_get_base_gpio_part1(); |
| 213 | int i; |
| 214 | |
| 215 | /* |
| 216 | * SROM:CS1 and EBI |
| 217 | * |
| 218 | * GPY0[0] SROM_CSn[0] |
| 219 | * GPY0[1] SROM_CSn[1](2) |
| 220 | * GPY0[2] SROM_CSn[2] |
| 221 | * GPY0[3] SROM_CSn[3] |
| 222 | * GPY0[4] EBI_OEn(2) |
| 223 | * GPY0[5] EBI_EEn(2) |
| 224 | * |
| 225 | * GPY1[0] EBI_BEn[0](2) |
| 226 | * GPY1[1] EBI_BEn[1](2) |
| 227 | * GPY1[2] SROM_WAIT(2) |
| 228 | * GPY1[3] EBI_DATA_RDn(2) |
| 229 | */ |
| 230 | s5p_gpio_cfg_pin(&gpio1->y0, (flags & PINMUX_FLAG_BANK), |
| 231 | GPIO_FUNC(2)); |
| 232 | s5p_gpio_cfg_pin(&gpio1->y0, 4, GPIO_FUNC(2)); |
| 233 | s5p_gpio_cfg_pin(&gpio1->y0, 5, GPIO_FUNC(2)); |
| 234 | |
| 235 | for (i = 0; i < 4; i++) |
| 236 | s5p_gpio_cfg_pin(&gpio1->y1, i, GPIO_FUNC(2)); |
| 237 | |
| 238 | /* |
| 239 | * EBI: 8 Addrss Lines |
| 240 | * |
| 241 | * GPY3[0] EBI_ADDR[0](2) |
| 242 | * GPY3[1] EBI_ADDR[1](2) |
| 243 | * GPY3[2] EBI_ADDR[2](2) |
| 244 | * GPY3[3] EBI_ADDR[3](2) |
| 245 | * GPY3[4] EBI_ADDR[4](2) |
| 246 | * GPY3[5] EBI_ADDR[5](2) |
| 247 | * GPY3[6] EBI_ADDR[6](2) |
| 248 | * GPY3[7] EBI_ADDR[7](2) |
| 249 | * |
| 250 | * EBI: 16 Data Lines |
| 251 | * |
| 252 | * GPY5[0] EBI_DATA[0](2) |
| 253 | * GPY5[1] EBI_DATA[1](2) |
| 254 | * GPY5[2] EBI_DATA[2](2) |
| 255 | * GPY5[3] EBI_DATA[3](2) |
| 256 | * GPY5[4] EBI_DATA[4](2) |
| 257 | * GPY5[5] EBI_DATA[5](2) |
| 258 | * GPY5[6] EBI_DATA[6](2) |
| 259 | * GPY5[7] EBI_DATA[7](2) |
| 260 | * |
| 261 | * GPY6[0] EBI_DATA[8](2) |
| 262 | * GPY6[1] EBI_DATA[9](2) |
| 263 | * GPY6[2] EBI_DATA[10](2) |
| 264 | * GPY6[3] EBI_DATA[11](2) |
| 265 | * GPY6[4] EBI_DATA[12](2) |
| 266 | * GPY6[5] EBI_DATA[13](2) |
| 267 | * GPY6[6] EBI_DATA[14](2) |
| 268 | * GPY6[7] EBI_DATA[15](2) |
| 269 | */ |
| 270 | for (i = 0; i < 8; i++) { |
| 271 | s5p_gpio_cfg_pin(&gpio1->y3, i, GPIO_FUNC(2)); |
| 272 | s5p_gpio_set_pull(&gpio1->y3, i, GPIO_PULL_UP); |
| 273 | |
| 274 | s5p_gpio_cfg_pin(&gpio1->y5, i, GPIO_FUNC(2)); |
| 275 | s5p_gpio_set_pull(&gpio1->y5, i, GPIO_PULL_UP); |
| 276 | |
| 277 | s5p_gpio_cfg_pin(&gpio1->y6, i, GPIO_FUNC(2)); |
| 278 | s5p_gpio_set_pull(&gpio1->y6, i, GPIO_PULL_UP); |
| 279 | } |
| 280 | } |
| 281 | |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 282 | static void exynos5_i2c_config(int peripheral, int flags) |
| 283 | { |
| 284 | |
| 285 | struct exynos5_gpio_part1 *gpio1 = |
| 286 | (struct exynos5_gpio_part1 *) samsung_get_base_gpio_part1(); |
| 287 | |
| 288 | switch (peripheral) { |
| 289 | case PERIPH_ID_I2C0: |
| 290 | s5p_gpio_cfg_pin(&gpio1->b3, 0, GPIO_FUNC(0x2)); |
| 291 | s5p_gpio_cfg_pin(&gpio1->b3, 1, GPIO_FUNC(0x2)); |
| 292 | break; |
| 293 | case PERIPH_ID_I2C1: |
| 294 | s5p_gpio_cfg_pin(&gpio1->b3, 2, GPIO_FUNC(0x2)); |
| 295 | s5p_gpio_cfg_pin(&gpio1->b3, 3, GPIO_FUNC(0x2)); |
| 296 | break; |
| 297 | case PERIPH_ID_I2C2: |
| 298 | s5p_gpio_cfg_pin(&gpio1->a0, 6, GPIO_FUNC(0x3)); |
| 299 | s5p_gpio_cfg_pin(&gpio1->a0, 7, GPIO_FUNC(0x3)); |
| 300 | break; |
| 301 | case PERIPH_ID_I2C3: |
| 302 | s5p_gpio_cfg_pin(&gpio1->a1, 2, GPIO_FUNC(0x3)); |
| 303 | s5p_gpio_cfg_pin(&gpio1->a1, 3, GPIO_FUNC(0x3)); |
| 304 | break; |
| 305 | case PERIPH_ID_I2C4: |
| 306 | s5p_gpio_cfg_pin(&gpio1->a2, 0, GPIO_FUNC(0x3)); |
| 307 | s5p_gpio_cfg_pin(&gpio1->a2, 1, GPIO_FUNC(0x3)); |
| 308 | break; |
| 309 | case PERIPH_ID_I2C5: |
| 310 | s5p_gpio_cfg_pin(&gpio1->a2, 2, GPIO_FUNC(0x3)); |
| 311 | s5p_gpio_cfg_pin(&gpio1->a2, 3, GPIO_FUNC(0x3)); |
| 312 | break; |
| 313 | case PERIPH_ID_I2C6: |
| 314 | s5p_gpio_cfg_pin(&gpio1->b1, 3, GPIO_FUNC(0x4)); |
| 315 | s5p_gpio_cfg_pin(&gpio1->b1, 4, GPIO_FUNC(0x4)); |
| 316 | break; |
| 317 | case PERIPH_ID_I2C7: |
| 318 | s5p_gpio_cfg_pin(&gpio1->b2, 2, GPIO_FUNC(0x3)); |
| 319 | s5p_gpio_cfg_pin(&gpio1->b2, 3, GPIO_FUNC(0x3)); |
| 320 | break; |
| 321 | } |
| 322 | } |
| 323 | |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 324 | static void exynos5420_i2c_config(int peripheral) |
| 325 | { |
| 326 | struct exynos5420_gpio_part1 *gpio1 = |
| 327 | (struct exynos5420_gpio_part1 *)samsung_get_base_gpio_part1(); |
| 328 | |
| 329 | switch (peripheral) { |
| 330 | case PERIPH_ID_I2C0: |
| 331 | s5p_gpio_cfg_pin(&gpio1->b3, 0, GPIO_FUNC(0x2)); |
| 332 | s5p_gpio_cfg_pin(&gpio1->b3, 1, GPIO_FUNC(0x2)); |
| 333 | break; |
| 334 | case PERIPH_ID_I2C1: |
| 335 | s5p_gpio_cfg_pin(&gpio1->b3, 2, GPIO_FUNC(0x2)); |
| 336 | s5p_gpio_cfg_pin(&gpio1->b3, 3, GPIO_FUNC(0x2)); |
| 337 | break; |
| 338 | case PERIPH_ID_I2C2: |
| 339 | s5p_gpio_cfg_pin(&gpio1->a0, 6, GPIO_FUNC(0x3)); |
| 340 | s5p_gpio_cfg_pin(&gpio1->a0, 7, GPIO_FUNC(0x3)); |
| 341 | break; |
| 342 | case PERIPH_ID_I2C3: |
| 343 | s5p_gpio_cfg_pin(&gpio1->a1, 2, GPIO_FUNC(0x3)); |
| 344 | s5p_gpio_cfg_pin(&gpio1->a1, 3, GPIO_FUNC(0x3)); |
| 345 | break; |
| 346 | case PERIPH_ID_I2C4: |
| 347 | s5p_gpio_cfg_pin(&gpio1->a2, 0, GPIO_FUNC(0x3)); |
| 348 | s5p_gpio_cfg_pin(&gpio1->a2, 1, GPIO_FUNC(0x3)); |
| 349 | break; |
| 350 | case PERIPH_ID_I2C5: |
| 351 | s5p_gpio_cfg_pin(&gpio1->a2, 2, GPIO_FUNC(0x3)); |
| 352 | s5p_gpio_cfg_pin(&gpio1->a2, 3, GPIO_FUNC(0x3)); |
| 353 | break; |
| 354 | case PERIPH_ID_I2C6: |
| 355 | s5p_gpio_cfg_pin(&gpio1->b1, 3, GPIO_FUNC(0x4)); |
| 356 | s5p_gpio_cfg_pin(&gpio1->b1, 4, GPIO_FUNC(0x4)); |
| 357 | break; |
| 358 | case PERIPH_ID_I2C7: |
| 359 | s5p_gpio_cfg_pin(&gpio1->b2, 2, GPIO_FUNC(0x3)); |
| 360 | s5p_gpio_cfg_pin(&gpio1->b2, 3, GPIO_FUNC(0x3)); |
| 361 | break; |
| 362 | case PERIPH_ID_I2C8: |
| 363 | s5p_gpio_cfg_pin(&gpio1->b3, 4, GPIO_FUNC(0x2)); |
| 364 | s5p_gpio_cfg_pin(&gpio1->b3, 5, GPIO_FUNC(0x2)); |
| 365 | break; |
| 366 | case PERIPH_ID_I2C9: |
| 367 | s5p_gpio_cfg_pin(&gpio1->b3, 6, GPIO_FUNC(0x2)); |
| 368 | s5p_gpio_cfg_pin(&gpio1->b3, 7, GPIO_FUNC(0x2)); |
| 369 | break; |
| 370 | case PERIPH_ID_I2C10: |
| 371 | s5p_gpio_cfg_pin(&gpio1->b4, 0, GPIO_FUNC(0x2)); |
| 372 | s5p_gpio_cfg_pin(&gpio1->b4, 1, GPIO_FUNC(0x2)); |
| 373 | break; |
| 374 | } |
| 375 | } |
| 376 | |
Rajeshwari Shinde | 7cf89a2 | 2012-10-25 19:49:27 +0000 | [diff] [blame] | 377 | static void exynos5_i2s_config(int peripheral) |
| 378 | { |
| 379 | int i; |
| 380 | struct exynos5_gpio_part1 *gpio1 = |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 381 | (struct exynos5_gpio_part1 *)samsung_get_base_gpio_part1(); |
| 382 | struct exynos5_gpio_part4 *gpio4 = |
| 383 | (struct exynos5_gpio_part4 *)samsung_get_base_gpio_part4(); |
Rajeshwari Shinde | 7cf89a2 | 2012-10-25 19:49:27 +0000 | [diff] [blame] | 384 | |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 385 | switch (peripheral) { |
| 386 | case PERIPH_ID_I2S0: |
| 387 | for (i = 0; i < 5; i++) |
| 388 | s5p_gpio_cfg_pin(&gpio4->z, i, GPIO_FUNC(0x02)); |
| 389 | break; |
| 390 | case PERIPH_ID_I2S1: |
| 391 | for (i = 0; i < 5; i++) |
| 392 | s5p_gpio_cfg_pin(&gpio1->b0, i, GPIO_FUNC(0x02)); |
| 393 | break; |
| 394 | } |
Rajeshwari Shinde | 7cf89a2 | 2012-10-25 19:49:27 +0000 | [diff] [blame] | 395 | } |
| 396 | |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 397 | void exynos5_spi_config(int peripheral) |
| 398 | { |
| 399 | int cfg = 0, pin = 0, i; |
| 400 | struct s5p_gpio_bank *bank = NULL; |
| 401 | struct exynos5_gpio_part1 *gpio1 = |
| 402 | (struct exynos5_gpio_part1 *) samsung_get_base_gpio_part1(); |
| 403 | struct exynos5_gpio_part2 *gpio2 = |
| 404 | (struct exynos5_gpio_part2 *) samsung_get_base_gpio_part2(); |
| 405 | |
| 406 | switch (peripheral) { |
| 407 | case PERIPH_ID_SPI0: |
| 408 | bank = &gpio1->a2; |
| 409 | cfg = GPIO_FUNC(0x2); |
| 410 | pin = 0; |
| 411 | break; |
| 412 | case PERIPH_ID_SPI1: |
| 413 | bank = &gpio1->a2; |
| 414 | cfg = GPIO_FUNC(0x2); |
| 415 | pin = 4; |
| 416 | break; |
| 417 | case PERIPH_ID_SPI2: |
| 418 | bank = &gpio1->b1; |
| 419 | cfg = GPIO_FUNC(0x5); |
| 420 | pin = 1; |
| 421 | break; |
| 422 | case PERIPH_ID_SPI3: |
| 423 | bank = &gpio2->f1; |
| 424 | cfg = GPIO_FUNC(0x2); |
| 425 | pin = 0; |
| 426 | break; |
| 427 | case PERIPH_ID_SPI4: |
| 428 | for (i = 0; i < 2; i++) { |
| 429 | s5p_gpio_cfg_pin(&gpio2->f0, i + 2, GPIO_FUNC(0x4)); |
| 430 | s5p_gpio_cfg_pin(&gpio2->e0, i + 4, GPIO_FUNC(0x4)); |
| 431 | } |
| 432 | break; |
| 433 | } |
| 434 | if (peripheral != PERIPH_ID_SPI4) { |
| 435 | for (i = pin; i < pin + 4; i++) |
| 436 | s5p_gpio_cfg_pin(bank, i, cfg); |
| 437 | } |
| 438 | } |
| 439 | |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 440 | void exynos5420_spi_config(int peripheral) |
| 441 | { |
| 442 | int cfg, pin, i; |
| 443 | struct s5p_gpio_bank *bank = NULL; |
| 444 | struct exynos5420_gpio_part1 *gpio1 = |
| 445 | (struct exynos5420_gpio_part1 *)samsung_get_base_gpio_part1(); |
| 446 | struct exynos5420_gpio_part4 *gpio4 = |
| 447 | (struct exynos5420_gpio_part4 *)samsung_get_base_gpio_part4(); |
| 448 | |
| 449 | switch (peripheral) { |
| 450 | case PERIPH_ID_SPI0: |
| 451 | bank = &gpio1->a2; |
| 452 | cfg = GPIO_FUNC(0x2); |
| 453 | pin = 0; |
| 454 | break; |
| 455 | case PERIPH_ID_SPI1: |
| 456 | bank = &gpio1->a2; |
| 457 | cfg = GPIO_FUNC(0x2); |
| 458 | pin = 4; |
| 459 | break; |
| 460 | case PERIPH_ID_SPI2: |
| 461 | bank = &gpio1->b1; |
| 462 | cfg = GPIO_FUNC(0x5); |
| 463 | pin = 1; |
| 464 | break; |
| 465 | case PERIPH_ID_SPI3: |
| 466 | bank = &gpio4->f1; |
| 467 | cfg = GPIO_FUNC(0x2); |
| 468 | pin = 0; |
| 469 | break; |
| 470 | case PERIPH_ID_SPI4: |
| 471 | cfg = 0; |
| 472 | pin = 0; |
| 473 | break; |
| 474 | default: |
| 475 | cfg = 0; |
| 476 | pin = 0; |
| 477 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 478 | return; |
| 479 | } |
| 480 | |
| 481 | if (peripheral != PERIPH_ID_SPI4) { |
| 482 | for (i = pin; i < pin + 4; i++) |
| 483 | s5p_gpio_cfg_pin(bank, i, cfg); |
| 484 | } else { |
| 485 | for (i = 0; i < 2; i++) { |
| 486 | s5p_gpio_cfg_pin(&gpio4->f0, i + 2, GPIO_FUNC(0x4)); |
| 487 | s5p_gpio_cfg_pin(&gpio4->e0, i + 4, GPIO_FUNC(0x4)); |
| 488 | } |
| 489 | } |
| 490 | } |
| 491 | |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 492 | static int exynos5_pinmux_config(int peripheral, int flags) |
| 493 | { |
| 494 | switch (peripheral) { |
| 495 | case PERIPH_ID_UART0: |
| 496 | case PERIPH_ID_UART1: |
| 497 | case PERIPH_ID_UART2: |
| 498 | case PERIPH_ID_UART3: |
| 499 | exynos5_uart_config(peripheral); |
| 500 | break; |
| 501 | case PERIPH_ID_SDMMC0: |
| 502 | case PERIPH_ID_SDMMC1: |
| 503 | case PERIPH_ID_SDMMC2: |
| 504 | case PERIPH_ID_SDMMC3: |
| 505 | return exynos5_mmc_config(peripheral, flags); |
| 506 | case PERIPH_ID_SROMC: |
| 507 | exynos5_sromc_config(flags); |
| 508 | break; |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 509 | case PERIPH_ID_I2C0: |
| 510 | case PERIPH_ID_I2C1: |
| 511 | case PERIPH_ID_I2C2: |
| 512 | case PERIPH_ID_I2C3: |
| 513 | case PERIPH_ID_I2C4: |
| 514 | case PERIPH_ID_I2C5: |
| 515 | case PERIPH_ID_I2C6: |
| 516 | case PERIPH_ID_I2C7: |
| 517 | exynos5_i2c_config(peripheral, flags); |
| 518 | break; |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 519 | case PERIPH_ID_I2S0: |
Rajeshwari Shinde | 7cf89a2 | 2012-10-25 19:49:27 +0000 | [diff] [blame] | 520 | case PERIPH_ID_I2S1: |
| 521 | exynos5_i2s_config(peripheral); |
| 522 | break; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 523 | case PERIPH_ID_SPI0: |
| 524 | case PERIPH_ID_SPI1: |
| 525 | case PERIPH_ID_SPI2: |
| 526 | case PERIPH_ID_SPI3: |
| 527 | case PERIPH_ID_SPI4: |
| 528 | exynos5_spi_config(peripheral); |
| 529 | break; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 530 | default: |
| 531 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 532 | return -1; |
| 533 | } |
| 534 | |
| 535 | return 0; |
| 536 | } |
| 537 | |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 538 | static int exynos5420_pinmux_config(int peripheral, int flags) |
| 539 | { |
| 540 | switch (peripheral) { |
| 541 | case PERIPH_ID_UART0: |
| 542 | case PERIPH_ID_UART1: |
| 543 | case PERIPH_ID_UART2: |
| 544 | case PERIPH_ID_UART3: |
| 545 | exynos5420_uart_config(peripheral); |
| 546 | break; |
| 547 | case PERIPH_ID_SDMMC0: |
| 548 | case PERIPH_ID_SDMMC1: |
| 549 | case PERIPH_ID_SDMMC2: |
| 550 | case PERIPH_ID_SDMMC3: |
| 551 | return exynos5420_mmc_config(peripheral, flags); |
| 552 | case PERIPH_ID_SPI0: |
| 553 | case PERIPH_ID_SPI1: |
| 554 | case PERIPH_ID_SPI2: |
| 555 | case PERIPH_ID_SPI3: |
| 556 | case PERIPH_ID_SPI4: |
| 557 | exynos5420_spi_config(peripheral); |
| 558 | break; |
| 559 | case PERIPH_ID_I2C0: |
| 560 | case PERIPH_ID_I2C1: |
| 561 | case PERIPH_ID_I2C2: |
| 562 | case PERIPH_ID_I2C3: |
| 563 | case PERIPH_ID_I2C4: |
| 564 | case PERIPH_ID_I2C5: |
| 565 | case PERIPH_ID_I2C6: |
| 566 | case PERIPH_ID_I2C7: |
| 567 | case PERIPH_ID_I2C8: |
| 568 | case PERIPH_ID_I2C9: |
| 569 | case PERIPH_ID_I2C10: |
| 570 | exynos5420_i2c_config(peripheral); |
| 571 | break; |
| 572 | default: |
| 573 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 574 | return -1; |
| 575 | } |
| 576 | |
| 577 | return 0; |
| 578 | } |
| 579 | |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 580 | static void exynos4_i2c_config(int peripheral, int flags) |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 581 | { |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 582 | struct exynos4_gpio_part1 *gpio1 = |
| 583 | (struct exynos4_gpio_part1 *) samsung_get_base_gpio_part1(); |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 584 | |
| 585 | switch (peripheral) { |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 586 | case PERIPH_ID_I2C0: |
| 587 | s5p_gpio_cfg_pin(&gpio1->d1, 0, GPIO_FUNC(0x2)); |
| 588 | s5p_gpio_cfg_pin(&gpio1->d1, 1, GPIO_FUNC(0x2)); |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 589 | break; |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 590 | case PERIPH_ID_I2C1: |
| 591 | s5p_gpio_cfg_pin(&gpio1->d1, 2, GPIO_FUNC(0x2)); |
| 592 | s5p_gpio_cfg_pin(&gpio1->d1, 3, GPIO_FUNC(0x2)); |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 593 | break; |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 594 | case PERIPH_ID_I2C2: |
| 595 | s5p_gpio_cfg_pin(&gpio1->a0, 6, GPIO_FUNC(0x3)); |
| 596 | s5p_gpio_cfg_pin(&gpio1->a0, 7, GPIO_FUNC(0x3)); |
| 597 | break; |
| 598 | case PERIPH_ID_I2C3: |
| 599 | s5p_gpio_cfg_pin(&gpio1->a1, 2, GPIO_FUNC(0x3)); |
| 600 | s5p_gpio_cfg_pin(&gpio1->a1, 3, GPIO_FUNC(0x3)); |
| 601 | break; |
| 602 | case PERIPH_ID_I2C4: |
| 603 | s5p_gpio_cfg_pin(&gpio1->b, 2, GPIO_FUNC(0x3)); |
| 604 | s5p_gpio_cfg_pin(&gpio1->b, 3, GPIO_FUNC(0x3)); |
| 605 | break; |
| 606 | case PERIPH_ID_I2C5: |
| 607 | s5p_gpio_cfg_pin(&gpio1->b, 6, GPIO_FUNC(0x3)); |
| 608 | s5p_gpio_cfg_pin(&gpio1->b, 7, GPIO_FUNC(0x3)); |
| 609 | break; |
| 610 | case PERIPH_ID_I2C6: |
| 611 | s5p_gpio_cfg_pin(&gpio1->c1, 3, GPIO_FUNC(0x4)); |
| 612 | s5p_gpio_cfg_pin(&gpio1->c1, 4, GPIO_FUNC(0x4)); |
| 613 | break; |
| 614 | case PERIPH_ID_I2C7: |
| 615 | s5p_gpio_cfg_pin(&gpio1->d0, 2, GPIO_FUNC(0x3)); |
| 616 | s5p_gpio_cfg_pin(&gpio1->d0, 3, GPIO_FUNC(0x3)); |
| 617 | break; |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 618 | } |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 619 | } |
| 620 | |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 621 | static int exynos4_mmc_config(int peripheral, int flags) |
| 622 | { |
| 623 | struct exynos4_gpio_part2 *gpio2 = |
| 624 | (struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2(); |
| 625 | struct s5p_gpio_bank *bank, *bank_ext; |
| 626 | int i; |
| 627 | |
| 628 | switch (peripheral) { |
| 629 | case PERIPH_ID_SDMMC0: |
| 630 | bank = &gpio2->k0; |
| 631 | bank_ext = &gpio2->k1; |
| 632 | break; |
| 633 | case PERIPH_ID_SDMMC2: |
| 634 | bank = &gpio2->k2; |
| 635 | bank_ext = &gpio2->k3; |
| 636 | break; |
| 637 | default: |
| 638 | return -1; |
| 639 | } |
| 640 | for (i = 0; i < 7; i++) { |
| 641 | if (i == 2) |
| 642 | continue; |
| 643 | s5p_gpio_cfg_pin(bank, i, GPIO_FUNC(0x2)); |
| 644 | s5p_gpio_set_pull(bank, i, GPIO_PULL_NONE); |
| 645 | s5p_gpio_set_drv(bank, i, GPIO_DRV_4X); |
| 646 | } |
| 647 | if (flags & PINMUX_FLAG_8BIT_MODE) { |
| 648 | for (i = 3; i < 7; i++) { |
| 649 | s5p_gpio_cfg_pin(bank_ext, i, GPIO_FUNC(0x3)); |
| 650 | s5p_gpio_set_pull(bank_ext, i, GPIO_PULL_NONE); |
| 651 | s5p_gpio_set_drv(bank_ext, i, GPIO_DRV_4X); |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | return 0; |
| 656 | } |
| 657 | |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 658 | static void exynos4_uart_config(int peripheral) |
| 659 | { |
| 660 | struct exynos4_gpio_part1 *gpio1 = |
| 661 | (struct exynos4_gpio_part1 *)samsung_get_base_gpio_part1(); |
| 662 | struct s5p_gpio_bank *bank; |
| 663 | int i, start, count; |
| 664 | |
| 665 | switch (peripheral) { |
| 666 | case PERIPH_ID_UART0: |
| 667 | bank = &gpio1->a0; |
| 668 | start = 0; |
| 669 | count = 4; |
| 670 | break; |
| 671 | case PERIPH_ID_UART1: |
| 672 | bank = &gpio1->a0; |
| 673 | start = 4; |
| 674 | count = 4; |
| 675 | break; |
| 676 | case PERIPH_ID_UART2: |
| 677 | bank = &gpio1->a1; |
| 678 | start = 0; |
| 679 | count = 4; |
| 680 | break; |
| 681 | case PERIPH_ID_UART3: |
| 682 | bank = &gpio1->a1; |
| 683 | start = 4; |
| 684 | count = 2; |
| 685 | break; |
| 686 | } |
| 687 | for (i = start; i < start + count; i++) { |
| 688 | s5p_gpio_set_pull(bank, i, GPIO_PULL_NONE); |
| 689 | s5p_gpio_cfg_pin(bank, i, GPIO_FUNC(0x2)); |
| 690 | } |
| 691 | } |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 692 | static int exynos4_pinmux_config(int peripheral, int flags) |
| 693 | { |
| 694 | switch (peripheral) { |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 695 | case PERIPH_ID_UART0: |
| 696 | case PERIPH_ID_UART1: |
| 697 | case PERIPH_ID_UART2: |
| 698 | case PERIPH_ID_UART3: |
| 699 | exynos4_uart_config(peripheral); |
| 700 | break; |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 701 | case PERIPH_ID_I2C0: |
| 702 | case PERIPH_ID_I2C1: |
| 703 | case PERIPH_ID_I2C2: |
| 704 | case PERIPH_ID_I2C3: |
| 705 | case PERIPH_ID_I2C4: |
| 706 | case PERIPH_ID_I2C5: |
| 707 | case PERIPH_ID_I2C6: |
| 708 | case PERIPH_ID_I2C7: |
| 709 | exynos4_i2c_config(peripheral, flags); |
| 710 | break; |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 711 | case PERIPH_ID_SDMMC0: |
| 712 | case PERIPH_ID_SDMMC2: |
| 713 | return exynos4_mmc_config(peripheral, flags); |
| 714 | case PERIPH_ID_SDMMC1: |
| 715 | case PERIPH_ID_SDMMC3: |
| 716 | case PERIPH_ID_SDMMC4: |
Rajeshwari Shinde | 507f892 | 2013-10-08 18:42:22 +0530 | [diff] [blame] | 717 | debug("SDMMC device %d not implemented\n", peripheral); |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 718 | return -1; |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 719 | default: |
| 720 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 721 | return -1; |
| 722 | } |
| 723 | |
| 724 | return 0; |
| 725 | } |
| 726 | |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 727 | int exynos_pinmux_config(int peripheral, int flags) |
| 728 | { |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 729 | if (cpu_is_exynos5()) { |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 730 | if (proid_is_exynos5420()) |
| 731 | return exynos5420_pinmux_config(peripheral, flags); |
| 732 | else if (proid_is_exynos5250()) |
| 733 | return exynos5_pinmux_config(peripheral, flags); |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 734 | } else if (cpu_is_exynos4()) { |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 735 | return exynos4_pinmux_config(peripheral, flags); |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 736 | } else { |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 737 | debug("pinmux functionality not supported\n"); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 738 | } |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 739 | |
| 740 | return -1; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 741 | } |
Rajeshwari Shinde | 28bae82 | 2012-12-26 20:03:11 +0000 | [diff] [blame] | 742 | |
| 743 | #ifdef CONFIG_OF_CONTROL |
| 744 | static int exynos5_pinmux_decode_periph_id(const void *blob, int node) |
| 745 | { |
| 746 | int err; |
| 747 | u32 cell[3]; |
| 748 | |
| 749 | err = fdtdec_get_int_array(blob, node, "interrupts", cell, |
| 750 | ARRAY_SIZE(cell)); |
| 751 | if (err) |
| 752 | return PERIPH_ID_NONE; |
| 753 | |
Minkyu Kang | dcc9917 | 2014-01-29 17:04:17 +0900 | [diff] [blame^] | 754 | return cell[1]; |
Rajeshwari Shinde | 28bae82 | 2012-12-26 20:03:11 +0000 | [diff] [blame] | 755 | } |
| 756 | |
| 757 | int pinmux_decode_periph_id(const void *blob, int node) |
| 758 | { |
| 759 | if (cpu_is_exynos5()) |
| 760 | return exynos5_pinmux_decode_periph_id(blob, node); |
| 761 | else |
| 762 | return PERIPH_ID_NONE; |
| 763 | } |
| 764 | #endif |