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 | |
| 394 | |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 395 | void exynos5_spi_config(int peripheral) |
| 396 | { |
| 397 | int cfg = 0, pin = 0, i; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 398 | |
| 399 | switch (peripheral) { |
| 400 | case PERIPH_ID_SPI0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 401 | cfg = S5P_GPIO_FUNC(0x2); |
| 402 | pin = EXYNOS5_GPIO_A20; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 403 | break; |
| 404 | case PERIPH_ID_SPI1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 405 | cfg = S5P_GPIO_FUNC(0x2); |
| 406 | pin = EXYNOS5_GPIO_A24; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 407 | break; |
| 408 | case PERIPH_ID_SPI2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 409 | cfg = S5P_GPIO_FUNC(0x5); |
| 410 | pin = EXYNOS5_GPIO_B11; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 411 | break; |
| 412 | case PERIPH_ID_SPI3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 413 | cfg = S5P_GPIO_FUNC(0x2); |
| 414 | pin = EXYNOS5_GPIO_F10; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 415 | break; |
| 416 | case PERIPH_ID_SPI4: |
| 417 | for (i = 0; i < 2; i++) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 418 | gpio_cfg_pin(EXYNOS5_GPIO_F02 + i, S5P_GPIO_FUNC(0x4)); |
| 419 | gpio_cfg_pin(EXYNOS5_GPIO_E04 + i, S5P_GPIO_FUNC(0x4)); |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 420 | } |
| 421 | break; |
| 422 | } |
| 423 | if (peripheral != PERIPH_ID_SPI4) { |
| 424 | for (i = pin; i < pin + 4; i++) |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 425 | gpio_cfg_pin(i, cfg); |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 426 | } |
| 427 | } |
| 428 | |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 429 | void exynos5420_spi_config(int peripheral) |
| 430 | { |
| 431 | int cfg, pin, i; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 432 | |
| 433 | switch (peripheral) { |
| 434 | case PERIPH_ID_SPI0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 435 | pin = EXYNOS5420_GPIO_A20; |
| 436 | cfg = S5P_GPIO_FUNC(0x2); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 437 | break; |
| 438 | case PERIPH_ID_SPI1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 439 | pin = EXYNOS5420_GPIO_A24; |
| 440 | cfg = S5P_GPIO_FUNC(0x2); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 441 | break; |
| 442 | case PERIPH_ID_SPI2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 443 | pin = EXYNOS5420_GPIO_B11; |
| 444 | cfg = S5P_GPIO_FUNC(0x5); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 445 | break; |
| 446 | case PERIPH_ID_SPI3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 447 | pin = EXYNOS5420_GPIO_F10; |
| 448 | cfg = S5P_GPIO_FUNC(0x2); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 449 | break; |
| 450 | case PERIPH_ID_SPI4: |
| 451 | cfg = 0; |
| 452 | pin = 0; |
| 453 | break; |
| 454 | default: |
| 455 | cfg = 0; |
| 456 | pin = 0; |
| 457 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 458 | return; |
| 459 | } |
| 460 | |
| 461 | if (peripheral != PERIPH_ID_SPI4) { |
| 462 | for (i = pin; i < pin + 4; i++) |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 463 | gpio_cfg_pin(i, cfg); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 464 | } else { |
| 465 | for (i = 0; i < 2; i++) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 466 | gpio_cfg_pin(EXYNOS5420_GPIO_F02 + i, |
| 467 | S5P_GPIO_FUNC(0x4)); |
| 468 | gpio_cfg_pin(EXYNOS5420_GPIO_E04 + i, |
| 469 | S5P_GPIO_FUNC(0x4)); |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 470 | } |
| 471 | } |
| 472 | } |
| 473 | |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 474 | static int exynos5_pinmux_config(int peripheral, int flags) |
| 475 | { |
| 476 | switch (peripheral) { |
| 477 | case PERIPH_ID_UART0: |
| 478 | case PERIPH_ID_UART1: |
| 479 | case PERIPH_ID_UART2: |
| 480 | case PERIPH_ID_UART3: |
| 481 | exynos5_uart_config(peripheral); |
| 482 | break; |
| 483 | case PERIPH_ID_SDMMC0: |
| 484 | case PERIPH_ID_SDMMC1: |
| 485 | case PERIPH_ID_SDMMC2: |
| 486 | case PERIPH_ID_SDMMC3: |
| 487 | return exynos5_mmc_config(peripheral, flags); |
| 488 | case PERIPH_ID_SROMC: |
| 489 | exynos5_sromc_config(flags); |
| 490 | break; |
Rajeshwari Shinde | 6c313f9 | 2012-07-23 21:23:51 +0000 | [diff] [blame] | 491 | case PERIPH_ID_I2C0: |
| 492 | case PERIPH_ID_I2C1: |
| 493 | case PERIPH_ID_I2C2: |
| 494 | case PERIPH_ID_I2C3: |
| 495 | case PERIPH_ID_I2C4: |
| 496 | case PERIPH_ID_I2C5: |
| 497 | case PERIPH_ID_I2C6: |
| 498 | case PERIPH_ID_I2C7: |
| 499 | exynos5_i2c_config(peripheral, flags); |
| 500 | break; |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 501 | case PERIPH_ID_I2S0: |
Rajeshwari Shinde | 7cf89a2 | 2012-10-25 19:49:27 +0000 | [diff] [blame] | 502 | case PERIPH_ID_I2S1: |
| 503 | exynos5_i2s_config(peripheral); |
| 504 | break; |
Rajeshwari Shinde | 8d909f3 | 2012-10-28 19:32:54 +0000 | [diff] [blame] | 505 | case PERIPH_ID_SPI0: |
| 506 | case PERIPH_ID_SPI1: |
| 507 | case PERIPH_ID_SPI2: |
| 508 | case PERIPH_ID_SPI3: |
| 509 | case PERIPH_ID_SPI4: |
| 510 | exynos5_spi_config(peripheral); |
| 511 | break; |
Simon Glass | 6f6af97 | 2015-07-02 18:16:13 -0600 | [diff] [blame] | 512 | case PERIPH_ID_DPHPD: |
| 513 | /* Set Hotplug detect for DP */ |
| 514 | gpio_cfg_pin(EXYNOS5_GPIO_X07, S5P_GPIO_FUNC(0x3)); |
| 515 | |
| 516 | /* |
| 517 | * Hotplug detect should have an external pullup; disable the |
| 518 | * internal pulldown so they don't fight. |
| 519 | */ |
| 520 | gpio_set_pull(EXYNOS5_GPIO_X07, S5P_GPIO_PULL_NONE); |
| 521 | break; |
Simon Glass | 114f836 | 2016-02-21 21:08:56 -0700 | [diff] [blame] | 522 | case PERIPH_ID_PWM0: |
| 523 | gpio_cfg_pin(EXYNOS5_GPIO_B20, S5P_GPIO_FUNC(2)); |
| 524 | break; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 525 | default: |
| 526 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 527 | return -1; |
| 528 | } |
| 529 | |
| 530 | return 0; |
| 531 | } |
| 532 | |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 533 | static int exynos5420_pinmux_config(int peripheral, int flags) |
| 534 | { |
| 535 | switch (peripheral) { |
| 536 | case PERIPH_ID_UART0: |
| 537 | case PERIPH_ID_UART1: |
| 538 | case PERIPH_ID_UART2: |
| 539 | case PERIPH_ID_UART3: |
| 540 | exynos5420_uart_config(peripheral); |
| 541 | break; |
| 542 | case PERIPH_ID_SDMMC0: |
| 543 | case PERIPH_ID_SDMMC1: |
| 544 | case PERIPH_ID_SDMMC2: |
| 545 | case PERIPH_ID_SDMMC3: |
| 546 | return exynos5420_mmc_config(peripheral, flags); |
| 547 | case PERIPH_ID_SPI0: |
| 548 | case PERIPH_ID_SPI1: |
| 549 | case PERIPH_ID_SPI2: |
| 550 | case PERIPH_ID_SPI3: |
| 551 | case PERIPH_ID_SPI4: |
| 552 | exynos5420_spi_config(peripheral); |
| 553 | break; |
| 554 | case PERIPH_ID_I2C0: |
| 555 | case PERIPH_ID_I2C1: |
| 556 | case PERIPH_ID_I2C2: |
| 557 | case PERIPH_ID_I2C3: |
| 558 | case PERIPH_ID_I2C4: |
| 559 | case PERIPH_ID_I2C5: |
| 560 | case PERIPH_ID_I2C6: |
| 561 | case PERIPH_ID_I2C7: |
| 562 | case PERIPH_ID_I2C8: |
| 563 | case PERIPH_ID_I2C9: |
| 564 | case PERIPH_ID_I2C10: |
| 565 | exynos5420_i2c_config(peripheral); |
| 566 | break; |
Simon Glass | 12d70f4 | 2018-12-10 10:37:41 -0700 | [diff] [blame] | 567 | case PERIPH_ID_I2S0: |
| 568 | exynos5420_i2s_config(peripheral); |
| 569 | break; |
Simon Glass | 114f836 | 2016-02-21 21:08:56 -0700 | [diff] [blame] | 570 | case PERIPH_ID_PWM0: |
| 571 | gpio_cfg_pin(EXYNOS5420_GPIO_B20, S5P_GPIO_FUNC(2)); |
| 572 | break; |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 573 | default: |
| 574 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 575 | return -1; |
| 576 | } |
| 577 | |
| 578 | return 0; |
| 579 | } |
| 580 | |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 581 | static void exynos4_i2c_config(int peripheral, int flags) |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 582 | { |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 583 | switch (peripheral) { |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 584 | case PERIPH_ID_I2C0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 585 | gpio_cfg_pin(EXYNOS4_GPIO_D10, S5P_GPIO_FUNC(0x2)); |
| 586 | gpio_cfg_pin(EXYNOS4_GPIO_D11, S5P_GPIO_FUNC(0x2)); |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 587 | break; |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 588 | case PERIPH_ID_I2C1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 589 | gpio_cfg_pin(EXYNOS4_GPIO_D12, S5P_GPIO_FUNC(0x2)); |
| 590 | gpio_cfg_pin(EXYNOS4_GPIO_D13, S5P_GPIO_FUNC(0x2)); |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 591 | break; |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 592 | case PERIPH_ID_I2C2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 593 | gpio_cfg_pin(EXYNOS4_GPIO_A06, S5P_GPIO_FUNC(0x3)); |
| 594 | gpio_cfg_pin(EXYNOS4_GPIO_A07, S5P_GPIO_FUNC(0x3)); |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 595 | break; |
| 596 | case PERIPH_ID_I2C3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 597 | gpio_cfg_pin(EXYNOS4_GPIO_A12, S5P_GPIO_FUNC(0x3)); |
| 598 | gpio_cfg_pin(EXYNOS4_GPIO_A13, S5P_GPIO_FUNC(0x3)); |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 599 | break; |
| 600 | case PERIPH_ID_I2C4: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 601 | gpio_cfg_pin(EXYNOS4_GPIO_B2, S5P_GPIO_FUNC(0x3)); |
| 602 | gpio_cfg_pin(EXYNOS4_GPIO_B3, S5P_GPIO_FUNC(0x3)); |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 603 | break; |
| 604 | case PERIPH_ID_I2C5: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 605 | gpio_cfg_pin(EXYNOS4_GPIO_B6, S5P_GPIO_FUNC(0x3)); |
| 606 | gpio_cfg_pin(EXYNOS4_GPIO_B7, S5P_GPIO_FUNC(0x3)); |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 607 | break; |
| 608 | case PERIPH_ID_I2C6: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 609 | gpio_cfg_pin(EXYNOS4_GPIO_C13, S5P_GPIO_FUNC(0x4)); |
| 610 | gpio_cfg_pin(EXYNOS4_GPIO_C14, S5P_GPIO_FUNC(0x4)); |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 611 | break; |
| 612 | case PERIPH_ID_I2C7: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 613 | gpio_cfg_pin(EXYNOS4_GPIO_D02, S5P_GPIO_FUNC(0x3)); |
| 614 | gpio_cfg_pin(EXYNOS4_GPIO_D03, S5P_GPIO_FUNC(0x3)); |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 615 | break; |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 616 | } |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 617 | } |
| 618 | |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 619 | static int exynos4_mmc_config(int peripheral, int flags) |
| 620 | { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 621 | int i, start = 0, start_ext = 0; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 622 | unsigned int func, ext_func; |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 623 | |
| 624 | switch (peripheral) { |
| 625 | case PERIPH_ID_SDMMC0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 626 | start = EXYNOS4_GPIO_K00; |
| 627 | start_ext = EXYNOS4_GPIO_K13; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 628 | func = S5P_GPIO_FUNC(0x2); |
| 629 | ext_func = S5P_GPIO_FUNC(0x3); |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 630 | break; |
| 631 | case PERIPH_ID_SDMMC2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 632 | start = EXYNOS4_GPIO_K20; |
| 633 | start_ext = EXYNOS4_GPIO_K33; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 634 | func = S5P_GPIO_FUNC(0x2); |
| 635 | ext_func = S5P_GPIO_FUNC(0x3); |
| 636 | break; |
| 637 | case PERIPH_ID_SDMMC4: |
| 638 | start = EXYNOS4_GPIO_K00; |
| 639 | start_ext = EXYNOS4_GPIO_K13; |
| 640 | func = S5P_GPIO_FUNC(0x3); |
| 641 | ext_func = S5P_GPIO_FUNC(0x4); |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 642 | break; |
| 643 | default: |
| 644 | return -1; |
| 645 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 646 | for (i = start; i < (start + 7); i++) { |
| 647 | if (i == (start + 2)) |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 648 | continue; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 649 | gpio_cfg_pin(i, func); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 650 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 651 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 652 | } |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 653 | /* SDMMC2 do not use 8bit mode at exynos4 */ |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 654 | if (flags & PINMUX_FLAG_8BIT_MODE) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 655 | for (i = start_ext; i < (start_ext + 4); i++) { |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 656 | gpio_cfg_pin(i, ext_func); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 657 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 658 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 659 | } |
| 660 | } |
| 661 | |
| 662 | return 0; |
| 663 | } |
| 664 | |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 665 | static void exynos4_uart_config(int peripheral) |
| 666 | { |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 667 | int i, start, count; |
| 668 | |
| 669 | switch (peripheral) { |
| 670 | case PERIPH_ID_UART0: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 671 | start = EXYNOS4_GPIO_A00; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 672 | count = 4; |
| 673 | break; |
| 674 | case PERIPH_ID_UART1: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 675 | start = EXYNOS4_GPIO_A04; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 676 | count = 4; |
| 677 | break; |
| 678 | case PERIPH_ID_UART2: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 679 | start = EXYNOS4_GPIO_A10; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 680 | count = 4; |
| 681 | break; |
| 682 | case PERIPH_ID_UART3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 683 | start = EXYNOS4_GPIO_A14; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 684 | count = 2; |
| 685 | break; |
Marek Vasut | e382be9 | 2014-03-10 20:04:31 +0100 | [diff] [blame] | 686 | default: |
| 687 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 688 | return; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 689 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 690 | for (i = start; i < (start + count); i++) { |
| 691 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 692 | gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2)); |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | static void exynos4x12_i2c_config(int peripheral, int flags) |
| 697 | { |
| 698 | switch (peripheral) { |
| 699 | case PERIPH_ID_I2C0: |
| 700 | gpio_cfg_pin(EXYNOS4X12_GPIO_D10, S5P_GPIO_FUNC(0x2)); |
| 701 | gpio_cfg_pin(EXYNOS4X12_GPIO_D11, S5P_GPIO_FUNC(0x2)); |
| 702 | break; |
| 703 | case PERIPH_ID_I2C1: |
| 704 | gpio_cfg_pin(EXYNOS4X12_GPIO_D12, S5P_GPIO_FUNC(0x2)); |
| 705 | gpio_cfg_pin(EXYNOS4X12_GPIO_D13, S5P_GPIO_FUNC(0x2)); |
| 706 | break; |
| 707 | case PERIPH_ID_I2C2: |
| 708 | gpio_cfg_pin(EXYNOS4X12_GPIO_A06, S5P_GPIO_FUNC(0x3)); |
| 709 | gpio_cfg_pin(EXYNOS4X12_GPIO_A07, S5P_GPIO_FUNC(0x3)); |
| 710 | break; |
| 711 | case PERIPH_ID_I2C3: |
| 712 | gpio_cfg_pin(EXYNOS4X12_GPIO_A12, S5P_GPIO_FUNC(0x3)); |
| 713 | gpio_cfg_pin(EXYNOS4X12_GPIO_A13, S5P_GPIO_FUNC(0x3)); |
| 714 | break; |
| 715 | case PERIPH_ID_I2C4: |
| 716 | gpio_cfg_pin(EXYNOS4X12_GPIO_B2, S5P_GPIO_FUNC(0x3)); |
| 717 | gpio_cfg_pin(EXYNOS4X12_GPIO_B3, S5P_GPIO_FUNC(0x3)); |
| 718 | break; |
| 719 | case PERIPH_ID_I2C5: |
| 720 | gpio_cfg_pin(EXYNOS4X12_GPIO_B6, S5P_GPIO_FUNC(0x3)); |
| 721 | gpio_cfg_pin(EXYNOS4X12_GPIO_B7, S5P_GPIO_FUNC(0x3)); |
| 722 | break; |
| 723 | case PERIPH_ID_I2C6: |
| 724 | gpio_cfg_pin(EXYNOS4X12_GPIO_C13, S5P_GPIO_FUNC(0x4)); |
| 725 | gpio_cfg_pin(EXYNOS4X12_GPIO_C14, S5P_GPIO_FUNC(0x4)); |
| 726 | break; |
| 727 | case PERIPH_ID_I2C7: |
| 728 | gpio_cfg_pin(EXYNOS4X12_GPIO_D02, S5P_GPIO_FUNC(0x3)); |
| 729 | gpio_cfg_pin(EXYNOS4X12_GPIO_D03, S5P_GPIO_FUNC(0x3)); |
| 730 | break; |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | static int exynos4x12_mmc_config(int peripheral, int flags) |
| 735 | { |
| 736 | int i, start = 0, start_ext = 0; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 737 | unsigned int func, ext_func; |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 738 | |
| 739 | switch (peripheral) { |
| 740 | case PERIPH_ID_SDMMC0: |
| 741 | start = EXYNOS4X12_GPIO_K00; |
| 742 | start_ext = EXYNOS4X12_GPIO_K13; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 743 | func = S5P_GPIO_FUNC(0x2); |
| 744 | ext_func = S5P_GPIO_FUNC(0x3); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 745 | break; |
| 746 | case PERIPH_ID_SDMMC2: |
| 747 | start = EXYNOS4X12_GPIO_K20; |
| 748 | start_ext = EXYNOS4X12_GPIO_K33; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 749 | func = S5P_GPIO_FUNC(0x2); |
| 750 | ext_func = S5P_GPIO_FUNC(0x3); |
| 751 | break; |
| 752 | case PERIPH_ID_SDMMC4: |
Przemyslaw Marczak | 64c7da5 | 2014-09-01 13:50:43 +0200 | [diff] [blame] | 753 | start = EXYNOS4X12_GPIO_K00; |
| 754 | start_ext = EXYNOS4X12_GPIO_K13; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 755 | func = S5P_GPIO_FUNC(0x3); |
| 756 | ext_func = S5P_GPIO_FUNC(0x4); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 757 | break; |
| 758 | default: |
| 759 | return -1; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 760 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 761 | for (i = start; i < (start + 7); i++) { |
Przemyslaw Marczak | 91fd747 | 2015-10-28 15:41:49 +0100 | [diff] [blame] | 762 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 763 | if (i == (start + 2)) |
| 764 | continue; |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 765 | gpio_cfg_pin(i, func); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 766 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
| 767 | } |
| 768 | if (flags & PINMUX_FLAG_8BIT_MODE) { |
| 769 | for (i = start_ext; i < (start_ext + 4); i++) { |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 770 | gpio_cfg_pin(i, ext_func); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 771 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 772 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
| 773 | } |
| 774 | } |
| 775 | |
| 776 | return 0; |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 777 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 778 | |
| 779 | static void exynos4x12_uart_config(int peripheral) |
| 780 | { |
| 781 | int i, start, count; |
| 782 | |
| 783 | switch (peripheral) { |
| 784 | case PERIPH_ID_UART0: |
| 785 | start = EXYNOS4X12_GPIO_A00; |
| 786 | count = 4; |
| 787 | break; |
| 788 | case PERIPH_ID_UART1: |
| 789 | start = EXYNOS4X12_GPIO_A04; |
| 790 | count = 4; |
| 791 | break; |
| 792 | case PERIPH_ID_UART2: |
| 793 | start = EXYNOS4X12_GPIO_A10; |
| 794 | count = 4; |
| 795 | break; |
| 796 | case PERIPH_ID_UART3: |
| 797 | start = EXYNOS4X12_GPIO_A14; |
| 798 | count = 2; |
| 799 | break; |
| 800 | default: |
| 801 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 802 | return; |
| 803 | } |
| 804 | for (i = start; i < (start + count); i++) { |
| 805 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
| 806 | gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2)); |
| 807 | } |
| 808 | } |
| 809 | |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 810 | static int exynos4_pinmux_config(int peripheral, int flags) |
| 811 | { |
| 812 | switch (peripheral) { |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 813 | case PERIPH_ID_UART0: |
| 814 | case PERIPH_ID_UART1: |
| 815 | case PERIPH_ID_UART2: |
| 816 | case PERIPH_ID_UART3: |
| 817 | exynos4_uart_config(peripheral); |
| 818 | break; |
Piotr Wilczek | edad217 | 2012-11-20 02:19:04 +0000 | [diff] [blame] | 819 | case PERIPH_ID_I2C0: |
| 820 | case PERIPH_ID_I2C1: |
| 821 | case PERIPH_ID_I2C2: |
| 822 | case PERIPH_ID_I2C3: |
| 823 | case PERIPH_ID_I2C4: |
| 824 | case PERIPH_ID_I2C5: |
| 825 | case PERIPH_ID_I2C6: |
| 826 | case PERIPH_ID_I2C7: |
| 827 | exynos4_i2c_config(peripheral, flags); |
| 828 | break; |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 829 | case PERIPH_ID_SDMMC0: |
| 830 | case PERIPH_ID_SDMMC2: |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 831 | case PERIPH_ID_SDMMC4: |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 832 | return exynos4_mmc_config(peripheral, flags); |
| 833 | case PERIPH_ID_SDMMC1: |
| 834 | case PERIPH_ID_SDMMC3: |
Rajeshwari Shinde | 507f892 | 2013-10-08 18:42:22 +0530 | [diff] [blame] | 835 | debug("SDMMC device %d not implemented\n", peripheral); |
Piotr Wilczek | a90efe9 | 2013-01-02 21:31:00 +0000 | [diff] [blame] | 836 | return -1; |
Piotr Wilczek | 7318b29 | 2012-09-20 00:19:57 +0000 | [diff] [blame] | 837 | default: |
| 838 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 839 | return -1; |
| 840 | } |
| 841 | |
| 842 | return 0; |
| 843 | } |
| 844 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 845 | static int exynos4x12_pinmux_config(int peripheral, int flags) |
| 846 | { |
| 847 | switch (peripheral) { |
| 848 | case PERIPH_ID_UART0: |
| 849 | case PERIPH_ID_UART1: |
| 850 | case PERIPH_ID_UART2: |
| 851 | case PERIPH_ID_UART3: |
| 852 | exynos4x12_uart_config(peripheral); |
| 853 | break; |
| 854 | case PERIPH_ID_I2C0: |
| 855 | case PERIPH_ID_I2C1: |
| 856 | case PERIPH_ID_I2C2: |
| 857 | case PERIPH_ID_I2C3: |
| 858 | case PERIPH_ID_I2C4: |
| 859 | case PERIPH_ID_I2C5: |
| 860 | case PERIPH_ID_I2C6: |
| 861 | case PERIPH_ID_I2C7: |
| 862 | exynos4x12_i2c_config(peripheral, flags); |
| 863 | break; |
| 864 | case PERIPH_ID_SDMMC0: |
| 865 | case PERIPH_ID_SDMMC2: |
Beomho Seo | 06d1b16 | 2014-05-16 13:59:46 +0900 | [diff] [blame] | 866 | case PERIPH_ID_SDMMC4: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 867 | return exynos4x12_mmc_config(peripheral, flags); |
| 868 | case PERIPH_ID_SDMMC1: |
| 869 | case PERIPH_ID_SDMMC3: |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 870 | debug("SDMMC device %d not implemented\n", peripheral); |
| 871 | return -1; |
| 872 | default: |
| 873 | debug("%s: invalid peripheral %d", __func__, peripheral); |
| 874 | return -1; |
| 875 | } |
| 876 | |
| 877 | return 0; |
| 878 | } |
| 879 | |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 880 | int exynos_pinmux_config(int peripheral, int flags) |
| 881 | { |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 882 | if (cpu_is_exynos5()) { |
Simon Glass | 8d451b4 | 2018-12-10 10:37:40 -0700 | [diff] [blame] | 883 | if (proid_is_exynos542x()) |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 884 | return exynos5420_pinmux_config(peripheral, flags); |
| 885 | else if (proid_is_exynos5250()) |
| 886 | return exynos5_pinmux_config(peripheral, flags); |
Dani Krishna Mohan | 65c7ee6 | 2013-09-11 16:38:48 +0530 | [diff] [blame] | 887 | } else if (cpu_is_exynos4()) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 888 | if (proid_is_exynos4412()) |
| 889 | return exynos4x12_pinmux_config(peripheral, flags); |
| 890 | else |
| 891 | return exynos4_pinmux_config(peripheral, flags); |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 892 | } |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 893 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 894 | debug("pinmux functionality not supported\n"); |
| 895 | |
Rajeshwari Birje | f0ce84f | 2013-12-26 09:44:23 +0530 | [diff] [blame] | 896 | return -1; |
Rajeshwari Shinde | 57da3e3 | 2012-06-06 19:54:29 +0000 | [diff] [blame] | 897 | } |
Rajeshwari Shinde | 28bae82 | 2012-12-26 20:03:11 +0000 | [diff] [blame] | 898 | |
Masahiro Yamada | 366b24f | 2015-08-12 07:31:55 +0900 | [diff] [blame] | 899 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
Piotr Wilczek | 246ec3a | 2014-03-07 14:59:38 +0100 | [diff] [blame] | 900 | static int exynos4_pinmux_decode_periph_id(const void *blob, int node) |
| 901 | { |
| 902 | int err; |
| 903 | u32 cell[3]; |
| 904 | |
| 905 | err = fdtdec_get_int_array(blob, node, "interrupts", cell, |
| 906 | ARRAY_SIZE(cell)); |
| 907 | if (err) { |
| 908 | debug(" invalid peripheral id\n"); |
| 909 | return PERIPH_ID_NONE; |
| 910 | } |
| 911 | |
| 912 | return cell[1]; |
| 913 | } |
| 914 | |
Rajeshwari Shinde | 28bae82 | 2012-12-26 20:03:11 +0000 | [diff] [blame] | 915 | static int exynos5_pinmux_decode_periph_id(const void *blob, int node) |
| 916 | { |
| 917 | int err; |
| 918 | u32 cell[3]; |
| 919 | |
| 920 | err = fdtdec_get_int_array(blob, node, "interrupts", cell, |
| 921 | ARRAY_SIZE(cell)); |
| 922 | if (err) |
| 923 | return PERIPH_ID_NONE; |
| 924 | |
Minkyu Kang | dcc9917 | 2014-01-29 17:04:17 +0900 | [diff] [blame] | 925 | return cell[1]; |
Rajeshwari Shinde | 28bae82 | 2012-12-26 20:03:11 +0000 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | int pinmux_decode_periph_id(const void *blob, int node) |
| 929 | { |
| 930 | if (cpu_is_exynos5()) |
| 931 | return exynos5_pinmux_decode_periph_id(blob, node); |
Piotr Wilczek | 246ec3a | 2014-03-07 14:59:38 +0100 | [diff] [blame] | 932 | else if (cpu_is_exynos4()) |
| 933 | return exynos4_pinmux_decode_periph_id(blob, node); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 934 | |
| 935 | return PERIPH_ID_NONE; |
Rajeshwari Shinde | 28bae82 | 2012-12-26 20:03:11 +0000 | [diff] [blame] | 936 | } |
| 937 | #endif |