1 /*
2  *
3  * BRIEF MODULE DESCRIPTION
4  *	Include file for Alchemy Semiconductor's Au1k CPU.
5  *
6  * Copyright 2000-2001, 2006-2008 MontaVista Software Inc.
7  * Author: MontaVista Software, Inc. <source@mvista.com>
8  *
9  *  This program is free software; you can redistribute  it and/or modify it
10  *  under  the terms of  the GNU General  Public License as published by the
11  *  Free Software Foundation;  either version 2 of the  License, or (at your
12  *  option) any later version.
13  *
14  *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
15  *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
16  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
17  *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
18  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
20  *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21  *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
22  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *  You should have received a copy of the  GNU General Public License along
26  *  with this program; if not, write  to the Free Software Foundation, Inc.,
27  *  675 Mass Ave, Cambridge, MA 02139, USA.
28  */
29 
30  /*
31   * some definitions add by takuzo@sm.sony.co.jp and sato@sm.sony.co.jp
32   */
33 
34 #ifndef _AU1000_H_
35 #define _AU1000_H_
36 
37 
38 #ifndef _LANGUAGE_ASSEMBLY
39 
40 #include <linux/delay.h>
41 #include <linux/types.h>
42 
43 #include <linux/io.h>
44 #include <linux/irq.h>
45 
46 #include <asm/cpu.h>
47 
48 /* cpu pipeline flush */
49 void static inline au_sync(void)
50 {
51 	__asm__ volatile ("sync");
52 }
53 
54 void static inline au_sync_udelay(int us)
55 {
56 	__asm__ volatile ("sync");
57 	udelay(us);
58 }
59 
60 void static inline au_sync_delay(int ms)
61 {
62 	__asm__ volatile ("sync");
63 	mdelay(ms);
64 }
65 
66 void static inline au_writeb(u8 val, unsigned long reg)
67 {
68 	*(volatile u8 *)reg = val;
69 }
70 
71 void static inline au_writew(u16 val, unsigned long reg)
72 {
73 	*(volatile u16 *)reg = val;
74 }
75 
76 void static inline au_writel(u32 val, unsigned long reg)
77 {
78 	*(volatile u32 *)reg = val;
79 }
80 
81 static inline u8 au_readb(unsigned long reg)
82 {
83 	return *(volatile u8 *)reg;
84 }
85 
86 static inline u16 au_readw(unsigned long reg)
87 {
88 	return *(volatile u16 *)reg;
89 }
90 
91 static inline u32 au_readl(unsigned long reg)
92 {
93 	return *(volatile u32 *)reg;
94 }
95 
96 /* Early Au1000 have a write-only SYS_CPUPLL register. */
97 static inline int au1xxx_cpu_has_pll_wo(void)
98 {
99 	switch (read_c0_prid()) {
100 	case 0x00030100:	/* Au1000 DA */
101 	case 0x00030201:	/* Au1000 HA */
102 	case 0x00030202:	/* Au1000 HB */
103 		return 1;
104 	}
105 	return 0;
106 }
107 
108 /* does CPU need CONFIG[OD] set to fix tons of errata? */
109 static inline int au1xxx_cpu_needs_config_od(void)
110 {
111 	/*
112 	 * c0_config.od (bit 19) was write only (and read as 0) on the
113 	 * early revisions of Alchemy SOCs.  It disables the bus trans-
114 	 * action overlapping and needs to be set to fix various errata.
115 	 */
116 	switch (read_c0_prid()) {
117 	case 0x00030100: /* Au1000 DA */
118 	case 0x00030201: /* Au1000 HA */
119 	case 0x00030202: /* Au1000 HB */
120 	case 0x01030200: /* Au1500 AB */
121 	/*
122 	 * Au1100/Au1200 errata actually keep silence about this bit,
123 	 * so we set it just in case for those revisions that require
124 	 * it to be set according to the (now gone) cpu_table.
125 	 */
126 	case 0x02030200: /* Au1100 AB */
127 	case 0x02030201: /* Au1100 BA */
128 	case 0x02030202: /* Au1100 BC */
129 	case 0x04030201: /* Au1200 AC */
130 		return 1;
131 	}
132 	return 0;
133 }
134 
135 #define ALCHEMY_CPU_UNKNOWN	-1
136 #define ALCHEMY_CPU_AU1000	0
137 #define ALCHEMY_CPU_AU1500	1
138 #define ALCHEMY_CPU_AU1100	2
139 #define ALCHEMY_CPU_AU1550	3
140 #define ALCHEMY_CPU_AU1200	4
141 #define ALCHEMY_CPU_AU1300	5
142 
143 static inline int alchemy_get_cputype(void)
144 {
145 	switch (read_c0_prid() & (PRID_OPT_MASK | PRID_COMP_MASK)) {
146 	case 0x00030000:
147 		return ALCHEMY_CPU_AU1000;
148 		break;
149 	case 0x01030000:
150 		return ALCHEMY_CPU_AU1500;
151 		break;
152 	case 0x02030000:
153 		return ALCHEMY_CPU_AU1100;
154 		break;
155 	case 0x03030000:
156 		return ALCHEMY_CPU_AU1550;
157 		break;
158 	case 0x04030000:
159 	case 0x05030000:
160 		return ALCHEMY_CPU_AU1200;
161 		break;
162 	case 0x800c0000:
163 		return ALCHEMY_CPU_AU1300;
164 		break;
165 	}
166 
167 	return ALCHEMY_CPU_UNKNOWN;
168 }
169 
170 /* return number of uarts on a given cputype */
171 static inline int alchemy_get_uarts(int type)
172 {
173 	switch (type) {
174 	case ALCHEMY_CPU_AU1000:
175 	case ALCHEMY_CPU_AU1300:
176 		return 4;
177 	case ALCHEMY_CPU_AU1500:
178 	case ALCHEMY_CPU_AU1200:
179 		return 2;
180 	case ALCHEMY_CPU_AU1100:
181 	case ALCHEMY_CPU_AU1550:
182 		return 3;
183 	}
184 	return 0;
185 }
186 
187 /* enable an UART block if it isn't already */
188 static inline void alchemy_uart_enable(u32 uart_phys)
189 {
190 	void __iomem *addr = (void __iomem *)KSEG1ADDR(uart_phys);
191 
192 	/* reset, enable clock, deassert reset */
193 	if ((__raw_readl(addr + 0x100) & 3) != 3) {
194 		__raw_writel(0, addr + 0x100);
195 		wmb();
196 		__raw_writel(1, addr + 0x100);
197 		wmb();
198 	}
199 	__raw_writel(3, addr + 0x100);
200 	wmb();
201 }
202 
203 static inline void alchemy_uart_disable(u32 uart_phys)
204 {
205 	void __iomem *addr = (void __iomem *)KSEG1ADDR(uart_phys);
206 	__raw_writel(0, addr + 0x100);	/* UART_MOD_CNTRL */
207 	wmb();
208 }
209 
210 static inline void alchemy_uart_putchar(u32 uart_phys, u8 c)
211 {
212 	void __iomem *base = (void __iomem *)KSEG1ADDR(uart_phys);
213 	int timeout, i;
214 
215 	/* check LSR TX_EMPTY bit */
216 	timeout = 0xffffff;
217 	do {
218 		if (__raw_readl(base + 0x1c) & 0x20)
219 			break;
220 		/* slow down */
221 		for (i = 10000; i; i--)
222 			asm volatile ("nop");
223 	} while (--timeout);
224 
225 	__raw_writel(c, base + 0x04);	/* tx */
226 	wmb();
227 }
228 
229 /* return number of ethernet MACs on a given cputype */
230 static inline int alchemy_get_macs(int type)
231 {
232 	switch (type) {
233 	case ALCHEMY_CPU_AU1000:
234 	case ALCHEMY_CPU_AU1500:
235 	case ALCHEMY_CPU_AU1550:
236 		return 2;
237 	case ALCHEMY_CPU_AU1100:
238 		return 1;
239 	}
240 	return 0;
241 }
242 
243 /* arch/mips/au1000/common/clocks.c */
244 extern void set_au1x00_speed(unsigned int new_freq);
245 extern unsigned int get_au1x00_speed(void);
246 extern void set_au1x00_uart_baud_base(unsigned long new_baud_base);
247 extern unsigned long get_au1x00_uart_baud_base(void);
248 extern unsigned long au1xxx_calc_clock(void);
249 
250 /* PM: arch/mips/alchemy/common/sleeper.S, power.c, irq.c */
251 void alchemy_sleep_au1000(void);
252 void alchemy_sleep_au1550(void);
253 void alchemy_sleep_au1300(void);
254 void au_sleep(void);
255 
256 /* USB: drivers/usb/host/alchemy-common.c */
257 enum alchemy_usb_block {
258 	ALCHEMY_USB_OHCI0,
259 	ALCHEMY_USB_UDC0,
260 	ALCHEMY_USB_EHCI0,
261 	ALCHEMY_USB_OTG0,
262 	ALCHEMY_USB_OHCI1,
263 };
264 int alchemy_usb_control(int block, int enable);
265 
266 /* PCI controller platform data */
267 struct alchemy_pci_platdata {
268 	int (*board_map_irq)(const struct pci_dev *d, u8 slot, u8 pin);
269 	int (*board_pci_idsel)(unsigned int devsel, int assert);
270 	/* bits to set/clear in PCI_CONFIG register */
271 	unsigned long pci_cfg_set;
272 	unsigned long pci_cfg_clr;
273 };
274 
275 /* Multifunction pins: Each of these pins can either be assigned to the
276  * GPIO controller or a on-chip peripheral.
277  * Call "au1300_pinfunc_to_dev()" or "au1300_pinfunc_to_gpio()" to
278  * assign one of these to either the GPIO controller or the device.
279  */
280 enum au1300_multifunc_pins {
281 	/* wake-from-str pins 0-3 */
282 	AU1300_PIN_WAKE0 = 0, AU1300_PIN_WAKE1, AU1300_PIN_WAKE2,
283 	AU1300_PIN_WAKE3,
284 	/* external clock sources for PSCs: 4-5 */
285 	AU1300_PIN_EXTCLK0, AU1300_PIN_EXTCLK1,
286 	/* 8bit MMC interface on SD0: 6-9 */
287 	AU1300_PIN_SD0DAT4, AU1300_PIN_SD0DAT5, AU1300_PIN_SD0DAT6,
288 	AU1300_PIN_SD0DAT7,
289 	/* aux clk input for freqgen 3: 10 */
290 	AU1300_PIN_FG3AUX,
291 	/* UART1 pins: 11-18 */
292 	AU1300_PIN_U1RI, AU1300_PIN_U1DCD, AU1300_PIN_U1DSR,
293 	AU1300_PIN_U1CTS, AU1300_PIN_U1RTS, AU1300_PIN_U1DTR,
294 	AU1300_PIN_U1RX, AU1300_PIN_U1TX,
295 	/* UART0 pins: 19-24 */
296 	AU1300_PIN_U0RI, AU1300_PIN_U0DCD, AU1300_PIN_U0DSR,
297 	AU1300_PIN_U0CTS, AU1300_PIN_U0RTS, AU1300_PIN_U0DTR,
298 	/* UART2: 25-26 */
299 	AU1300_PIN_U2RX, AU1300_PIN_U2TX,
300 	/* UART3: 27-28 */
301 	AU1300_PIN_U3RX, AU1300_PIN_U3TX,
302 	/* LCD controller PWMs, ext pixclock: 29-31 */
303 	AU1300_PIN_LCDPWM0, AU1300_PIN_LCDPWM1, AU1300_PIN_LCDCLKIN,
304 	/* SD1 interface: 32-37 */
305 	AU1300_PIN_SD1DAT0, AU1300_PIN_SD1DAT1, AU1300_PIN_SD1DAT2,
306 	AU1300_PIN_SD1DAT3, AU1300_PIN_SD1CMD, AU1300_PIN_SD1CLK,
307 	/* SD2 interface: 38-43 */
308 	AU1300_PIN_SD2DAT0, AU1300_PIN_SD2DAT1, AU1300_PIN_SD2DAT2,
309 	AU1300_PIN_SD2DAT3, AU1300_PIN_SD2CMD, AU1300_PIN_SD2CLK,
310 	/* PSC0/1 clocks: 44-45 */
311 	AU1300_PIN_PSC0CLK, AU1300_PIN_PSC1CLK,
312 	/* PSCs: 46-49/50-53/54-57/58-61 */
313 	AU1300_PIN_PSC0SYNC0, AU1300_PIN_PSC0SYNC1, AU1300_PIN_PSC0D0,
314 	AU1300_PIN_PSC0D1,
315 	AU1300_PIN_PSC1SYNC0, AU1300_PIN_PSC1SYNC1, AU1300_PIN_PSC1D0,
316 	AU1300_PIN_PSC1D1,
317 	AU1300_PIN_PSC2SYNC0, AU1300_PIN_PSC2SYNC1, AU1300_PIN_PSC2D0,
318 	AU1300_PIN_PSC2D1,
319 	AU1300_PIN_PSC3SYNC0, AU1300_PIN_PSC3SYNC1, AU1300_PIN_PSC3D0,
320 	AU1300_PIN_PSC3D1,
321 	/* PCMCIA interface: 62-70 */
322 	AU1300_PIN_PCE2, AU1300_PIN_PCE1, AU1300_PIN_PIOS16,
323 	AU1300_PIN_PIOR, AU1300_PIN_PWE, AU1300_PIN_PWAIT,
324 	AU1300_PIN_PREG, AU1300_PIN_POE, AU1300_PIN_PIOW,
325 	/* camera interface H/V sync inputs: 71-72 */
326 	AU1300_PIN_CIMLS, AU1300_PIN_CIMFS,
327 	/* PSC2/3 clocks: 73-74 */
328 	AU1300_PIN_PSC2CLK, AU1300_PIN_PSC3CLK,
329 };
330 
331 /* GPIC (Au1300) pin management: arch/mips/alchemy/common/gpioint.c */
332 extern void au1300_pinfunc_to_gpio(enum au1300_multifunc_pins gpio);
333 extern void au1300_pinfunc_to_dev(enum au1300_multifunc_pins gpio);
334 extern void au1300_set_irq_priority(unsigned int irq, int p);
335 extern void au1300_set_dbdma_gpio(int dchan, unsigned int gpio);
336 
337 /* Au1300 allows to disconnect certain blocks from internal power supply */
338 enum au1300_vss_block {
339 	AU1300_VSS_MPE = 0,
340 	AU1300_VSS_BSA,
341 	AU1300_VSS_GPE,
342 	AU1300_VSS_MGP,
343 };
344 
345 extern void au1300_vss_block_control(int block, int enable);
346 
347 
348 /* SOC Interrupt numbers */
349 /* Au1000-style (IC0/1): 2 controllers with 32 sources each */
350 #define AU1000_INTC0_INT_BASE	(MIPS_CPU_IRQ_BASE + 8)
351 #define AU1000_INTC0_INT_LAST	(AU1000_INTC0_INT_BASE + 31)
352 #define AU1000_INTC1_INT_BASE	(AU1000_INTC0_INT_LAST + 1)
353 #define AU1000_INTC1_INT_LAST	(AU1000_INTC1_INT_BASE + 31)
354 #define AU1000_MAX_INTR		AU1000_INTC1_INT_LAST
355 
356 /* Au1300-style (GPIC): 1 controller with up to 128 sources */
357 #define ALCHEMY_GPIC_INT_BASE	(MIPS_CPU_IRQ_BASE + 8)
358 #define ALCHEMY_GPIC_INT_NUM	128
359 #define ALCHEMY_GPIC_INT_LAST	(ALCHEMY_GPIC_INT_BASE + ALCHEMY_GPIC_INT_NUM - 1)
360 
361 enum soc_au1000_ints {
362 	AU1000_FIRST_INT	= AU1000_INTC0_INT_BASE,
363 	AU1000_UART0_INT	= AU1000_FIRST_INT,
364 	AU1000_UART1_INT,
365 	AU1000_UART2_INT,
366 	AU1000_UART3_INT,
367 	AU1000_SSI0_INT,
368 	AU1000_SSI1_INT,
369 	AU1000_DMA_INT_BASE,
370 
371 	AU1000_TOY_INT		= AU1000_FIRST_INT + 14,
372 	AU1000_TOY_MATCH0_INT,
373 	AU1000_TOY_MATCH1_INT,
374 	AU1000_TOY_MATCH2_INT,
375 	AU1000_RTC_INT,
376 	AU1000_RTC_MATCH0_INT,
377 	AU1000_RTC_MATCH1_INT,
378 	AU1000_RTC_MATCH2_INT,
379 	AU1000_IRDA_TX_INT,
380 	AU1000_IRDA_RX_INT,
381 	AU1000_USB_DEV_REQ_INT,
382 	AU1000_USB_DEV_SUS_INT,
383 	AU1000_USB_HOST_INT,
384 	AU1000_ACSYNC_INT,
385 	AU1000_MAC0_DMA_INT,
386 	AU1000_MAC1_DMA_INT,
387 	AU1000_I2S_UO_INT,
388 	AU1000_AC97C_INT,
389 	AU1000_GPIO0_INT,
390 	AU1000_GPIO1_INT,
391 	AU1000_GPIO2_INT,
392 	AU1000_GPIO3_INT,
393 	AU1000_GPIO4_INT,
394 	AU1000_GPIO5_INT,
395 	AU1000_GPIO6_INT,
396 	AU1000_GPIO7_INT,
397 	AU1000_GPIO8_INT,
398 	AU1000_GPIO9_INT,
399 	AU1000_GPIO10_INT,
400 	AU1000_GPIO11_INT,
401 	AU1000_GPIO12_INT,
402 	AU1000_GPIO13_INT,
403 	AU1000_GPIO14_INT,
404 	AU1000_GPIO15_INT,
405 	AU1000_GPIO16_INT,
406 	AU1000_GPIO17_INT,
407 	AU1000_GPIO18_INT,
408 	AU1000_GPIO19_INT,
409 	AU1000_GPIO20_INT,
410 	AU1000_GPIO21_INT,
411 	AU1000_GPIO22_INT,
412 	AU1000_GPIO23_INT,
413 	AU1000_GPIO24_INT,
414 	AU1000_GPIO25_INT,
415 	AU1000_GPIO26_INT,
416 	AU1000_GPIO27_INT,
417 	AU1000_GPIO28_INT,
418 	AU1000_GPIO29_INT,
419 	AU1000_GPIO30_INT,
420 	AU1000_GPIO31_INT,
421 };
422 
423 enum soc_au1100_ints {
424 	AU1100_FIRST_INT	= AU1000_INTC0_INT_BASE,
425 	AU1100_UART0_INT	= AU1100_FIRST_INT,
426 	AU1100_UART1_INT,
427 	AU1100_SD_INT,
428 	AU1100_UART3_INT,
429 	AU1100_SSI0_INT,
430 	AU1100_SSI1_INT,
431 	AU1100_DMA_INT_BASE,
432 
433 	AU1100_TOY_INT		= AU1100_FIRST_INT + 14,
434 	AU1100_TOY_MATCH0_INT,
435 	AU1100_TOY_MATCH1_INT,
436 	AU1100_TOY_MATCH2_INT,
437 	AU1100_RTC_INT,
438 	AU1100_RTC_MATCH0_INT,
439 	AU1100_RTC_MATCH1_INT,
440 	AU1100_RTC_MATCH2_INT,
441 	AU1100_IRDA_TX_INT,
442 	AU1100_IRDA_RX_INT,
443 	AU1100_USB_DEV_REQ_INT,
444 	AU1100_USB_DEV_SUS_INT,
445 	AU1100_USB_HOST_INT,
446 	AU1100_ACSYNC_INT,
447 	AU1100_MAC0_DMA_INT,
448 	AU1100_GPIO208_215_INT,
449 	AU1100_LCD_INT,
450 	AU1100_AC97C_INT,
451 	AU1100_GPIO0_INT,
452 	AU1100_GPIO1_INT,
453 	AU1100_GPIO2_INT,
454 	AU1100_GPIO3_INT,
455 	AU1100_GPIO4_INT,
456 	AU1100_GPIO5_INT,
457 	AU1100_GPIO6_INT,
458 	AU1100_GPIO7_INT,
459 	AU1100_GPIO8_INT,
460 	AU1100_GPIO9_INT,
461 	AU1100_GPIO10_INT,
462 	AU1100_GPIO11_INT,
463 	AU1100_GPIO12_INT,
464 	AU1100_GPIO13_INT,
465 	AU1100_GPIO14_INT,
466 	AU1100_GPIO15_INT,
467 	AU1100_GPIO16_INT,
468 	AU1100_GPIO17_INT,
469 	AU1100_GPIO18_INT,
470 	AU1100_GPIO19_INT,
471 	AU1100_GPIO20_INT,
472 	AU1100_GPIO21_INT,
473 	AU1100_GPIO22_INT,
474 	AU1100_GPIO23_INT,
475 	AU1100_GPIO24_INT,
476 	AU1100_GPIO25_INT,
477 	AU1100_GPIO26_INT,
478 	AU1100_GPIO27_INT,
479 	AU1100_GPIO28_INT,
480 	AU1100_GPIO29_INT,
481 	AU1100_GPIO30_INT,
482 	AU1100_GPIO31_INT,
483 };
484 
485 enum soc_au1500_ints {
486 	AU1500_FIRST_INT	= AU1000_INTC0_INT_BASE,
487 	AU1500_UART0_INT	= AU1500_FIRST_INT,
488 	AU1500_PCI_INTA,
489 	AU1500_PCI_INTB,
490 	AU1500_UART3_INT,
491 	AU1500_PCI_INTC,
492 	AU1500_PCI_INTD,
493 	AU1500_DMA_INT_BASE,
494 
495 	AU1500_TOY_INT		= AU1500_FIRST_INT + 14,
496 	AU1500_TOY_MATCH0_INT,
497 	AU1500_TOY_MATCH1_INT,
498 	AU1500_TOY_MATCH2_INT,
499 	AU1500_RTC_INT,
500 	AU1500_RTC_MATCH0_INT,
501 	AU1500_RTC_MATCH1_INT,
502 	AU1500_RTC_MATCH2_INT,
503 	AU1500_PCI_ERR_INT,
504 	AU1500_RESERVED_INT,
505 	AU1500_USB_DEV_REQ_INT,
506 	AU1500_USB_DEV_SUS_INT,
507 	AU1500_USB_HOST_INT,
508 	AU1500_ACSYNC_INT,
509 	AU1500_MAC0_DMA_INT,
510 	AU1500_MAC1_DMA_INT,
511 	AU1500_AC97C_INT	= AU1500_FIRST_INT + 31,
512 	AU1500_GPIO0_INT,
513 	AU1500_GPIO1_INT,
514 	AU1500_GPIO2_INT,
515 	AU1500_GPIO3_INT,
516 	AU1500_GPIO4_INT,
517 	AU1500_GPIO5_INT,
518 	AU1500_GPIO6_INT,
519 	AU1500_GPIO7_INT,
520 	AU1500_GPIO8_INT,
521 	AU1500_GPIO9_INT,
522 	AU1500_GPIO10_INT,
523 	AU1500_GPIO11_INT,
524 	AU1500_GPIO12_INT,
525 	AU1500_GPIO13_INT,
526 	AU1500_GPIO14_INT,
527 	AU1500_GPIO15_INT,
528 	AU1500_GPIO200_INT,
529 	AU1500_GPIO201_INT,
530 	AU1500_GPIO202_INT,
531 	AU1500_GPIO203_INT,
532 	AU1500_GPIO20_INT,
533 	AU1500_GPIO204_INT,
534 	AU1500_GPIO205_INT,
535 	AU1500_GPIO23_INT,
536 	AU1500_GPIO24_INT,
537 	AU1500_GPIO25_INT,
538 	AU1500_GPIO26_INT,
539 	AU1500_GPIO27_INT,
540 	AU1500_GPIO28_INT,
541 	AU1500_GPIO206_INT,
542 	AU1500_GPIO207_INT,
543 	AU1500_GPIO208_215_INT,
544 };
545 
546 enum soc_au1550_ints {
547 	AU1550_FIRST_INT	= AU1000_INTC0_INT_BASE,
548 	AU1550_UART0_INT	= AU1550_FIRST_INT,
549 	AU1550_PCI_INTA,
550 	AU1550_PCI_INTB,
551 	AU1550_DDMA_INT,
552 	AU1550_CRYPTO_INT,
553 	AU1550_PCI_INTC,
554 	AU1550_PCI_INTD,
555 	AU1550_PCI_RST_INT,
556 	AU1550_UART1_INT,
557 	AU1550_UART3_INT,
558 	AU1550_PSC0_INT,
559 	AU1550_PSC1_INT,
560 	AU1550_PSC2_INT,
561 	AU1550_PSC3_INT,
562 	AU1550_TOY_INT,
563 	AU1550_TOY_MATCH0_INT,
564 	AU1550_TOY_MATCH1_INT,
565 	AU1550_TOY_MATCH2_INT,
566 	AU1550_RTC_INT,
567 	AU1550_RTC_MATCH0_INT,
568 	AU1550_RTC_MATCH1_INT,
569 	AU1550_RTC_MATCH2_INT,
570 
571 	AU1550_NAND_INT		= AU1550_FIRST_INT + 23,
572 	AU1550_USB_DEV_REQ_INT,
573 	AU1550_USB_DEV_SUS_INT,
574 	AU1550_USB_HOST_INT,
575 	AU1550_MAC0_DMA_INT,
576 	AU1550_MAC1_DMA_INT,
577 	AU1550_GPIO0_INT	= AU1550_FIRST_INT + 32,
578 	AU1550_GPIO1_INT,
579 	AU1550_GPIO2_INT,
580 	AU1550_GPIO3_INT,
581 	AU1550_GPIO4_INT,
582 	AU1550_GPIO5_INT,
583 	AU1550_GPIO6_INT,
584 	AU1550_GPIO7_INT,
585 	AU1550_GPIO8_INT,
586 	AU1550_GPIO9_INT,
587 	AU1550_GPIO10_INT,
588 	AU1550_GPIO11_INT,
589 	AU1550_GPIO12_INT,
590 	AU1550_GPIO13_INT,
591 	AU1550_GPIO14_INT,
592 	AU1550_GPIO15_INT,
593 	AU1550_GPIO200_INT,
594 	AU1550_GPIO201_205_INT, /* Logical or of GPIO201:205 */
595 	AU1550_GPIO16_INT,
596 	AU1550_GPIO17_INT,
597 	AU1550_GPIO20_INT,
598 	AU1550_GPIO21_INT,
599 	AU1550_GPIO22_INT,
600 	AU1550_GPIO23_INT,
601 	AU1550_GPIO24_INT,
602 	AU1550_GPIO25_INT,
603 	AU1550_GPIO26_INT,
604 	AU1550_GPIO27_INT,
605 	AU1550_GPIO28_INT,
606 	AU1550_GPIO206_INT,
607 	AU1550_GPIO207_INT,
608 	AU1550_GPIO208_215_INT, /* Logical or of GPIO208:215 */
609 };
610 
611 enum soc_au1200_ints {
612 	AU1200_FIRST_INT	= AU1000_INTC0_INT_BASE,
613 	AU1200_UART0_INT	= AU1200_FIRST_INT,
614 	AU1200_SWT_INT,
615 	AU1200_SD_INT,
616 	AU1200_DDMA_INT,
617 	AU1200_MAE_BE_INT,
618 	AU1200_GPIO200_INT,
619 	AU1200_GPIO201_INT,
620 	AU1200_GPIO202_INT,
621 	AU1200_UART1_INT,
622 	AU1200_MAE_FE_INT,
623 	AU1200_PSC0_INT,
624 	AU1200_PSC1_INT,
625 	AU1200_AES_INT,
626 	AU1200_CAMERA_INT,
627 	AU1200_TOY_INT,
628 	AU1200_TOY_MATCH0_INT,
629 	AU1200_TOY_MATCH1_INT,
630 	AU1200_TOY_MATCH2_INT,
631 	AU1200_RTC_INT,
632 	AU1200_RTC_MATCH0_INT,
633 	AU1200_RTC_MATCH1_INT,
634 	AU1200_RTC_MATCH2_INT,
635 	AU1200_GPIO203_INT,
636 	AU1200_NAND_INT,
637 	AU1200_GPIO204_INT,
638 	AU1200_GPIO205_INT,
639 	AU1200_GPIO206_INT,
640 	AU1200_GPIO207_INT,
641 	AU1200_GPIO208_215_INT, /* Logical OR of 208:215 */
642 	AU1200_USB_INT,
643 	AU1200_LCD_INT,
644 	AU1200_MAE_BOTH_INT,
645 	AU1200_GPIO0_INT,
646 	AU1200_GPIO1_INT,
647 	AU1200_GPIO2_INT,
648 	AU1200_GPIO3_INT,
649 	AU1200_GPIO4_INT,
650 	AU1200_GPIO5_INT,
651 	AU1200_GPIO6_INT,
652 	AU1200_GPIO7_INT,
653 	AU1200_GPIO8_INT,
654 	AU1200_GPIO9_INT,
655 	AU1200_GPIO10_INT,
656 	AU1200_GPIO11_INT,
657 	AU1200_GPIO12_INT,
658 	AU1200_GPIO13_INT,
659 	AU1200_GPIO14_INT,
660 	AU1200_GPIO15_INT,
661 	AU1200_GPIO16_INT,
662 	AU1200_GPIO17_INT,
663 	AU1200_GPIO18_INT,
664 	AU1200_GPIO19_INT,
665 	AU1200_GPIO20_INT,
666 	AU1200_GPIO21_INT,
667 	AU1200_GPIO22_INT,
668 	AU1200_GPIO23_INT,
669 	AU1200_GPIO24_INT,
670 	AU1200_GPIO25_INT,
671 	AU1200_GPIO26_INT,
672 	AU1200_GPIO27_INT,
673 	AU1200_GPIO28_INT,
674 	AU1200_GPIO29_INT,
675 	AU1200_GPIO30_INT,
676 	AU1200_GPIO31_INT,
677 };
678 
679 #endif /* !defined (_LANGUAGE_ASSEMBLY) */
680 
681 /* Au1300 peripheral interrupt numbers */
682 #define AU1300_FIRST_INT	(ALCHEMY_GPIC_INT_BASE)
683 #define AU1300_UART1_INT	(AU1300_FIRST_INT + 17)
684 #define AU1300_UART2_INT	(AU1300_FIRST_INT + 25)
685 #define AU1300_UART3_INT	(AU1300_FIRST_INT + 27)
686 #define AU1300_SD1_INT		(AU1300_FIRST_INT + 32)
687 #define AU1300_SD2_INT		(AU1300_FIRST_INT + 38)
688 #define AU1300_PSC0_INT		(AU1300_FIRST_INT + 48)
689 #define AU1300_PSC1_INT		(AU1300_FIRST_INT + 52)
690 #define AU1300_PSC2_INT		(AU1300_FIRST_INT + 56)
691 #define AU1300_PSC3_INT		(AU1300_FIRST_INT + 60)
692 #define AU1300_NAND_INT		(AU1300_FIRST_INT + 62)
693 #define AU1300_DDMA_INT		(AU1300_FIRST_INT + 75)
694 #define AU1300_MMU_INT		(AU1300_FIRST_INT + 76)
695 #define AU1300_MPU_INT		(AU1300_FIRST_INT + 77)
696 #define AU1300_GPU_INT		(AU1300_FIRST_INT + 78)
697 #define AU1300_UDMA_INT		(AU1300_FIRST_INT + 79)
698 #define AU1300_TOY_INT		(AU1300_FIRST_INT + 80)
699 #define AU1300_TOY_MATCH0_INT	(AU1300_FIRST_INT + 81)
700 #define AU1300_TOY_MATCH1_INT	(AU1300_FIRST_INT + 82)
701 #define AU1300_TOY_MATCH2_INT	(AU1300_FIRST_INT + 83)
702 #define AU1300_RTC_INT		(AU1300_FIRST_INT + 84)
703 #define AU1300_RTC_MATCH0_INT	(AU1300_FIRST_INT + 85)
704 #define AU1300_RTC_MATCH1_INT	(AU1300_FIRST_INT + 86)
705 #define AU1300_RTC_MATCH2_INT	(AU1300_FIRST_INT + 87)
706 #define AU1300_UART0_INT	(AU1300_FIRST_INT + 88)
707 #define AU1300_SD0_INT		(AU1300_FIRST_INT + 89)
708 #define AU1300_USB_INT		(AU1300_FIRST_INT + 90)
709 #define AU1300_LCD_INT		(AU1300_FIRST_INT + 91)
710 #define AU1300_BSA_INT		(AU1300_FIRST_INT + 92)
711 #define AU1300_MPE_INT		(AU1300_FIRST_INT + 93)
712 #define AU1300_ITE_INT		(AU1300_FIRST_INT + 94)
713 #define AU1300_AES_INT		(AU1300_FIRST_INT + 95)
714 #define AU1300_CIM_INT		(AU1300_FIRST_INT + 96)
715 
716 /**********************************************************************/
717 
718 /*
719  * Physical base addresses for integrated peripherals
720  * 0..au1000 1..au1500 2..au1100 3..au1550 4..au1200 5..au1300
721  */
722 
723 #define AU1000_AC97_PHYS_ADDR		0x10000000 /* 012 */
724 #define AU1300_ROM_PHYS_ADDR		0x10000000 /* 5 */
725 #define AU1300_OTP_PHYS_ADDR		0x10002000 /* 5 */
726 #define AU1300_VSS_PHYS_ADDR		0x10003000 /* 5 */
727 #define AU1300_UART0_PHYS_ADDR		0x10100000 /* 5 */
728 #define AU1300_UART1_PHYS_ADDR		0x10101000 /* 5 */
729 #define AU1300_UART2_PHYS_ADDR		0x10102000 /* 5 */
730 #define AU1300_UART3_PHYS_ADDR		0x10103000 /* 5 */
731 #define AU1000_USB_OHCI_PHYS_ADDR	0x10100000 /* 012 */
732 #define AU1000_USB_UDC_PHYS_ADDR	0x10200000 /* 0123 */
733 #define AU1300_GPIC_PHYS_ADDR		0x10200000 /* 5 */
734 #define AU1000_IRDA_PHYS_ADDR		0x10300000 /* 02 */
735 #define AU1200_AES_PHYS_ADDR		0x10300000 /* 45 */
736 #define AU1000_IC0_PHYS_ADDR		0x10400000 /* 01234 */
737 #define AU1300_GPU_PHYS_ADDR		0x10500000 /* 5 */
738 #define AU1000_MAC0_PHYS_ADDR		0x10500000 /* 023 */
739 #define AU1000_MAC1_PHYS_ADDR		0x10510000 /* 023 */
740 #define AU1000_MACEN_PHYS_ADDR		0x10520000 /* 023 */
741 #define AU1100_SD0_PHYS_ADDR		0x10600000 /* 245 */
742 #define AU1300_SD1_PHYS_ADDR		0x10601000 /* 5 */
743 #define AU1300_SD2_PHYS_ADDR		0x10602000 /* 5 */
744 #define AU1100_SD1_PHYS_ADDR		0x10680000 /* 24 */
745 #define AU1300_SYS_PHYS_ADDR		0x10900000 /* 5 */
746 #define AU1550_PSC2_PHYS_ADDR		0x10A00000 /* 3 */
747 #define AU1550_PSC3_PHYS_ADDR		0x10B00000 /* 3 */
748 #define AU1300_PSC0_PHYS_ADDR		0x10A00000 /* 5 */
749 #define AU1300_PSC1_PHYS_ADDR		0x10A01000 /* 5 */
750 #define AU1300_PSC2_PHYS_ADDR		0x10A02000 /* 5 */
751 #define AU1300_PSC3_PHYS_ADDR		0x10A03000 /* 5 */
752 #define AU1000_I2S_PHYS_ADDR		0x11000000 /* 02 */
753 #define AU1500_MAC0_PHYS_ADDR		0x11500000 /* 1 */
754 #define AU1500_MAC1_PHYS_ADDR		0x11510000 /* 1 */
755 #define AU1500_MACEN_PHYS_ADDR		0x11520000 /* 1 */
756 #define AU1000_UART0_PHYS_ADDR		0x11100000 /* 01234 */
757 #define AU1200_SWCNT_PHYS_ADDR		0x1110010C /* 4 */
758 #define AU1000_UART1_PHYS_ADDR		0x11200000 /* 0234 */
759 #define AU1000_UART2_PHYS_ADDR		0x11300000 /* 0 */
760 #define AU1000_UART3_PHYS_ADDR		0x11400000 /* 0123 */
761 #define AU1000_SSI0_PHYS_ADDR		0x11600000 /* 02 */
762 #define AU1000_SSI1_PHYS_ADDR		0x11680000 /* 02 */
763 #define AU1500_GPIO2_PHYS_ADDR		0x11700000 /* 1234 */
764 #define AU1000_IC1_PHYS_ADDR		0x11800000 /* 01234 */
765 #define AU1000_SYS_PHYS_ADDR		0x11900000 /* 012345 */
766 #define AU1550_PSC0_PHYS_ADDR		0x11A00000 /* 34 */
767 #define AU1550_PSC1_PHYS_ADDR		0x11B00000 /* 34 */
768 #define AU1000_MEM_PHYS_ADDR		0x14000000 /* 01234 */
769 #define AU1000_STATIC_MEM_PHYS_ADDR	0x14001000 /* 01234 */
770 #define AU1300_UDMA_PHYS_ADDR		0x14001800 /* 5 */
771 #define AU1000_DMA_PHYS_ADDR		0x14002000 /* 012 */
772 #define AU1550_DBDMA_PHYS_ADDR		0x14002000 /* 345 */
773 #define AU1550_DBDMA_CONF_PHYS_ADDR	0x14003000 /* 345 */
774 #define AU1000_MACDMA0_PHYS_ADDR	0x14004000 /* 0123 */
775 #define AU1000_MACDMA1_PHYS_ADDR	0x14004200 /* 0123 */
776 #define AU1200_CIM_PHYS_ADDR		0x14004000 /* 45 */
777 #define AU1500_PCI_PHYS_ADDR		0x14005000 /* 13 */
778 #define AU1550_PE_PHYS_ADDR		0x14008000 /* 3 */
779 #define AU1200_MAEBE_PHYS_ADDR		0x14010000 /* 4 */
780 #define AU1200_MAEFE_PHYS_ADDR		0x14012000 /* 4 */
781 #define AU1300_MAEITE_PHYS_ADDR		0x14010000 /* 5 */
782 #define AU1300_MAEMPE_PHYS_ADDR		0x14014000 /* 5 */
783 #define AU1550_USB_OHCI_PHYS_ADDR	0x14020000 /* 3 */
784 #define AU1200_USB_CTL_PHYS_ADDR	0x14020000 /* 4 */
785 #define AU1200_USB_OTG_PHYS_ADDR	0x14020020 /* 4 */
786 #define AU1200_USB_OHCI_PHYS_ADDR	0x14020100 /* 4 */
787 #define AU1200_USB_EHCI_PHYS_ADDR	0x14020200 /* 4 */
788 #define AU1200_USB_UDC_PHYS_ADDR	0x14022000 /* 4 */
789 #define AU1300_USB_EHCI_PHYS_ADDR	0x14020000 /* 5 */
790 #define AU1300_USB_OHCI0_PHYS_ADDR	0x14020400 /* 5 */
791 #define AU1300_USB_OHCI1_PHYS_ADDR	0x14020800 /* 5 */
792 #define AU1300_USB_CTL_PHYS_ADDR	0x14021000 /* 5 */
793 #define AU1300_USB_OTG_PHYS_ADDR	0x14022000 /* 5 */
794 #define AU1300_MAEBSA_PHYS_ADDR		0x14030000 /* 5 */
795 #define AU1100_LCD_PHYS_ADDR		0x15000000 /* 2 */
796 #define AU1200_LCD_PHYS_ADDR		0x15000000 /* 45 */
797 #define AU1500_PCI_MEM_PHYS_ADDR	0x400000000ULL /* 13 */
798 #define AU1500_PCI_IO_PHYS_ADDR		0x500000000ULL /* 13 */
799 #define AU1500_PCI_CONFIG0_PHYS_ADDR	0x600000000ULL /* 13 */
800 #define AU1500_PCI_CONFIG1_PHYS_ADDR	0x680000000ULL /* 13 */
801 #define AU1000_PCMCIA_IO_PHYS_ADDR	0xF00000000ULL /* 012345 */
802 #define AU1000_PCMCIA_ATTR_PHYS_ADDR	0xF40000000ULL /* 012345 */
803 #define AU1000_PCMCIA_MEM_PHYS_ADDR	0xF80000000ULL /* 012345 */
804 
805 /**********************************************************************/
806 
807 
808 /*
809  * Au1300 GPIO+INT controller (GPIC) register offsets and bits
810  * Registers are 128bits (0x10 bytes), divided into 4 "banks".
811  */
812 #define AU1300_GPIC_PINVAL	0x0000
813 #define AU1300_GPIC_PINVALCLR	0x0010
814 #define AU1300_GPIC_IPEND	0x0020
815 #define AU1300_GPIC_PRIENC	0x0030
816 #define AU1300_GPIC_IEN		0x0040	/* int_mask in manual */
817 #define AU1300_GPIC_IDIS	0x0050	/* int_maskclr in manual */
818 #define AU1300_GPIC_DMASEL	0x0060
819 #define AU1300_GPIC_DEVSEL	0x0080
820 #define AU1300_GPIC_DEVCLR	0x0090
821 #define AU1300_GPIC_RSTVAL	0x00a0
822 /* pin configuration space. one 32bit register for up to 128 IRQs */
823 #define AU1300_GPIC_PINCFG	0x1000
824 
825 #define GPIC_GPIO_TO_BIT(gpio)	\
826 	(1 << ((gpio) & 0x1f))
827 
828 #define GPIC_GPIO_BANKOFF(gpio) \
829 	(((gpio) >> 5) * 4)
830 
831 /* Pin Control bits: who owns the pin, what does it do */
832 #define GPIC_CFG_PC_GPIN		0
833 #define GPIC_CFG_PC_DEV			1
834 #define GPIC_CFG_PC_GPOLOW		2
835 #define GPIC_CFG_PC_GPOHIGH		3
836 #define GPIC_CFG_PC_MASK		3
837 
838 /* assign pin to MIPS IRQ line */
839 #define GPIC_CFG_IL_SET(x)	(((x) & 3) << 2)
840 #define GPIC_CFG_IL_MASK	(3 << 2)
841 
842 /* pin interrupt type setup */
843 #define GPIC_CFG_IC_OFF		(0 << 4)
844 #define GPIC_CFG_IC_LEVEL_LOW	(1 << 4)
845 #define GPIC_CFG_IC_LEVEL_HIGH	(2 << 4)
846 #define GPIC_CFG_IC_EDGE_FALL	(5 << 4)
847 #define GPIC_CFG_IC_EDGE_RISE	(6 << 4)
848 #define GPIC_CFG_IC_EDGE_BOTH	(7 << 4)
849 #define GPIC_CFG_IC_MASK	(7 << 4)
850 
851 /* allow interrupt to wake cpu from 'wait' */
852 #define GPIC_CFG_IDLEWAKE	(1 << 7)
853 
854 /***********************************************************************/
855 
856 /* Au1000 SDRAM memory controller register offsets */
857 #define AU1000_MEM_SDMODE0		0x0000
858 #define AU1000_MEM_SDMODE1		0x0004
859 #define AU1000_MEM_SDMODE2		0x0008
860 #define AU1000_MEM_SDADDR0		0x000C
861 #define AU1000_MEM_SDADDR1		0x0010
862 #define AU1000_MEM_SDADDR2		0x0014
863 #define AU1000_MEM_SDREFCFG		0x0018
864 #define AU1000_MEM_SDPRECMD		0x001C
865 #define AU1000_MEM_SDAUTOREF		0x0020
866 #define AU1000_MEM_SDWRMD0		0x0024
867 #define AU1000_MEM_SDWRMD1		0x0028
868 #define AU1000_MEM_SDWRMD2		0x002C
869 #define AU1000_MEM_SDSLEEP		0x0030
870 #define AU1000_MEM_SDSMCKE		0x0034
871 
872 /* MEM_SDMODE register content definitions */
873 #define MEM_SDMODE_F		(1 << 22)
874 #define MEM_SDMODE_SR		(1 << 21)
875 #define MEM_SDMODE_BS		(1 << 20)
876 #define MEM_SDMODE_RS		(3 << 18)
877 #define MEM_SDMODE_CS		(7 << 15)
878 #define MEM_SDMODE_TRAS		(15 << 11)
879 #define MEM_SDMODE_TMRD		(3 << 9)
880 #define MEM_SDMODE_TWR		(3 << 7)
881 #define MEM_SDMODE_TRP		(3 << 5)
882 #define MEM_SDMODE_TRCD		(3 << 3)
883 #define MEM_SDMODE_TCL		(7 << 0)
884 
885 #define MEM_SDMODE_BS_2Bank	(0 << 20)
886 #define MEM_SDMODE_BS_4Bank	(1 << 20)
887 #define MEM_SDMODE_RS_11Row	(0 << 18)
888 #define MEM_SDMODE_RS_12Row	(1 << 18)
889 #define MEM_SDMODE_RS_13Row	(2 << 18)
890 #define MEM_SDMODE_RS_N(N)	((N) << 18)
891 #define MEM_SDMODE_CS_7Col	(0 << 15)
892 #define MEM_SDMODE_CS_8Col	(1 << 15)
893 #define MEM_SDMODE_CS_9Col	(2 << 15)
894 #define MEM_SDMODE_CS_10Col	(3 << 15)
895 #define MEM_SDMODE_CS_11Col	(4 << 15)
896 #define MEM_SDMODE_CS_N(N)	((N) << 15)
897 #define MEM_SDMODE_TRAS_N(N)	((N) << 11)
898 #define MEM_SDMODE_TMRD_N(N)	((N) << 9)
899 #define MEM_SDMODE_TWR_N(N)	((N) << 7)
900 #define MEM_SDMODE_TRP_N(N)	((N) << 5)
901 #define MEM_SDMODE_TRCD_N(N)	((N) << 3)
902 #define MEM_SDMODE_TCL_N(N)	((N) << 0)
903 
904 /* MEM_SDADDR register contents definitions */
905 #define MEM_SDADDR_E		(1 << 20)
906 #define MEM_SDADDR_CSBA		(0x03FF << 10)
907 #define MEM_SDADDR_CSMASK	(0x03FF << 0)
908 #define MEM_SDADDR_CSBA_N(N)	((N) & (0x03FF << 22) >> 12)
909 #define MEM_SDADDR_CSMASK_N(N)	((N)&(0x03FF << 22) >> 22)
910 
911 /* MEM_SDREFCFG register content definitions */
912 #define MEM_SDREFCFG_TRC	(15 << 28)
913 #define MEM_SDREFCFG_TRPM	(3 << 26)
914 #define MEM_SDREFCFG_E		(1 << 25)
915 #define MEM_SDREFCFG_RE		(0x1ffffff << 0)
916 #define MEM_SDREFCFG_TRC_N(N)	((N) << MEM_SDREFCFG_TRC)
917 #define MEM_SDREFCFG_TRPM_N(N)	((N) << MEM_SDREFCFG_TRPM)
918 #define MEM_SDREFCFG_REF_N(N)	(N)
919 
920 /* Au1550 SDRAM Register Offsets */
921 #define AU1550_MEM_SDMODE0		0x0800
922 #define AU1550_MEM_SDMODE1		0x0808
923 #define AU1550_MEM_SDMODE2		0x0810
924 #define AU1550_MEM_SDADDR0		0x0820
925 #define AU1550_MEM_SDADDR1		0x0828
926 #define AU1550_MEM_SDADDR2		0x0830
927 #define AU1550_MEM_SDCONFIGA		0x0840
928 #define AU1550_MEM_SDCONFIGB		0x0848
929 #define AU1550_MEM_SDSTAT		0x0850
930 #define AU1550_MEM_SDERRADDR		0x0858
931 #define AU1550_MEM_SDSTRIDE0		0x0860
932 #define AU1550_MEM_SDSTRIDE1		0x0868
933 #define AU1550_MEM_SDSTRIDE2		0x0870
934 #define AU1550_MEM_SDWRMD0		0x0880
935 #define AU1550_MEM_SDWRMD1		0x0888
936 #define AU1550_MEM_SDWRMD2		0x0890
937 #define AU1550_MEM_SDPRECMD		0x08C0
938 #define AU1550_MEM_SDAUTOREF		0x08C8
939 #define AU1550_MEM_SDSREF		0x08D0
940 #define AU1550_MEM_SDSLEEP		MEM_SDSREF
941 
942 /* Static Bus Controller */
943 #define MEM_STCFG0		0xB4001000
944 #define MEM_STTIME0		0xB4001004
945 #define MEM_STADDR0		0xB4001008
946 
947 #define MEM_STCFG1		0xB4001010
948 #define MEM_STTIME1		0xB4001014
949 #define MEM_STADDR1		0xB4001018
950 
951 #define MEM_STCFG2		0xB4001020
952 #define MEM_STTIME2		0xB4001024
953 #define MEM_STADDR2		0xB4001028
954 
955 #define MEM_STCFG3		0xB4001030
956 #define MEM_STTIME3		0xB4001034
957 #define MEM_STADDR3		0xB4001038
958 
959 #define MEM_STNDCTL		0xB4001100
960 #define MEM_STSTAT		0xB4001104
961 
962 #define MEM_STNAND_CMD		0x0
963 #define MEM_STNAND_ADDR		0x4
964 #define MEM_STNAND_DATA		0x20
965 
966 
967 /* Programmable Counters 0 and 1 */
968 #define SYS_BASE		0xB1900000
969 #define SYS_COUNTER_CNTRL	(SYS_BASE + 0x14)
970 #  define SYS_CNTRL_E1S		(1 << 23)
971 #  define SYS_CNTRL_T1S		(1 << 20)
972 #  define SYS_CNTRL_M21		(1 << 19)
973 #  define SYS_CNTRL_M11		(1 << 18)
974 #  define SYS_CNTRL_M01		(1 << 17)
975 #  define SYS_CNTRL_C1S		(1 << 16)
976 #  define SYS_CNTRL_BP		(1 << 14)
977 #  define SYS_CNTRL_EN1		(1 << 13)
978 #  define SYS_CNTRL_BT1		(1 << 12)
979 #  define SYS_CNTRL_EN0		(1 << 11)
980 #  define SYS_CNTRL_BT0		(1 << 10)
981 #  define SYS_CNTRL_E0		(1 << 8)
982 #  define SYS_CNTRL_E0S		(1 << 7)
983 #  define SYS_CNTRL_32S		(1 << 5)
984 #  define SYS_CNTRL_T0S		(1 << 4)
985 #  define SYS_CNTRL_M20		(1 << 3)
986 #  define SYS_CNTRL_M10		(1 << 2)
987 #  define SYS_CNTRL_M00		(1 << 1)
988 #  define SYS_CNTRL_C0S		(1 << 0)
989 
990 /* Programmable Counter 0 Registers */
991 #define SYS_TOYTRIM		(SYS_BASE + 0)
992 #define SYS_TOYWRITE		(SYS_BASE + 4)
993 #define SYS_TOYMATCH0		(SYS_BASE + 8)
994 #define SYS_TOYMATCH1		(SYS_BASE + 0xC)
995 #define SYS_TOYMATCH2		(SYS_BASE + 0x10)
996 #define SYS_TOYREAD		(SYS_BASE + 0x40)
997 
998 /* Programmable Counter 1 Registers */
999 #define SYS_RTCTRIM		(SYS_BASE + 0x44)
1000 #define SYS_RTCWRITE		(SYS_BASE + 0x48)
1001 #define SYS_RTCMATCH0		(SYS_BASE + 0x4C)
1002 #define SYS_RTCMATCH1		(SYS_BASE + 0x50)
1003 #define SYS_RTCMATCH2		(SYS_BASE + 0x54)
1004 #define SYS_RTCREAD		(SYS_BASE + 0x58)
1005 
1006 /* I2S Controller */
1007 #define I2S_DATA		0xB1000000
1008 #  define I2S_DATA_MASK		0xffffff
1009 #define I2S_CONFIG		0xB1000004
1010 #  define I2S_CONFIG_XU		(1 << 25)
1011 #  define I2S_CONFIG_XO		(1 << 24)
1012 #  define I2S_CONFIG_RU		(1 << 23)
1013 #  define I2S_CONFIG_RO		(1 << 22)
1014 #  define I2S_CONFIG_TR		(1 << 21)
1015 #  define I2S_CONFIG_TE		(1 << 20)
1016 #  define I2S_CONFIG_TF		(1 << 19)
1017 #  define I2S_CONFIG_RR		(1 << 18)
1018 #  define I2S_CONFIG_RE		(1 << 17)
1019 #  define I2S_CONFIG_RF		(1 << 16)
1020 #  define I2S_CONFIG_PD		(1 << 11)
1021 #  define I2S_CONFIG_LB		(1 << 10)
1022 #  define I2S_CONFIG_IC		(1 << 9)
1023 #  define I2S_CONFIG_FM_BIT	7
1024 #  define I2S_CONFIG_FM_MASK	(0x3 << I2S_CONFIG_FM_BIT)
1025 #    define I2S_CONFIG_FM_I2S	(0x0 << I2S_CONFIG_FM_BIT)
1026 #    define I2S_CONFIG_FM_LJ	(0x1 << I2S_CONFIG_FM_BIT)
1027 #    define I2S_CONFIG_FM_RJ	(0x2 << I2S_CONFIG_FM_BIT)
1028 #  define I2S_CONFIG_TN		(1 << 6)
1029 #  define I2S_CONFIG_RN		(1 << 5)
1030 #  define I2S_CONFIG_SZ_BIT	0
1031 #  define I2S_CONFIG_SZ_MASK	(0x1F << I2S_CONFIG_SZ_BIT)
1032 
1033 #define I2S_CONTROL		0xB1000008
1034 #  define I2S_CONTROL_D		(1 << 1)
1035 #  define I2S_CONTROL_CE	(1 << 0)
1036 
1037 
1038 /* Ethernet Controllers  */
1039 
1040 /* 4 byte offsets from AU1000_ETH_BASE */
1041 #define MAC_CONTROL		0x0
1042 #  define MAC_RX_ENABLE		(1 << 2)
1043 #  define MAC_TX_ENABLE		(1 << 3)
1044 #  define MAC_DEF_CHECK		(1 << 5)
1045 #  define MAC_SET_BL(X)		(((X) & 0x3) << 6)
1046 #  define MAC_AUTO_PAD		(1 << 8)
1047 #  define MAC_DISABLE_RETRY	(1 << 10)
1048 #  define MAC_DISABLE_BCAST	(1 << 11)
1049 #  define MAC_LATE_COL		(1 << 12)
1050 #  define MAC_HASH_MODE		(1 << 13)
1051 #  define MAC_HASH_ONLY		(1 << 15)
1052 #  define MAC_PASS_ALL		(1 << 16)
1053 #  define MAC_INVERSE_FILTER	(1 << 17)
1054 #  define MAC_PROMISCUOUS	(1 << 18)
1055 #  define MAC_PASS_ALL_MULTI	(1 << 19)
1056 #  define MAC_FULL_DUPLEX	(1 << 20)
1057 #  define MAC_NORMAL_MODE	0
1058 #  define MAC_INT_LOOPBACK	(1 << 21)
1059 #  define MAC_EXT_LOOPBACK	(1 << 22)
1060 #  define MAC_DISABLE_RX_OWN	(1 << 23)
1061 #  define MAC_BIG_ENDIAN	(1 << 30)
1062 #  define MAC_RX_ALL		(1 << 31)
1063 #define MAC_ADDRESS_HIGH	0x4
1064 #define MAC_ADDRESS_LOW		0x8
1065 #define MAC_MCAST_HIGH		0xC
1066 #define MAC_MCAST_LOW		0x10
1067 #define MAC_MII_CNTRL		0x14
1068 #  define MAC_MII_BUSY		(1 << 0)
1069 #  define MAC_MII_READ		0
1070 #  define MAC_MII_WRITE		(1 << 1)
1071 #  define MAC_SET_MII_SELECT_REG(X) (((X) & 0x1f) << 6)
1072 #  define MAC_SET_MII_SELECT_PHY(X) (((X) & 0x1f) << 11)
1073 #define MAC_MII_DATA		0x18
1074 #define MAC_FLOW_CNTRL		0x1C
1075 #  define MAC_FLOW_CNTRL_BUSY	(1 << 0)
1076 #  define MAC_FLOW_CNTRL_ENABLE (1 << 1)
1077 #  define MAC_PASS_CONTROL	(1 << 2)
1078 #  define MAC_SET_PAUSE(X)	(((X) & 0xffff) << 16)
1079 #define MAC_VLAN1_TAG		0x20
1080 #define MAC_VLAN2_TAG		0x24
1081 
1082 /* Ethernet Controller Enable */
1083 
1084 #  define MAC_EN_CLOCK_ENABLE	(1 << 0)
1085 #  define MAC_EN_RESET0		(1 << 1)
1086 #  define MAC_EN_TOSS		(0 << 2)
1087 #  define MAC_EN_CACHEABLE	(1 << 3)
1088 #  define MAC_EN_RESET1		(1 << 4)
1089 #  define MAC_EN_RESET2		(1 << 5)
1090 #  define MAC_DMA_RESET		(1 << 6)
1091 
1092 /* Ethernet Controller DMA Channels */
1093 
1094 #define MAC0_TX_DMA_ADDR	0xB4004000
1095 #define MAC1_TX_DMA_ADDR	0xB4004200
1096 /* offsets from MAC_TX_RING_ADDR address */
1097 #define MAC_TX_BUFF0_STATUS	0x0
1098 #  define TX_FRAME_ABORTED	(1 << 0)
1099 #  define TX_JAB_TIMEOUT	(1 << 1)
1100 #  define TX_NO_CARRIER		(1 << 2)
1101 #  define TX_LOSS_CARRIER	(1 << 3)
1102 #  define TX_EXC_DEF		(1 << 4)
1103 #  define TX_LATE_COLL_ABORT	(1 << 5)
1104 #  define TX_EXC_COLL		(1 << 6)
1105 #  define TX_UNDERRUN		(1 << 7)
1106 #  define TX_DEFERRED		(1 << 8)
1107 #  define TX_LATE_COLL		(1 << 9)
1108 #  define TX_COLL_CNT_MASK	(0xF << 10)
1109 #  define TX_PKT_RETRY		(1 << 31)
1110 #define MAC_TX_BUFF0_ADDR	0x4
1111 #  define TX_DMA_ENABLE		(1 << 0)
1112 #  define TX_T_DONE		(1 << 1)
1113 #  define TX_GET_DMA_BUFFER(X)	(((X) >> 2) & 0x3)
1114 #define MAC_TX_BUFF0_LEN	0x8
1115 #define MAC_TX_BUFF1_STATUS	0x10
1116 #define MAC_TX_BUFF1_ADDR	0x14
1117 #define MAC_TX_BUFF1_LEN	0x18
1118 #define MAC_TX_BUFF2_STATUS	0x20
1119 #define MAC_TX_BUFF2_ADDR	0x24
1120 #define MAC_TX_BUFF2_LEN	0x28
1121 #define MAC_TX_BUFF3_STATUS	0x30
1122 #define MAC_TX_BUFF3_ADDR	0x34
1123 #define MAC_TX_BUFF3_LEN	0x38
1124 
1125 #define MAC0_RX_DMA_ADDR	0xB4004100
1126 #define MAC1_RX_DMA_ADDR	0xB4004300
1127 /* offsets from MAC_RX_RING_ADDR */
1128 #define MAC_RX_BUFF0_STATUS	0x0
1129 #  define RX_FRAME_LEN_MASK	0x3fff
1130 #  define RX_WDOG_TIMER		(1 << 14)
1131 #  define RX_RUNT		(1 << 15)
1132 #  define RX_OVERLEN		(1 << 16)
1133 #  define RX_COLL		(1 << 17)
1134 #  define RX_ETHER		(1 << 18)
1135 #  define RX_MII_ERROR		(1 << 19)
1136 #  define RX_DRIBBLING		(1 << 20)
1137 #  define RX_CRC_ERROR		(1 << 21)
1138 #  define RX_VLAN1		(1 << 22)
1139 #  define RX_VLAN2		(1 << 23)
1140 #  define RX_LEN_ERROR		(1 << 24)
1141 #  define RX_CNTRL_FRAME	(1 << 25)
1142 #  define RX_U_CNTRL_FRAME	(1 << 26)
1143 #  define RX_MCAST_FRAME	(1 << 27)
1144 #  define RX_BCAST_FRAME	(1 << 28)
1145 #  define RX_FILTER_FAIL	(1 << 29)
1146 #  define RX_PACKET_FILTER	(1 << 30)
1147 #  define RX_MISSED_FRAME	(1 << 31)
1148 
1149 #  define RX_ERROR (RX_WDOG_TIMER | RX_RUNT | RX_OVERLEN |  \
1150 		    RX_COLL | RX_MII_ERROR | RX_CRC_ERROR | \
1151 		    RX_LEN_ERROR | RX_U_CNTRL_FRAME | RX_MISSED_FRAME)
1152 #define MAC_RX_BUFF0_ADDR	0x4
1153 #  define RX_DMA_ENABLE		(1 << 0)
1154 #  define RX_T_DONE		(1 << 1)
1155 #  define RX_GET_DMA_BUFFER(X)	(((X) >> 2) & 0x3)
1156 #  define RX_SET_BUFF_ADDR(X)	((X) & 0xffffffc0)
1157 #define MAC_RX_BUFF1_STATUS	0x10
1158 #define MAC_RX_BUFF1_ADDR	0x14
1159 #define MAC_RX_BUFF2_STATUS	0x20
1160 #define MAC_RX_BUFF2_ADDR	0x24
1161 #define MAC_RX_BUFF3_STATUS	0x30
1162 #define MAC_RX_BUFF3_ADDR	0x34
1163 
1164 #define UART_RX		0	/* Receive buffer */
1165 #define UART_TX		4	/* Transmit buffer */
1166 #define UART_IER	8	/* Interrupt Enable Register */
1167 #define UART_IIR	0xC	/* Interrupt ID Register */
1168 #define UART_FCR	0x10	/* FIFO Control Register */
1169 #define UART_LCR	0x14	/* Line Control Register */
1170 #define UART_MCR	0x18	/* Modem Control Register */
1171 #define UART_LSR	0x1C	/* Line Status Register */
1172 #define UART_MSR	0x20	/* Modem Status Register */
1173 #define UART_CLK	0x28	/* Baud Rate Clock Divider */
1174 #define UART_MOD_CNTRL	0x100	/* Module Control */
1175 
1176 /* SSIO */
1177 #define SSI0_STATUS		0xB1600000
1178 #  define SSI_STATUS_BF		(1 << 4)
1179 #  define SSI_STATUS_OF		(1 << 3)
1180 #  define SSI_STATUS_UF		(1 << 2)
1181 #  define SSI_STATUS_D		(1 << 1)
1182 #  define SSI_STATUS_B		(1 << 0)
1183 #define SSI0_INT		0xB1600004
1184 #  define SSI_INT_OI		(1 << 3)
1185 #  define SSI_INT_UI		(1 << 2)
1186 #  define SSI_INT_DI		(1 << 1)
1187 #define SSI0_INT_ENABLE		0xB1600008
1188 #  define SSI_INTE_OIE		(1 << 3)
1189 #  define SSI_INTE_UIE		(1 << 2)
1190 #  define SSI_INTE_DIE		(1 << 1)
1191 #define SSI0_CONFIG		0xB1600020
1192 #  define SSI_CONFIG_AO		(1 << 24)
1193 #  define SSI_CONFIG_DO		(1 << 23)
1194 #  define SSI_CONFIG_ALEN_BIT	20
1195 #  define SSI_CONFIG_ALEN_MASK	(0x7 << 20)
1196 #  define SSI_CONFIG_DLEN_BIT	16
1197 #  define SSI_CONFIG_DLEN_MASK	(0x7 << 16)
1198 #  define SSI_CONFIG_DD		(1 << 11)
1199 #  define SSI_CONFIG_AD		(1 << 10)
1200 #  define SSI_CONFIG_BM_BIT	8
1201 #  define SSI_CONFIG_BM_MASK	(0x3 << 8)
1202 #  define SSI_CONFIG_CE		(1 << 7)
1203 #  define SSI_CONFIG_DP		(1 << 6)
1204 #  define SSI_CONFIG_DL		(1 << 5)
1205 #  define SSI_CONFIG_EP		(1 << 4)
1206 #define SSI0_ADATA		0xB1600024
1207 #  define SSI_AD_D		(1 << 24)
1208 #  define SSI_AD_ADDR_BIT	16
1209 #  define SSI_AD_ADDR_MASK	(0xff << 16)
1210 #  define SSI_AD_DATA_BIT	0
1211 #  define SSI_AD_DATA_MASK	(0xfff << 0)
1212 #define SSI0_CLKDIV		0xB1600028
1213 #define SSI0_CONTROL		0xB1600100
1214 #  define SSI_CONTROL_CD	(1 << 1)
1215 #  define SSI_CONTROL_E		(1 << 0)
1216 
1217 /* SSI1 */
1218 #define SSI1_STATUS		0xB1680000
1219 #define SSI1_INT		0xB1680004
1220 #define SSI1_INT_ENABLE		0xB1680008
1221 #define SSI1_CONFIG		0xB1680020
1222 #define SSI1_ADATA		0xB1680024
1223 #define SSI1_CLKDIV		0xB1680028
1224 #define SSI1_ENABLE		0xB1680100
1225 
1226 /*
1227  * Register content definitions
1228  */
1229 #define SSI_STATUS_BF		(1 << 4)
1230 #define SSI_STATUS_OF		(1 << 3)
1231 #define SSI_STATUS_UF		(1 << 2)
1232 #define SSI_STATUS_D		(1 << 1)
1233 #define SSI_STATUS_B		(1 << 0)
1234 
1235 /* SSI_INT */
1236 #define SSI_INT_OI		(1 << 3)
1237 #define SSI_INT_UI		(1 << 2)
1238 #define SSI_INT_DI		(1 << 1)
1239 
1240 /* SSI_INTEN */
1241 #define SSI_INTEN_OIE		(1 << 3)
1242 #define SSI_INTEN_UIE		(1 << 2)
1243 #define SSI_INTEN_DIE		(1 << 1)
1244 
1245 #define SSI_CONFIG_AO		(1 << 24)
1246 #define SSI_CONFIG_DO		(1 << 23)
1247 #define SSI_CONFIG_ALEN		(7 << 20)
1248 #define SSI_CONFIG_DLEN		(15 << 16)
1249 #define SSI_CONFIG_DD		(1 << 11)
1250 #define SSI_CONFIG_AD		(1 << 10)
1251 #define SSI_CONFIG_BM		(3 << 8)
1252 #define SSI_CONFIG_CE		(1 << 7)
1253 #define SSI_CONFIG_DP		(1 << 6)
1254 #define SSI_CONFIG_DL		(1 << 5)
1255 #define SSI_CONFIG_EP		(1 << 4)
1256 #define SSI_CONFIG_ALEN_N(N)	((N-1) << 20)
1257 #define SSI_CONFIG_DLEN_N(N)	((N-1) << 16)
1258 #define SSI_CONFIG_BM_HI	(0 << 8)
1259 #define SSI_CONFIG_BM_LO	(1 << 8)
1260 #define SSI_CONFIG_BM_CY	(2 << 8)
1261 
1262 #define SSI_ADATA_D		(1 << 24)
1263 #define SSI_ADATA_ADDR		(0xFF << 16)
1264 #define SSI_ADATA_DATA		0x0FFF
1265 #define SSI_ADATA_ADDR_N(N)	(N << 16)
1266 
1267 #define SSI_ENABLE_CD		(1 << 1)
1268 #define SSI_ENABLE_E		(1 << 0)
1269 
1270 
1271 /*
1272  * The IrDA peripheral has an IRFIRSEL pin, but on the DB/PB boards it's not
1273  * used to select FIR/SIR mode on the transceiver but as a GPIO.  Instead a
1274  * CPLD has to be told about the mode.
1275  */
1276 #define AU1000_IRDA_PHY_MODE_OFF	0
1277 #define AU1000_IRDA_PHY_MODE_SIR	1
1278 #define AU1000_IRDA_PHY_MODE_FIR	2
1279 
1280 struct au1k_irda_platform_data {
1281 	void(*set_phy_mode)(int mode);
1282 };
1283 
1284 
1285 /* GPIO */
1286 #define SYS_PINFUNC		0xB190002C
1287 #  define SYS_PF_USB		(1 << 15)	/* 2nd USB device/host */
1288 #  define SYS_PF_U3		(1 << 14)	/* GPIO23/U3TXD */
1289 #  define SYS_PF_U2		(1 << 13)	/* GPIO22/U2TXD */
1290 #  define SYS_PF_U1		(1 << 12)	/* GPIO21/U1TXD */
1291 #  define SYS_PF_SRC		(1 << 11)	/* GPIO6/SROMCKE */
1292 #  define SYS_PF_CK5		(1 << 10)	/* GPIO3/CLK5 */
1293 #  define SYS_PF_CK4		(1 << 9)	/* GPIO2/CLK4 */
1294 #  define SYS_PF_IRF		(1 << 8)	/* GPIO15/IRFIRSEL */
1295 #  define SYS_PF_UR3		(1 << 7)	/* GPIO[14:9]/UART3 */
1296 #  define SYS_PF_I2D		(1 << 6)	/* GPIO8/I2SDI */
1297 #  define SYS_PF_I2S		(1 << 5)	/* I2S/GPIO[29:31] */
1298 #  define SYS_PF_NI2		(1 << 4)	/* NI2/GPIO[24:28] */
1299 #  define SYS_PF_U0		(1 << 3)	/* U0TXD/GPIO20 */
1300 #  define SYS_PF_RD		(1 << 2)	/* IRTXD/GPIO19 */
1301 #  define SYS_PF_A97		(1 << 1)	/* AC97/SSL1 */
1302 #  define SYS_PF_S0		(1 << 0)	/* SSI_0/GPIO[16:18] */
1303 
1304 /* Au1100 only */
1305 #  define SYS_PF_PC		(1 << 18)	/* PCMCIA/GPIO[207:204] */
1306 #  define SYS_PF_LCD		(1 << 17)	/* extern lcd/GPIO[203:200] */
1307 #  define SYS_PF_CS		(1 << 16)	/* EXTCLK0/32KHz to gpio2 */
1308 #  define SYS_PF_EX0		(1 << 9)	/* GPIO2/clock */
1309 
1310 /* Au1550 only.	 Redefines lots of pins */
1311 #  define SYS_PF_PSC2_MASK	(7 << 17)
1312 #  define SYS_PF_PSC2_AC97	0
1313 #  define SYS_PF_PSC2_SPI	0
1314 #  define SYS_PF_PSC2_I2S	(1 << 17)
1315 #  define SYS_PF_PSC2_SMBUS	(3 << 17)
1316 #  define SYS_PF_PSC2_GPIO	(7 << 17)
1317 #  define SYS_PF_PSC3_MASK	(7 << 20)
1318 #  define SYS_PF_PSC3_AC97	0
1319 #  define SYS_PF_PSC3_SPI	0
1320 #  define SYS_PF_PSC3_I2S	(1 << 20)
1321 #  define SYS_PF_PSC3_SMBUS	(3 << 20)
1322 #  define SYS_PF_PSC3_GPIO	(7 << 20)
1323 #  define SYS_PF_PSC1_S1	(1 << 1)
1324 #  define SYS_PF_MUST_BE_SET	((1 << 5) | (1 << 2))
1325 
1326 /* Au1200 only */
1327 #define SYS_PINFUNC_DMA		(1 << 31)
1328 #define SYS_PINFUNC_S0A		(1 << 30)
1329 #define SYS_PINFUNC_S1A		(1 << 29)
1330 #define SYS_PINFUNC_LP0		(1 << 28)
1331 #define SYS_PINFUNC_LP1		(1 << 27)
1332 #define SYS_PINFUNC_LD16	(1 << 26)
1333 #define SYS_PINFUNC_LD8		(1 << 25)
1334 #define SYS_PINFUNC_LD1		(1 << 24)
1335 #define SYS_PINFUNC_LD0		(1 << 23)
1336 #define SYS_PINFUNC_P1A		(3 << 21)
1337 #define SYS_PINFUNC_P1B		(1 << 20)
1338 #define SYS_PINFUNC_FS3		(1 << 19)
1339 #define SYS_PINFUNC_P0A		(3 << 17)
1340 #define SYS_PINFUNC_CS		(1 << 16)
1341 #define SYS_PINFUNC_CIM		(1 << 15)
1342 #define SYS_PINFUNC_P1C		(1 << 14)
1343 #define SYS_PINFUNC_U1T		(1 << 12)
1344 #define SYS_PINFUNC_U1R		(1 << 11)
1345 #define SYS_PINFUNC_EX1		(1 << 10)
1346 #define SYS_PINFUNC_EX0		(1 << 9)
1347 #define SYS_PINFUNC_U0R		(1 << 8)
1348 #define SYS_PINFUNC_MC		(1 << 7)
1349 #define SYS_PINFUNC_S0B		(1 << 6)
1350 #define SYS_PINFUNC_S0C		(1 << 5)
1351 #define SYS_PINFUNC_P0B		(1 << 4)
1352 #define SYS_PINFUNC_U0T		(1 << 3)
1353 #define SYS_PINFUNC_S1B		(1 << 2)
1354 
1355 /* Power Management */
1356 #define SYS_SCRATCH0		0xB1900018
1357 #define SYS_SCRATCH1		0xB190001C
1358 #define SYS_WAKEMSK		0xB1900034
1359 #define SYS_ENDIAN		0xB1900038
1360 #define SYS_POWERCTRL		0xB190003C
1361 #define SYS_WAKESRC		0xB190005C
1362 #define SYS_SLPPWR		0xB1900078
1363 #define SYS_SLEEP		0xB190007C
1364 
1365 #define SYS_WAKEMSK_D2		(1 << 9)
1366 #define SYS_WAKEMSK_M2		(1 << 8)
1367 #define SYS_WAKEMSK_GPIO(x)	(1 << (x))
1368 
1369 /* Clock Controller */
1370 #define SYS_FREQCTRL0		0xB1900020
1371 #  define SYS_FC_FRDIV2_BIT	22
1372 #  define SYS_FC_FRDIV2_MASK	(0xff << SYS_FC_FRDIV2_BIT)
1373 #  define SYS_FC_FE2		(1 << 21)
1374 #  define SYS_FC_FS2		(1 << 20)
1375 #  define SYS_FC_FRDIV1_BIT	12
1376 #  define SYS_FC_FRDIV1_MASK	(0xff << SYS_FC_FRDIV1_BIT)
1377 #  define SYS_FC_FE1		(1 << 11)
1378 #  define SYS_FC_FS1		(1 << 10)
1379 #  define SYS_FC_FRDIV0_BIT	2
1380 #  define SYS_FC_FRDIV0_MASK	(0xff << SYS_FC_FRDIV0_BIT)
1381 #  define SYS_FC_FE0		(1 << 1)
1382 #  define SYS_FC_FS0		(1 << 0)
1383 #define SYS_FREQCTRL1		0xB1900024
1384 #  define SYS_FC_FRDIV5_BIT	22
1385 #  define SYS_FC_FRDIV5_MASK	(0xff << SYS_FC_FRDIV5_BIT)
1386 #  define SYS_FC_FE5		(1 << 21)
1387 #  define SYS_FC_FS5		(1 << 20)
1388 #  define SYS_FC_FRDIV4_BIT	12
1389 #  define SYS_FC_FRDIV4_MASK	(0xff << SYS_FC_FRDIV4_BIT)
1390 #  define SYS_FC_FE4		(1 << 11)
1391 #  define SYS_FC_FS4		(1 << 10)
1392 #  define SYS_FC_FRDIV3_BIT	2
1393 #  define SYS_FC_FRDIV3_MASK	(0xff << SYS_FC_FRDIV3_BIT)
1394 #  define SYS_FC_FE3		(1 << 1)
1395 #  define SYS_FC_FS3		(1 << 0)
1396 #define SYS_CLKSRC		0xB1900028
1397 #  define SYS_CS_ME1_BIT	27
1398 #  define SYS_CS_ME1_MASK	(0x7 << SYS_CS_ME1_BIT)
1399 #  define SYS_CS_DE1		(1 << 26)
1400 #  define SYS_CS_CE1		(1 << 25)
1401 #  define SYS_CS_ME0_BIT	22
1402 #  define SYS_CS_ME0_MASK	(0x7 << SYS_CS_ME0_BIT)
1403 #  define SYS_CS_DE0		(1 << 21)
1404 #  define SYS_CS_CE0		(1 << 20)
1405 #  define SYS_CS_MI2_BIT	17
1406 #  define SYS_CS_MI2_MASK	(0x7 << SYS_CS_MI2_BIT)
1407 #  define SYS_CS_DI2		(1 << 16)
1408 #  define SYS_CS_CI2		(1 << 15)
1409 
1410 #  define SYS_CS_ML_BIT		7
1411 #  define SYS_CS_ML_MASK	(0x7 << SYS_CS_ML_BIT)
1412 #  define SYS_CS_DL		(1 << 6)
1413 #  define SYS_CS_CL		(1 << 5)
1414 
1415 #  define SYS_CS_MUH_BIT	12
1416 #  define SYS_CS_MUH_MASK	(0x7 << SYS_CS_MUH_BIT)
1417 #  define SYS_CS_DUH		(1 << 11)
1418 #  define SYS_CS_CUH		(1 << 10)
1419 #  define SYS_CS_MUD_BIT	7
1420 #  define SYS_CS_MUD_MASK	(0x7 << SYS_CS_MUD_BIT)
1421 #  define SYS_CS_DUD		(1 << 6)
1422 #  define SYS_CS_CUD		(1 << 5)
1423 
1424 #  define SYS_CS_MIR_BIT	2
1425 #  define SYS_CS_MIR_MASK	(0x7 << SYS_CS_MIR_BIT)
1426 #  define SYS_CS_DIR		(1 << 1)
1427 #  define SYS_CS_CIR		(1 << 0)
1428 
1429 #  define SYS_CS_MUX_AUX	0x1
1430 #  define SYS_CS_MUX_FQ0	0x2
1431 #  define SYS_CS_MUX_FQ1	0x3
1432 #  define SYS_CS_MUX_FQ2	0x4
1433 #  define SYS_CS_MUX_FQ3	0x5
1434 #  define SYS_CS_MUX_FQ4	0x6
1435 #  define SYS_CS_MUX_FQ5	0x7
1436 #define SYS_CPUPLL		0xB1900060
1437 #define SYS_AUXPLL		0xB1900064
1438 
1439 /* AC97 Controller */
1440 #define AC97C_CONFIG		0xB0000000
1441 #  define AC97C_RECV_SLOTS_BIT	13
1442 #  define AC97C_RECV_SLOTS_MASK (0x3ff << AC97C_RECV_SLOTS_BIT)
1443 #  define AC97C_XMIT_SLOTS_BIT	3
1444 #  define AC97C_XMIT_SLOTS_MASK (0x3ff << AC97C_XMIT_SLOTS_BIT)
1445 #  define AC97C_SG		(1 << 2)
1446 #  define AC97C_SYNC		(1 << 1)
1447 #  define AC97C_RESET		(1 << 0)
1448 #define AC97C_STATUS		0xB0000004
1449 #  define AC97C_XU		(1 << 11)
1450 #  define AC97C_XO		(1 << 10)
1451 #  define AC97C_RU		(1 << 9)
1452 #  define AC97C_RO		(1 << 8)
1453 #  define AC97C_READY		(1 << 7)
1454 #  define AC97C_CP		(1 << 6)
1455 #  define AC97C_TR		(1 << 5)
1456 #  define AC97C_TE		(1 << 4)
1457 #  define AC97C_TF		(1 << 3)
1458 #  define AC97C_RR		(1 << 2)
1459 #  define AC97C_RE		(1 << 1)
1460 #  define AC97C_RF		(1 << 0)
1461 #define AC97C_DATA		0xB0000008
1462 #define AC97C_CMD		0xB000000C
1463 #  define AC97C_WD_BIT		16
1464 #  define AC97C_READ		(1 << 7)
1465 #  define AC97C_INDEX_MASK	0x7f
1466 #define AC97C_CNTRL		0xB0000010
1467 #  define AC97C_RS		(1 << 1)
1468 #  define AC97C_CE		(1 << 0)
1469 
1470 
1471 /* The PCI chip selects are outside the 32bit space, and since we can't
1472  * just program the 36bit addresses into BARs, we have to take a chunk
1473  * out of the 32bit space and reserve it for PCI.  When these addresses
1474  * are ioremap()ed, they'll be fixed up to the real 36bit address before
1475  * being passed to the real ioremap function.
1476  */
1477 #define ALCHEMY_PCI_MEMWIN_START	(AU1500_PCI_MEM_PHYS_ADDR >> 4)
1478 #define ALCHEMY_PCI_MEMWIN_END		(ALCHEMY_PCI_MEMWIN_START + 0x0FFFFFFF)
1479 
1480 /* for PCI IO it's simpler because we get to do the ioremap ourselves and then
1481  * adjust the device's resources.
1482  */
1483 #define ALCHEMY_PCI_IOWIN_START		0x00001000
1484 #define ALCHEMY_PCI_IOWIN_END		0x0000FFFF
1485 
1486 #ifdef CONFIG_PCI
1487 
1488 #define IOPORT_RESOURCE_START	0x00001000	/* skip legacy probing */
1489 #define IOPORT_RESOURCE_END	0xffffffff
1490 #define IOMEM_RESOURCE_START	0x10000000
1491 #define IOMEM_RESOURCE_END	0xfffffffffULL
1492 
1493 #else
1494 
1495 /* Don't allow any legacy ports probing */
1496 #define IOPORT_RESOURCE_START	0x10000000
1497 #define IOPORT_RESOURCE_END	0xffffffff
1498 #define IOMEM_RESOURCE_START	0x10000000
1499 #define IOMEM_RESOURCE_END	0xfffffffffULL
1500 
1501 #endif
1502 
1503 /* PCI controller block register offsets */
1504 #define PCI_REG_CMEM		0x0000
1505 #define PCI_REG_CONFIG		0x0004
1506 #define PCI_REG_B2BMASK_CCH	0x0008
1507 #define PCI_REG_B2BBASE0_VID	0x000C
1508 #define PCI_REG_B2BBASE1_SID	0x0010
1509 #define PCI_REG_MWMASK_DEV	0x0014
1510 #define PCI_REG_MWBASE_REV_CCL	0x0018
1511 #define PCI_REG_ERR_ADDR	0x001C
1512 #define PCI_REG_SPEC_INTACK	0x0020
1513 #define PCI_REG_ID		0x0100
1514 #define PCI_REG_STATCMD		0x0104
1515 #define PCI_REG_CLASSREV	0x0108
1516 #define PCI_REG_PARAM		0x010C
1517 #define PCI_REG_MBAR		0x0110
1518 #define PCI_REG_TIMEOUT		0x0140
1519 
1520 /* PCI controller block register bits */
1521 #define PCI_CMEM_E		(1 << 28)	/* enable cacheable memory */
1522 #define PCI_CMEM_CMBASE(x)	(((x) & 0x3fff) << 14)
1523 #define PCI_CMEM_CMMASK(x)	((x) & 0x3fff)
1524 #define PCI_CONFIG_ERD		(1 << 27) /* pci error during R/W */
1525 #define PCI_CONFIG_ET		(1 << 26) /* error in target mode */
1526 #define PCI_CONFIG_EF		(1 << 25) /* fatal error */
1527 #define PCI_CONFIG_EP		(1 << 24) /* parity error */
1528 #define PCI_CONFIG_EM		(1 << 23) /* multiple errors */
1529 #define PCI_CONFIG_BM		(1 << 22) /* bad master error */
1530 #define PCI_CONFIG_PD		(1 << 20) /* PCI Disable */
1531 #define PCI_CONFIG_BME		(1 << 19) /* Byte Mask Enable for reads */
1532 #define PCI_CONFIG_NC		(1 << 16) /* mark mem access non-coherent */
1533 #define PCI_CONFIG_IA		(1 << 15) /* INTA# enabled (target mode) */
1534 #define PCI_CONFIG_IP		(1 << 13) /* int on PCI_PERR# */
1535 #define PCI_CONFIG_IS		(1 << 12) /* int on PCI_SERR# */
1536 #define PCI_CONFIG_IMM		(1 << 11) /* int on master abort */
1537 #define PCI_CONFIG_ITM		(1 << 10) /* int on target abort (as master) */
1538 #define PCI_CONFIG_ITT		(1 << 9)  /* int on target abort (as target) */
1539 #define PCI_CONFIG_IPB		(1 << 8)  /* int on PERR# in bus master acc */
1540 #define PCI_CONFIG_SIC_NO	(0 << 6)  /* no byte mask changes */
1541 #define PCI_CONFIG_SIC_BA_ADR	(1 << 6)  /* on byte/hw acc, invert adr bits */
1542 #define PCI_CONFIG_SIC_HWA_DAT	(2 << 6)  /* on halfword acc, swap data */
1543 #define PCI_CONFIG_SIC_ALL	(3 << 6)  /* swap data bytes on all accesses */
1544 #define PCI_CONFIG_ST		(1 << 5)  /* swap data by target transactions */
1545 #define PCI_CONFIG_SM		(1 << 4)  /* swap data from PCI ctl */
1546 #define PCI_CONFIG_AEN		(1 << 3)  /* enable internal arbiter */
1547 #define PCI_CONFIG_R2H		(1 << 2)  /* REQ2# to hi-prio arbiter */
1548 #define PCI_CONFIG_R1H		(1 << 1)  /* REQ1# to hi-prio arbiter */
1549 #define PCI_CONFIG_CH		(1 << 0)  /* PCI ctl to hi-prio arbiter */
1550 #define PCI_B2BMASK_B2BMASK(x)	(((x) & 0xffff) << 16)
1551 #define PCI_B2BMASK_CCH(x)	((x) & 0xffff) /* 16 upper bits of class code */
1552 #define PCI_B2BBASE0_VID_B0(x)	(((x) & 0xffff) << 16)
1553 #define PCI_B2BBASE0_VID_SV(x)	((x) & 0xffff)
1554 #define PCI_B2BBASE1_SID_B1(x)	(((x) & 0xffff) << 16)
1555 #define PCI_B2BBASE1_SID_SI(x)	((x) & 0xffff)
1556 #define PCI_MWMASKDEV_MWMASK(x) (((x) & 0xffff) << 16)
1557 #define PCI_MWMASKDEV_DEVID(x)	((x) & 0xffff)
1558 #define PCI_MWBASEREVCCL_BASE(x) (((x) & 0xffff) << 16)
1559 #define PCI_MWBASEREVCCL_REV(x)	 (((x) & 0xff) << 8)
1560 #define PCI_MWBASEREVCCL_CCL(x)	 ((x) & 0xff)
1561 #define PCI_ID_DID(x)		(((x) & 0xffff) << 16)
1562 #define PCI_ID_VID(x)		((x) & 0xffff)
1563 #define PCI_STATCMD_STATUS(x)	(((x) & 0xffff) << 16)
1564 #define PCI_STATCMD_CMD(x)	((x) & 0xffff)
1565 #define PCI_CLASSREV_CLASS(x)	(((x) & 0x00ffffff) << 8)
1566 #define PCI_CLASSREV_REV(x)	((x) & 0xff)
1567 #define PCI_PARAM_BIST(x)	(((x) & 0xff) << 24)
1568 #define PCI_PARAM_HT(x)		(((x) & 0xff) << 16)
1569 #define PCI_PARAM_LT(x)		(((x) & 0xff) << 8)
1570 #define PCI_PARAM_CLS(x)	((x) & 0xff)
1571 #define PCI_TIMEOUT_RETRIES(x)	(((x) & 0xff) << 8)	/* max retries */
1572 #define PCI_TIMEOUT_TO(x)	((x) & 0xff)	/* target ready timeout */
1573 
1574 #endif
1575