gemini_reg.h revision 1.2 1 1.2 cliff /* $NetBSD: gemini_reg.h,v 1.2 2008/10/28 23:18:44 cliff Exp $ */
2 1.1 matt
3 1.1 matt #ifndef _ARM_GEMINI_REG_H_
4 1.1 matt #define _ARM_GEMINI_REG_H_
5 1.1 matt
6 1.1 matt /*
7 1.1 matt * Register definitions for Gemini SOC
8 1.1 matt */
9 1.1 matt
10 1.1 matt #include "opt_gemini.h"
11 1.1 matt #include <machine/endian.h>
12 1.1 matt #include <sys/cdefs.h>
13 1.1 matt
14 1.1 matt #if defined(SL3516)
15 1.1 matt /*
16 1.1 matt * Gemini SL3516 memory map
17 1.1 matt */
18 1.1 matt #define GEMINI_SRAM_BASE 0x00000000 /* Internal SRAM */
19 1.2 cliff /* NOTE: use the SHADOW to avoid conflict w/ DRAM */
20 1.1 matt #define GEMINI_SRAM_SIZE 0x10000000 /* 128 MB */
21 1.2 cliff #define GEMINI_DRAM_BASE 0x00000000 /* DRAM (via DDR Control Module) */
22 1.2 cliff /* NOTE: this is a shadow of 0x10000000 */
23 1.1 matt #define GEMINI_DRAM_SIZE 0x20000000 /* 512 MB */
24 1.2 cliff /* NOTE: size of addr space, not necessarily populated */
25 1.1 matt #define GEMINI_FLASH_BASE 0x30000000 /* DRAM (via DDR Control Module) */
26 1.1 matt #define GEMINI_FLASH_SIZE 0x10000000 /* 128 MB */
27 1.1 matt
28 1.1 matt /*
29 1.1 matt * Gemini SL3516 device map
30 1.1 matt */
31 1.1 matt #define GEMINI_GLOBAL_BASE 0x40000000 /* Global registers */
32 1.1 matt #define GEMINI_WATCHDOG_BASE 0x41000000 /* Watch dog timer module */
33 1.1 matt #define GEMINI_UART_BASE 0x42000000 /* UART control module */
34 1.1 matt #define GEMINI_UART_SIZE 0x20
35 1.1 matt #define GEMINI_TIMER_BASE 0x43000000 /* Timer module */
36 1.1 matt #define GEMINI_LCD_BASE 0x44000000 /* LCD Interface module */
37 1.1 matt #define GEMINI_RTC_BASE 0x45000000 /* Real Time Clock module */
38 1.1 matt #define GEMINI_SATA_BASE 0x46000000 /* Serial ATA module */
39 1.1 matt #define GEMINI_LPCHC_BASE 0x47000000 /* LPC Hosr Controller module */
40 1.1 matt #define GEMINI_LPCP_BASE 0x47800000 /* LPC Peripherals IO space */
41 1.1 matt #define GEMINI_IC0_BASE 0x48000000 /* Interrupt Control module #0 */
42 1.1 matt #define GEMINI_IC1_BASE 0x49000000 /* Interrupt Control module #1 */
43 1.1 matt #define GEMINI_SSPC_BASE 0x4a000000 /* Synchronous Serial Port Control module */
44 1.1 matt #define GEMINI_PWRC_BASE 0x4b000000 /* Power Control module */
45 1.1 matt #define GEMINI_CIR_BASE 0x4c000000 /* CIR Control module */
46 1.1 matt #define GEMINI_GPIO0_BASE 0x4d000000 /* GPIO module #0 */
47 1.1 matt #define GEMINI_GPIO1_BASE 0x4e000000 /* GPIO module #1 */
48 1.1 matt #define GEMINI_GPIO2_BASE 0x4f000000 /* GPIO module #2 */
49 1.1 matt #define GEMINI_PCICFG_BASE 0x50000000 /* PCI IO, configuration and control space */
50 1.1 matt #define GEMINI_PCIIO_BASE 0x50001000 /* PCI IO space */
51 1.1 matt #define GEMINI_PCIIO_SIZE 0x0007f000 /* PCI IO space size */
52 1.1 matt #define GEMINI_PCIMEM_BASE 0x58000000 /* PCI Memory space */
53 1.1 matt #define GEMINI_PCIMEM_SIZE 0x08000000 /* PCI Memory space size */
54 1.1 matt #define GEMINI_NGC_BASE 0x60000000 /* NetEngine & GMAC Configuration registers */
55 1.1 matt #define GEMINI_SDC_BASE 0x62000000 /* Security DMA and Configure registers */
56 1.1 matt #define GEMINI_MIDE_BASE 0x63000000 /* Multi IDE registers */
57 1.1 matt #define GEMINI_RXDC_BASE 0x64000000 /* RAID XOR DMA Configuration registers */
58 1.1 matt #define GEMINI_FLASHC_BASE 0x65000000 /* Flash Controller registers */
59 1.1 matt #define GEMINI_DRAMC_BASE 0x66000000 /* DRAM (DDR/SDR) Controller registers */
60 1.1 matt #define GEMINI_GDMA_BASE 0x67000000 /* General DMA registers */
61 1.1 matt #define GEMINI_USB0_BASE 0x68000000 /* USB #0 registers */
62 1.1 matt #define GEMINI_USB1_BASE 0x69000000 /* USB #1 registers */
63 1.1 matt #define GEMINI_TVE_BASE 0x6a000000 /* TVE registers */
64 1.1 matt #define GEMINI_SRAM_SHADOW_BASE 0x70000000 /* Shadow of internal SRAM */
65 1.1 matt
66 1.1 matt /*
67 1.1 matt * Gemini SL3516 Watchdog device register offsets and bits
68 1.1 matt */
69 1.1 matt #define GEMINI_WDT_WDCOUNTER 0x0 /* Watchdog Timer Counter */ /* ro */
70 1.1 matt #define GEMINI_WDT_WDLOAD 0x4 /* Watchdog Timer Load */ /* rw */
71 1.1 matt #define WDT_WDLOAD_DFLT 0x3EF1480 /* default Load reg val */
72 1.1 matt #define GEMINI_WDT_WDRESTART 0x8 /* Watchdog Timer Restart */ /* wo */
73 1.1 matt #define WDT_WDRESTART_Resv __BITS(31,16)
74 1.1 matt #define WDT_WDRESTART_RST __BITS(15,0)
75 1.1 matt #define WDT_WDRESTART_MAGIC 0x5ab9
76 1.1 matt #define GEMINI_WDT_WDCR 0xc /* Watchdog Timer Control */ /* rw */
77 1.1 matt #define WDT_WDCR_Resv __BITS(31,5)
78 1.1 matt #define WDT_WDCR_CLKSRC __BIT(4) /* Timer Clock Source: 5 MHz clock */
79 1.1 matt #define WDCR_CLKSRC_PCLK (0 << 4) /* Timer Clock Source: PCLK (APB CLK) */
80 1.1 matt #define WDCR_CLKSRC_5MHZ (1 << 4) /* Timer Clock Source: 5 MHz clock */
81 1.1 matt #define WDT_WDCR_EXTSIG_ENB __BIT(3) /* Timer External Signal Enable */
82 1.1 matt #define WDT_WDCR_INTR_ENB __BIT(2) /* Timer System Interrupt Enable */
83 1.1 matt #define WDT_WDCR_RESET_ENB __BIT(1) /* Timer System Reset Enable */
84 1.1 matt #define WDT_WDCR_ENB __BIT(0) /* Timer Enable */
85 1.1 matt #define GEMINI_WDT_WDSTATUS 0x10 /* Watchdog Timer Status */ /* ro */
86 1.1 matt #define WDT_WDSTATUS_Resv __BITS(31,1)
87 1.1 matt #define WDT_WDSTATUS_ZERO __BIT(0) /* non-zero if timer counted down to zero! */
88 1.1 matt #define GEMINI_WDT_WDCLEAR 0x14 /* Watchdog Timer Clear */ /* wo */
89 1.1 matt #define WDT_WDCLEAR_Resv __BITS(31,1)
90 1.1 matt #define WDT_WDCLEAR_CLEAR __BIT(0) /* write this bit to clear Status */
91 1.1 matt #define GEMINI_WDT_WDINTERLEN 0x18 /* Watchdog Timer Interrupt Length */ /* rw */
92 1.1 matt /* duration of signal assertion, */
93 1.1 matt /* in units of clock cycles */
94 1.1 matt #define WDT_WDINTERLEN_DFLT 0xff /* default is 256 cycles */
95 1.1 matt
96 1.1 matt
97 1.1 matt /*
98 1.1 matt * Gemini SL3516 Timer device register offsets and bits
99 1.1 matt *
100 1.1 matt * have 3 timers, here indexed 1<=(n)<=3 as in the doc
101 1.1 matt * each has 4 sequential 32bit rw regs
102 1.1 matt */
103 1.1 matt #define GEMINI_NTIMERS 3
104 1.1 matt #define GEMINI_TIMERn_REG(n, o) ((((n) - 1) * 0x10) + (o))
105 1.1 matt #define GEMINI_TIMERn_COUNTER(n) GEMINI_TIMERn_REG((n), 0x0) /* rw */
106 1.1 matt #define GEMINI_TIMERn_LOAD(n) GEMINI_TIMERn_REG((n), 0x4) /* rw */
107 1.1 matt #define GEMINI_TIMERn_MATCH1(n) GEMINI_TIMERn_REG((n), 0x08) /* rw */
108 1.1 matt #define GEMINI_TIMERn_MATCH2(n) GEMINI_TIMERn_REG((n), 0x0C) /* rw */
109 1.1 matt #define GEMINI_TIMER_TMCR 0x30 /* rw */
110 1.1 matt #define TIMER_TMCR_Resv __BITS(31,12)
111 1.1 matt #define TIMER_TMCR_TMnUPDOWN(n) __BIT(9 + (n) - 1)
112 1.1 matt #define TIMER_TMCR_TMnOFENABLE(n) __BIT((((n) - 1) * 3) + 2)
113 1.1 matt #define TIMER_TMCR_TMnCLOCK(n) __BIT((((n) - 1) * 3) + 1)
114 1.1 matt #define TIMER_TMCR_TMnENABLE(n) __BIT((((n) - 1) * 3) + 0)
115 1.1 matt #define GEMINI_TIMER_TMnCR_MASK(n) \
116 1.1 matt ( TIMER_TMCR_TMnUPDOWN(n) \
117 1.1 matt | TIMER_TMCR_TMnOFENABLE(n) \
118 1.1 matt | TIMER_TMCR_TMnCLOCK(n) \
119 1.1 matt | TIMER_TMCR_TMnENABLE(n) )
120 1.1 matt #define GEMINI_TIMER_INTRSTATE 0x34 /* rw */
121 1.1 matt #define TIMER_INTRSTATE_Resv __BITS(31,9)
122 1.1 matt #define TIMER_INTRSTATE_TMnOVFLOW(n) __BIT((((n) -1) * 3) + 2)
123 1.1 matt #define TIMER_INTRSTATE_TMnMATCH2(n) __BIT((((n) -1) * 3) + 1)
124 1.1 matt #define TIMER_INTRSTATE_TMnMATCH1(n) __BIT((((n) -1) * 3) + 0)
125 1.1 matt #define GEMINI_TIMER_INTRMASK 0x38 /* rw */
126 1.1 matt #define TIMER_INTRMASK_Resv __BITS(31,9)
127 1.1 matt #define TIMER_INTRMASK_TMnOVFLOW(n) __BIT((((n) -1) * 3) + 2)
128 1.1 matt #define TIMER_INTRMASK_TMnMATCH2(n) __BIT((((n) -1) * 3) + 1)
129 1.1 matt #define TIMER_INTRMASK_TMnMATCH1(n) __BIT((((n) -1) * 3) + 0)
130 1.1 matt #define GEMINI_TIMERn_INTRMASK(n) \
131 1.1 matt ( TIMER_INTRMASK_TMnOVFLOW(n) \
132 1.1 matt | TIMER_INTRMASK_TMnMATCH2(n) \
133 1.1 matt | TIMER_INTRMASK_TMnMATCH1(n) )
134 1.1 matt
135 1.1 matt /*
136 1.1 matt * Gemini SL3516 Interrupt Controller device register offsets and bits
137 1.1 matt */
138 1.1 matt #define GEMINI_ICU_IRQ_SOURCE 0x0 /* ro */
139 1.1 matt #define GEMINI_ICU_IRQ_ENABLE 0x4 /* rw */
140 1.1 matt #define GEMINI_ICU_IRQ_CLEAR 0x8 /* wo */
141 1.1 matt #define GEMINI_ICU_IRQ_TRIGMODE 0xc /* rw */
142 1.1 matt #define ICU_IRQ_TRIGMODE_EDGE 1 /* edge triggered */
143 1.1 matt #define ICU_IRQ_TRIGMODE_LEVEL 0 /* level triggered */
144 1.1 matt #define GEMINI_ICU_IRQ_TRIGLEVEL 0x10 /* rw */
145 1.1 matt #define ICU_IRQ_TRIGLEVEL_LO 1 /* active low or falling edge */
146 1.1 matt #define ICU_IRQ_TRIGLEVEL_HI 0 /* active high or rising edge */
147 1.1 matt #define GEMINI_ICU_IRQ_STATUS 0x14 /* ro */
148 1.1 matt
149 1.1 matt #define GEMINI_ICU_FIQ_SOURCE 0x20 /* ro */
150 1.1 matt #define GEMINI_ICU_FIQ_ENABLE 0x24 /* rw */
151 1.1 matt #define GEMINI_ICU_FIQ_CLEAR 0x28 /* wo */
152 1.1 matt #define GEMINI_ICU_FIQ_TRIGMODE 0x2c /* rw */
153 1.1 matt #define GEMINI_ICU_FIQ_TRIGLEVEL 0x30 /* rw */
154 1.1 matt #define GEMINI_ICU_FIQ_STATUS 0x34 /* ro */
155 1.1 matt
156 1.1 matt #define GEMINI_ICU_REVISION 0x50 /* ro */
157 1.1 matt #define GEMINI_ICU_INPUT_NUM 0x54 /* ro */
158 1.1 matt #define ICU_INPUT_NUM_RESV __BITS(31,16)
159 1.1 matt #define ICU_INPUT_NUM_IRQ __BITS(15,8)
160 1.1 matt #define ICU_INPUT_NUM_FIQ __BITS(7,0)
161 1.1 matt #define GEMINI_ICU_IRQ_DEBOUNCE 0x58 /* ro */
162 1.1 matt #define GEMINI_ICU_FIQ_DEBOUNCE 0x5c /* ro */
163 1.1 matt
164 1.1 matt
165 1.1 matt /*
166 1.1 matt * Gemini PCI controller register offsets and bits
167 1.1 matt */
168 1.1 matt #define GEMINI_PCI_IOSIZE 0x00 /* I/O Space Size */ /* rw */
169 1.1 matt #define GEMINI_PCI_PROT 0x04 /* AHB Protection */ /* rw */
170 1.1 matt #define GEMINI_PCI_PCICTRL 0x08 /* PCI Control Signal */ /* rw */
171 1.1 matt #define GEMINI_PCI_ERREN 0x0c /* Soft Reset Counter and
172 1.1 matt * Response Error Enable */ /* rw */
173 1.1 matt #define GEMINI_PCI_SOFTRST 0x10 /* Soft Reset */
174 1.1 matt #define GEMINI_PCI_CFG_CMD 0x28 /* PCI Configuration Command */ /* rw */
175 1.1 matt #define PCI_CFG_CMD_ENB __BIT(31) /* Enable */
176 1.1 matt #define PCI_CFG_CMD_RESa __BITS(30,24)
177 1.1 matt #define PCI_CFG_CMD_BUSNO __BITS(23,16) /* Bus Number */
178 1.1 matt #define PCI_CFG_CMD_BUSn(n) (((n) << 16) & PCI_CFG_CMD_BUSNO)
179 1.1 matt #define PCI_CFG_CMD_DEVNO __BITS(15,11) /* Device Number */
180 1.1 matt #define PCI_CFG_CMD_DEVn(n) (((n) << 11) & PCI_CFG_CMD_DEVNO)
181 1.1 matt #define PCI_CFG_CMD_FUNCNO __BITS(10,8) /* Function Number */
182 1.1 matt #define PCI_CFG_CMD_FUNCn(n) (((n) << 8) & PCI_CFG_CMD_FUNCNO)
183 1.1 matt #define PCI_CFG_CMD_REGNO __BITS(7,2) /* Register Number */
184 1.1 matt #define PCI_CFG_CMD_REGn(n) (((n) << 0) & PCI_CFG_CMD_REGNO)
185 1.1 matt #define PCI_CFG_CMD_RESb __BITS(1,0)
186 1.1 matt #define PCI_CFG_CMD_RESV \
187 1.1 matt (PCI_CFG_CMD_RESa | PCI_CFG_CMD_RESb)
188 1.1 matt #define GEMINI_PCI_CFG_DATA 0x2c /* PCI Configuration Data */ /* rw */
189 1.1 matt
190 1.1 matt /*
191 1.1 matt * Gemini machine dependent PCI config registers
192 1.1 matt */
193 1.1 matt #define GEMINI_PCI_CFG_REG_PMR1 0x40 /* Power Management 1 */ /* rw */
194 1.1 matt #define GEMINI_PCI_CFG_REG_PMR2 0x44 /* Power Management 2 */ /* rw */
195 1.1 matt #define GEMINI_PCI_CFG_REG_CTL1 0x48 /* Control 1 */ /* rw */
196 1.1 matt #define GEMINI_PCI_CFG_REG_CTL2 0x4c /* Control 2 */ /* rw */
197 1.1 matt #define PCI_CFG_REG_CTL2_INTSTS __BITS(31,28)
198 1.1 matt #define CFG_REG_CTL2_INTSTS_INTD __BIT(28 + 3)
199 1.1 matt #define CFG_REG_CTL2_INTSTS_INTC __BIT(28 + 2)
200 1.1 matt #define CFG_REG_CTL2_INTSTS_INTB __BIT(28 + 1)
201 1.1 matt #define CFG_REG_CTL2_INTSTS_INTA __BIT(28 + 0)
202 1.1 matt #define PCI_CFG_REG_CTL2_INTMASK __BITS(27,16)
203 1.1 matt #define CFG_REG_CTL2_INTMASK_CMDERR __BIT(16 + 11)
204 1.1 matt #define CFG_REG_CTL2_INTMASK_PARERR __BIT(16 + 10)
205 1.1 matt #define CFG_REG_CTL2_INTMASK_INTD __BIT(16 + 9)
206 1.1 matt #define CFG_REG_CTL2_INTMASK_INTC __BIT(16 + 8)
207 1.1 matt #define CFG_REG_CTL2_INTMASK_INTB __BIT(16 + 7)
208 1.1 matt #define CFG_REG_CTL2_INTMASK_INTA __BIT(16 + 6)
209 1.1 matt #define CFG_REG_CTL2_INTMASK_INT_ABCD __BITS(16+9,16+6)
210 1.1 matt #define CFG_REG_CTL2_INTMASK_MABRT_RX __BIT(16 + 5)
211 1.1 matt #define CFG_REG_CTL2_INTMASK_TABRT_RX __BIT(16 + 4)
212 1.1 matt #define CFG_REG_CTL2_INTMASK_TABRT_TX __BIT(16 + 3)
213 1.1 matt #define CFG_REG_CTL2_INTMASK_RETRY4 __BIT(16 + 2)
214 1.1 matt #define CFG_REG_CTL2_INTMASK_SERR_RX __BIT(16 + 1)
215 1.1 matt #define CFG_REG_CTL2_INTMASK_PERR_RX __BIT(16 + 0)
216 1.1 matt #define PCI_CFG_REG_CTL2_RESa __BIT(15)
217 1.1 matt #define PCI_CFG_REG_CTL2_MSTPRI __BITS(14,8)
218 1.1 matt #define CFG_REG_CTL2_MSTPRI_REQn(n) __BIT(8 + (n))
219 1.1 matt #define PCI_CFG_REG_CTL2_RESb __BITS(7,4)
220 1.1 matt #define PCI_CFG_REG_CTL2_TRDYW __BITS(3,0)
221 1.1 matt #define PCI_CFG_REG_CTL2_RESV \
222 1.1 matt (PCI_CFG_REG_CTL2_RESa | PCI_CFG_REG_CTL2_RESb)
223 1.1 matt #define GEMINI_PCI_CFG_REG_MEM1 0x50 /* Memory 1 Base */ /* rw */
224 1.1 matt #define GEMINI_PCI_CFG_REG_MEM2 0x54 /* Memory 2 Base */ /* rw */
225 1.1 matt #define GEMINI_PCI_CFG_REG_MEM3 0x58 /* Memory 3 Base */ /* rw */
226 1.1 matt #define PCI_CFG_REG_MEM_BASE_MASK __BITS(31,20)
227 1.1 matt #define PCI_CFG_REG_MEM_BASE(base) ((base) & PCI_CFG_REG_MEM_BASE_MASK)
228 1.1 matt #define PCI_CFG_REG_MEM_SIZE_MASK __BITS(19,16)
229 1.1 matt #define PCI_CFG_REG_MEM_SIZE_1MB (0x0 << 16)
230 1.1 matt #define PCI_CFG_REG_MEM_SIZE_2MB (0x1 << 16)
231 1.1 matt #define PCI_CFG_REG_MEM_SIZE_4MB (0x2 << 16)
232 1.1 matt #define PCI_CFG_REG_MEM_SIZE_8MB (0x3 << 16)
233 1.1 matt #define PCI_CFG_REG_MEM_SIZE_16MB (0x4 << 16)
234 1.1 matt #define PCI_CFG_REG_MEM_SIZE_32MB (0x5 << 16)
235 1.1 matt #define PCI_CFG_REG_MEM_SIZE_64MB (0x6 << 16)
236 1.1 matt #define PCI_CFG_REG_MEM_SIZE_128MB (0x7 << 16)
237 1.1 matt #define PCI_CFG_REG_MEM_SIZE_256MB (0x8 << 16)
238 1.1 matt #define PCI_CFG_REG_MEM_SIZE_512MB (0x9 << 16)
239 1.1 matt #define PCI_CFG_REG_MEM_SIZE_1GB (0xa << 16)
240 1.1 matt #define PCI_CFG_REG_MEM_SIZE_2GB (0xb << 16)
241 1.1 matt #define PCI_CFG_REG_MEM_RESV __BITS(19,16)
242 1.1 matt
243 1.1 matt #ifndef _LOCORE
244 1.1 matt static inline unsigned int
245 1.1 matt gemini_pci_cfg_reg_mem_size(size_t sz)
246 1.1 matt {
247 1.1 matt switch (sz) {
248 1.1 matt case (1 << 20):
249 1.1 matt return PCI_CFG_REG_MEM_SIZE_1MB;
250 1.1 matt case (2 << 20):
251 1.1 matt return PCI_CFG_REG_MEM_SIZE_2MB;
252 1.1 matt case (4 << 20):
253 1.1 matt return PCI_CFG_REG_MEM_SIZE_4MB;
254 1.1 matt case (8 << 20):
255 1.1 matt return PCI_CFG_REG_MEM_SIZE_8MB;
256 1.1 matt case (16 << 20):
257 1.1 matt return PCI_CFG_REG_MEM_SIZE_16MB;
258 1.1 matt case (32 << 20):
259 1.1 matt return PCI_CFG_REG_MEM_SIZE_32MB;
260 1.1 matt case (64 << 20):
261 1.1 matt return PCI_CFG_REG_MEM_SIZE_64MB;
262 1.1 matt case (128 << 20):
263 1.1 matt return PCI_CFG_REG_MEM_SIZE_128MB;
264 1.1 matt case (256 << 20):
265 1.1 matt return PCI_CFG_REG_MEM_SIZE_256MB;
266 1.1 matt case (512 << 20):
267 1.1 matt return PCI_CFG_REG_MEM_SIZE_512MB;
268 1.1 matt case (1024 << 20):
269 1.1 matt return PCI_CFG_REG_MEM_SIZE_1GB;
270 1.1 matt case (2048 << 20):
271 1.1 matt return PCI_CFG_REG_MEM_SIZE_2GB;
272 1.1 matt default:
273 1.1 matt panic("gemini_pci_cfg_reg_mem_size: bad size %#lx\n", sz);
274 1.1 matt }
275 1.1 matt /* NOTREACHED */
276 1.1 matt }
277 1.1 matt #endif /* _LOCORE */
278 1.1 matt
279 1.1 matt #else
280 1.1 matt # error unknown gemini cpu type
281 1.1 matt #endif
282 1.1 matt
283 1.1 matt #endif /* _ARM_GEMINI_REG_H_ */
284