Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2012 Samsung Electronics. |
| 4 | * Abhilash Kesavan <a.kesavan@samsung.com> |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Rajeshwari Shinde | 28bae82 | 2012-12-26 20:03:11 +0000 | [diff] [blame] | 7 | #include <fdtdec.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Simon Glass | 37f1162 | 2014-10-20 19:48:37 -0600 | [diff] [blame] | 9 | #include <asm/gpio.h> |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 10 | #include <asm/arch/pinmux.h> |
| 11 | #include <asm/arch/sromc.h> |
| 12 | |
| 13 | static void exynos5_uart_config(int peripheral) |
| 14 | { |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 15 | int i, start, count; |
| 16 | |
| 17 | switch (peripheral) { |
| 18 | case PERIPH_ID_UART0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 19 | start = EXYNOS5_GPIO_A00; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 20 | count = 4; |
| 21 | break; |
| 22 | case PERIPH_ID_UART1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 23 | start = EXYNOS5_GPIO_D00; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 24 | count = 4; |
| 25 | break; |
| 26 | case PERIPH_ID_UART2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 27 | start = EXYNOS5_GPIO_A10; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 28 | count = 4; |
| 29 | break; |
| 30 | case PERIPH_ID_UART3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 31 | start = EXYNOS5_GPIO_A14; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 32 | count = 2; |
| 33 | break; |
Marek Vasut | e382be9 | 2014-03-10 20:04:31 +0100 | [diff] [blame] | 34 | default: |
| 35 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 36 | return; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 37 | } |
| 38 | for (i = start; i < start + count; i++) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 39 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 40 | gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2)); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 41 | } |
| 42 | } |
| 43 | |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 44 | static void exynos5420_uart_config(int peripheral) |
| 45 | { |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 46 | int i, start, count; |
| 47 | |
| 48 | switch (peripheral) { |
| 49 | case PERIPH_ID_UART0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 50 | start = EXYNOS5420_GPIO_A00; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 51 | count = 4; |
| 52 | break; |
| 53 | case PERIPH_ID_UART1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 54 | start = EXYNOS5420_GPIO_A04; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 55 | count = 4; |
| 56 | break; |
| 57 | case PERIPH_ID_UART2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 58 | start = EXYNOS5420_GPIO_A10; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 59 | count = 4; |
| 60 | break; |
| 61 | case PERIPH_ID_UART3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 62 | start = EXYNOS5420_GPIO_A14; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 63 | count = 2; |
| 64 | break; |
Marek Vasut | e382be9 | 2014-03-10 20:04:31 +0100 | [diff] [blame] | 65 | default: |
| 66 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 67 | return; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | for (i = start; i < start + count; i++) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 71 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 72 | gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 76 | static int exynos5_mmc_config(int peripheral, int flags) |
| 77 | { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 78 | int i, start, start_ext, gpio_func = 0; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 79 | |
| 80 | switch (peripheral) { |
| 81 | case PERIPH_ID_SDMMC0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 82 | start = EXYNOS5_GPIO_C00; |
| 83 | start_ext = EXYNOS5_GPIO_C10; |
| 84 | gpio_func = S5P_GPIO_FUNC(0x2); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 85 | break; |
| 86 | case PERIPH_ID_SDMMC1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 87 | start = EXYNOS5_GPIO_C20; |
| 88 | start_ext = 0; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 89 | break; |
| 90 | case PERIPH_ID_SDMMC2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 91 | start = EXYNOS5_GPIO_C30; |
| 92 | start_ext = EXYNOS5_GPIO_C43; |
| 93 | gpio_func = S5P_GPIO_FUNC(0x3); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 94 | break; |
| 95 | case PERIPH_ID_SDMMC3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 96 | start = EXYNOS5_GPIO_C40; |
| 97 | start_ext = 0; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 98 | break; |
Marek Vasut | e382be9 | 2014-03-10 20:04:31 +0100 | [diff] [blame] | 99 | default: |
| 100 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 101 | return -1; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 102 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 103 | if ((flags & PINMUX_FLAG_8BIT_MODE) && !start_ext) { |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 104 | debug("SDMMC device %d does not support 8bit mode", |
| 105 | peripheral); |
| 106 | return -1; |
| 107 | } |
| 108 | if (flags & PINMUX_FLAG_8BIT_MODE) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 109 | for (i = start_ext; i <= (start_ext + 3); i++) { |
| 110 | gpio_cfg_pin(i, gpio_func); |
| 111 | gpio_set_pull(i, S5P_GPIO_PULL_UP); |
| 112 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 113 | } |
| 114 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 115 | for (i = start; i < (start + 2); i++) { |
| 116 | gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2)); |
| 117 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 118 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 119 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 120 | for (i = (start + 3); i <= (start + 6); i++) { |
| 121 | gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2)); |
| 122 | gpio_set_pull(i, S5P_GPIO_PULL_UP); |
| 123 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | static int exynos5420_mmc_config(int peripheral, int flags) |
| 130 | { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 131 | int i, start = 0, start_ext = 0; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 132 | |
| 133 | switch (peripheral) { |
| 134 | case PERIPH_ID_SDMMC0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 135 | start = EXYNOS5420_GPIO_C00; |
| 136 | start_ext = EXYNOS5420_GPIO_C30; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 137 | break; |
| 138 | case PERIPH_ID_SDMMC1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 139 | start = EXYNOS5420_GPIO_C10; |
| 140 | start_ext = EXYNOS5420_GPIO_D14; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 141 | break; |
| 142 | case PERIPH_ID_SDMMC2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 143 | start = EXYNOS5420_GPIO_C20; |
| 144 | start_ext = 0; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 145 | break; |
| 146 | default: |
| 147 | start = 0; |
| 148 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 149 | return -1; |
| 150 | } |
| 151 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 152 | if ((flags & PINMUX_FLAG_8BIT_MODE) && !start_ext) { |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 153 | debug("SDMMC device %d does not support 8bit mode", |
| 154 | peripheral); |
| 155 | return -1; |
| 156 | } |
| 157 | |
| 158 | if (flags & PINMUX_FLAG_8BIT_MODE) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 159 | for (i = start_ext; i <= (start_ext + 3); i++) { |
| 160 | gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2)); |
| 161 | gpio_set_pull(i, S5P_GPIO_PULL_UP); |
| 162 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 163 | } |
| 164 | } |
| 165 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 166 | for (i = start; i < (start + 3); i++) { |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 167 | /* |
| 168 | * MMC0 is intended to be used for eMMC. The |
| 169 | * card detect pin is used as a VDDEN signal to |
| 170 | * power on the eMMC. The 5420 iROM makes |
| 171 | * this same assumption. |
| 172 | */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 173 | if ((peripheral == PERIPH_ID_SDMMC0) && (i == (start + 2))) { |
Simon Glass | 4f83d3d | 2014-10-20 19:48:39 -0600 | [diff] [blame] | 174 | #ifndef CONFIG_SPL_BUILD |
| 175 | gpio_request(i, "sdmmc0_vdden"); |
| 176 | #endif |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 177 | gpio_set_value(i, 1); |
| 178 | gpio_cfg_pin(i, S5P_GPIO_OUTPUT); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 179 | } else { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 180 | gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 181 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 182 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 183 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 184 | } |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 185 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 186 | for (i = (start + 3); i <= (start + 6); i++) { |
| 187 | gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2)); |
| 188 | gpio_set_pull(i, S5P_GPIO_PULL_UP); |
| 189 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 190 | } |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 191 | |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | static void exynos5_sromc_config(int flags) |
| 196 | { |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 197 | int i; |
| 198 | |
| 199 | /* |
| 200 | * SROM:CS1 and EBI |
| 201 | * |
| 202 | * GPY0[0] SROM_CSn[0] |
| 203 | * GPY0[1] SROM_CSn[1](2) |
| 204 | * GPY0[2] SROM_CSn[2] |
| 205 | * GPY0[3] SROM_CSn[3] |
| 206 | * GPY0[4] EBI_OEn(2) |
| 207 | * GPY0[5] EBI_EEn(2) |
| 208 | * |
| 209 | * GPY1[0] EBI_BEn[0](2) |
| 210 | * GPY1[1] EBI_BEn[1](2) |
| 211 | * GPY1[2] SROM_WAIT(2) |
| 212 | * GPY1[3] EBI_DATA_RDn(2) |
| 213 | */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 214 | gpio_cfg_pin(EXYNOS5_GPIO_Y00 + (flags & PINMUX_FLAG_BANK), |
| 215 | S5P_GPIO_FUNC(2)); |
| 216 | gpio_cfg_pin(EXYNOS5_GPIO_Y04, S5P_GPIO_FUNC(2)); |
| 217 | gpio_cfg_pin(EXYNOS5_GPIO_Y05, S5P_GPIO_FUNC(2)); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 218 | |
| 219 | for (i = 0; i < 4; i++) |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 220 | gpio_cfg_pin(EXYNOS5_GPIO_Y10 + i, S5P_GPIO_FUNC(2)); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 221 | |
| 222 | /* |
| 223 | * EBI: 8 Addrss Lines |
| 224 | * |
| 225 | * GPY3[0] EBI_ADDR[0](2) |
| 226 | * GPY3[1] EBI_ADDR[1](2) |
| 227 | * GPY3[2] EBI_ADDR[2](2) |
| 228 | * GPY3[3] EBI_ADDR[3](2) |
| 229 | * GPY3[4] EBI_ADDR[4](2) |
| 230 | * GPY3[5] EBI_ADDR[5](2) |
| 231 | * GPY3[6] EBI_ADDR[6](2) |
| 232 | * GPY3[7] EBI_ADDR[7](2) |
| 233 | * |
| 234 | * EBI: 16 Data Lines |
| 235 | * |
| 236 | * GPY5[0] EBI_DATA[0](2) |
| 237 | * GPY5[1] EBI_DATA[1](2) |
| 238 | * GPY5[2] EBI_DATA[2](2) |
| 239 | * GPY5[3] EBI_DATA[3](2) |
| 240 | * GPY5[4] EBI_DATA[4](2) |
| 241 | * GPY5[5] EBI_DATA[5](2) |
| 242 | * GPY5[6] EBI_DATA[6](2) |
| 243 | * GPY5[7] EBI_DATA[7](2) |
| 244 | * |
| 245 | * GPY6[0] EBI_DATA[8](2) |
| 246 | * GPY6[1] EBI_DATA[9](2) |
| 247 | * GPY6[2] EBI_DATA[10](2) |
| 248 | * GPY6[3] EBI_DATA[11](2) |
| 249 | * GPY6[4] EBI_DATA[12](2) |
| 250 | * GPY6[5] EBI_DATA[13](2) |
| 251 | * GPY6[6] EBI_DATA[14](2) |
| 252 | * GPY6[7] EBI_DATA[15](2) |
| 253 | */ |
| 254 | for (i = 0; i < 8; i++) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 255 | gpio_cfg_pin(EXYNOS5_GPIO_Y30 + i, S5P_GPIO_FUNC(2)); |
| 256 | gpio_set_pull(EXYNOS5_GPIO_Y30 + i, S5P_GPIO_PULL_UP); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 257 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 258 | gpio_cfg_pin(EXYNOS5_GPIO_Y50 + i, S5P_GPIO_FUNC(2)); |
| 259 | gpio_set_pull(EXYNOS5_GPIO_Y50 + i, S5P_GPIO_PULL_UP); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 260 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 261 | gpio_cfg_pin(EXYNOS5_GPIO_Y60 + i, S5P_GPIO_FUNC(2)); |
| 262 | gpio_set_pull(EXYNOS5_GPIO_Y60 + i, S5P_GPIO_PULL_UP); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 263 | } |
| 264 | } |
| 265 | |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 266 | static void exynos5_i2c_config(int peripheral, int flags) |
| 267 | { |
Przemyslaw Marczak | 056d655 | 2015-01-27 13:36:34 +0100 | [diff] [blame] | 268 | int func01, func23; |
| 269 | |
| 270 | /* High-Speed I2C */ |
| 271 | if (flags & PINMUX_FLAG_HS_MODE) { |
| 272 | func01 = 4; |
| 273 | func23 = 4; |
| 274 | } else { |
| 275 | func01 = 2; |
| 276 | func23 = 3; |
| 277 | } |
| 278 | |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 279 | switch (peripheral) { |
| 280 | case PERIPH_ID_I2C0: |
Przemyslaw Marczak | 056d655 | 2015-01-27 13:36:34 +0100 | [diff] [blame] | 281 | gpio_cfg_pin(EXYNOS5_GPIO_B30, S5P_GPIO_FUNC(func01)); |
| 282 | gpio_cfg_pin(EXYNOS5_GPIO_B31, S5P_GPIO_FUNC(func01)); |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 283 | break; |
| 284 | case PERIPH_ID_I2C1: |
Przemyslaw Marczak | 056d655 | 2015-01-27 13:36:34 +0100 | [diff] [blame] | 285 | gpio_cfg_pin(EXYNOS5_GPIO_B32, S5P_GPIO_FUNC(func01)); |
| 286 | gpio_cfg_pin(EXYNOS5_GPIO_B33, S5P_GPIO_FUNC(func01)); |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 287 | break; |
| 288 | case PERIPH_ID_I2C2: |
Przemyslaw Marczak | 056d655 | 2015-01-27 13:36:34 +0100 | [diff] [blame] | 289 | gpio_cfg_pin(EXYNOS5_GPIO_A06, S5P_GPIO_FUNC(func23)); |
| 290 | gpio_cfg_pin(EXYNOS5_GPIO_A07, S5P_GPIO_FUNC(func23)); |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 291 | break; |
| 292 | case PERIPH_ID_I2C3: |
Przemyslaw Marczak | 056d655 | 2015-01-27 13:36:34 +0100 | [diff] [blame] | 293 | gpio_cfg_pin(EXYNOS5_GPIO_A12, S5P_GPIO_FUNC(func23)); |
| 294 | gpio_cfg_pin(EXYNOS5_GPIO_A13, S5P_GPIO_FUNC(func23)); |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 295 | break; |
| 296 | case PERIPH_ID_I2C4: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 297 | gpio_cfg_pin(EXYNOS5_GPIO_A20, S5P_GPIO_FUNC(0x3)); |
| 298 | gpio_cfg_pin(EXYNOS5_GPIO_A21, S5P_GPIO_FUNC(0x3)); |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 299 | break; |
| 300 | case PERIPH_ID_I2C5: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 301 | gpio_cfg_pin(EXYNOS5_GPIO_A22, S5P_GPIO_FUNC(0x3)); |
| 302 | gpio_cfg_pin(EXYNOS5_GPIO_A23, S5P_GPIO_FUNC(0x3)); |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 303 | break; |
| 304 | case PERIPH_ID_I2C6: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 305 | gpio_cfg_pin(EXYNOS5_GPIO_B13, S5P_GPIO_FUNC(0x4)); |
| 306 | gpio_cfg_pin(EXYNOS5_GPIO_B14, S5P_GPIO_FUNC(0x4)); |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 307 | break; |
| 308 | case PERIPH_ID_I2C7: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 309 | gpio_cfg_pin(EXYNOS5_GPIO_B22, S5P_GPIO_FUNC(0x3)); |
| 310 | gpio_cfg_pin(EXYNOS5_GPIO_B23, S5P_GPIO_FUNC(0x3)); |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 311 | break; |
| 312 | } |
| 313 | } |
| 314 | |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 315 | static void exynos5420_i2c_config(int peripheral) |
| 316 | { |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 317 | switch (peripheral) { |
| 318 | case PERIPH_ID_I2C0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 319 | gpio_cfg_pin(EXYNOS5420_GPIO_B30, S5P_GPIO_FUNC(0x2)); |
| 320 | gpio_cfg_pin(EXYNOS5420_GPIO_B31, S5P_GPIO_FUNC(0x2)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 321 | break; |
| 322 | case PERIPH_ID_I2C1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 323 | gpio_cfg_pin(EXYNOS5420_GPIO_B32, S5P_GPIO_FUNC(0x2)); |
| 324 | gpio_cfg_pin(EXYNOS5420_GPIO_B33, S5P_GPIO_FUNC(0x2)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 325 | break; |
| 326 | case PERIPH_ID_I2C2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 327 | gpio_cfg_pin(EXYNOS5420_GPIO_A06, S5P_GPIO_FUNC(0x3)); |
| 328 | gpio_cfg_pin(EXYNOS5420_GPIO_A07, S5P_GPIO_FUNC(0x3)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 329 | break; |
| 330 | case PERIPH_ID_I2C3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 331 | gpio_cfg_pin(EXYNOS5420_GPIO_A12, S5P_GPIO_FUNC(0x3)); |
| 332 | gpio_cfg_pin(EXYNOS5420_GPIO_A13, S5P_GPIO_FUNC(0x3)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 333 | break; |
| 334 | case PERIPH_ID_I2C4: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 335 | gpio_cfg_pin(EXYNOS5420_GPIO_A20, S5P_GPIO_FUNC(0x3)); |
| 336 | gpio_cfg_pin(EXYNOS5420_GPIO_A21, S5P_GPIO_FUNC(0x3)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 337 | break; |
| 338 | case PERIPH_ID_I2C5: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 339 | gpio_cfg_pin(EXYNOS5420_GPIO_A22, S5P_GPIO_FUNC(0x3)); |
| 340 | gpio_cfg_pin(EXYNOS5420_GPIO_A23, S5P_GPIO_FUNC(0x3)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 341 | break; |
| 342 | case PERIPH_ID_I2C6: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 343 | gpio_cfg_pin(EXYNOS5420_GPIO_B13, S5P_GPIO_FUNC(0x4)); |
| 344 | gpio_cfg_pin(EXYNOS5420_GPIO_B14, S5P_GPIO_FUNC(0x4)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 345 | break; |
| 346 | case PERIPH_ID_I2C7: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 347 | gpio_cfg_pin(EXYNOS5420_GPIO_B22, S5P_GPIO_FUNC(0x3)); |
| 348 | gpio_cfg_pin(EXYNOS5420_GPIO_B23, S5P_GPIO_FUNC(0x3)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 349 | break; |
| 350 | case PERIPH_ID_I2C8: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 351 | gpio_cfg_pin(EXYNOS5420_GPIO_B34, S5P_GPIO_FUNC(0x2)); |
| 352 | gpio_cfg_pin(EXYNOS5420_GPIO_B35, S5P_GPIO_FUNC(0x2)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 353 | break; |
| 354 | case PERIPH_ID_I2C9: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 355 | gpio_cfg_pin(EXYNOS5420_GPIO_B36, S5P_GPIO_FUNC(0x2)); |
| 356 | gpio_cfg_pin(EXYNOS5420_GPIO_B37, S5P_GPIO_FUNC(0x2)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 357 | break; |
| 358 | case PERIPH_ID_I2C10: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 359 | gpio_cfg_pin(EXYNOS5420_GPIO_B40, S5P_GPIO_FUNC(0x2)); |
| 360 | gpio_cfg_pin(EXYNOS5420_GPIO_B41, S5P_GPIO_FUNC(0x2)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 361 | break; |
| 362 | } |
| 363 | } |
| 364 | |
Rajeshwari Shinde | 7cf89a2 | 2012-10-25 19:49:27 +0000 | [diff] [blame] | 365 | static void exynos5_i2s_config(int peripheral) |
| 366 | { |
| 367 | int i; |
Rajeshwari Shinde | 7cf89a2 | 2012-10-25 19:49:27 +0000 | [diff] [blame] | 368 | |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 369 | switch (peripheral) { |
| 370 | case PERIPH_ID_I2S0: |
| 371 | for (i = 0; i < 5; i++) |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 372 | gpio_cfg_pin(EXYNOS5_GPIO_Z0 + i, S5P_GPIO_FUNC(0x02)); |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 373 | break; |
| 374 | case PERIPH_ID_I2S1: |
| 375 | for (i = 0; i < 5; i++) |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 376 | gpio_cfg_pin(EXYNOS5_GPIO_B00 + i, S5P_GPIO_FUNC(0x02)); |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 377 | break; |
| 378 | } |
Rajeshwari Shinde | 7cf89a2 | 2012-10-25 19:49:27 +0000 | [diff] [blame] | 379 | } |
| 380 | |
Simon Glass | 12d70f4 | 2018-12-10 10:37:41 -0700 | [diff] [blame] | 381 | static void exynos5420_i2s_config(int peripheral) |
| 382 | { |
| 383 | int i; |
| 384 | |
| 385 | switch (peripheral) { |
| 386 | case PERIPH_ID_I2S0: |
| 387 | for (i = 0; i < 5; i++) |
| 388 | gpio_cfg_pin(EXYNOS5420_GPIO_Z0 + i, |
| 389 | S5P_GPIO_FUNC(0x02)); |
| 390 | break; |
| 391 | } |
| 392 | } |
| 393 | |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 394 | void exynos5_spi_config(int peripheral) |
| 395 | { |
| 396 | int cfg = 0, pin = 0, i; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 397 | |
| 398 | switch (peripheral) { |
| 399 | case PERIPH_ID_SPI0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 400 | cfg = S5P_GPIO_FUNC(0x2); |
| 401 | pin = EXYNOS5_GPIO_A20; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 402 | break; |
| 403 | case PERIPH_ID_SPI1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 404 | cfg = S5P_GPIO_FUNC(0x2); |
| 405 | pin = EXYNOS5_GPIO_A24; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 406 | break; |
| 407 | case PERIPH_ID_SPI2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 408 | cfg = S5P_GPIO_FUNC(0x5); |
| 409 | pin = EXYNOS5_GPIO_B11; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 410 | break; |
| 411 | case PERIPH_ID_SPI3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 412 | cfg = S5P_GPIO_FUNC(0x2); |
| 413 | pin = EXYNOS5_GPIO_F10; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 414 | break; |
| 415 | case PERIPH_ID_SPI4: |
| 416 | for (i = 0; i < 2; i++) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 417 | gpio_cfg_pin(EXYNOS5_GPIO_F02 + i, S5P_GPIO_FUNC(0x4)); |
| 418 | gpio_cfg_pin(EXYNOS5_GPIO_E04 + i, S5P_GPIO_FUNC(0x4)); |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 419 | } |
| 420 | break; |
| 421 | } |
| 422 | if (peripheral != PERIPH_ID_SPI4) { |
| 423 | for (i = pin; i < pin + 4; i++) |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 424 | gpio_cfg_pin(i, cfg); |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 425 | } |
| 426 | } |
| 427 | |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 428 | void exynos5420_spi_config(int peripheral) |
| 429 | { |
| 430 | int cfg, pin, i; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 431 | |
| 432 | switch (peripheral) { |
| 433 | case PERIPH_ID_SPI0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 434 | pin = EXYNOS5420_GPIO_A20; |
| 435 | cfg = S5P_GPIO_FUNC(0x2); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 436 | break; |
| 437 | case PERIPH_ID_SPI1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 438 | pin = EXYNOS5420_GPIO_A24; |
| 439 | cfg = S5P_GPIO_FUNC(0x2); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 440 | break; |
| 441 | case PERIPH_ID_SPI2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 442 | pin = EXYNOS5420_GPIO_B11; |
| 443 | cfg = S5P_GPIO_FUNC(0x5); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 444 | break; |
| 445 | case PERIPH_ID_SPI3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 446 | pin = EXYNOS5420_GPIO_F10; |
| 447 | cfg = S5P_GPIO_FUNC(0x2); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 448 | break; |
| 449 | case PERIPH_ID_SPI4: |
| 450 | cfg = 0; |
| 451 | pin = 0; |
| 452 | break; |
| 453 | default: |
| 454 | cfg = 0; |
| 455 | pin = 0; |
| 456 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 457 | return; |
| 458 | } |
| 459 | |
| 460 | if (peripheral != PERIPH_ID_SPI4) { |
| 461 | for (i = pin; i < pin + 4; i++) |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 462 | gpio_cfg_pin(i, cfg); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 463 | } else { |
| 464 | for (i = 0; i < 2; i++) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 465 | gpio_cfg_pin(EXYNOS5420_GPIO_F02 + i, |
| 466 | S5P_GPIO_FUNC(0x4)); |
| 467 | gpio_cfg_pin(EXYNOS5420_GPIO_E04 + i, |
| 468 | S5P_GPIO_FUNC(0x4)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 469 | } |
| 470 | } |
| 471 | } |
| 472 | |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 473 | static int exynos5_pinmux_config(int peripheral, int flags) |
| 474 | { |
| 475 | switch (peripheral) { |
| 476 | case PERIPH_ID_UART0: |
| 477 | case PERIPH_ID_UART1: |
| 478 | case PERIPH_ID_UART2: |
| 479 | case PERIPH_ID_UART3: |
| 480 | exynos5_uart_config(peripheral); |
| 481 | break; |
| 482 | case PERIPH_ID_SDMMC0: |
| 483 | case PERIPH_ID_SDMMC1: |
| 484 | case PERIPH_ID_SDMMC2: |
| 485 | case PERIPH_ID_SDMMC3: |
| 486 | return exynos5_mmc_config(peripheral, flags); |
| 487 | case PERIPH_ID_SROMC: |
| 488 | exynos5_sromc_config(flags); |
| 489 | break; |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 490 | case PERIPH_ID_I2C0: |
| 491 | case PERIPH_ID_I2C1: |
| 492 | case PERIPH_ID_I2C2: |
| 493 | case PERIPH_ID_I2C3: |
| 494 | case PERIPH_ID_I2C4: |
| 495 | case PERIPH_ID_I2C5: |
| 496 | case PERIPH_ID_I2C6: |
| 497 | case PERIPH_ID_I2C7: |
| 498 | exynos5_i2c_config(peripheral, flags); |
| 499 | break; |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 500 | case PERIPH_ID_I2S0: |
Rajeshwari Shinde | 7cf89a2 | 2012-10-25 19:49:27 +0000 | [diff] [blame] | 501 | case PERIPH_ID_I2S1: |
| 502 | exynos5_i2s_config(peripheral); |
| 503 | break; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 504 | case PERIPH_ID_SPI0: |
| 505 | case PERIPH_ID_SPI1: |
| 506 | case PERIPH_ID_SPI2: |
| 507 | case PERIPH_ID_SPI3: |
| 508 | case PERIPH_ID_SPI4: |
| 509 | exynos5_spi_config(peripheral); |
| 510 | break; |
Simon Glass | 6f6af97 | 2015-07-02 18:16:13 -0600 | [diff] [blame] | 511 | case PERIPH_ID_DPHPD: |
| 512 | /* Set Hotplug detect for DP */ |
| 513 | gpio_cfg_pin(EXYNOS5_GPIO_X07, S5P_GPIO_FUNC(0x3)); |
| 514 | |
| 515 | /* |
| 516 | * Hotplug detect should have an external pullup; disable the |
| 517 | * internal pulldown so they don't fight. |
| 518 | */ |
| 519 | gpio_set_pull(EXYNOS5_GPIO_X07, S5P_GPIO_PULL_NONE); |
| 520 | break; |
Simon Glass | 114f836 | 2016-02-21 21:08:56 -0700 | [diff] [blame] | 521 | case PERIPH_ID_PWM0: |
| 522 | gpio_cfg_pin(EXYNOS5_GPIO_B20, S5P_GPIO_FUNC(2)); |
| 523 | break; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 524 | default: |
| 525 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 526 | return -1; |
| 527 | } |
| 528 | |
| 529 | return 0; |
| 530 | } |
| 531 | |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 532 | static int exynos5420_pinmux_config(int peripheral, int flags) |
| 533 | { |
| 534 | switch (peripheral) { |
| 535 | case PERIPH_ID_UART0: |
| 536 | case PERIPH_ID_UART1: |
| 537 | case PERIPH_ID_UART2: |
| 538 | case PERIPH_ID_UART3: |
| 539 | exynos5420_uart_config(peripheral); |
| 540 | break; |
| 541 | case PERIPH_ID_SDMMC0: |
| 542 | case PERIPH_ID_SDMMC1: |
| 543 | case PERIPH_ID_SDMMC2: |
| 544 | case PERIPH_ID_SDMMC3: |
| 545 | return exynos5420_mmc_config(peripheral, flags); |
| 546 | case PERIPH_ID_SPI0: |
| 547 | case PERIPH_ID_SPI1: |
| 548 | case PERIPH_ID_SPI2: |
| 549 | case PERIPH_ID_SPI3: |
| 550 | case PERIPH_ID_SPI4: |
| 551 | exynos5420_spi_config(peripheral); |
| 552 | break; |
| 553 | case PERIPH_ID_I2C0: |
| 554 | case PERIPH_ID_I2C1: |
| 555 | case PERIPH_ID_I2C2: |
| 556 | case PERIPH_ID_I2C3: |
| 557 | case PERIPH_ID_I2C4: |
| 558 | case PERIPH_ID_I2C5: |
| 559 | case PERIPH_ID_I2C6: |
| 560 | case PERIPH_ID_I2C7: |
| 561 | case PERIPH_ID_I2C8: |
| 562 | case PERIPH_ID_I2C9: |
| 563 | case PERIPH_ID_I2C10: |
| 564 | exynos5420_i2c_config(peripheral); |
| 565 | break; |
Simon Glass | 12d70f4 | 2018-12-10 10:37:41 -0700 | [diff] [blame] | 566 | case PERIPH_ID_I2S0: |
| 567 | exynos5420_i2s_config(peripheral); |
| 568 | break; |
Simon Glass | 114f836 | 2016-02-21 21:08:56 -0700 | [diff] [blame] | 569 | case PERIPH_ID_PWM0: |
| 570 | gpio_cfg_pin(EXYNOS5420_GPIO_B20, S5P_GPIO_FUNC(2)); |
| 571 | break; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 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 | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 582 | switch (peripheral) { |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 583 | case PERIPH_ID_I2C0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 584 | gpio_cfg_pin(EXYNOS4_GPIO_D10, S5P_GPIO_FUNC(0x2)); |
| 585 | gpio_cfg_pin(EXYNOS4_GPIO_D11, S5P_GPIO_FUNC(0x2)); |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 586 | break; |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 587 | case PERIPH_ID_I2C1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 588 | gpio_cfg_pin(EXYNOS4_GPIO_D12, S5P_GPIO_FUNC(0x2)); |
| 589 | gpio_cfg_pin(EXYNOS4_GPIO_D13, S5P_GPIO_FUNC(0x2)); |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 590 | break; |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 591 | case PERIPH_ID_I2C2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 592 | gpio_cfg_pin(EXYNOS4_GPIO_A06, S5P_GPIO_FUNC(0x3)); |
| 593 | gpio_cfg_pin(EXYNOS4_GPIO_A07, S5P_GPIO_FUNC(0x3)); |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 594 | break; |
| 595 | case PERIPH_ID_I2C3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 596 | gpio_cfg_pin(EXYNOS4_GPIO_A12, S5P_GPIO_FUNC(0x3)); |
| 597 | gpio_cfg_pin(EXYNOS4_GPIO_A13, S5P_GPIO_FUNC(0x3)); |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 598 | break; |
| 599 | case PERIPH_ID_I2C4: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 600 | gpio_cfg_pin(EXYNOS4_GPIO_B2, S5P_GPIO_FUNC(0x3)); |
| 601 | gpio_cfg_pin(EXYNOS4_GPIO_B3, S5P_GPIO_FUNC(0x3)); |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 602 | break; |
| 603 | case PERIPH_ID_I2C5: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 604 | gpio_cfg_pin(EXYNOS4_GPIO_B6, S5P_GPIO_FUNC(0x3)); |
| 605 | gpio_cfg_pin(EXYNOS4_GPIO_B7, S5P_GPIO_FUNC(0x3)); |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 606 | break; |
| 607 | case PERIPH_ID_I2C6: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 608 | gpio_cfg_pin(EXYNOS4_GPIO_C13, S5P_GPIO_FUNC(0x4)); |
| 609 | gpio_cfg_pin(EXYNOS4_GPIO_C14, S5P_GPIO_FUNC(0x4)); |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 610 | break; |
| 611 | case PERIPH_ID_I2C7: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 612 | gpio_cfg_pin(EXYNOS4_GPIO_D02, S5P_GPIO_FUNC(0x3)); |
| 613 | gpio_cfg_pin(EXYNOS4_GPIO_D03, S5P_GPIO_FUNC(0x3)); |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 614 | break; |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 615 | } |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 616 | } |
| 617 | |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 618 | static int exynos4_mmc_config(int peripheral, int flags) |
| 619 | { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 620 | int i, start = 0, start_ext = 0; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 621 | unsigned int func, ext_func; |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 622 | |
| 623 | switch (peripheral) { |
| 624 | case PERIPH_ID_SDMMC0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 625 | start = EXYNOS4_GPIO_K00; |
| 626 | start_ext = EXYNOS4_GPIO_K13; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 627 | func = S5P_GPIO_FUNC(0x2); |
| 628 | ext_func = S5P_GPIO_FUNC(0x3); |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 629 | break; |
| 630 | case PERIPH_ID_SDMMC2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 631 | start = EXYNOS4_GPIO_K20; |
| 632 | start_ext = EXYNOS4_GPIO_K33; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 633 | func = S5P_GPIO_FUNC(0x2); |
| 634 | ext_func = S5P_GPIO_FUNC(0x3); |
| 635 | break; |
| 636 | case PERIPH_ID_SDMMC4: |
| 637 | start = EXYNOS4_GPIO_K00; |
| 638 | start_ext = EXYNOS4_GPIO_K13; |
| 639 | func = S5P_GPIO_FUNC(0x3); |
| 640 | ext_func = S5P_GPIO_FUNC(0x4); |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 641 | break; |
| 642 | default: |
| 643 | return -1; |
| 644 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 645 | for (i = start; i < (start + 7); i++) { |
| 646 | if (i == (start + 2)) |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 647 | continue; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 648 | gpio_cfg_pin(i, func); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 649 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 650 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 651 | } |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 652 | /* SDMMC2 do not use 8bit mode at exynos4 */ |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 653 | if (flags & PINMUX_FLAG_8BIT_MODE) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 654 | for (i = start_ext; i < (start_ext + 4); i++) { |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 655 | gpio_cfg_pin(i, ext_func); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 656 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 657 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 658 | } |
| 659 | } |
| 660 | |
| 661 | return 0; |
| 662 | } |
| 663 | |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 664 | static void exynos4_uart_config(int peripheral) |
| 665 | { |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 666 | int i, start, count; |
| 667 | |
| 668 | switch (peripheral) { |
| 669 | case PERIPH_ID_UART0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 670 | start = EXYNOS4_GPIO_A00; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 671 | count = 4; |
| 672 | break; |
| 673 | case PERIPH_ID_UART1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 674 | start = EXYNOS4_GPIO_A04; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 675 | count = 4; |
| 676 | break; |
| 677 | case PERIPH_ID_UART2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 678 | start = EXYNOS4_GPIO_A10; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 679 | count = 4; |
| 680 | break; |
| 681 | case PERIPH_ID_UART3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 682 | start = EXYNOS4_GPIO_A14; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 683 | count = 2; |
| 684 | break; |
Marek Vasut | e382be9 | 2014-03-10 20:04:31 +0100 | [diff] [blame] | 685 | default: |
| 686 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 687 | return; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 688 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 689 | for (i = start; i < (start + count); i++) { |
| 690 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 691 | gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2)); |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | static void exynos4x12_i2c_config(int peripheral, int flags) |
| 696 | { |
| 697 | switch (peripheral) { |
| 698 | case PERIPH_ID_I2C0: |
| 699 | gpio_cfg_pin(EXYNOS4X12_GPIO_D10, S5P_GPIO_FUNC(0x2)); |
| 700 | gpio_cfg_pin(EXYNOS4X12_GPIO_D11, S5P_GPIO_FUNC(0x2)); |
| 701 | break; |
| 702 | case PERIPH_ID_I2C1: |
| 703 | gpio_cfg_pin(EXYNOS4X12_GPIO_D12, S5P_GPIO_FUNC(0x2)); |
| 704 | gpio_cfg_pin(EXYNOS4X12_GPIO_D13, S5P_GPIO_FUNC(0x2)); |
| 705 | break; |
| 706 | case PERIPH_ID_I2C2: |
| 707 | gpio_cfg_pin(EXYNOS4X12_GPIO_A06, S5P_GPIO_FUNC(0x3)); |
| 708 | gpio_cfg_pin(EXYNOS4X12_GPIO_A07, S5P_GPIO_FUNC(0x3)); |
| 709 | break; |
| 710 | case PERIPH_ID_I2C3: |
| 711 | gpio_cfg_pin(EXYNOS4X12_GPIO_A12, S5P_GPIO_FUNC(0x3)); |
| 712 | gpio_cfg_pin(EXYNOS4X12_GPIO_A13, S5P_GPIO_FUNC(0x3)); |
| 713 | break; |
| 714 | case PERIPH_ID_I2C4: |
| 715 | gpio_cfg_pin(EXYNOS4X12_GPIO_B2, S5P_GPIO_FUNC(0x3)); |
| 716 | gpio_cfg_pin(EXYNOS4X12_GPIO_B3, S5P_GPIO_FUNC(0x3)); |
| 717 | break; |
| 718 | case PERIPH_ID_I2C5: |
| 719 | gpio_cfg_pin(EXYNOS4X12_GPIO_B6, S5P_GPIO_FUNC(0x3)); |
| 720 | gpio_cfg_pin(EXYNOS4X12_GPIO_B7, S5P_GPIO_FUNC(0x3)); |
| 721 | break; |
| 722 | case PERIPH_ID_I2C6: |
| 723 | gpio_cfg_pin(EXYNOS4X12_GPIO_C13, S5P_GPIO_FUNC(0x4)); |
| 724 | gpio_cfg_pin(EXYNOS4X12_GPIO_C14, S5P_GPIO_FUNC(0x4)); |
| 725 | break; |
| 726 | case PERIPH_ID_I2C7: |
| 727 | gpio_cfg_pin(EXYNOS4X12_GPIO_D02, S5P_GPIO_FUNC(0x3)); |
| 728 | gpio_cfg_pin(EXYNOS4X12_GPIO_D03, S5P_GPIO_FUNC(0x3)); |
| 729 | break; |
| 730 | } |
| 731 | } |
| 732 | |
| 733 | static int exynos4x12_mmc_config(int peripheral, int flags) |
| 734 | { |
| 735 | int i, start = 0, start_ext = 0; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 736 | unsigned int func, ext_func; |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 737 | |
| 738 | switch (peripheral) { |
| 739 | case PERIPH_ID_SDMMC0: |
| 740 | start = EXYNOS4X12_GPIO_K00; |
| 741 | start_ext = EXYNOS4X12_GPIO_K13; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 742 | func = S5P_GPIO_FUNC(0x2); |
| 743 | ext_func = S5P_GPIO_FUNC(0x3); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 744 | break; |
| 745 | case PERIPH_ID_SDMMC2: |
| 746 | start = EXYNOS4X12_GPIO_K20; |
| 747 | start_ext = EXYNOS4X12_GPIO_K33; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 748 | func = S5P_GPIO_FUNC(0x2); |
| 749 | ext_func = S5P_GPIO_FUNC(0x3); |
| 750 | break; |
| 751 | case PERIPH_ID_SDMMC4: |
Przemyslaw Marczak | 64c7da5 | 2014-09-01 13:50:43 +0200 | [diff] [blame] | 752 | start = EXYNOS4X12_GPIO_K00; |
| 753 | start_ext = EXYNOS4X12_GPIO_K13; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 754 | func = S5P_GPIO_FUNC(0x3); |
| 755 | ext_func = S5P_GPIO_FUNC(0x4); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 756 | break; |
| 757 | default: |
| 758 | return -1; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 759 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 760 | for (i = start; i < (start + 7); i++) { |
Przemyslaw Marczak | 91fd747 | 2015-10-28 15:41:49 +0100 | [diff] [blame] | 761 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 762 | if (i == (start + 2)) |
| 763 | continue; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 764 | gpio_cfg_pin(i, func); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 765 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
| 766 | } |
| 767 | if (flags & PINMUX_FLAG_8BIT_MODE) { |
| 768 | for (i = start_ext; i < (start_ext + 4); i++) { |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 769 | gpio_cfg_pin(i, ext_func); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 770 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 771 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | return 0; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 776 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 777 | |
| 778 | static void exynos4x12_uart_config(int peripheral) |
| 779 | { |
| 780 | int i, start, count; |
| 781 | |
| 782 | switch (peripheral) { |
| 783 | case PERIPH_ID_UART0: |
| 784 | start = EXYNOS4X12_GPIO_A00; |
| 785 | count = 4; |
| 786 | break; |
| 787 | case PERIPH_ID_UART1: |
| 788 | start = EXYNOS4X12_GPIO_A04; |
| 789 | count = 4; |
| 790 | break; |
| 791 | case PERIPH_ID_UART2: |
| 792 | start = EXYNOS4X12_GPIO_A10; |
| 793 | count = 4; |
| 794 | break; |
| 795 | case PERIPH_ID_UART3: |
| 796 | start = EXYNOS4X12_GPIO_A14; |
| 797 | count = 2; |
| 798 | break; |
| 799 | default: |
| 800 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 801 | return; |
| 802 | } |
| 803 | for (i = start; i < (start + count); i++) { |
| 804 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 805 | gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2)); |
| 806 | } |
| 807 | } |
| 808 | |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 809 | static int exynos4_pinmux_config(int peripheral, int flags) |
| 810 | { |
| 811 | switch (peripheral) { |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 812 | case PERIPH_ID_UART0: |
| 813 | case PERIPH_ID_UART1: |
| 814 | case PERIPH_ID_UART2: |
| 815 | case PERIPH_ID_UART3: |
| 816 | exynos4_uart_config(peripheral); |
| 817 | break; |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 818 | case PERIPH_ID_I2C0: |
| 819 | case PERIPH_ID_I2C1: |
| 820 | case PERIPH_ID_I2C2: |
| 821 | case PERIPH_ID_I2C3: |
| 822 | case PERIPH_ID_I2C4: |
| 823 | case PERIPH_ID_I2C5: |
| 824 | case PERIPH_ID_I2C6: |
| 825 | case PERIPH_ID_I2C7: |
| 826 | exynos4_i2c_config(peripheral, flags); |
| 827 | break; |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 828 | case PERIPH_ID_SDMMC0: |
| 829 | case PERIPH_ID_SDMMC2: |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 830 | case PERIPH_ID_SDMMC4: |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 831 | return exynos4_mmc_config(peripheral, flags); |
| 832 | case PERIPH_ID_SDMMC1: |
| 833 | case PERIPH_ID_SDMMC3: |
Rajeshwari Shinde | 507f892 | 2013-10-08 18:42:22 +0530 | [diff] [blame] | 834 | debug("SDMMC device %d not implemented\n", peripheral); |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 835 | return -1; |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 836 | default: |
| 837 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 838 | return -1; |
| 839 | } |
| 840 | |
| 841 | return 0; |
| 842 | } |
| 843 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 844 | static int exynos4x12_pinmux_config(int peripheral, int flags) |
| 845 | { |
| 846 | switch (peripheral) { |
| 847 | case PERIPH_ID_UART0: |
| 848 | case PERIPH_ID_UART1: |
| 849 | case PERIPH_ID_UART2: |
| 850 | case PERIPH_ID_UART3: |
| 851 | exynos4x12_uart_config(peripheral); |
| 852 | break; |
| 853 | case PERIPH_ID_I2C0: |
| 854 | case PERIPH_ID_I2C1: |
| 855 | case PERIPH_ID_I2C2: |
| 856 | case PERIPH_ID_I2C3: |
| 857 | case PERIPH_ID_I2C4: |
| 858 | case PERIPH_ID_I2C5: |
| 859 | case PERIPH_ID_I2C6: |
| 860 | case PERIPH_ID_I2C7: |
| 861 | exynos4x12_i2c_config(peripheral, flags); |
| 862 | break; |
| 863 | case PERIPH_ID_SDMMC0: |
| 864 | case PERIPH_ID_SDMMC2: |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 865 | case PERIPH_ID_SDMMC4: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 866 | return exynos4x12_mmc_config(peripheral, flags); |
| 867 | case PERIPH_ID_SDMMC1: |
| 868 | case PERIPH_ID_SDMMC3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 869 | debug("SDMMC device %d not implemented\n", peripheral); |
| 870 | return -1; |
| 871 | default: |
| 872 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 873 | return -1; |
| 874 | } |
| 875 | |
| 876 | return 0; |
| 877 | } |
| 878 | |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 879 | int exynos_pinmux_config(int peripheral, int flags) |
| 880 | { |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 881 | if (cpu_is_exynos5()) { |
Simon Glass | 8d451b4 | 2018-12-10 10:37:40 -0700 | [diff] [blame] | 882 | if (proid_is_exynos542x()) |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 883 | return exynos5420_pinmux_config(peripheral, flags); |
| 884 | else if (proid_is_exynos5250()) |
| 885 | return exynos5_pinmux_config(peripheral, flags); |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 886 | } else if (cpu_is_exynos4()) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 887 | if (proid_is_exynos4412()) |
| 888 | return exynos4x12_pinmux_config(peripheral, flags); |
| 889 | else |
| 890 | return exynos4_pinmux_config(peripheral, flags); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 891 | } |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 892 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 893 | debug("pinmux functionality not supported\n"); |
| 894 | |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 895 | return -1; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 896 | } |
Rajeshwari Shinde | 28bae82 | 2012-12-26 20:03:11 +0000 | [diff] [blame] | 897 | |
Masahiro Yamada | 366b24f | 2015-08-12 07:31:55 +0900 | [diff] [blame] | 898 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
Piotr Wilczek | 246ec3a | 2014-03-07 14:59:38 +0100 | [diff] [blame] | 899 | static int exynos4_pinmux_decode_periph_id(const void *blob, int node) |
| 900 | { |
| 901 | int err; |
| 902 | u32 cell[3]; |
| 903 | |
| 904 | err = fdtdec_get_int_array(blob, node, "interrupts", cell, |
| 905 | ARRAY_SIZE(cell)); |
| 906 | if (err) { |
| 907 | debug(" invalid peripheral id\n"); |
| 908 | return PERIPH_ID_NONE; |
| 909 | } |
| 910 | |
| 911 | return cell[1]; |
| 912 | } |
| 913 | |
Rajeshwari Shinde | 28bae82 | 2012-12-26 20:03:11 +0000 | [diff] [blame] | 914 | static int exynos5_pinmux_decode_periph_id(const void *blob, int node) |
| 915 | { |
| 916 | int err; |
| 917 | u32 cell[3]; |
| 918 | |
| 919 | err = fdtdec_get_int_array(blob, node, "interrupts", cell, |
| 920 | ARRAY_SIZE(cell)); |
| 921 | if (err) |
| 922 | return PERIPH_ID_NONE; |
| 923 | |
Minkyu Kang | dcc9917 | 2014-01-29 17:04:17 +0900 | [diff] [blame] | 924 | return cell[1]; |
Rajeshwari Shinde | 28bae82 | 2012-12-26 20:03:11 +0000 | [diff] [blame] | 925 | } |
| 926 | |
| 927 | int pinmux_decode_periph_id(const void *blob, int node) |
| 928 | { |
| 929 | if (cpu_is_exynos5()) |
| 930 | return exynos5_pinmux_decode_periph_id(blob, node); |
Piotr Wilczek | 246ec3a | 2014-03-07 14:59:38 +0100 | [diff] [blame] | 931 | else if (cpu_is_exynos4()) |
| 932 | return exynos4_pinmux_decode_periph_id(blob, node); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 933 | |
| 934 | return PERIPH_ID_NONE; |
Rajeshwari Shinde | 28bae82 | 2012-12-26 20:03:11 +0000 | [diff] [blame] | 935 | } |
| 936 | #endif |