1 //==========================================================================
5 // SoC chip definitions
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
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.
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
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.
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.
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.
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 //========================================================================*/
46 #include <pkgconf/hal_arm_soc_specific_def.h>
50 #define REG8_VAL(a) (a)
51 #define REG16_VAL(a) (a)
52 #define REG32_VAL(a) (a)
54 #define REG8_PTR(a) (a)
55 #define REG16_PTR(a) (a)
56 #define REG32_PTR(a) (a)
58 #else /* __ASSEMBLER__ */
60 extern char HAL_PLATFORM_EXTRA[];
61 #define REG8_VAL(a) ((unsigned char)(a))
62 #define REG16_VAL(a) ((unsigned short)(a))
63 #define REG32_VAL(a) ((unsigned int)(a))
65 #define REG8_PTR(a) ((volatile unsigned char *)(a))
66 #define REG16_PTR(a) ((volatile unsigned short *)(a))
67 #define REG32_PTR(a) ((volatile unsigned int *)(a))
68 #define readb(a) (*(volatile unsigned char *)(a))
69 #define readw(a) (*(volatile unsigned short *)(a))
70 #define readl(a) (*(volatile unsigned int *)(a))
71 #define writeb(v,a) (*(volatile unsigned char *)(a) = (v))
72 #define writew(v,a) (*(volatile unsigned short *)(a) = (v))
73 #define writel(v,a) (*(volatile unsigned int *)(a) = (v))
75 #endif /* __ASSEMBLER__ */
78 * Default Memory Layout Definitions
81 #define L2CC_BASE_ADDR 0x30000000
86 #define AIPS1_BASE_ADDR 0x43F00000
87 #define AIPS1_CTRL_BASE_ADDR AIPS1_BASE_ADDR
88 #define MAX_BASE_ADDR 0x43F04000
89 #define EVTMON_BASE_ADDR 0x43F08000
90 #define CLKCTL_BASE_ADDR 0x43F0C000
91 #define ETB_SLOT4_BASE_ADDR 0x43F10000
92 #define ETB_SLOT5_BASE_ADDR 0x43F14000
93 #define ECT_CTIO_BASE_ADDR 0x43F18000
94 #define I2C_BASE_ADDR 0x43F80000
95 #define MU_BASE_ADDR 0x43F84000
96 #define WDOG2_BASE_ADDR 0x43F88000
97 #define UART1_BASE_ADDR 0x43F90000
98 #define UART2_BASE_ADDR 0x43F94000
99 #define OWIRE_BASE_ADDR 0x43F9C000
100 #define SSI1_BASE_ADDR 0x43FA0000
101 #define CSPI1_BASE_ADDR 0x43FA4000
102 #define KPP_BASE_ADDR 0x43FA8000
107 #define SPBA_BASE_ADDR 0x50000000
108 #if defined(CYGPKG_HAL_ARM_MXC91331_CHIP)
109 #define SIM2_BASE_ADDR 0x50000000
110 #elif defined(CYGPKG_HAL_ARM_MXC91321_CHIP)
111 #define IOMUXC_BASE_ADDR 0x50000000
113 #error Neither MXC91321 nor MXC91331 defined. What is it?
115 #define MMC_SDHC1_BASE_ADDR 0x50004000
116 #define MMC_SDHC2_BASE_ADDR 0x50008000
117 #define UART3_BASE_ADDR 0x5000C000
118 #define CSPI2_BASE_ADDR 0x50010000
119 #define SSI2_BASE_ADDR 0x50014000
120 #define SIM1_BASE_ADDR 0x50018000
121 #define IIM_BASE_ADDR 0x5001C000
122 #define USBOTG_BASE_ADDR 0x50020000
123 #define HAC_BASE_ADDR 0x50024000
124 #define UART4_BASE_ADDR 0x50028000
125 #define GPIO2_BASE_ADDR 0x5002C000
126 #if defined(CYGPKG_HAL_ARM_MXC91331_CHIP)
127 #define IOMUXC_BASE_ADDR 0x50030000
128 #elif defined(CYGPKG_HAL_ARM_MXC91321_CHIP)
129 #define SIM2_BASE_ADDR 0x50000000
131 #define GEMK_BASE_ADDR 0x50034000
132 #define SDMA_CTI_BASE_ADDR 0x50038000
133 #define SPBA_CTRL_BASE_ADDR 0x5003C000
138 #define AIPS2_BASE_ADDR 0x53F00000
139 #define AIPS2_CTRL_BASE_ADDR AIPS2_BASE_ADDR
140 #define CRM_MCU_BASE_ADDR 0x53F80000
141 #define ECT_MCU_CTI_BASE_ADDR 0x53F84000
142 #define EDIO_BASE_ADDR 0x53F88000
143 #define FIRI_BASE_ADDR 0x53F8C000
144 #define GPT_BASE_ADDR 0x53F90000
145 #define EPIT1_BASE_ADDR 0x53F94000
146 #define EPIT2_BASE_ADDR 0x53F98000
147 #define SCC_BASE 0x53FAC000
148 #define RNG_BASE_ADDR 0x53FB0000
149 #define RTR_BASE_ADDR 0x53FB4000
150 #define IPU_CTRL_BASE_ADDR 0x53FC0000
151 #define AUDMUX_BASE 0x53FC4000
152 #define MPEG4_ENC_BASE 0x53FC8000
153 #define GPIO1_BASE_ADDR 0x53FCC000
154 #define SDMA_BASE_ADDR 0x53FD4000
155 #define RTC_BASE_ADDR 0x53FD8000
156 #define WDOG1_BASE_ADDR 0x53FDC000
157 #define WDOG_BASE_ADDR WDOG1_BASE_ADDR
158 #define PWM_BASE_ADDR 0x53FE0000
159 #define RTIC_BASE_ADDR 0x53FEC000
164 #define ROMPATCH_BASE_ADDR 0x60000000
165 #define AVIC_BASE_ADDR 0x68000000
168 * NAND, SDRAM, WEIM, M3IF, EMI controllers
170 #define EXT_MEM_CTRL_BASE 0xB8000000
171 #define NFC_BASE EXT_MEM_CTRL_BASE
172 #define ESDCTL_BASE 0xB8001000
173 #define WEIM_BASE_ADDR 0xB8002000
174 #define WEIM_CTRL_CS0 WEIM_BASE_ADDR
175 #define WEIM_CTRL_CS1 (WEIM_BASE_ADDR + 0x10)
176 #define WEIM_CTRL_CS2 (WEIM_BASE_ADDR + 0x20)
177 #define WEIM_CTRL_CS3 (WEIM_BASE_ADDR + 0x30)
178 #define WEIM_CTRL_CS4 (WEIM_BASE_ADDR + 0x40)
179 #define M3IF_BASE 0xB8003000
180 #define PCMCIA_CTL_BASE 0xB8004000
183 * Memory regions and CS
185 #define IPU_MEM_BASE_ADDR 0x70000000
186 #define CSD0_BASE_ADDR 0x80000000
187 #define CSD1_BASE_ADDR 0x90000000
188 #define CS0_BASE_ADDR 0xA0000000
189 #define CS1_BASE_ADDR 0xA8000000
190 #define CS2_BASE_ADDR 0xB0000000
191 #define CS3_BASE_ADDR 0xB2000000
192 #define CS4_BASE_ADDR 0xB4000000
193 #define CS4_BASE_PSRAM 0xB5000000
194 #define CS5_BASE_ADDR 0xB6000000
195 #define PCMCIA_MEM_BASE_ADDR 0xC0000000
197 #define INTERNAL_ROM_VA 0xF0000000
200 * IRQ Controller Register Definitions.
202 #define AVIC_NIMASK REG32_PTR(AVIC_BASE_ADDR + (0x04))
203 #define AVIC_INTTYPEH REG32_PTR(AVIC_BASE_ADDR + (0x18))
204 #define AVIC_INTTYPEL REG32_PTR(AVIC_BASE_ADDR + (0x1C))
207 #define L2_CACHE_LINE_SIZE 32
208 #define L2_CACHE_CTL_REG 0x100
209 #define L2_CACHE_AUX_CTL_REG 0x104
210 #define L2_CACHE_SYNC_REG 0x730
211 #define L2_CACHE_INV_LINE_REG 0x770
212 #define L2_CACHE_INV_WAY_REG 0x77C
213 #define L2_CACHE_CLEAN_LINE_PA_REG 0x7B0
214 #define L2_CACHE_CLEAN_LINE_WAY_REG 0x7B8
215 #define L2_CACHE_CLEAN_WAY_REG 0x7BC
216 #define L2_CACHE_CLEAN_INV_LINE_PA_REG 0x7F0
217 #define L2_CACHE_CLEAN_INV_LINE_WAY_REG 0x7F8
218 #define L2_CACHE_CLEAN_INV_WAY_REG 0x7FC
221 #define SPBA_IOMUX 0x30
222 #define SPBA_GPIO_SDMA 0x2C
225 #define CLKCTL_MCR 0x00
226 #define CLKCTL_PDR0 0x04
227 #define CLKCTL_PDR1 0x08
228 #define CLKCTL_RCSR 0x0C
229 #define CLKCTL_MPCTL 0x10
230 #define CLKCTL_UPCTL 0x14
231 #define CLKCTL_COSR 0x18
232 #define CLKCTL_MCGR0 0x1C
233 #define CLKCTL_MCGR1 0x20
234 #define CLKCTL_MCGR2 0x24
235 #define CLKCTL_DCVR0 0x28
236 #define CLKCTL_DCVR1 0x2C
237 #define CLKCTL_DCVR2 0x30
238 #define CLKCTL_DCVR3 0x34
239 #define CLKCTL_PMCR 0x38
240 #define CLKCTL_SDCR 0x3C
241 #define CLKCTL_CDTR 0x40
242 // The following is for MXC91321 only
243 #define CLKCTL_TPCTL 0x44
244 #define CLKCTL_UCDTR 0x48
245 #define CLKCTL_TCDTR 0x4C
246 #define CLKCTL_MPDR2 0x50
247 #define CLKCTL_DPTCDBG 0x54
248 #define CLKCTL_PMCR1 0x58
250 #define FREQ_26MHZ 26000000
251 #define FREQ_32768HZ (32768 * 512)
252 #define FREQ_32000HZ (32000 * 512)
253 #define PLL_REF_CLK FREQ_26MHZ
254 //#define PLL_REF_CLK FREQ_32768HZ
255 //#define PLL_REF_CLK FREQ_32000HZ
263 #define ESDCTL_ESDCTL0 0x00
264 #define ESDCTL_ESDCFG0 0x04
265 #define ESDCTL_ESDCTL1 0x08
266 #define ESDCTL_ESDCFG1 0x0C
267 #define ESDCTL_ESDMISC 0x10
268 #define ESDCTL_ESDCDLY1 0x20
269 #define ESDCTL_ESDCDLY2 0x24
270 #define ESDCTL_ESDCDLY5 0x30
271 #define ESDCTL_ESDCDLYL 0x34
273 #if (PLL_REF_CLK != 26000000)
274 #error Wrong PLL reference clock! The following macros will not work.
277 /* Assuming 26MHz input clock */
278 /* MPCTL PD MFD MFI MFN */
279 #define MPCTL_PARAM_208 (((2-1) << 26) + ((1-1) << 16) + (8 << 11) + (0 << 0))
280 #define MPCTL_PARAM_399 (((1-1) << 26) + ((52-1) << 16) + (7 << 11) + (35 << 0))
281 #define MPCTL_PARAM_532 (((1-1) << 26) + ((13-1) << 16) + (10 << 11) + (3 << 0))
282 #define TPCTL_PARAM_500 (((1-1) << 26) + ((208-1) << 16) + (9 << 11) + (123 << 0))
283 #define TPCTL_PARAM_532 MPCTL_PARAM_532
285 /* UPCTL PD MFD MFI MFN */
286 #define UPCTL_PARAM_288 (((1-1) << 26) + ((13-1) << 16) + (5 << 10) + (7 << 0))
288 #define PDR0_399_133_66 0xFF800550 /* ARM=399MHz, HCLK=133MHz, IPG=66.5MHz */
289 #define PDR0_399_100_50 0xFF800458 /* ARM=399MHz, HCLK=100MHz, IPG=50MHz */
290 #define PDR0_399_66_66 0xFF800328 /* ARM=399MHz, HCLK=IPG=66.5MHz */
291 #define PDR0_52_52_52 0xFF80021C /* ARM=HCLK=IPG=52MHz */
292 #define PDR0_208_52_52 0xFF800218 /* ARM=208MHz, HCLK=52MHz, IPG=52MHz */
293 #define PDR0_532_66_66 0xFF800338 /* ARM=532MHz, HCLK=66MHz, IPG=66MHz */
294 #define PDR0_532_133_66 0xFF800658 /* ARM=532MHz, HCLK=133MHz, IPG=66MHz */
297 #define CHIP_REV_1_0 0x10 /* PASS 1.0 */
298 #define CHIP_REV_1_1 0x11 /* PASS 1.0 */
299 #define CHIP_REV_1_2 0x12 /* PASS 1.2 */
300 #define CHIP_REV_2_0 0x20 /* PASS 2.0 */
301 #define CHIP_REV_2_1 0x21 /* PASS 2.1 */
302 #if defined(CYGPKG_HAL_ARM_MXC91321_CHIP)
303 #define CHIP_LATEST CHIP_REV_1_2
305 #define CHIP_LATEST CHIP_REV_2_1
307 #define IIM_STAT_OFF 0x00
308 #define IIM_STAT_BUSY (1 << 7)
309 #define IIM_STAT_PRGD (1 << 1)
310 #define IIM_STAT_SNSD (1 << 0)
311 #define IIM_STATM_OFF 0x04
312 #define IIM_ERR_OFF 0x08
313 #define IIM_ERR_PRGE (1 << 7)
314 #define IIM_ERR_WPE (1 << 6)
315 #define IIM_ERR_OPE (1 << 5)
316 #define IIM_ERR_RPE (1 << 4)
317 #define IIM_ERR_WLRE (1 << 3)
318 #define IIM_ERR_SNSE (1 << 2)
319 #define IIM_ERR_PARITYE (1 << 1)
320 #define IIM_EMASK_OFF 0x0C
321 #define IIM_FCTL_OFF 0x10
322 #define IIM_UA_OFF 0x14
323 #define IIM_LA_OFF 0x18
324 #define IIM_SDAT_OFF 0x1C
325 #define IIM_PREV_OFF 0x20
326 #define IIM_SREV_OFF 0x24
327 #define IIM_PREG_P_OFF 0x28
328 #define IIM_SCS0_OFF 0x2C
329 #define IIM_SCS1_P_OFF 0x30
330 #define IIM_SCS2_OFF 0x34
331 #define IIM_SCS3_P_OFF 0x38
333 #define EPIT_BASE_ADDR EPIT1_BASE_ADDR
337 #define EPITCMPR 0x0C
340 #define NAND_REG_BASE (NFC_BASE + 0xE00)
341 #define NFC_BUFSIZE_REG_OFF (0 + 0x00)
342 #define RAM_BUFFER_ADDRESS_REG_OFF (0 + 0x04)
343 #define NAND_FLASH_ADD_REG_OFF (0 + 0x06)
344 #define NAND_FLASH_CMD_REG_OFF (0 + 0x08)
345 #define NFC_CONFIGURATION_REG_OFF (0 + 0x0A)
346 #define ECC_STATUS_RESULT_REG_OFF (0 + 0x0C)
347 #define ECC_RSLT_MAIN_AREA_REG_OFF (0 + 0x0E)
348 #define ECC_RSLT_SPARE_AREA_REG_OFF (0 + 0x10)
349 #define NF_WR_PROT_REG_OFF (0 + 0x12)
350 #define UNLOCK_START_BLK_ADD_REG_OFF (0 + 0x14)
351 #define UNLOCK_END_BLK_ADD_REG_OFF (0 + 0x16)
352 #define NAND_FLASH_WR_PR_ST_REG_OFF (0 + 0x18)
353 #define NAND_FLASH_CONFIG1_REG_OFF (0 + 0x1A)
354 #define NAND_FLASH_CONFIG2_REG_OFF (0 + 0x1C)
355 #define RAM_BUFFER_ADDRESS_RBA_3 0x3
356 #define NFC_BUFSIZE_1KB 0x0
357 #define NFC_BUFSIZE_2KB 0x1
358 #define NFC_CONFIGURATION_UNLOCKED 0x2
359 #define ECC_STATUS_RESULT_NO_ERR 0x0
360 #define ECC_STATUS_RESULT_1BIT_ERR 0x1
361 #define ECC_STATUS_RESULT_2BIT_ERR 0x2
362 #define NF_WR_PROT_UNLOCK 0x4
363 #define NAND_FLASH_CONFIG1_FORCE_CE (1 << 7)
364 #define NAND_FLASH_CONFIG1_RST (1 << 6)
365 #define NAND_FLASH_CONFIG1_BIG (1 << 5)
366 #define NAND_FLASH_CONFIG1_INT_MSK (1 << 4)
367 #define NAND_FLASH_CONFIG1_ECC_EN (1 << 3)
368 #define NAND_FLASH_CONFIG1_SP_EN (1 << 2)
369 #define NAND_FLASH_CONFIG2_INT_DONE (1 << 15)
370 #define NAND_FLASH_CONFIG2_FDO_PAGE (0 << 3)
371 #define NAND_FLASH_CONFIG2_FDO_ID (2 << 3)
372 #define NAND_FLASH_CONFIG2_FDO_STATUS (4 << 3)
373 #define NAND_FLASH_CONFIG2_FDI_EN (1 << 2)
374 #define NAND_FLASH_CONFIG2_FADD_EN (1 << 1)
375 #define NAND_FLASH_CONFIG2_FCMD_EN (1 << 0)
376 #define FDO_PAGE_SPARE_VAL 0x8
378 #define NOR_FLASH_BOOT 0
379 #define NAND_FLASH_BOOT 0x10000000
380 #define SDRAM_NON_FLASH_BOOT 0x20000000
381 #define MMC_BOOT 0x40000000
382 #define MXCBOOT_FLAG_REG (AVIC_BASE_ADDR + 0x100)
384 #define MXCFIS_NOTHING 0x00000000
385 #define MXCFIS_NAND 0x10000000
386 #define MXCFIS_NOR 0x20000000
387 #define MXCFIS_MMC 0x40000000
388 #define MXCFIS_FLAG_REG (AVIC_BASE_ADDR + 0x104)
390 #define IS_BOOTING_FROM_NAND() (readl(MXCBOOT_FLAG_REG) == NAND_FLASH_BOOT)
391 #define IS_BOOTING_FROM_NOR() (readl(MXCBOOT_FLAG_REG) == NOR_FLASH_BOOT)
392 #define IS_BOOTING_FROM_SDRAM() (readl(MXCBOOT_FLAG_REG) == SDRAM_NON_FLASH_BOOT)
393 #define IS_BOOTING_FROM_MMC() (readl(MXCBOOT_FLAG_REG) == MMC_BOOT)
395 #ifndef MXCFLASH_SELECT_NAND
396 #define IS_FIS_FROM_NAND() 0
398 #define IS_FIS_FROM_NAND() (readl(MXCFIS_FLAG_REG) == MXCFIS_NAND)
401 #ifndef MXCFLASH_SELECT_NOR
402 #define IS_FIS_FROM_NOR() 0
404 #define IS_FIS_FROM_NOR() (readl(MXCFIS_FLAG_REG) == MXCFIS_NOR)
407 #ifndef MXCFLASH_SELECT_MMC
408 #define IS_FIS_FROM_MMC() 0
410 #define IS_FIS_FROM_MMC() (readl(MXCFIS_FLAG_REG) == MXCFIS_MMC)
413 #define MXC_ASSERT_NOR_BOOT() writel(MXCFIS_NOR, MXCFIS_FLAG_REG)
414 #define MXC_ASSERT_NAND_BOOT() writel(MXCFIS_NAND, MXCFIS_FLAG_REG)
415 #define MXC_ASSERT_MMC_BOOT() writel(MXCFIS_MMC, MXCFIS_FLAG_REG)
418 * This macro is used to get certain bit field from a number
420 #define MXC_GET_FIELD(val, len, sh) ((val >> sh) & ((1 << len) - 1))
423 * This macro is used to set certain bit field inside a number
425 #define MXC_SET_FIELD(val, len, sh, nval) ((val & ~(((1 << len) - 1) << sh)) | (nval << sh))
427 #define UART_WIDTH_32 /* internal UART is 32bit access only */
431 #if !defined(__ASSEMBLER__)
432 void cyg_hal_plf_serial_init(void);
433 void cyg_hal_plf_serial_stop(void);
434 void hal_delay_us(unsigned int usecs);
435 #define HAL_DELAY_US(n) hal_delay_us(n)
438 MCU_PLL = CRM_MCU_BASE_ADDR + CLKCTL_MPCTL,
439 USB_PLL = CRM_MCU_BASE_ADDR + CLKCTL_UPCTL,
440 TUR_PLL = CRM_MCU_BASE_ADDR + CLKCTL_TPCTL,
460 SPI1_CLK = CSPI1_BASE_ADDR,
461 SPI2_CLK = CSPI2_BASE_ADDR,
464 unsigned int pll_clock(enum plls pll);
466 unsigned int get_main_clock(enum main_clocks clk);
468 unsigned int get_peri_clock(enum peri_clocks clk);
470 typedef unsigned int nfc_setup_func_t(unsigned int, unsigned int, unsigned int, unsigned int);
472 #endif //#if !defined(__ASSEMBLER__)
474 #define HAL_MMU_OFF() \
477 "mcr p15, 0, r0, c7, c14, 0;" \
478 "mcr p15, 0, r0, c7, c10, 4;" /* drain the write buffer */ \
479 "mcr p15, 0, r0, c7, c5, 0;" /* invalidate I cache */ \
480 "mrc p15, 0, r0, c1, c0, 0;" /* read c1 */ \
481 "bic r0, r0, #0x7;" /* disable DCache and MMU */ \
482 "bic r0, r0, #0x1000;" /* disable ICache */ \
483 "mcr p15, 0, r0, c1, c0, 0;" /* */ \
484 "nop;" /* flush i+d-TLBs */ \
485 "nop;" /* flush i+d-TLBs */ \
486 "nop;" /* flush i+d-TLBs */ \
487 "nop;" /* flush i+d-TLBs */ \
488 "nop;" /* flush i+d-TLBs */ \
489 "nop;" /* flush i+d-TLBs */ \
490 "nop;" /* flush i+d-TLBs */ \
491 "nop;" /* flush i+d-TLBs */ \
492 "nop;" /* flush i+d-TLBs */ \
495 : "r0","memory" /* clobber list */); \
498 #endif // __HAL_SOC_H__