change source file mode to 0644 instead of 0755
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc8825 / mfp.h
1 /*
2  * arch/arm/mach-sprd/include/mach/pm.h
3  *
4  * Pin Map Definitions
5  *
6  * Copyright (C) 2010 Spreadtrum International Ltd.
7  *
8  * 2010-03-05: yingchun li <yingchun.li@spreadtrum.com>
9  *            initial version
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License version 2 as
13  *  published by the Free Software Foundation.
14  */
15
16 #ifndef __ASM_ARCH_MFP_H
17 #define __ASM_ARCH_MFP_H
18
19 #include <asm/arch/bits.h>
20 /*
21         This is identical to the order of pin's register map.
22         NOTE: if the pin register is not countinus, you should
23         intest a RESEVERED pin between them;
24 */
25 #define PIN_SIMCLK0_REG_OFFS                          (0x008C)
26 #define PIN_SIMDA0_REG_OFFS                          (0x0090)
27 #define PIN_SIMRST0_REG_OFFS                          (0x0094)
28 #define PIN_SIMCLK1_REG_OFFS                          (0x0098)
29 #define PIN_SIMDA1_REG_OFFS                          (0x009C)
30 #define PIN_SIMRST1_REG_OFFS                          (0x00A0)
31 #define PIN_SD0_CLK_REG_OFFS                          (0x0030)
32 #define PIN_SD0_CMD_REG_OFFS                          (0x0034)
33 #define PIN_SD0_D0_REG_OFFS                          (0x0038)
34 #define PIN_SD0_D1_REG_OFFS                          (0x003c)
35 #define PIN_SD0_D2_REG_OFFS                          (0x0040)
36 #define PIN_SD0_D3_REG_OFFS                          (0x0044)
37 #define PIN_SD1_CLK_REG_OFFS                          (0x01fc)
38 #define PIN_SD1_CMD_REG_OFFS                          (0x0200)
39 #define PIN_SD1_D0_REG_OFFS                          (0x0204)
40 #define PIN_SD1_D1_REG_OFFS                          (0x0208)
41 #define PIN_SD1_D2_REG_OFFS                          (0x020c)
42 #define PIN_SD1_D3_REG_OFFS                          (0x0210)
43 #define PIN_KEYOUT0_REG_OFFS                          (0x011C)
44 #define PIN_KEYOUT1_REG_OFFS                          (0x0120)
45 #define PIN_KEYOUT2_REG_OFFS                          (0x0124)
46 #define PIN_KEYOUT3_REG_OFFS                          (0x0128)
47 #define PIN_KEYOUT4_REG_OFFS                          (0x012C)
48 #define PIN_KEYOUT5_REG_OFFS                          (0x0130)
49 #define PIN_KEYOUT6_REG_OFFS                          (0x014C)
50 #define PIN_KEYOUT7_REG_OFFS                          (0x0150)
51 #define PIN_KEYIN0_REG_OFFS                          (0x0154)
52 #define PIN_KEYIN1_REG_OFFS                          (0x0158)
53 #define PIN_KEYIN2_REG_OFFS                          (0x015C)
54 #define PIN_KEYIN3_REG_OFFS                          (0x0160)
55 #define PIN_KEYIN4_REG_OFFS                          (0x0164)
56 #define PIN_KEYIN5_REG_OFFS                          (0x0168)
57 #define PIN_KEYIN6_REG_OFFS                          (0x016C)
58 #define PIN_KEYIN7_REG_OFFS                          (0x0170)
59 #define PIN_SPI_DI_REG_OFFS                          (0x0100)
60 #define PIN_SPI_CLK_REG_OFFS                          (0x0104)
61 #define PIN_SPI_DO_REG_OFFS                          (0x0108)
62 #define PIN_SPI_CSN0_REG_OFFS                          (0x010C)
63 #define PIN_SPI_CSN1_REG_OFFS                          (0x0110)
64 #define PIN_MTDO_REG_OFFS                          (0x0114)
65 #define PIN_MTDI_REG_OFFS                          (0x0118)
66 #define PIN_MTCK_REG_OFFS                          (0x011C)
67 #define PIN_MTMS_REG_OFFS                          (0x0120)
68 #define PIN_MTRST_N_REG_OFFS                          (0x0124)
69 #define PIN_U0TXD_REG_OFFS                          (0x0128)
70 #define PIN_U0RXD_REG_OFFS                          (0x012C)
71 #define PIN_U0CTS_REG_OFFS                          (0x0130)
72 #define PIN_U0RTS_REG_OFFS                          (0x0134)
73 #define PIN_U1TXD_REG_OFFS                          (0x0138)
74 #define PIN_U1RXD_REG_OFFS                          (0x013C)
75 #define PIN_NFWPN_REG_OFFS                          (0x0140)
76 #define PIN_NFRB_REG_OFFS                          (0x0144)
77 #define PIN_NFCLE_REG_OFFS                          (0x0148)
78 #define PIN_NFALE_REG_OFFS                          (0x014C)
79 #define PIN_NFCEN_REG_OFFS                          (0x0150)
80 #define PIN_NFWEN_REG_OFFS                          (0x0154)
81 #define PIN_NFREN_REG_OFFS                          (0x0158)
82 #define PIN_NFD0_REG_OFFS                          (0x015C)
83 #define PIN_NFD1_REG_OFFS                          (0x0160)
84 #define PIN_NFD2_REG_OFFS                          (0x0164)
85 #define PIN_NFD3_REG_OFFS                          (0x0168)
86 #define PIN_NFD4_REG_OFFS                          (0x016C)
87 #define PIN_NFD5_REG_OFFS                          (0x0170)
88 #define PIN_NFD6_REG_OFFS                          (0x0174)
89 #define PIN_NFD7_REG_OFFS                          (0x0178)
90 #define PIN_NFD8_REG_OFFS                          (0x017C)
91 #define PIN_NFD9_REG_OFFS                          (0x0180)
92 #define PIN_NFD10_REG_OFFS                          (0x0184)
93 #define PIN_NFD11_REG_OFFS                          (0x0188)
94 #define PIN_NFD12_REG_OFFS                          (0x018C)
95 #define PIN_NFD13_REG_OFFS                          (0x0190)
96 #define PIN_NFD14_REG_OFFS                          (0x0194)
97 #define PIN_NFD15_REG_OFFS                          (0x0198)
98 #define PIN_EMRST_N_REG_OFFS                          (0x019C)
99 #define PIN_EMA0_REG_OFFS                          (0x01A0)
100 #define PIN_EMA1_REG_OFFS                          (0x01A4)
101 #define PIN_EMA2_REG_OFFS                          (0x01A8)
102 #define PIN_EMA3_REG_OFFS                          (0x01AC)
103 #define PIN_EMA4_REG_OFFS                          (0x01B0)
104 #define PIN_EMA5_REG_OFFS                          (0x01B4)
105 #define PIN_EMA6_REG_OFFS                          (0x01B8)
106 #define PIN_EMA7_REG_OFFS                          (0x01BC)
107 #define PIN_EMA8_REG_OFFS                          (0x01C0)
108 #define PIN_EMA9_REG_OFFS                          (0x01C4)
109 #define PIN_EMA10_REG_OFFS                          (0x01C8)
110 #define PIN_EMA11_REG_OFFS                          (0x01CC)
111 #define PIN_EMA12_REG_OFFS                          (0x01D0)
112 #define PIN_EMA13_REG_OFFS                          (0x01D4)
113 #define PIN_EMCKE1_REG_OFFS                          (0x01D8)
114 #define PIN_EMD0_REG_OFFS                          (0x01DC)
115 #define PIN_EMD1_REG_OFFS                          (0x01E0)
116 #define PIN_EMD2_REG_OFFS                          (0x01E4)
117 #define PIN_EMD3_REG_OFFS                          (0x01E8)
118 #define PIN_EMD4_REG_OFFS                          (0x01EC)
119 #define PIN_EMD5_REG_OFFS                          (0x01F0)
120 #define PIN_EMD6_REG_OFFS                          (0x01F4)
121 #define PIN_EMD7_REG_OFFS                          (0x01F8)
122 #define PIN_EMDQM0_REG_OFFS                          (0x01FC)
123 #define PIN_EMDQS0_REG_OFFS                          (0x0200)
124 #define PIN_EMD8_REG_OFFS                          (0x0204)
125 #define PIN_EMD9_REG_OFFS                          (0x0208)
126 #define PIN_EMD10_REG_OFFS                          (0x020C)
127 #define PIN_EMD11_REG_OFFS                          (0x0210)
128 #define PIN_EMD12_REG_OFFS                          (0x0214)
129 #define PIN_EMD13_REG_OFFS                          (0x0218)
130 #define PIN_EMD14_REG_OFFS                          (0x021C)
131 #define PIN_EMD15_REG_OFFS                          (0x0220)
132 #define PIN_EMDQM1_REG_OFFS                          (0x0224)
133 #define PIN_EMDQS1_REG_OFFS                          (0x0228)
134 #define PIN_EMD16_REG_OFFS                          (0x022C)
135 #define PIN_EMD17_REG_OFFS                          (0x0230)
136 #define PIN_EMD18_REG_OFFS                          (0x0234)
137 #define PIN_EMD19_REG_OFFS                          (0x0238)
138 #define PIN_EMD20_REG_OFFS                          (0x023C)
139 #define PIN_EMD21_REG_OFFS                          (0x0240)
140 #define PIN_EMD22_REG_OFFS                          (0x0244)
141 #define PIN_EMD23_REG_OFFS                          (0x0248)
142 #define PIN_EMDQM2_REG_OFFS                          (0x024C)
143 #define PIN_EMDQS2_REG_OFFS                          (0x0250)
144 #define PIN_EMD24_REG_OFFS                          (0x0254)
145 #define PIN_EMD25_REG_OFFS                          (0x0258)
146 #define PIN_EMD26_REG_OFFS                          (0x025C)
147 #define PIN_EMD27_REG_OFFS                          (0x0260)
148 #define PIN_EMD28_REG_OFFS                          (0x0264)
149 #define PIN_EMD29_REG_OFFS                          (0x0268)
150 #define PIN_EMD30_REG_OFFS                          (0x026C)
151 #define PIN_EMD31_REG_OFFS                          (0x0270)
152 #define PIN_EMDQM3_REG_OFFS                          (0x0274)
153 #define PIN_EMDQS3_REG_OFFS                          (0x0278)
154 #define PIN_CLKDPMEM_REG_OFFS                          (0x027C)
155 #define PIN_CLKDMMEM_REG_OFFS                          (0x0280)
156 #define PIN_EMRAS_N_REG_OFFS                          (0x0284)
157 #define PIN_EMCAS_N_REG_OFFS                          (0x0288)
158 #define PIN_EMWE_N_REG_OFFS                          (0x028C)
159 #define PIN_EMCS_N0_REG_OFFS                          (0x0290)
160 #define PIN_EMCS_N1_REG_OFFS                          (0x0294)
161 #define PIN_EMCS_N2_REG_OFFS                          (0x0298)
162 #define PIN_EMCS_N3_REG_OFFS                          (0x029C)
163 #define PIN_EMBA0_REG_OFFS                          (0x02A0)
164 #define PIN_EMBA1_REG_OFFS                          (0x02A4)
165 #define PIN_EMCKE0_REG_OFFS                          (0x02A8)
166 #define PIN_LCD_CSN1_REG_OFFS                          (0x02AC)
167 #define PIN_LCD_RSTN_REG_OFFS                          (0x02B0)
168 #define PIN_LCD_CD_REG_OFFS                          (0x02B4)
169 #define PIN_LCD_D0_REG_OFFS                          (0x02B8)
170 #define PIN_LCD_D1_REG_OFFS                          (0x02BC)
171 #define PIN_LCD_D2_REG_OFFS                          (0x02C0)
172 #define PIN_LCD_D3_REG_OFFS                          (0x02C4)
173 #define PIN_LCD_D4_REG_OFFS                          (0x02C8)
174 #define PIN_LCD_D5_REG_OFFS                          (0x02CC)
175 #define PIN_LCD_D6_REG_OFFS                          (0x02D0)
176 #define PIN_LCD_D7_REG_OFFS                          (0x02D4)
177 #define PIN_LCD_D8_REG_OFFS                          (0x02D8)
178 #define PIN_LCD_WRN_REG_OFFS                          (0x02DC)
179 #define PIN_LCD_RDN_REG_OFFS                          (0x02E0)
180 #define PIN_LCD_CSN0_REG_OFFS                          (0x02E4)
181 #define PIN_LCD_D9_REG_OFFS                          (0x02E8)
182 #define PIN_LCD_D10_REG_OFFS                          (0x02EC)
183 #define PIN_LCD_D11_REG_OFFS                          (0x02F0)
184 #define PIN_LCD_D12_REG_OFFS                          (0x02F4)
185 #define PIN_LCD_D13_REG_OFFS                          (0x02F8)
186 #define PIN_LCD_D14_REG_OFFS                          (0x02FC)
187 #define PIN_LCD_D15_REG_OFFS                          (0x0300)
188 #define PIN_LCD_D16_REG_OFFS                          (0x0304)
189 #define PIN_LCD_D17_REG_OFFS                          (0x0308)
190 #define PIN_LCD_FMARK_REG_OFFS                          (0x030C)
191 #define PIN_CCIRMCLK_REG_OFFS                          (0x0310)
192 #define PIN_CCIRCK_REG_OFFS                          (0x0314)
193 #define PIN_CCIRHS_REG_OFFS                          (0x0318)
194 #define PIN_CCIRVS_REG_OFFS                          (0x031C)
195 #define PIN_CCIRD0_REG_OFFS                          (0x0320)
196 #define PIN_CCIRD1_REG_OFFS                          (0x0324)
197 #define PIN_CCIRD2_REG_OFFS                          (0x0328)
198 #define PIN_CCIRD3_REG_OFFS                          (0x032C)
199 #define PIN_CCIRD4_REG_OFFS                          (0x0330)
200 #define PIN_CCIRD5_REG_OFFS                          (0x0334)
201 #define PIN_CCIRD6_REG_OFFS                          (0x0338)
202 #define PIN_CCIRD7_REG_OFFS                          (0x033C)
203 #define PIN_CCIRRST_REG_OFFS                          (0x0340)
204 #define PIN_CCIRPD1_REG_OFFS                          (0x0344)
205 #define PIN_CCIRPD0_REG_OFFS                          (0x0348)
206 #define PIN_SCL_REG_OFFS                          (0x034C)
207 #define PIN_SDA_REG_OFFS                          (0x0350)
208 #define PIN_CLK_AUX0_REG_OFFS                          (0x0354)
209 #define PIN_IISDI_REG_OFFS                          (0x0358)
210 #define PIN_IISDO_REG_OFFS                          (0x035C)
211 #define PIN_IISCLK_REG_OFFS                          (0x0360)
212 #define PIN_IISLRCK_REG_OFFS                          (0x0364)
213 #define PIN_IISMCK_REG_OFFS                          (0x0368)
214 #define PIN_RFSDA0_REG_OFFS                          (0x036C)
215 #define PIN_RFSCK0_REG_OFFS                          (0x0370)
216 #define PIN_RFSEN0_REG_OFFS                          (0x0374)
217 #define PIN_RFCTL0_REG_OFFS                          (0x0378)
218 #define PIN_RFCTL1_REG_OFFS                          (0x037C)
219 #define PIN_RFCTL2_REG_OFFS                          (0x0380)
220 #define PIN_RFCTL3_REG_OFFS                          (0x0384)
221 #define PIN_RFCTL4_REG_OFFS                          (0x0388)
222 #define PIN_RFCTL5_REG_OFFS                          (0x038C)
223 #define PIN_RFCTL6_REG_OFFS                          (0x0390)
224 #define PIN_RFCTL7_REG_OFFS                          (0x0394)
225 #define PIN_RFCTL8_REG_OFFS                          (0x0398)
226 #define PIN_RFCTL9_REG_OFFS                          (0x039C)
227 #define PIN_RFCTL10_REG_OFFS                          (0x03A0)
228 #define PIN_RFCTL11_REG_OFFS                          (0x03A4)
229 #define PIN_RFCTL12_REG_OFFS                          (0x03A8)
230 #define PIN_RFCTL13_REG_OFFS                          (0x03AC)
231 #define PIN_RFCTL14_REG_OFFS                          (0x03B0)
232 #define PIN_RFCTL15_REG_OFFS                          (0x03B4)
233 #define PIN_XTL_EN_REG_OFFS                          (0x03B8)
234 #define PIN_PTEST_REG_OFFS                          (0x03BC)
235 #define PIN_GPIO135_REG_OFFS                          (0x03C0)
236 #define PIN_GPIO136_REG_OFFS                          (0x03C4)
237 #define PIN_GPIO137_REG_OFFS                          (0x03C8)
238 #define PIN_GPIO138_REG_OFFS                          (0x03CC)
239 #define PIN_GPIO139_REG_OFFS                          (0x03D0)
240 #define PIN_GPIO140_REG_OFFS                          (0x03D4)
241 #define PIN_OPTION2_REG_OFFS                          (0x03D8)
242 #define PIN_OPTION3_REG_OFFS                          (0x03DC)
243 #define PIN_GPIO141_REG_OFFS                          (0x03E0)
244 #define PIN_GPIO142_REG_OFFS                          (0x03E4)
245 #define PIN_GPIO143_REG_OFFS                          (0x03E8)
246 #define PIN_GPIO144_REG_OFFS                          (0x03EC)
247
248 /*----------Analog Die Pin Control Register----------*/
249
250
251 #define ANA_PIN_CHIP_RSTN_REG_OFFS           (0x008C)
252 #define ANA_PIN_PBINT_REG_OFFS               (0x0094)
253 #define ANA_PIN_TP_XL_REG_OFFS               (0x0098)
254 #define ANA_PIN_TP_XR_REG_OFFS               (0x009C)
255 #define ANA_PIN_TP_YU_REG_OFFS               (0x00A0)
256 #define ANA_PIN_TP_YD_REG_OFFS               (0x00A4)
257
258 //The pin is in A die
259 #define A_DIE_PIN       BIT_31
260
261 #define MFP_PIN(x)      (((x##_REG_OFFS) & 0xffff) << 16)
262
263 #define MFP_ANA_PIN(x) ((((x##_REG_OFFS) & 0xffff) << 16) | A_DIE_PIN)
264
265 #define MFP_CFG_TO_REG_OFFS(x)  ((x) >> 16)
266
267 //special bit for setting, for the default value of is not same
268 //with all registers
269 #define MFP_IO_SET                              (0x1 << 15)
270 #define MFP_S_PULL_SET  (0x1 << 14)
271 #define MFP_AF_SET                      (0x1 << 13)
272 #define MFP_F_PULL_SET          (0x1 << 12)
273 #define MFP_DS_SET                              (0x1 << 11)
274
275 /* Pinmap ctrl register Bit field value
276 --------------------------------------------------------------------------------------------------------------------------
277 |                 |                 |            |            |              |       |       |            |              |
278 | Reserved[31:10] | Drv str sel[9:8]| func PU[7] | func PD[6] | func sel[5:4]| PU[3] | PD[2] | input En[1]| output En[0] |
279 |                 |                 |            |            |              |       |       |            |              |
280 --------------------------------------------------------------------------------------------------------------------------
281 */
282
283 /*
284 pin output/input enable.
285 NOTE, this is not applied to GPIO pins, GPIO pin's input/output direction have specific
286         registers and specfic bits.
287         BIT 0, 1
288 */
289 #define MFP_IO_NONE  (0x0 << 0)
290 #define MFP_IO_Z                MFP_IO_NONE
291 #define MFP_IO_OE               (0x1    << 0)
292 #define MFP_IO_IE               (0x2 << 0)
293 #define MFP_IO_BOTH   (0x3 << 0)
294 #define MFP_IO_MASK  MFP_IO_BOTH
295
296 /*
297         pin weak pull up/down in sleep mode
298         BIT 2, 3
299 */
300 #define MFP_S_PULL_NONE (0x0  << 2)
301 #define MFP_S_PULL_DOWN         (0x1 << 2)
302 #define MFP_S_PULL_UP           (0x2  << 2)
303 #define MFP_S_PULL_BOTH (0x3  << 2)
304 #define MFP_S_PULL_MASK         MFP_S_PULL_BOTH
305
306 /*
307         pin alternate function
308         BIT 4, 5
309 */
310 #define MFP_AF0                 (0x0 << 4)
311 #define MFP_AF1                 (0x1 << 4)
312 #define MFP_AF2                 (0x2 << 4)
313 #define MFP_AF3                 (0x3 << 4)
314 #define MFP_AF_MASK             (0x3 << 4)
315 #define MFP_GPIO  MFP_AF3
316
317 /*
318         pin weak pull up/down in function mode
319         BIT 6, 7
320 */
321 #define MFP_F_PULL_NONE (0x0  << 6)
322 #define MFP_F_PULL_DOWN         (0x1 << 6)
323 #define MFP_F_PULL_UP           (0x2  << 6)
324 #define MFP_F_PULL_BOTH (0x3  << 6)
325 #define MFP_F_PULL_MASK         MFP_F_PULL_BOTH
326
327 /*
328         pin driver strenth
329         BIT 8, 9
330 */
331
332 #define MFP_DS0         (0x0 << 8)
333 #define MFP_DS1         (0x1 << 8)
334 #define MFP_DS2         (0x2 << 8)
335 #define MFP_DS3         (0x3 << 8)
336 #define MFP_DS_MASK     (0x3 << 8)
337
338
339 #define MFP_CFG(pin, af)                \
340         (MFP_AF_SET |\
341          (MFP_PIN(PIN_##pin) | MFP_##af))
342
343 #define MFP_CFG_DRV(pin, af, drv)       \
344         ((MFP_AF_SET |MFP_DS_SET) |\
345          (MFP_PIN(PIN_##pin) | MFP_##af | MFP_##drv))
346
347 #define MFP_CFG_SLEEP_UPDOWN(pin, af, updown)   \
348         ((MFP_AF_SET | MFP_S_PULL_SET) |\
349          (MFP_PIN(PIN_##pin) | MFP_##af | MFP_##updown))
350
351 #define MFP_CFG_IOE(pin, af, io)        \
352         ((MFP_AF_SET |MFP_IO_SET)  |\
353          (MFP_PIN(PIN_##pin) | MFP_##af | MFP_##io))
354
355 #define MFP_SET_ALL     \
356         (MFP_AF_SET |MFP_IO_SET | MFP_S_PULL_SET | MFP_DS_SET | \
357         MFP_F_PULL_SET)
358
359 #define MFP_CFG_X(pin, af, drv, func_updown, sleep_updown, io)  \
360         (MFP_SET_ALL |\
361          (MFP_PIN(PIN_##pin) | MFP_##af | MFP_##drv |\
362          MFP_##func_updown  | MFP_##sleep_updown| MFP_##io))
363
364 #define MFP_ANA_CFG_X(pin, drv, func_updown, af, sleep_updown, io)      \
365         (MFP_SET_ALL |\
366          (MFP_ANA_PIN(ANA_PIN_##pin) |  MFP_##af | MFP_##drv |\
367          MFP_##func_updown | MFP_##sleep_updown| MFP_##io))
368
369 extern unsigned long mfp_to_gpio(int pin);
370 extern void sprd_mfp_config(unsigned long *mfp_cfgs, int num);
371 #endif
372