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