blob: ecfc9733db7e583d25f29dd15d0395682a6a1a56 [file] [log] [blame]
Linus Walleij06351d12017-08-05 23:04:08 +02001/*
2 * Driver for the Gemini pin controller
3 *
4 * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org>
5 *
6 * This is a group-only pin controller.
7 */
8#include <linux/err.h>
9#include <linux/init.h>
10#include <linux/io.h>
11#include <linux/mfd/syscon.h>
12#include <linux/of.h>
13#include <linux/pinctrl/machine.h>
14#include <linux/pinctrl/pinctrl.h>
15#include <linux/pinctrl/pinmux.h>
Linus Walleij1c5b7f32017-10-28 15:37:18 +020016#include <linux/pinctrl/pinconf.h>
17#include <linux/pinctrl/pinconf-generic.h>
Linus Walleij06351d12017-08-05 23:04:08 +020018#include <linux/platform_device.h>
19#include <linux/slab.h>
20#include <linux/regmap.h>
21
22#include "pinctrl-utils.h"
23
24#define DRIVER_NAME "pinctrl-gemini"
25
26/**
Linus Walleij60ad4812017-10-28 15:37:19 +020027 * struct gemini_pin_conf - information about configuring a pin
28 * @pin: the pin number
29 * @reg: config register
30 * @mask: the bits affecting the configuration of the pin
31 */
32struct gemini_pin_conf {
33 unsigned int pin;
34 u32 reg;
35 u32 mask;
36};
37
38/**
39 * struct gemini_pmx - state holder for the gemini pin controller
Linus Walleij06351d12017-08-05 23:04:08 +020040 * @dev: a pointer back to containing device
41 * @virtbase: the offset to the controller in virtual memory
42 * @map: regmap to access registers
43 * @is_3512: whether the SoC/package is the 3512 variant
44 * @is_3516: whether the SoC/package is the 3516 variant
45 * @flash_pin: whether the flash pin (extended pins for parallel
46 * flash) is set
Linus Walleij60ad4812017-10-28 15:37:19 +020047 * @confs: pin config information
48 * @nconfs: number of pin config information items
Linus Walleij06351d12017-08-05 23:04:08 +020049 */
50struct gemini_pmx {
51 struct device *dev;
52 struct pinctrl_dev *pctl;
53 struct regmap *map;
54 bool is_3512;
55 bool is_3516;
56 bool flash_pin;
Linus Walleij60ad4812017-10-28 15:37:19 +020057 const struct gemini_pin_conf *confs;
58 unsigned int nconfs;
Linus Walleij06351d12017-08-05 23:04:08 +020059};
60
61/**
62 * struct gemini_pin_group - describes a Gemini pin group
63 * @name: the name of this specific pin group
64 * @pins: an array of discrete physical pins used in this group, taken
65 * from the driver-local pin enumeration space
66 * @num_pins: the number of pins in this group array, i.e. the number of
67 * elements in .pins so we can iterate over that array
68 * @mask: bits to clear to enable this when doing pin muxing
69 * @value: bits to set to enable this when doing pin muxing
70 */
71struct gemini_pin_group {
72 const char *name;
73 const unsigned int *pins;
74 const unsigned int num_pins;
75 u32 mask;
76 u32 value;
77};
78
Linus Walleij60ad4812017-10-28 15:37:19 +020079/* Some straight-forward control registers */
80#define GLOBAL_WORD_ID 0x00
81#define GLOBAL_STATUS 0x04
82#define GLOBAL_STATUS_FLPIN BIT(20)
83#define GLOBAL_GMAC_CTRL_SKEW 0x1c
84#define GLOBAL_GMAC0_DATA_SKEW 0x20
85#define GLOBAL_GMAC1_DATA_SKEW 0x24
Linus Walleij06351d12017-08-05 23:04:08 +020086/*
87 * Global Miscellaneous Control Register
88 * This register controls all Gemini pad/pin multiplexing
89 *
90 * It is a tricky register though:
91 * - For the bits named *_ENABLE, once you DISABLE something, it simply cannot
92 * be brought back online, so it means permanent disablement of the
93 * corresponding pads.
94 * - For the bits named *_DISABLE, once you enable something, it cannot be
95 * DISABLED again. So you select a flash configuration once, and then
96 * you are stuck with it.
97 */
Linus Walleij06351d12017-08-05 23:04:08 +020098#define GLOBAL_MISC_CTRL 0x30
Linus Walleij756a0242017-11-06 21:27:34 +010099#define GEMINI_GMAC_IOSEL_MASK GENMASK(28, 27)
100/* Not really used */
101#define GEMINI_GMAC_IOSEL_GMAC0_GMII BIT(28)
102/* Activated with GMAC1 */
103#define GEMINI_GMAC_IOSEL_GMAC0_GMAC1_RGMII BIT(27)
104/* This will be the default */
105#define GEMINI_GMAC_IOSEL_GMAC0_RGMII_GMAC1_GPIO2 0
Linus Walleij06351d12017-08-05 23:04:08 +0200106#define TVC_CLK_PAD_ENABLE BIT(20)
107#define PCI_CLK_PAD_ENABLE BIT(17)
108#define LPC_CLK_PAD_ENABLE BIT(16)
109#define TVC_PADS_ENABLE BIT(9)
110#define SSP_PADS_ENABLE BIT(8)
111#define LCD_PADS_ENABLE BIT(7)
112#define LPC_PADS_ENABLE BIT(6)
113#define PCI_PADS_ENABLE BIT(5)
114#define IDE_PADS_ENABLE BIT(4)
115#define DRAM_PADS_POWERDOWN BIT(3)
116#define NAND_PADS_DISABLE BIT(2)
117#define PFLASH_PADS_DISABLE BIT(1)
118#define SFLASH_PADS_DISABLE BIT(0)
Linus Walleij756a0242017-11-06 21:27:34 +0100119#define PADS_MASK (GENMASK(9, 0) | BIT(16) | BIT(17) | BIT(20) | BIT(27))
120#define PADS_MAXBIT 27
Linus Walleij06351d12017-08-05 23:04:08 +0200121
122/* Ordered by bit index */
123static const char * const gemini_padgroups[] = {
124 "serial flash",
125 "parallel flash",
126 "NAND flash",
127 "DRAM",
128 "IDE",
129 "PCI",
130 "LPC",
131 "LCD",
132 "SSP",
133 "TVC",
134 NULL, NULL, NULL, NULL, NULL, NULL,
135 "LPC CLK",
136 "PCI CLK",
137 NULL, NULL,
138 "TVC CLK",
139};
140
141static const struct pinctrl_pin_desc gemini_3512_pins[] = {
142 /* Row A */
143 PINCTRL_PIN(0, "A1 VREF CTRL"),
144 PINCTRL_PIN(1, "A2 VCC2IO CTRL"),
145 PINCTRL_PIN(2, "A3 DRAM CK"),
146 PINCTRL_PIN(3, "A4 DRAM CK N"),
147 PINCTRL_PIN(4, "A5 DRAM A5"),
148 PINCTRL_PIN(5, "A6 DRAM CKE"),
149 PINCTRL_PIN(6, "A7 DRAM DQ11"),
150 PINCTRL_PIN(7, "A8 DRAM DQ0"),
151 PINCTRL_PIN(8, "A9 DRAM DQ5"),
152 PINCTRL_PIN(9, "A10 DRAM DQ6"),
153 PINCTRL_PIN(10, "A11 DRAM DRAM VREF"),
154 PINCTRL_PIN(11, "A12 DRAM BA1"),
155 PINCTRL_PIN(12, "A13 DRAM A2"),
156 PINCTRL_PIN(13, "A14 PCI GNT1 N"),
157 PINCTRL_PIN(14, "A15 PCI REQ9 N"),
158 PINCTRL_PIN(15, "A16 PCI REQ2 N"),
159 PINCTRL_PIN(16, "A17 PCI REQ3 N"),
160 PINCTRL_PIN(17, "A18 PCI AD31"),
161 /* Row B */
162 PINCTRL_PIN(18, "B1 VCCK CTRL"),
163 PINCTRL_PIN(19, "B2 PWR EN"),
164 PINCTRL_PIN(20, "B3 RTC CLKI"),
165 PINCTRL_PIN(21, "B4 DRAM A4"),
166 PINCTRL_PIN(22, "B5 DRAM A6"),
167 PINCTRL_PIN(23, "B6 DRAM A12"),
168 PINCTRL_PIN(24, "B7 DRAM DQS1"),
169 PINCTRL_PIN(25, "B8 DRAM DQ15"),
170 PINCTRL_PIN(26, "B9 DRAM DQ4"),
171 PINCTRL_PIN(27, "B10 DRAM DQS0"),
172 PINCTRL_PIN(28, "B11 DRAM WE N"),
173 PINCTRL_PIN(29, "B12 DRAM A10"),
174 PINCTRL_PIN(30, "B13 DRAM A3"),
175 PINCTRL_PIN(31, "B14 PCI GNT0 N"),
176 PINCTRL_PIN(32, "B15 PCI GNT3 N"),
177 PINCTRL_PIN(33, "B16 PCI REQ1 N"),
178 PINCTRL_PIN(34, "B17 PCI AD30"),
179 PINCTRL_PIN(35, "B18 PCI AD29"),
180 /* Row C */
181 PINCTRL_PIN(36, "C1 CIR RST N"), /* REALLY? CIR is not in 3512... */
182 PINCTRL_PIN(37, "C2 XTALI"),
183 PINCTRL_PIN(38, "C3 PWR BTN"),
184 PINCTRL_PIN(39, "C4 RTC CLKO"),
185 PINCTRL_PIN(40, "C5 DRAM A7"),
186 PINCTRL_PIN(41, "C6 DRAM A11"),
187 PINCTRL_PIN(42, "C7 DRAM DQ10"),
188 PINCTRL_PIN(43, "C8 DRAM DQ14"),
189 PINCTRL_PIN(44, "C9 DRAM DQ3"),
190 PINCTRL_PIN(45, "C10 DRAM DQ7"),
191 PINCTRL_PIN(46, "C11 DRAM CAS N"),
192 PINCTRL_PIN(47, "C12 DRAM A0"),
193 PINCTRL_PIN(48, "C13 PCI INT0 N"),
194 PINCTRL_PIN(49, "C14 EXT RESET N"),
195 PINCTRL_PIN(50, "C15 PCI GNT2 N"),
196 PINCTRL_PIN(51, "C16 PCI AD28"),
197 PINCTRL_PIN(52, "C17 PCI AD27"),
198 PINCTRL_PIN(53, "C18 PCI AD26"),
199 /* Row D */
200 PINCTRL_PIN(54, "D1 AVCCKHA"),
201 PINCTRL_PIN(55, "D2 AGNDIOHA"),
202 PINCTRL_PIN(56, "D3 XTALO"),
203 PINCTRL_PIN(57, "D4 AVCC3IOHA"),
204 PINCTRL_PIN(58, "D5 DRAM A8"),
205 PINCTRL_PIN(59, "D6 DRAM A9"),
206 PINCTRL_PIN(60, "D7 DRAM DQ9"),
207 PINCTRL_PIN(61, "D8 DRAM DQ13"),
208 PINCTRL_PIN(62, "D9 DRAM DQ2"),
209 PINCTRL_PIN(63, "D10 DRAM A13"),
210 PINCTRL_PIN(64, "D11 DRAM RAS N"),
211 PINCTRL_PIN(65, "D12 DRAM A1"),
212 PINCTRL_PIN(66, "D13 PCI INTC N"),
213 PINCTRL_PIN(67, "D14 PCI CLK"),
214 PINCTRL_PIN(68, "D15 PCI AD25"),
215 PINCTRL_PIN(69, "D16 PCI AD24"),
216 PINCTRL_PIN(70, "D17 PCI CBE3 N"),
217 PINCTRL_PIN(71, "D18 PCI AD23"),
218 /* Row E */
219 PINCTRL_PIN(72, "E1 AVCC3IOHA"),
220 PINCTRL_PIN(73, "E2 EBG"),
221 PINCTRL_PIN(74, "E3 AVCC3IOHB"),
222 PINCTRL_PIN(75, "E4 REXT"),
223 PINCTRL_PIN(76, "E5 GND"),
224 PINCTRL_PIN(77, "E6 DRAM DQM1"),
225 PINCTRL_PIN(78, "E7 DRAM DQ8"),
226 PINCTRL_PIN(79, "E8 DRAM DQ12"),
227 PINCTRL_PIN(80, "E9 DRAM DQ1"),
228 PINCTRL_PIN(81, "E10 DRAM DQM0"),
229 PINCTRL_PIN(82, "E11 DRAM BA0"),
230 PINCTRL_PIN(83, "E12 PCI INTA N"),
231 PINCTRL_PIN(84, "E13 PCI INTB N"),
232 PINCTRL_PIN(85, "E14 GND"),
233 PINCTRL_PIN(86, "E15 PCI AD22"),
234 PINCTRL_PIN(87, "E16 PCI AD21"),
235 PINCTRL_PIN(88, "E17 PCI AD20"),
236 PINCTRL_PIN(89, "E18 PCI AD19"),
237 /* Row F */
238 PINCTRL_PIN(90, "F1 SATA0 RXDP"),
239 PINCTRL_PIN(91, "F2 SATA0 RXDN"),
240 PINCTRL_PIN(92, "F3 AGNDK 0"),
241 PINCTRL_PIN(93, "F4 AVCC3 S"),
242 PINCTRL_PIN(94, "F5 AVCCK P"),
243 PINCTRL_PIN(95, "F6 GND"),
244 PINCTRL_PIN(96, "F7 VCC2IOHA 2"),
245 PINCTRL_PIN(97, "F8 VCC2IOHA 2"),
246 PINCTRL_PIN(98, "F9 V1"),
247 PINCTRL_PIN(99, "F10 V1"),
248 PINCTRL_PIN(100, "F11 VCC2IOHA 2"),
249 PINCTRL_PIN(101, "F12 VCC2IOHA 2"),
250 PINCTRL_PIN(102, "F13 GND"),
251 PINCTRL_PIN(103, "F14 PCI AD18"),
252 PINCTRL_PIN(104, "F15 PCI AD17"),
253 PINCTRL_PIN(105, "F16 PCI AD16"),
254 PINCTRL_PIN(106, "F17 PCI CBE2 N"),
255 PINCTRL_PIN(107, "F18 PCI FRAME N"),
256 /* Row G */
257 PINCTRL_PIN(108, "G1 SATA0 TXDP"),
258 PINCTRL_PIN(109, "G2 SATA0 TXDN"),
259 PINCTRL_PIN(110, "G3 AGNDK 1"),
260 PINCTRL_PIN(111, "G4 AVCCK 0"),
261 PINCTRL_PIN(112, "G5 TEST CLKOUT"),
262 PINCTRL_PIN(113, "G6 AGND"),
263 PINCTRL_PIN(114, "G7 GND"),
264 PINCTRL_PIN(115, "G8 VCC2IOHA 2"),
265 PINCTRL_PIN(116, "G9 V1"),
266 PINCTRL_PIN(117, "G10 V1"),
267 PINCTRL_PIN(118, "G11 VCC2IOHA 2"),
268 PINCTRL_PIN(119, "G12 GND"),
269 PINCTRL_PIN(120, "G13 VCC3IOHA"),
270 PINCTRL_PIN(121, "G14 PCI IRDY N"),
271 PINCTRL_PIN(122, "G15 PCI TRDY N"),
272 PINCTRL_PIN(123, "G16 PCI DEVSEL N"),
273 PINCTRL_PIN(124, "G17 PCI STOP N"),
274 PINCTRL_PIN(125, "G18 PCI PAR"),
275 /* Row H */
276 PINCTRL_PIN(126, "H1 SATA1 TXDP"),
277 PINCTRL_PIN(127, "H2 SATA1 TXDN"),
278 PINCTRL_PIN(128, "H3 AGNDK 2"),
279 PINCTRL_PIN(129, "H4 AVCCK 1"),
280 PINCTRL_PIN(130, "H5 AVCCK S"),
281 PINCTRL_PIN(131, "H6 AVCCKHB"),
282 PINCTRL_PIN(132, "H7 AGND"),
283 PINCTRL_PIN(133, "H8 GND"),
284 PINCTRL_PIN(134, "H9 GND"),
285 PINCTRL_PIN(135, "H10 GND"),
286 PINCTRL_PIN(136, "H11 GND"),
287 PINCTRL_PIN(137, "H12 VCC3IOHA"),
288 PINCTRL_PIN(138, "H13 VCC3IOHA"),
289 PINCTRL_PIN(139, "H14 PCI CBE1 N"),
290 PINCTRL_PIN(140, "H15 PCI AD15"),
291 PINCTRL_PIN(141, "H16 PCI AD14"),
292 PINCTRL_PIN(142, "H17 PCI AD13"),
293 PINCTRL_PIN(143, "H18 PCI AD12"),
294 /* Row J (for some reason I is skipped) */
295 PINCTRL_PIN(144, "J1 SATA1 RXDP"),
296 PINCTRL_PIN(145, "J2 SATA1 RXDN"),
297 PINCTRL_PIN(146, "J3 AGNDK 3"),
298 PINCTRL_PIN(147, "J4 AVCCK 2"),
299 PINCTRL_PIN(148, "J5 IDE DA1"),
300 PINCTRL_PIN(149, "J6 V1"),
301 PINCTRL_PIN(150, "J7 V1"),
302 PINCTRL_PIN(151, "J8 GND"),
303 PINCTRL_PIN(152, "J9 GND"),
304 PINCTRL_PIN(153, "J10 GND"),
305 PINCTRL_PIN(154, "J11 GND"),
306 PINCTRL_PIN(155, "J12 V1"),
307 PINCTRL_PIN(156, "J13 V1"),
308 PINCTRL_PIN(157, "J14 PCI AD11"),
309 PINCTRL_PIN(158, "J15 PCI AD10"),
310 PINCTRL_PIN(159, "J16 PCI AD9"),
311 PINCTRL_PIN(160, "J17 PCI AD8"),
312 PINCTRL_PIN(161, "J18 PCI CBE0 N"),
313 /* Row K */
314 PINCTRL_PIN(162, "K1 IDE CS1 N"),
315 PINCTRL_PIN(163, "K2 IDE CS0 N"),
316 PINCTRL_PIN(164, "K3 AVCCK 3"),
317 PINCTRL_PIN(165, "K4 IDE DA2"),
318 PINCTRL_PIN(166, "K5 IDE DA0"),
319 PINCTRL_PIN(167, "K6 V1"),
320 PINCTRL_PIN(168, "K7 V1"),
321 PINCTRL_PIN(169, "K8 GND"),
322 PINCTRL_PIN(170, "K9 GND"),
323 PINCTRL_PIN(171, "K10 GND"),
324 PINCTRL_PIN(172, "K11 GND"),
325 PINCTRL_PIN(173, "K12 V1"),
326 PINCTRL_PIN(174, "K13 V1"),
327 PINCTRL_PIN(175, "K14 PCI AD3"),
328 PINCTRL_PIN(176, "K15 PCI AD4"),
329 PINCTRL_PIN(177, "K16 PCI AD5"),
330 PINCTRL_PIN(178, "K17 PCI AD6"),
331 PINCTRL_PIN(179, "K18 PCI AD7"),
332 /* Row L */
333 PINCTRL_PIN(180, "L1 IDE INTRQ"),
334 PINCTRL_PIN(181, "L2 IDE DMACK N"),
335 PINCTRL_PIN(182, "L3 IDE IORDY"),
336 PINCTRL_PIN(183, "L4 IDE DIOR N"),
337 PINCTRL_PIN(184, "L5 IDE DIOW N"),
338 PINCTRL_PIN(185, "L6 VCC3IOHA"),
339 PINCTRL_PIN(186, "L7 VCC3IOHA"),
340 PINCTRL_PIN(187, "L8 GND"),
341 PINCTRL_PIN(188, "L9 GND"),
342 PINCTRL_PIN(189, "L10 GND"),
343 PINCTRL_PIN(190, "L11 GND"),
344 PINCTRL_PIN(191, "L12 VCC3IOHA"),
345 PINCTRL_PIN(192, "L13 VCC3IOHA"),
346 PINCTRL_PIN(193, "L14 GPIO0 30"),
347 PINCTRL_PIN(194, "L15 GPIO0 31"),
348 PINCTRL_PIN(195, "L16 PCI AD0"),
349 PINCTRL_PIN(196, "L17 PCI AD1"),
350 PINCTRL_PIN(197, "L18 PCI AD2"),
351 /* Row M */
352 PINCTRL_PIN(198, "M1 IDE DMARQ"),
353 PINCTRL_PIN(199, "M2 IDE DD15"),
354 PINCTRL_PIN(200, "M3 IDE DD0"),
355 PINCTRL_PIN(201, "M4 IDE DD14"),
356 PINCTRL_PIN(202, "M5 IDE DD1"),
357 PINCTRL_PIN(203, "M6 VCC3IOHA"),
358 PINCTRL_PIN(204, "M7 GND"),
359 PINCTRL_PIN(205, "M8 VCC2IOHA 1"),
360 PINCTRL_PIN(206, "M9 V1"),
361 PINCTRL_PIN(207, "M10 V1"),
362 PINCTRL_PIN(208, "M11 VCC3IOHA"),
363 PINCTRL_PIN(209, "M12 GND"),
364 PINCTRL_PIN(210, "M13 VCC3IOHA"),
365 PINCTRL_PIN(211, "M14 GPIO0 25"),
366 PINCTRL_PIN(212, "M15 GPIO0 26"),
367 PINCTRL_PIN(213, "M16 GPIO0 27"),
368 PINCTRL_PIN(214, "M17 GPIO0 28"),
369 PINCTRL_PIN(215, "M18 GPIO0 29"),
370 /* Row N */
371 PINCTRL_PIN(216, "N1 IDE DD13"),
372 PINCTRL_PIN(217, "N2 IDE DD2"),
373 PINCTRL_PIN(218, "N3 IDE DD12"),
374 PINCTRL_PIN(219, "N4 IDE DD3"),
375 PINCTRL_PIN(220, "N5 IDE DD11"),
376 PINCTRL_PIN(221, "N6 GND"),
377 PINCTRL_PIN(222, "N7 VCC2IOHA 1"),
378 PINCTRL_PIN(223, "N8 VCC2IOHA 1"),
379 PINCTRL_PIN(224, "N9 V1"),
380 PINCTRL_PIN(225, "N10 V1"),
381 PINCTRL_PIN(226, "N11 VCC3IOHA"),
382 PINCTRL_PIN(227, "N12 VCC3IOHA"),
383 PINCTRL_PIN(228, "N13 GND"),
384 PINCTRL_PIN(229, "N14 GPIO0 20"),
385 PINCTRL_PIN(230, "N15 GPIO0 21"),
386 PINCTRL_PIN(231, "N16 GPIO0 22"),
387 PINCTRL_PIN(232, "N17 GPIO0 23"),
388 PINCTRL_PIN(233, "N18 GPIO0 24"),
389 /* Row P (for some reason O is skipped) */
390 PINCTRL_PIN(234, "P1 IDE DD4"),
391 PINCTRL_PIN(235, "P2 IDE DD10"),
392 PINCTRL_PIN(236, "P3 IDE DD5"),
393 PINCTRL_PIN(237, "P4 IDE DD9"),
394 PINCTRL_PIN(238, "P5 GND"),
395 PINCTRL_PIN(239, "P6 USB XSCO"),
396 PINCTRL_PIN(240, "P7 GMAC0 TXD3"),
397 PINCTRL_PIN(241, "P8 GMAC0 TXEN"),
398 PINCTRL_PIN(242, "P9 GMAC0 RXD2"),
399 PINCTRL_PIN(243, "P10 GMAC1 TXC"),
400 PINCTRL_PIN(244, "P11 GMAC1 RXD1"),
401 PINCTRL_PIN(245, "P12 MODE SEL 1"),
402 PINCTRL_PIN(246, "P13 GPIO1 28"),
403 PINCTRL_PIN(247, "P14 GND"),
404 PINCTRL_PIN(248, "P15 GPIO0 5"),
405 PINCTRL_PIN(249, "P16 GPIO0 17"),
406 PINCTRL_PIN(250, "P17 GPIO0 18"),
407 PINCTRL_PIN(251, "P18 GPIO0 19"),
408 /* Row R (for some reason Q us skipped) */
409 PINCTRL_PIN(252, "R1 IDE DD6"),
410 PINCTRL_PIN(253, "R2 IDE DD8"),
411 PINCTRL_PIN(254, "R3 IDE DD7"),
412 PINCTRL_PIN(255, "R4 IDE RESET N"),
413 PINCTRL_PIN(256, "R5 ICE0 DBGACK"),
414 PINCTRL_PIN(257, "R6 USB XSCI"),
415 PINCTRL_PIN(258, "R7 GMAC0 TXD2"),
416 PINCTRL_PIN(259, "R8 GMAC0 RXDV"),
417 PINCTRL_PIN(260, "R9 GMAC0 RXD3"),
418 PINCTRL_PIN(261, "R10 GMAC1 TXD0"),
419 PINCTRL_PIN(262, "R11 GMAC1 RXD0"),
420 PINCTRL_PIN(263, "R12 MODE SEL 0"),
421 PINCTRL_PIN(264, "R13 MODE SEL 3"),
422 PINCTRL_PIN(265, "R14 GPIO0 0"),
423 PINCTRL_PIN(266, "R15 GPIO0 4"),
424 PINCTRL_PIN(267, "R16 GPIO0 9"),
425 PINCTRL_PIN(268, "R17 GPIO0 15"),
426 PINCTRL_PIN(269, "R18 GPIO0 16"),
427 /* Row T (for some reason S is skipped) */
428 PINCTRL_PIN(270, "T1 ICE0 DBGRQ"),
429 PINCTRL_PIN(271, "T2 ICE0 IDO"),
430 PINCTRL_PIN(272, "T3 ICE0 ICK"),
431 PINCTRL_PIN(273, "T4 ICE0 IMS"),
432 PINCTRL_PIN(274, "T5 ICE0 IDI"),
433 PINCTRL_PIN(275, "T6 USB RREF"),
434 PINCTRL_PIN(276, "T7 GMAC0 TXD1"),
435 PINCTRL_PIN(277, "T8 GMAC0 RXC"),
436 PINCTRL_PIN(278, "T9 GMAC0 CRS"),
437 PINCTRL_PIN(279, "T10 GMAC1 TXD1"),
438 PINCTRL_PIN(280, "T11 GMAC1 RXC"),
439 PINCTRL_PIN(281, "T12 GMAC1 CRS"),
440 PINCTRL_PIN(282, "T13 EXT CLK"),
441 PINCTRL_PIN(283, "T14 GPIO1 31"),
442 PINCTRL_PIN(284, "T15 GPIO0 3"),
443 PINCTRL_PIN(285, "T16 GPIO0 8"),
444 PINCTRL_PIN(286, "T17 GPIO0 12"),
445 PINCTRL_PIN(287, "T18 GPIO0 14"),
446 /* Row U */
447 PINCTRL_PIN(288, "U1 ICE0 IRST N"),
448 PINCTRL_PIN(289, "U2 USB0 VCCHSRT"),
449 PINCTRL_PIN(290, "U3 USB0 DP"),
450 PINCTRL_PIN(291, "U4 USB VCCA U20"),
451 PINCTRL_PIN(292, "U5 USB1 DP"),
452 PINCTRL_PIN(293, "U6 USB1 GNDHSRT 1"),
453 PINCTRL_PIN(294, "U7 GMAC0 TXD0"),
454 PINCTRL_PIN(295, "U8 GMAC0 RXD0"),
455 PINCTRL_PIN(296, "U9 GMAC1 COL"),
456 PINCTRL_PIN(297, "U10 GMAC1 TXD2"),
457 PINCTRL_PIN(298, "U11 GMAC1 RXDV"),
458 PINCTRL_PIN(299, "U12 GMAC1 RXD3"),
459 PINCTRL_PIN(300, "U13 MODE SEL 2"),
460 PINCTRL_PIN(301, "U14 GPIO1 30"),
461 PINCTRL_PIN(302, "U15 GPIO0 2"),
462 PINCTRL_PIN(303, "U16 GPIO0 7"),
463 PINCTRL_PIN(304, "U17 GPIO0 11"),
464 PINCTRL_PIN(305, "U18 GPIO0 13"),
465 /* Row V */
466 PINCTRL_PIN(306, "V1 USB0 GNDHSRT"),
467 PINCTRL_PIN(307, "V2 USB0 DM"),
468 PINCTRL_PIN(308, "V3 USB GNDA U20"),
469 PINCTRL_PIN(309, "V4 USB1 DM"),
470 PINCTRL_PIN(310, "V5 USB1 VCCHSRT1"),
471 PINCTRL_PIN(311, "V6 GMAC0 COL"),
472 PINCTRL_PIN(312, "V7 GMAC0 TXC"),
473 PINCTRL_PIN(313, "V8 GMAC0 RXD1"),
474 PINCTRL_PIN(314, "V9 REF CLK"),
475 PINCTRL_PIN(315, "V10 GMAC1 TXD3"),
476 PINCTRL_PIN(316, "V11 GMAC1 TXEN"),
477 PINCTRL_PIN(317, "V12 GMAC1 RXD2"),
478 PINCTRL_PIN(318, "V13 M30 CLK"),
479 PINCTRL_PIN(319, "V14 GPIO1 29"),
480 PINCTRL_PIN(320, "V15 GPIO0 1"),
481 PINCTRL_PIN(321, "V16 GPIO0 6"),
482 PINCTRL_PIN(322, "V17 GPIO0 10"),
483 PINCTRL_PIN(323, "V18 SYS RESET N"),
484};
485
486
487/* Digital ground */
488static const unsigned int gnd_3512_pins[] = {
489 76, 85, 95, 102, 114, 119, 133, 134, 135, 136, 151, 152, 153, 154, 169,
490 170, 171, 172, 187, 188, 189, 190, 204, 209, 221, 228, 238, 247
491};
492
493static const unsigned int dram_3512_pins[] = {
494 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 21, 22, 23, 24, 25, 26, 27, 28, 29,
495 30, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 64, 65, 77,
496 78, 79, 80, 81, 82
497};
498
499static const unsigned int rtc_3512_pins[] = { 57, 20, 39 };
500
501static const unsigned int power_3512_pins[] = { 19, 38, 36, 55, 37, 56, 54, 72 };
502
503static const unsigned int system_3512_pins[] = {
504 318, 264, 300, 245, 263, 282, 314, 323, 49,
505};
506
507static const unsigned int vcontrol_3512_pins[] = { 18, 0, 1 };
508
509static const unsigned int ice_3512_pins[] = { 256, 270, 271, 272, 273, 274, 288 };
510
511static const unsigned int ide_3512_pins[] = {
512 162, 163, 165, 166, 148, 180, 181, 182, 183, 184, 198, 199, 200, 201, 202,
513 216, 217, 218, 219, 220, 234, 235, 236, 237, 252, 253, 254, 255
514};
515
516static const unsigned int sata_3512_pins[] = {
517 75, 74, 73, 93, 94, 131, 112, 130, 92, 91, 90, 111, 110, 109, 108, 129,
518 128, 127, 126, 147, 146, 145, 144, 164
519};
520
521static const unsigned int usb_3512_pins[] = {
522 306, 289, 307, 290, 239, 257, 275, 308, 291, 309, 292, 310, 293
523};
524
525/* GMII, ethernet pins */
Linus Walleij756a0242017-11-06 21:27:34 +0100526static const unsigned int gmii_gmac0_3512_pins[] = {
527 240, 241, 242, 258, 259, 260, 276, 277, 278, 294, 295, 311, 312, 313
528};
529
530static const unsigned int gmii_gmac1_3512_pins[] = {
531 243, 244, 261, 262, 279, 280, 281, 296, 297, 298, 299, 315, 316, 317
Linus Walleij06351d12017-08-05 23:04:08 +0200532};
533
534static const unsigned int pci_3512_pins[] = {
535 13, 14, 15, 16, 17, 31, 32, 33, 34, 35, 48, 50, 51, 52, 53, 66, 67, 68, 69,
536 70, 71, 83, 84, 86, 87, 88, 89, 103, 104, 105, 106, 107, 121, 122, 123,
537 124, 125, 139, 140, 141, 142, 143, 157, 158, 159, 160, 161, 175, 176, 177,
538 178, 179, 195, 196, 197
539};
540
541/*
542 * Apparently the LPC interface is using the PCICLK for the clocking so
543 * PCI needs to be active at the same time.
544 */
545static const unsigned int lpc_3512_pins[] = {
546 285, /* LPC_LAD[0] */
547 304, /* LPC_SERIRQ */
548 286, /* LPC_LAD[2] */
549 305, /* LPC_LFRAME# */
550 287, /* LPC_LAD[3] */
551 268, /* LPC_LAD[1] */
552};
553
554/* Character LCD */
555static const unsigned int lcd_3512_pins[] = {
556 262, 244, 317, 299, 246, 319, 301, 283, 269, 233, 211
557};
558
559static const unsigned int ssp_3512_pins[] = {
560 285, /* SSP_97RST# SSP AC97 Reset, active low */
561 304, /* SSP_FSC */
562 286, /* SSP_ECLK */
563 305, /* SSP_TXD */
564 287, /* SSP_RXD */
565 268, /* SSP_SCLK */
566};
567
568static const unsigned int uart_rxtx_3512_pins[] = {
569 267, /* UART_SIN serial input, RX */
570 322, /* UART_SOUT serial output, TX */
571};
572
573static const unsigned int uart_modem_3512_pins[] = {
574 285, /* UART_NDCD DCD carrier detect */
575 304, /* UART_NDTR DTR data terminal ready */
576 286, /* UART_NDSR DSR data set ready */
577 305, /* UART_NRTS RTS request to send */
578 287, /* UART_NCTS CTS clear to send */
579 268, /* UART_NRI RI ring indicator */
580};
581
582static const unsigned int tvc_3512_pins[] = {
583 246, /* TVC_DATA[0] */
584 319, /* TVC_DATA[1] */
585 301, /* TVC_DATA[2] */
586 283, /* TVC_DATA[3] */
587 265, /* TVC_CLK */
588 320, /* TVC_DATA[4] */
589 302, /* TVC_DATA[5] */
590 284, /* TVC_DATA[6] */
591 266, /* TVC_DATA[7] */
592};
593
594/* NAND flash pins */
595static const unsigned int nflash_3512_pins[] = {
596 199, 200, 201, 202, 216, 217, 218, 219, 220, 234, 235, 236, 237, 252,
597 253, 254, 249, 250, 232, 233, 211, 193, 194
598};
599
600/* Parallel (NOR) flash pins, D[0-15], A[16-25], CE0, CE1, RB, WE, OE, ALE */
601static const unsigned int pflash_3512_pins[] = {
602 162, 163, 165, 166, 148, 199, 200, 201, 202, 216, 217, 218, 219, 220,
603 234, 235, 236, 237, 252, 253, 254, 251, 229, 232, 233, 211, 212, 213,
604 214, 215, 193, 194
605};
606
607/*
608 * The parallel flash can be set up in a 26-bit address bus mode exposing
609 * A[0-15] (A[15] takes the place of ALE), but it has the
610 * side effect of stealing pins from GMAC1 and TVC so these blocks cannot be
611 * used at the same time.
612 */
613static const unsigned int pflash_3512_pins_extended[] = {
614 162, 163, 165, 166, 148, 199, 200, 201, 202, 216, 217, 218, 219, 220,
615 234, 235, 236, 237, 252, 253, 254, 251, 229, 232, 233, 211, 212, 213,
616 214, 215, 193, 194,
617 /* The extra pins */
618 296, 315, 297, 279, 261, 243, 316, 298, 280, 262, 244, 317, 299, 281,
619 265,
620};
621
622/* Serial flash pins CE0, CE1, DI, DO, CK */
623static const unsigned int sflash_3512_pins[] = { 230, 231, 232, 233, 211 };
624
625/* The GPIO0A (0) pin overlap with TVC and extended parallel flash */
626static const unsigned int gpio0a_3512_pins[] = { 265 };
627
628/* The GPIO0B (1-4) pins overlap with TVC and ICE */
629static const unsigned int gpio0b_3512_pins[] = { 320, 302, 284, 266 };
630
631/* The GPIO0C (5-7) pins overlap with ICE */
632static const unsigned int gpio0c_3512_pins[] = { 248, 321, 303 };
633
634/* The GPIO0D (9,10) pins overlap with UART RX/TX */
635static const unsigned int gpio0d_3512_pins[] = { 267, 322 };
636
637/* The GPIO0E (8,11-15) pins overlap with LPC, UART modem pins, SSP */
638static const unsigned int gpio0e_3512_pins[] = { 285, 304, 286, 305, 287, 268 };
639
640/* The GPIO0F (16) pins overlap with LCD */
641static const unsigned int gpio0f_3512_pins[] = { 269 };
642
643/* The GPIO0G (17,18) pins overlap with NAND flash CE0, CE1 */
644static const unsigned int gpio0g_3512_pins[] = { 249, 250 };
645
646/* The GPIO0H (19,20) pins overlap with parallel flash CE0, CE1 */
647static const unsigned int gpio0h_3512_pins[] = { 251, 229 };
648
649/* The GPIO0I (21,22) pins overlap with serial flash CE0, CE1 */
650static const unsigned int gpio0i_3512_pins[] = { 230, 231 };
651
652/* The GPIO0J (23) pins overlap with all flash */
653static const unsigned int gpio0j_3512_pins[] = { 232 };
654
655/* The GPIO0K (24,25) pins overlap with all flash and LCD */
656static const unsigned int gpio0k_3512_pins[] = { 233, 211 };
657
658/* The GPIO0L (26-29) pins overlap with parallel flash */
659static const unsigned int gpio0l_3512_pins[] = { 212, 213, 214, 215 };
660
661/* The GPIO0M (30,31) pins overlap with parallel flash and NAND flash */
662static const unsigned int gpio0m_3512_pins[] = { 193, 194 };
663
664/* The GPIO1A (0-4) pins that overlap with IDE and parallel flash */
665static const unsigned int gpio1a_3512_pins[] = { 162, 163, 165, 166, 148 };
666
667/* The GPIO1B (5-10, 27) pins overlap with just IDE */
668static const unsigned int gpio1b_3512_pins[] = {
669 180, 181, 182, 183, 184, 198, 255
670};
671
672/* The GPIO1C (11-26) pins overlap with IDE, parallel flash and NAND flash */
673static const unsigned int gpio1c_3512_pins[] = {
674 199, 200, 201, 202, 216, 217, 218, 219, 220, 234, 235, 236, 237,
675 252, 253, 254
676};
677
678/* The GPIO1D (28-31) pins overlap with LCD and TVC */
679static const unsigned int gpio1d_3512_pins[] = { 246, 319, 301, 283 };
680
Linus Walleij756a0242017-11-06 21:27:34 +0100681/* The GPIO2A (0-3) pins overlap with GMII GMAC1 and extended parallel flash */
Linus Walleij06351d12017-08-05 23:04:08 +0200682static const unsigned int gpio2a_3512_pins[] = { 315, 297, 279, 261 };
683
Linus Walleij756a0242017-11-06 21:27:34 +0100684/* The GPIO2B (4-7) pins overlap with GMII GMAC1, extended parallel flash and LCD */
Linus Walleij06351d12017-08-05 23:04:08 +0200685static const unsigned int gpio2b_3512_pins[] = { 262, 244, 317, 299 };
686
687/* The GPIO2C (8-31) pins overlap with PCI */
688static const unsigned int gpio2c_3512_pins[] = {
689 17, 34, 35, 51, 52, 53, 68, 69, 71, 86, 87, 88, 89, 103, 104, 105,
690 140, 141, 142, 143, 157, 158, 159, 160
691};
692
693/* Groups for the 3512 SoC/package */
694static const struct gemini_pin_group gemini_3512_pin_groups[] = {
695 {
696 .name = "gndgrp",
697 .pins = gnd_3512_pins,
698 .num_pins = ARRAY_SIZE(gnd_3512_pins),
699 },
700 {
701 .name = "dramgrp",
702 .pins = dram_3512_pins,
703 .num_pins = ARRAY_SIZE(dram_3512_pins),
704 .mask = DRAM_PADS_POWERDOWN,
705 },
706 {
707 .name = "rtcgrp",
708 .pins = rtc_3512_pins,
709 .num_pins = ARRAY_SIZE(rtc_3512_pins),
710 },
711 {
712 .name = "powergrp",
713 .pins = power_3512_pins,
714 .num_pins = ARRAY_SIZE(power_3512_pins),
715 },
716 {
717 .name = "systemgrp",
718 .pins = system_3512_pins,
719 .num_pins = ARRAY_SIZE(system_3512_pins),
720 },
721 {
722 .name = "vcontrolgrp",
723 .pins = vcontrol_3512_pins,
724 .num_pins = ARRAY_SIZE(vcontrol_3512_pins),
725 },
726 {
727 .name = "icegrp",
728 .pins = ice_3512_pins,
729 .num_pins = ARRAY_SIZE(ice_3512_pins),
730 /* Conflict with some GPIO groups */
731 },
732 {
733 .name = "idegrp",
734 .pins = ide_3512_pins,
735 .num_pins = ARRAY_SIZE(ide_3512_pins),
736 /* Conflict with all flash usage */
737 .value = IDE_PADS_ENABLE | NAND_PADS_DISABLE |
738 PFLASH_PADS_DISABLE | SFLASH_PADS_DISABLE,
739 },
740 {
741 .name = "satagrp",
742 .pins = sata_3512_pins,
743 .num_pins = ARRAY_SIZE(sata_3512_pins),
744 },
745 {
746 .name = "usbgrp",
747 .pins = usb_3512_pins,
748 .num_pins = ARRAY_SIZE(usb_3512_pins),
749 },
750 {
Linus Walleij756a0242017-11-06 21:27:34 +0100751 .name = "gmii_gmac0_grp",
752 .pins = gmii_gmac0_3512_pins,
753 .num_pins = ARRAY_SIZE(gmii_gmac0_3512_pins),
754 },
755 {
756 .name = "gmii_gmac1_grp",
757 .pins = gmii_gmac1_3512_pins,
758 .num_pins = ARRAY_SIZE(gmii_gmac1_3512_pins),
759 /* Bring out RGMII on the GMAC1 pins */
760 .value = GEMINI_GMAC_IOSEL_GMAC0_GMAC1_RGMII,
Linus Walleij06351d12017-08-05 23:04:08 +0200761 },
762 {
763 .name = "pcigrp",
764 .pins = pci_3512_pins,
765 .num_pins = ARRAY_SIZE(pci_3512_pins),
766 /* Conflict only with GPIO2 */
767 .value = PCI_PADS_ENABLE | PCI_CLK_PAD_ENABLE,
768 },
769 {
770 .name = "lpcgrp",
771 .pins = lpc_3512_pins,
772 .num_pins = ARRAY_SIZE(lpc_3512_pins),
773 /* Conflict with SSP and UART modem pins */
774 .mask = SSP_PADS_ENABLE,
775 .value = LPC_PADS_ENABLE | LPC_CLK_PAD_ENABLE,
776 },
777 {
778 .name = "lcdgrp",
779 .pins = lcd_3512_pins,
780 .num_pins = ARRAY_SIZE(lcd_3512_pins),
781 /* Conflict with TVC and ICE */
782 .mask = TVC_PADS_ENABLE,
783 .value = LCD_PADS_ENABLE,
784 },
785 {
786 .name = "sspgrp",
787 .pins = ssp_3512_pins,
788 .num_pins = ARRAY_SIZE(ssp_3512_pins),
789 /* Conflict with LPC and UART modem pins */
790 .mask = LPC_PADS_ENABLE,
791 .value = SSP_PADS_ENABLE,
792 },
793 {
794 .name = "uartrxtxgrp",
795 .pins = uart_rxtx_3512_pins,
796 .num_pins = ARRAY_SIZE(uart_rxtx_3512_pins),
797 /* No conflicts except GPIO */
798 },
799 {
800 .name = "uartmodemgrp",
801 .pins = uart_modem_3512_pins,
802 .num_pins = ARRAY_SIZE(uart_modem_3512_pins),
803 /*
804 * Conflict with LPC and SSP,
805 * so when those are both disabled, modem UART can thrive.
806 */
807 .mask = LPC_PADS_ENABLE | SSP_PADS_ENABLE,
808 },
809 {
810 .name = "tvcgrp",
811 .pins = tvc_3512_pins,
812 .num_pins = ARRAY_SIZE(tvc_3512_pins),
813 /* Conflict with character LCD and ICE */
814 .mask = LCD_PADS_ENABLE,
815 .value = TVC_PADS_ENABLE | TVC_CLK_PAD_ENABLE,
816 },
817 /*
818 * The construction is done such that it is possible to use a serial
819 * flash together with a NAND or parallel (NOR) flash, but it is not
820 * possible to use NAND and parallel flash together. To use serial
821 * flash with one of the two others, the muxbits need to be flipped
822 * around before any access.
823 */
824 {
825 .name = "nflashgrp",
826 .pins = nflash_3512_pins,
827 .num_pins = ARRAY_SIZE(nflash_3512_pins),
828 /* Conflict with IDE, parallel and serial flash */
829 .mask = NAND_PADS_DISABLE | IDE_PADS_ENABLE,
830 .value = PFLASH_PADS_DISABLE | SFLASH_PADS_DISABLE,
831 },
832 {
833 .name = "pflashgrp",
834 .pins = pflash_3512_pins,
835 .num_pins = ARRAY_SIZE(pflash_3512_pins),
836 /* Conflict with IDE, NAND and serial flash */
837 .mask = PFLASH_PADS_DISABLE | IDE_PADS_ENABLE,
838 .value = NAND_PADS_DISABLE | SFLASH_PADS_DISABLE,
839 },
840 {
841 .name = "sflashgrp",
842 .pins = sflash_3512_pins,
843 .num_pins = ARRAY_SIZE(sflash_3512_pins),
844 /* Conflict with IDE, NAND and parallel flash */
845 .mask = SFLASH_PADS_DISABLE | IDE_PADS_ENABLE,
846 .value = NAND_PADS_DISABLE | PFLASH_PADS_DISABLE,
847 },
848 {
849 .name = "gpio0agrp",
850 .pins = gpio0a_3512_pins,
851 .num_pins = ARRAY_SIZE(gpio0a_3512_pins),
852 /* Conflict with TVC */
853 .mask = TVC_PADS_ENABLE,
854 },
855 {
856 .name = "gpio0bgrp",
857 .pins = gpio0b_3512_pins,
858 .num_pins = ARRAY_SIZE(gpio0b_3512_pins),
859 /* Conflict with TVC and ICE */
860 .mask = TVC_PADS_ENABLE,
861 },
862 {
863 .name = "gpio0cgrp",
864 .pins = gpio0c_3512_pins,
865 .num_pins = ARRAY_SIZE(gpio0c_3512_pins),
866 /* Conflict with ICE */
867 },
868 {
869 .name = "gpio0dgrp",
870 .pins = gpio0d_3512_pins,
871 .num_pins = ARRAY_SIZE(gpio0d_3512_pins),
872 /* Conflict with UART RX/TX */
873 },
874 {
875 .name = "gpio0egrp",
876 .pins = gpio0e_3512_pins,
877 .num_pins = ARRAY_SIZE(gpio0e_3512_pins),
878 /* Conflict with LPC, UART modem pins, SSP */
879 .mask = LPC_PADS_ENABLE | SSP_PADS_ENABLE,
880 },
881 {
882 .name = "gpio0fgrp",
883 .pins = gpio0f_3512_pins,
884 .num_pins = ARRAY_SIZE(gpio0f_3512_pins),
885 /* Conflict with LCD */
886 .mask = LCD_PADS_ENABLE,
887 },
888 {
889 .name = "gpio0ggrp",
890 .pins = gpio0g_3512_pins,
891 .num_pins = ARRAY_SIZE(gpio0g_3512_pins),
892 /* Conflict with NAND flash */
893 .value = NAND_PADS_DISABLE,
894 },
895 {
896 .name = "gpio0hgrp",
897 .pins = gpio0h_3512_pins,
898 .num_pins = ARRAY_SIZE(gpio0h_3512_pins),
899 /* Conflict with parallel flash */
900 .value = PFLASH_PADS_DISABLE,
901 },
902 {
903 .name = "gpio0igrp",
904 .pins = gpio0i_3512_pins,
905 .num_pins = ARRAY_SIZE(gpio0i_3512_pins),
906 /* Conflict with serial flash */
907 .value = SFLASH_PADS_DISABLE,
908 },
909 {
910 .name = "gpio0jgrp",
911 .pins = gpio0j_3512_pins,
912 .num_pins = ARRAY_SIZE(gpio0j_3512_pins),
913 /* Conflict with all flash */
914 .value = PFLASH_PADS_DISABLE | NAND_PADS_DISABLE |
915 SFLASH_PADS_DISABLE,
916 },
917 {
918 .name = "gpio0kgrp",
919 .pins = gpio0k_3512_pins,
920 .num_pins = ARRAY_SIZE(gpio0k_3512_pins),
921 /* Conflict with all flash and LCD */
922 .mask = LCD_PADS_ENABLE,
923 .value = PFLASH_PADS_DISABLE | NAND_PADS_DISABLE |
924 SFLASH_PADS_DISABLE,
925 },
926 {
927 .name = "gpio0lgrp",
928 .pins = gpio0l_3512_pins,
929 .num_pins = ARRAY_SIZE(gpio0l_3512_pins),
930 /* Conflict with parallel flash */
931 .value = PFLASH_PADS_DISABLE,
932 },
933 {
934 .name = "gpio0mgrp",
935 .pins = gpio0m_3512_pins,
936 .num_pins = ARRAY_SIZE(gpio0m_3512_pins),
937 /* Conflict with parallel and NAND flash */
938 .value = PFLASH_PADS_DISABLE | NAND_PADS_DISABLE,
939 },
940 {
941 .name = "gpio1agrp",
942 .pins = gpio1a_3512_pins,
943 .num_pins = ARRAY_SIZE(gpio1a_3512_pins),
944 /* Conflict with IDE and parallel flash */
945 .mask = IDE_PADS_ENABLE,
946 .value = PFLASH_PADS_DISABLE,
947 },
948 {
949 .name = "gpio1bgrp",
950 .pins = gpio1b_3512_pins,
951 .num_pins = ARRAY_SIZE(gpio1b_3512_pins),
952 /* Conflict with IDE only */
953 .mask = IDE_PADS_ENABLE,
954 },
955 {
956 .name = "gpio1cgrp",
957 .pins = gpio1c_3512_pins,
958 .num_pins = ARRAY_SIZE(gpio1c_3512_pins),
959 /* Conflict with IDE, parallel and NAND flash */
960 .mask = IDE_PADS_ENABLE,
961 .value = NAND_PADS_DISABLE | PFLASH_PADS_DISABLE,
962 },
963 {
964 .name = "gpio1dgrp",
965 .pins = gpio1d_3512_pins,
966 .num_pins = ARRAY_SIZE(gpio1d_3512_pins),
967 /* Conflict with LCD and TVC */
968 .mask = LCD_PADS_ENABLE | TVC_PADS_ENABLE,
969 },
970 {
971 .name = "gpio2agrp",
972 .pins = gpio2a_3512_pins,
973 .num_pins = ARRAY_SIZE(gpio2a_3512_pins),
Linus Walleij756a0242017-11-06 21:27:34 +0100974 .mask = GEMINI_GMAC_IOSEL_GMAC0_GMAC1_RGMII,
975 /* Conflict with GMII GMAC1 and extended parallel flash */
Linus Walleij06351d12017-08-05 23:04:08 +0200976 },
977 {
978 .name = "gpio2bgrp",
979 .pins = gpio2b_3512_pins,
980 .num_pins = ARRAY_SIZE(gpio2b_3512_pins),
Linus Walleij756a0242017-11-06 21:27:34 +0100981 /* Conflict with GMII GMAC1, extended parallel flash and LCD */
982 .mask = LCD_PADS_ENABLE | GEMINI_GMAC_IOSEL_GMAC0_GMAC1_RGMII,
Linus Walleij06351d12017-08-05 23:04:08 +0200983 },
984 {
985 .name = "gpio2cgrp",
986 .pins = gpio2c_3512_pins,
987 .num_pins = ARRAY_SIZE(gpio2c_3512_pins),
988 /* Conflict with PCI */
989 .mask = PCI_PADS_ENABLE,
990 },
991};
992
993/* Pin names for the pinmux subsystem, 3516 variant */
994static const struct pinctrl_pin_desc gemini_3516_pins[] = {
995 /* Row A */
996 PINCTRL_PIN(0, "A1 AVCC3IOHA"),
997 PINCTRL_PIN(1, "A2 DRAM CK N"),
998 PINCTRL_PIN(2, "A3 DRAM CK"),
999 PINCTRL_PIN(3, "A4 DRAM DQM1"),
1000 PINCTRL_PIN(4, "A5 DRAM DQ9"),
1001 PINCTRL_PIN(5, "A6 DRAM DQ13"),
1002 PINCTRL_PIN(6, "A7 DRAM DQ1"),
1003 PINCTRL_PIN(7, "A8 DRAM DQ2"),
1004 PINCTRL_PIN(8, "A9 DRAM DQ4"),
1005 PINCTRL_PIN(9, "A10 DRAM VREF"),
1006 PINCTRL_PIN(10, "A11 DRAM DQ24"),
1007 PINCTRL_PIN(11, "A12 DRAM DQ28"),
1008 PINCTRL_PIN(12, "A13 DRAM DQ30"),
1009 PINCTRL_PIN(13, "A14 DRAM DQ18"),
1010 PINCTRL_PIN(14, "A15 DRAM DQ21"),
1011 PINCTRL_PIN(15, "A16 DRAM CAS_N"),
1012 PINCTRL_PIN(16, "A17 DRAM BA1"),
1013 PINCTRL_PIN(17, "A18 PCI INTA N"),
1014 PINCTRL_PIN(18, "A19 PCI INTB N"),
1015 PINCTRL_PIN(19, "A20 PCI INTC N"),
1016 /* Row B */
1017 PINCTRL_PIN(20, "B1 PWR EN"),
1018 PINCTRL_PIN(21, "B2 GND"),
1019 PINCTRL_PIN(22, "B3 RTC CLKO"),
1020 PINCTRL_PIN(23, "B4 DRAM A5"),
1021 PINCTRL_PIN(24, "B5 DRAM A6"),
1022 PINCTRL_PIN(25, "B6 DRAM DQS1"),
1023 PINCTRL_PIN(26, "B7 DRAM DQ11"),
1024 PINCTRL_PIN(27, "B8 DRAM DQ0"),
1025 PINCTRL_PIN(28, "B9 DRAM DQS0"),
1026 PINCTRL_PIN(29, "B10 DRAM DQ7"),
1027 PINCTRL_PIN(30, "B11 DRAM DQS3"),
1028 PINCTRL_PIN(31, "B12 DRAM DQ27"),
1029 PINCTRL_PIN(32, "B13 DRAM DQ31"),
1030 PINCTRL_PIN(33, "B14 DRAM DQ20"),
1031 PINCTRL_PIN(34, "B15 DRAM DQS2"),
1032 PINCTRL_PIN(35, "B16 DRAM WE N"),
1033 PINCTRL_PIN(36, "B17 DRAM A10"),
1034 PINCTRL_PIN(37, "B18 DRAM A2"),
1035 PINCTRL_PIN(38, "B19 GND"),
1036 PINCTRL_PIN(39, "B20 PCI GNT0 N"),
1037 /* Row C */
1038 PINCTRL_PIN(40, "C1 AGNDIOHA"),
1039 PINCTRL_PIN(41, "C2 XTALI"),
1040 PINCTRL_PIN(42, "C3 GND"),
1041 PINCTRL_PIN(43, "C4 RTC CLKI"),
1042 PINCTRL_PIN(44, "C5 DRAM A12"),
1043 PINCTRL_PIN(45, "C6 DRAM A11"),
1044 PINCTRL_PIN(46, "C7 DRAM DQ8"),
1045 PINCTRL_PIN(47, "C8 DRAM DQ10"),
1046 PINCTRL_PIN(48, "C9 DRAM DQ3"),
1047 PINCTRL_PIN(49, "C10 DRAM DQ6"),
1048 PINCTRL_PIN(50, "C11 DRAM DQM0"),
1049 PINCTRL_PIN(51, "C12 DRAM DQ26"),
1050 PINCTRL_PIN(52, "C13 DRAM DQ16"),
1051 PINCTRL_PIN(53, "C14 DRAM DQ22"),
1052 PINCTRL_PIN(54, "C15 DRAM DQM2"),
1053 PINCTRL_PIN(55, "C16 DRAM BA0"),
1054 PINCTRL_PIN(56, "C17 DRAM A3"),
1055 PINCTRL_PIN(57, "C18 GND"),
1056 PINCTRL_PIN(58, "C19 PCI GNT1 N"),
1057 PINCTRL_PIN(59, "C20 PCI REQ2 N"),
1058 /* Row D */
1059 PINCTRL_PIN(60, "D1 AVCC3IOAHA"),
1060 PINCTRL_PIN(61, "D2 AVCCKHA"),
1061 PINCTRL_PIN(62, "D3 XTALO"),
1062 PINCTRL_PIN(63, "D4 GND"),
1063 PINCTRL_PIN(64, "D5 CIR RXD"),
1064 PINCTRL_PIN(65, "D6 DRAM A7"),
1065 PINCTRL_PIN(66, "D7 DRAM A4"),
1066 PINCTRL_PIN(67, "D8 DRAM A8"),
1067 PINCTRL_PIN(68, "D9 DRAM CKE"),
1068 PINCTRL_PIN(69, "D10 DRAM DQ14"),
1069 PINCTRL_PIN(70, "D11 DRAM DQ5"),
1070 PINCTRL_PIN(71, "D12 DRAM DQ25"),
1071 PINCTRL_PIN(72, "D13 DRAM DQ17"),
1072 PINCTRL_PIN(73, "D14 DRAM DQ23"),
1073 PINCTRL_PIN(74, "D15 DRAM RAS N"),
1074 PINCTRL_PIN(75, "D16 DRAM A1"),
1075 PINCTRL_PIN(76, "D17 GND"),
1076 PINCTRL_PIN(77, "D18 EXT RESET N"),
1077 PINCTRL_PIN(78, "D19 PCI REQ1 N"),
1078 PINCTRL_PIN(79, "D20 PCI REQ3 N"),
1079 /* Row E */
1080 PINCTRL_PIN(80, "E1 VCC2IO CTRL"),
1081 PINCTRL_PIN(81, "E2 VREF CTRL"),
1082 PINCTRL_PIN(82, "E3 CIR RST N"),
1083 PINCTRL_PIN(83, "E4 PWR BTN"),
1084 PINCTRL_PIN(84, "E5 GND"),
1085 PINCTRL_PIN(85, "E6 CIR TXD"),
1086 PINCTRL_PIN(86, "E7 VCCK CTRL"),
1087 PINCTRL_PIN(87, "E8 DRAM A9"),
1088 PINCTRL_PIN(88, "E9 DRAM DQ12"),
1089 PINCTRL_PIN(89, "E10 DRAM DQ15"),
1090 PINCTRL_PIN(90, "E11 DRAM DQM3"),
1091 PINCTRL_PIN(91, "E12 DRAM DQ29"),
1092 PINCTRL_PIN(92, "E13 DRAM DQ19"),
1093 PINCTRL_PIN(93, "E14 DRAM A13"),
1094 PINCTRL_PIN(94, "E15 DRAM A0"),
1095 PINCTRL_PIN(95, "E16 GND"),
1096 PINCTRL_PIN(96, "E17 PCI INTD N"),
1097 PINCTRL_PIN(97, "E18 PCI GNT3 N"),
1098 PINCTRL_PIN(98, "E19 PCI AD29"),
1099 PINCTRL_PIN(99, "E20 PCI AD28"),
1100 /* Row F */
1101 PINCTRL_PIN(100, "F1 AVCCKHB"),
1102 PINCTRL_PIN(101, "F2 AVCCK P"),
1103 PINCTRL_PIN(102, "F3 EBG"),
1104 PINCTRL_PIN(103, "F4 REXT"),
1105 PINCTRL_PIN(104, "F5 AVCC3IOHB"),
1106 PINCTRL_PIN(105, "F6 GND"),
1107 PINCTRL_PIN(106, "F7 VCC2IOHA 2"),
1108 PINCTRL_PIN(107, "F8 VCC2IOHA 2"),
1109 PINCTRL_PIN(108, "F9 VCC2IOHA 2"),
1110 PINCTRL_PIN(109, "F10 V1"),
1111 PINCTRL_PIN(110, "F11 V1"),
1112 PINCTRL_PIN(111, "F12 VCC2IOHA 2"),
1113 PINCTRL_PIN(112, "F13 VCC2IOHA 2"),
1114 PINCTRL_PIN(113, "F14 VCC2IOHA 2"),
1115 PINCTRL_PIN(114, "F15 GND"),
1116 PINCTRL_PIN(115, "F16 PCI CLK"),
1117 PINCTRL_PIN(116, "F17 PCI GNT2 N"),
1118 PINCTRL_PIN(117, "F18 PCI AD31"),
1119 PINCTRL_PIN(118, "F19 PCI AD26"),
1120 PINCTRL_PIN(119, "F20 PCI CBE3 N"),
1121 /* Row G */
1122 PINCTRL_PIN(120, "G1 SATA0 RXDP"),
1123 PINCTRL_PIN(121, "G2 SATA0 RXDN"),
1124 PINCTRL_PIN(122, "G3 AGNDK 0"),
1125 PINCTRL_PIN(123, "G4 AVCCK S"),
1126 PINCTRL_PIN(124, "G5 AVCC3 S"),
1127 PINCTRL_PIN(125, "G6 VCC2IOHA 2"),
1128 PINCTRL_PIN(126, "G7 GND"),
1129 PINCTRL_PIN(127, "G8 VCC2IOHA 2"),
1130 PINCTRL_PIN(128, "G9 V1"),
1131 PINCTRL_PIN(129, "G10 V1"),
1132 PINCTRL_PIN(130, "G11 V1"),
1133 PINCTRL_PIN(131, "G12 V1"),
1134 PINCTRL_PIN(132, "G13 VCC2IOHA 2"),
1135 PINCTRL_PIN(133, "G14 GND"),
1136 PINCTRL_PIN(134, "G15 VCC3IOHA"),
1137 PINCTRL_PIN(135, "G16 PCI REQ0 N"),
1138 PINCTRL_PIN(136, "G17 PCI AD30"),
1139 PINCTRL_PIN(137, "G18 PCI AD24"),
1140 PINCTRL_PIN(138, "G19 PCI AD23"),
1141 PINCTRL_PIN(139, "G20 PCI AD21"),
1142 /* Row H */
1143 PINCTRL_PIN(140, "H1 SATA0 TXDP"),
1144 PINCTRL_PIN(141, "H2 SATA0 TXDN"),
1145 PINCTRL_PIN(142, "H3 AGNDK 1"),
1146 PINCTRL_PIN(143, "H4 AVCCK 0"),
1147 PINCTRL_PIN(144, "H5 TEST CLKOUT"),
1148 PINCTRL_PIN(145, "H6 AGND"),
1149 PINCTRL_PIN(146, "H7 VCC2IOHA 2"),
1150 PINCTRL_PIN(147, "H8 GND"),
1151 PINCTRL_PIN(148, "H9 GND"),
1152 PINCTRL_PIN(149, "H10 GDN"),
1153 PINCTRL_PIN(150, "H11 GND"),
1154 PINCTRL_PIN(151, "H12 GND"),
1155 PINCTRL_PIN(152, "H13 GND"),
1156 PINCTRL_PIN(153, "H14 VCC3IOHA"),
1157 PINCTRL_PIN(154, "H15 VCC3IOHA"),
1158 PINCTRL_PIN(155, "H16 PCI AD27"),
1159 PINCTRL_PIN(156, "H17 PCI AD25"),
1160 PINCTRL_PIN(157, "H18 PCI AD22"),
1161 PINCTRL_PIN(158, "H19 PCI AD18"),
1162 PINCTRL_PIN(159, "H20 PCI AD17"),
1163 /* Row J (for some reason I is skipped) */
1164 PINCTRL_PIN(160, "J1 SATA1 TXDP"),
1165 PINCTRL_PIN(161, "J2 SATA1 TXDN"),
1166 PINCTRL_PIN(162, "J3 AGNDK 2"),
1167 PINCTRL_PIN(163, "J4 AVCCK 1"),
1168 PINCTRL_PIN(164, "J5 AGND"),
1169 PINCTRL_PIN(165, "J6 AGND"),
1170 PINCTRL_PIN(166, "J7 V1"),
1171 PINCTRL_PIN(167, "J8 GND"),
1172 PINCTRL_PIN(168, "J9 GND"),
1173 PINCTRL_PIN(169, "J10 GND"),
1174 PINCTRL_PIN(170, "J11 GND"),
1175 PINCTRL_PIN(171, "J12 GND"),
1176 PINCTRL_PIN(172, "J13 GND"),
1177 PINCTRL_PIN(173, "J14 V1"),
1178 PINCTRL_PIN(174, "J15 VCC3IOHA"),
1179 PINCTRL_PIN(175, "J16 PCI AD19"),
1180 PINCTRL_PIN(176, "J17 PCI AD20"),
1181 PINCTRL_PIN(177, "J18 PCI AD16"),
1182 PINCTRL_PIN(178, "J19 PCI CBE2 N"),
1183 PINCTRL_PIN(179, "J20 PCI FRAME N"),
1184 /* Row K */
1185 PINCTRL_PIN(180, "K1 SATA1 RXDP"),
1186 PINCTRL_PIN(181, "K2 SATA1 RXDN"),
1187 PINCTRL_PIN(182, "K3 AGNDK 3"),
1188 PINCTRL_PIN(183, "K4 AVCCK 2"),
1189 PINCTRL_PIN(184, "K5 AGND"),
1190 PINCTRL_PIN(185, "K6 V1"),
1191 PINCTRL_PIN(186, "K7 V1"),
1192 PINCTRL_PIN(187, "K8 GND"),
1193 PINCTRL_PIN(188, "K9 GND"),
1194 PINCTRL_PIN(189, "K10 GND"),
1195 PINCTRL_PIN(190, "K11 GND"),
1196 PINCTRL_PIN(191, "K12 GND"),
1197 PINCTRL_PIN(192, "K13 GND"),
1198 PINCTRL_PIN(193, "K14 V1"),
1199 PINCTRL_PIN(194, "K15 V1"),
1200 PINCTRL_PIN(195, "K16 PCI TRDY N"),
1201 PINCTRL_PIN(196, "K17 PCI IRDY N"),
1202 PINCTRL_PIN(197, "K18 PCI DEVSEL N"),
1203 PINCTRL_PIN(198, "K19 PCI STOP N"),
1204 PINCTRL_PIN(199, "K20 PCI PAR"),
1205 /* Row L */
1206 PINCTRL_PIN(200, "L1 IDE CS0 N"),
1207 PINCTRL_PIN(201, "L2 IDE DA0"),
1208 PINCTRL_PIN(202, "L3 AVCCK 3"),
1209 PINCTRL_PIN(203, "L4 AGND"),
1210 PINCTRL_PIN(204, "L5 IDE DIOR N"),
1211 PINCTRL_PIN(205, "L6 V1"),
1212 PINCTRL_PIN(206, "L7 V1"),
1213 PINCTRL_PIN(207, "L8 GND"),
1214 PINCTRL_PIN(208, "L9 GND"),
1215 PINCTRL_PIN(209, "L10 GND"),
1216 PINCTRL_PIN(210, "L11 GND"),
1217 PINCTRL_PIN(211, "L12 GND"),
1218 PINCTRL_PIN(212, "L13 GND"),
1219 PINCTRL_PIN(213, "L14 V1"),
1220 PINCTRL_PIN(214, "L15 V1"),
1221 PINCTRL_PIN(215, "L16 PCI AD12"),
1222 PINCTRL_PIN(216, "L17 PCI AD13"),
1223 PINCTRL_PIN(217, "L18 PCI AD14"),
1224 PINCTRL_PIN(218, "L19 PCI AD15"),
1225 PINCTRL_PIN(219, "L20 PCI CBE1 N"),
1226 /* Row M */
1227 PINCTRL_PIN(220, "M1 IDE DA1"),
1228 PINCTRL_PIN(221, "M2 IDE CS1 N"),
1229 PINCTRL_PIN(222, "M3 IDE DA2"),
1230 PINCTRL_PIN(223, "M4 IDE DMACK N"),
1231 PINCTRL_PIN(224, "M5 IDE DD1"),
1232 PINCTRL_PIN(225, "M6 VCC3IOHA"),
1233 PINCTRL_PIN(226, "M7 V1"),
1234 PINCTRL_PIN(227, "M8 GND"),
1235 PINCTRL_PIN(228, "M9 GND"),
1236 PINCTRL_PIN(229, "M10 GND"),
1237 PINCTRL_PIN(230, "M11 GND"),
1238 PINCTRL_PIN(231, "M12 GND"),
1239 PINCTRL_PIN(232, "M13 GND"),
1240 PINCTRL_PIN(233, "M14 V1"),
1241 PINCTRL_PIN(234, "M15 VCC3IOHA"),
1242 PINCTRL_PIN(235, "M16 PCI AD7"),
1243 PINCTRL_PIN(236, "M17 PCI AD6"),
1244 PINCTRL_PIN(237, "M18 PCI AD9"),
1245 PINCTRL_PIN(238, "M19 PCI AD10"),
1246 PINCTRL_PIN(239, "M20 PCI AD11"),
1247 /* Row N */
1248 PINCTRL_PIN(240, "N1 IDE IORDY"),
1249 PINCTRL_PIN(241, "N2 IDE INTRQ"),
1250 PINCTRL_PIN(242, "N3 IDE DIOW N"),
1251 PINCTRL_PIN(243, "N4 IDE DD15"),
1252 PINCTRL_PIN(244, "N5 IDE DMARQ"),
1253 PINCTRL_PIN(245, "N6 VCC3IOHA"),
1254 PINCTRL_PIN(246, "N7 VCC3IOHA"),
1255 PINCTRL_PIN(247, "N8 GND"),
1256 PINCTRL_PIN(248, "N9 GND"),
1257 PINCTRL_PIN(249, "N10 GND"),
1258 PINCTRL_PIN(250, "N11 GND"),
1259 PINCTRL_PIN(251, "N12 GND"),
1260 PINCTRL_PIN(252, "N13 GND"),
1261 PINCTRL_PIN(253, "N14 VCC3IOHA"),
1262 PINCTRL_PIN(254, "N15 VCC3IOHA"),
1263 PINCTRL_PIN(255, "N16 PCI CLKRUN N"),
1264 PINCTRL_PIN(256, "N17 PCI AD0"),
1265 PINCTRL_PIN(257, "N18 PCI AD4"),
1266 PINCTRL_PIN(258, "N19 PCI CBE0 N"),
1267 PINCTRL_PIN(259, "N20 PCI AD8"),
1268 /* Row P (for some reason O is skipped) */
1269 PINCTRL_PIN(260, "P1 IDE DD0"),
1270 PINCTRL_PIN(261, "P2 IDE DD14"),
1271 PINCTRL_PIN(262, "P3 IDE DD2"),
1272 PINCTRL_PIN(263, "P4 IDE DD4"),
1273 PINCTRL_PIN(264, "P5 IDE DD3"),
1274 PINCTRL_PIN(265, "P6 VCC3IOHA"),
1275 PINCTRL_PIN(266, "P7 GND"),
1276 PINCTRL_PIN(267, "P8 VCC2IOHA 1"),
1277 PINCTRL_PIN(268, "P9 V1"),
1278 PINCTRL_PIN(269, "P10 V1"),
1279 PINCTRL_PIN(270, "P11 V1"),
1280 PINCTRL_PIN(271, "P12 V1"),
1281 PINCTRL_PIN(272, "P13 VCC3IOHA"),
1282 PINCTRL_PIN(273, "P14 GND"),
1283 PINCTRL_PIN(274, "P15 VCC3IOHA"),
1284 PINCTRL_PIN(275, "P16 GPIO0 30"),
1285 PINCTRL_PIN(276, "P17 GPIO0 28"),
1286 PINCTRL_PIN(277, "P18 PCI AD1"),
1287 PINCTRL_PIN(278, "P19 PCI AD3"),
1288 PINCTRL_PIN(279, "P20 PCI AD5"),
1289 /* Row R (for some reason Q us skipped) */
1290 PINCTRL_PIN(280, "R1 IDE DD13"),
1291 PINCTRL_PIN(281, "R2 IDE DD12"),
1292 PINCTRL_PIN(282, "R3 IDE DD10"),
1293 PINCTRL_PIN(283, "R4 IDE DD6"),
1294 PINCTRL_PIN(284, "R5 ICE0 IDI"),
1295 PINCTRL_PIN(285, "R6 GND"),
1296 PINCTRL_PIN(286, "R7 VCC2IOHA 1"),
1297 PINCTRL_PIN(287, "R8 VCC2IOHA 1"),
1298 PINCTRL_PIN(288, "R9 VCC2IOHA 1"),
1299 PINCTRL_PIN(289, "R10 V1"),
1300 PINCTRL_PIN(290, "R11 V1"),
1301 PINCTRL_PIN(291, "R12 VCC3IOHA"),
1302 PINCTRL_PIN(292, "R13 VCC3IOHA"),
1303 PINCTRL_PIN(293, "R14 VCC3IOHA"),
1304 PINCTRL_PIN(294, "R15 GND"),
1305 PINCTRL_PIN(295, "R16 GPIO0 23"),
1306 PINCTRL_PIN(296, "R17 GPIO0 21"),
1307 PINCTRL_PIN(297, "R18 GPIO0 26"),
1308 PINCTRL_PIN(298, "R19 GPIO0 31"),
1309 PINCTRL_PIN(299, "R20 PCI AD2"),
1310 /* Row T (for some reason S is skipped) */
1311 PINCTRL_PIN(300, "T1 IDE DD11"),
1312 PINCTRL_PIN(301, "T2 IDE DD5"),
1313 PINCTRL_PIN(302, "T3 IDE DD8"),
1314 PINCTRL_PIN(303, "T4 ICE0 IDO"),
1315 PINCTRL_PIN(304, "T5 GND"),
1316 PINCTRL_PIN(305, "T6 USB GNDA U20"),
1317 PINCTRL_PIN(306, "T7 GMAC0 TXD0"),
1318 PINCTRL_PIN(307, "T8 GMAC0 TXEN"),
1319 PINCTRL_PIN(308, "T9 GMAC1 TXD3"),
1320 PINCTRL_PIN(309, "T10 GMAC1 RXDV"),
1321 PINCTRL_PIN(310, "T11 GMAC1 RXD2"),
1322 PINCTRL_PIN(311, "T12 GPIO1 29"),
1323 PINCTRL_PIN(312, "T13 GPIO0 3"),
1324 PINCTRL_PIN(313, "T14 GPIO0 9"),
1325 PINCTRL_PIN(314, "T15 GPIO0 16"),
1326 PINCTRL_PIN(315, "T16 GND"),
1327 PINCTRL_PIN(316, "T17 GPIO0 14"),
1328 PINCTRL_PIN(317, "T18 GPIO0 19"),
1329 PINCTRL_PIN(318, "T19 GPIO0 27"),
1330 PINCTRL_PIN(319, "T20 GPIO0 29"),
1331 /* Row U */
1332 PINCTRL_PIN(320, "U1 IDE DD9"),
1333 PINCTRL_PIN(321, "U2 IDE DD7"),
1334 PINCTRL_PIN(322, "U3 ICE0 ICK"),
1335 PINCTRL_PIN(323, "U4 GND"),
1336 PINCTRL_PIN(324, "U5 USB XSCO"),
1337 PINCTRL_PIN(325, "U6 GMAC0 TXD1"),
1338 PINCTRL_PIN(326, "U7 GMAC0 TXD3"),
1339 PINCTRL_PIN(327, "U8 GMAC0 TXC"),
1340 PINCTRL_PIN(328, "U9 GMAC0 RXD3"),
1341 PINCTRL_PIN(329, "U10 GMAC1 TXD0"),
1342 PINCTRL_PIN(330, "U11 GMAC1 CRS"),
1343 PINCTRL_PIN(331, "U12 EXT CLK"),
1344 PINCTRL_PIN(332, "U13 DEV DEF"),
1345 PINCTRL_PIN(333, "U14 GPIO0 0"),
1346 PINCTRL_PIN(334, "U15 GPIO0 4"),
1347 PINCTRL_PIN(335, "U16 GPIO0 10"),
1348 PINCTRL_PIN(336, "U17 GND"),
1349 PINCTRL_PIN(337, "U18 GPIO0 17"),
1350 PINCTRL_PIN(338, "U19 GPIO0 22"),
1351 PINCTRL_PIN(339, "U20 GPIO0 25"),
1352 /* Row V */
1353 PINCTRL_PIN(340, "V1 ICE0 DBGACK"),
1354 PINCTRL_PIN(341, "V2 ICE0 DBGRQ"),
1355 PINCTRL_PIN(342, "V3 GND"),
1356 PINCTRL_PIN(343, "V4 ICE0 IRST N"),
1357 PINCTRL_PIN(344, "V5 USB XSCI"),
1358 PINCTRL_PIN(345, "V6 GMAC0 COL"),
1359 PINCTRL_PIN(346, "V7 GMAC0 TXD2"),
1360 PINCTRL_PIN(347, "V8 GMAC0 RXDV"),
1361 PINCTRL_PIN(348, "V9 GMAC0 RXD1"),
1362 PINCTRL_PIN(349, "V10 GMAC1 COL"),
1363 PINCTRL_PIN(350, "V11 GMAC1 TXC"),
1364 PINCTRL_PIN(351, "V12 GMAC1 RXD1"),
1365 PINCTRL_PIN(352, "V13 MODE SEL1"),
1366 PINCTRL_PIN(353, "V14 GPIO1 28"),
1367 PINCTRL_PIN(354, "V15 GPIO0 1"),
1368 PINCTRL_PIN(355, "V16 GPIO0 8"),
1369 PINCTRL_PIN(356, "V17 GPIO0 11"),
1370 PINCTRL_PIN(357, "V18 GND"),
1371 PINCTRL_PIN(358, "V19 GPIO0 18"),
1372 PINCTRL_PIN(359, "V20 GPIO0 24"),
1373 /* Row W */
1374 PINCTRL_PIN(360, "W1 IDE RESET N"),
1375 PINCTRL_PIN(361, "W2 GND"),
1376 PINCTRL_PIN(362, "W3 USB0 VCCHSRT"),
1377 PINCTRL_PIN(363, "W4 USB0 DP"),
1378 PINCTRL_PIN(364, "W5 USB VCCA U20"),
1379 PINCTRL_PIN(365, "W6 USB1 DP"),
1380 PINCTRL_PIN(366, "W7 USB1 GNDHSRT"),
1381 PINCTRL_PIN(367, "W8 GMAC0 RXD0"),
1382 PINCTRL_PIN(368, "W9 GMAC0 CRS"),
1383 PINCTRL_PIN(369, "W10 GMAC1 TXD2"),
1384 PINCTRL_PIN(370, "W11 GMAC1 TXEN"),
1385 PINCTRL_PIN(371, "W12 GMAC1 RXD3"),
1386 PINCTRL_PIN(372, "W13 MODE SEL0"),
1387 PINCTRL_PIN(373, "W14 MODE SEL3"),
1388 PINCTRL_PIN(374, "W15 GPIO1 31"),
1389 PINCTRL_PIN(375, "W16 GPIO0 5"),
1390 PINCTRL_PIN(376, "W17 GPIO0 7"),
1391 PINCTRL_PIN(377, "W18 GPIO0 12"),
1392 PINCTRL_PIN(378, "W19 GND"),
1393 PINCTRL_PIN(379, "W20 GPIO0 20"),
1394 /* Row Y */
1395 PINCTRL_PIN(380, "Y1 ICE0 IMS"),
1396 PINCTRL_PIN(381, "Y2 USB0 GNDHSRT"),
1397 PINCTRL_PIN(382, "Y3 USB0 DM"),
1398 PINCTRL_PIN(383, "Y4 USB RREF"),
1399 PINCTRL_PIN(384, "Y5 USB1 DM"),
1400 PINCTRL_PIN(385, "Y6 USB1 VCCHSRT"),
1401 PINCTRL_PIN(386, "Y7 GMAC0 RXC"),
1402 PINCTRL_PIN(387, "Y8 GMAC0 RXD2"),
1403 PINCTRL_PIN(388, "Y9 REF CLK"),
1404 PINCTRL_PIN(389, "Y10 GMAC1 TXD1"),
1405 PINCTRL_PIN(390, "Y11 GMAC1 RXC"),
1406 PINCTRL_PIN(391, "Y12 GMAC1 RXD0"),
1407 PINCTRL_PIN(392, "Y13 M30 CLK"),
1408 PINCTRL_PIN(393, "Y14 MODE SEL2"),
1409 PINCTRL_PIN(394, "Y15 GPIO1 30"),
1410 PINCTRL_PIN(395, "Y16 GPIO0 2"),
1411 PINCTRL_PIN(396, "Y17 GPIO0 6"),
1412 PINCTRL_PIN(397, "Y18 SYS RESET N"),
1413 PINCTRL_PIN(398, "Y19 GPIO0 13"),
1414 PINCTRL_PIN(399, "Y20 GPIO0 15"),
1415};
1416
1417/* Digital ground */
1418static const unsigned int gnd_3516_pins[] = {
1419 21, 38, 42, 57, 63, 76, 84, 95, 105, 114, 126, 133, 147, 148, 149, 150,
1420 151, 152, 167, 168, 169, 170, 171, 172, 187, 188, 189, 190, 191, 192,
1421 207, 208, 209, 210, 211, 212, 227, 228, 229, 230, 231, 232, 247, 248,
1422 249, 250, 251, 252, 266, 273, 285, 294, 304, 315, 323, 336, 342, 357,
1423 361, 378
1424};
1425
1426static const unsigned int dram_3516_pins[] = {
1427 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 23, 24, 25, 26,
1428 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 44, 45, 46, 47, 48, 49, 50,
1429 51, 52, 53, 54, 55, 56, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
1430 87, 88, 89, 90, 91, 92, 93, 94
1431};
1432
1433static const unsigned int rtc_3516_pins[] = { 0, 43, 22 };
1434
1435static const unsigned int power_3516_pins[] = { 20, 83, 40, 41, 60, 61, 62 };
1436
1437static const unsigned int cir_3516_pins[] = { 85, 64, 82 };
1438
1439static const unsigned int system_3516_pins[] = {
1440 332, 392, 372, 373, 393, 352, 331, 388, 397, 77
1441};
1442
1443static const unsigned int vcontrol_3516_pins[] = { 86, 81, 80 };
1444
1445static const unsigned int ice_3516_pins[] = { 340, 341, 303, 322, 380, 284, 343 };
1446
1447static const unsigned int ide_3516_pins[] = {
1448 200, 201, 204, 220, 221, 222, 223, 224, 240, 241, 242, 243, 244, 260,
1449 261, 262, 263, 264, 280, 281, 282, 283, 300, 301, 302, 320, 321, 360
1450};
1451
1452static const unsigned int sata_3516_pins[] = {
1453 100, 101, 102, 103, 104, 120, 121, 122, 123, 124, 140, 141, 142, 143,
1454 144, 160, 161, 162, 163, 180, 181, 182, 183, 202
1455};
1456
1457static const unsigned int usb_3516_pins[] = {
1458 305, 324, 344, 362, 363, 364, 365, 366, 381, 382, 383, 384, 385
1459};
1460
1461/* GMII, ethernet pins */
Linus Walleij756a0242017-11-06 21:27:34 +01001462static const unsigned int gmii_gmac0_3516_pins[] = {
1463 306, 307, 325, 326, 327, 328, 345, 346, 347, 348, 367, 368, 386, 387
1464};
1465
1466static const unsigned int gmii_gmac1_3516_pins[] = {
1467 308, 309, 310, 329, 330, 349, 350, 351, 369, 370, 371, 389, 390, 391
Linus Walleij06351d12017-08-05 23:04:08 +02001468};
1469
1470static const unsigned int pci_3516_pins[] = {
1471 17, 18, 19, 39, 58, 59, 78, 79, 96, 97, 98, 99, 115, 116, 117, 118,
1472 119, 135, 136, 137, 138, 139, 155, 156, 157, 158, 159, 175, 176, 177,
1473 178, 179, 195, 196, 197, 198, 199, 215, 216, 217, 218, 219, 235, 236,
1474 237, 238, 239, 255, 256, 257, 258, 259, 277, 278, 279, 299
1475};
1476
1477/*
1478 * Apparently the LPC interface is using the PCICLK for the clocking so
1479 * PCI needs to be active at the same time.
1480 */
1481static const unsigned int lpc_3516_pins[] = {
1482 355, /* LPC_LAD[0] */
1483 356, /* LPC_SERIRQ */
1484 377, /* LPC_LAD[2] */
1485 398, /* LPC_LFRAME# */
1486 316, /* LPC_LAD[3] */
1487 399, /* LPC_LAD[1] */
1488};
1489
1490/* Character LCD */
1491static const unsigned int lcd_3516_pins[] = {
1492 391, 351, 310, 371, 353, 311, 394, 374, 314, 359, 339
1493};
1494
1495static const unsigned int ssp_3516_pins[] = {
1496 355, /* SSP_97RST# SSP AC97 Reset, active low */
1497 356, /* SSP_FSC */
1498 377, /* SSP_ECLK */
1499 398, /* SSP_TXD */
1500 316, /* SSP_RXD */
1501 399, /* SSP_SCLK */
1502};
1503
1504static const unsigned int uart_rxtx_3516_pins[] = {
1505 313, /* UART_SIN serial input, RX */
1506 335, /* UART_SOUT serial output, TX */
1507};
1508
1509static const unsigned int uart_modem_3516_pins[] = {
1510 355, /* UART_NDCD DCD carrier detect */
1511 356, /* UART_NDTR DTR data terminal ready */
1512 377, /* UART_NDSR DSR data set ready */
1513 398, /* UART_NRTS RTS request to send */
1514 316, /* UART_NCTS CTS clear to send */
1515 399, /* UART_NRI RI ring indicator */
1516};
1517
1518static const unsigned int tvc_3516_pins[] = {
1519 353, /* TVC_DATA[0] */
1520 311, /* TVC_DATA[1] */
1521 394, /* TVC_DATA[2] */
1522 374, /* TVC_DATA[3] */
1523 333, /* TVC_CLK */
1524 354, /* TVC_DATA[4] */
1525 395, /* TVC_DATA[5] */
1526 312, /* TVC_DATA[6] */
1527 334, /* TVC_DATA[7] */
1528};
1529
1530/* NAND flash pins */
1531static const unsigned int nflash_3516_pins[] = {
1532 243, 260, 261, 224, 280, 262, 281, 264, 300, 263, 282, 301, 320, 283,
1533 302, 321, 337, 358, 295, 359, 339, 275, 298
1534};
1535
1536/* Parallel (NOR) flash pins, D[0-15], A[16-25], CE0, CE1, RB, WE, OE, ALE */
1537static const unsigned int pflash_3516_pins[] = {
1538 221, 200, 222, 201, 220, 243, 260, 261, 224, 280, 262, 281, 264, 300,
1539 263, 282, 301, 320, 283, 302, 321, 317, 379, 295, 359, 339, 297, 318,
1540 276, 319, 275, 298
1541};
1542
1543/*
1544 * The parallel flash can be set up in a 26-bit address bus mode exposing
1545 * A[0-15] (A[15] takes the place of ALE), but it has the
1546 * side effect of stealing pins from GMAC1 and TVC so these blocks cannot be
1547 * used at the same time.
1548 */
1549static const unsigned int pflash_3516_pins_extended[] = {
1550 221, 200, 222, 201, 220, 243, 260, 261, 224, 280, 262, 281, 264, 300,
1551 263, 282, 301, 320, 283, 302, 321, 317, 379, 295, 359, 339, 297, 318,
1552 276, 319, 275, 298,
1553 /* The extra pins */
1554 349, 308, 369, 389, 329, 350, 370, 309, 390, 391, 351, 310, 371, 330,
1555 333
1556};
1557
1558/* Serial flash pins CE0, CE1, DI, DO, CK */
1559static const unsigned int sflash_3516_pins[] = { 296, 338, 295, 359, 339 };
1560
1561/* The GPIO0A (0-4) pins overlap with TVC and extended parallel flash */
1562static const unsigned int gpio0a_3516_pins[] = { 333, 354, 395, 312, 334 };
1563
1564/* The GPIO0B (5-7) pins overlap with ICE */
1565static const unsigned int gpio0b_3516_pins[] = { 375, 396, 376 };
1566
1567/* The GPIO0C (8,11-15) pins overlap with LPC, UART and SSP */
1568static const unsigned int gpio0c_3516_pins[] = { 355, 356, 377, 398, 316, 399 };
1569
1570/* The GPIO0D (9,10) pins overlap with UART RX/TX */
1571static const unsigned int gpio0d_3516_pins[] = { 313, 335 };
1572
1573/* The GPIO0E (16) pins overlap with LCD */
1574static const unsigned int gpio0e_3516_pins[] = { 314 };
1575
1576/* The GPIO0F (17,18) pins overlap with NAND flash CE0, CE1 */
1577static const unsigned int gpio0f_3516_pins[] = { 337, 358 };
1578
1579/* The GPIO0G (19,20,26-29) pins overlap with parallel flash */
1580static const unsigned int gpio0g_3516_pins[] = { 317, 379, 297, 318, 276, 319 };
1581
1582/* The GPIO0H (21,22) pins overlap with serial flash CE0, CE1 */
1583static const unsigned int gpio0h_3516_pins[] = { 296, 338 };
1584
1585/* The GPIO0I (23) pins overlap with all flash */
1586static const unsigned int gpio0i_3516_pins[] = { 295 };
1587
1588/* The GPIO0J (24,25) pins overlap with all flash and LCD */
1589static const unsigned int gpio0j_3516_pins[] = { 359, 339 };
1590
1591/* The GPIO0K (30,31) pins overlap with NAND flash */
1592static const unsigned int gpio0k_3516_pins[] = { 275, 298 };
1593
1594/* The GPIO1A (0-4) pins that overlap with IDE and parallel flash */
1595static const unsigned int gpio1a_3516_pins[] = { 221, 200, 222, 201, 220 };
1596
1597/* The GPIO1B (5-10,27) pins overlap with just IDE */
1598static const unsigned int gpio1b_3516_pins[] = { 241, 223, 240, 204, 242, 244, 360 };
1599
1600/* The GPIO1C (11-26) pins overlap with IDE, parallel flash and NAND flash */
1601static const unsigned int gpio1c_3516_pins[] = {
1602 243, 260, 261, 224, 280, 262, 281, 264, 300, 263, 282, 301, 320, 283,
1603 302, 321
1604};
1605
1606/* The GPIO1D (28-31) pins overlap with TVC */
1607static const unsigned int gpio1d_3516_pins[] = { 353, 311, 394, 374 };
1608
Linus Walleij756a0242017-11-06 21:27:34 +01001609/* The GPIO2A (0-3) pins overlap with GMII GMAC1 and extended parallel flash */
Linus Walleij06351d12017-08-05 23:04:08 +02001610static const unsigned int gpio2a_3516_pins[] = { 308, 369, 389, 329 };
1611
Linus Walleij756a0242017-11-06 21:27:34 +01001612/* The GPIO2B (4-7) pins overlap with GMII GMAC1, extended parallel flash and LCD */
Linus Walleij06351d12017-08-05 23:04:08 +02001613static const unsigned int gpio2b_3516_pins[] = { 391, 351, 310, 371 };
1614
1615/* The GPIO2C (8-31) pins overlap with PCI */
1616static const unsigned int gpio2c_3516_pins[] = {
1617 259, 237, 238, 239, 215, 216, 217, 218, 177, 159, 158, 175, 176, 139,
1618 157, 138, 137, 156, 118, 155, 99, 98, 136, 117
1619};
1620
1621/* Groups for the 3516 SoC/package */
1622static const struct gemini_pin_group gemini_3516_pin_groups[] = {
1623 {
1624 .name = "gndgrp",
1625 .pins = gnd_3516_pins,
1626 .num_pins = ARRAY_SIZE(gnd_3516_pins),
1627 },
1628 {
1629 .name = "dramgrp",
1630 .pins = dram_3516_pins,
1631 .num_pins = ARRAY_SIZE(dram_3516_pins),
1632 .mask = DRAM_PADS_POWERDOWN,
1633 },
1634 {
1635 .name = "rtcgrp",
1636 .pins = rtc_3516_pins,
1637 .num_pins = ARRAY_SIZE(rtc_3516_pins),
1638 },
1639 {
1640 .name = "powergrp",
1641 .pins = power_3516_pins,
1642 .num_pins = ARRAY_SIZE(power_3516_pins),
1643 },
1644 {
1645 .name = "cirgrp",
1646 .pins = cir_3516_pins,
1647 .num_pins = ARRAY_SIZE(cir_3516_pins),
1648 },
1649 {
1650 .name = "systemgrp",
1651 .pins = system_3516_pins,
1652 .num_pins = ARRAY_SIZE(system_3516_pins),
1653 },
1654 {
1655 .name = "vcontrolgrp",
1656 .pins = vcontrol_3516_pins,
1657 .num_pins = ARRAY_SIZE(vcontrol_3516_pins),
1658 },
1659 {
1660 .name = "icegrp",
1661 .pins = ice_3516_pins,
1662 .num_pins = ARRAY_SIZE(ice_3516_pins),
1663 /* Conflict with some GPIO groups */
1664 },
1665 {
1666 .name = "idegrp",
1667 .pins = ide_3516_pins,
1668 .num_pins = ARRAY_SIZE(ide_3516_pins),
1669 /* Conflict with all flash usage */
1670 .value = IDE_PADS_ENABLE | NAND_PADS_DISABLE |
1671 PFLASH_PADS_DISABLE | SFLASH_PADS_DISABLE,
1672 },
1673 {
1674 .name = "satagrp",
1675 .pins = sata_3516_pins,
1676 .num_pins = ARRAY_SIZE(sata_3516_pins),
1677 },
1678 {
1679 .name = "usbgrp",
1680 .pins = usb_3516_pins,
1681 .num_pins = ARRAY_SIZE(usb_3516_pins),
1682 },
1683 {
Linus Walleij756a0242017-11-06 21:27:34 +01001684 .name = "gmii_gmac0_grp",
1685 .pins = gmii_gmac0_3516_pins,
1686 .num_pins = ARRAY_SIZE(gmii_gmac0_3516_pins),
1687 },
1688 {
1689 .name = "gmii_gmac1_grp",
1690 .pins = gmii_gmac1_3516_pins,
1691 .num_pins = ARRAY_SIZE(gmii_gmac1_3516_pins),
1692 /* Bring out RGMII on the GMAC1 pins */
1693 .value = GEMINI_GMAC_IOSEL_GMAC0_GMAC1_RGMII,
Linus Walleij06351d12017-08-05 23:04:08 +02001694 },
1695 {
1696 .name = "pcigrp",
1697 .pins = pci_3516_pins,
1698 .num_pins = ARRAY_SIZE(pci_3516_pins),
1699 /* Conflict only with GPIO2 */
1700 .value = PCI_PADS_ENABLE | PCI_CLK_PAD_ENABLE,
1701 },
1702 {
1703 .name = "lpcgrp",
1704 .pins = lpc_3516_pins,
1705 .num_pins = ARRAY_SIZE(lpc_3516_pins),
1706 /* Conflict with SSP */
1707 .mask = SSP_PADS_ENABLE,
1708 .value = LPC_PADS_ENABLE | LPC_CLK_PAD_ENABLE,
1709 },
1710 {
1711 .name = "lcdgrp",
1712 .pins = lcd_3516_pins,
1713 .num_pins = ARRAY_SIZE(lcd_3516_pins),
1714 .mask = TVC_PADS_ENABLE,
1715 .value = LCD_PADS_ENABLE,
1716 },
1717 {
1718 .name = "sspgrp",
1719 .pins = ssp_3516_pins,
1720 .num_pins = ARRAY_SIZE(ssp_3516_pins),
1721 /* Conflict with LPC */
1722 .mask = LPC_PADS_ENABLE,
1723 .value = SSP_PADS_ENABLE,
1724 },
1725 {
1726 .name = "uartrxtxgrp",
1727 .pins = uart_rxtx_3516_pins,
1728 .num_pins = ARRAY_SIZE(uart_rxtx_3516_pins),
1729 /* No conflicts except GPIO */
1730 },
1731 {
1732 .name = "uartmodemgrp",
1733 .pins = uart_modem_3516_pins,
1734 .num_pins = ARRAY_SIZE(uart_modem_3516_pins),
1735 /*
1736 * Conflict with LPC and SSP,
1737 * so when those are both disabled, modem UART can thrive.
1738 */
1739 .mask = LPC_PADS_ENABLE | SSP_PADS_ENABLE,
1740 },
1741 {
1742 .name = "tvcgrp",
1743 .pins = tvc_3516_pins,
1744 .num_pins = ARRAY_SIZE(tvc_3516_pins),
1745 /* Conflict with character LCD */
1746 .mask = LCD_PADS_ENABLE,
1747 .value = TVC_PADS_ENABLE | TVC_CLK_PAD_ENABLE,
1748 },
1749 /*
1750 * The construction is done such that it is possible to use a serial
1751 * flash together with a NAND or parallel (NOR) flash, but it is not
1752 * possible to use NAND and parallel flash together. To use serial
1753 * flash with one of the two others, the muxbits need to be flipped
1754 * around before any access.
1755 */
1756 {
1757 .name = "nflashgrp",
1758 .pins = nflash_3516_pins,
1759 .num_pins = ARRAY_SIZE(nflash_3516_pins),
1760 /* Conflict with IDE, parallel and serial flash */
1761 .mask = NAND_PADS_DISABLE | IDE_PADS_ENABLE,
1762 .value = PFLASH_PADS_DISABLE | SFLASH_PADS_DISABLE,
1763 },
1764 {
1765 .name = "pflashgrp",
1766 .pins = pflash_3516_pins,
1767 .num_pins = ARRAY_SIZE(pflash_3516_pins),
1768 /* Conflict with IDE, NAND and serial flash */
1769 .mask = PFLASH_PADS_DISABLE | IDE_PADS_ENABLE,
1770 .value = NAND_PADS_DISABLE | SFLASH_PADS_DISABLE,
1771 },
1772 {
1773 .name = "sflashgrp",
1774 .pins = sflash_3516_pins,
1775 .num_pins = ARRAY_SIZE(sflash_3516_pins),
1776 /* Conflict with IDE, NAND and parallel flash */
1777 .mask = SFLASH_PADS_DISABLE | IDE_PADS_ENABLE,
1778 .value = NAND_PADS_DISABLE | PFLASH_PADS_DISABLE,
1779 },
1780 {
1781 .name = "gpio0agrp",
1782 .pins = gpio0a_3516_pins,
1783 .num_pins = ARRAY_SIZE(gpio0a_3516_pins),
1784 /* Conflict with TVC and ICE */
1785 .mask = TVC_PADS_ENABLE,
1786 },
1787 {
1788 .name = "gpio0bgrp",
1789 .pins = gpio0b_3516_pins,
1790 .num_pins = ARRAY_SIZE(gpio0b_3516_pins),
1791 /* Conflict with ICE */
1792 },
1793 {
1794 .name = "gpio0cgrp",
1795 .pins = gpio0c_3516_pins,
1796 .num_pins = ARRAY_SIZE(gpio0c_3516_pins),
1797 /* Conflict with LPC, UART and SSP */
1798 .mask = LPC_PADS_ENABLE | SSP_PADS_ENABLE,
1799 },
1800 {
1801 .name = "gpio0dgrp",
1802 .pins = gpio0d_3516_pins,
1803 .num_pins = ARRAY_SIZE(gpio0d_3516_pins),
1804 /* Conflict with UART */
1805 },
1806 {
1807 .name = "gpio0egrp",
1808 .pins = gpio0e_3516_pins,
1809 .num_pins = ARRAY_SIZE(gpio0e_3516_pins),
1810 /* Conflict with LCD */
1811 .mask = LCD_PADS_ENABLE,
1812 },
1813 {
1814 .name = "gpio0fgrp",
1815 .pins = gpio0f_3516_pins,
1816 .num_pins = ARRAY_SIZE(gpio0f_3516_pins),
1817 /* Conflict with NAND flash */
1818 .value = NAND_PADS_DISABLE,
1819 },
1820 {
1821 .name = "gpio0ggrp",
1822 .pins = gpio0g_3516_pins,
1823 .num_pins = ARRAY_SIZE(gpio0g_3516_pins),
1824 /* Conflict with parallel flash */
1825 .value = PFLASH_PADS_DISABLE,
1826 },
1827 {
1828 .name = "gpio0hgrp",
1829 .pins = gpio0h_3516_pins,
1830 .num_pins = ARRAY_SIZE(gpio0h_3516_pins),
1831 /* Conflict with serial flash */
1832 .value = SFLASH_PADS_DISABLE,
1833 },
1834 {
1835 .name = "gpio0igrp",
1836 .pins = gpio0i_3516_pins,
1837 .num_pins = ARRAY_SIZE(gpio0i_3516_pins),
1838 /* Conflict with all flash */
1839 .value = PFLASH_PADS_DISABLE | NAND_PADS_DISABLE |
1840 SFLASH_PADS_DISABLE,
1841 },
1842 {
1843 .name = "gpio0jgrp",
1844 .pins = gpio0j_3516_pins,
1845 .num_pins = ARRAY_SIZE(gpio0j_3516_pins),
1846 /* Conflict with all flash and LCD */
1847 .mask = LCD_PADS_ENABLE,
1848 .value = PFLASH_PADS_DISABLE | NAND_PADS_DISABLE |
1849 SFLASH_PADS_DISABLE,
1850 },
1851 {
1852 .name = "gpio0kgrp",
1853 .pins = gpio0k_3516_pins,
1854 .num_pins = ARRAY_SIZE(gpio0k_3516_pins),
1855 /* Conflict with parallel and NAND flash */
1856 .value = PFLASH_PADS_DISABLE | NAND_PADS_DISABLE,
1857 },
1858 {
1859 .name = "gpio1agrp",
1860 .pins = gpio1a_3516_pins,
1861 .num_pins = ARRAY_SIZE(gpio1a_3516_pins),
1862 /* Conflict with IDE and parallel flash */
1863 .mask = IDE_PADS_ENABLE,
1864 .value = PFLASH_PADS_DISABLE,
1865 },
1866 {
1867 .name = "gpio1bgrp",
1868 .pins = gpio1b_3516_pins,
1869 .num_pins = ARRAY_SIZE(gpio1b_3516_pins),
1870 /* Conflict with IDE only */
1871 .mask = IDE_PADS_ENABLE,
1872 },
1873 {
1874 .name = "gpio1cgrp",
1875 .pins = gpio1c_3516_pins,
1876 .num_pins = ARRAY_SIZE(gpio1c_3516_pins),
1877 /* Conflict with IDE, parallel and NAND flash */
1878 .mask = IDE_PADS_ENABLE,
1879 .value = NAND_PADS_DISABLE | PFLASH_PADS_DISABLE,
1880 },
1881 {
1882 .name = "gpio1dgrp",
1883 .pins = gpio1d_3516_pins,
1884 .num_pins = ARRAY_SIZE(gpio1d_3516_pins),
1885 /* Conflict with TVC */
1886 .mask = TVC_PADS_ENABLE,
1887 },
1888 {
1889 .name = "gpio2agrp",
1890 .pins = gpio2a_3516_pins,
1891 .num_pins = ARRAY_SIZE(gpio2a_3516_pins),
Linus Walleij756a0242017-11-06 21:27:34 +01001892 .mask = GEMINI_GMAC_IOSEL_GMAC0_GMAC1_RGMII,
1893 /* Conflict with GMII GMAC1 and extended parallel flash */
Linus Walleij06351d12017-08-05 23:04:08 +02001894 },
1895 {
1896 .name = "gpio2bgrp",
1897 .pins = gpio2b_3516_pins,
1898 .num_pins = ARRAY_SIZE(gpio2b_3516_pins),
Linus Walleij756a0242017-11-06 21:27:34 +01001899 /* Conflict with GMII GMAC1, extended parallel flash and LCD */
1900 .mask = LCD_PADS_ENABLE | GEMINI_GMAC_IOSEL_GMAC0_GMAC1_RGMII,
Linus Walleij06351d12017-08-05 23:04:08 +02001901 },
1902 {
1903 .name = "gpio2cgrp",
1904 .pins = gpio2c_3516_pins,
1905 .num_pins = ARRAY_SIZE(gpio2c_3516_pins),
1906 /* Conflict with PCI */
1907 .mask = PCI_PADS_ENABLE,
1908 },
1909};
1910
1911static int gemini_get_groups_count(struct pinctrl_dev *pctldev)
1912{
1913 struct gemini_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
1914
1915 if (pmx->is_3512)
1916 return ARRAY_SIZE(gemini_3512_pin_groups);
1917 if (pmx->is_3516)
1918 return ARRAY_SIZE(gemini_3516_pin_groups);
1919 return 0;
1920}
1921
1922static const char *gemini_get_group_name(struct pinctrl_dev *pctldev,
1923 unsigned int selector)
1924{
1925 struct gemini_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
1926
1927 if (pmx->is_3512)
1928 return gemini_3512_pin_groups[selector].name;
1929 if (pmx->is_3516)
1930 return gemini_3516_pin_groups[selector].name;
1931 return NULL;
1932}
1933
1934static int gemini_get_group_pins(struct pinctrl_dev *pctldev,
1935 unsigned int selector,
1936 const unsigned int **pins,
1937 unsigned int *num_pins)
1938{
1939 struct gemini_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
1940
1941 /* The special case with the 3516 flash pin */
1942 if (pmx->flash_pin &&
1943 pmx->is_3512 &&
1944 !strcmp(gemini_3512_pin_groups[selector].name, "pflashgrp")) {
1945 *pins = pflash_3512_pins_extended;
1946 *num_pins = ARRAY_SIZE(pflash_3512_pins_extended);
1947 return 0;
1948 }
1949 if (pmx->flash_pin &&
1950 pmx->is_3516 &&
1951 !strcmp(gemini_3516_pin_groups[selector].name, "pflashgrp")) {
1952 *pins = pflash_3516_pins_extended;
1953 *num_pins = ARRAY_SIZE(pflash_3516_pins_extended);
1954 return 0;
1955 }
1956 if (pmx->is_3512) {
1957 *pins = gemini_3512_pin_groups[selector].pins;
1958 *num_pins = gemini_3512_pin_groups[selector].num_pins;
1959 }
1960 if (pmx->is_3516) {
1961 *pins = gemini_3516_pin_groups[selector].pins;
1962 *num_pins = gemini_3516_pin_groups[selector].num_pins;
1963 }
1964 return 0;
1965}
1966
1967static void gemini_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
1968 unsigned int offset)
1969{
1970 seq_printf(s, " " DRIVER_NAME);
1971}
1972
Linus Walleij06351d12017-08-05 23:04:08 +02001973static const struct pinctrl_ops gemini_pctrl_ops = {
1974 .get_groups_count = gemini_get_groups_count,
1975 .get_group_name = gemini_get_group_name,
1976 .get_group_pins = gemini_get_group_pins,
1977 .pin_dbg_show = gemini_pin_dbg_show,
Linus Walleij60ad4812017-10-28 15:37:19 +02001978 .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
Linus Walleij1c5b7f32017-10-28 15:37:18 +02001979 .dt_free_map = pinconf_generic_dt_free_map,
Linus Walleij06351d12017-08-05 23:04:08 +02001980};
1981
1982/**
1983 * struct gemini_pmx_func - describes Gemini pinmux functions
1984 * @name: the name of this specific function
1985 * @groups: corresponding pin groups
1986 */
1987struct gemini_pmx_func {
1988 const char *name;
1989 const char * const *groups;
1990 const unsigned int num_groups;
1991};
1992
1993static const char * const dramgrps[] = { "dramgrp" };
1994static const char * const rtcgrps[] = { "rtcgrp" };
1995static const char * const powergrps[] = { "powergrp" };
1996static const char * const cirgrps[] = { "cirgrp" };
1997static const char * const systemgrps[] = { "systemgrp" };
1998static const char * const vcontrolgrps[] = { "vcontrolgrp" };
1999static const char * const icegrps[] = { "icegrp" };
2000static const char * const idegrps[] = { "idegrp" };
2001static const char * const satagrps[] = { "satagrp" };
2002static const char * const usbgrps[] = { "usbgrp" };
Linus Walleij756a0242017-11-06 21:27:34 +01002003static const char * const gmiigrps[] = { "gmii_gmac0_grp", "gmii_gmac1_grp" };
Linus Walleij06351d12017-08-05 23:04:08 +02002004static const char * const pcigrps[] = { "pcigrp" };
2005static const char * const lpcgrps[] = { "lpcgrp" };
2006static const char * const lcdgrps[] = { "lcdgrp" };
2007static const char * const sspgrps[] = { "sspgrp" };
2008static const char * const uartgrps[] = { "uartrxtxgrp", "uartmodemgrp" };
2009static const char * const tvcgrps[] = { "tvcgrp" };
2010static const char * const nflashgrps[] = { "nflashgrp" };
2011static const char * const pflashgrps[] = { "pflashgrp", "pflashextgrp" };
2012static const char * const sflashgrps[] = { "sflashgrp" };
2013static const char * const gpio0grps[] = { "gpio0agrp", "gpio0bgrp", "gpio0cgrp",
2014 "gpio0dgrp", "gpio0egrp", "gpio0fgrp",
2015 "gpio0ggrp", "gpio0hgrp", "gpio0igrp",
2016 "gpio0jgrp", "gpio0kgrp" };
2017static const char * const gpio1grps[] = { "gpio1agrp", "gpio1bgrp", "gpio1cgrp",
2018 "gpio1dgrp" };
2019static const char * const gpio2grps[] = { "gpio2agrp", "gpio2bgrp", "gpio2cgrp" };
2020
2021static const struct gemini_pmx_func gemini_pmx_functions[] = {
2022 {
2023 .name = "dram",
2024 .groups = dramgrps,
2025 .num_groups = ARRAY_SIZE(idegrps),
2026 },
2027 {
2028 .name = "rtc",
2029 .groups = rtcgrps,
2030 .num_groups = ARRAY_SIZE(rtcgrps),
2031 },
2032 {
2033 .name = "power",
2034 .groups = powergrps,
2035 .num_groups = ARRAY_SIZE(powergrps),
2036 },
2037 {
2038 /* This function is strictly unavailable on 3512 */
2039 .name = "cir",
2040 .groups = cirgrps,
2041 .num_groups = ARRAY_SIZE(cirgrps),
2042 },
2043 {
2044 .name = "system",
2045 .groups = systemgrps,
2046 .num_groups = ARRAY_SIZE(systemgrps),
2047 },
2048 {
2049 .name = "vcontrol",
2050 .groups = vcontrolgrps,
2051 .num_groups = ARRAY_SIZE(vcontrolgrps),
2052 },
2053 {
2054 .name = "ice",
2055 .groups = icegrps,
2056 .num_groups = ARRAY_SIZE(icegrps),
2057 },
2058 {
2059 .name = "ide",
2060 .groups = idegrps,
2061 .num_groups = ARRAY_SIZE(idegrps),
2062 },
2063 {
2064 .name = "sata",
2065 .groups = satagrps,
2066 .num_groups = ARRAY_SIZE(satagrps),
2067 },
2068 {
Linus Walleij89aab2d2017-10-14 17:13:03 +02002069 .name = "usb",
2070 .groups = usbgrps,
2071 .num_groups = ARRAY_SIZE(usbgrps),
2072 },
2073 {
2074 .name = "gmii",
2075 .groups = gmiigrps,
2076 .num_groups = ARRAY_SIZE(gmiigrps),
2077 },
2078 {
Linus Walleij06351d12017-08-05 23:04:08 +02002079 .name = "pci",
2080 .groups = pcigrps,
2081 .num_groups = ARRAY_SIZE(pcigrps),
2082 },
2083 {
2084 .name = "lpc",
2085 .groups = lpcgrps,
2086 .num_groups = ARRAY_SIZE(lpcgrps),
2087 },
2088 {
2089 .name = "lcd",
2090 .groups = lcdgrps,
2091 .num_groups = ARRAY_SIZE(lcdgrps),
2092 },
2093 {
2094 .name = "ssp",
2095 .groups = sspgrps,
2096 .num_groups = ARRAY_SIZE(sspgrps),
2097 },
2098 {
2099 .name = "uart",
2100 .groups = uartgrps,
2101 .num_groups = ARRAY_SIZE(uartgrps),
2102 },
2103 {
2104 .name = "tvc",
2105 .groups = tvcgrps,
2106 .num_groups = ARRAY_SIZE(tvcgrps),
2107 },
2108 {
2109 .name = "nflash",
2110 .groups = nflashgrps,
2111 .num_groups = ARRAY_SIZE(nflashgrps),
2112 },
2113 {
2114 .name = "pflash",
2115 .groups = pflashgrps,
2116 .num_groups = ARRAY_SIZE(pflashgrps),
2117 },
2118 {
2119 .name = "sflash",
2120 .groups = sflashgrps,
2121 .num_groups = ARRAY_SIZE(sflashgrps),
2122 },
2123 {
2124 .name = "gpio0",
2125 .groups = gpio0grps,
2126 .num_groups = ARRAY_SIZE(gpio0grps),
2127 },
2128 {
2129 .name = "gpio1",
2130 .groups = gpio1grps,
2131 .num_groups = ARRAY_SIZE(gpio1grps),
2132 },
2133 {
2134 .name = "gpio2",
2135 .groups = gpio2grps,
2136 .num_groups = ARRAY_SIZE(gpio2grps),
2137 },
2138};
2139
2140
2141static int gemini_pmx_set_mux(struct pinctrl_dev *pctldev,
2142 unsigned int selector,
2143 unsigned int group)
2144{
2145 struct gemini_pmx *pmx;
2146 const struct gemini_pmx_func *func;
2147 const struct gemini_pin_group *grp;
2148 u32 before, after, expected;
2149 unsigned long tmp;
2150 int i;
2151
2152 pmx = pinctrl_dev_get_drvdata(pctldev);
2153
2154 func = &gemini_pmx_functions[selector];
2155 if (pmx->is_3512)
2156 grp = &gemini_3512_pin_groups[group];
2157 else if (pmx->is_3516)
2158 grp = &gemini_3516_pin_groups[group];
2159 else {
2160 dev_err(pmx->dev, "invalid SoC type\n");
2161 return -ENODEV;
2162 }
2163
2164 dev_info(pmx->dev,
2165 "ACTIVATE function \"%s\" with group \"%s\"\n",
2166 func->name, grp->name);
2167
2168 regmap_read(pmx->map, GLOBAL_MISC_CTRL, &before);
2169 regmap_update_bits(pmx->map, GLOBAL_MISC_CTRL, grp->mask,
2170 grp->value);
2171 regmap_read(pmx->map, GLOBAL_MISC_CTRL, &after);
2172
2173 /* Which bits changed */
2174 before &= PADS_MASK;
2175 after &= PADS_MASK;
2176 expected = before &= ~grp->mask;
2177 expected |= grp->value;
2178 expected &= PADS_MASK;
2179
2180 /* Print changed states */
2181 tmp = grp->mask;
2182 for_each_set_bit(i, &tmp, PADS_MAXBIT) {
2183 bool enabled = !(i > 3);
2184
2185 /* Did not go low though it should */
2186 if (after & BIT(i)) {
2187 dev_err(pmx->dev,
2188 "pin group %s could not be %s: "
2189 "probably a hardware limitation\n",
2190 gemini_padgroups[i],
2191 enabled ? "enabled" : "disabled");
2192 dev_err(pmx->dev,
2193 "GLOBAL MISC CTRL before: %08x, after %08x, expected %08x\n",
2194 before, after, expected);
2195 } else {
2196 dev_info(pmx->dev,
2197 "padgroup %s %s\n",
2198 gemini_padgroups[i],
2199 enabled ? "enabled" : "disabled");
2200 }
2201 }
2202
2203 tmp = grp->value;
2204 for_each_set_bit(i, &tmp, PADS_MAXBIT) {
2205 bool enabled = (i > 3);
2206
2207 /* Did not go high though it should */
2208 if (!(after & BIT(i))) {
2209 dev_err(pmx->dev,
2210 "pin group %s could not be %s: "
2211 "probably a hardware limitation\n",
2212 gemini_padgroups[i],
2213 enabled ? "enabled" : "disabled");
2214 dev_err(pmx->dev,
2215 "GLOBAL MISC CTRL before: %08x, after %08x, expected %08x\n",
2216 before, after, expected);
2217 } else {
2218 dev_info(pmx->dev,
2219 "padgroup %s %s\n",
2220 gemini_padgroups[i],
2221 enabled ? "enabled" : "disabled");
2222 }
2223 }
2224
2225 return 0;
2226}
2227
2228static int gemini_pmx_get_funcs_count(struct pinctrl_dev *pctldev)
2229{
2230 return ARRAY_SIZE(gemini_pmx_functions);
2231}
2232
2233static const char *gemini_pmx_get_func_name(struct pinctrl_dev *pctldev,
2234 unsigned int selector)
2235{
2236 return gemini_pmx_functions[selector].name;
2237}
2238
2239static int gemini_pmx_get_groups(struct pinctrl_dev *pctldev,
2240 unsigned int selector,
2241 const char * const **groups,
2242 unsigned int * const num_groups)
2243{
2244 *groups = gemini_pmx_functions[selector].groups;
2245 *num_groups = gemini_pmx_functions[selector].num_groups;
2246 return 0;
2247}
2248
2249static const struct pinmux_ops gemini_pmx_ops = {
2250 .get_functions_count = gemini_pmx_get_funcs_count,
2251 .get_function_name = gemini_pmx_get_func_name,
2252 .get_function_groups = gemini_pmx_get_groups,
2253 .set_mux = gemini_pmx_set_mux,
2254};
2255
Linus Walleij60ad4812017-10-28 15:37:19 +02002256#define GEMINI_CFGPIN(_n, _r, _lb, _hb) { \
2257 .pin = _n, \
2258 .reg = _r, \
2259 .mask = GENMASK(_hb, _lb) \
2260}
2261
2262static const struct gemini_pin_conf gemini_confs_3512[] = {
2263 GEMINI_CFGPIN(259, GLOBAL_GMAC_CTRL_SKEW, 0, 3), /* GMAC0 RXDV */
2264 GEMINI_CFGPIN(277, GLOBAL_GMAC_CTRL_SKEW, 4, 7), /* GMAC0 RXC */
2265 GEMINI_CFGPIN(241, GLOBAL_GMAC_CTRL_SKEW, 8, 11), /* GMAC0 TXEN */
2266 GEMINI_CFGPIN(312, GLOBAL_GMAC_CTRL_SKEW, 12, 15), /* GMAC0 TXC */
2267 GEMINI_CFGPIN(298, GLOBAL_GMAC_CTRL_SKEW, 16, 19), /* GMAC1 RXDV */
2268 GEMINI_CFGPIN(280, GLOBAL_GMAC_CTRL_SKEW, 20, 23), /* GMAC1 RXC */
2269 GEMINI_CFGPIN(316, GLOBAL_GMAC_CTRL_SKEW, 24, 27), /* GMAC1 TXEN */
2270 GEMINI_CFGPIN(243, GLOBAL_GMAC_CTRL_SKEW, 28, 31), /* GMAC1 TXC */
2271 GEMINI_CFGPIN(295, GLOBAL_GMAC0_DATA_SKEW, 0, 3), /* GMAC0 RXD0 */
2272 GEMINI_CFGPIN(313, GLOBAL_GMAC0_DATA_SKEW, 4, 7), /* GMAC0 RXD1 */
2273 GEMINI_CFGPIN(242, GLOBAL_GMAC0_DATA_SKEW, 8, 11), /* GMAC0 RXD2 */
2274 GEMINI_CFGPIN(260, GLOBAL_GMAC0_DATA_SKEW, 12, 15), /* GMAC0 RXD3 */
2275 GEMINI_CFGPIN(294, GLOBAL_GMAC0_DATA_SKEW, 16, 19), /* GMAC0 TXD0 */
2276 GEMINI_CFGPIN(276, GLOBAL_GMAC0_DATA_SKEW, 20, 23), /* GMAC0 TXD1 */
2277 GEMINI_CFGPIN(258, GLOBAL_GMAC0_DATA_SKEW, 24, 27), /* GMAC0 TXD2 */
2278 GEMINI_CFGPIN(240, GLOBAL_GMAC0_DATA_SKEW, 28, 31), /* GMAC0 TXD3 */
2279 GEMINI_CFGPIN(262, GLOBAL_GMAC1_DATA_SKEW, 0, 3), /* GMAC1 RXD0 */
2280 GEMINI_CFGPIN(244, GLOBAL_GMAC1_DATA_SKEW, 4, 7), /* GMAC1 RXD1 */
2281 GEMINI_CFGPIN(317, GLOBAL_GMAC1_DATA_SKEW, 8, 11), /* GMAC1 RXD2 */
2282 GEMINI_CFGPIN(299, GLOBAL_GMAC1_DATA_SKEW, 12, 15), /* GMAC1 RXD3 */
2283 GEMINI_CFGPIN(261, GLOBAL_GMAC1_DATA_SKEW, 16, 19), /* GMAC1 TXD0 */
2284 GEMINI_CFGPIN(279, GLOBAL_GMAC1_DATA_SKEW, 20, 23), /* GMAC1 TXD1 */
2285 GEMINI_CFGPIN(297, GLOBAL_GMAC1_DATA_SKEW, 24, 27), /* GMAC1 TXD2 */
2286 GEMINI_CFGPIN(315, GLOBAL_GMAC1_DATA_SKEW, 28, 31), /* GMAC1 TXD3 */
2287};
2288
2289static const struct gemini_pin_conf gemini_confs_3516[] = {
2290 GEMINI_CFGPIN(347, GLOBAL_GMAC_CTRL_SKEW, 0, 3), /* GMAC0 RXDV */
2291 GEMINI_CFGPIN(386, GLOBAL_GMAC_CTRL_SKEW, 4, 7), /* GMAC0 RXC */
2292 GEMINI_CFGPIN(307, GLOBAL_GMAC_CTRL_SKEW, 8, 11), /* GMAC0 TXEN */
2293 GEMINI_CFGPIN(327, GLOBAL_GMAC_CTRL_SKEW, 12, 15), /* GMAC0 TXC */
2294 GEMINI_CFGPIN(309, GLOBAL_GMAC_CTRL_SKEW, 16, 19), /* GMAC1 RXDV */
2295 GEMINI_CFGPIN(390, GLOBAL_GMAC_CTRL_SKEW, 20, 23), /* GMAC1 RXC */
2296 GEMINI_CFGPIN(370, GLOBAL_GMAC_CTRL_SKEW, 24, 27), /* GMAC1 TXEN */
2297 GEMINI_CFGPIN(350, GLOBAL_GMAC_CTRL_SKEW, 28, 31), /* GMAC1 TXC */
2298 GEMINI_CFGPIN(367, GLOBAL_GMAC0_DATA_SKEW, 0, 3), /* GMAC0 RXD0 */
2299 GEMINI_CFGPIN(348, GLOBAL_GMAC0_DATA_SKEW, 4, 7), /* GMAC0 RXD1 */
2300 GEMINI_CFGPIN(387, GLOBAL_GMAC0_DATA_SKEW, 8, 11), /* GMAC0 RXD2 */
2301 GEMINI_CFGPIN(328, GLOBAL_GMAC0_DATA_SKEW, 12, 15), /* GMAC0 RXD3 */
2302 GEMINI_CFGPIN(306, GLOBAL_GMAC0_DATA_SKEW, 16, 19), /* GMAC0 TXD0 */
2303 GEMINI_CFGPIN(325, GLOBAL_GMAC0_DATA_SKEW, 20, 23), /* GMAC0 TXD1 */
2304 GEMINI_CFGPIN(346, GLOBAL_GMAC0_DATA_SKEW, 24, 27), /* GMAC0 TXD2 */
2305 GEMINI_CFGPIN(326, GLOBAL_GMAC0_DATA_SKEW, 28, 31), /* GMAC0 TXD3 */
2306 GEMINI_CFGPIN(391, GLOBAL_GMAC1_DATA_SKEW, 0, 3), /* GMAC1 RXD0 */
2307 GEMINI_CFGPIN(351, GLOBAL_GMAC1_DATA_SKEW, 4, 7), /* GMAC1 RXD1 */
2308 GEMINI_CFGPIN(310, GLOBAL_GMAC1_DATA_SKEW, 8, 11), /* GMAC1 RXD2 */
2309 GEMINI_CFGPIN(371, GLOBAL_GMAC1_DATA_SKEW, 12, 15), /* GMAC1 RXD3 */
2310 GEMINI_CFGPIN(329, GLOBAL_GMAC1_DATA_SKEW, 16, 19), /* GMAC1 TXD0 */
2311 GEMINI_CFGPIN(389, GLOBAL_GMAC1_DATA_SKEW, 20, 23), /* GMAC1 TXD1 */
2312 GEMINI_CFGPIN(369, GLOBAL_GMAC1_DATA_SKEW, 24, 27), /* GMAC1 TXD2 */
2313 GEMINI_CFGPIN(308, GLOBAL_GMAC1_DATA_SKEW, 28, 31), /* GMAC1 TXD3 */
2314};
2315
2316static const struct gemini_pin_conf *gemini_get_pin_conf(struct gemini_pmx *pmx,
2317 unsigned int pin)
2318{
2319 const struct gemini_pin_conf *retconf;
2320 int i;
2321
2322 for (i = 0; i < pmx->nconfs; i++) {
2323 retconf = &gemini_confs_3516[i];
2324 if (retconf->pin == pin)
2325 return retconf;
2326 }
2327 return NULL;
2328}
2329
2330static int gemini_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
2331 unsigned long *config)
2332{
2333 struct gemini_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
2334 enum pin_config_param param = pinconf_to_config_param(*config);
2335 const struct gemini_pin_conf *conf;
2336 u32 val;
2337
2338 switch (param) {
2339 case PIN_CONFIG_SKEW_DELAY:
2340 conf = gemini_get_pin_conf(pmx, pin);
2341 if (!conf)
2342 return -ENOTSUPP;
2343 regmap_read(pmx->map, conf->reg, &val);
2344 val &= conf->mask;
2345 val >>= (ffs(conf->mask) - 1);
2346 *config = pinconf_to_config_packed(PIN_CONFIG_SKEW_DELAY, val);
2347 break;
2348 default:
2349 return -ENOTSUPP;
2350 }
2351
2352 return 0;
2353}
2354
2355static int gemini_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
2356 unsigned long *configs, unsigned int num_configs)
2357{
2358 struct gemini_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
2359 const struct gemini_pin_conf *conf;
2360 enum pin_config_param param;
2361 u32 arg;
2362 int ret = 0;
2363 int i;
2364
2365 for (i = 0; i < num_configs; i++) {
2366 param = pinconf_to_config_param(configs[i]);
2367 arg = pinconf_to_config_argument(configs[i]);
2368
2369 switch (param) {
2370 case PIN_CONFIG_SKEW_DELAY:
2371 if (arg > 0xf)
2372 return -EINVAL;
2373 conf = gemini_get_pin_conf(pmx, pin);
2374 if (!conf) {
2375 dev_err(pmx->dev,
2376 "invalid pin for skew delay %d\n", pin);
2377 return -ENOTSUPP;
2378 }
2379 arg <<= (ffs(conf->mask) - 1);
2380 dev_dbg(pmx->dev,
2381 "set pin %d to skew delay mask %08x, val %08x\n",
2382 pin, conf->mask, arg);
2383 regmap_update_bits(pmx->map, conf->reg, conf->mask, arg);
2384 break;
2385 default:
2386 dev_err(pmx->dev, "Invalid config param %04x\n", param);
2387 return -ENOTSUPP;
2388 }
2389 }
2390
2391 return ret;
2392}
2393
2394static const struct pinconf_ops gemini_pinconf_ops = {
2395 .pin_config_get = gemini_pinconf_get,
2396 .pin_config_set = gemini_pinconf_set,
2397 .is_generic = true,
2398};
2399
Linus Walleij06351d12017-08-05 23:04:08 +02002400static struct pinctrl_desc gemini_pmx_desc = {
2401 .name = DRIVER_NAME,
2402 .pctlops = &gemini_pctrl_ops,
2403 .pmxops = &gemini_pmx_ops,
Linus Walleij60ad4812017-10-28 15:37:19 +02002404 .confops = &gemini_pinconf_ops,
Linus Walleij06351d12017-08-05 23:04:08 +02002405 .owner = THIS_MODULE,
2406};
2407
2408static int gemini_pmx_probe(struct platform_device *pdev)
2409{
2410 struct gemini_pmx *pmx;
2411 struct regmap *map;
2412 struct device *dev = &pdev->dev;
2413 struct device *parent;
2414 unsigned long tmp;
2415 u32 val;
2416 int ret;
2417 int i;
2418
2419 /* Create state holders etc for this driver */
2420 pmx = devm_kzalloc(&pdev->dev, sizeof(*pmx), GFP_KERNEL);
2421 if (!pmx)
2422 return -ENOMEM;
2423
2424 pmx->dev = &pdev->dev;
2425 parent = dev->parent;
2426 if (!parent) {
2427 dev_err(dev, "no parent to pin controller\n");
2428 return -ENODEV;
2429 }
2430 map = syscon_node_to_regmap(parent->of_node);
2431 if (IS_ERR(map)) {
2432 dev_err(dev, "no syscon regmap\n");
2433 return PTR_ERR(map);
2434 }
2435 pmx->map = map;
2436
2437 /* Check that regmap works at first call, then no more */
2438 ret = regmap_read(map, GLOBAL_WORD_ID, &val);
2439 if (ret) {
2440 dev_err(dev, "cannot access regmap\n");
2441 return ret;
2442 }
2443 val >>= 8;
2444 val &= 0xffff;
2445 if (val == 0x3512) {
2446 pmx->is_3512 = true;
Linus Walleij60ad4812017-10-28 15:37:19 +02002447 pmx->confs = gemini_confs_3512;
2448 pmx->nconfs = ARRAY_SIZE(gemini_confs_3512);
Linus Walleij06351d12017-08-05 23:04:08 +02002449 gemini_pmx_desc.pins = gemini_3512_pins;
2450 gemini_pmx_desc.npins = ARRAY_SIZE(gemini_3512_pins);
2451 dev_info(dev, "detected 3512 chip variant\n");
2452 } else if (val == 0x3516) {
2453 pmx->is_3516 = true;
Linus Walleij60ad4812017-10-28 15:37:19 +02002454 pmx->confs = gemini_confs_3516;
2455 pmx->nconfs = ARRAY_SIZE(gemini_confs_3516);
Linus Walleij06351d12017-08-05 23:04:08 +02002456 gemini_pmx_desc.pins = gemini_3516_pins;
2457 gemini_pmx_desc.npins = ARRAY_SIZE(gemini_3516_pins);
2458 dev_info(dev, "detected 3516 chip variant\n");
2459 } else {
2460 dev_err(dev, "unknown chip ID: %04x\n", val);
2461 return -ENODEV;
2462 }
2463
2464 ret = regmap_read(map, GLOBAL_MISC_CTRL, &val);
2465 dev_info(dev, "GLOBAL MISC CTRL at boot: 0x%08x\n", val);
2466 /* Mask off relevant pads */
2467 val &= PADS_MASK;
2468 /* Invert the meaning of the DRAM+flash pads */
2469 val ^= 0x0f;
2470 /* Print initial state */
2471 tmp = val;
2472 for_each_set_bit(i, &tmp, PADS_MAXBIT) {
2473 dev_info(dev, "pad group %s %s\n", gemini_padgroups[i],
2474 (val & BIT(i)) ? "enabled" : "disabled");
2475 }
2476
2477 /* Check if flash pin is set */
2478 regmap_read(map, GLOBAL_STATUS, &val);
2479 pmx->flash_pin = !!(val & GLOBAL_STATUS_FLPIN);
2480 dev_info(dev, "flash pin is %s\n", pmx->flash_pin ? "set" : "not set");
2481
2482 pmx->pctl = devm_pinctrl_register(dev, &gemini_pmx_desc, pmx);
2483 if (IS_ERR(pmx->pctl)) {
2484 dev_err(dev, "could not register pinmux driver\n");
2485 return PTR_ERR(pmx->pctl);
2486 }
2487
2488 dev_info(dev, "initialized Gemini pin control driver\n");
2489
2490 return 0;
2491}
2492
2493static const struct of_device_id gemini_pinctrl_match[] = {
2494 { .compatible = "cortina,gemini-pinctrl" },
2495 {},
2496};
2497
2498static struct platform_driver gemini_pmx_driver = {
2499 .driver = {
2500 .name = DRIVER_NAME,
2501 .of_match_table = gemini_pinctrl_match,
2502 },
2503 .probe = gemini_pmx_probe,
2504};
2505
2506static int __init gemini_pmx_init(void)
2507{
2508 return platform_driver_register(&gemini_pmx_driver);
2509}
2510arch_initcall(gemini_pmx_init);