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