1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
2 | /* |
3 | * Common Multi-Function Pin Definitions |
4 | * |
5 | * Copyright (C) 2007 Marvell International Ltd. |
6 | * |
7 | * 2007-8-21: eric miao <eric.miao@marvell.com> |
8 | * initial version |
9 | */ |
10 | |
11 | #ifndef __ASM_PLAT_MFP_H |
12 | #define __ASM_PLAT_MFP_H |
13 | |
14 | #define mfp_to_gpio(m) ((m) % 256) |
15 | |
16 | /* list of all the configurable MFP pins */ |
17 | enum { |
18 | MFP_PIN_INVALID = -1, |
19 | |
20 | MFP_PIN_GPIO0 = 0, |
21 | MFP_PIN_GPIO1, |
22 | MFP_PIN_GPIO2, |
23 | MFP_PIN_GPIO3, |
24 | MFP_PIN_GPIO4, |
25 | MFP_PIN_GPIO5, |
26 | MFP_PIN_GPIO6, |
27 | MFP_PIN_GPIO7, |
28 | MFP_PIN_GPIO8, |
29 | MFP_PIN_GPIO9, |
30 | MFP_PIN_GPIO10, |
31 | MFP_PIN_GPIO11, |
32 | MFP_PIN_GPIO12, |
33 | MFP_PIN_GPIO13, |
34 | MFP_PIN_GPIO14, |
35 | MFP_PIN_GPIO15, |
36 | MFP_PIN_GPIO16, |
37 | MFP_PIN_GPIO17, |
38 | MFP_PIN_GPIO18, |
39 | MFP_PIN_GPIO19, |
40 | MFP_PIN_GPIO20, |
41 | MFP_PIN_GPIO21, |
42 | MFP_PIN_GPIO22, |
43 | MFP_PIN_GPIO23, |
44 | MFP_PIN_GPIO24, |
45 | MFP_PIN_GPIO25, |
46 | MFP_PIN_GPIO26, |
47 | MFP_PIN_GPIO27, |
48 | MFP_PIN_GPIO28, |
49 | MFP_PIN_GPIO29, |
50 | MFP_PIN_GPIO30, |
51 | MFP_PIN_GPIO31, |
52 | MFP_PIN_GPIO32, |
53 | MFP_PIN_GPIO33, |
54 | MFP_PIN_GPIO34, |
55 | MFP_PIN_GPIO35, |
56 | MFP_PIN_GPIO36, |
57 | MFP_PIN_GPIO37, |
58 | MFP_PIN_GPIO38, |
59 | MFP_PIN_GPIO39, |
60 | MFP_PIN_GPIO40, |
61 | MFP_PIN_GPIO41, |
62 | MFP_PIN_GPIO42, |
63 | MFP_PIN_GPIO43, |
64 | MFP_PIN_GPIO44, |
65 | MFP_PIN_GPIO45, |
66 | MFP_PIN_GPIO46, |
67 | MFP_PIN_GPIO47, |
68 | MFP_PIN_GPIO48, |
69 | MFP_PIN_GPIO49, |
70 | MFP_PIN_GPIO50, |
71 | MFP_PIN_GPIO51, |
72 | MFP_PIN_GPIO52, |
73 | MFP_PIN_GPIO53, |
74 | MFP_PIN_GPIO54, |
75 | MFP_PIN_GPIO55, |
76 | MFP_PIN_GPIO56, |
77 | MFP_PIN_GPIO57, |
78 | MFP_PIN_GPIO58, |
79 | MFP_PIN_GPIO59, |
80 | MFP_PIN_GPIO60, |
81 | MFP_PIN_GPIO61, |
82 | MFP_PIN_GPIO62, |
83 | MFP_PIN_GPIO63, |
84 | MFP_PIN_GPIO64, |
85 | MFP_PIN_GPIO65, |
86 | MFP_PIN_GPIO66, |
87 | MFP_PIN_GPIO67, |
88 | MFP_PIN_GPIO68, |
89 | MFP_PIN_GPIO69, |
90 | MFP_PIN_GPIO70, |
91 | MFP_PIN_GPIO71, |
92 | MFP_PIN_GPIO72, |
93 | MFP_PIN_GPIO73, |
94 | MFP_PIN_GPIO74, |
95 | MFP_PIN_GPIO75, |
96 | MFP_PIN_GPIO76, |
97 | MFP_PIN_GPIO77, |
98 | MFP_PIN_GPIO78, |
99 | MFP_PIN_GPIO79, |
100 | MFP_PIN_GPIO80, |
101 | MFP_PIN_GPIO81, |
102 | MFP_PIN_GPIO82, |
103 | MFP_PIN_GPIO83, |
104 | MFP_PIN_GPIO84, |
105 | MFP_PIN_GPIO85, |
106 | MFP_PIN_GPIO86, |
107 | MFP_PIN_GPIO87, |
108 | MFP_PIN_GPIO88, |
109 | MFP_PIN_GPIO89, |
110 | MFP_PIN_GPIO90, |
111 | MFP_PIN_GPIO91, |
112 | MFP_PIN_GPIO92, |
113 | MFP_PIN_GPIO93, |
114 | MFP_PIN_GPIO94, |
115 | MFP_PIN_GPIO95, |
116 | MFP_PIN_GPIO96, |
117 | MFP_PIN_GPIO97, |
118 | MFP_PIN_GPIO98, |
119 | MFP_PIN_GPIO99, |
120 | MFP_PIN_GPIO100, |
121 | MFP_PIN_GPIO101, |
122 | MFP_PIN_GPIO102, |
123 | MFP_PIN_GPIO103, |
124 | MFP_PIN_GPIO104, |
125 | MFP_PIN_GPIO105, |
126 | MFP_PIN_GPIO106, |
127 | MFP_PIN_GPIO107, |
128 | MFP_PIN_GPIO108, |
129 | MFP_PIN_GPIO109, |
130 | MFP_PIN_GPIO110, |
131 | MFP_PIN_GPIO111, |
132 | MFP_PIN_GPIO112, |
133 | MFP_PIN_GPIO113, |
134 | MFP_PIN_GPIO114, |
135 | MFP_PIN_GPIO115, |
136 | MFP_PIN_GPIO116, |
137 | MFP_PIN_GPIO117, |
138 | MFP_PIN_GPIO118, |
139 | MFP_PIN_GPIO119, |
140 | MFP_PIN_GPIO120, |
141 | MFP_PIN_GPIO121, |
142 | MFP_PIN_GPIO122, |
143 | MFP_PIN_GPIO123, |
144 | MFP_PIN_GPIO124, |
145 | MFP_PIN_GPIO125, |
146 | MFP_PIN_GPIO126, |
147 | MFP_PIN_GPIO127, |
148 | |
149 | MFP_PIN_GPIO128, |
150 | MFP_PIN_GPIO129, |
151 | MFP_PIN_GPIO130, |
152 | MFP_PIN_GPIO131, |
153 | MFP_PIN_GPIO132, |
154 | MFP_PIN_GPIO133, |
155 | MFP_PIN_GPIO134, |
156 | MFP_PIN_GPIO135, |
157 | MFP_PIN_GPIO136, |
158 | MFP_PIN_GPIO137, |
159 | MFP_PIN_GPIO138, |
160 | MFP_PIN_GPIO139, |
161 | MFP_PIN_GPIO140, |
162 | MFP_PIN_GPIO141, |
163 | MFP_PIN_GPIO142, |
164 | MFP_PIN_GPIO143, |
165 | MFP_PIN_GPIO144, |
166 | MFP_PIN_GPIO145, |
167 | MFP_PIN_GPIO146, |
168 | MFP_PIN_GPIO147, |
169 | MFP_PIN_GPIO148, |
170 | MFP_PIN_GPIO149, |
171 | MFP_PIN_GPIO150, |
172 | MFP_PIN_GPIO151, |
173 | MFP_PIN_GPIO152, |
174 | MFP_PIN_GPIO153, |
175 | MFP_PIN_GPIO154, |
176 | MFP_PIN_GPIO155, |
177 | MFP_PIN_GPIO156, |
178 | MFP_PIN_GPIO157, |
179 | MFP_PIN_GPIO158, |
180 | MFP_PIN_GPIO159, |
181 | MFP_PIN_GPIO160, |
182 | MFP_PIN_GPIO161, |
183 | MFP_PIN_GPIO162, |
184 | MFP_PIN_GPIO163, |
185 | MFP_PIN_GPIO164, |
186 | MFP_PIN_GPIO165, |
187 | MFP_PIN_GPIO166, |
188 | MFP_PIN_GPIO167, |
189 | MFP_PIN_GPIO168, |
190 | MFP_PIN_GPIO169, |
191 | MFP_PIN_GPIO170, |
192 | MFP_PIN_GPIO171, |
193 | MFP_PIN_GPIO172, |
194 | MFP_PIN_GPIO173, |
195 | MFP_PIN_GPIO174, |
196 | MFP_PIN_GPIO175, |
197 | MFP_PIN_GPIO176, |
198 | MFP_PIN_GPIO177, |
199 | MFP_PIN_GPIO178, |
200 | MFP_PIN_GPIO179, |
201 | MFP_PIN_GPIO180, |
202 | MFP_PIN_GPIO181, |
203 | MFP_PIN_GPIO182, |
204 | MFP_PIN_GPIO183, |
205 | MFP_PIN_GPIO184, |
206 | MFP_PIN_GPIO185, |
207 | MFP_PIN_GPIO186, |
208 | MFP_PIN_GPIO187, |
209 | MFP_PIN_GPIO188, |
210 | MFP_PIN_GPIO189, |
211 | MFP_PIN_GPIO190, |
212 | MFP_PIN_GPIO191, |
213 | |
214 | MFP_PIN_GPIO255 = 255, |
215 | |
216 | MFP_PIN_GPIO0_2, |
217 | MFP_PIN_GPIO1_2, |
218 | MFP_PIN_GPIO2_2, |
219 | MFP_PIN_GPIO3_2, |
220 | MFP_PIN_GPIO4_2, |
221 | MFP_PIN_GPIO5_2, |
222 | MFP_PIN_GPIO6_2, |
223 | MFP_PIN_GPIO7_2, |
224 | MFP_PIN_GPIO8_2, |
225 | MFP_PIN_GPIO9_2, |
226 | MFP_PIN_GPIO10_2, |
227 | MFP_PIN_GPIO11_2, |
228 | MFP_PIN_GPIO12_2, |
229 | MFP_PIN_GPIO13_2, |
230 | MFP_PIN_GPIO14_2, |
231 | MFP_PIN_GPIO15_2, |
232 | MFP_PIN_GPIO16_2, |
233 | MFP_PIN_GPIO17_2, |
234 | |
235 | MFP_PIN_ULPI_STP, |
236 | MFP_PIN_ULPI_NXT, |
237 | MFP_PIN_ULPI_DIR, |
238 | |
239 | MFP_PIN_nXCVREN, |
240 | MFP_PIN_DF_CLE_nOE, |
241 | MFP_PIN_DF_nADV1_ALE, |
242 | MFP_PIN_DF_SCLK_E, |
243 | MFP_PIN_DF_SCLK_S, |
244 | MFP_PIN_nBE0, |
245 | MFP_PIN_nBE1, |
246 | MFP_PIN_DF_nADV2_ALE, |
247 | MFP_PIN_DF_INT_RnB, |
248 | MFP_PIN_DF_nCS0, |
249 | MFP_PIN_DF_nCS1, |
250 | MFP_PIN_nLUA, |
251 | MFP_PIN_nLLA, |
252 | MFP_PIN_DF_nWE, |
253 | MFP_PIN_DF_ALE_nWE, |
254 | MFP_PIN_DF_nRE_nOE, |
255 | MFP_PIN_DF_ADDR0, |
256 | MFP_PIN_DF_ADDR1, |
257 | MFP_PIN_DF_ADDR2, |
258 | MFP_PIN_DF_ADDR3, |
259 | MFP_PIN_DF_IO0, |
260 | MFP_PIN_DF_IO1, |
261 | MFP_PIN_DF_IO2, |
262 | MFP_PIN_DF_IO3, |
263 | MFP_PIN_DF_IO4, |
264 | MFP_PIN_DF_IO5, |
265 | MFP_PIN_DF_IO6, |
266 | MFP_PIN_DF_IO7, |
267 | MFP_PIN_DF_IO8, |
268 | MFP_PIN_DF_IO9, |
269 | MFP_PIN_DF_IO10, |
270 | MFP_PIN_DF_IO11, |
271 | MFP_PIN_DF_IO12, |
272 | MFP_PIN_DF_IO13, |
273 | MFP_PIN_DF_IO14, |
274 | MFP_PIN_DF_IO15, |
275 | MFP_PIN_DF_nCS0_SM_nCS2, |
276 | MFP_PIN_DF_nCS1_SM_nCS3, |
277 | MFP_PIN_SM_nCS0, |
278 | MFP_PIN_SM_nCS1, |
279 | MFP_PIN_DF_WEn, |
280 | MFP_PIN_DF_REn, |
281 | MFP_PIN_DF_CLE_SM_OEn, |
282 | MFP_PIN_DF_ALE_SM_WEn, |
283 | MFP_PIN_DF_RDY0, |
284 | MFP_PIN_DF_RDY1, |
285 | |
286 | MFP_PIN_SM_SCLK, |
287 | MFP_PIN_SM_BE0, |
288 | MFP_PIN_SM_BE1, |
289 | MFP_PIN_SM_ADV, |
290 | MFP_PIN_SM_ADVMUX, |
291 | MFP_PIN_SM_RDY, |
292 | |
293 | MFP_PIN_MMC1_DAT7, |
294 | MFP_PIN_MMC1_DAT6, |
295 | MFP_PIN_MMC1_DAT5, |
296 | MFP_PIN_MMC1_DAT4, |
297 | MFP_PIN_MMC1_DAT3, |
298 | MFP_PIN_MMC1_DAT2, |
299 | MFP_PIN_MMC1_DAT1, |
300 | MFP_PIN_MMC1_DAT0, |
301 | MFP_PIN_MMC1_CMD, |
302 | MFP_PIN_MMC1_CLK, |
303 | MFP_PIN_MMC1_CD, |
304 | MFP_PIN_MMC1_WP, |
305 | |
306 | /* additional pins on PXA930 */ |
307 | MFP_PIN_GSIM_UIO, |
308 | MFP_PIN_GSIM_UCLK, |
309 | MFP_PIN_GSIM_UDET, |
310 | MFP_PIN_GSIM_nURST, |
311 | MFP_PIN_PMIC_INT, |
312 | MFP_PIN_RDY, |
313 | |
314 | /* additional pins on MMP2 */ |
315 | MFP_PIN_TWSI1_SCL, |
316 | MFP_PIN_TWSI1_SDA, |
317 | MFP_PIN_TWSI4_SCL, |
318 | MFP_PIN_TWSI4_SDA, |
319 | MFP_PIN_CLK_REQ, |
320 | |
321 | MFP_PIN_MAX, |
322 | }; |
323 | |
324 | /* |
325 | * a possible MFP configuration is represented by a 32-bit integer |
326 | * |
327 | * bit 0.. 9 - MFP Pin Number (1024 Pins Maximum) |
328 | * bit 10..12 - Alternate Function Selection |
329 | * bit 13..15 - Drive Strength |
330 | * bit 16..18 - Low Power Mode State |
331 | * bit 19..20 - Low Power Mode Edge Detection |
332 | * bit 21..22 - Run Mode Pull State |
333 | * |
334 | * to facilitate the definition, the following macros are provided |
335 | * |
336 | * MFP_CFG_DEFAULT - default MFP configuration value, with |
337 | * alternate function = 0, |
338 | * drive strength = fast 3mA (MFP_DS03X) |
339 | * low power mode = default |
340 | * edge detection = none |
341 | * |
342 | * MFP_CFG - default MFPR value with alternate function |
343 | * MFP_CFG_DRV - default MFPR value with alternate function and |
344 | * pin drive strength |
345 | * MFP_CFG_LPM - default MFPR value with alternate function and |
346 | * low power mode |
347 | * MFP_CFG_X - default MFPR value with alternate function, |
348 | * pin drive strength and low power mode |
349 | */ |
350 | |
351 | typedef unsigned long mfp_cfg_t; |
352 | |
353 | #define MFP_PIN(x) ((x) & 0x3ff) |
354 | |
355 | #define MFP_AF0 (0x0 << 10) |
356 | #define MFP_AF1 (0x1 << 10) |
357 | #define MFP_AF2 (0x2 << 10) |
358 | #define MFP_AF3 (0x3 << 10) |
359 | #define MFP_AF4 (0x4 << 10) |
360 | #define MFP_AF5 (0x5 << 10) |
361 | #define MFP_AF6 (0x6 << 10) |
362 | #define MFP_AF7 (0x7 << 10) |
363 | #define MFP_AF_MASK (0x7 << 10) |
364 | #define MFP_AF(x) (((x) >> 10) & 0x7) |
365 | |
366 | #define MFP_DS01X (0x0 << 13) |
367 | #define MFP_DS02X (0x1 << 13) |
368 | #define MFP_DS03X (0x2 << 13) |
369 | #define MFP_DS04X (0x3 << 13) |
370 | #define MFP_DS06X (0x4 << 13) |
371 | #define MFP_DS08X (0x5 << 13) |
372 | #define MFP_DS10X (0x6 << 13) |
373 | #define MFP_DS13X (0x7 << 13) |
374 | #define MFP_DS_MASK (0x7 << 13) |
375 | #define MFP_DS(x) (((x) >> 13) & 0x7) |
376 | |
377 | #define MFP_LPM_DEFAULT (0x0 << 16) |
378 | #define MFP_LPM_DRIVE_LOW (0x1 << 16) |
379 | #define MFP_LPM_DRIVE_HIGH (0x2 << 16) |
380 | #define MFP_LPM_PULL_LOW (0x3 << 16) |
381 | #define MFP_LPM_PULL_HIGH (0x4 << 16) |
382 | #define MFP_LPM_FLOAT (0x5 << 16) |
383 | #define MFP_LPM_INPUT (0x6 << 16) |
384 | #define MFP_LPM_STATE_MASK (0x7 << 16) |
385 | #define MFP_LPM_STATE(x) (((x) >> 16) & 0x7) |
386 | |
387 | #define MFP_LPM_EDGE_NONE (0x0 << 19) |
388 | #define MFP_LPM_EDGE_RISE (0x1 << 19) |
389 | #define MFP_LPM_EDGE_FALL (0x2 << 19) |
390 | #define MFP_LPM_EDGE_BOTH (0x3 << 19) |
391 | #define MFP_LPM_EDGE_MASK (0x3 << 19) |
392 | #define MFP_LPM_EDGE(x) (((x) >> 19) & 0x3) |
393 | |
394 | #define MFP_PULL_NONE (0x0 << 21) |
395 | #define MFP_PULL_LOW (0x1 << 21) |
396 | #define MFP_PULL_HIGH (0x2 << 21) |
397 | #define MFP_PULL_BOTH (0x3 << 21) |
398 | #define MFP_PULL_FLOAT (0x4 << 21) |
399 | #define MFP_PULL_MASK (0x7 << 21) |
400 | #define MFP_PULL(x) (((x) >> 21) & 0x7) |
401 | |
402 | #define MFP_CFG_DEFAULT (MFP_AF0 | MFP_DS03X | MFP_LPM_DEFAULT |\ |
403 | MFP_LPM_EDGE_NONE | MFP_PULL_NONE) |
404 | |
405 | #define MFP_CFG(pin, af) \ |
406 | ((MFP_CFG_DEFAULT & ~MFP_AF_MASK) |\ |
407 | (MFP_PIN(MFP_PIN_##pin) | MFP_##af)) |
408 | |
409 | #define MFP_CFG_DRV(pin, af, drv) \ |
410 | ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DS_MASK)) |\ |
411 | (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_##drv)) |
412 | |
413 | #define MFP_CFG_LPM(pin, af, lpm) \ |
414 | ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_LPM_STATE_MASK)) |\ |
415 | (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_LPM_##lpm)) |
416 | |
417 | #define MFP_CFG_X(pin, af, drv, lpm) \ |
418 | ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DS_MASK | MFP_LPM_STATE_MASK)) |\ |
419 | (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_##drv | MFP_LPM_##lpm)) |
420 | |
421 | #if defined(CONFIG_PXA3xx) || defined(CONFIG_ARCH_MMP) |
422 | /* |
423 | * each MFP pin will have a MFPR register, since the offset of the |
424 | * register varies between processors, the processor specific code |
425 | * should initialize the pin offsets by mfp_init() |
426 | * |
427 | * mfp_init_base() - accepts a virtual base for all MFPR registers and |
428 | * initialize the MFP table to a default state |
429 | * |
430 | * mfp_init_addr() - accepts a table of "mfp_addr_map" structure, which |
431 | * represents a range of MFP pins from "start" to "end", with the offset |
432 | * beginning at "offset", to define a single pin, let "end" = -1. |
433 | * |
434 | * use |
435 | * |
436 | * MFP_ADDR_X() to define a range of pins |
437 | * MFP_ADDR() to define a single pin |
438 | * MFP_ADDR_END to signal the end of pin offset definitions |
439 | */ |
440 | struct mfp_addr_map { |
441 | unsigned int start; |
442 | unsigned int end; |
443 | unsigned long offset; |
444 | }; |
445 | |
446 | #define MFP_ADDR_X(start, end, offset) \ |
447 | { MFP_PIN_##start, MFP_PIN_##end, offset } |
448 | |
449 | #define MFP_ADDR(pin, offset) \ |
450 | { MFP_PIN_##pin, -1, offset } |
451 | |
452 | #define MFP_ADDR_END { MFP_PIN_INVALID, 0 } |
453 | |
454 | void mfp_init_base(void __iomem *mfpr_base); |
455 | void mfp_init_addr(struct mfp_addr_map *map); |
456 | |
457 | /* |
458 | * mfp_{read, write}() - for direct read/write access to the MFPR register |
459 | * mfp_config() - for configuring a group of MFPR registers |
460 | * mfp_config_lpm() - configuring all low power MFPR registers for suspend |
461 | * mfp_config_run() - configuring all run time MFPR registers after resume |
462 | */ |
463 | unsigned long mfp_read(int mfp); |
464 | void mfp_write(int mfp, unsigned long mfpr_val); |
465 | void mfp_config(unsigned long *mfp_cfgs, int num); |
466 | void mfp_config_run(void); |
467 | void mfp_config_lpm(void); |
468 | #endif /* CONFIG_PXA3xx || CONFIG_ARCH_MMP */ |
469 | |
470 | #endif /* __ASM_PLAT_MFP_H */ |
471 | |