]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/hal/arm/mx35/var/v2_0/include/hal_soc.h
Initial revision
[karo-tx-redboot.git] / packages / hal / arm / mx35 / 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          0x30000000
80
81 /*
82  * AIPS 1
83  */
84 #define AIPS1_BASE_ADDR         0x43F00000
85 #define AIPS1_CTRL_BASE_ADDR    AIPS1_BASE_ADDR
86 #define MAX_BASE_ADDR           0x43F04000
87 #define EVTMON_BASE_ADDR        0x43F08000
88 #define CLKCTL_BASE_ADDR        0x43F0C000
89 #define ETB_SLOT4_BASE_ADDR     0x43F10000
90 #define ETB_SLOT5_BASE_ADDR     0x43F14000
91 #define ECT_CTIO_BASE_ADDR      0x43F18000
92 #define I2C_BASE_ADDR           0x43F80000
93 #define I2C3_BASE_ADDR          0x43F84000
94 //#define OTG_BASE_ADDR           0x43F88000
95 #define ATA_BASE_ADDR           0x43F8C000
96 #define UART1_BASE_ADDR         0x43F90000
97 #define UART2_BASE_ADDR         0x43F94000
98 #define I2C2_BASE_ADDR          0x43F98000
99 #define OWIRE_BASE_ADDR         0x43F9C000
100 #define SSI1_BASE_ADDR          0x43FA0000
101 #define CSPI1_BASE_ADDR         0x43FA4000
102 #define KPP_BASE_ADDR           0x43FA8000
103 #define IOMUXC_BASE_ADDR        0x43FAC000
104 //#define UART4_BASE_ADDR         0x43FB0000
105 //#define UART5_BASE_ADDR         0x43FB4000
106 #define ECT_IP1_BASE_ADDR       0x43FB8000
107 #define ECT_IP2_BASE_ADDR       0x43FBC000
108
109 /*
110  * SPBA
111  */
112 #define SPBA_BASE_ADDR          0x50000000
113 #define MMC_SDHC1_BASE_ADDR     0x53FB4000
114 #define MMC_SDHC2_BASE_ADDR     0x53FB8000
115 #define ESDHC1_REG_BASE         MMC_SDHC1_BASE_ADDR
116 #define UART3_BASE_ADDR         0x5000C000
117 #define CSPI2_BASE_ADDR         0x50010000
118 #define SSI2_BASE_ADDR          0x50014000
119 //#define SIM_BASE_ADDR           0x50018000
120 #define ATA_DMA_BASE_ADDR       0x50020000
121 #define FEC_BASE_ADDR           0x50038000
122 #define SOC_FEC_BASE            FEC_BASE_ADDR
123 #define SPBA_CTRL_BASE_ADDR     0x5003C000
124
125 /*
126  * AIPS 2
127  */
128 #define AIPS2_BASE_ADDR         0x53F00000
129 #define AIPS2_CTRL_BASE_ADDR    AIPS2_BASE_ADDR
130 #define CCM_BASE_ADDR           0x53F80000
131 //#define FIRI_BASE_ADDR          0x53F8C000
132 #define GPT1_BASE_ADDR          0x53F90000
133 #define EPIT1_BASE_ADDR         0x53F94000
134 #define EPIT2_BASE_ADDR         0x53F98000
135 #define GPIO3_BASE_ADDR         0x53FA4000
136 #define SCC_BASE                0x53FAC000
137 //#define SCM_BASE                0x53FAE000
138 //#define SMN_BASE                0x53FAF000
139 #define RNGA_BASE_ADDR          0x53FB0000
140 #define IPU_CTRL_BASE_ADDR      0x53FC0000
141 #define AUDMUX_BASE             0x53FC4000
142 //#define MPEG4_ENC_BASE          0x53FC8000
143 #define GPIO1_BASE_ADDR         0x53FCC000
144 #define GPIO2_BASE_ADDR         0x53FD0000
145 #define SDMA_BASE_ADDR          0x53FD4000
146 #define RTC_BASE_ADDR           0x53FD8000
147 #define WDOG_BASE_ADDR          0x53FDC000
148 #define PWM_BASE_ADDR           0x53FE0000
149 #define RTIC_BASE_ADDR          0x53FEC000
150 #define IIM_BASE_ADDR           0x53FF0000
151
152 /*
153  * ROMPATCH and AVIC
154  */
155 #define ROMPATCH_BASE_ADDR      0x60000000
156 #define AVIC_BASE_ADDR          0x68000000
157
158 /*
159  * NAND, SDRAM, WEIM, M3IF, EMI controllers
160  */
161 #define EXT_MEM_CTRL_BASE       0xB8000000
162 #define ESDCTL_BASE             0xB8001000
163 #define WEIM_BASE_ADDR          0xB8002000
164 #define WEIM_CTRL_CS0           WEIM_BASE_ADDR
165 #define WEIM_CTRL_CS1           (WEIM_BASE_ADDR + 0x10)
166 #define WEIM_CTRL_CS2           (WEIM_BASE_ADDR + 0x20)
167 #define WEIM_CTRL_CS3           (WEIM_BASE_ADDR + 0x30)
168 #define WEIM_CTRL_CS4           (WEIM_BASE_ADDR + 0x40)
169 #define WEIM_CTRL_CS5           (WEIM_BASE_ADDR + 0x50)
170 #define M3IF_BASE               0xB8003000
171 #define EMI_BASE                0xB8004000
172
173 #define NFC_BASE                0xBB000000
174
175 #define ROM_BASE_ADDR           0x0
176 #define ROM_BASE_ADDR_VIRT      0xF0000000
177 #define ROM_SI_REV_OFFSET       0x40
178
179 /*
180  * Memory regions and CS
181  */
182 #define IPU_MEM_BASE_ADDR       0x70000000
183 #define CSD0_BASE_ADDR          0x80000000
184 #define CSD1_BASE_ADDR          0x90000000
185 #define CS0_BASE_ADDR           0xA0000000
186 #define CS1_BASE_ADDR           0xA8000000
187 #define CS2_BASE_ADDR           0xB0000000
188 #define CS3_BASE_ADDR           0xB2000000
189 #define CS4_BASE_ADDR           0xB4000000
190 #define CS4_BASE_PSRAM          0xB5000000
191 #define CS5_BASE_ADDR           0xB6000000
192
193 #define INTERNAL_ROM_VA         0xF0000000
194
195 /*
196  * IRQ Controller Register Definitions.
197  */
198 #define AVIC_NIMASK                     REG32_PTR(AVIC_BASE_ADDR + (0x04))
199 #define AVIC_INTTYPEH                   REG32_PTR(AVIC_BASE_ADDR + (0x18))
200 #define AVIC_INTTYPEL                   REG32_PTR(AVIC_BASE_ADDR + (0x1C))
201
202 /* L210 */
203 #define L2CC_BASE_ADDR                  0x30000000
204 #define L2_CACHE_LINE_SIZE              32
205 #define L2_CACHE_CTL_REG                0x100
206 #define L2_CACHE_AUX_CTL_REG            0x104
207 #define L2_CACHE_SYNC_REG               0x730
208 #define L2_CACHE_INV_LINE_REG           0x770
209 #define L2_CACHE_INV_WAY_REG            0x77C
210 #define L2_CACHE_CLEAN_LINE_REG         0x7B0
211 #define L2_CACHE_CLEAN_INV_LINE_REG     0x7F0
212 #define L2_CACHE_DBG_CTL_REG            0xF40
213
214 /* CCM */
215 #define CLKCTL_CCMR                     0x00
216 #define CLKCTL_PDR0                     0x04
217 #define CLKCTL_PDR1                     0x08
218 #define CLKCTL_PDR2                     0x0C
219 #define CLKCTL_PDR3                     0x10
220 #define CLKCTL_PDR4                     0x14
221 #define CLKCTL_RCSR                     0x18
222 #define CLKCTL_MPCTL                    0x1C
223 #define CLKCTL_PPCTL                    0x20
224 #define CLKCTL_ACMR                     0x24
225 #define CLKCTL_COSR                     0x28
226 #define CLKCTL_CGR0                     0x2C
227 #define CLKCTL_CGR1                     0x30
228 #define CLKCTL_CGR2                     0x34
229 #define CLKCTL_CGR3                     0x38
230
231
232 #define FREQ_24MHZ                      24000000
233 #define PLL_REF_CLK                     FREQ_24MHZ
234
235 #define CLKMODE_AUTO            0
236 #define CLKMODE_CONSUMER        1
237
238 /* WEIM - CS0 */
239 #define CSCRU                           0x00
240 #define CSCRL                           0x04
241 #define CSCRA                           0x08
242
243 #define CHIP_REV_1_0            0x0      /* PASS 1.0 */
244 #define CHIP_REV_1_1            0x1      /* PASS 1.1 */
245 #define CHIP_REV_2_0            0x2      /* PASS 2.0 */
246 #define CHIP_LATEST             CHIP_REV_1_1
247
248 #define IIM_STAT_OFF            0x00
249 #define IIM_STAT_BUSY           (1 << 7)
250 #define IIM_STAT_PRGD           (1 << 1)
251 #define IIM_STAT_SNSD           (1 << 0)
252 #define IIM_STATM_OFF           0x04
253 #define IIM_ERR_OFF             0x08
254 #define IIM_ERR_PRGE            (1 << 7)
255 #define IIM_ERR_WPE         (1 << 6)
256 #define IIM_ERR_OPE         (1 << 5)
257 #define IIM_ERR_RPE         (1 << 4)
258 #define IIM_ERR_WLRE        (1 << 3)
259 #define IIM_ERR_SNSE        (1 << 2)
260 #define IIM_ERR_PARITYE     (1 << 1)
261 #define IIM_EMASK_OFF           0x0C
262 #define IIM_FCTL_OFF            0x10
263 #define IIM_UA_OFF              0x14
264 #define IIM_LA_OFF              0x18
265 #define IIM_SDAT_OFF            0x1C
266 #define IIM_PREV_OFF            0x20
267 #define IIM_SREV_OFF            0x24
268 #define IIM_PREG_P_OFF          0x28
269 #define IIM_SCS0_OFF            0x2C
270 #define IIM_SCS1_P_OFF          0x30
271 #define IIM_SCS2_OFF            0x34
272 #define IIM_SCS3_P_OFF          0x38
273
274 #define EPIT_BASE_ADDR          EPIT1_BASE_ADDR
275 #define EPITCR                  0x00
276 #define EPITSR                  0x04
277 #define EPITLR                  0x08
278 #define EPITCMPR                0x0C
279 #define EPITCNR                 0x10
280
281 #define GPT_BASE_ADDR           GPT1_BASE_ADDR
282 #define GPTCR                   0x00
283 #define GPTPR                   0x04
284 #define GPTSR                   0x08
285 #define GPTIR                   0x0C
286 #define GPTOCR1                 0x10
287 #define GPTOCR2                 0x14
288 #define GPTOCR3                 0x18
289 #define GPTICR1                 0x1C
290 #define GPTICR2                 0x20
291 #define GPTCNT                  0x24
292
293 /* ESDCTL */
294 #define ESDCTL_ESDCTL0                  0x00
295 #define ESDCTL_ESDCFG0                  0x04
296 #define ESDCTL_ESDCTL1                  0x08
297 #define ESDCTL_ESDCFG1                  0x0C
298 #define ESDCTL_ESDMISC                  0x10
299
300 #if (PLL_REF_CLK != 24000000)
301 #error Wrong PLL reference clock! The following macros will not work.
302 #endif
303
304 /* Assuming 24MHz input clock */
305 /*                            PD             MFD              MFI          MFN */
306 #define MPCTL_PARAM_399     (((1-1) << 26) + ((16-1) << 16) + (8  << 10) + (5 << 0))
307 #define MPCTL_PARAM_532     ((1 << 31) + ((1-1) << 26) + ((12-1) << 16) + (11  << 10) + (1 << 0))
308 #define MPCTL_PARAM_665     (((1-1) << 26) + ((48-1) << 16) + (13  << 10) + (41 << 0))
309
310 /* UPCTL                      PD             MFD              MFI          MFN */
311 #define PPCTL_PARAM_300     (((1-1) << 26) + ((4-1) << 16) + (6  << 10) + (1  << 0))
312
313 #define NFC_V1_1
314
315 #define NAND_REG_BASE                   (NFC_BASE + 0x1E00)
316 #define NFC_BUFSIZE_REG_OFF             (0 + 0x00)
317 #define RAM_BUFFER_ADDRESS_REG_OFF      (0 + 0x04)
318 #define NAND_FLASH_ADD_REG_OFF          (0 + 0x06)
319 #define NAND_FLASH_CMD_REG_OFF          (0 + 0x08)
320 #define NFC_CONFIGURATION_REG_OFF       (0 + 0x0A)
321 #define ECC_STATUS_RESULT_REG_OFF       (0 + 0x0C)
322 #define ECC_RSLT_MAIN_AREA_REG_OFF      (0 + 0x0E)
323 #define ECC_RSLT_SPARE_AREA_REG_OFF     (0 + 0x10)
324 #define NF_WR_PROT_REG_OFF              (0 + 0x12)
325 #define NAND_FLASH_WR_PR_ST_REG_OFF     (0 + 0x18)
326 #define NAND_FLASH_CONFIG1_REG_OFF      (0 + 0x1A)
327 #define NAND_FLASH_CONFIG2_REG_OFF      (0 + 0x1C)
328 #define UNLOCK_START_BLK_ADD_REG_OFF    (0 + 0x20)
329 #define UNLOCK_END_BLK_ADD_REG_OFF      (0 + 0x22)
330 #define RAM_BUFFER_ADDRESS_RBA_3        0x3
331 #define NFC_BUFSIZE_1KB                 0x0
332 #define NFC_BUFSIZE_2KB                 0x1
333 #define NFC_CONFIGURATION_UNLOCKED      0x2
334 #define ECC_STATUS_RESULT_NO_ERR        0x0
335 #define ECC_STATUS_RESULT_1BIT_ERR      0x1
336 #define ECC_STATUS_RESULT_2BIT_ERR      0x2
337 #define NF_WR_PROT_UNLOCK               0x4
338 #define NAND_FLASH_CONFIG1_FORCE_CE     (1 << 7)
339 #define NAND_FLASH_CONFIG1_RST          (1 << 6)
340 #define NAND_FLASH_CONFIG1_BIG          (1 << 5)
341 #define NAND_FLASH_CONFIG1_INT_MSK      (1 << 4)
342 #define NAND_FLASH_CONFIG1_ECC_EN       (1 << 3)
343 #define NAND_FLASH_CONFIG1_SP_EN        (1 << 2)
344 #define NAND_FLASH_CONFIG2_INT_DONE     (1 << 15)
345 #define NAND_FLASH_CONFIG2_FDO_PAGE     (0 << 3)
346 #define NAND_FLASH_CONFIG2_FDO_ID       (2 << 3)
347 #define NAND_FLASH_CONFIG2_FDO_STATUS   (4 << 3)
348 #define NAND_FLASH_CONFIG2_FDI_EN       (1 << 2)
349 #define NAND_FLASH_CONFIG2_FADD_EN      (1 << 1)
350 #define NAND_FLASH_CONFIG2_FCMD_EN      (1 << 0)
351 #define FDO_PAGE_SPARE_VAL              0x8
352 #define NAND_BUF_NUM    8
353
354 #define MXC_NAND_BASE_DUMMY             0x00000000
355 #define MXC_MMC_BASE_DUMMY              0x00000000
356 #define NOR_FLASH_BOOT                  0
357 #define NAND_FLASH_BOOT                 0x10000000
358 #define SDRAM_NON_FLASH_BOOT            0x20000000
359 #define MMC_FLASH_BOOT                  0x40000000
360 #define MXCBOOT_FLAG_REG                (AVIC_BASE_ADDR + 0x100)
361 #define MXCFIS_NOTHING                  0x00000000
362 #define MXCFIS_NAND                     0x10000000
363 #define MXCFIS_NOR                      0x20000000
364 #define MXCFIS_MMC                      0x40000000
365 #define MXCFIS_FLAG_REG                 (AVIC_BASE_ADDR + 0x104)
366
367 #define IS_BOOTING_FROM_NAND()          (readl(MXCBOOT_FLAG_REG) == NAND_FLASH_BOOT)
368 #define IS_BOOTING_FROM_NOR()           (readl(MXCBOOT_FLAG_REG) == NOR_FLASH_BOOT)
369 #define IS_BOOTING_FROM_SDRAM()         (readl(MXCBOOT_FLAG_REG) == SDRAM_NON_FLASH_BOOT)
370 #define IS_BOOTING_FROM_MMC()           (readl(MXCBOOT_FLAG_REG) == MMC_FLASH_BOOT)
371
372 #ifndef MXCFLASH_SELECT_NAND
373 #define IS_FIS_FROM_NAND()              0
374 #else
375 #define IS_FIS_FROM_NAND()              (readl(MXCFIS_FLAG_REG) == MXCFIS_NAND)
376 #endif
377
378 #ifndef MXCFLASH_SELECT_MMC
379 #define IS_FIS_FROM_MMC()               0
380 #else
381 #define IS_FIS_FROM_MMC()               (readl(MXCFIS_FLAG_REG) == MXCFIS_MMC)
382 #endif
383
384 #ifndef MXCFLASH_SELECT_NOR
385 #define IS_FIS_FROM_NOR()               0
386 #else
387 #define IS_FIS_FROM_NOR()               (readl(MXCFIS_FLAG_REG) == MXCFIS_NOR)
388 #endif
389
390 #define MXC_ASSERT_NOR_BOOT()           writel(MXCFIS_NOR, MXCFIS_FLAG_REG)
391 #define MXC_ASSERT_NAND_BOOT()          writel(MXCFIS_NAND, MXCFIS_FLAG_REG)
392 #define MXC_ASSERT_MMC_BOOT()           writel(MXCFIS_MMC, MXCFIS_FLAG_REG)
393
394 /*
395  * This macro is used to get certain bit field from a number
396  */
397 #define MXC_GET_FIELD(val, len, sh)          ((val >> sh) & ((1 << len) - 1))
398
399 /*
400  * This macro is used to set certain bit field inside a number
401  */
402 #define MXC_SET_FIELD(val, len, sh, nval)    ((val & ~(((1 << len) - 1) << sh)) | (nval << sh))
403
404 #define L1CC_ENABLED
405 #define L2CC_ENABLED
406
407 #define UART_WIDTH_32         /* internal UART is 32bit access only */
408
409 #if !defined(__ASSEMBLER__)
410 void cyg_hal_plf_serial_init(void);
411 void cyg_hal_plf_serial_stop(void);
412 void hal_delay_us(unsigned int usecs);
413 #define HAL_DELAY_US(n)     hal_delay_us(n)
414
415 enum plls {
416         MCU_PLL = CCM_BASE_ADDR + CLKCTL_MPCTL,
417         PER_PLL = CCM_BASE_ADDR + CLKCTL_PPCTL,
418 };
419
420 enum main_clocks {
421         CPU_CLK,
422         AHB_CLK,
423         IPG_CLK,
424         IPG_PER_CLK,
425         NFC_CLK,
426         USB_CLK,
427         HSP_CLK,
428 };
429
430 enum peri_clocks {
431         UART1_BAUD,
432         UART2_BAUD,
433         UART3_BAUD,
434         SSI1_BAUD,
435         SSI2_BAUD,
436         CSI_BAUD,
437         MSHC_CLK,
438         ESDHC1_CLK,
439         ESDHC2_CLK,
440         ESDHC3_CLK,
441         SPDIF_CLK,
442         SPI1_CLK = CSPI1_BASE_ADDR,
443         SPI2_CLK = CSPI2_BASE_ADDR,
444 };
445
446 unsigned int pll_clock(enum plls pll);
447
448 unsigned int get_main_clock(enum main_clocks clk);
449
450 unsigned int get_peri_clock(enum peri_clocks clk);
451
452 typedef unsigned int nfc_setup_func_t(unsigned int, unsigned int, unsigned int, unsigned int);
453
454 #endif //#if !defined(__ASSEMBLER__)
455
456 #define HAL_MMU_OFF() \
457 CYG_MACRO_START          \
458     asm volatile (                                                      \
459         "mcr p15, 0, r0, c7, c14, 0;"                                   \
460         "mcr p15, 0, r0, c7, c10, 4;" /* drain the write buffer */      \
461         "mcr p15, 0, r0, c7, c5, 0;" /* invalidate I cache */           \
462         "mrc p15, 0, r0, c1, c0, 0;" /* read c1 */                      \
463         "bic r0, r0, #0x7;" /* disable DCache and MMU */                \
464         "bic r0, r0, #0x1000;" /* disable ICache */                     \
465         "mcr p15, 0, r0, c1, c0, 0;" /*  */                             \
466         "nop;" /* flush i+d-TLBs */                                     \
467         "nop;" /* flush i+d-TLBs */                                     \
468         "nop;" /* flush i+d-TLBs */                                     \
469         :                                                               \
470         :                                                               \
471         : "r0","memory" /* clobber list */);                            \
472 CYG_MACRO_END
473
474 #endif /* __HAL_SOC_H__ */