fe94c3ffc19c3333bd615591fa85aefe8d468895
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
7 * Copyright (C) 2006 FON Technology, SL.
8 * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
9 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
13 * Platform devices for Atheros SoCs
16 #include <linux/autoconf.h>
17 #include <linux/init.h>
18 #include <linux/module.h>
19 #include <linux/types.h>
20 #include <linux/string.h>
21 #include <linux/platform_device.h>
22 #include <linux/kernel.h>
23 #include <linux/serial.h>
24 #include <linux/serial_core.h>
25 #include <asm/bootinfo.h>
29 char *board_config
, *radio_config
;
31 static u8
*find_board_config(char *flash_limit
)
36 for (addr
= (char *) (flash_limit
- 0x1000);
37 addr
>= (char *) (flash_limit
- 0x30000);
40 if ( *(int *)addr
== 0x35333131) {
41 /* config magic found */
48 printk("WARNING: No board configuration data found!\n");
55 static u8
*find_radio_config(char *flash_limit
, char *board_config
)
61 * Now find the start of Radio Configuration data, using heuristics:
62 * Search forward from Board Configuration data by 0x1000 bytes
63 * at a time until we find non-0xffffffff.
66 for (radio_config
= (u32
) board_config
+ 0x1000;
67 (radio_config
< (u32
) flash_limit
);
68 radio_config
+= 0x1000) {
69 if (*(int *)radio_config
!= 0xffffffff) {
75 #ifdef CONFIG_ATHEROS_AR5315
76 if (!dataFound
) { /* AR2316 relocates radio config to new location */
77 for (radio_config
= (u32
) board_config
+ 0xf8;
78 (radio_config
< (u32
) flash_limit
- 0x1000 + 0xf8);
79 radio_config
+= 0x1000) {
80 if (*(int *)radio_config
!= 0xffffffff) {
89 printk("Could not find Radio Configuration data\n");
93 return (u8
*) radio_config
;
96 int __init
ar531x_find_config(char *flash_limit
)
98 unsigned int rcfg_size
;
101 /* Copy the board and radio data to RAM, because with the new
102 * spiflash driver, accessing the mapped memory directly is no
105 bcfg
= find_board_config(flash_limit
);
109 board_config
= kmalloc(0x1000, GFP_KERNEL
);
110 memcpy(board_config
, bcfg
, 0x100);
112 /* Radio config starts 0x100 bytes after board config, regardless
113 * of what the physical layout on the flash chip looks like */
115 rcfg
= find_radio_config(flash_limit
, bcfg
);
119 printk("Radio config found at offset 0x%x\n", rcfg
- bcfg
);
120 radio_config
= board_config
+ 0x100 + ((rcfg
- bcfg
) & 0xfff);
121 rcfg_size
= 0x1000 - ((rcfg
- bcfg
) & 0xfff);
122 memcpy(radio_config
, rcfg
, rcfg_size
);
127 void __init
serial_setup(unsigned long mapbase
, unsigned int uartclk
)
131 memset(&s
, 0, sizeof(s
));
133 s
.flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
;
135 s
.irq
= AR531X_MISC_IRQ_UART0
;
139 s
.membase
= (void __iomem
*)s
.mapbase
;
141 early_serial_setup(&s
);
144 void __init
plat_mem_setup(void)
146 switch(mips_machtype
) {
147 #ifdef CONFIG_ATHEROS_AR5312
148 case MACH_ATHEROS_AR5312
:
152 #ifdef CONFIG_ATHEROS_AR5315
153 case MACH_ATHEROS_AR5315
:
159 /* Disable data watchpoints */
160 write_c0_watchlo0(0);
163 const char *get_system_type(void)
165 switch (mips_machtype
) {
166 #ifdef CONFIG_ATHEROS_AR5312
167 case MACH_ATHEROS_AR5312
:
168 return "Atheros AR5312\n";
170 #ifdef CONFIG_ATHEROS_AR5315
171 case MACH_ATHEROS_AR5315
:
172 return "Atheros AR5315\n";
175 return "Atheros (unknown)";
178 void __init
plat_timer_setup(struct irqaction
*irq
)
182 /* Usually irq is timer_irqaction (timer_interrupt) */
183 setup_irq(AR531X_IRQ_CPU_CLOCK
, irq
);
185 /* to generate the first CPU timer interrupt */
186 count
= read_c0_count();
187 write_c0_compare(count
+ 1000);
This page took 0.043339 seconds and 3 git commands to generate.