~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/u-boot/arch/arm/include/asm/arch-exynos/gpio.h

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * (C) Copyright 2010 Samsung Electronics
 
3
 * Minkyu Kang <mk7.kang@samsung.com>
 
4
 *
 
5
 * SPDX-License-Identifier:     GPL-2.0+
 
6
 */
 
7
 
 
8
#ifndef __ASM_ARCH_GPIO_H
 
9
#define __ASM_ARCH_GPIO_H
 
10
 
 
11
#ifndef __ASSEMBLY__
 
12
struct s5p_gpio_bank {
 
13
        unsigned int    con;
 
14
        unsigned int    dat;
 
15
        unsigned int    pull;
 
16
        unsigned int    drv;
 
17
        unsigned int    pdn_con;
 
18
        unsigned int    pdn_pull;
 
19
        unsigned char   res1[8];
 
20
};
 
21
 
 
22
struct exynos4_gpio_part1 {
 
23
        struct s5p_gpio_bank a0;
 
24
        struct s5p_gpio_bank a1;
 
25
        struct s5p_gpio_bank b;
 
26
        struct s5p_gpio_bank c0;
 
27
        struct s5p_gpio_bank c1;
 
28
        struct s5p_gpio_bank d0;
 
29
        struct s5p_gpio_bank d1;
 
30
        struct s5p_gpio_bank e0;
 
31
        struct s5p_gpio_bank e1;
 
32
        struct s5p_gpio_bank e2;
 
33
        struct s5p_gpio_bank e3;
 
34
        struct s5p_gpio_bank e4;
 
35
        struct s5p_gpio_bank f0;
 
36
        struct s5p_gpio_bank f1;
 
37
        struct s5p_gpio_bank f2;
 
38
        struct s5p_gpio_bank f3;
 
39
};
 
40
 
 
41
struct exynos4_gpio_part2 {
 
42
        struct s5p_gpio_bank j0;
 
43
        struct s5p_gpio_bank j1;
 
44
        struct s5p_gpio_bank k0;
 
45
        struct s5p_gpio_bank k1;
 
46
        struct s5p_gpio_bank k2;
 
47
        struct s5p_gpio_bank k3;
 
48
        struct s5p_gpio_bank l0;
 
49
        struct s5p_gpio_bank l1;
 
50
        struct s5p_gpio_bank l2;
 
51
        struct s5p_gpio_bank y0;
 
52
        struct s5p_gpio_bank y1;
 
53
        struct s5p_gpio_bank y2;
 
54
        struct s5p_gpio_bank y3;
 
55
        struct s5p_gpio_bank y4;
 
56
        struct s5p_gpio_bank y5;
 
57
        struct s5p_gpio_bank y6;
 
58
        struct s5p_gpio_bank res1[80];
 
59
        struct s5p_gpio_bank x0;
 
60
        struct s5p_gpio_bank x1;
 
61
        struct s5p_gpio_bank x2;
 
62
        struct s5p_gpio_bank x3;
 
63
};
 
64
 
 
65
struct exynos4_gpio_part3 {
 
66
        struct s5p_gpio_bank z;
 
67
};
 
68
 
 
69
struct exynos4x12_gpio_part1 {
 
70
        struct s5p_gpio_bank a0;
 
71
        struct s5p_gpio_bank a1;
 
72
        struct s5p_gpio_bank b;
 
73
        struct s5p_gpio_bank c0;
 
74
        struct s5p_gpio_bank c1;
 
75
        struct s5p_gpio_bank d0;
 
76
        struct s5p_gpio_bank d1;
 
77
        struct s5p_gpio_bank res1[0x5];
 
78
        struct s5p_gpio_bank f0;
 
79
        struct s5p_gpio_bank f1;
 
80
        struct s5p_gpio_bank f2;
 
81
        struct s5p_gpio_bank f3;
 
82
        struct s5p_gpio_bank res2[0x2];
 
83
        struct s5p_gpio_bank j0;
 
84
        struct s5p_gpio_bank j1;
 
85
};
 
86
 
 
87
struct exynos4x12_gpio_part2 {
 
88
        struct s5p_gpio_bank res1[0x2];
 
89
        struct s5p_gpio_bank k0;
 
90
        struct s5p_gpio_bank k1;
 
91
        struct s5p_gpio_bank k2;
 
92
        struct s5p_gpio_bank k3;
 
93
        struct s5p_gpio_bank l0;
 
94
        struct s5p_gpio_bank l1;
 
95
        struct s5p_gpio_bank l2;
 
96
        struct s5p_gpio_bank y0;
 
97
        struct s5p_gpio_bank y1;
 
98
        struct s5p_gpio_bank y2;
 
99
        struct s5p_gpio_bank y3;
 
100
        struct s5p_gpio_bank y4;
 
101
        struct s5p_gpio_bank y5;
 
102
        struct s5p_gpio_bank y6;
 
103
        struct s5p_gpio_bank res2[0x3];
 
104
        struct s5p_gpio_bank m0;
 
105
        struct s5p_gpio_bank m1;
 
106
        struct s5p_gpio_bank m2;
 
107
        struct s5p_gpio_bank m3;
 
108
        struct s5p_gpio_bank m4;
 
109
        struct s5p_gpio_bank res3[0x48];
 
110
        struct s5p_gpio_bank x0;
 
111
        struct s5p_gpio_bank x1;
 
112
        struct s5p_gpio_bank x2;
 
113
        struct s5p_gpio_bank x3;
 
114
};
 
115
 
 
116
struct exynos4x12_gpio_part3 {
 
117
        struct s5p_gpio_bank z;
 
118
};
 
119
 
 
120
struct exynos4x12_gpio_part4 {
 
121
        struct s5p_gpio_bank v0;
 
122
        struct s5p_gpio_bank v1;
 
123
        struct s5p_gpio_bank res1[0x1];
 
124
        struct s5p_gpio_bank v2;
 
125
        struct s5p_gpio_bank v3;
 
126
        struct s5p_gpio_bank res2[0x1];
 
127
        struct s5p_gpio_bank v4;
 
128
};
 
129
 
 
130
struct exynos5420_gpio_part1 {
 
131
        struct s5p_gpio_bank a0;
 
132
        struct s5p_gpio_bank a1;
 
133
        struct s5p_gpio_bank a2;
 
134
        struct s5p_gpio_bank b0;
 
135
        struct s5p_gpio_bank b1;
 
136
        struct s5p_gpio_bank b2;
 
137
        struct s5p_gpio_bank b3;
 
138
        struct s5p_gpio_bank b4;
 
139
        struct s5p_gpio_bank h0;
 
140
};
 
141
 
 
142
struct exynos5420_gpio_part2 {
 
143
        struct s5p_gpio_bank y7; /* 0x1340_0000 */
 
144
        struct s5p_gpio_bank res[0x5f]; /*  */
 
145
        struct s5p_gpio_bank x0; /* 0x1340_0C00 */
 
146
        struct s5p_gpio_bank x1; /* 0x1340_0C20 */
 
147
        struct s5p_gpio_bank x2; /* 0x1340_0C40 */
 
148
        struct s5p_gpio_bank x3; /* 0x1340_0C60 */
 
149
};
 
150
 
 
151
struct exynos5420_gpio_part3 {
 
152
        struct s5p_gpio_bank c0;
 
153
        struct s5p_gpio_bank c1;
 
154
        struct s5p_gpio_bank c2;
 
155
        struct s5p_gpio_bank c3;
 
156
        struct s5p_gpio_bank c4;
 
157
        struct s5p_gpio_bank d1;
 
158
        struct s5p_gpio_bank y0;
 
159
        struct s5p_gpio_bank y1;
 
160
        struct s5p_gpio_bank y2;
 
161
        struct s5p_gpio_bank y3;
 
162
        struct s5p_gpio_bank y4;
 
163
        struct s5p_gpio_bank y5;
 
164
        struct s5p_gpio_bank y6;
 
165
};
 
166
 
 
167
struct exynos5420_gpio_part4 {
 
168
        struct s5p_gpio_bank e0; /* 0x1400_0000 */
 
169
        struct s5p_gpio_bank e1; /* 0x1400_0020 */
 
170
        struct s5p_gpio_bank f0; /* 0x1400_0040 */
 
171
        struct s5p_gpio_bank f1; /* 0x1400_0060 */
 
172
        struct s5p_gpio_bank g0; /* 0x1400_0080 */
 
173
        struct s5p_gpio_bank g1; /* 0x1400_00A0 */
 
174
        struct s5p_gpio_bank g2; /* 0x1400_00C0 */
 
175
        struct s5p_gpio_bank j4; /* 0x1400_00E0 */
 
176
};
 
177
 
 
178
struct exynos5420_gpio_part5 {
 
179
        struct s5p_gpio_bank z0; /* 0x0386_0000 */
 
180
};
 
181
 
 
182
struct exynos5_gpio_part1 {
 
183
        struct s5p_gpio_bank a0;
 
184
        struct s5p_gpio_bank a1;
 
185
        struct s5p_gpio_bank a2;
 
186
        struct s5p_gpio_bank b0;
 
187
        struct s5p_gpio_bank b1;
 
188
        struct s5p_gpio_bank b2;
 
189
        struct s5p_gpio_bank b3;
 
190
        struct s5p_gpio_bank c0;
 
191
        struct s5p_gpio_bank c1;
 
192
        struct s5p_gpio_bank c2;
 
193
        struct s5p_gpio_bank c3;
 
194
        struct s5p_gpio_bank d0;
 
195
        struct s5p_gpio_bank d1;
 
196
        struct s5p_gpio_bank y0;
 
197
        struct s5p_gpio_bank y1;
 
198
        struct s5p_gpio_bank y2;
 
199
        struct s5p_gpio_bank y3;
 
200
        struct s5p_gpio_bank y4;
 
201
        struct s5p_gpio_bank y5;
 
202
        struct s5p_gpio_bank y6;
 
203
        struct s5p_gpio_bank res1[0x3];
 
204
        struct s5p_gpio_bank c4;
 
205
        struct s5p_gpio_bank res2[0x48];
 
206
        struct s5p_gpio_bank x0;
 
207
        struct s5p_gpio_bank x1;
 
208
        struct s5p_gpio_bank x2;
 
209
        struct s5p_gpio_bank x3;
 
210
};
 
211
 
 
212
struct exynos5_gpio_part2 {
 
213
        struct s5p_gpio_bank e0;
 
214
        struct s5p_gpio_bank e1;
 
215
        struct s5p_gpio_bank f0;
 
216
        struct s5p_gpio_bank f1;
 
217
        struct s5p_gpio_bank g0;
 
218
        struct s5p_gpio_bank g1;
 
219
        struct s5p_gpio_bank g2;
 
220
        struct s5p_gpio_bank h0;
 
221
        struct s5p_gpio_bank h1;
 
222
};
 
223
 
 
224
struct exynos5_gpio_part3 {
 
225
        struct s5p_gpio_bank v0;
 
226
        struct s5p_gpio_bank v1;
 
227
        struct s5p_gpio_bank res1[0x1];
 
228
        struct s5p_gpio_bank v2;
 
229
        struct s5p_gpio_bank v3;
 
230
        struct s5p_gpio_bank res2[0x1];
 
231
        struct s5p_gpio_bank v4;
 
232
};
 
233
 
 
234
struct exynos5_gpio_part4 {
 
235
        struct s5p_gpio_bank z;
 
236
};
 
237
 
 
238
/* functions */
 
239
void s5p_gpio_cfg_pin(struct s5p_gpio_bank *bank, int gpio, int cfg);
 
240
void s5p_gpio_direction_output(struct s5p_gpio_bank *bank, int gpio, int en);
 
241
void s5p_gpio_direction_input(struct s5p_gpio_bank *bank, int gpio);
 
242
void s5p_gpio_set_value(struct s5p_gpio_bank *bank, int gpio, int en);
 
243
unsigned int s5p_gpio_get_value(struct s5p_gpio_bank *bank, int gpio);
 
244
void s5p_gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode);
 
245
void s5p_gpio_set_drv(struct s5p_gpio_bank *bank, int gpio, int mode);
 
246
void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode);
 
247
 
 
248
/* GPIO pins per bank  */
 
249
#define GPIO_PER_BANK 8
 
250
#define S5P_GPIO_PART_SHIFT     (24)
 
251
#define S5P_GPIO_PART_MASK      (0xff)
 
252
#define S5P_GPIO_BANK_SHIFT     (8)
 
253
#define S5P_GPIO_BANK_MASK      (0xffff)
 
254
#define S5P_GPIO_PIN_MASK       (0xff)
 
255
 
 
256
#define S5P_GPIO_SET_PART(x) \
 
257
                        (((x) & S5P_GPIO_PART_MASK) << S5P_GPIO_PART_SHIFT)
 
258
 
 
259
#define S5P_GPIO_GET_PART(x) \
 
260
                        (((x) >> S5P_GPIO_PART_SHIFT) & S5P_GPIO_PART_MASK)
 
261
 
 
262
#define S5P_GPIO_SET_PIN(x) \
 
263
                        ((x) & S5P_GPIO_PIN_MASK)
 
264
 
 
265
#define EXYNOS4_GPIO_SET_BANK(part, bank) \
 
266
                        ((((unsigned)&(((struct exynos4_gpio_part##part *) \
 
267
                        EXYNOS4_GPIO_PART##part##_BASE)->bank) \
 
268
                        - EXYNOS4_GPIO_PART##part##_BASE) \
 
269
                        & S5P_GPIO_BANK_MASK) << S5P_GPIO_BANK_SHIFT)
 
270
 
 
271
#define EXYNOS4X12_GPIO_SET_BANK(part, bank) \
 
272
                        ((((unsigned)&(((struct exynos4x12_gpio_part##part *) \
 
273
                        EXYNOS4X12_GPIO_PART##part##_BASE)->bank) \
 
274
                        - EXYNOS4X12_GPIO_PART##part##_BASE) \
 
275
                        & S5P_GPIO_BANK_MASK) << S5P_GPIO_BANK_SHIFT)
 
276
 
 
277
#define EXYNOS5_GPIO_SET_BANK(part, bank) \
 
278
                        ((((unsigned)&(((struct exynos5420_gpio_part##part *) \
 
279
                        EXYNOS5420_GPIO_PART##part##_BASE)->bank) \
 
280
                        - EXYNOS5_GPIO_PART##part##_BASE) \
 
281
                        & S5P_GPIO_BANK_MASK) << S5P_GPIO_BANK_SHIFT)
 
282
 
 
283
#define EXYNOS5420_GPIO_SET_BANK(part, bank) \
 
284
                        ((((unsigned)&(((struct exynos5420_gpio_part##part *) \
 
285
                        EXYNOS5420_GPIO_PART##part##_BASE)->bank) \
 
286
                        - EXYNOS5420_GPIO_PART##part##_BASE) \
 
287
                        & S5P_GPIO_BANK_MASK) << S5P_GPIO_BANK_SHIFT)
 
288
 
 
289
#define exynos4_gpio_get(part, bank, pin) \
 
290
                        (S5P_GPIO_SET_PART(part) | \
 
291
                        EXYNOS4_GPIO_SET_BANK(part, bank) | \
 
292
                        S5P_GPIO_SET_PIN(pin))
 
293
 
 
294
#define exynos4x12_gpio_get(part, bank, pin) \
 
295
                        (S5P_GPIO_SET_PART(part) | \
 
296
                        EXYNOS4X12_GPIO_SET_BANK(part, bank) | \
 
297
                        S5P_GPIO_SET_PIN(pin))
 
298
 
 
299
#define exynos5420_gpio_get(part, bank, pin) \
 
300
                        (S5P_GPIO_SET_PART(part) | \
 
301
                        EXYNOS5420_GPIO_SET_BANK(part, bank) | \
 
302
                        S5P_GPIO_SET_PIN(pin))
 
303
 
 
304
#define exynos5_gpio_get(part, bank, pin) \
 
305
                        (S5P_GPIO_SET_PART(part) | \
 
306
                        EXYNOS5_GPIO_SET_BANK(part, bank) | \
 
307
                        S5P_GPIO_SET_PIN(pin))
 
308
 
 
309
static inline unsigned int s5p_gpio_base(int gpio)
 
310
{
 
311
        unsigned gpio_part = S5P_GPIO_GET_PART(gpio);
 
312
 
 
313
        switch (gpio_part) {
 
314
        case 1:
 
315
                return samsung_get_base_gpio_part1();
 
316
        case 2:
 
317
                return samsung_get_base_gpio_part2();
 
318
        case 3:
 
319
                return samsung_get_base_gpio_part3();
 
320
        case 4:
 
321
                return samsung_get_base_gpio_part4();
 
322
        default:
 
323
                return 0;
 
324
        }
 
325
}
 
326
#endif
 
327
 
 
328
/* Pin configurations */
 
329
#define GPIO_INPUT      0x0
 
330
#define GPIO_OUTPUT     0x1
 
331
#define GPIO_IRQ        0xf
 
332
#define GPIO_FUNC(x)    (x)
 
333
 
 
334
/* Pull mode */
 
335
#define GPIO_PULL_NONE  0x0
 
336
#define GPIO_PULL_DOWN  0x1
 
337
#define GPIO_PULL_UP    0x3
 
338
 
 
339
/* Drive Strength level */
 
340
#define GPIO_DRV_1X     0x0
 
341
#define GPIO_DRV_3X     0x1
 
342
#define GPIO_DRV_2X     0x2
 
343
#define GPIO_DRV_4X     0x3
 
344
#define GPIO_DRV_FAST   0x0
 
345
#define GPIO_DRV_SLOW   0x1
 
346
#endif