56f63030ce822919b7764dca1b5e4da0f20ec990
[openwrt/svn-archive/archive.git] / target / linux / atheros-2.6 / files / arch / mips / atheros / ar531x.h
1 #ifndef __AR531X_H
2 #define __AR531X_H
3
4 #include <asm/cpu-info.h>
5 #include <ar531x_platform.h>
6 #include "ar5312.h"
7 #include "ar5315.h"
8
9 /*
10 * Atheros CPUs before the AR2315 are using MIPS 4Kc core, later designs are
11 * using MIPS 4KEc R2 core. This makes it easy to determine the board at runtime.
12 */
13 #ifdef CONFIG_ATHEROS_AR5312
14 #define DO_AR5312(...) \
15 if (current_cpu_data.cputype != CPU_4KEC) { \
16 __VA_ARGS__ \
17 }
18 #else
19 #define DO_AR5312(...)
20 #endif
21 #ifdef CONFIG_ATHEROS_AR5315
22 #define DO_AR5315(...) \
23 if (current_cpu_data.cputype == CPU_4KEC) { \
24 __VA_ARGS__ \
25 }
26 #else
27 #define DO_AR5315(...)
28 #endif
29
30 #include <irq.h>
31
32 #define AR531X_HIGH_PRIO 0x10
33 #define AR531X_MISC_IRQ_BASE 0x20
34 #define AR531X_GPIO_IRQ_BASE 0x30
35
36 /* Software's idea of interrupts handled by "CPU Interrupt Controller" */
37 #define AR531X_IRQ_NONE MIPS_CPU_IRQ_BASE+0
38 #define AR531X_IRQ_CPU_CLOCK MIPS_CPU_IRQ_BASE+7 /* C0_CAUSE: 0x8000 */
39
40 /* Miscellaneous interrupts, which share IP6 */
41 #define AR531X_MISC_IRQ_NONE AR531X_MISC_IRQ_BASE+0
42 #define AR531X_MISC_IRQ_TIMER AR531X_MISC_IRQ_BASE+1
43 #define AR531X_MISC_IRQ_AHB_PROC AR531X_MISC_IRQ_BASE+2
44 #define AR531X_MISC_IRQ_AHB_DMA AR531X_MISC_IRQ_BASE+3
45 #define AR531X_MISC_IRQ_GPIO AR531X_MISC_IRQ_BASE+4
46 #define AR531X_MISC_IRQ_UART0 AR531X_MISC_IRQ_BASE+5
47 #define AR531X_MISC_IRQ_UART0_DMA AR531X_MISC_IRQ_BASE+6
48 #define AR531X_MISC_IRQ_WATCHDOG AR531X_MISC_IRQ_BASE+7
49 #define AR531X_MISC_IRQ_LOCAL AR531X_MISC_IRQ_BASE+8
50 #define AR531X_MISC_IRQ_COUNT 9
51
52 /* GPIO Interrupts [0..7], share AR531X_MISC_IRQ_GPIO */
53 #define AR531X_GPIO_IRQ_NONE AR531X_MISC_IRQ_BASE+0
54 #define AR531X_GPIO_IRQ(n) AR531X_MISC_IRQ_BASE+(n)+1
55 #define AR531X_GPIO_IRQ_COUNT 22
56
57 #define sysRegRead(phys) \
58 (*(volatile u32 *)KSEG1ADDR(phys))
59
60 #define sysRegWrite(phys, val) \
61 ((*(volatile u32 *)KSEG1ADDR(phys)) = (val))
62
63 /*
64 * This is board-specific data that is stored in a "fixed" location in flash.
65 * It is shared across operating systems, so it should not be changed lightly.
66 * The main reason we need it is in order to extract the ethernet MAC
67 * address(es).
68 */
69 struct ar531x_boarddata {
70 u32 magic; /* board data is valid */
71 #define AR531X_BD_MAGIC 0x35333131 /* "5311", for all 531x platforms */
72 u16 cksum; /* checksum (starting with BD_REV 2) */
73 u16 rev; /* revision of this struct */
74 #define BD_REV 4
75 char boardName[64]; /* Name of board */
76 u16 major; /* Board major number */
77 u16 minor; /* Board minor number */
78 u32 config; /* Board configuration */
79 #define BD_ENET0 0x00000001 /* ENET0 is stuffed */
80 #define BD_ENET1 0x00000002 /* ENET1 is stuffed */
81 #define BD_UART1 0x00000004 /* UART1 is stuffed */
82 #define BD_UART0 0x00000008 /* UART0 is stuffed (dma) */
83 #define BD_RSTFACTORY 0x00000010 /* Reset factory defaults stuffed */
84 #define BD_SYSLED 0x00000020 /* System LED stuffed */
85 #define BD_EXTUARTCLK 0x00000040 /* External UART clock */
86 #define BD_CPUFREQ 0x00000080 /* cpu freq is valid in nvram */
87 #define BD_SYSFREQ 0x00000100 /* sys freq is set in nvram */
88 #define BD_WLAN0 0x00000200 /* Enable WLAN0 */
89 #define BD_MEMCAP 0x00000400 /* CAP SDRAM @ memCap for testing */
90 #define BD_DISWATCHDOG 0x00000800 /* disable system watchdog */
91 #define BD_WLAN1 0x00001000 /* Enable WLAN1 (ar5212) */
92 #define BD_ISCASPER 0x00002000 /* FLAG for AR2312 */
93 #define BD_WLAN0_2G_EN 0x00004000 /* FLAG for radio0_2G */
94 #define BD_WLAN0_5G_EN 0x00008000 /* FLAG for radio0_2G */
95 #define BD_WLAN1_2G_EN 0x00020000 /* FLAG for radio0_2G */
96 #define BD_WLAN1_5G_EN 0x00040000 /* FLAG for radio0_2G */
97 u16 resetConfigGpio; /* Reset factory GPIO pin */
98 u16 sysLedGpio; /* System LED GPIO pin */
99
100 u32 cpuFreq; /* CPU core frequency in Hz */
101 u32 sysFreq; /* System frequency in Hz */
102 u32 cntFreq; /* Calculated C0_COUNT frequency */
103
104 u8 wlan0Mac[6];
105 u8 enet0Mac[6];
106 u8 enet1Mac[6];
107
108 u16 pciId; /* Pseudo PCIID for common code */
109 u16 memCap; /* cap bank1 in MB */
110
111 /* version 3 */
112 u8 wlan1Mac[6]; /* (ar5212) */
113 };
114
115 #define BOARD_CONFIG_BUFSZ 0x1000
116
117 extern char *board_config, *radio_config;
118 extern void serial_setup(unsigned long mapbase, unsigned int uartclk);
119 extern int ar531x_find_config(char *flash_limit);
120
121 extern void ar5312_prom_init(void);
122 extern void ar5312_misc_intr_init(int irq_base);
123 extern void ar5312_plat_setup(void);
124 extern asmlinkage void ar5312_irq_dispatch(void);
125
126 extern void ar5315_prom_init(void);
127 extern void ar5315_misc_intr_init(int irq_base);
128 extern void ar5315_plat_setup(void);
129 extern asmlinkage void ar5315_irq_dispatch(void);
130
131 #endif