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