blob: c3b2de1ccb902cbf560cad62af36ded27ab02370 [file] [log] [blame]
Angel Pons1ddb8942020-04-04 18:51:26 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer9fe20cb2012-12-07 17:18:43 -08002
Julius Werner1ed0c8c2014-10-20 13:16:29 -07003#include <console/console.h>
4#include <soc/gpio.h>
5#include <soc/pinmux.h>
Stefan Reinauer9fe20cb2012-12-07 17:18:43 -08006
Gabe Blackfe640602013-06-15 20:33:05 -07007static void exynos_pinmux_uart(int start, int count)
Stefan Reinauer9fe20cb2012-12-07 17:18:43 -08008{
Gabe Blackfe640602013-06-15 20:33:05 -07009 int i;
Stefan Reinauer9fe20cb2012-12-07 17:18:43 -080010
Gabe Blackfe640602013-06-15 20:33:05 -070011 for (i = start; i < start + count; i++) {
12 gpio_set_pull(i, GPIO_PULL_NONE);
13 gpio_cfg_pin(i, GPIO_FUNC(0x2));
Stefan Reinauer9fe20cb2012-12-07 17:18:43 -080014 }
Gabe Blackfe640602013-06-15 20:33:05 -070015}
Stefan Reinauer9fe20cb2012-12-07 17:18:43 -080016
Gabe Blackfe640602013-06-15 20:33:05 -070017void exynos_pinmux_uart0(void)
18{
19 exynos_pinmux_uart(GPIO_A00, 4);
20}
21
22void exynos_pinmux_uart1(void)
23{
24 exynos_pinmux_uart(GPIO_D00, 4);
25}
26
27void exynos_pinmux_uart2(void)
28{
29 exynos_pinmux_uart(GPIO_A10, 4);
30}
31
32void exynos_pinmux_uart3(void)
33{
34 exynos_pinmux_uart(GPIO_A14, 2);
35}
36
37static void exynos_pinmux_sdmmc(int start, int start_ext)
38{
39 int i;
40
41 if (start_ext) {
42 for (i = 0; i <= 3; i++) {
43 gpio_cfg_pin(start_ext + i, GPIO_FUNC(0x2));
44 gpio_set_pull(start_ext + i, GPIO_PULL_UP);
45 gpio_set_drv(start_ext + i, GPIO_DRV_4X);
Gabe Black63dd2cb2013-05-18 15:52:01 -070046 }
Gabe Blackfe640602013-06-15 20:33:05 -070047 }
48 for (i = 0; i < 2; i++) {
49 gpio_cfg_pin(start + i, GPIO_FUNC(0x2));
50 gpio_set_pull(start + i, GPIO_PULL_NONE);
51 gpio_set_drv(start + i, GPIO_DRV_4X);
52 }
53 for (i = 2; i <= 6; i++) {
54 gpio_cfg_pin(start + i, GPIO_FUNC(0x2));
55 gpio_set_pull(start + i, GPIO_PULL_UP);
56 gpio_set_drv(start + i, GPIO_DRV_4X);
57 }
58}
59
60void exynos_pinmux_sdmmc0(void)
61{
62 exynos_pinmux_sdmmc(GPIO_C00, GPIO_C10);
63}
64
65void exynos_pinmux_sdmmc1(void)
66{
67 exynos_pinmux_sdmmc(GPIO_C20, 0);
68}
69
70void exynos_pinmux_sdmmc2(void)
71{
72 exynos_pinmux_sdmmc(GPIO_C30, 0);
73}
74
75void exynos_pinmux_sdmmc3(void)
76{
77 /*
Martin Roth4c3ab732013-07-08 16:23:54 -060078 * TODO: Need to add definitions for GPC4 before
Gabe Blackfe640602013-06-15 20:33:05 -070079 * enabling this.
80 */
81 printk(BIOS_DEBUG, "SDMMC3 not supported yet");
82}
83
84void exynos_pinmux_sromc(int bank, int sixteen_bit)
85{
86 int i;
87
88 if (bank > 3) {
89 printk(BIOS_DEBUG, "Unsupported sromc bank %d.\n", bank);
90 return;
Stefan Reinauer9fe20cb2012-12-07 17:18:43 -080091 }
92
Gabe Blackfe640602013-06-15 20:33:05 -070093 gpio_cfg_pin(GPIO_Y00 + bank, GPIO_FUNC(2));
94 gpio_cfg_pin(GPIO_Y04, GPIO_FUNC(2));
95 gpio_cfg_pin(GPIO_Y05, GPIO_FUNC(2));
96
97 for (i = 2; i < 4; i++)
98 gpio_cfg_pin(GPIO_Y10 + i, GPIO_FUNC(2));
99
100 for (i = 0; i < 8; i++) {
101 gpio_cfg_pin(GPIO_Y30 + i, GPIO_FUNC(2));
102 gpio_set_pull(GPIO_Y30 + i, GPIO_PULL_UP);
103
104 gpio_cfg_pin(GPIO_Y50 + i, GPIO_FUNC(2));
105 gpio_set_pull(GPIO_Y50 + i, GPIO_PULL_UP);
106
107 if (sixteen_bit) {
108 gpio_cfg_pin(GPIO_Y60 + i, GPIO_FUNC(2));
109 gpio_set_pull(GPIO_Y60 + i, GPIO_PULL_UP);
110 }
111 }
112}
113
114static void exynos_pinmux_spi(int start, int cfg)
115{
116 int i;
117
Julius Wernerce011ec2013-08-06 16:00:37 -0700118 for (i = 0; i < 4; i++) {
Gabe Blackfe640602013-06-15 20:33:05 -0700119 gpio_cfg_pin(start + i, GPIO_FUNC(cfg));
Julius Wernerce011ec2013-08-06 16:00:37 -0700120 gpio_set_pull(start + i, GPIO_PULL_NONE);
121 gpio_set_drv(start + i, GPIO_DRV_3X);
122 }
Gabe Blackfe640602013-06-15 20:33:05 -0700123}
124
125void exynos_pinmux_spi0(void)
126{
127 exynos_pinmux_spi(GPIO_A20, 0x2);
128}
129
130void exynos_pinmux_spi1(void)
131{
132 exynos_pinmux_spi(GPIO_A24, 0x2);
133}
134
135void exynos_pinmux_spi2(void)
136{
137 exynos_pinmux_spi(GPIO_B11, 0x5);
138}
139
140void exynos_pinmux_spi3(void)
141{
142 exynos_pinmux_spi(GPIO_E00, 0x2);
143}
144
145void exynos_pinmux_spi4(void)
146{
147 int i;
148
149 for (i = 0; i < 2; i++)
150 gpio_cfg_pin(GPIO_F02 + i, GPIO_FUNC(0x4));
151 for (i = 2; i < 4; i++)
152 gpio_cfg_pin(GPIO_E02 + i, GPIO_FUNC(0x4));
153}
154
155void exynos_pinmux_backlight(void)
156{
157 gpio_cfg_pin(GPIO_B20, GPIO_OUTPUT);
158 gpio_set_value(GPIO_B20, 1);
159}
160
161void exynos_pinmux_lcd(void)
162{
163 gpio_cfg_pin(GPIO_Y25, GPIO_OUTPUT);
164 gpio_set_value(GPIO_Y25, 1);
165 gpio_cfg_pin(GPIO_X15, GPIO_OUTPUT);
166 gpio_set_value(GPIO_X15, 1);
167 gpio_cfg_pin(GPIO_X30, GPIO_OUTPUT);
168 gpio_set_value(GPIO_X30, 1);
169}
170
171static void exynos_pinmux_i2c(int start, int func)
172{
173 gpio_cfg_pin(start, GPIO_FUNC(func));
174 gpio_cfg_pin(start + 1, GPIO_FUNC(func));
175 gpio_set_pull(start, GPIO_PULL_NONE);
176 gpio_set_pull(start + 1, GPIO_PULL_NONE);
177}
178
179void exynos_pinmux_i2c0(void)
180{
181 exynos_pinmux_i2c(GPIO_B30, 0x2);
182}
183
184void exynos_pinmux_i2c1(void)
185{
186 exynos_pinmux_i2c(GPIO_B32, 0x2);
187}
188
189void exynos_pinmux_i2c2(void)
190{
191 exynos_pinmux_i2c(GPIO_A06, 0x3);
192}
193
194void exynos_pinmux_i2c3(void)
195{
196 exynos_pinmux_i2c(GPIO_A12, 0x3);
197}
198
199void exynos_pinmux_i2c4(void)
200{
201 exynos_pinmux_i2c(GPIO_A20, 0x3);
202}
203
204void exynos_pinmux_i2c5(void)
205{
206 exynos_pinmux_i2c(GPIO_A22, 0x3);
207}
208
209void exynos_pinmux_i2c6(void)
210{
211 exynos_pinmux_i2c(GPIO_B13, 0x4);
212}
213
214void exynos_pinmux_i2c7(void)
215{
216 exynos_pinmux_i2c(GPIO_B22, 0x3);
217}
218
219void exynos_pinmux_dphpd(void)
220{
221 /* Set Hotplug detect for DP */
222 gpio_cfg_pin(GPIO_X07, GPIO_FUNC(0x3));
223
224 /*
225 * Hotplug detect should have an external pullup; disable the
226 * internal pulldown so they don't fight.
227 */
228 gpio_set_pull(GPIO_X07, GPIO_PULL_NONE);
229}
230
Gabe Black4e195af2013-08-05 22:15:21 -0700231void exynos_pinmux_i2s0(void)
232{
233 int i;
234
235 for (i = 0; i < 5; i++) {
236 gpio_cfg_pin(GPIO_Z0 + i, GPIO_FUNC(0x02));
237 gpio_set_pull(GPIO_Z0 + i, GPIO_PULL_NONE);
238 }
239}
240
Gabe Blackfe640602013-06-15 20:33:05 -0700241void exynos_pinmux_i2s1(void)
242{
243 int i;
244
245 for (i = 0; i < 5; i++) {
246 gpio_cfg_pin(GPIO_B00 + i, GPIO_FUNC(0x02));
247 gpio_set_pull(GPIO_B00 + i, GPIO_PULL_NONE);
248 }
Stefan Reinauer9fe20cb2012-12-07 17:18:43 -0800249}