1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
|
/*
* Copyright (C) ST-Ericsson SA 2012
*
* Author: Patrice Chotard <patrice.chotard@stericsson.com> for ST-Ericsson.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/kernel.h>
#include <linux/gpio.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/mfd/abx500/ab8500.h>
#include "pinctrl-abx500.h"
/* All the pins that can be used for GPIO and some other functions */
#define ABX500_GPIO(offset) (offset)
#define AB8500_PIN_T10 ABX500_GPIO(1)
#define AB8500_PIN_T9 ABX500_GPIO(2)
#define AB8500_PIN_U9 ABX500_GPIO(3)
#define AB8500_PIN_W2 ABX500_GPIO(4)
/* hole */
#define AB8500_PIN_Y18 ABX500_GPIO(6)
#define AB8500_PIN_AA20 ABX500_GPIO(7)
#define AB8500_PIN_W18 ABX500_GPIO(8)
#define AB8500_PIN_AA19 ABX500_GPIO(9)
#define AB8500_PIN_U17 ABX500_GPIO(10)
#define AB8500_PIN_AA18 ABX500_GPIO(11)
#define AB8500_PIN_U16 ABX500_GPIO(12)
#define AB8500_PIN_W17 ABX500_GPIO(13)
#define AB8500_PIN_F14 ABX500_GPIO(14)
#define AB8500_PIN_B17 ABX500_GPIO(15)
#define AB8500_PIN_F15 ABX500_GPIO(16)
#define AB8500_PIN_P5 ABX500_GPIO(17)
#define AB8500_PIN_R5 ABX500_GPIO(18)
#define AB8500_PIN_U5 ABX500_GPIO(19)
#define AB8500_PIN_T5 ABX500_GPIO(20)
#define AB8500_PIN_H19 ABX500_GPIO(21)
#define AB8500_PIN_G20 ABX500_GPIO(22)
#define AB8500_PIN_G19 ABX500_GPIO(23)
#define AB8500_PIN_T14 ABX500_GPIO(24)
#define AB8500_PIN_R16 ABX500_GPIO(25)
#define AB8500_PIN_M16 ABX500_GPIO(26)
#define AB8500_PIN_J6 ABX500_GPIO(27)
#define AB8500_PIN_K6 ABX500_GPIO(28)
#define AB8500_PIN_G6 ABX500_GPIO(29)
#define AB8500_PIN_H6 ABX500_GPIO(30)
#define AB8500_PIN_F5 ABX500_GPIO(31)
#define AB8500_PIN_G5 ABX500_GPIO(32)
/* hole */
#define AB8500_PIN_R17 ABX500_GPIO(34)
#define AB8500_PIN_W15 ABX500_GPIO(35)
#define AB8500_PIN_A17 ABX500_GPIO(36)
#define AB8500_PIN_E15 ABX500_GPIO(37)
#define AB8500_PIN_C17 ABX500_GPIO(38)
#define AB8500_PIN_E16 ABX500_GPIO(39)
#define AB8500_PIN_T19 ABX500_GPIO(40)
#define AB8500_PIN_U19 ABX500_GPIO(41)
#define AB8500_PIN_U2 ABX500_GPIO(42)
/* indicates the highest GPIO number */
#define AB8500_GPIO_MAX_NUMBER 42
/*
* The names of the pins are denoted by GPIO number and ball name, even
* though they can be used for other things than GPIO, this is the first
* column in the table of the data sheet and often used on schematics and
* such.
*/
static const struct pinctrl_pin_desc ab8500_pins[] = {
PINCTRL_PIN(AB8500_PIN_T10, "GPIO1_T10"),
PINCTRL_PIN(AB8500_PIN_T9, "GPIO2_T9"),
PINCTRL_PIN(AB8500_PIN_U9, "GPIO3_U9"),
PINCTRL_PIN(AB8500_PIN_W2, "GPIO4_W2"),
/* hole */
PINCTRL_PIN(AB8500_PIN_Y18, "GPIO6_Y18"),
PINCTRL_PIN(AB8500_PIN_AA20, "GPIO7_AA20"),
PINCTRL_PIN(AB8500_PIN_W18, "GPIO8_W18"),
PINCTRL_PIN(AB8500_PIN_AA19, "GPIO9_AA19"),
PINCTRL_PIN(AB8500_PIN_U17, "GPIO10_U17"),
PINCTRL_PIN(AB8500_PIN_AA18, "GPIO11_AA18"),
PINCTRL_PIN(AB8500_PIN_U16, "GPIO12_U16"),
PINCTRL_PIN(AB8500_PIN_W17, "GPIO13_W17"),
PINCTRL_PIN(AB8500_PIN_F14, "GPIO14_F14"),
PINCTRL_PIN(AB8500_PIN_B17, "GPIO15_B17"),
PINCTRL_PIN(AB8500_PIN_F15, "GPIO16_F15"),
PINCTRL_PIN(AB8500_PIN_P5, "GPIO17_P5"),
PINCTRL_PIN(AB8500_PIN_R5, "GPIO18_R5"),
PINCTRL_PIN(AB8500_PIN_U5, "GPIO19_U5"),
PINCTRL_PIN(AB8500_PIN_T5, "GPIO20_T5"),
PINCTRL_PIN(AB8500_PIN_H19, "GPIO21_H19"),
PINCTRL_PIN(AB8500_PIN_G20, "GPIO22_G20"),
PINCTRL_PIN(AB8500_PIN_G19, "GPIO23_G19"),
PINCTRL_PIN(AB8500_PIN_T14, "GPIO24_T14"),
PINCTRL_PIN(AB8500_PIN_R16, "GPIO25_R16"),
PINCTRL_PIN(AB8500_PIN_M16, "GPIO26_M16"),
PINCTRL_PIN(AB8500_PIN_J6, "GPIO27_J6"),
PINCTRL_PIN(AB8500_PIN_K6, "GPIO28_K6"),
PINCTRL_PIN(AB8500_PIN_G6, "GPIO29_G6"),
PINCTRL_PIN(AB8500_PIN_H6, "GPIO30_H6"),
PINCTRL_PIN(AB8500_PIN_F5, "GPIO31_F5"),
PINCTRL_PIN(AB8500_PIN_G5, "GPIO32_G5"),
/* hole */
PINCTRL_PIN(AB8500_PIN_R17, "GPIO34_R17"),
PINCTRL_PIN(AB8500_PIN_W15, "GPIO35_W15"),
PINCTRL_PIN(AB8500_PIN_A17, "GPIO36_A17"),
PINCTRL_PIN(AB8500_PIN_E15, "GPIO37_E15"),
PINCTRL_PIN(AB8500_PIN_C17, "GPIO38_C17"),
PINCTRL_PIN(AB8500_PIN_E16, "GPIO39_E16"),
PINCTRL_PIN(AB8500_PIN_T19, "GPIO40_T19"),
PINCTRL_PIN(AB8500_PIN_U19, "GPIO41_U19"),
PINCTRL_PIN(AB8500_PIN_U2, "GPIO42_U2"),
};
/*
* Maps local GPIO offsets to local pin numbers
*/
static const struct abx500_pinrange ab8500_pinranges[] = {
ABX500_PINRANGE(1, 4, ABX500_ALT_A),
ABX500_PINRANGE(6, 4, ABX500_ALT_A),
ABX500_PINRANGE(10, 4, ABX500_DEFAULT),
ABX500_PINRANGE(14, 12, ABX500_ALT_A),
ABX500_PINRANGE(26, 1, ABX500_DEFAULT),
ABX500_PINRANGE(27, 6, ABX500_ALT_A),
ABX500_PINRANGE(34, 1, ABX500_ALT_A),
ABX500_PINRANGE(35, 1, ABX500_DEFAULT),
ABX500_PINRANGE(36, 7, ABX500_ALT_A),
};
/*
* Read the pin group names like this:
* sysclkreq2_d_1 = first groups of pins for sysclkreq2 on default function
*
* The groups are arranged as sets per altfunction column, so we can
* mux in one group at a time by selecting the same altfunction for them
* all. When functions require pins on different altfunctions, you need
* to combine several groups.
*/
/* default column */
static const unsigned sysclkreq2_d_1_pins[] = { AB8500_PIN_T10 };
static const unsigned sysclkreq3_d_1_pins[] = { AB8500_PIN_T9 };
static const unsigned sysclkreq4_d_1_pins[] = { AB8500_PIN_U9 };
static const unsigned sysclkreq6_d_1_pins[] = { AB8500_PIN_W2 };
static const unsigned ycbcr0123_d_1_pins[] = { AB8500_PIN_Y18, AB8500_PIN_AA20,
AB8500_PIN_W18, AB8500_PIN_AA19};
static const unsigned gpio10_d_1_pins[] = { AB8500_PIN_U17 };
static const unsigned gpio11_d_1_pins[] = { AB8500_PIN_AA18 };
static const unsigned gpio12_d_1_pins[] = { AB8500_PIN_U16 };
static const unsigned gpio13_d_1_pins[] = { AB8500_PIN_W17 };
static const unsigned pwmout1_d_1_pins[] = { AB8500_PIN_F14 };
static const unsigned pwmout2_d_1_pins[] = { AB8500_PIN_B17 };
static const unsigned pwmout3_d_1_pins[] = { AB8500_PIN_F15 };
/* audio data interface 1*/
static const unsigned adi1_d_1_pins[] = { AB8500_PIN_P5, AB8500_PIN_R5,
AB8500_PIN_U5, AB8500_PIN_T5 };
/* USBUICC */
static const unsigned usbuicc_d_1_pins[] = { AB8500_PIN_H19, AB8500_PIN_G20,
AB8500_PIN_G19 };
static const unsigned sysclkreq7_d_1_pins[] = { AB8500_PIN_T14 };
static const unsigned sysclkreq8_d_1_pins[] = { AB8500_PIN_R16 };
static const unsigned gpio26_d_1_pins[] = { AB8500_PIN_M16 };
/* Digital microphone 1 and 2 */
static const unsigned dmic12_d_1_pins[] = { AB8500_PIN_J6, AB8500_PIN_K6 };
/* Digital microphone 3 and 4 */
static const unsigned dmic34_d_1_pins[] = { AB8500_PIN_G6, AB8500_PIN_H6 };
/* Digital microphone 5 and 6 */
static const unsigned dmic56_d_1_pins[] = { AB8500_PIN_F5, AB8500_PIN_G5 };
static const unsigned extcpena_d_1_pins[] = { AB8500_PIN_R17 };
static const unsigned gpio35_d_1_pins[] = { AB8500_PIN_W15 };
/* APE SPI */
static const unsigned apespi_d_1_pins[] = { AB8500_PIN_A17, AB8500_PIN_E15,
AB8500_PIN_C17, AB8500_PIN_E16};
/* modem SDA/SCL */
static const unsigned modsclsda_d_1_pins[] = { AB8500_PIN_T19, AB8500_PIN_U19 };
static const unsigned sysclkreq5_d_1_pins[] = { AB8500_PIN_U2 };
/* Altfunction A column */
static const unsigned gpio1_a_1_pins[] = { AB8500_PIN_T10 };
static const unsigned gpio2_a_1_pins[] = { AB8500_PIN_T9 };
static const unsigned gpio3_a_1_pins[] = { AB8500_PIN_U9 };
static const unsigned gpio4_a_1_pins[] = { AB8500_PIN_W2 };
static const unsigned gpio6_a_1_pins[] = { AB8500_PIN_Y18 };
static const unsigned gpio7_a_1_pins[] = { AB8500_PIN_AA20 };
static const unsigned gpio8_a_1_pins[] = { AB8500_PIN_W18 };
static const unsigned gpio9_a_1_pins[] = { AB8500_PIN_AA19 };
/* YCbCr4 YCbCr5 YCbCr6 YCbCr7*/
static const unsigned ycbcr4567_a_1_pins[] = { AB8500_PIN_U17, AB8500_PIN_AA18,
AB8500_PIN_U16, AB8500_PIN_W17};
static const unsigned gpio14_a_1_pins[] = { AB8500_PIN_F14 };
static const unsigned gpio15_a_1_pins[] = { AB8500_PIN_B17 };
static const unsigned gpio16_a_1_pins[] = { AB8500_PIN_F15 };
static const unsigned gpio17_a_1_pins[] = { AB8500_PIN_P5 };
static const unsigned gpio18_a_1_pins[] = { AB8500_PIN_R5 };
static const unsigned gpio19_a_1_pins[] = { AB8500_PIN_U5 };
static const unsigned gpio20_a_1_pins[] = { AB8500_PIN_T5 };
static const unsigned gpio21_a_1_pins[] = { AB8500_PIN_H19 };
static const unsigned gpio22_a_1_pins[] = { AB8500_PIN_G20 };
static const unsigned gpio23_a_1_pins[] = { AB8500_PIN_G19 };
static const unsigned gpio24_a_1_pins[] = { AB8500_PIN_T14 };
static const unsigned gpio25_a_1_pins[] = { AB8500_PIN_R16 };
static const unsigned gpio27_a_1_pins[] = {
|