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