]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/hal/arm/mx37/var/v2_0/include/hal_soc.h
50617cb183dbf16b0bc530239b8cec2d43ff1366
[karo-tx-redboot.git] / packages / hal / arm / mx37 / var / v2_0 / include / hal_soc.h
1 //==========================================================================
2 //
3 //              hal_soc.h
4 //
5 //              SoC chip definitions
6 //
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12 // Copyright (C) 2002 Gary Thomas
13 //
14 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version.
17 //
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21 // for more details.
22 //
23 // You should have received a copy of the GNU General Public License along
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 //
27 // As a special exception, if other files instantiate templates or use macros
28 // or inline functions from this file, or you compile this file and link it
29 // with other works to produce a work based on this file, this file does not
30 // by itself cause the resulting work to be covered by the GNU General Public
31 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License.
33 //
34 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License.
36 //
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38 // at http://sources.redhat.com/ecos/ecos-license/
39 // -------------------------------------------
40 //####ECOSGPLCOPYRIGHTEND####
41 //========================================================================*/
42
43 #ifndef __HAL_SOC_H__
44 #define __HAL_SOC_H__
45
46 #ifdef __ASSEMBLER__
47 #define UL(a)            (a)
48 #define REG8_VAL(a)      (a)
49 #define REG16_VAL(a) (a)
50 #define REG32_VAL(a) (a)
51
52 #define REG8_PTR(a)      (a)
53 #define REG16_PTR(a) (a)
54 #define REG32_PTR(a) (a)
55
56 #else /* __ASSEMBLER__ */
57
58 #define UL(a)            (a##UL)
59
60 extern char HAL_PLATFORM_EXTRA[20];
61
62 #define REG8_VAL(a)                                             ((unsigned char)(a))
63 #define REG16_VAL(a)                                    ((unsigned short)(a))
64 #define REG32_VAL(a)                                    ((unsigned int)(a))
65
66 #define REG8_PTR(a)                                             ((volatile unsigned char *)(a))
67 #define REG16_PTR(a)                                    ((volatile unsigned short *)(a))
68 #define REG32_PTR(a)                                    ((volatile unsigned int *)(a))
69 #define readb(a)                                                (*(volatile unsigned char *)(a))
70 #define readw(a)                                                (*(volatile unsigned short *)(a))
71 #define readl(a)                                                (*(volatile unsigned int *)(a))
72 #define writeb(v,a)                                             (*(volatile unsigned char *)(a) = (v))
73 #define writew(v,a)                                             (*(volatile unsigned short *)(a) = (v))
74 #define writel(v,a)                                             (*(volatile unsigned int *)(a) = (v))
75
76 #endif /* __ASSEMBLER__ */
77
78 /*
79  * Default Memory Layout Definitions
80  */
81
82 #define L2CC_BASE_ADDR                  UL(0xB0000000)
83
84 #define IRAM_BASE_ADDR                  UL(0x10000000)
85 /*
86  * AIPS 1
87  */
88 #define AIPS1_BASE_ADDR                 UL(0xC3F00000)
89 #define AIPS1_CTRL_BASE_ADDR    AIPS1_BASE_ADDR
90 #define MAX_BASE_ADDR                   UL(0xC3F80000)
91 #define GPIO1_BASE_ADDR                 UL(0xC3F84000)
92 #define GPIO2_BASE_ADDR                 UL(0xC3F88000)
93 #define GPIO3_BASE_ADDR                 UL(0xC3F8C000)
94 #define KPP_BASE_ADDR                   UL(0xC3F94000)
95 #define WDOG1_BASE_ADDR                 UL(0xC3F98000)
96 #define WDOG_BASE_ADDR                  WDOG1_BASE_ADDR
97
98 #define WDOG_WCR_REG                    (WDOG_BASE_ADDR + 0x00)
99 #define WDOG_WRSR_REG                   (WDOG_BASE_ADDR + 0x04)
100
101 #define WDOG2_BASE_ADDR                 UL(0xC3F9C000)
102 #define GPT1_BASE_ADDR                  UL(0xC3FA0000)
103 #define RTC_BASE_ADDR                   UL(0xC3FA4000)
104 #define IOMUXC_BASE_ADDR                UL(0xC3FA8000)
105 #define IIM_BASE_ADDR                   UL(0xC3FAC000)
106 #define FEC_BASE_ADDR                   UL(0xC3FE8000)
107 #define SOC_FEC_BASE                    FEC_BASE_ADDR
108 /*
109  * SPBA
110  */
111 #define MMC_SDHC1_BASE_ADDR             UL(0xC0004000)
112 #define ESDHC1_REG_BASE                 MMC_SDHC1_BASE_ADDR
113 #define MMC_SDHC2_BASE_ADDR             UL(0xC0008000)
114 #define UART3_BASE_ADDR                 UL(0xC000C000)
115 #define CSPI2_BASE_ADDR                 UL(0xC0010000)
116 #define SSI2_BASE_ADDR                  UL(0xC0014000)
117 #define ATA_DMA_BASE_ADDR               UL(0xC0034000)
118 #define SPBA_CTRL_BASE_ADDR             UL(0xC003C000)
119
120 /*
121  * AIPS 2
122  */
123 #define AIPS2_BASE_ADDR                 UL(0xE3F00000)
124 #define AIPS2_CTRL_BASE_ADDR    AIPS2_BASE_ADDR
125 #define PLL1_BASE_ADDR                  UL(0xE3F80000)
126 #define PLL2_BASE_ADDR                  UL(0xE3F84000)
127 #define PLL3_BASE_ADDR                  UL(0xE3F88000)
128 #define CCM_BASE_ADDR                   UL(0xE3F8C000)
129 #define SRC_BASE_ADDR                   UL(0xE3F94000)
130
131 #define SRC_SRSR_REG                    (SRC_BASE_ADDR + 0x08)
132
133 #define EPIT1_BASE_ADDR                 UL(0xE3F98000)
134 #define EPIT2_BASE_ADDR                 UL(0xE3F9C000)
135 #define CSPI3_BASE_ADDR                 UL(0xE3FA8000)
136 #define CSPI1_BASE_ADDR                 UL(0xE3FAC000)
137 #define UART1_BASE_ADDR                 UL(0xE3FB0000)
138 #define UART2_BASE_ADDR                 UL(0xE3FBC000)
139 #define I2C3_BASE_ADDR                  UL(0xE3FC0000)
140 #define I2C2_BASE_ADDR                  UL(0xE3FC4000)
141 #define I2C_BASE_ADDR                   UL(0xE3FC8000)
142 #define SSI1_BASE_ADDR                  UL(0xE3FCC000)
143 #define AUDMUX_BASE                             UL(0xE3FD0000)
144
145 #define GPC_BASE_ADDR                   UL(0xE3F90000)
146 #define GPC_CNTR_REG                    (GPC_BASE_ADDR + 0x0)
147 #define GPC_PGR_REG                             (GPC_BASE_ADDR + 0x4)
148 #define GPC_VCR_REG                             (GPC_BASE_ADDR + 0x8)
149
150 #define PGC_BASE_VPU                    (GPC_BASE_ADDR + 0x0240)
151 #define PGC_BASE_IPU                    (GPC_BASE_ADDR + 0x0220)
152 #define GPC_PGR                                 (GPC_BASE_ADDR + 0x000)
153 #define SRPGCR_ARM                              (GPC_BASE_ADDR + 0x02A0 + 0x0000)
154 #define SRPGCR_EMI                              (GPC_BASE_ADDR + 0x0280 + 0x0000)
155 #define PGC_PGCR_VPU                    (PGC_BASE_VPU + 0x0000)
156 #define PGC_PGCR_IPU                    (PGC_BASE_IPU + 0x0000)
157
158 #define PLATFORM_BASE_ADDR              UL(0xB0404000)
159 #define PLATFORM_LPC_REG                (PLATFORM_BASE_ADDR + 0x14)
160
161 /*
162  * Interrupt controller
163  */
164 #define INTC_BASE_ADDR                  UL(0xB0800000)
165
166 /*
167  * NAND, SDRAM, WEIM, M4IF, EMI controllers
168  */
169 #define NFC_IP_BASE                             UL(0xE3FDB000)
170 #define ESDCTL_BASE                             UL(0xE3FD9000)
171 #define WEIM_BASE_ADDR                  UL(0xE3FDA000)
172
173 #define WEIM_CTRL_CS0                   WEIM_BASE_ADDR
174 #define WEIM_CTRL_CS1                   (WEIM_BASE_ADDR + 0x18)
175 #define WEIM_CTRL_CS2                   (WEIM_BASE_ADDR + 0x30)
176 #define WEIM_CTRL_CS3                   (WEIM_BASE_ADDR + 0x48)
177 #define WEIM_CTRL_CS4                   (WEIM_BASE_ADDR + 0x60)
178 #define WEIM_CTRL_CS5                   (WEIM_BASE_ADDR + 0x78)
179 #define M4IF_BASE                               UL(0xE3FD8000)
180
181 /*
182  * Memory regions and CS
183  */
184 #define CSD0_BASE_ADDR                  UL(0x40000000)
185 #define CSD1_BASE_ADDR                  UL(0x50000000)
186 #define CS0_BASE_ADDR                   UL(0x60000000)
187 #define CS1_BASE_ADDR                   UL(0x68000000)
188 #define CS2_BASE_ADDR                   UL(0x70000000)
189
190 /*
191  * IRQ Controller Register Definitions.
192  */
193 #define INTC_NIMASK                                             REG32_PTR(INTC_BASE_ADDR + (0x04))
194 #define INTC_INTTYPEH                                   REG32_PTR(INTC_BASE_ADDR + (0x18))
195 #define INTC_INTTYPEL                                   REG32_PTR(INTC_BASE_ADDR + (0x1C))
196
197 /* M4IF */
198 #define M4IF_FBPM0                                              0x40
199 #define M4IF_FIDBP                                              0x48
200
201 /* L210 */
202 #define L2_CACHE_LINE_SIZE                              32
203 #define L2_CACHE_CTL_REG                                0x100
204 #define L2_CACHE_AUX_CTL_REG                    0x104
205 #define L2_CACHE_SYNC_REG                               0x730
206 #define L2_CACHE_INV_LINE_REG                   0x770
207 #define L2_CACHE_INV_WAY_REG                    0x77C
208 #define L2_CACHE_CLEAN_LINE_PA_REG              0x7B0
209 #define L2_CACHE_CLEAN_LINE_WAY_REG             0x7B8
210 #define L2_CACHE_CLEAN_WAY_REG                  0x7BC
211 #define L2_CACHE_CLEAN_INV_LINE_PA_REG  0x7F0
212 #define L2_CACHE_CLEAN_INV_LINE_WAY_REG 0x7F8
213 #define L2_CACHE_CLEAN_INV_WAY_REG              0x7FC
214
215 /* CCM */
216 #define CLKCTL_CCMR                                     0x00
217 #define CLKCTL_PDR0                                     0x04
218 #define CLKCTL_PDR1                                     0x08
219
220 #define CLKCTL_CCSR                                     0x0C
221 #define CLKCTL_CACRR                            0x10
222 #define CLKCTL_CBCDR2                           0x18
223 #define CLKCTL_CBCDR3                           0x1C
224 #define CLKCTL_CBCDR4                           0x20
225 #define CLKCTL_CBCDR5                           0x24
226 #define CLKCTL_CBCDR6                           0x28
227 #define CLKCTL_CBCDR7                           0x2C
228 #define CLKCTL_CAMR                                     0x30
229 #define CLKCTL_PDR2                                     0x64
230 #define CLKCTL_RCSR                                     0x0C
231 #define CLKCTL_MPCTL                            0x10
232 #define CLKCTL_UPCTL                            0x14
233 #define CLKCTL_SPCTL                            0x18
234 #define CLKCTL_COSR                                     0x1C
235 #define CLKCTL_CSCMR1                           0x34
236 #define CLKCTL_CSCDR1                           0x3C
237 #define CLKCTL_CS1CDR                           0x40
238 #define CLKCTL_CS2CDR                           0x44
239 #define CLKCTL_CSCDR2                           0x60
240 #define CLKCTL_CDCR                                     0x6C
241 #define CLKCTL_CCOSR                            0x80
242
243 #define FREQ_24MHZ                                      24000000
244 #define FREQ_32768HZ                            (32768 * 1024)
245 #define FREQ_38400HZ                            (38400 * 1024)
246 #define FREQ_32000HZ                            (32000 * 1024)
247 #define PLL_REF_CLK                                     FREQ_24MHZ
248 //#define PLL_REF_CLK  FREQ_32768HZ
249 //#define PLL_REF_CLK  FREQ_32000HZ
250
251 /* WEIM registers */
252 #define CSGCR1                                          0x00
253 #define CSGCR2                                          0x04
254 #define CSRCR1                                          0x08
255 #define CSRCR2                                          0x0C
256 #define CSWCR1                                          0x10
257
258 /* ESDCTL */
259 #define ESDCTL_ESDCTL0                          0x00
260 #define ESDCTL_ESDCFG0                          0x04
261 #define ESDCTL_ESDCTL1                          0x08
262 #define ESDCTL_ESDCFG1                          0x0C
263 #define ESDCTL_ESDMISC                          0x10
264 #define ESDCTL_ESDSCR                           0x14
265 #define ESDCTL_ESDCDLY1                         0x20
266 #define ESDCTL_ESDCDLY2                         0x24
267 #define ESDCTL_ESDCDLY3                         0x28
268 #define ESDCTL_ESDCDLY4                         0x2C
269 #define ESDCTL_ESDCDLY5                         0x30
270 #define ESDCTL_ESDCDLYGD                        0x34
271
272 /* DPLL */
273 #define PLL_DP_CTL                                      0x00
274 #define PLL_DP_CONFIG                           0x04
275 #define PLL_DP_OP                                       0x08
276 #define PLL_DP_MFD                                      0x0C
277 #define PLL_DP_MFN                                      0x10
278 #define PLL_DP_MFNMINUS                         0x14
279 #define PLL_DP_MFNPLUS                          0x18
280 #define PLL_DP_HFS_OP                           0x1C
281 #define PLL_DP_HFS_MFD                          0x20
282 #define PLL_DP_HFS_MFN                          0x24
283 #define PLL_DP_TOGC                                     0x28
284 #define PLL_DP_DESTAT                           0x2C
285
286 #define CHIP_REV_1_0                            0x0              /* PASS 1.0 */
287 #define CHIP_REV_1_1                            0x1              /* PASS 1.1 */
288 #define CHIP_REV_2_0                            0x2              /* PASS 2.0 */
289 #define CHIP_LATEST                                     CHIP_REV_1_1
290
291 #define IIM_STAT_OFF                            0x00
292 #define IIM_STAT_BUSY                           (1 << 7)
293 #define IIM_STAT_PRGD                           (1 << 1)
294 #define IIM_STAT_SNSD                           (1 << 0)
295 #define IIM_STATM_OFF                           0x04
296 #define IIM_ERR_OFF                                     0x08
297 #define IIM_ERR_PRGE                            (1 << 7)
298 #define IIM_ERR_WPE                                     (1 << 6)
299 #define IIM_ERR_OPE                                     (1 << 5)
300 #define IIM_ERR_RPE                                     (1 << 4)
301 #define IIM_ERR_WLRE                            (1 << 3)
302 #define IIM_ERR_SNSE                            (1 << 2)
303 #define IIM_ERR_PARITYE                         (1 << 1)
304 #define IIM_EMASK_OFF                           0x0C
305 #define IIM_FCTL_OFF                            0x10
306 #define IIM_UA_OFF                                      0x14
307 #define IIM_LA_OFF                                      0x18
308 #define IIM_SDAT_OFF                            0x1C
309 #define IIM_PREV_OFF                            0x20
310 #define IIM_SREV_OFF                            0x24
311 #define IIM_PREG_P_OFF                          0x28
312 #define IIM_SCS0_OFF                            0x2C
313 #define IIM_SCS1_P_OFF                          0x30
314 #define IIM_SCS2_OFF                            0x34
315 #define IIM_SCS3_P_OFF                          0x38
316
317 #define EPIT_BASE_ADDR                          EPIT1_BASE_ADDR
318 #define EPITCR                                          0x00
319 #define EPITSR                                          0x04
320 #define EPITLR                                          0x08
321 #define EPITCMPR                                        0x0C
322 #define EPITCNR                                         0x10
323
324 /*defines iomux for mx37*/
325 #define IOMUX_SD1_CMD_PORT                      0
326 #define IOMUX_SD1_CMD_PIN                       32
327 #define IOMUX_SD1_CMD_SEL                       (0x200 | 0x10 | (51 << 12))
328 #define IOMUX_SD1_CMD_DIR                       0xFF
329
330 #define IOMUX_SD1_CLK_PORT                      0
331 #define IOMUX_SD1_CLK_PIN                       32
332 #define IOMUX_SD1_CLK_SEL                       (0x200 | (52 << 12))
333 #define IOMUX_SD1_CLK_DIR                       0xFF
334
335 #define IOMUX_SD1_DATA0_PORT            0
336 #define IOMUX_SD1_DATA0_PIN                     32
337 #define IOMUX_SD1_DATA0_SEL                     (0x200 | (53 << 12))
338 #define IOMUX_SD1_DATA0_DIR                     0xFF
339
340 #define IOMUX_SD1_DATA1_PORT            0
341 #define IOMUX_SD1_DATA1_PIN                     32
342 #define IOMUX_SD1_DATA1_SEL                     (0x200 | (54 << 12))
343 #define IOMUX_SD1_DATA1_DIR                     0xFF
344
345 #define IOMUX_SD1_DATA2_PORT            0
346 #define IOMUX_SD1_DATA2_PIN                     32
347 #define IOMUX_SD1_DATA2_SEL                     (0x200 | (55 << 12))
348 #define IOMUX_SD1_DATA2_DIR                     0xFF
349
350 #define IOMUX_SD1_DATA3_PORT            0
351 #define IOMUX_SD1_DATA3_PIN                     32
352 #define IOMUX_SD1_DATA3_SEL                     (0x200 | (56 << 12))
353 #define IOMUX_SD1_DATA3_DIR                     0xFF
354
355 #define IOMUX_SD2_DATA0_PORT            0
356 #define IOMUX_SD2_DATA0_PIN                     32
357 #define IOMUX_SD2_DATA0_SEL                     (0x200 | 0x4 | (59 << 12))
358 #define IOMUX_SD2_DATA0_DIR                     0xFF
359 #define IOMUX_SD2_DATA1_PORT            0
360 #define IOMUX_SD2_DATA1_PIN                     32
361 #define IOMUX_SD2_DATA1_SEL                     (0x200 | 0x4 | (60 << 12))
362 #define IOMUX_SD2_DATA1_DIR                     0xFF
363 #define IOMUX_SD2_DATA2_PORT            0
364 #define IOMUX_SD2_DATA2_PIN                     32
365 #define IOMUX_SD2_DATA2_SEL                     (0x200 | 0x4 | (61 << 12))
366 #define IOMUX_SD2_DATA2_DIR                     0xFF
367 #define IOMUX_SD2_DATA3_PORT            0
368 #define IOMUX_SD2_DATA3_PIN                     32
369 #define IOMUX_SD2_DATA3_SEL                     (0x200 | 0x4 | (62 << 12))
370 #define IOMUX_SD2_DATA3_DIR                     0xFF
371
372 #define IOMUX_PAD_GPIO1_4_PORT          0
373 #define IOMUX_PAD_GPIO1_4_PIN           32
374 #define IOMUX_PAD_GPIO1_4_SEL           (0x200 | 0x6 | (134 << 12))
375 #define IOMUX_PAD_GPIO1_4_SEL_1         (0x200 | 0x0 | (134 << 12))
376 #define IOMUX_PAD_GPIO1_4_DIR           0xFF
377
378 #define IOMUX_PAD_GPIO1_5_PORT          0
379 #define IOMUX_PAD_GPIO1_5_PIN           32
380 #define IOMUX_PAD_GPIO1_5_SEL           (0x200 | 0x6 | (135 << 12))
381 #define IOMUX_PAD_GPIO1_5_DIR           0xFF
382
383 #define IOMUX_PAD_GPIO1_6_PORT          0
384 #define IOMUX_PAD_GPIO1_6_PIN           32
385 #define IOMUX_PAD_GPIO1_6_SEL           (0x200 | 0x6 | (136 << 12))
386 #define IOMUX_PAD_GPIO1_6_DIR           0xFF
387
388 #define GPT_BASE_ADDR                   GPT1_BASE_ADDR
389 #define GPTCR                                   0x00
390 #define GPTPR                                   0x04
391 #define GPTSR                                   0x08
392 #define GPTIR                                   0x0C
393 #define GPTOCR1                                 0x10
394 #define GPTOCR2                                 0x14
395 #define GPTOCR3                                 0x18
396 #define GPTICR1                                 0x1C
397 #define GPTICR2                                 0x20
398 #define GPTCNT                                  0x24
399
400 /* Assuming 26MHz input clock */
401 /*                                                        PD                     MFD                      MFI              MFN */
402 #define MPCTL_PARAM_208         (((2-1) << 26) + ((1 -1) << 16) + (8  << 10) + (0  << 0))
403 #define MPCTL_PARAM_399         (((1-1) << 26) + ((52-1) << 16) + (7  << 10) + (35 << 0))
404 #define MPCTL_PARAM_532         (((1-1) << 26) + ((52-1) << 16) + (10 << 10) + (12 << 0))
405 #define MPCTL_PARAM_665         (((1-1) << 26) + ((52-1) << 16) + (12 << 10) + (41 << 0))
406 #define MPCTL_PARAM_532_27      (((1-1) << 26) + ((15-1) << 16) + (9  << 10) + (13 << 0))
407
408 /* UPCTL                                          PD                     MFD                      MFI              MFN */
409 #define UPCTL_PARAM_288         (((1-1) << 26) + ((13-1) << 16) + (5  << 10) + (7  << 0))
410 #define UPCTL_PARAM_240         (((2-1) << 26) + ((13-1) << 16) + (9  << 10) + (3  << 0))
411 #define UPCTL_PARAM_240_27      (((2-1) << 26) + ((9 -1) << 16) + (8  << 10) + (8  << 0))
412
413 /* PDR0 */
414 #define PDR0_208_104_52         0xFF870D48      /* ARM=208MHz, HCLK=104MHz, IPG=52MHz */
415 #define PDR0_399_66_66          0xFF872B28      /* ARM=399MHz, HCLK=IPG=66.5MHz */
416 #define PDR0_399_133_66         0xFF871650      /* ARM=399MHz, HCLK=133MHz, IPG=66.5MHz */
417 #define PDR0_532_133_66         0xFF871D58      /* ARM=532MHz, HCLK=133MHz, IPG=66MHz */
418 #define PDR0_665_83_42          0xFF873B78      /* ARM=665MHz, HCLK=83MHz, IPG=42MHz */
419 #define PDR0_665_133_66         0xFF872560      /* ARM=665MHz, HCLK=133MHz, IPG=66MHz */
420
421 //#define BARKER_CODE_SWAP_LOC                  0x404
422 #define BARKER_CODE_VAL                                 0xB1
423 #define NFC_V2_1
424 #define NFC_BASE                                                UL(0x7FFF0000)
425 #define NAND_REG_BASE                                   (NFC_BASE + 0x1E00)
426
427 #define NAND_ADD_CMD_REG                                (NAND_REG_BASE + 0x00)
428
429 #define NAND_CONFIGURATION1_REG                 (NAND_REG_BASE + 0x04)
430         #define NAND_CONFIGURATION1_NFC_RST             (1 << 2)
431         #define NAND_CONFIGURATION1_NF_CE               (1 << 1)
432         #define NAND_CONFIGURATION1_SP_EN               (1 << 0)
433
434 #define NAND_ECC_STATUS_RESULT_REG              (NAND_REG_BASE + 0x08)
435
436 #define NAND_LAUNCH_REG                                 (NAND_REG_BASE + 0x0C)
437         #define NAND_LAUNCH_FCMD                                (1 << 0)
438         #define NAND_LAUNCH_FADD                                (1 << 1)
439         #define NAND_LAUNCH_FDI                                 (1 << 2)
440
441
442 #define NFC_WR_PROT_REG                                 (NFC_IP_BASE + 0x00)
443         #define NFC_WR_PROT_CS0                                 (0 << 20)
444         #define NFC_WR_PROT_BLS_UNLOCK                  (2 << 16)
445         #define NFC_WR_PROT_WPC                                 (4 << 0)
446
447 #define UNLOCK_BLK_ADD0_REG                             (NFC_IP_BASE + 0x04)
448
449 #define UNLOCK_BLK_ADD1_REG                             (NFC_IP_BASE + 0x08)
450
451 #define UNLOCK_BLK_ADD2_REG                             (NFC_IP_BASE + 0x0C)
452
453 #define UNLOCK_BLK_ADD3_REG                             (NFC_IP_BASE + 0x10)
454
455 #define NFC_FLASH_CONFIG2_REG                   (NFC_IP_BASE + 0x14)
456         #define NFC_FLASH_CONFIG2_EDC0                  (0 << 9)
457         #define NFC_FLASH_CONFIG2_EDC1                  (1 << 9)
458         #define NFC_FLASH_CONFIG2_EDC2                  (2 << 9)
459         #define NFC_FLASH_CONFIG2_EDC3                  (3 << 9)
460         #define NFC_FLASH_CONFIG2_EDC4                  (4 << 9)
461         #define NFC_FLASH_CONFIG2_EDC5                  (5 << 9)
462         #define NFC_FLASH_CONFIG2_EDC6                  (6 << 9)
463         #define NFC_FLASH_CONFIG2_EDC7                  (7 << 9)
464         #define NFC_FLASH_CONFIG2_PPB_32                (0 << 7)
465         #define NFC_FLASH_CONFIG2_PPB_64                (1 << 7)
466         #define NFC_FLASH_CONFIG2_PPB_128               (2 << 7)
467         #define NFC_FLASH_CONFIG2_PPB_256               (3 << 7)
468         #define NFC_FLASH_CONFIG2_INT_MSK               (1 << 4)
469         #define NFC_FLASH_CONFIG2_ECC_EN                (1 << 3)
470         #define NFC_FLASH_CONFIG2_SYM                   (1 << 2)
471
472 #define NFC_IPC_REG                                             (NFC_IP_BASE + 0x18)
473         #define NFC_IPC_INT                                             (1 << 31)
474         #define NFC_IPC_LPS                                             (1 << 30)
475         #define NFC_IPC_RB_B                                    (1 << 29)
476         #define NFC_IPC_CACK                                    (1 << 1)
477         #define NFC_IPC_CREQ                                    (1 << 0)
478 #define NFC_AXI_ERR_ADD_REG                             (NFC_IP_BASE + 0x1C)
479
480 #define MXC_NAND_BASE_DUMMY                             0x00000000
481 #define MXC_MMC_BASE_DUMMY                              0x00000000
482
483 #define FROM_SDRAM                                              0x00000000
484 #define FROM_NAND_FLASH                                 0x10000000
485 #define FROM_NOR_FLASH                                  0x20000000
486 #define FROM_MMC_FLASH                                  0x40000000
487 #define FROM_SPI_NOR_FLASH                              0x80000000
488
489 #define IS_BOOTING_FROM_NAND()                  (_mxc_boot == FROM_NAND_FLASH)
490 // No NOR flash is supported under MX37 for booting
491 #define IS_BOOTING_FROM_NOR()                   0
492 #define IS_BOOTING_FROM_SPI_NOR()               0
493 #define IS_BOOTING_FROM_SDRAM()                 (_mxc_boot == FROM_SDRAM)
494 #define IS_BOOTING_FROM_MMC()                   (_mxc_boot == FROM_MMC_FLASH)
495
496 #ifndef MXCFLASH_SELECT_NAND
497 #define IS_FIS_FROM_NAND()                              0
498 #else
499 #define IS_FIS_FROM_NAND()                              (_mxc_fis == FROM_NAND_FLASH)
500 #endif
501
502 #ifndef MXCFLASH_SELECT_MMC
503 #define IS_FIS_FROM_MMC()                               0
504 #else
505 #define IS_FIS_FROM_MMC()                               (_mxc_fis == FROM_MMC_FLASH)
506 #endif
507
508 #define IS_FIS_FROM_NOR()                               0
509
510 /*
511  * This macro is used to get certain bit field from a number
512  */
513 #define MXC_GET_FIELD(val, len, sh)                     ((val >> sh) & ((1 << len) - 1))
514
515 /*
516  * This macro is used to set certain bit field inside a number
517  */
518 #define MXC_SET_FIELD(val, len, sh, nval)       ((val & ~(((1 << len) - 1) << sh)) | (nval << sh))
519
520 #define L2CC_ENABLED
521 #define UART_WIDTH_32           /* internal UART is 32bit access only */
522
523 /* Offsets for system_rev */
524 #define PART_NUMBER_OFFSET                      12
525 #define PMIC_ID_OFFSET                          8
526 #define MAJOR_NUMBER_OFFSET                     4
527 #define MINOR_NUMBER_OFFSET                     0
528
529 #if !defined(__ASSEMBLER__)
530 void cyg_hal_plf_serial_init(void);
531 void cyg_hal_plf_serial_stop(void);
532 void hal_delay_us(unsigned int usecs);
533 #define HAL_DELAY_US(n)         hal_delay_us(n)
534 extern int _mxc_fis;
535 extern int _mxc_boot;
536 extern unsigned int system_rev;
537
538 enum plls {
539         PLL1,
540         PLL2,
541         PLL3,
542 };
543
544 enum main_clocks {
545                 CPU_CLK,
546                 AHB_CLK,
547                 IPG_CLK,
548                 IPG_PER_CLK,
549                 DDR_CLK,
550                 NFC_CLK,
551                 USB_CLK,
552 };
553
554 enum peri_clocks {
555                 UART1_BAUD,
556                 UART2_BAUD,
557                 UART3_BAUD,
558                 SSI1_BAUD,
559                 SSI2_BAUD,
560                 CSI_BAUD,
561                 MSTICK1_CLK,
562                 MSTICK2_CLK,
563                 SPI1_CLK = CSPI1_BASE_ADDR,
564                 SPI2_CLK = CSPI2_BASE_ADDR,
565 };
566
567 unsigned int pll_clock(enum plls pll);
568
569 unsigned int get_main_clock(enum main_clocks clk);
570
571 unsigned int get_peri_clock(enum peri_clocks clk);
572
573 typedef unsigned int nfc_setup_func_t(unsigned int, unsigned int, unsigned int, unsigned int);
574
575 #endif //#if !defined(__ASSEMBLER__)
576
577 #define HAL_MMU_OFF()                                                                                           \
578 CYG_MACRO_START                                                                                                         \
579         asm volatile (                                                                                                  \
580                 "mcr p15, 0, r0, c7, c14, 0;"                                                           \
581                 "mcr p15, 0, r0, c7, c10, 4;" /* drain the write buffer */      \
582                 "mcr p15, 0, r0, c7, c5, 0;" /* invalidate I cache */           \
583                 "mrc p15, 0, r0, c1, c0, 0;" /* read c1 */                                      \
584                 "bic r0, r0, #0x7;" /* disable DCache and MMU */                        \
585                 "bic r0, r0, #0x1000;" /* disable ICache */                                     \
586                 "mcr p15, 0, r0, c1, c0, 0;"                                                            \
587                 "nop;" /* flush i+d-TLBs */                                                                     \
588                 "nop;" /* flush i+d-TLBs */                                                                     \
589                 "nop;" /* flush i+d-TLBs */                                                                     \
590                 :                                                                                                                       \
591                 :                                                                                                                       \
592                 : "r0","memory" /* clobber list */);                                            \
593 CYG_MACRO_END
594
595 #endif /* __HAL_SOC_H__ */