1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2011 by Amaury Pouly
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
26 * 0x00000000 - 0x00007fff: on chip ram
27 * 0x40000000 - 0x5fffffff: dram (512Mb max)
28 * 0x80000000 - 0x80100000: memory mapped registers
29 * We use the following map:
30 * 0x60000000 - 0x7fffffff: dram (cached)
31 * 0x90000000 - 0xafffffff: dram (buffered)
32 * everything else : identity mapped (uncached)
34 * As a side note it's important to notice that uncached dram is identity mapped
38 #define IRAM_SIZE 0x8000
39 #define DRAM_ORIG 0x40000000
40 #define DRAM_SIZE (MEMORYSIZE * 0x100000)
42 #define UNCACHED_DRAM_ADDR 0x40000000
43 #define CACHED_DRAM_ADDR 0x60000000
44 #define BUFFERED_DRAM_ADDR 0x90000000
45 #define CACHEALIGN_SIZE 32
47 #define NOCACHE_BASE (UNCACHED_DRAM_ADDR - CACHED_DRAM_ADDR)
49 #define PHYSICAL_ADDR(a) \
50 ((typeof(a))((uintptr_t)(a) >= BUFFERED_DRAM_ADDR ? \
51 ((uintptr_t)(a) - BUFFERED_DRAM_ADDR + UNCACHED_DRAM_ADDR) \
52 :(uintptr_t)(a) >= CACHED_DRAM_ADDR ? \
53 ((uintptr_t)(a) - CACHED_DRAM_ADDR + UNCACHED_DRAM_ADDR) \
55 #define UNCACHED_ADDR(a) PHYSICAL_ADDR(a)
57 #define TTB_BASE_ADDR (DRAM_ORIG + DRAM_SIZE - TTB_SIZE)
58 #define TTB_SIZE 0x4000
59 #define TTB_BASE ((unsigned long *)TTB_BASE_ADDR)
60 #define FRAME_SIZE (LCD_WIDTH * LCD_HEIGHT * LCD_DEPTH / 8)
61 #define FRAME_PHYS_ADDR (DRAM_ORIG + DRAM_SIZE - TTB_SIZE - FRAME_SIZE)
62 #define FRAME ((void *)(FRAME_PHYS_ADDR - UNCACHED_DRAM_ADDR + BUFFERED_DRAM_ADDR))
64 /* Timer runs at APBX speed which is derived from ref_xtal@24MHz */
65 #define TIMER_FREQ 24000000
68 #define TICK_TIMER_NR 0
69 #define USER_TIMER_NR 1
71 #error Select timers !
75 #define USB_QHARRAY_ATTR __attribute__((section(".qharray"),nocommon,aligned(2048)))
76 #define USB_NUM_ENDPOINTS 5
77 #define USB_DEVBSS_ATTR NOCACHEBSS_ATTR
78 #define USB_BASE 0x80080000
80 #define QHARRAY_SIZE ((64*USB_NUM_ENDPOINTS*2 + 2047) & (0xffffffff - 2047))
81 #define QHARRAY_PHYS_ADDR ((FRAME_PHYS_ADDR - QHARRAY_SIZE) & (0xffffffff - 2047))
84 #define __REG_SET(reg) (*((volatile uint32_t *)(® + 1)))
85 #define __REG_CLR(reg) (*((volatile uint32_t *)(® + 2)))
86 #define __REG_TOG(reg) (*((volatile uint32_t *)(® + 3)))
88 #define __BLOCK_SFTRST (1 << 31)
89 #define __BLOCK_CLKGATE (1 << 30)
91 #define CACHEALIGN_BITS 4
93 #define __XTRACT(reg, field) ((reg & reg##__##field##_BM) >> reg##__##field##_BP)
94 #define __XTRACT_EX(val, field) (((val) & field##_BM) >> field##_BP)
95 #define __FIELD_SET(reg, field, val) reg = (reg & ~reg##__##field##_BM) | (val << reg##__##field##_BP)
97 #endif /* __IMX233_H__ */