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