blob: ee7c2e5a4be5b755cc38d434a12204868630a263 [file] [log] [blame]
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +00001/*
2 * Copyright (c) 2012 Samsung Electronics.
3 * Abhilash Kesavan <a.kesavan@samsung.com>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +00006 */
7
8#include <common.h>
Rajeshwari Shinde28bae822012-12-26 20:03:11 +00009#include <fdtdec.h>
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000010#include <asm/arch/gpio.h>
11#include <asm/arch/pinmux.h>
12#include <asm/arch/sromc.h>
13
14static void exynos5_uart_config(int peripheral)
15{
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000016 int i, start, count;
17
18 switch (peripheral) {
19 case PERIPH_ID_UART0:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053020 start = EXYNOS5_GPIO_A00;
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000021 count = 4;
22 break;
23 case PERIPH_ID_UART1:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053024 start = EXYNOS5_GPIO_D00;
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000025 count = 4;
26 break;
27 case PERIPH_ID_UART2:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053028 start = EXYNOS5_GPIO_A10;
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000029 count = 4;
30 break;
31 case PERIPH_ID_UART3:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053032 start = EXYNOS5_GPIO_A14;
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000033 count = 2;
34 break;
Marek Vasute382be92014-03-10 20:04:31 +010035 default:
36 debug("%s: invalid peripheral %d", __func__, peripheral);
37 return;
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000038 }
39 for (i = start; i < start + count; i++) {
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053040 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
41 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000042 }
43}
44
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +053045static void exynos5420_uart_config(int peripheral)
46{
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +053047 int i, start, count;
48
49 switch (peripheral) {
50 case PERIPH_ID_UART0:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053051 start = EXYNOS5420_GPIO_A00;
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +053052 count = 4;
53 break;
54 case PERIPH_ID_UART1:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053055 start = EXYNOS5420_GPIO_A04;
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +053056 count = 4;
57 break;
58 case PERIPH_ID_UART2:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053059 start = EXYNOS5420_GPIO_A10;
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +053060 count = 4;
61 break;
62 case PERIPH_ID_UART3:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053063 start = EXYNOS5420_GPIO_A14;
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +053064 count = 2;
65 break;
Marek Vasute382be92014-03-10 20:04:31 +010066 default:
67 debug("%s: invalid peripheral %d", __func__, peripheral);
68 return;
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +053069 }
70
71 for (i = start; i < start + count; i++) {
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053072 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
73 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +053074 }
75}
76
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000077static int exynos5_mmc_config(int peripheral, int flags)
78{
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053079 int i, start, start_ext, gpio_func = 0;
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000080
81 switch (peripheral) {
82 case PERIPH_ID_SDMMC0:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053083 start = EXYNOS5_GPIO_C00;
84 start_ext = EXYNOS5_GPIO_C10;
85 gpio_func = S5P_GPIO_FUNC(0x2);
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000086 break;
87 case PERIPH_ID_SDMMC1:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053088 start = EXYNOS5_GPIO_C20;
89 start_ext = 0;
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000090 break;
91 case PERIPH_ID_SDMMC2:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053092 start = EXYNOS5_GPIO_C30;
93 start_ext = EXYNOS5_GPIO_C43;
94 gpio_func = S5P_GPIO_FUNC(0x3);
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000095 break;
96 case PERIPH_ID_SDMMC3:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053097 start = EXYNOS5_GPIO_C40;
98 start_ext = 0;
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +000099 break;
Marek Vasute382be92014-03-10 20:04:31 +0100100 default:
101 debug("%s: invalid peripheral %d", __func__, peripheral);
102 return -1;
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000103 }
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530104 if ((flags & PINMUX_FLAG_8BIT_MODE) && !start_ext) {
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000105 debug("SDMMC device %d does not support 8bit mode",
106 peripheral);
107 return -1;
108 }
109 if (flags & PINMUX_FLAG_8BIT_MODE) {
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530110 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 Shinde57da3e32012-06-06 19:54:29 +0000114 }
115 }
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530116 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 Birjef0ce84f2013-12-26 09:44:23 +0530120 }
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530121 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 Birjef0ce84f2013-12-26 09:44:23 +0530125 }
126
127 return 0;
128}
129
130static int exynos5420_mmc_config(int peripheral, int flags)
131{
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530132 int i, start = 0, start_ext = 0;
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530133
134 switch (peripheral) {
135 case PERIPH_ID_SDMMC0:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530136 start = EXYNOS5420_GPIO_C00;
137 start_ext = EXYNOS5420_GPIO_C30;
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530138 break;
139 case PERIPH_ID_SDMMC1:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530140 start = EXYNOS5420_GPIO_C10;
141 start_ext = EXYNOS5420_GPIO_D14;
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530142 break;
143 case PERIPH_ID_SDMMC2:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530144 start = EXYNOS5420_GPIO_C20;
145 start_ext = 0;
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530146 break;
147 default:
148 start = 0;
149 debug("%s: invalid peripheral %d", __func__, peripheral);
150 return -1;
151 }
152
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530153 if ((flags & PINMUX_FLAG_8BIT_MODE) && !start_ext) {
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530154 debug("SDMMC device %d does not support 8bit mode",
155 peripheral);
156 return -1;
157 }
158
159 if (flags & PINMUX_FLAG_8BIT_MODE) {
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530160 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 Birjef0ce84f2013-12-26 09:44:23 +0530164 }
165 }
166
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530167 for (i = start; i < (start + 3); i++) {
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530168 /*
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 Saraswat1376cdd2014-05-13 10:30:14 +0530174 if ((peripheral == PERIPH_ID_SDMMC0) && (i == (start + 2))) {
175 gpio_set_value(i, 1);
176 gpio_cfg_pin(i, S5P_GPIO_OUTPUT);
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530177 } else {
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530178 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530179 }
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530180 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
181 gpio_set_drv(i, S5P_GPIO_DRV_4X);
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000182 }
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530183
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530184 for (i = (start + 3); i <= (start + 6); i++) {
185 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
186 gpio_set_pull(i, S5P_GPIO_PULL_UP);
187 gpio_set_drv(i, S5P_GPIO_DRV_4X);
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000188 }
Rajeshwari Shinde8d909f32012-10-28 19:32:54 +0000189
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000190 return 0;
191}
192
193static void exynos5_sromc_config(int flags)
194{
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000195 int i;
196
197 /*
198 * SROM:CS1 and EBI
199 *
200 * GPY0[0] SROM_CSn[0]
201 * GPY0[1] SROM_CSn[1](2)
202 * GPY0[2] SROM_CSn[2]
203 * GPY0[3] SROM_CSn[3]
204 * GPY0[4] EBI_OEn(2)
205 * GPY0[5] EBI_EEn(2)
206 *
207 * GPY1[0] EBI_BEn[0](2)
208 * GPY1[1] EBI_BEn[1](2)
209 * GPY1[2] SROM_WAIT(2)
210 * GPY1[3] EBI_DATA_RDn(2)
211 */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530212 gpio_cfg_pin(EXYNOS5_GPIO_Y00 + (flags & PINMUX_FLAG_BANK),
213 S5P_GPIO_FUNC(2));
214 gpio_cfg_pin(EXYNOS5_GPIO_Y04, S5P_GPIO_FUNC(2));
215 gpio_cfg_pin(EXYNOS5_GPIO_Y05, S5P_GPIO_FUNC(2));
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000216
217 for (i = 0; i < 4; i++)
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530218 gpio_cfg_pin(EXYNOS5_GPIO_Y10 + i, S5P_GPIO_FUNC(2));
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000219
220 /*
221 * EBI: 8 Addrss Lines
222 *
223 * GPY3[0] EBI_ADDR[0](2)
224 * GPY3[1] EBI_ADDR[1](2)
225 * GPY3[2] EBI_ADDR[2](2)
226 * GPY3[3] EBI_ADDR[3](2)
227 * GPY3[4] EBI_ADDR[4](2)
228 * GPY3[5] EBI_ADDR[5](2)
229 * GPY3[6] EBI_ADDR[6](2)
230 * GPY3[7] EBI_ADDR[7](2)
231 *
232 * EBI: 16 Data Lines
233 *
234 * GPY5[0] EBI_DATA[0](2)
235 * GPY5[1] EBI_DATA[1](2)
236 * GPY5[2] EBI_DATA[2](2)
237 * GPY5[3] EBI_DATA[3](2)
238 * GPY5[4] EBI_DATA[4](2)
239 * GPY5[5] EBI_DATA[5](2)
240 * GPY5[6] EBI_DATA[6](2)
241 * GPY5[7] EBI_DATA[7](2)
242 *
243 * GPY6[0] EBI_DATA[8](2)
244 * GPY6[1] EBI_DATA[9](2)
245 * GPY6[2] EBI_DATA[10](2)
246 * GPY6[3] EBI_DATA[11](2)
247 * GPY6[4] EBI_DATA[12](2)
248 * GPY6[5] EBI_DATA[13](2)
249 * GPY6[6] EBI_DATA[14](2)
250 * GPY6[7] EBI_DATA[15](2)
251 */
252 for (i = 0; i < 8; i++) {
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530253 gpio_cfg_pin(EXYNOS5_GPIO_Y30 + i, S5P_GPIO_FUNC(2));
254 gpio_set_pull(EXYNOS5_GPIO_Y30 + i, S5P_GPIO_PULL_UP);
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000255
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530256 gpio_cfg_pin(EXYNOS5_GPIO_Y50 + i, S5P_GPIO_FUNC(2));
257 gpio_set_pull(EXYNOS5_GPIO_Y50 + i, S5P_GPIO_PULL_UP);
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000258
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530259 gpio_cfg_pin(EXYNOS5_GPIO_Y60 + i, S5P_GPIO_FUNC(2));
260 gpio_set_pull(EXYNOS5_GPIO_Y60 + i, S5P_GPIO_PULL_UP);
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000261 }
262}
263
Rajeshwari Shinde6c313f92012-07-23 21:23:51 +0000264static void exynos5_i2c_config(int peripheral, int flags)
265{
Rajeshwari Shinde6c313f92012-07-23 21:23:51 +0000266 switch (peripheral) {
267 case PERIPH_ID_I2C0:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530268 gpio_cfg_pin(EXYNOS5_GPIO_B30, S5P_GPIO_FUNC(0x2));
269 gpio_cfg_pin(EXYNOS5_GPIO_B31, S5P_GPIO_FUNC(0x2));
Rajeshwari Shinde6c313f92012-07-23 21:23:51 +0000270 break;
271 case PERIPH_ID_I2C1:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530272 gpio_cfg_pin(EXYNOS5_GPIO_B32, S5P_GPIO_FUNC(0x2));
273 gpio_cfg_pin(EXYNOS5_GPIO_B33, S5P_GPIO_FUNC(0x2));
Rajeshwari Shinde6c313f92012-07-23 21:23:51 +0000274 break;
275 case PERIPH_ID_I2C2:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530276 gpio_cfg_pin(EXYNOS5_GPIO_A06, S5P_GPIO_FUNC(0x3));
277 gpio_cfg_pin(EXYNOS5_GPIO_A07, S5P_GPIO_FUNC(0x3));
Rajeshwari Shinde6c313f92012-07-23 21:23:51 +0000278 break;
279 case PERIPH_ID_I2C3:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530280 gpio_cfg_pin(EXYNOS5_GPIO_A12, S5P_GPIO_FUNC(0x3));
281 gpio_cfg_pin(EXYNOS5_GPIO_A13, S5P_GPIO_FUNC(0x3));
Rajeshwari Shinde6c313f92012-07-23 21:23:51 +0000282 break;
283 case PERIPH_ID_I2C4:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530284 gpio_cfg_pin(EXYNOS5_GPIO_A20, S5P_GPIO_FUNC(0x3));
285 gpio_cfg_pin(EXYNOS5_GPIO_A21, S5P_GPIO_FUNC(0x3));
Rajeshwari Shinde6c313f92012-07-23 21:23:51 +0000286 break;
287 case PERIPH_ID_I2C5:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530288 gpio_cfg_pin(EXYNOS5_GPIO_A22, S5P_GPIO_FUNC(0x3));
289 gpio_cfg_pin(EXYNOS5_GPIO_A23, S5P_GPIO_FUNC(0x3));
Rajeshwari Shinde6c313f92012-07-23 21:23:51 +0000290 break;
291 case PERIPH_ID_I2C6:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530292 gpio_cfg_pin(EXYNOS5_GPIO_B13, S5P_GPIO_FUNC(0x4));
293 gpio_cfg_pin(EXYNOS5_GPIO_B14, S5P_GPIO_FUNC(0x4));
Rajeshwari Shinde6c313f92012-07-23 21:23:51 +0000294 break;
295 case PERIPH_ID_I2C7:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530296 gpio_cfg_pin(EXYNOS5_GPIO_B22, S5P_GPIO_FUNC(0x3));
297 gpio_cfg_pin(EXYNOS5_GPIO_B23, S5P_GPIO_FUNC(0x3));
Rajeshwari Shinde6c313f92012-07-23 21:23:51 +0000298 break;
299 }
300}
301
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530302static void exynos5420_i2c_config(int peripheral)
303{
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530304 switch (peripheral) {
305 case PERIPH_ID_I2C0:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530306 gpio_cfg_pin(EXYNOS5420_GPIO_B30, S5P_GPIO_FUNC(0x2));
307 gpio_cfg_pin(EXYNOS5420_GPIO_B31, S5P_GPIO_FUNC(0x2));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530308 break;
309 case PERIPH_ID_I2C1:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530310 gpio_cfg_pin(EXYNOS5420_GPIO_B32, S5P_GPIO_FUNC(0x2));
311 gpio_cfg_pin(EXYNOS5420_GPIO_B33, S5P_GPIO_FUNC(0x2));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530312 break;
313 case PERIPH_ID_I2C2:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530314 gpio_cfg_pin(EXYNOS5420_GPIO_A06, S5P_GPIO_FUNC(0x3));
315 gpio_cfg_pin(EXYNOS5420_GPIO_A07, S5P_GPIO_FUNC(0x3));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530316 break;
317 case PERIPH_ID_I2C3:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530318 gpio_cfg_pin(EXYNOS5420_GPIO_A12, S5P_GPIO_FUNC(0x3));
319 gpio_cfg_pin(EXYNOS5420_GPIO_A13, S5P_GPIO_FUNC(0x3));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530320 break;
321 case PERIPH_ID_I2C4:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530322 gpio_cfg_pin(EXYNOS5420_GPIO_A20, S5P_GPIO_FUNC(0x3));
323 gpio_cfg_pin(EXYNOS5420_GPIO_A21, S5P_GPIO_FUNC(0x3));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530324 break;
325 case PERIPH_ID_I2C5:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530326 gpio_cfg_pin(EXYNOS5420_GPIO_A22, S5P_GPIO_FUNC(0x3));
327 gpio_cfg_pin(EXYNOS5420_GPIO_A23, S5P_GPIO_FUNC(0x3));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530328 break;
329 case PERIPH_ID_I2C6:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530330 gpio_cfg_pin(EXYNOS5420_GPIO_B13, S5P_GPIO_FUNC(0x4));
331 gpio_cfg_pin(EXYNOS5420_GPIO_B14, S5P_GPIO_FUNC(0x4));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530332 break;
333 case PERIPH_ID_I2C7:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530334 gpio_cfg_pin(EXYNOS5420_GPIO_B22, S5P_GPIO_FUNC(0x3));
335 gpio_cfg_pin(EXYNOS5420_GPIO_B23, S5P_GPIO_FUNC(0x3));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530336 break;
337 case PERIPH_ID_I2C8:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530338 gpio_cfg_pin(EXYNOS5420_GPIO_B34, S5P_GPIO_FUNC(0x2));
339 gpio_cfg_pin(EXYNOS5420_GPIO_B35, S5P_GPIO_FUNC(0x2));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530340 break;
341 case PERIPH_ID_I2C9:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530342 gpio_cfg_pin(EXYNOS5420_GPIO_B36, S5P_GPIO_FUNC(0x2));
343 gpio_cfg_pin(EXYNOS5420_GPIO_B37, S5P_GPIO_FUNC(0x2));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530344 break;
345 case PERIPH_ID_I2C10:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530346 gpio_cfg_pin(EXYNOS5420_GPIO_B40, S5P_GPIO_FUNC(0x2));
347 gpio_cfg_pin(EXYNOS5420_GPIO_B41, S5P_GPIO_FUNC(0x2));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530348 break;
349 }
350}
351
Rajeshwari Shinde7cf89a22012-10-25 19:49:27 +0000352static void exynos5_i2s_config(int peripheral)
353{
354 int i;
Rajeshwari Shinde7cf89a22012-10-25 19:49:27 +0000355
Dani Krishna Mohan65c7ee62013-09-11 16:38:48 +0530356 switch (peripheral) {
357 case PERIPH_ID_I2S0:
358 for (i = 0; i < 5; i++)
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530359 gpio_cfg_pin(EXYNOS5_GPIO_Z0 + i, S5P_GPIO_FUNC(0x02));
Dani Krishna Mohan65c7ee62013-09-11 16:38:48 +0530360 break;
361 case PERIPH_ID_I2S1:
362 for (i = 0; i < 5; i++)
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530363 gpio_cfg_pin(EXYNOS5_GPIO_B00 + i, S5P_GPIO_FUNC(0x02));
Dani Krishna Mohan65c7ee62013-09-11 16:38:48 +0530364 break;
365 }
Rajeshwari Shinde7cf89a22012-10-25 19:49:27 +0000366}
367
Rajeshwari Shinde8d909f32012-10-28 19:32:54 +0000368void exynos5_spi_config(int peripheral)
369{
370 int cfg = 0, pin = 0, i;
Rajeshwari Shinde8d909f32012-10-28 19:32:54 +0000371
372 switch (peripheral) {
373 case PERIPH_ID_SPI0:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530374 cfg = S5P_GPIO_FUNC(0x2);
375 pin = EXYNOS5_GPIO_A20;
Rajeshwari Shinde8d909f32012-10-28 19:32:54 +0000376 break;
377 case PERIPH_ID_SPI1:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530378 cfg = S5P_GPIO_FUNC(0x2);
379 pin = EXYNOS5_GPIO_A24;
Rajeshwari Shinde8d909f32012-10-28 19:32:54 +0000380 break;
381 case PERIPH_ID_SPI2:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530382 cfg = S5P_GPIO_FUNC(0x5);
383 pin = EXYNOS5_GPIO_B11;
Rajeshwari Shinde8d909f32012-10-28 19:32:54 +0000384 break;
385 case PERIPH_ID_SPI3:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530386 cfg = S5P_GPIO_FUNC(0x2);
387 pin = EXYNOS5_GPIO_F10;
Rajeshwari Shinde8d909f32012-10-28 19:32:54 +0000388 break;
389 case PERIPH_ID_SPI4:
390 for (i = 0; i < 2; i++) {
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530391 gpio_cfg_pin(EXYNOS5_GPIO_F02 + i, S5P_GPIO_FUNC(0x4));
392 gpio_cfg_pin(EXYNOS5_GPIO_E04 + i, S5P_GPIO_FUNC(0x4));
Rajeshwari Shinde8d909f32012-10-28 19:32:54 +0000393 }
394 break;
395 }
396 if (peripheral != PERIPH_ID_SPI4) {
397 for (i = pin; i < pin + 4; i++)
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530398 gpio_cfg_pin(i, cfg);
Rajeshwari Shinde8d909f32012-10-28 19:32:54 +0000399 }
400}
401
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530402void exynos5420_spi_config(int peripheral)
403{
404 int cfg, pin, i;
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530405
406 switch (peripheral) {
407 case PERIPH_ID_SPI0:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530408 pin = EXYNOS5420_GPIO_A20;
409 cfg = S5P_GPIO_FUNC(0x2);
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530410 break;
411 case PERIPH_ID_SPI1:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530412 pin = EXYNOS5420_GPIO_A24;
413 cfg = S5P_GPIO_FUNC(0x2);
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530414 break;
415 case PERIPH_ID_SPI2:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530416 pin = EXYNOS5420_GPIO_B11;
417 cfg = S5P_GPIO_FUNC(0x5);
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530418 break;
419 case PERIPH_ID_SPI3:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530420 pin = EXYNOS5420_GPIO_F10;
421 cfg = S5P_GPIO_FUNC(0x2);
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530422 break;
423 case PERIPH_ID_SPI4:
424 cfg = 0;
425 pin = 0;
426 break;
427 default:
428 cfg = 0;
429 pin = 0;
430 debug("%s: invalid peripheral %d", __func__, peripheral);
431 return;
432 }
433
434 if (peripheral != PERIPH_ID_SPI4) {
435 for (i = pin; i < pin + 4; i++)
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530436 gpio_cfg_pin(i, cfg);
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530437 } else {
438 for (i = 0; i < 2; i++) {
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530439 gpio_cfg_pin(EXYNOS5420_GPIO_F02 + i,
440 S5P_GPIO_FUNC(0x4));
441 gpio_cfg_pin(EXYNOS5420_GPIO_E04 + i,
442 S5P_GPIO_FUNC(0x4));
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530443 }
444 }
445}
446
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000447static int exynos5_pinmux_config(int peripheral, int flags)
448{
449 switch (peripheral) {
450 case PERIPH_ID_UART0:
451 case PERIPH_ID_UART1:
452 case PERIPH_ID_UART2:
453 case PERIPH_ID_UART3:
454 exynos5_uart_config(peripheral);
455 break;
456 case PERIPH_ID_SDMMC0:
457 case PERIPH_ID_SDMMC1:
458 case PERIPH_ID_SDMMC2:
459 case PERIPH_ID_SDMMC3:
460 return exynos5_mmc_config(peripheral, flags);
461 case PERIPH_ID_SROMC:
462 exynos5_sromc_config(flags);
463 break;
Rajeshwari Shinde6c313f92012-07-23 21:23:51 +0000464 case PERIPH_ID_I2C0:
465 case PERIPH_ID_I2C1:
466 case PERIPH_ID_I2C2:
467 case PERIPH_ID_I2C3:
468 case PERIPH_ID_I2C4:
469 case PERIPH_ID_I2C5:
470 case PERIPH_ID_I2C6:
471 case PERIPH_ID_I2C7:
472 exynos5_i2c_config(peripheral, flags);
473 break;
Dani Krishna Mohan65c7ee62013-09-11 16:38:48 +0530474 case PERIPH_ID_I2S0:
Rajeshwari Shinde7cf89a22012-10-25 19:49:27 +0000475 case PERIPH_ID_I2S1:
476 exynos5_i2s_config(peripheral);
477 break;
Rajeshwari Shinde8d909f32012-10-28 19:32:54 +0000478 case PERIPH_ID_SPI0:
479 case PERIPH_ID_SPI1:
480 case PERIPH_ID_SPI2:
481 case PERIPH_ID_SPI3:
482 case PERIPH_ID_SPI4:
483 exynos5_spi_config(peripheral);
484 break;
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000485 default:
486 debug("%s: invalid peripheral %d", __func__, peripheral);
487 return -1;
488 }
489
490 return 0;
491}
492
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530493static int exynos5420_pinmux_config(int peripheral, int flags)
494{
495 switch (peripheral) {
496 case PERIPH_ID_UART0:
497 case PERIPH_ID_UART1:
498 case PERIPH_ID_UART2:
499 case PERIPH_ID_UART3:
500 exynos5420_uart_config(peripheral);
501 break;
502 case PERIPH_ID_SDMMC0:
503 case PERIPH_ID_SDMMC1:
504 case PERIPH_ID_SDMMC2:
505 case PERIPH_ID_SDMMC3:
506 return exynos5420_mmc_config(peripheral, flags);
507 case PERIPH_ID_SPI0:
508 case PERIPH_ID_SPI1:
509 case PERIPH_ID_SPI2:
510 case PERIPH_ID_SPI3:
511 case PERIPH_ID_SPI4:
512 exynos5420_spi_config(peripheral);
513 break;
514 case PERIPH_ID_I2C0:
515 case PERIPH_ID_I2C1:
516 case PERIPH_ID_I2C2:
517 case PERIPH_ID_I2C3:
518 case PERIPH_ID_I2C4:
519 case PERIPH_ID_I2C5:
520 case PERIPH_ID_I2C6:
521 case PERIPH_ID_I2C7:
522 case PERIPH_ID_I2C8:
523 case PERIPH_ID_I2C9:
524 case PERIPH_ID_I2C10:
525 exynos5420_i2c_config(peripheral);
526 break;
527 default:
528 debug("%s: invalid peripheral %d", __func__, peripheral);
529 return -1;
530 }
531
532 return 0;
533}
534
Piotr Wilczekedad2172012-11-20 02:19:04 +0000535static void exynos4_i2c_config(int peripheral, int flags)
Piotr Wilczek7318b292012-09-20 00:19:57 +0000536{
Piotr Wilczek7318b292012-09-20 00:19:57 +0000537 switch (peripheral) {
Piotr Wilczekedad2172012-11-20 02:19:04 +0000538 case PERIPH_ID_I2C0:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530539 gpio_cfg_pin(EXYNOS4_GPIO_D10, S5P_GPIO_FUNC(0x2));
540 gpio_cfg_pin(EXYNOS4_GPIO_D11, S5P_GPIO_FUNC(0x2));
Piotr Wilczek7318b292012-09-20 00:19:57 +0000541 break;
Piotr Wilczekedad2172012-11-20 02:19:04 +0000542 case PERIPH_ID_I2C1:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530543 gpio_cfg_pin(EXYNOS4_GPIO_D12, S5P_GPIO_FUNC(0x2));
544 gpio_cfg_pin(EXYNOS4_GPIO_D13, S5P_GPIO_FUNC(0x2));
Piotr Wilczek7318b292012-09-20 00:19:57 +0000545 break;
Piotr Wilczekedad2172012-11-20 02:19:04 +0000546 case PERIPH_ID_I2C2:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530547 gpio_cfg_pin(EXYNOS4_GPIO_A06, S5P_GPIO_FUNC(0x3));
548 gpio_cfg_pin(EXYNOS4_GPIO_A07, S5P_GPIO_FUNC(0x3));
Piotr Wilczekedad2172012-11-20 02:19:04 +0000549 break;
550 case PERIPH_ID_I2C3:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530551 gpio_cfg_pin(EXYNOS4_GPIO_A12, S5P_GPIO_FUNC(0x3));
552 gpio_cfg_pin(EXYNOS4_GPIO_A13, S5P_GPIO_FUNC(0x3));
Piotr Wilczekedad2172012-11-20 02:19:04 +0000553 break;
554 case PERIPH_ID_I2C4:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530555 gpio_cfg_pin(EXYNOS4_GPIO_B2, S5P_GPIO_FUNC(0x3));
556 gpio_cfg_pin(EXYNOS4_GPIO_B3, S5P_GPIO_FUNC(0x3));
Piotr Wilczekedad2172012-11-20 02:19:04 +0000557 break;
558 case PERIPH_ID_I2C5:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530559 gpio_cfg_pin(EXYNOS4_GPIO_B6, S5P_GPIO_FUNC(0x3));
560 gpio_cfg_pin(EXYNOS4_GPIO_B7, S5P_GPIO_FUNC(0x3));
Piotr Wilczekedad2172012-11-20 02:19:04 +0000561 break;
562 case PERIPH_ID_I2C6:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530563 gpio_cfg_pin(EXYNOS4_GPIO_C13, S5P_GPIO_FUNC(0x4));
564 gpio_cfg_pin(EXYNOS4_GPIO_C14, S5P_GPIO_FUNC(0x4));
Piotr Wilczekedad2172012-11-20 02:19:04 +0000565 break;
566 case PERIPH_ID_I2C7:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530567 gpio_cfg_pin(EXYNOS4_GPIO_D02, S5P_GPIO_FUNC(0x3));
568 gpio_cfg_pin(EXYNOS4_GPIO_D03, S5P_GPIO_FUNC(0x3));
Piotr Wilczekedad2172012-11-20 02:19:04 +0000569 break;
Piotr Wilczek7318b292012-09-20 00:19:57 +0000570 }
Piotr Wilczek7318b292012-09-20 00:19:57 +0000571}
572
Piotr Wilczeka90efe92013-01-02 21:31:00 +0000573static int exynos4_mmc_config(int peripheral, int flags)
574{
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530575 int i, start = 0, start_ext = 0;
Piotr Wilczeka90efe92013-01-02 21:31:00 +0000576
577 switch (peripheral) {
578 case PERIPH_ID_SDMMC0:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530579 start = EXYNOS4_GPIO_K00;
580 start_ext = EXYNOS4_GPIO_K13;
Piotr Wilczeka90efe92013-01-02 21:31:00 +0000581 break;
582 case PERIPH_ID_SDMMC2:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530583 start = EXYNOS4_GPIO_K20;
584 start_ext = EXYNOS4_GPIO_K33;
Piotr Wilczeka90efe92013-01-02 21:31:00 +0000585 break;
586 default:
587 return -1;
588 }
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530589 for (i = start; i < (start + 7); i++) {
590 if (i == (start + 2))
Piotr Wilczeka90efe92013-01-02 21:31:00 +0000591 continue;
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530592 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
593 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
594 gpio_set_drv(i, S5P_GPIO_DRV_4X);
Piotr Wilczeka90efe92013-01-02 21:31:00 +0000595 }
596 if (flags & PINMUX_FLAG_8BIT_MODE) {
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530597 for (i = start_ext; i < (start_ext + 4); i++) {
598 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x3));
599 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
600 gpio_set_drv(i, S5P_GPIO_DRV_4X);
Piotr Wilczeka90efe92013-01-02 21:31:00 +0000601 }
602 }
603
604 return 0;
605}
606
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +0530607static void exynos4_uart_config(int peripheral)
608{
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +0530609 int i, start, count;
610
611 switch (peripheral) {
612 case PERIPH_ID_UART0:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530613 start = EXYNOS4_GPIO_A00;
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +0530614 count = 4;
615 break;
616 case PERIPH_ID_UART1:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530617 start = EXYNOS4_GPIO_A04;
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +0530618 count = 4;
619 break;
620 case PERIPH_ID_UART2:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530621 start = EXYNOS4_GPIO_A10;
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +0530622 count = 4;
623 break;
624 case PERIPH_ID_UART3:
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530625 start = EXYNOS4_GPIO_A14;
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +0530626 count = 2;
627 break;
Marek Vasute382be92014-03-10 20:04:31 +0100628 default:
629 debug("%s: invalid peripheral %d", __func__, peripheral);
630 return;
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +0530631 }
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530632 for (i = start; i < (start + count); i++) {
633 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
634 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
635 }
636}
637
638static void exynos4x12_i2c_config(int peripheral, int flags)
639{
640 switch (peripheral) {
641 case PERIPH_ID_I2C0:
642 gpio_cfg_pin(EXYNOS4X12_GPIO_D10, S5P_GPIO_FUNC(0x2));
643 gpio_cfg_pin(EXYNOS4X12_GPIO_D11, S5P_GPIO_FUNC(0x2));
644 break;
645 case PERIPH_ID_I2C1:
646 gpio_cfg_pin(EXYNOS4X12_GPIO_D12, S5P_GPIO_FUNC(0x2));
647 gpio_cfg_pin(EXYNOS4X12_GPIO_D13, S5P_GPIO_FUNC(0x2));
648 break;
649 case PERIPH_ID_I2C2:
650 gpio_cfg_pin(EXYNOS4X12_GPIO_A06, S5P_GPIO_FUNC(0x3));
651 gpio_cfg_pin(EXYNOS4X12_GPIO_A07, S5P_GPIO_FUNC(0x3));
652 break;
653 case PERIPH_ID_I2C3:
654 gpio_cfg_pin(EXYNOS4X12_GPIO_A12, S5P_GPIO_FUNC(0x3));
655 gpio_cfg_pin(EXYNOS4X12_GPIO_A13, S5P_GPIO_FUNC(0x3));
656 break;
657 case PERIPH_ID_I2C4:
658 gpio_cfg_pin(EXYNOS4X12_GPIO_B2, S5P_GPIO_FUNC(0x3));
659 gpio_cfg_pin(EXYNOS4X12_GPIO_B3, S5P_GPIO_FUNC(0x3));
660 break;
661 case PERIPH_ID_I2C5:
662 gpio_cfg_pin(EXYNOS4X12_GPIO_B6, S5P_GPIO_FUNC(0x3));
663 gpio_cfg_pin(EXYNOS4X12_GPIO_B7, S5P_GPIO_FUNC(0x3));
664 break;
665 case PERIPH_ID_I2C6:
666 gpio_cfg_pin(EXYNOS4X12_GPIO_C13, S5P_GPIO_FUNC(0x4));
667 gpio_cfg_pin(EXYNOS4X12_GPIO_C14, S5P_GPIO_FUNC(0x4));
668 break;
669 case PERIPH_ID_I2C7:
670 gpio_cfg_pin(EXYNOS4X12_GPIO_D02, S5P_GPIO_FUNC(0x3));
671 gpio_cfg_pin(EXYNOS4X12_GPIO_D03, S5P_GPIO_FUNC(0x3));
672 break;
673 }
674}
675
676static int exynos4x12_mmc_config(int peripheral, int flags)
677{
678 int i, start = 0, start_ext = 0;
679
680 switch (peripheral) {
681 case PERIPH_ID_SDMMC0:
682 start = EXYNOS4X12_GPIO_K00;
683 start_ext = EXYNOS4X12_GPIO_K13;
684 break;
685 case PERIPH_ID_SDMMC2:
686 start = EXYNOS4X12_GPIO_K20;
687 start_ext = EXYNOS4X12_GPIO_K33;
688 break;
689 default:
690 return -1;
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +0530691 }
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530692 for (i = start; i < (start + 7); i++) {
693 if (i == (start + 2))
694 continue;
695 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
696 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
697 gpio_set_drv(i, S5P_GPIO_DRV_4X);
698 }
699 if (flags & PINMUX_FLAG_8BIT_MODE) {
700 for (i = start_ext; i < (start_ext + 4); i++) {
701 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x3));
702 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
703 gpio_set_drv(i, S5P_GPIO_DRV_4X);
704 }
705 }
706
707 return 0;
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +0530708}
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530709
710static void exynos4x12_uart_config(int peripheral)
711{
712 int i, start, count;
713
714 switch (peripheral) {
715 case PERIPH_ID_UART0:
716 start = EXYNOS4X12_GPIO_A00;
717 count = 4;
718 break;
719 case PERIPH_ID_UART1:
720 start = EXYNOS4X12_GPIO_A04;
721 count = 4;
722 break;
723 case PERIPH_ID_UART2:
724 start = EXYNOS4X12_GPIO_A10;
725 count = 4;
726 break;
727 case PERIPH_ID_UART3:
728 start = EXYNOS4X12_GPIO_A14;
729 count = 2;
730 break;
731 default:
732 debug("%s: invalid peripheral %d", __func__, peripheral);
733 return;
734 }
735 for (i = start; i < (start + count); i++) {
736 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
737 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
738 }
739}
740
Piotr Wilczek7318b292012-09-20 00:19:57 +0000741static int exynos4_pinmux_config(int peripheral, int flags)
742{
743 switch (peripheral) {
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +0530744 case PERIPH_ID_UART0:
745 case PERIPH_ID_UART1:
746 case PERIPH_ID_UART2:
747 case PERIPH_ID_UART3:
748 exynos4_uart_config(peripheral);
749 break;
Piotr Wilczekedad2172012-11-20 02:19:04 +0000750 case PERIPH_ID_I2C0:
751 case PERIPH_ID_I2C1:
752 case PERIPH_ID_I2C2:
753 case PERIPH_ID_I2C3:
754 case PERIPH_ID_I2C4:
755 case PERIPH_ID_I2C5:
756 case PERIPH_ID_I2C6:
757 case PERIPH_ID_I2C7:
758 exynos4_i2c_config(peripheral, flags);
759 break;
Piotr Wilczeka90efe92013-01-02 21:31:00 +0000760 case PERIPH_ID_SDMMC0:
761 case PERIPH_ID_SDMMC2:
762 return exynos4_mmc_config(peripheral, flags);
763 case PERIPH_ID_SDMMC1:
764 case PERIPH_ID_SDMMC3:
765 case PERIPH_ID_SDMMC4:
Rajeshwari Shinde507f8922013-10-08 18:42:22 +0530766 debug("SDMMC device %d not implemented\n", peripheral);
Piotr Wilczeka90efe92013-01-02 21:31:00 +0000767 return -1;
Piotr Wilczek7318b292012-09-20 00:19:57 +0000768 default:
769 debug("%s: invalid peripheral %d", __func__, peripheral);
770 return -1;
771 }
772
773 return 0;
774}
775
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530776static int exynos4x12_pinmux_config(int peripheral, int flags)
777{
778 switch (peripheral) {
779 case PERIPH_ID_UART0:
780 case PERIPH_ID_UART1:
781 case PERIPH_ID_UART2:
782 case PERIPH_ID_UART3:
783 exynos4x12_uart_config(peripheral);
784 break;
785 case PERIPH_ID_I2C0:
786 case PERIPH_ID_I2C1:
787 case PERIPH_ID_I2C2:
788 case PERIPH_ID_I2C3:
789 case PERIPH_ID_I2C4:
790 case PERIPH_ID_I2C5:
791 case PERIPH_ID_I2C6:
792 case PERIPH_ID_I2C7:
793 exynos4x12_i2c_config(peripheral, flags);
794 break;
795 case PERIPH_ID_SDMMC0:
796 case PERIPH_ID_SDMMC2:
797 return exynos4x12_mmc_config(peripheral, flags);
798 case PERIPH_ID_SDMMC1:
799 case PERIPH_ID_SDMMC3:
800 case PERIPH_ID_SDMMC4:
801 debug("SDMMC device %d not implemented\n", peripheral);
802 return -1;
803 default:
804 debug("%s: invalid peripheral %d", __func__, peripheral);
805 return -1;
806 }
807
808 return 0;
809}
810
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000811int exynos_pinmux_config(int peripheral, int flags)
812{
Dani Krishna Mohan65c7ee62013-09-11 16:38:48 +0530813 if (cpu_is_exynos5()) {
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530814 if (proid_is_exynos5420())
815 return exynos5420_pinmux_config(peripheral, flags);
816 else if (proid_is_exynos5250())
817 return exynos5_pinmux_config(peripheral, flags);
Dani Krishna Mohan65c7ee62013-09-11 16:38:48 +0530818 } else if (cpu_is_exynos4()) {
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530819 if (proid_is_exynos4412())
820 return exynos4x12_pinmux_config(peripheral, flags);
821 else
822 return exynos4_pinmux_config(peripheral, flags);
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000823 }
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530824
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530825 debug("pinmux functionality not supported\n");
826
Rajeshwari Birjef0ce84f2013-12-26 09:44:23 +0530827 return -1;
Rajeshwari Shinde57da3e32012-06-06 19:54:29 +0000828}
Rajeshwari Shinde28bae822012-12-26 20:03:11 +0000829
830#ifdef CONFIG_OF_CONTROL
Piotr Wilczek246ec3a2014-03-07 14:59:38 +0100831static int exynos4_pinmux_decode_periph_id(const void *blob, int node)
832{
833 int err;
834 u32 cell[3];
835
836 err = fdtdec_get_int_array(blob, node, "interrupts", cell,
837 ARRAY_SIZE(cell));
838 if (err) {
839 debug(" invalid peripheral id\n");
840 return PERIPH_ID_NONE;
841 }
842
843 return cell[1];
844}
845
Rajeshwari Shinde28bae822012-12-26 20:03:11 +0000846static int exynos5_pinmux_decode_periph_id(const void *blob, int node)
847{
848 int err;
849 u32 cell[3];
850
851 err = fdtdec_get_int_array(blob, node, "interrupts", cell,
852 ARRAY_SIZE(cell));
853 if (err)
854 return PERIPH_ID_NONE;
855
Minkyu Kangdcc99172014-01-29 17:04:17 +0900856 return cell[1];
Rajeshwari Shinde28bae822012-12-26 20:03:11 +0000857}
858
859int pinmux_decode_periph_id(const void *blob, int node)
860{
861 if (cpu_is_exynos5())
862 return exynos5_pinmux_decode_periph_id(blob, node);
Piotr Wilczek246ec3a2014-03-07 14:59:38 +0100863 else if (cpu_is_exynos4())
864 return exynos4_pinmux_decode_periph_id(blob, node);
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530865
866 return PERIPH_ID_NONE;
Rajeshwari Shinde28bae822012-12-26 20:03:11 +0000867}
868#endif