blob: b24c1247e56395ed154b56e8621f579848aa827d [file] [log] [blame]
Angel Pons1ddb8942020-04-04 18:51:26 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Gabe Black607c0b62013-05-16 05:45:57 -07002
Julius Werner80af4422014-10-20 13:18:56 -07003#include <soc/gpio.h>
4#include <soc/pinmux.h>
Gabe Black607c0b62013-05-16 05:45:57 -07005
Gabe Blacke6a44eb2013-06-15 23:40:26 -07006static void exynos_pinmux_uart(int start, int count)
Gabe Black607c0b62013-05-16 05:45:57 -07007{
Gabe Blacke6a44eb2013-06-15 23:40:26 -07008 int i;
Gabe Black607c0b62013-05-16 05:45:57 -07009
Gabe Blacke6a44eb2013-06-15 23:40:26 -070010 for (i = start; i < start + count; i++) {
11 gpio_set_pull(i, GPIO_PULL_NONE);
12 gpio_cfg_pin(i, GPIO_FUNC(0x2));
13 }
14}
15
16void exynos_pinmux_uart0(void)
17{
18 exynos_pinmux_uart(GPIO_A00, 4);
19}
20
21void exynos_pinmux_uart1(void)
22{
23 exynos_pinmux_uart(GPIO_A04, 4);
24}
25
26void exynos_pinmux_uart2(void)
27{
28 exynos_pinmux_uart(GPIO_A10, 4);
29}
30
31void exynos_pinmux_uart3(void)
32{
33 exynos_pinmux_uart(GPIO_A14, 2);
34}
35
David Hendrickse0cfad22013-08-08 14:09:46 -070036struct gpio {
37 enum exynos5_gpio_pin pin;
38 unsigned int func;
39 unsigned int pull;
40 unsigned int drv;
41};
42
43static void exynos_pinmux_sdmmc(struct gpio *gpios, int num_gpios)
Gabe Blacke6a44eb2013-06-15 23:40:26 -070044{
45 int i;
46
David Hendrickse0cfad22013-08-08 14:09:46 -070047 for (i = 0; i < num_gpios; i++) {
48 gpio_set_drv(gpios[i].pin, gpios[i].drv);
49 gpio_set_pull(gpios[i].pin, gpios[i].pull);
50 gpio_cfg_pin(gpios[i].pin, GPIO_FUNC(gpios[i].func));
Gabe Blacke6a44eb2013-06-15 23:40:26 -070051 }
52}
53
54void exynos_pinmux_sdmmc0(void)
55{
David Hendrickse0cfad22013-08-08 14:09:46 -070056 struct gpio gpios[] = {
57 { GPIO_C00, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CLK */
58 { GPIO_C01, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CMD */
59 /*
60 * MMC0 is intended to be used for eMMC. The card detect
61 * pin is used as a VDDEN signal to power on the eMMC. The
62 * 5420 iROM makes this same assumption.
63 */
64 { GPIO_C02, GPIO_OUTPUT, GPIO_PULL_NONE, GPIO_DRV_4X },
65 { GPIO_C03, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[0] */
66 { GPIO_C04, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[1] */
67 { GPIO_C05, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[2] */
68 { GPIO_C06, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[3] */
69
70 { GPIO_C30, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[4] */
71 { GPIO_C31, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[5] */
72 { GPIO_C32, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[6] */
73 { GPIO_C33, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[7] */
74 };
75
76 exynos_pinmux_sdmmc(&gpios[0], ARRAY_SIZE(gpios));
77
78 /* set VDDEN */
David Hendricksb9f267c2013-08-08 14:51:07 -070079 gpio_set_value(GPIO_C02, 1);
Gabe Blacke6a44eb2013-06-15 23:40:26 -070080}
81
82void exynos_pinmux_sdmmc1(void)
83{
David Hendrickse0cfad22013-08-08 14:09:46 -070084 struct gpio gpios[] = {
85 { GPIO_C10, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CLK */
86 { GPIO_C11, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CMD */
87 { GPIO_C12, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CDn */
88 { GPIO_C13, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[0] */
89 { GPIO_C14, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[1] */
90 { GPIO_C15, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[2] */
91 { GPIO_C16, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[3] */
92
93 { GPIO_D14, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[4] */
94 { GPIO_D15, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[5] */
95 { GPIO_D16, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[6] */
96 { GPIO_D17, 0x2, GPIO_PULL_UP, GPIO_DRV_4X }, /* DATA[7] */
97 };
98
99 exynos_pinmux_sdmmc(&gpios[0], ARRAY_SIZE(gpios));
Gabe Blacke6a44eb2013-06-15 23:40:26 -0700100}
101
102void exynos_pinmux_sdmmc2(void)
103{
David Hendrickse0cfad22013-08-08 14:09:46 -0700104 struct gpio gpios[] = {
105 { GPIO_C20, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CLK */
106 { GPIO_C21, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CMD */
107 { GPIO_C22, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* CDn */
108 { GPIO_C23, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[0] */
109 { GPIO_C24, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[1] */
110 { GPIO_C25, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[2] */
111 { GPIO_C26, 0x2, GPIO_PULL_NONE, GPIO_DRV_4X }, /* DATA[3] */
112 };
113
114 exynos_pinmux_sdmmc(&gpios[0], ARRAY_SIZE(gpios));
Gabe Blacke6a44eb2013-06-15 23:40:26 -0700115}
116
117static void exynos_pinmux_spi(int start, int cfg)
118{
119 int i;
120
Julius Werner45d2ff32013-08-12 18:04:06 -0700121 for (i = start; i < start + 4; i++) {
Gabe Blacke6a44eb2013-06-15 23:40:26 -0700122 gpio_cfg_pin(i, cfg);
Julius Werner45d2ff32013-08-12 18:04:06 -0700123 gpio_set_pull(i, GPIO_PULL_NONE);
124 gpio_set_drv(i, GPIO_DRV_3X);
125 }
Gabe Blacke6a44eb2013-06-15 23:40:26 -0700126}
127
128void exynos_pinmux_spi0(void)
129{
130 exynos_pinmux_spi(GPIO_A20, 0x2);
131}
132
133void exynos_pinmux_spi1(void)
134{
135 exynos_pinmux_spi(GPIO_A24, 0x2);
136}
137
138void exynos_pinmux_spi2(void)
139{
140 exynos_pinmux_spi(GPIO_B11, 0x5);
141}
142
143void exynos_pinmux_spi3(void)
144{
145 exynos_pinmux_spi(GPIO_F10, 0x2);
146}
147
148void exynos_pinmux_spi4(void)
149{
150 int i;
151
152 for (i = 0; i < 2; i++) {
153 gpio_cfg_pin(GPIO_F02 + i, GPIO_FUNC(0x4));
154 gpio_cfg_pin(GPIO_E04 + i, GPIO_FUNC(0x4));
155 }
156}
157
158static void exynos_pinmux_i2c(int start, int func)
159{
160 gpio_cfg_pin(start, GPIO_FUNC(func));
161 gpio_cfg_pin(start + 1, GPIO_FUNC(func));
162 gpio_set_pull(start, GPIO_PULL_NONE);
163 gpio_set_pull(start + 1, GPIO_PULL_NONE);
164}
165
166void exynos_pinmux_i2c0(void)
167{
168 exynos_pinmux_i2c(GPIO_B30, 0x2);
169}
170
171void exynos_pinmux_i2c1(void)
172{
173 exynos_pinmux_i2c(GPIO_B32, 0x2);
174}
175
176void exynos_pinmux_i2c2(void)
177{
178 exynos_pinmux_i2c(GPIO_A06, 0x3);
179}
180
181void exynos_pinmux_i2c3(void)
182{
183 exynos_pinmux_i2c(GPIO_A12, 0x3);
184}
185
186void exynos_pinmux_i2c4(void)
187{
188 exynos_pinmux_i2c(GPIO_A20, 0x3);
189}
190
191void exynos_pinmux_i2c5(void)
192{
193 exynos_pinmux_i2c(GPIO_A22, 0x3);
194}
195
196void exynos_pinmux_i2c6(void)
197{
198 exynos_pinmux_i2c(GPIO_B13, 0x4);
199}
200
201void exynos_pinmux_i2c7(void)
202{
203 exynos_pinmux_i2c(GPIO_B22, 0x3);
204}
205
206void exynos_pinmux_i2c8(void)
207{
208 exynos_pinmux_i2c(GPIO_B34, 0x2);
209}
210
211void exynos_pinmux_i2c9(void)
212{
213 exynos_pinmux_i2c(GPIO_B36, 0x2);
214}
215
216void exynos_pinmux_i2c10(void)
217{
218 exynos_pinmux_i2c(GPIO_B40, 0x2);
219}
220
221void exynos_pinmux_dphpd(void)
222{
223 gpio_cfg_pin(GPIO_X07, GPIO_FUNC(0x3));
224 gpio_set_pull(GPIO_X07, GPIO_PULL_NONE);
Gabe Black607c0b62013-05-16 05:45:57 -0700225}