atheros: v3.18: update register names
[librecmc/librecmc.git] / target / linux / atheros / patches-3.18 / 100-board.patch
1 --- a/arch/mips/Kconfig
2 +++ b/arch/mips/Kconfig
3 @@ -96,6 +96,19 @@ config AR7
4           Support for the Texas Instruments AR7 System-on-a-Chip
5           family: TNETD7100, 7200 and 7300.
6  
7 +config ATH25
8 +       bool "Atheros 231x/531x SoC support"
9 +       select CEVT_R4K
10 +       select CSRC_R4K
11 +       select DMA_NONCOHERENT
12 +       select IRQ_CPU
13 +       select SYS_HAS_CPU_MIPS32_R1
14 +       select SYS_SUPPORTS_BIG_ENDIAN
15 +       select SYS_SUPPORTS_32BIT_KERNEL
16 +       select ARCH_REQUIRE_GPIOLIB
17 +       help
18 +         Support for AR231x and AR531x based boards
19 +
20  config ATH79
21         bool "Atheros AR71XX/AR724X/AR913X based boards"
22         select ARCH_REQUIRE_GPIOLIB
23 @@ -834,6 +847,7 @@ config MIPS_PARAVIRT
24  
25  endchoice
26  
27 +source "arch/mips/ath25/Kconfig"
28  source "arch/mips/alchemy/Kconfig"
29  source "arch/mips/ath79/Kconfig"
30  source "arch/mips/bcm47xx/Kconfig"
31 --- a/arch/mips/Kbuild.platforms
32 +++ b/arch/mips/Kbuild.platforms
33 @@ -2,6 +2,7 @@
34  
35  platforms += alchemy
36  platforms += ar7
37 +platforms += ath25
38  platforms += ath79
39  platforms += bcm47xx
40  platforms += bcm63xx
41 --- /dev/null
42 +++ b/arch/mips/ath25/Platform
43 @@ -0,0 +1,6 @@
44 +#
45 +# Atheros AR531X/AR231X WiSoC
46 +#
47 +platform-$(CONFIG_ATH25)       += ath25/
48 +cflags-$(CONFIG_ATH25)         += -I$(srctree)/arch/mips/include/asm/mach-ath25
49 +load-$(CONFIG_ATH25)           += 0xffffffff80041000
50 --- /dev/null
51 +++ b/arch/mips/ath25/Kconfig
52 @@ -0,0 +1,9 @@
53 +config SOC_AR5312
54 +       bool "Atheros 5312/2312+ support"
55 +       depends on ATH25
56 +       default y
57 +
58 +config SOC_AR2315
59 +       bool "Atheros 2315+ support"
60 +       depends on ATH25
61 +       default y
62 --- /dev/null
63 +++ b/arch/mips/ath25/Makefile
64 @@ -0,0 +1,13 @@
65 +#
66 +# This file is subject to the terms and conditions of the GNU General Public
67 +# License.  See the file "COPYING" in the main directory of this archive
68 +# for more details.
69 +#
70 +# Copyright (C) 2006 FON Technology, SL.
71 +# Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
72 +# Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
73 +#
74 +
75 +obj-y += board.o prom.o devices.o
76 +obj-$(CONFIG_SOC_AR5312) += ar5312.o
77 +obj-$(CONFIG_SOC_AR2315) += ar2315.o
78 --- /dev/null
79 +++ b/arch/mips/ath25/board.c
80 @@ -0,0 +1,244 @@
81 +/*
82 + * This file is subject to the terms and conditions of the GNU General Public
83 + * License.  See the file "COPYING" in the main directory of this archive
84 + * for more details.
85 + *
86 + * Copyright (C) 2003 Atheros Communications, Inc.,  All Rights Reserved.
87 + * Copyright (C) 2006 FON Technology, SL.
88 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
89 + * Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
90 + */
91 +
92 +#include <generated/autoconf.h>
93 +#include <linux/init.h>
94 +#include <linux/module.h>
95 +#include <linux/types.h>
96 +#include <linux/string.h>
97 +#include <linux/platform_device.h>
98 +#include <linux/kernel.h>
99 +#include <linux/random.h>
100 +#include <linux/etherdevice.h>
101 +#include <linux/irq.h>
102 +#include <linux/io.h>
103 +#include <asm/irq_cpu.h>
104 +#include <asm/reboot.h>
105 +#include <asm/bootinfo.h>
106 +#include <asm/time.h>
107 +
108 +#include <ath25_platform.h>
109 +#include "devices.h"
110 +#include "ar5312.h"
111 +#include "ar2315.h"
112 +
113 +void (*ath25_irq_dispatch)(void);
114 +
115 +static inline bool check_radio_magic(const void __iomem *addr)
116 +{
117 +       addr += 0x7a; /* offset for flash magic */
118 +       return (__raw_readb(addr) == 0x5a) && (__raw_readb(addr + 1) == 0xa5);
119 +}
120 +
121 +static inline bool check_notempty(const void __iomem *addr)
122 +{
123 +       return __raw_readl(addr) != 0xffffffff;
124 +}
125 +
126 +static inline bool check_board_data(const void __iomem *addr, bool broken)
127 +{
128 +       /* config magic found */
129 +       if (__raw_readl(addr) == ATH25_BD_MAGIC)
130 +               return true;
131 +
132 +       if (!broken)
133 +               return false;
134 +
135 +       /* broken board data detected, use radio data to find the
136 +        * offset, user will fix this */
137 +
138 +       if (check_radio_magic(addr + 0x1000))
139 +               return true;
140 +       if (check_radio_magic(addr + 0xf8))
141 +               return true;
142 +
143 +       return false;
144 +}
145 +
146 +static const void __iomem * __init find_board_config(const void __iomem *limit,
147 +                                                    const bool broken)
148 +{
149 +       const void __iomem *addr;
150 +       const void __iomem *begin = limit - 0x1000;
151 +       const void __iomem *end = limit - 0x30000;
152 +
153 +       for (addr = begin; addr >= end; addr -= 0x1000)
154 +               if (check_board_data(addr, broken))
155 +                       return addr;
156 +
157 +       return NULL;
158 +}
159 +
160 +static const void __iomem * __init find_radio_config(const void __iomem *limit,
161 +                                                    const void __iomem *bcfg)
162 +{
163 +       const void __iomem *rcfg, *begin, *end;
164 +
165 +       /*
166 +        * Now find the start of Radio Configuration data, using heuristics:
167 +        * Search forward from Board Configuration data by 0x1000 bytes
168 +        * at a time until we find non-0xffffffff.
169 +        */
170 +       begin = bcfg + 0x1000;
171 +       end = limit;
172 +       for (rcfg = begin; rcfg < end; rcfg += 0x1000)
173 +               if (check_notempty(rcfg) && check_radio_magic(rcfg))
174 +                       return rcfg;
175 +
176 +       /* AR2316 relocates radio config to new location */
177 +       begin = bcfg + 0xf8;
178 +       end = limit - 0x1000 + 0xf8;
179 +       for (rcfg = begin; rcfg < end; rcfg += 0x1000)
180 +               if (check_notempty(rcfg) && check_radio_magic(rcfg))
181 +                       return rcfg;
182 +
183 +       return NULL;
184 +}
185 +
186 +/*
187 + * NB: Search region size could be larger than the actual flash size,
188 + * but this shouldn't be a problem here, because the flash
189 + * will simply be mapped multiple times.
190 + */
191 +int __init ath25_find_config(phys_addr_t base, unsigned long size)
192 +{
193 +       const void __iomem *flash_base, *flash_limit;
194 +       struct ath25_boarddata *config;
195 +       unsigned int rcfg_size;
196 +       int broken_boarddata = 0;
197 +       const void __iomem *bcfg, *rcfg;
198 +       u8 *board_data;
199 +       u8 *radio_data;
200 +       u8 *mac_addr;
201 +       u32 offset;
202 +
203 +       flash_base = ioremap_nocache(base, size);
204 +       flash_limit = flash_base + size;
205 +
206 +       ath25_board.config = NULL;
207 +       ath25_board.radio = NULL;
208 +
209 +       /* Copy the board and radio data to RAM, because accessing the mapped
210 +        * memory of the flash directly after booting is not safe */
211 +
212 +       /* Try to find valid board and radio data */
213 +       bcfg = find_board_config(flash_limit, false);
214 +
215 +       /* If that fails, try to at least find valid radio data */
216 +       if (!bcfg) {
217 +               bcfg = find_board_config(flash_limit, true);
218 +               broken_boarddata = 1;
219 +       }
220 +
221 +       if (!bcfg) {
222 +               pr_warn("WARNING: No board configuration data found!\n");
223 +               goto error;
224 +       }
225 +
226 +       board_data = kzalloc(BOARD_CONFIG_BUFSZ, GFP_KERNEL);
227 +       ath25_board.config = (struct ath25_boarddata *)board_data;
228 +       memcpy_fromio(board_data, bcfg, 0x100);
229 +       if (broken_boarddata) {
230 +               pr_warn("WARNING: broken board data detected\n");
231 +               config = ath25_board.config;
232 +               if (is_zero_ether_addr(config->enet0_mac)) {
233 +                       pr_info("Fixing up empty mac addresses\n");
234 +                       config->reset_config_gpio = 0xffff;
235 +                       config->sys_led_gpio = 0xffff;
236 +                       random_ether_addr(config->wlan0_mac);
237 +                       config->wlan0_mac[0] &= ~0x06;
238 +                       random_ether_addr(config->enet0_mac);
239 +                       random_ether_addr(config->enet1_mac);
240 +               }
241 +       }
242 +
243 +       /* Radio config starts 0x100 bytes after board config, regardless
244 +        * of what the physical layout on the flash chip looks like */
245 +
246 +       rcfg = find_radio_config(flash_limit, bcfg);
247 +       if (!rcfg) {
248 +               pr_warn("WARNING: Could not find Radio Configuration data\n");
249 +               goto error;
250 +       }
251 +
252 +       radio_data = board_data + 0x100 + ((rcfg - bcfg) & 0xfff);
253 +       ath25_board.radio = radio_data;
254 +       offset = radio_data - board_data;
255 +       pr_info("Radio config found at offset 0x%x (0x%x)\n", rcfg - bcfg,
256 +               offset);
257 +       rcfg_size = BOARD_CONFIG_BUFSZ - offset;
258 +       memcpy_fromio(radio_data, rcfg, rcfg_size);
259 +
260 +       mac_addr = &radio_data[0x1d * 2];
261 +       if (is_broadcast_ether_addr(mac_addr)) {
262 +               pr_info("Radio MAC is blank; using board-data\n");
263 +               ether_addr_copy(mac_addr, ath25_board.config->wlan0_mac);
264 +       }
265 +
266 +       iounmap(flash_base);
267 +
268 +       return 0;
269 +
270 +error:
271 +       iounmap(flash_base);
272 +       return -ENODEV;
273 +}
274 +
275 +static void ath25_halt(void)
276 +{
277 +       local_irq_disable();
278 +       while (1)
279 +               ;
280 +}
281 +
282 +void __init plat_mem_setup(void)
283 +{
284 +       _machine_halt = ath25_halt;
285 +       pm_power_off = ath25_halt;
286 +
287 +       if (is_ar5312())
288 +               ar5312_plat_mem_setup();
289 +       else
290 +               ar2315_plat_mem_setup();
291 +
292 +       /* Disable data watchpoints */
293 +       write_c0_watchlo0(0);
294 +}
295 +
296 +asmlinkage void plat_irq_dispatch(void)
297 +{
298 +       ath25_irq_dispatch();
299 +}
300 +
301 +void __init plat_time_init(void)
302 +{
303 +       if (is_ar5312())
304 +               ar5312_plat_time_init();
305 +       else
306 +               ar2315_plat_time_init();
307 +}
308 +
309 +unsigned int __cpuinit get_c0_compare_int(void)
310 +{
311 +       return CP0_LEGACY_COMPARE_IRQ;
312 +}
313 +
314 +void __init arch_init_irq(void)
315 +{
316 +       clear_c0_status(ST0_IM);
317 +       mips_cpu_irq_init();
318 +
319 +       /* Initialize interrupt controllers */
320 +       if (is_ar5312())
321 +               ar5312_arch_init_irq();
322 +       else
323 +               ar2315_arch_init_irq();
324 +}
325 --- /dev/null
326 +++ b/arch/mips/ath25/prom.c
327 @@ -0,0 +1,26 @@
328 +/*
329 + * This file is subject to the terms and conditions of the GNU General Public
330 + * License.  See the file "COPYING" in the main directory of this archive
331 + * for more details.
332 + *
333 + * Copyright MontaVista Software Inc
334 + * Copyright (C) 2003 Atheros Communications, Inc.,  All Rights Reserved.
335 + * Copyright (C) 2006 FON Technology, SL.
336 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
337 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
338 + */
339 +
340 +/*
341 + * Prom setup file for ar231x
342 + */
343 +
344 +#include <linux/init.h>
345 +#include <asm/bootinfo.h>
346 +
347 +void __init prom_init(void)
348 +{
349 +}
350 +
351 +void __init prom_free_prom_memory(void)
352 +{
353 +}
354 --- /dev/null
355 +++ b/arch/mips/include/asm/mach-ath25/ath25_platform.h
356 @@ -0,0 +1,84 @@
357 +#ifndef __ASM_MACH_ATH25_PLATFORM_H
358 +#define __ASM_MACH_ATH25_PLATFORM_H
359 +
360 +#include <linux/etherdevice.h>
361 +
362 +/*
363 + * This is board-specific data that is stored in a "fixed" location in flash.
364 + * It is shared across operating systems, so it should not be changed lightly.
365 + * The main reason we need it is in order to extract the ethernet MAC
366 + * address(es).
367 + */
368 +struct ath25_boarddata {
369 +       u32 magic;                   /* board data is valid */
370 +#define ATH25_BD_MAGIC 0x35333131    /* "5311", for all 531x/231x platforms */
371 +       u16 cksum;                   /* checksum (starting with BD_REV 2) */
372 +       u16 rev;                     /* revision of this struct */
373 +#define BD_REV 4
374 +       char board_name[64];         /* Name of board */
375 +       u16 major;                   /* Board major number */
376 +       u16 minor;                   /* Board minor number */
377 +       u32 flags;                   /* Board configuration */
378 +#define BD_ENET0        0x00000001   /* ENET0 is stuffed */
379 +#define BD_ENET1        0x00000002   /* ENET1 is stuffed */
380 +#define BD_UART1        0x00000004   /* UART1 is stuffed */
381 +#define BD_UART0        0x00000008   /* UART0 is stuffed (dma) */
382 +#define BD_RSTFACTORY   0x00000010   /* Reset factory defaults stuffed */
383 +#define BD_SYSLED       0x00000020   /* System LED stuffed */
384 +#define BD_EXTUARTCLK   0x00000040   /* External UART clock */
385 +#define BD_CPUFREQ      0x00000080   /* cpu freq is valid in nvram */
386 +#define BD_SYSFREQ      0x00000100   /* sys freq is set in nvram */
387 +#define BD_WLAN0        0x00000200   /* Enable WLAN0 */
388 +#define BD_MEMCAP       0x00000400   /* CAP SDRAM @ mem_cap for testing */
389 +#define BD_DISWATCHDOG  0x00000800   /* disable system watchdog */
390 +#define BD_WLAN1        0x00001000   /* Enable WLAN1 (ar5212) */
391 +#define BD_ISCASPER     0x00002000   /* FLAG for AR2312 */
392 +#define BD_WLAN0_2G_EN  0x00004000   /* FLAG for radio0_2G */
393 +#define BD_WLAN0_5G_EN  0x00008000   /* FLAG for radio0_2G */
394 +#define BD_WLAN1_2G_EN  0x00020000   /* FLAG for radio0_2G */
395 +#define BD_WLAN1_5G_EN  0x00040000   /* FLAG for radio0_2G */
396 +       u16 reset_config_gpio;       /* Reset factory GPIO pin */
397 +       u16 sys_led_gpio;            /* System LED GPIO pin */
398 +
399 +       u32 cpu_freq;                /* CPU core frequency in Hz */
400 +       u32 sys_freq;                /* System frequency in Hz */
401 +       u32 cnt_freq;                /* Calculated C0_COUNT frequency */
402 +
403 +       u8  wlan0_mac[ETH_ALEN];
404 +       u8  enet0_mac[ETH_ALEN];
405 +       u8  enet1_mac[ETH_ALEN];
406 +
407 +       u16 pci_id;                  /* Pseudo PCIID for common code */
408 +       u16 mem_cap;                 /* cap bank1 in MB */
409 +
410 +       /* version 3 */
411 +       u8  wlan1_mac[ETH_ALEN];     /* (ar5212) */
412 +};
413 +
414 +#define BOARD_CONFIG_BUFSZ             0x1000
415 +
416 +/*
417 + * Platform device information for the Wireless MAC
418 + */
419 +struct ar231x_board_config {
420 +       u16 devid;
421 +
422 +       /* board config data */
423 +       struct ath25_boarddata *config;
424 +
425 +       /* radio calibration data */
426 +       const char *radio;
427 +};
428 +
429 +/*
430 + * Platform device information for the Ethernet MAC
431 + */
432 +struct ar231x_eth {
433 +       void (*reset_set)(u32);
434 +       void (*reset_clear)(u32);
435 +       u32 reset_mac;
436 +       u32 reset_phy;
437 +       char *macaddr;
438 +};
439 +
440 +#endif /* __ASM_MACH_ATH25_PLATFORM_H */
441 --- /dev/null
442 +++ b/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h
443 @@ -0,0 +1,64 @@
444 +/*
445 + *  Atheros AR231x/AR531x SoC specific CPU feature overrides
446 + *
447 + *  Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
448 + *
449 + *  This file was derived from: include/asm-mips/cpu-features.h
450 + *     Copyright (C) 2003, 2004 Ralf Baechle
451 + *     Copyright (C) 2004 Maciej W. Rozycki
452 + *
453 + *  This program is free software; you can redistribute it and/or modify it
454 + *  under the terms of the GNU General Public License version 2 as published
455 + *  by the Free Software Foundation.
456 + *
457 + */
458 +#ifndef __ASM_MACH_ATH25_CPU_FEATURE_OVERRIDES_H
459 +#define __ASM_MACH_ATH25_CPU_FEATURE_OVERRIDES_H
460 +
461 +/*
462 + * The Atheros AR531x/AR231x SoCs have MIPS 4Kc/4KEc core.
463 + */
464 +#define cpu_has_tlb                    1
465 +#define cpu_has_4kex                   1
466 +#define cpu_has_3k_cache               0
467 +#define cpu_has_4k_cache               1
468 +#define cpu_has_tx39_cache             0
469 +#define cpu_has_sb1_cache              0
470 +#define cpu_has_fpu                    0
471 +#define cpu_has_32fpr                  0
472 +#define cpu_has_counter                        1
473 +#define cpu_has_ejtag                  1
474 +
475 +#if !defined(CONFIG_SOC_AR5312)
476 +#  define cpu_has_llsc                 1
477 +#else
478 +/*
479 + * The MIPS 4Kc V0.9 core in the AR5312/AR2312 have problems with the
480 + * ll/sc instructions.
481 + */
482 +#  define cpu_has_llsc                 0
483 +#endif
484 +
485 +#define cpu_has_mips16                 0
486 +#define cpu_has_mdmx                   0
487 +#define cpu_has_mips3d                 0
488 +#define cpu_has_smartmips              0
489 +
490 +#define cpu_has_mips32r1               1
491 +
492 +#if !defined(CONFIG_SOC_AR5312)
493 +#  define cpu_has_mips32r2             1
494 +#endif
495 +
496 +#define cpu_has_mips64r1               0
497 +#define cpu_has_mips64r2               0
498 +
499 +#define cpu_has_dsp                    0
500 +#define cpu_has_mipsmt                 0
501 +
502 +#define cpu_has_64bits                 0
503 +#define cpu_has_64bit_zero_reg         0
504 +#define cpu_has_64bit_gp_regs          0
505 +#define cpu_has_64bit_addresses                0
506 +
507 +#endif /* __ASM_MACH_ATH25_CPU_FEATURE_OVERRIDES_H */
508 --- /dev/null
509 +++ b/arch/mips/include/asm/mach-ath25/dma-coherence.h
510 @@ -0,0 +1,82 @@
511 +/*
512 + * This file is subject to the terms and conditions of the GNU General Public
513 + * License.  See the file "COPYING" in the main directory of this archive
514 + * for more details.
515 + *
516 + * Copyright (C) 2006  Ralf Baechle <ralf@linux-mips.org>
517 + * Copyright (C) 2007  Felix Fietkau <nbd@openwrt.org>
518 + *
519 + */
520 +#ifndef __ASM_MACH_ATH25_DMA_COHERENCE_H
521 +#define __ASM_MACH_ATH25_DMA_COHERENCE_H
522 +
523 +#include <linux/device.h>
524 +
525 +/*
526 + * We need some arbitrary non-zero value to be programmed to the BAR1 register
527 + * of PCI host controller to enable DMA. The same value should be used as the
528 + * offset to calculate the physical address of DMA buffer for PCI devices.
529 + */
530 +#define AR2315_PCI_HOST_SDRAM_BASEADDR 0x20000000
531 +
532 +static inline dma_addr_t ath25_dev_offset(struct device *dev)
533 +{
534 +#ifdef CONFIG_PCI
535 +       extern struct bus_type pci_bus_type;
536 +
537 +       if (dev && dev->bus == &pci_bus_type)
538 +               return AR2315_PCI_HOST_SDRAM_BASEADDR;
539 +#endif
540 +       return 0;
541 +}
542 +
543 +static inline dma_addr_t
544 +plat_map_dma_mem(struct device *dev, void *addr, size_t size)
545 +{
546 +       return virt_to_phys(addr) + ath25_dev_offset(dev);
547 +}
548 +
549 +static inline dma_addr_t
550 +plat_map_dma_mem_page(struct device *dev, struct page *page)
551 +{
552 +       return page_to_phys(page) + ath25_dev_offset(dev);
553 +}
554 +
555 +static inline unsigned long
556 +plat_dma_addr_to_phys(struct device *dev, dma_addr_t dma_addr)
557 +{
558 +       return dma_addr - ath25_dev_offset(dev);
559 +}
560 +
561 +static inline void
562 +plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr, size_t size,
563 +                  enum dma_data_direction direction)
564 +{
565 +}
566 +
567 +static inline int plat_dma_supported(struct device *dev, u64 mask)
568 +{
569 +       return 1;
570 +}
571 +
572 +static inline void plat_extra_sync_for_device(struct device *dev)
573 +{
574 +}
575 +
576 +static inline int plat_dma_mapping_error(struct device *dev,
577 +                                        dma_addr_t dma_addr)
578 +{
579 +       return 0;
580 +}
581 +
582 +static inline int plat_device_is_coherent(struct device *dev)
583 +{
584 +#ifdef CONFIG_DMA_COHERENT
585 +       return 1;
586 +#endif
587 +#ifdef CONFIG_DMA_NONCOHERENT
588 +       return 0;
589 +#endif
590 +}
591 +
592 +#endif /* __ASM_MACH_ATH25_DMA_COHERENCE_H */
593 --- /dev/null
594 +++ b/arch/mips/include/asm/mach-ath25/gpio.h
595 @@ -0,0 +1,16 @@
596 +#ifndef __ASM_MACH_ATH25_GPIO_H
597 +#define __ASM_MACH_ATH25_GPIO_H
598 +
599 +#include <asm-generic/gpio.h>
600 +
601 +#define gpio_get_value __gpio_get_value
602 +#define gpio_set_value __gpio_set_value
603 +#define gpio_cansleep __gpio_cansleep
604 +#define gpio_to_irq __gpio_to_irq
605 +
606 +static inline int irq_to_gpio(unsigned irq)
607 +{
608 +       return -EINVAL;
609 +}
610 +
611 +#endif /* __ASM_MACH_ATH25_GPIO_H */
612 --- /dev/null
613 +++ b/arch/mips/include/asm/mach-ath25/war.h
614 @@ -0,0 +1,25 @@
615 +/*
616 + * This file is subject to the terms and conditions of the GNU General Public
617 + * License.  See the file "COPYING" in the main directory of this archive
618 + * for more details.
619 + *
620 + * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
621 + */
622 +#ifndef __ASM_MACH_ATH25_WAR_H
623 +#define __ASM_MACH_ATH25_WAR_H
624 +
625 +#define R4600_V1_INDEX_ICACHEOP_WAR    0
626 +#define R4600_V1_HIT_CACHEOP_WAR       0
627 +#define R4600_V2_HIT_CACHEOP_WAR       0
628 +#define R5432_CP0_INTERRUPT_WAR                0
629 +#define BCM1250_M3_WAR                 0
630 +#define SIBYTE_1956_WAR                        0
631 +#define MIPS4K_ICACHE_REFILL_WAR       0
632 +#define MIPS_CACHE_SYNC_WAR            0
633 +#define TX49XX_ICACHE_INDEX_INV_WAR    0
634 +#define RM9000_CDEX_SMP_WAR            0
635 +#define ICACHE_REFILLS_WORKAROUND_WAR  0
636 +#define R10000_LLSC_WAR                        0
637 +#define MIPS34K_MISSED_ITLB_WAR                0
638 +
639 +#endif /* __ASM_MACH_ATH25_WAR_H */
640 --- /dev/null
641 +++ b/arch/mips/ath25/ar2315_regs.h
642 @@ -0,0 +1,479 @@
643 +/*
644 + * Register definitions for AR2315+
645 + *
646 + * This file is subject to the terms and conditions of the GNU General Public
647 + * License.  See the file "COPYING" in the main directory of this archive
648 + * for more details.
649 + *
650 + * Copyright (C) 2003 Atheros Communications, Inc.,  All Rights Reserved.
651 + * Copyright (C) 2006 FON Technology, SL.
652 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
653 + * Copyright (C) 2006-2008 Felix Fietkau <nbd@openwrt.org>
654 + */
655 +
656 +#ifndef __ASM_MACH_ATH25_AR2315_REGS_H
657 +#define __ASM_MACH_ATH25_AR2315_REGS_H
658 +
659 +/*
660 + * IRQs
661 + */
662 +#define AR2315_IRQ_MISC                (MIPS_CPU_IRQ_BASE + 2) /* C0_CAUSE: 0x0400 */
663 +#define AR2315_IRQ_WLAN0       (MIPS_CPU_IRQ_BASE + 3) /* C0_CAUSE: 0x0800 */
664 +#define AR2315_IRQ_ENET0       (MIPS_CPU_IRQ_BASE + 4) /* C0_CAUSE: 0x1000 */
665 +#define AR2315_IRQ_LCBUS_PCI   (MIPS_CPU_IRQ_BASE + 5) /* C0_CAUSE: 0x2000 */
666 +#define AR2315_IRQ_WLAN0_POLL  (MIPS_CPU_IRQ_BASE + 6) /* C0_CAUSE: 0x4000 */
667 +
668 +/*
669 + * Miscellaneous interrupts, which share IP2.
670 + */
671 +#define AR2315_MISC_IRQ_UART0          (AR231X_MISC_IRQ_BASE+0)
672 +#define AR2315_MISC_IRQ_I2C_RSVD       (AR231X_MISC_IRQ_BASE+1)
673 +#define AR2315_MISC_IRQ_SPI            (AR231X_MISC_IRQ_BASE+2)
674 +#define AR2315_MISC_IRQ_AHB            (AR231X_MISC_IRQ_BASE+3)
675 +#define AR2315_MISC_IRQ_APB            (AR231X_MISC_IRQ_BASE+4)
676 +#define AR2315_MISC_IRQ_TIMER          (AR231X_MISC_IRQ_BASE+5)
677 +#define AR2315_MISC_IRQ_GPIO           (AR231X_MISC_IRQ_BASE+6)
678 +#define AR2315_MISC_IRQ_WATCHDOG       (AR231X_MISC_IRQ_BASE+7)
679 +#define AR2315_MISC_IRQ_IR_RSVD                (AR231X_MISC_IRQ_BASE+8)
680 +#define AR2315_MISC_IRQ_COUNT          9
681 +
682 +/*
683 + * Address map
684 + */
685 +#define AR2315_SPI_READ_BASE   0x08000000      /* SPI flash */
686 +#define AR2315_SPI_READ_SIZE   0x01000000
687 +#define AR2315_WLAN0_BASE      0x10000000      /* Wireless MMR */
688 +#define AR2315_PCI_BASE                0x10100000      /* PCI MMR */
689 +#define AR2315_PCI_SIZE                0x00001000
690 +#define AR2315_SDRAMCTL_BASE   0x10300000      /* SDRAM MMR */
691 +#define AR2315_SDRAMCTL_SIZE   0x00000020
692 +#define AR2315_LOCAL_BASE      0x10400000      /* Local bus MMR */
693 +#define AR2315_ENET0_BASE      0x10500000      /* Ethernet MMR */
694 +#define AR2315_RST_BASE                0x11000000      /* Reset control MMR */
695 +#define AR2315_RST_SIZE                0x00000100
696 +#define AR2315_UART0_BASE      0x11100000      /* UART MMR */
697 +#define AR2315_SPI_MMR_BASE    0x11300000      /* SPI flash MMR */
698 +#define AR2315_SPI_MMR_SIZE    0x00000010
699 +#define AR2315_PCI_EXT_BASE    0x80000000      /* PCI external */
700 +#define AR2315_PCI_EXT_SIZE    0x40000000
701 +
702 +/* MII registers offset inside Ethernet MMR region */
703 +#define AR2315_ENET0_MII_BASE  (AR2315_ENET0_BASE + 0x14)
704 +
705 +/*
706 + * Cold reset register
707 + */
708 +#define AR2315_COLD_RESET              0x0000
709 +
710 +#define AR2315_RESET_COLD_AHB              0x00000001
711 +#define AR2315_RESET_COLD_APB              0x00000002
712 +#define AR2315_RESET_COLD_CPU              0x00000004
713 +#define AR2315_RESET_COLD_CPUWARM          0x00000008
714 +#define AR2315_RESET_SYSTEM    \
715 +       (RESET_COLD_CPU |\
716 +        RESET_COLD_APB |\
717 +        RESET_COLD_AHB)                                   /* full system */
718 +#define AR2317_RESET_SYSTEM                0x00000010
719 +
720 +/*
721 + * Reset register
722 + */
723 +#define AR2315_RESET                   0x0004
724 +
725 +/* warm reset WLAN0 MAC */
726 +#define AR2315_RESET_WARM_WLAN0_MAC        0x00000001
727 +/* warm reset WLAN0 BaseBand */
728 +#define AR2315_RESET_WARM_WLAN0_BB         0x00000002
729 +/* warm reset MPEG-TS */
730 +#define AR2315_RESET_MPEGTS_RSVD           0x00000004
731 +/* warm reset PCI ahb/dma */
732 +#define AR2315_RESET_PCIDMA                0x00000008
733 +/* warm reset memory controller */
734 +#define AR2315_RESET_MEMCTL                0x00000010
735 +/* warm reset local bus */
736 +#define AR2315_RESET_LOCAL                 0x00000020
737 +/* warm reset I2C bus */
738 +#define AR2315_RESET_I2C_RSVD              0x00000040
739 +/* warm reset SPI interface */
740 +#define AR2315_RESET_SPI                   0x00000080
741 +/* warm reset UART0 */
742 +#define AR2315_RESET_UART0                 0x00000100
743 +/* warm reset IR interface */
744 +#define AR2315_RESET_IR_RSVD               0x00000200
745 +/* cold reset ENET0 phy */
746 +#define AR2315_RESET_EPHY0                 0x00000400
747 +/* cold reset ENET0 mac */
748 +#define AR2315_RESET_ENET0                 0x00000800
749 +
750 +/*
751 + * AHB master arbitration control
752 + */
753 +#define AR2315_AHB_ARB_CTL             0x0008
754 +
755 +/* CPU, default */
756 +#define AR2315_ARB_CPU                     0x00000001
757 +/* WLAN */
758 +#define AR2315_ARB_WLAN                    0x00000002
759 +/* MPEG-TS */
760 +#define AR2315_ARB_MPEGTS_RSVD             0x00000004
761 +/* LOCAL */
762 +#define AR2315_ARB_LOCAL                   0x00000008
763 +/* PCI */
764 +#define AR2315_ARB_PCI                     0x00000010
765 +/* Ethernet */
766 +#define AR2315_ARB_ETHERNET                0x00000020
767 +/* retry policy, debug only */
768 +#define AR2315_ARB_RETRY                   0x00000100
769 +
770 +/*
771 + * Config Register
772 + */
773 +#define AR2315_ENDIAN_CTL              0x000c
774 +
775 +/* EC - AHB bridge endianess */
776 +#define AR2315_CONFIG_AHB                  0x00000001
777 +/* WLAN byteswap */
778 +#define AR2315_CONFIG_WLAN                 0x00000002
779 +/* MPEG-TS byteswap */
780 +#define AR2315_CONFIG_MPEGTS_RSVD          0x00000004
781 +/* PCI byteswap */
782 +#define AR2315_CONFIG_PCI                  0x00000008
783 +/* Memory controller endianess */
784 +#define AR2315_CONFIG_MEMCTL               0x00000010
785 +/* Local bus byteswap */
786 +#define AR2315_CONFIG_LOCAL                0x00000020
787 +/* Ethernet byteswap */
788 +#define AR2315_CONFIG_ETHERNET             0x00000040
789 +
790 +/* CPU write buffer merge */
791 +#define AR2315_CONFIG_MERGE                0x00000200
792 +/* CPU big endian */
793 +#define AR2315_CONFIG_CPU                  0x00000400
794 +#define AR2315_CONFIG_PCIAHB               0x00000800
795 +#define AR2315_CONFIG_PCIAHB_BRIDGE        0x00001000
796 +/* SPI byteswap */
797 +#define AR2315_CONFIG_SPI                  0x00008000
798 +#define AR2315_CONFIG_CPU_DRAM             0x00010000
799 +#define AR2315_CONFIG_CPU_PCI              0x00020000
800 +#define AR2315_CONFIG_CPU_MMR              0x00040000
801 +#define AR2315_CONFIG_BIG                  0x00000400
802 +
803 +/*
804 + * NMI control
805 + */
806 +#define AR2315_NMI_CTL                 0x0010
807 +
808 +#define AR2315_NMI_EN  1
809 +
810 +/*
811 + * Revision Register - Initial value is 0x3010 (WMAC 3.0, AR231X 1.0).
812 + */
813 +#define AR2315_SREV                    0x0014
814 +
815 +#define AR2315_REV_MAJ                     0x00f0
816 +#define AR2315_REV_MAJ_S                   4
817 +#define AR2315_REV_MIN                     0x000f
818 +#define AR2315_REV_MIN_S                   0
819 +#define AR2315_REV_CHIP                    (AR2315_REV_MAJ|AR2315_REV_MIN)
820 +
821 +/*
822 + * Interface Enable
823 + */
824 +#define AR2315_IF_CTL                  0x0018
825 +
826 +#define AR2315_IF_MASK                     0x00000007
827 +#define AR2315_IF_DISABLED                 0
828 +#define AR2315_IF_PCI                      1
829 +#define AR2315_IF_TS_LOCAL                 2
830 +/* only for emulation with separate pins */
831 +#define AR2315_IF_ALL                      3
832 +#define AR2315_IF_LOCAL_HOST               0x00000008
833 +#define AR2315_IF_PCI_HOST                 0x00000010
834 +#define AR2315_IF_PCI_INTR                 0x00000020
835 +#define AR2315_IF_PCI_CLK_MASK             0x00030000
836 +#define AR2315_IF_PCI_CLK_INPUT            0
837 +#define AR2315_IF_PCI_CLK_OUTPUT_LOW       1
838 +#define AR2315_IF_PCI_CLK_OUTPUT_CLK       2
839 +#define AR2315_IF_PCI_CLK_OUTPUT_HIGH      3
840 +#define AR2315_IF_PCI_CLK_SHIFT            16
841 +
842 +/*
843 + * APB Interrupt control
844 + */
845 +
846 +#define AR2315_ISR                     0x0020
847 +#define AR2315_IMR                     0x0024
848 +#define AR2315_GISR                    0x0028
849 +
850 +#define AR2315_ISR_UART0       0x0001           /* high speed UART */
851 +#define AR2315_ISR_I2C_RSVD    0x0002           /* I2C bus */
852 +#define AR2315_ISR_SPI         0x0004           /* SPI bus */
853 +#define AR2315_ISR_AHB         0x0008           /* AHB error */
854 +#define AR2315_ISR_APB         0x0010           /* APB error */
855 +#define AR2315_ISR_TIMER       0x0020           /* timer */
856 +#define AR2315_ISR_GPIO                0x0040           /* GPIO */
857 +#define AR2315_ISR_WD          0x0080           /* watchdog */
858 +#define AR2315_ISR_IR_RSVD     0x0100           /* IR */
859 +
860 +#define AR2315_GISR_MISC       0x0001
861 +#define AR2315_GISR_WLAN0      0x0002
862 +#define AR2315_GISR_MPEGTS_RSVD        0x0004
863 +#define AR2315_GISR_LOCALPCI   0x0008
864 +#define AR2315_GISR_WMACPOLL   0x0010
865 +#define AR2315_GISR_TIMER      0x0020
866 +#define AR2315_GISR_ETHERNET   0x0040
867 +
868 +/*
869 + * Timers
870 + */
871 +#define AR2315_TIMER                   0x0030
872 +#define AR2315_RELOAD                  0x0034
873 +
874 +#define AR2315_WDT_TIMER               0x0038
875 +#define AR2315_WDT_CTRL                        0x003c
876 +
877 +#define AR2315_WDT_CTRL_IGNORE 0x00000000      /* ignore expiration */
878 +#define AR2315_WDT_CTRL_NMI    0x00000001      /* NMI on watchdog */
879 +#define AR2315_WDT_CTRL_RESET  0x00000002      /* reset on watchdog */
880 +
881 +/*
882 + * CPU Performance Counters
883 + */
884 +#define AR2315_PERFCNT0                        0x0048
885 +#define AR2315_PERFCNT1                        0x004c
886 +
887 +#define AR2315_PERF0_DATAHIT   0x0001  /* Count Data Cache Hits */
888 +#define AR2315_PERF0_DATAMISS  0x0002  /* Count Data Cache Misses */
889 +#define AR2315_PERF0_INSTHIT   0x0004  /* Count Instruction Cache Hits */
890 +#define AR2315_PERF0_INSTMISS  0x0008  /* Count Instruction Cache Misses */
891 +#define AR2315_PERF0_ACTIVE    0x0010  /* Count Active Processor Cycles */
892 +#define AR2315_PERF0_WBHIT     0x0020  /* Count CPU Write Buffer Hits */
893 +#define AR2315_PERF0_WBMISS    0x0040  /* Count CPU Write Buffer Misses */
894 +
895 +#define AR2315_PERF1_EB_ARDY   0x0001  /* Count EB_ARdy signal */
896 +#define AR2315_PERF1_EB_AVALID 0x0002  /* Count EB_AValid signal */
897 +#define AR2315_PERF1_EB_WDRDY  0x0004  /* Count EB_WDRdy signal */
898 +#define AR2315_PERF1_EB_RDVAL  0x0008  /* Count EB_RdVal signal */
899 +#define AR2315_PERF1_VRADDR    0x0010  /* Count valid read address cycles */
900 +#define AR2315_PERF1_VWADDR    0x0020  /* Count valid write address cycles */
901 +#define AR2315_PERF1_VWDATA    0x0040  /* Count valid write data cycles */
902 +
903 +/*
904 + * AHB Error Reporting.
905 + */
906 +#define AR2315_AHB_ERR0                        0x0050  /* error  */
907 +#define AR2315_AHB_ERR1                        0x0054  /* haddr  */
908 +#define AR2315_AHB_ERR2                        0x0058  /* hwdata */
909 +#define AR2315_AHB_ERR3                        0x005c  /* hrdata */
910 +#define AR2315_AHB_ERR4                        0x0060  /* status */
911 +
912 +#define AR2315_AHB_ERROR_DET   1 /* AHB Error has been detected,          */
913 +                                 /* write 1 to clear all bits in ERR0     */
914 +#define AR2315_AHB_ERROR_OVR   2 /* AHB Error overflow has been detected  */
915 +#define AR2315_AHB_ERROR_WDT   4 /* AHB Error due to wdt instead of hresp */
916 +
917 +#define AR2315_PROCERR_HMAST               0x0000000f
918 +#define AR2315_PROCERR_HMAST_DFLT          0
919 +#define AR2315_PROCERR_HMAST_WMAC          1
920 +#define AR2315_PROCERR_HMAST_ENET          2
921 +#define AR2315_PROCERR_HMAST_PCIENDPT      3
922 +#define AR2315_PROCERR_HMAST_LOCAL         4
923 +#define AR2315_PROCERR_HMAST_CPU           5
924 +#define AR2315_PROCERR_HMAST_PCITGT        6
925 +
926 +#define AR2315_PROCERR_HMAST_S             0
927 +#define AR2315_PROCERR_HWRITE              0x00000010
928 +#define AR2315_PROCERR_HSIZE               0x00000060
929 +#define AR2315_PROCERR_HSIZE_S             5
930 +#define AR2315_PROCERR_HTRANS              0x00000180
931 +#define AR2315_PROCERR_HTRANS_S            7
932 +#define AR2315_PROCERR_HBURST              0x00000e00
933 +#define AR2315_PROCERR_HBURST_S            9
934 +
935 +/*
936 + * Clock Control
937 + */
938 +#define AR2315_PLLC_CTL                        0x0064
939 +#define AR2315_PLLV_CTL                        0x0068
940 +#define AR2315_CPUCLK                  0x006c
941 +#define AR2315_AMBACLK                 0x0070
942 +#define AR2315_SYNCCLK                 0x0074
943 +#define AR2315_DSL_SLEEP_CTL           0x0080
944 +#define AR2315_DSL_SLEEP_DUR           0x0084
945 +
946 +/* PLLc Control fields */
947 +#define AR2315_PLLC_REF_DIV_M          0x00000003
948 +#define AR2315_PLLC_REF_DIV_S          0
949 +#define AR2315_PLLC_FDBACK_DIV_M       0x0000007c
950 +#define AR2315_PLLC_FDBACK_DIV_S       2
951 +#define AR2315_PLLC_ADD_FDBACK_DIV_M   0x00000080
952 +#define AR2315_PLLC_ADD_FDBACK_DIV_S   7
953 +#define AR2315_PLLC_CLKC_DIV_M         0x0001c000
954 +#define AR2315_PLLC_CLKC_DIV_S         14
955 +#define AR2315_PLLC_CLKM_DIV_M         0x00700000
956 +#define AR2315_PLLC_CLKM_DIV_S         20
957 +
958 +/* CPU CLK Control fields */
959 +#define AR2315_CPUCLK_CLK_SEL_M                0x00000003
960 +#define AR2315_CPUCLK_CLK_SEL_S                0
961 +#define AR2315_CPUCLK_CLK_DIV_M                0x0000000c
962 +#define AR2315_CPUCLK_CLK_DIV_S                2
963 +
964 +/* AMBA CLK Control fields */
965 +#define AR2315_AMBACLK_CLK_SEL_M       0x00000003
966 +#define AR2315_AMBACLK_CLK_SEL_S       0
967 +#define AR2315_AMBACLK_CLK_DIV_M       0x0000000c
968 +#define AR2315_AMBACLK_CLK_DIV_S       2
969 +
970 +/* GPIO MMR base address */
971 +#define AR2315_GPIO                    0x0088
972 +
973 +#define AR2315_RESET_GPIO       5
974 +
975 +/*
976 + *  PCI Clock Control
977 + */
978 +#define AR2315_PCICLK                  0x00a4
979 +
980 +#define AR2315_PCICLK_INPUT_M              0x3
981 +#define AR2315_PCICLK_INPUT_S              0
982 +
983 +#define AR2315_PCICLK_PLLC_CLKM            0
984 +#define AR2315_PCICLK_PLLC_CLKM1           1
985 +#define AR2315_PCICLK_PLLC_CLKC            2
986 +#define AR2315_PCICLK_REF_CLK              3
987 +
988 +#define AR2315_PCICLK_DIV_M                0xc
989 +#define AR2315_PCICLK_DIV_S                2
990 +
991 +#define AR2315_PCICLK_IN_FREQ              0
992 +#define AR2315_PCICLK_IN_FREQ_DIV_6        1
993 +#define AR2315_PCICLK_IN_FREQ_DIV_8        2
994 +#define AR2315_PCICLK_IN_FREQ_DIV_10       3
995 +
996 +/*
997 + * Observation Control Register
998 + */
999 +#define AR2315_OCR                     0x00b0
1000 +
1001 +#define AR2315_OCR_GPIO0_IRIN          0x00000040
1002 +#define AR2315_OCR_GPIO1_IROUT         0x00000080
1003 +#define AR2315_OCR_GPIO3_RXCLR         0x00000200
1004 +
1005 +/*
1006 + *  General Clock Control
1007 + */
1008 +#define AR2315_MISCCLK                 0x00b4
1009 +
1010 +#define AR2315_MISCCLK_PLLBYPASS_EN    0x00000001
1011 +#define AR2315_MISCCLK_PROCREFCLK      0x00000002
1012 +
1013 +/*
1014 + * SDRAM Controller
1015 + *   - No read or write buffers are included.
1016 + */
1017 +#define AR2315_MEM_CFG                 0x0000
1018 +#define AR2315_MEM_CTRL                        0x000c
1019 +#define AR2315_MEM_REF                 0x0010
1020 +
1021 +#define AR2315_MEM_CFG_DATA_WIDTH_M    0x00006000
1022 +#define AR2315_MEM_CFG_DATA_WIDTH_S    13
1023 +#define AR2315_MEM_CFG_COL_WIDTH_M     0x00001e00
1024 +#define AR2315_MEM_CFG_COL_WIDTH_S     9
1025 +#define AR2315_MEM_CFG_ROW_WIDTH_M     0x000001e0
1026 +#define AR2315_MEM_CFG_ROW_WIDTH_S     5
1027 +#define AR2315_MEM_CFG_BANKADDR_BITS_M 0x00000018
1028 +#define AR2315_MEM_CFG_BANKADDR_BITS_S 3
1029 +
1030 +/*
1031 + * Local Bus Interface Registers
1032 + */
1033 +#define AR2315_LB_CONFIG               0x0000
1034 +
1035 +#define AR2315_LBCONF_OE        0x00000001    /* =1 OE is low-true */
1036 +#define AR2315_LBCONF_CS0       0x00000002    /* =1 first CS is low-true */
1037 +#define AR2315_LBCONF_CS1       0x00000004    /* =1 2nd CS is low-true */
1038 +#define AR2315_LBCONF_RDY       0x00000008    /* =1 RDY is low-true */
1039 +#define AR2315_LBCONF_WE        0x00000010    /* =1 Write En is low-true */
1040 +#define AR2315_LBCONF_WAIT      0x00000020    /* =1 WAIT is low-true */
1041 +#define AR2315_LBCONF_ADS       0x00000040    /* =1 Adr Strobe is low-true */
1042 +#define AR2315_LBCONF_MOT       0x00000080    /* =0 Intel, =1 Motorola */
1043 +#define AR2315_LBCONF_8CS       0x00000100    /* =1 8 bits CS, 0= 16bits */
1044 +#define AR2315_LBCONF_8DS       0x00000200    /* =1 8 bits Data S, 0=16bits */
1045 +#define AR2315_LBCONF_ADS_EN    0x00000400    /* =1 Enable ADS */
1046 +#define AR2315_LBCONF_ADR_OE    0x00000800    /* =1 Adr cap on OE, WE or DS */
1047 +#define AR2315_LBCONF_ADDT_MUX  0x00001000    /* =1 Adr and Data share bus */
1048 +#define AR2315_LBCONF_DATA_OE   0x00002000    /* =1 Data cap on OE, WE, DS */
1049 +#define AR2315_LBCONF_16DATA    0x00004000    /* =1 Data is 16 bits wide */
1050 +#define AR2315_LBCONF_SWAPDT    0x00008000    /* =1 Byte swap data */
1051 +#define AR2315_LBCONF_SYNC      0x00010000    /* =1 Bus synchronous to clk */
1052 +#define AR2315_LBCONF_INT       0x00020000    /* =1 Intr is low true */
1053 +#define AR2315_LBCONF_INT_CTR0  0x00000000    /* GND high-Z, Vdd is high-Z */
1054 +#define AR2315_LBCONF_INT_CTR1  0x00040000    /* GND drive, Vdd is high-Z */
1055 +#define AR2315_LBCONF_INT_CTR2  0x00080000    /* GND high-Z, Vdd drive */
1056 +#define AR2315_LBCONF_INT_CTR3  0x000C0000    /* GND drive, Vdd drive */
1057 +#define AR2315_LBCONF_RDY_WAIT  0x00100000    /* =1 RDY is negative of WAIT */
1058 +#define AR2315_LBCONF_INT_PULSE 0x00200000    /* =1 Interrupt is a pulse */
1059 +#define AR2315_LBCONF_ENABLE    0x00400000    /* =1 Falcon respond to LB */
1060 +
1061 +#define AR2315_LB_CLKSEL               0x0004
1062 +
1063 +#define AR2315_LBCLK_EXT        0x0001        /* use external clk for lb */
1064 +
1065 +#define AR2315_LB_1MS                  0x0008
1066 +
1067 +#define AR2315_LB1MS_MASK       0x3FFFF       /* # of AHB clk cycles in 1ms */
1068 +
1069 +#define AR2315_LB_MISCCFG              0x000c
1070 +#define AR2315_LBM_TXD_EN       0x00000001    /* Enable TXD for fragments */
1071 +#define AR2315_LBM_RX_INTEN     0x00000002    /* Enable LB ints on RX ready */
1072 +#define AR2315_LBM_MBOXWR_INTEN 0x00000004    /* Enable LB ints on mbox wr */
1073 +#define AR2315_LBM_MBOXRD_INTEN 0x00000008    /* Enable LB ints on mbox rd */
1074 +#define AR2315_LMB_DESCSWAP_EN  0x00000010    /* Byte swap desc enable */
1075 +#define AR2315_LBM_TIMEOUT_M   0x00ffff80
1076 +#define AR2315_LBM_TIMEOUT_S   7
1077 +#define AR2315_LBM_PORTMUX      0x07000000
1078 +
1079 +#define AR2315_LB_RXTSOFF              0x0010
1080 +
1081 +#define AR2315_LB_TX_CHAIN_EN          0x0100
1082 +
1083 +#define AR2315_LB_TXEN_0        0x01
1084 +#define AR2315_LB_TXEN_1        0x02
1085 +#define AR2315_LB_TXEN_2        0x04
1086 +#define AR2315_LB_TXEN_3        0x08
1087 +
1088 +#define AR2315_LB_TX_CHAIN_DIS         0x0104
1089 +#define AR2315_LB_TX_DESC_PTR          0x0200
1090 +
1091 +#define AR2315_LB_RX_CHAIN_EN          0x0400
1092 +
1093 +#define AR2315_LB_RXEN          0x01
1094 +
1095 +#define AR2315_LB_RX_CHAIN_DIS         0x0404
1096 +#define AR2315_LB_RX_DESC_PTR          0x0408
1097 +
1098 +#define AR2315_LB_INT_STATUS           0x0500
1099 +
1100 +#define AR2315_LB_INT_TX_DESC          0x00000001
1101 +#define AR2315_LB_INT_TX_OK            0x00000002
1102 +#define AR2315_LB_INT_TX_ERR           0x00000004
1103 +#define AR2315_LB_INT_TX_EOF           0x00000008
1104 +#define AR2315_LB_INT_RX_DESC          0x00000010
1105 +#define AR2315_LB_INT_RX_OK            0x00000020
1106 +#define AR2315_LB_INT_RX_ERR           0x00000040
1107 +#define AR2315_LB_INT_RX_EOF           0x00000080
1108 +#define AR2315_LB_INT_TX_TRUNC         0x00000100
1109 +#define AR2315_LB_INT_TX_STARVE                0x00000200
1110 +#define AR2315_LB_INT_LB_TIMEOUT       0x00000400
1111 +#define AR2315_LB_INT_LB_ERR           0x00000800
1112 +#define AR2315_LB_INT_MBOX_WR          0x00001000
1113 +#define AR2315_LB_INT_MBOX_RD          0x00002000
1114 +
1115 +/* Bit definitions for INT MASK are the same as INT_STATUS */
1116 +#define AR2315_LB_INT_MASK             0x0504
1117 +
1118 +#define AR2315_LB_INT_EN               0x0508
1119 +#define AR2315_LB_MBOX                 0x0600
1120 +
1121 +#endif /* __ASM_MACH_ATH25_AR2315_REGS_H */
1122 --- /dev/null
1123 +++ b/arch/mips/ath25/ar5312_regs.h
1124 @@ -0,0 +1,229 @@
1125 +/*
1126 + * This file is subject to the terms and conditions of the GNU General Public
1127 + * License.  See the file "COPYING" in the main directory of this archive
1128 + * for more details.
1129 + *
1130 + * Copyright (C) 2003 Atheros Communications, Inc.,  All Rights Reserved.
1131 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
1132 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
1133 + */
1134 +
1135 +#ifndef __ASM_MACH_ATH25_AR5312_REGS_H
1136 +#define __ASM_MACH_ATH25_AR5312_REGS_H
1137 +
1138 +#include <asm/addrspace.h>
1139 +
1140 +/*
1141 + * IRQs
1142 + */
1143 +#define AR5312_IRQ_WLAN0       (MIPS_CPU_IRQ_BASE + 2) /* C0_CAUSE: 0x0400 */
1144 +#define AR5312_IRQ_ENET0       (MIPS_CPU_IRQ_BASE + 3) /* C0_CAUSE: 0x0800 */
1145 +#define AR5312_IRQ_ENET1       (MIPS_CPU_IRQ_BASE + 4) /* C0_CAUSE: 0x1000 */
1146 +#define AR5312_IRQ_WLAN1       (MIPS_CPU_IRQ_BASE + 5) /* C0_CAUSE: 0x2000 */
1147 +#define AR5312_IRQ_MISC                (MIPS_CPU_IRQ_BASE + 6) /* C0_CAUSE: 0x4000 */
1148 +
1149 +/*
1150 + * Miscellaneous interrupts, which share IP6.
1151 + */
1152 +#define AR5312_MISC_IRQ_TIMER          (AR231X_MISC_IRQ_BASE+0)
1153 +#define AR5312_MISC_IRQ_AHB_PROC       (AR231X_MISC_IRQ_BASE+1)
1154 +#define AR5312_MISC_IRQ_AHB_DMA                (AR231X_MISC_IRQ_BASE+2)
1155 +#define AR5312_MISC_IRQ_GPIO           (AR231X_MISC_IRQ_BASE+3)
1156 +#define AR5312_MISC_IRQ_UART0          (AR231X_MISC_IRQ_BASE+4)
1157 +#define AR5312_MISC_IRQ_UART0_DMA      (AR231X_MISC_IRQ_BASE+5)
1158 +#define AR5312_MISC_IRQ_WATCHDOG       (AR231X_MISC_IRQ_BASE+6)
1159 +#define AR5312_MISC_IRQ_LOCAL          (AR231X_MISC_IRQ_BASE+7)
1160 +#define AR5312_MISC_IRQ_SPI            (AR231X_MISC_IRQ_BASE+8)
1161 +#define AR5312_MISC_IRQ_COUNT          9
1162 +
1163 +/*
1164 + * Address Map
1165 + *
1166 + * The AR5312 supports 2 enet MACS, even though many reference boards only
1167 + * actually use 1 of them (i.e. Only MAC 0 is actually connected to an enet
1168 + * PHY or PHY switch. The AR2312 supports 1 enet MAC.
1169 + */
1170 +#define AR5312_WLAN0_BASE              0x18000000
1171 +#define AR5312_ENET0_BASE              0x18100000
1172 +#define AR5312_ENET1_BASE              0x18200000
1173 +#define AR5312_SDRAMCTL_BASE           0x18300000
1174 +#define AR5312_SDRAMCTL_SIZE           0x00000010
1175 +#define AR5312_FLASHCTL_BASE           0x18400000
1176 +#define AR5312_FLASHCTL_SIZE           0x00000010
1177 +#define AR5312_WLAN1_BASE              0x18500000
1178 +#define AR5312_UART0_BASE              0x1c000000      /* UART MMR */
1179 +#define AR5312_GPIO_BASE               0x1c002000
1180 +#define AR5312_GPIO_SIZE               0x00000010
1181 +#define AR5312_RST_BASE                        0x1c003000
1182 +#define AR5312_RST_SIZE                        0x00000100
1183 +#define AR5312_FLASH_BASE              0x1e000000
1184 +#define AR5312_FLASH_SIZE              0x00800000
1185 +
1186 +/*
1187 + * Need these defines to determine true number of ethernet MACs
1188 + */
1189 +#define AR5312_AR5312_REV2      0x0052          /* AR5312 WMAC (AP31) */
1190 +#define AR5312_AR5312_REV7      0x0057          /* AR5312 WMAC (AP30-040) */
1191 +#define AR5312_AR2313_REV8      0x0058          /* AR2313 WMAC (AP43-030) */
1192 +
1193 +/* MII registers offset inside Ethernet MMR region */
1194 +#define AR5312_ENET0_MII_BASE  (AR5312_ENET0_BASE + 0x14)
1195 +#define AR5312_ENET1_MII_BASE  (AR5312_ENET1_BASE + 0x14)
1196 +
1197 +/* Reset/Timer Block Address Map */
1198 +#define AR5312_TIMER           0x0000 /* countdown timer */
1199 +#define AR5312_RELOAD          0x0004 /* timer reload value */
1200 +#define AR5312_WDT_CTRL                0x0008 /* watchdog cntrl */
1201 +#define AR5312_WDT_TIMER       0x000c /* watchdog timer */
1202 +#define AR5312_ISR             0x0010 /* Intr Status Reg */
1203 +#define AR5312_IMR             0x0014 /* Intr Mask Reg */
1204 +#define AR5312_RESET           0x0020
1205 +#define AR5312_CLOCKCTL1       0x0064
1206 +#define AR5312_SCRATCH         0x006c
1207 +#define AR5312_PROCADDR                0x0070
1208 +#define AR5312_PROC1           0x0074
1209 +#define AR5312_DMAADDR         0x0078
1210 +#define AR5312_DMA1            0x007c
1211 +#define AR5312_ENABLE          0x0080 /* interface enb */
1212 +#define AR5312_REV             0x0090 /* revision */
1213 +
1214 +/* AR5312_WDT_CTRL register bit field definitions */
1215 +#define AR5312_WDT_CTRL_IGNORE 0x00000000      /* ignore expiration */
1216 +#define AR5312_WDT_CTRL_NMI    0x00000001
1217 +#define AR5312_WDT_CTRL_RESET  0x00000002
1218 +
1219 +/* AR5312_ISR register bit field definitions */
1220 +#define AR5312_ISR_TIMER       0x0001
1221 +#define AR5312_ISR_AHBPROC     0x0002
1222 +#define AR5312_ISR_AHBDMA      0x0004
1223 +#define AR5312_ISR_GPIO                0x0008
1224 +#define AR5312_ISR_UART0       0x0010
1225 +#define AR5312_ISR_UART0DMA    0x0020
1226 +#define AR5312_ISR_WD          0x0040
1227 +#define AR5312_ISR_LOCAL       0x0080
1228 +
1229 +/* AR5312_RESET register bit field definitions */
1230 +#define AR5312_RESET_SYSTEM     0x00000001  /* cold reset full system */
1231 +#define AR5312_RESET_PROC       0x00000002  /* cold reset MIPS core */
1232 +#define AR5312_RESET_WLAN0      0x00000004  /* cold reset WLAN MAC and BB */
1233 +#define AR5312_RESET_EPHY0      0x00000008  /* cold reset ENET0 phy */
1234 +#define AR5312_RESET_EPHY1      0x00000010  /* cold reset ENET1 phy */
1235 +#define AR5312_RESET_ENET0      0x00000020  /* cold reset ENET0 mac */
1236 +#define AR5312_RESET_ENET1      0x00000040  /* cold reset ENET1 mac */
1237 +#define AR5312_RESET_UART0      0x00000100  /* cold reset UART0 (high speed) */
1238 +#define AR5312_RESET_WLAN1      0x00000200  /* cold reset WLAN MAC/BB */
1239 +#define AR5312_RESET_APB        0x00000400  /* cold reset APB (ar5312) */
1240 +#define AR5312_RESET_WARM_PROC  0x00001000  /* warm reset MIPS core */
1241 +#define AR5312_RESET_WARM_WLAN0_MAC 0x00002000  /* warm reset WLAN0 MAC */
1242 +#define AR5312_RESET_WARM_WLAN0_BB  0x00004000  /* warm reset WLAN0 BaseBand */
1243 +#define AR5312_RESET_NMI        0x00010000  /* send an NMI to the processor */
1244 +#define AR5312_RESET_WARM_WLAN1_MAC 0x00020000  /* warm reset WLAN1 mac */
1245 +#define AR5312_RESET_WARM_WLAN1_BB  0x00040000  /* warm reset WLAN1 baseband */
1246 +#define AR5312_RESET_LOCAL_BUS  0x00080000  /* reset local bus */
1247 +#define AR5312_RESET_WDOG       0x00100000  /* last reset was a watchdog */
1248 +
1249 +#define AR5312_RESET_WMAC0_BITS \
1250 +       (AR5312_RESET_WLAN0 |\
1251 +        AR5312_RESET_WARM_WLAN0_MAC |\
1252 +        AR5312_RESET_WARM_WLAN0_BB)
1253 +
1254 +#define AR5312_RESET_WMAC1_BITS \
1255 +       (AR5312_RESET_WLAN1 |\
1256 +        AR5312_RESET_WARM_WLAN1_MAC |\
1257 +        AR5312_RESET_WARM_WLAN1_BB)
1258 +
1259 +/* AR5312_CLOCKCTL1 register bit field definitions */
1260 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK    0x00000030
1261 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT            4
1262 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK   0x00001f00
1263 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT           8
1264 +#define AR5312_CLOCKCTL1_DOUBLER_MASK      0x00010000
1265 +
1266 +/* Valid for AR5312 and AR2312 */
1267 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK    0x00000030
1268 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT            4
1269 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK   0x00001f00
1270 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT           8
1271 +#define AR5312_CLOCKCTL1_DOUBLER_MASK      0x00010000
1272 +
1273 +/* Valid for AR2313 */
1274 +#define AR2313_CLOCKCTL1_PREDIVIDE_MASK    0x00003000
1275 +#define AR2313_CLOCKCTL1_PREDIVIDE_SHIFT           12
1276 +#define AR2313_CLOCKCTL1_MULTIPLIER_MASK   0x001f0000
1277 +#define AR2313_CLOCKCTL1_MULTIPLIER_SHIFT          16
1278 +#define AR2313_CLOCKCTL1_DOUBLER_MASK      0x00000000
1279 +
1280 +/* AR5312_ENABLE register bit field definitions */
1281 +#define AR5312_ENABLE_WLAN0              0x0001
1282 +#define AR5312_ENABLE_ENET0              0x0002
1283 +#define AR5312_ENABLE_ENET1              0x0004
1284 +#define AR5312_ENABLE_UART_AND_WLAN1_PIO 0x0008   /* UART, and WLAN1 PIOs */
1285 +#define AR5312_ENABLE_WLAN1_DMA          0x0010   /* WLAN1 DMAs */
1286 +#define AR5312_ENABLE_WLAN1 \
1287 +       (AR5312_ENABLE_UART_AND_WLAN1_PIO |\
1288 +        AR5312_ENABLE_WLAN1_DMA)
1289 +
1290 +/* AR5312_REV register bit field definitions */
1291 +#define AR5312_REV_WMAC_MAJ    0xf000
1292 +#define AR5312_REV_WMAC_MAJ_S  12
1293 +#define AR5312_REV_WMAC_MIN    0x0f00
1294 +#define AR5312_REV_WMAC_MIN_S  8
1295 +#define AR5312_REV_MAJ         0x00f0
1296 +#define AR5312_REV_MAJ_S       4
1297 +#define AR5312_REV_MIN         0x000f
1298 +#define AR5312_REV_MIN_S       0
1299 +#define AR5312_REV_CHIP        (AR5312_REV_MAJ|AR5312_REV_MIN)
1300 +
1301 +/* Major revision numbers, bits 7..4 of Revision ID register */
1302 +#define AR5312_REV_MAJ_AR5312          0x4
1303 +#define AR5312_REV_MAJ_AR2313          0x5
1304 +
1305 +/* Minor revision numbers, bits 3..0 of Revision ID register */
1306 +#define AR5312_REV_MIN_DUAL     0x0     /* Dual WLAN version */
1307 +#define AR5312_REV_MIN_SINGLE   0x1     /* Single WLAN version */
1308 +
1309 +/* ARM Flash Controller -- 3 flash banks with either x8 or x16 devices.  */
1310 +#define AR5312_FLASHCTL0       0x0000
1311 +#define AR5312_FLASHCTL1       0x0004
1312 +#define AR5312_FLASHCTL2       0x0008
1313 +
1314 +/* AR5312_FLASHCTL register bit field definitions */
1315 +#define AR5312_FLASHCTL_IDCY   0x0000000f      /* Idle cycle turnaround time */
1316 +#define AR5312_FLASHCTL_IDCY_S 0
1317 +#define AR5312_FLASHCTL_WST1   0x000003e0      /* Wait state 1 */
1318 +#define AR5312_FLASHCTL_WST1_S 5
1319 +#define AR5312_FLASHCTL_RBLE   0x00000400      /* Read byte lane enable */
1320 +#define AR5312_FLASHCTL_WST2   0x0000f800      /* Wait state 2 */
1321 +#define AR5312_FLASHCTL_WST2_S 11
1322 +#define AR5312_FLASHCTL_AC     0x00070000      /* Flash addr check (added) */
1323 +#define AR5312_FLASHCTL_AC_S   16
1324 +#define AR5312_FLASHCTL_AC_128K        0x00000000
1325 +#define AR5312_FLASHCTL_AC_256K        0x00010000
1326 +#define AR5312_FLASHCTL_AC_512K        0x00020000
1327 +#define AR5312_FLASHCTL_AC_1M  0x00030000
1328 +#define AR5312_FLASHCTL_AC_2M  0x00040000
1329 +#define AR5312_FLASHCTL_AC_4M  0x00050000
1330 +#define AR5312_FLASHCTL_AC_8M  0x00060000
1331 +#define AR5312_FLASHCTL_AC_RES 0x00070000      /* 16MB is not supported */
1332 +#define AR5312_FLASHCTL_E      0x00080000      /* Flash bank enable (added) */
1333 +#define AR5312_FLASHCTL_BUSERR 0x01000000      /* Bus transfer error flag */
1334 +#define AR5312_FLASHCTL_WPERR  0x02000000      /* Write protect error flag */
1335 +#define AR5312_FLASHCTL_WP     0x04000000      /* Write protect */
1336 +#define AR5312_FLASHCTL_BM     0x08000000      /* Burst mode */
1337 +#define AR5312_FLASHCTL_MW     0x30000000      /* Mem width */
1338 +#define AR5312_FLASHCTL_MW8    0x00000000      /* Mem width x8 */
1339 +#define AR5312_FLASHCTL_MW16   0x10000000      /* Mem width x16 */
1340 +#define AR5312_FLASHCTL_MW32   0x20000000      /* Mem width x32 (not supp) */
1341 +#define AR5312_FLASHCTL_ATNR   0x00000000      /* Access == no retry */
1342 +#define AR5312_FLASHCTL_ATR    0x80000000      /* Access == retry every */
1343 +#define AR5312_FLASHCTL_ATR4   0xc0000000      /* Access == retry every 4 */
1344 +
1345 +/* ARM SDRAM Controller -- just enough to determine memory size */
1346 +#define AR5312_MEM_CFG1                0x0004
1347 +
1348 +#define AR5312_MEM_CFG1_AC0_M  0x00000700      /* bank 0: SDRAM addr check */
1349 +#define AR5312_MEM_CFG1_AC0_S  8
1350 +#define AR5312_MEM_CFG1_AC1_M  0x00007000      /* bank 1: SDRAM addr check */
1351 +#define AR5312_MEM_CFG1_AC1_S  12
1352 +
1353 +#endif /* __ASM_MACH_ATH25_AR5312_REGS_H */
1354 --- /dev/null
1355 +++ b/arch/mips/ath25/ar5312.c
1356 @@ -0,0 +1,474 @@
1357 +/*
1358 + * This file is subject to the terms and conditions of the GNU General Public
1359 + * License.  See the file "COPYING" in the main directory of this archive
1360 + * for more details.
1361 + *
1362 + * Copyright (C) 2003 Atheros Communications, Inc.,  All Rights Reserved.
1363 + * Copyright (C) 2006 FON Technology, SL.
1364 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
1365 + * Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
1366 + * Copyright (C) 2012 Alexandros C. Couloumbis <alex@ozo.com>
1367 + */
1368 +
1369 +/*
1370 + * Platform devices for Atheros SoCs
1371 + */
1372 +
1373 +#include <generated/autoconf.h>
1374 +#include <linux/init.h>
1375 +#include <linux/module.h>
1376 +#include <linux/types.h>
1377 +#include <linux/string.h>
1378 +#include <linux/mtd/physmap.h>
1379 +#include <linux/platform_device.h>
1380 +#include <linux/kernel.h>
1381 +#include <linux/reboot.h>
1382 +#include <linux/leds.h>
1383 +#include <linux/gpio.h>
1384 +#include <asm/bootinfo.h>
1385 +#include <asm/reboot.h>
1386 +#include <asm/time.h>
1387 +#include <linux/irq.h>
1388 +#include <linux/io.h>
1389 +
1390 +#include <ath25_platform.h>
1391 +
1392 +#include "devices.h"
1393 +#include "ar5312.h"
1394 +#include "ar5312_regs.h"
1395 +
1396 +static void __iomem *ar5312_rst_base;
1397 +
1398 +static inline u32 ar5312_rst_reg_read(u32 reg)
1399 +{
1400 +       return __raw_readl(ar5312_rst_base + reg);
1401 +}
1402 +
1403 +static inline void ar5312_rst_reg_write(u32 reg, u32 val)
1404 +{
1405 +       __raw_writel(val, ar5312_rst_base + reg);
1406 +}
1407 +
1408 +static inline void ar5312_rst_reg_mask(u32 reg, u32 mask, u32 val)
1409 +{
1410 +       u32 ret = ar5312_rst_reg_read(reg);
1411 +
1412 +       ret &= ~mask;
1413 +       ret |= val;
1414 +       ar5312_rst_reg_write(reg, ret);
1415 +}
1416 +
1417 +static irqreturn_t ar5312_ahb_err_handler(int cpl, void *dev_id)
1418 +{
1419 +       u32 proc1 = ar5312_rst_reg_read(AR5312_PROC1);
1420 +       u32 proc_addr = ar5312_rst_reg_read(AR5312_PROCADDR); /* clears error */
1421 +       u32 dma1 = ar5312_rst_reg_read(AR5312_DMA1);
1422 +       u32 dma_addr = ar5312_rst_reg_read(AR5312_DMAADDR);   /* clears error */
1423 +
1424 +       pr_emerg("AHB interrupt: PROCADDR=0x%8.8x PROC1=0x%8.8x DMAADDR=0x%8.8x DMA1=0x%8.8x\n",
1425 +                proc_addr, proc1, dma_addr, dma1);
1426 +
1427 +       machine_restart("AHB error"); /* Catastrophic failure */
1428 +       return IRQ_HANDLED;
1429 +}
1430 +
1431 +static struct irqaction ar5312_ahb_err_interrupt  = {
1432 +       .handler = ar5312_ahb_err_handler,
1433 +       .name    = "ar5312-ahb-error",
1434 +};
1435 +
1436 +static void ar5312_misc_irq_handler(unsigned irq, struct irq_desc *desc)
1437 +{
1438 +       unsigned int ar231x_misc_intrs = ar5312_rst_reg_read(AR5312_ISR) &
1439 +                                        ar5312_rst_reg_read(AR5312_IMR);
1440 +
1441 +       if (ar231x_misc_intrs & AR5312_ISR_TIMER) {
1442 +               generic_handle_irq(AR5312_MISC_IRQ_TIMER);
1443 +               (void)ar5312_rst_reg_read(AR5312_TIMER);
1444 +       } else if (ar231x_misc_intrs & AR5312_ISR_AHBPROC)
1445 +               generic_handle_irq(AR5312_MISC_IRQ_AHB_PROC);
1446 +       else if ((ar231x_misc_intrs & AR5312_ISR_UART0))
1447 +               generic_handle_irq(AR5312_MISC_IRQ_UART0);
1448 +       else if (ar231x_misc_intrs & AR5312_ISR_WD)
1449 +               generic_handle_irq(AR5312_MISC_IRQ_WATCHDOG);
1450 +       else
1451 +               spurious_interrupt();
1452 +}
1453 +
1454 +/* Enable the specified AR5312_MISC_IRQ interrupt */
1455 +static void ar5312_misc_irq_unmask(struct irq_data *d)
1456 +{
1457 +       unsigned int imr;
1458 +
1459 +       imr = ar5312_rst_reg_read(AR5312_IMR);
1460 +       imr |= 1 << (d->irq - AR231X_MISC_IRQ_BASE);
1461 +       ar5312_rst_reg_write(AR5312_IMR, imr);
1462 +}
1463 +
1464 +/* Disable the specified AR5312_MISC_IRQ interrupt */
1465 +static void ar5312_misc_irq_mask(struct irq_data *d)
1466 +{
1467 +       unsigned int imr;
1468 +
1469 +       imr = ar5312_rst_reg_read(AR5312_IMR);
1470 +       imr &= ~(1 << (d->irq - AR231X_MISC_IRQ_BASE));
1471 +       ar5312_rst_reg_write(AR5312_IMR, imr);
1472 +       ar5312_rst_reg_read(AR5312_IMR); /* flush write buffer */
1473 +}
1474 +
1475 +static struct irq_chip ar5312_misc_irq_chip = {
1476 +       .name           = "ar5312-misc",
1477 +       .irq_unmask     = ar5312_misc_irq_unmask,
1478 +       .irq_mask       = ar5312_misc_irq_mask,
1479 +};
1480 +
1481 +static void ar5312_irq_dispatch(void)
1482 +{
1483 +       int pending = read_c0_status() & read_c0_cause();
1484 +
1485 +       if (pending & CAUSEF_IP2)
1486 +               do_IRQ(AR5312_IRQ_WLAN0);
1487 +       else if (pending & CAUSEF_IP3)
1488 +               do_IRQ(AR5312_IRQ_ENET0);
1489 +       else if (pending & CAUSEF_IP4)
1490 +               do_IRQ(AR5312_IRQ_ENET1);
1491 +       else if (pending & CAUSEF_IP5)
1492 +               do_IRQ(AR5312_IRQ_WLAN1);
1493 +       else if (pending & CAUSEF_IP6)
1494 +               do_IRQ(AR5312_IRQ_MISC);
1495 +       else if (pending & CAUSEF_IP7)
1496 +               do_IRQ(ATH25_IRQ_CPU_CLOCK);
1497 +       else
1498 +               spurious_interrupt();
1499 +}
1500 +
1501 +void __init ar5312_arch_init_irq(void)
1502 +{
1503 +       int i;
1504 +
1505 +       ath25_irq_dispatch = ar5312_irq_dispatch;
1506 +       for (i = 0; i < AR5312_MISC_IRQ_COUNT; i++) {
1507 +               int irq = AR231X_MISC_IRQ_BASE + i;
1508 +
1509 +               irq_set_chip_and_handler(irq, &ar5312_misc_irq_chip,
1510 +                                        handle_level_irq);
1511 +       }
1512 +       setup_irq(AR5312_MISC_IRQ_AHB_PROC, &ar5312_ahb_err_interrupt);
1513 +       irq_set_chained_handler(AR5312_IRQ_MISC, ar5312_misc_irq_handler);
1514 +}
1515 +
1516 +static void ar5312_device_reset_set(u32 mask)
1517 +{
1518 +       u32 val;
1519 +
1520 +       val = ar5312_rst_reg_read(AR5312_RESET);
1521 +       ar5312_rst_reg_write(AR5312_RESET, val | mask);
1522 +}
1523 +
1524 +static void ar5312_device_reset_clear(u32 mask)
1525 +{
1526 +       u32 val;
1527 +
1528 +       val = ar5312_rst_reg_read(AR5312_RESET);
1529 +       ar5312_rst_reg_write(AR5312_RESET, val & ~mask);
1530 +}
1531 +
1532 +static struct physmap_flash_data ar5312_flash_data = {
1533 +       .width = 2,
1534 +};
1535 +
1536 +static struct resource ar5312_flash_resource = {
1537 +       .start = AR5312_FLASH_BASE,
1538 +       .end = AR5312_FLASH_BASE + AR5312_FLASH_SIZE - 1,
1539 +       .flags = IORESOURCE_MEM,
1540 +};
1541 +
1542 +static struct ar231x_eth ar5312_eth0_data = {
1543 +       .reset_set = ar5312_device_reset_set,
1544 +       .reset_clear = ar5312_device_reset_clear,
1545 +       .reset_mac = AR5312_RESET_ENET0,
1546 +       .reset_phy = AR5312_RESET_EPHY0,
1547 +};
1548 +
1549 +static struct ar231x_eth ar5312_eth1_data = {
1550 +       .reset_set = ar5312_device_reset_set,
1551 +       .reset_clear = ar5312_device_reset_clear,
1552 +       .reset_mac = AR5312_RESET_ENET1,
1553 +       .reset_phy = AR5312_RESET_EPHY1,
1554 +};
1555 +
1556 +static struct platform_device ar5312_physmap_flash = {
1557 +       .name = "physmap-flash",
1558 +       .id = 0,
1559 +       .dev.platform_data = &ar5312_flash_data,
1560 +       .resource = &ar5312_flash_resource,
1561 +       .num_resources = 1,
1562 +};
1563 +
1564 +#ifdef CONFIG_LEDS_GPIO
1565 +static struct gpio_led ar5312_leds[] = {
1566 +       { .name = "wlan", .gpio = 0, .active_low = 1, },
1567 +};
1568 +
1569 +static const struct gpio_led_platform_data ar5312_led_data = {
1570 +       .num_leds = ARRAY_SIZE(ar5312_leds),
1571 +       .leds = (void *)ar5312_leds,
1572 +};
1573 +
1574 +static struct platform_device ar5312_gpio_leds = {
1575 +       .name = "leds-gpio",
1576 +       .id = -1,
1577 +       .dev.platform_data = (void *)&ar5312_led_data,
1578 +};
1579 +#endif
1580 +
1581 +static void __init ar5312_flash_init(void)
1582 +{
1583 +       void __iomem *flashctl_base;
1584 +       u32 ctl;
1585 +
1586 +       flashctl_base = ioremap_nocache(AR5312_FLASHCTL_BASE,
1587 +                                       AR5312_FLASHCTL_SIZE);
1588 +
1589 +       ctl = __raw_readl(flashctl_base + AR5312_FLASHCTL0);
1590 +       ctl &= AR5312_FLASHCTL_MW;
1591 +
1592 +       /* fixup flash width */
1593 +       switch (ctl) {
1594 +       case AR5312_FLASHCTL_MW16:
1595 +               ar5312_flash_data.width = 2;
1596 +               break;
1597 +       case AR5312_FLASHCTL_MW8:
1598 +       default:
1599 +               ar5312_flash_data.width = 1;
1600 +               break;
1601 +       }
1602 +
1603 +       /*
1604 +        * Configure flash bank 0.
1605 +        * Assume 8M window size. Flash will be aliased if it's smaller
1606 +        */
1607 +       ctl |= AR5312_FLASHCTL_E | AR5312_FLASHCTL_AC_8M | AR5312_FLASHCTL_RBLE;
1608 +       ctl |= 0x01 << AR5312_FLASHCTL_IDCY_S;
1609 +       ctl |= 0x07 << AR5312_FLASHCTL_WST1_S;
1610 +       ctl |= 0x07 << AR5312_FLASHCTL_WST2_S;
1611 +       __raw_writel(ctl, flashctl_base + AR5312_FLASHCTL0);
1612 +
1613 +       /* Disable other flash banks */
1614 +       ctl = __raw_readl(flashctl_base + AR5312_FLASHCTL1);
1615 +       ctl &= ~(AR5312_FLASHCTL_E | AR5312_FLASHCTL_AC);
1616 +       __raw_writel(ctl, flashctl_base + AR5312_FLASHCTL1);
1617 +       ctl = __raw_readl(flashctl_base + AR5312_FLASHCTL2);
1618 +       ctl &= ~(AR5312_FLASHCTL_E | AR5312_FLASHCTL_AC);
1619 +       __raw_writel(ctl, flashctl_base + AR5312_FLASHCTL2);
1620 +
1621 +       iounmap(flashctl_base);
1622 +}
1623 +
1624 +void __init ar5312_init_devices(void)
1625 +{
1626 +       struct ath25_boarddata *config;
1627 +       u8 *c;
1628 +
1629 +       ar5312_flash_init();
1630 +
1631 +       /* Locate board/radio config data */
1632 +       ath25_find_config(AR5312_FLASH_BASE, AR5312_FLASH_SIZE);
1633 +       config = ath25_board.config;
1634 +
1635 +       /* AR2313 has CPU minor rev. 10 */
1636 +       if ((current_cpu_data.processor_id & 0xff) == 0x0a)
1637 +               ath25_soc = ATH25_SOC_AR2313;
1638 +
1639 +       /* AR2312 shares the same Silicon ID as AR5312 */
1640 +       else if (config->flags & BD_ISCASPER)
1641 +               ath25_soc = ATH25_SOC_AR2312;
1642 +
1643 +       /* Everything else is probably AR5312 or compatible */
1644 +       else
1645 +               ath25_soc = ATH25_SOC_AR5312;
1646 +
1647 +       platform_device_register(&ar5312_physmap_flash);
1648 +
1649 +#ifdef CONFIG_LEDS_GPIO
1650 +       ar5312_leds[0].gpio = config->sys_led_gpio;
1651 +       platform_device_register(&ar5312_gpio_leds);
1652 +#endif
1653 +
1654 +       /* Fix up MAC addresses if necessary */
1655 +       if (is_broadcast_ether_addr(config->enet0_mac))
1656 +               ether_addr_copy(config->enet0_mac, config->enet1_mac);
1657 +
1658 +       /* If ENET0 and ENET1 have the same mac address,
1659 +        * increment the one from ENET1 */
1660 +       if (ether_addr_equal(config->enet0_mac, config->enet1_mac)) {
1661 +               c = config->enet1_mac + 5;
1662 +               while ((c >= config->enet1_mac) && !(++(*c)))
1663 +                       c--;
1664 +       }
1665 +
1666 +       switch (ath25_soc) {
1667 +       case ATH25_SOC_AR5312:
1668 +               ar5312_eth0_data.macaddr = config->enet0_mac;
1669 +               ath25_add_ethernet(0, AR5312_ENET0_BASE, "eth0_mii",
1670 +                                  AR5312_ENET0_MII_BASE, AR5312_IRQ_ENET0,
1671 +                                  &ar5312_eth0_data);
1672 +
1673 +               ar5312_eth1_data.macaddr = config->enet1_mac;
1674 +               ath25_add_ethernet(1, AR5312_ENET1_BASE, "eth1_mii",
1675 +                                  AR5312_ENET1_MII_BASE, AR5312_IRQ_ENET1,
1676 +                                  &ar5312_eth1_data);
1677 +
1678 +               if (!ath25_board.radio)
1679 +                       return;
1680 +
1681 +               if (!(config->flags & BD_WLAN0))
1682 +                       break;
1683 +
1684 +               ath25_add_wmac(0, AR5312_WLAN0_BASE, AR5312_IRQ_WLAN0);
1685 +               break;
1686 +       /*
1687 +        * AR2312/3 ethernet uses the PHY of ENET0, but the MAC
1688 +        * of ENET1. Atheros calls it 'twisted' for a reason :)
1689 +        */
1690 +       case ATH25_SOC_AR2312:
1691 +       case ATH25_SOC_AR2313:
1692 +               ar5312_eth1_data.reset_phy = ar5312_eth0_data.reset_phy;
1693 +               ar5312_eth1_data.macaddr = config->enet0_mac;
1694 +               ath25_add_ethernet(1, AR5312_ENET1_BASE, "eth0_mii",
1695 +                                  AR5312_ENET0_MII_BASE, AR5312_IRQ_ENET1,
1696 +                                  &ar5312_eth1_data);
1697 +
1698 +               if (!ath25_board.radio)
1699 +                       return;
1700 +               break;
1701 +       default:
1702 +               break;
1703 +       }
1704 +
1705 +       if (config->flags & BD_WLAN1)
1706 +               ath25_add_wmac(1, AR5312_WLAN1_BASE, AR5312_IRQ_WLAN1);
1707 +}
1708 +
1709 +static void ar5312_restart(char *command)
1710 +{
1711 +       /* reset the system */
1712 +       local_irq_disable();
1713 +       while (1)
1714 +               ar5312_rst_reg_write(AR5312_RESET, AR5312_RESET_SYSTEM);
1715 +}
1716 +
1717 +/*
1718 + * This table is indexed by bits 5..4 of the CLOCKCTL1 register
1719 + * to determine the predevisor value.
1720 + */
1721 +static unsigned clockctl1_predivide_table[4] __initdata = { 1, 2, 4, 5 };
1722 +
1723 +static unsigned __init ar5312_cpu_frequency(void)
1724 +{
1725 +       unsigned int scratch;
1726 +       unsigned int predivide_mask, predivide_shift;
1727 +       unsigned int multiplier_mask, multiplier_shift;
1728 +       unsigned int clock_ctl1, predivide_select, predivisor, multiplier;
1729 +       unsigned int doubler_mask;
1730 +       u16 devid;
1731 +
1732 +       /* Trust the bootrom's idea of cpu frequency. */
1733 +       scratch = ar5312_rst_reg_read(AR5312_SCRATCH);
1734 +       if (scratch)
1735 +               return scratch;
1736 +
1737 +       devid = ar5312_rst_reg_read(AR5312_REV);
1738 +       devid &= AR5312_REV_MAJ;
1739 +       devid >>= AR5312_REV_MAJ_S;
1740 +       if (devid == AR5312_REV_MAJ_AR2313) {
1741 +               predivide_mask = AR2313_CLOCKCTL1_PREDIVIDE_MASK;
1742 +               predivide_shift = AR2313_CLOCKCTL1_PREDIVIDE_SHIFT;
1743 +               multiplier_mask = AR2313_CLOCKCTL1_MULTIPLIER_MASK;
1744 +               multiplier_shift = AR2313_CLOCKCTL1_MULTIPLIER_SHIFT;
1745 +               doubler_mask = AR2313_CLOCKCTL1_DOUBLER_MASK;
1746 +       } else { /* AR5312 and AR2312 */
1747 +               predivide_mask = AR5312_CLOCKCTL1_PREDIVIDE_MASK;
1748 +               predivide_shift = AR5312_CLOCKCTL1_PREDIVIDE_SHIFT;
1749 +               multiplier_mask = AR5312_CLOCKCTL1_MULTIPLIER_MASK;
1750 +               multiplier_shift = AR5312_CLOCKCTL1_MULTIPLIER_SHIFT;
1751 +               doubler_mask = AR5312_CLOCKCTL1_DOUBLER_MASK;
1752 +       }
1753 +
1754 +       /*
1755 +        * Clocking is derived from a fixed 40MHz input clock.
1756 +        *
1757 +        *  cpu_freq = input_clock * MULT (where MULT is PLL multiplier)
1758 +        *  sys_freq = cpu_freq / 4       (used for APB clock, serial,
1759 +        *                                 flash, Timer, Watchdog Timer)
1760 +        *
1761 +        *  cnt_freq = cpu_freq / 2        (use for CPU count/compare)
1762 +        *
1763 +        * So, for example, with a PLL multiplier of 5, we have
1764 +        *
1765 +        *  cpu_freq = 200MHz
1766 +        *  sys_freq = 50MHz
1767 +        *  cnt_freq = 100MHz
1768 +        *
1769 +        * We compute the CPU frequency, based on PLL settings.
1770 +        */
1771 +
1772 +       clock_ctl1 = ar5312_rst_reg_read(AR5312_CLOCKCTL1);
1773 +       predivide_select = (clock_ctl1 & predivide_mask) >> predivide_shift;
1774 +       predivisor = clockctl1_predivide_table[predivide_select];
1775 +       multiplier = (clock_ctl1 & multiplier_mask) >> multiplier_shift;
1776 +
1777 +       if (clock_ctl1 & doubler_mask)
1778 +               multiplier = multiplier << 1;
1779 +
1780 +       return (40000000 / predivisor) * multiplier;
1781 +}
1782 +
1783 +static inline unsigned ar5312_sys_frequency(void)
1784 +{
1785 +       return ar5312_cpu_frequency() / 4;
1786 +}
1787 +
1788 +void __init ar5312_plat_time_init(void)
1789 +{
1790 +       mips_hpt_frequency = ar5312_cpu_frequency() / 2;
1791 +}
1792 +
1793 +void __init ar5312_plat_mem_setup(void)
1794 +{
1795 +       void __iomem *sdram_base;
1796 +       u32 memsize, memcfg, bank0_ac, bank1_ac;
1797 +       u32 devid;
1798 +
1799 +       /* Detect memory size */
1800 +       sdram_base = ioremap_nocache(AR5312_SDRAMCTL_BASE,
1801 +                                    AR5312_SDRAMCTL_SIZE);
1802 +       memcfg = __raw_readl(sdram_base + AR5312_MEM_CFG1);
1803 +       bank0_ac = ATH25_REG_MS(memcfg, AR5312_MEM_CFG1_AC0);
1804 +       bank1_ac = ATH25_REG_MS(memcfg, AR5312_MEM_CFG1_AC1);
1805 +       memsize = (bank0_ac ? (1 << (bank0_ac + 1)) : 0) +
1806 +                 (bank1_ac ? (1 << (bank1_ac + 1)) : 0);
1807 +       memsize <<= 20;
1808 +       add_memory_region(0, memsize, BOOT_MEM_RAM);
1809 +       iounmap(sdram_base);
1810 +
1811 +       ar5312_rst_base = ioremap_nocache(AR5312_RST_BASE, AR5312_RST_SIZE);
1812 +
1813 +       devid = ar5312_rst_reg_read(AR5312_REV);
1814 +       devid >>= AR5312_REV_WMAC_MIN_S;
1815 +       devid &= AR5312_REV_CHIP;
1816 +       ath25_board.devid = (u16)devid;
1817 +
1818 +       /* Clear any lingering AHB errors */
1819 +       ar5312_rst_reg_read(AR5312_PROCADDR);
1820 +       ar5312_rst_reg_read(AR5312_DMAADDR);
1821 +       ar5312_rst_reg_write(AR5312_WDT_CTRL, AR5312_WDT_CTRL_IGNORE);
1822 +
1823 +       _machine_restart = ar5312_restart;
1824 +}
1825 +
1826 +void __init ar5312_arch_init(void)
1827 +{
1828 +       ath25_serial_setup(AR5312_UART0_BASE, AR5312_MISC_IRQ_UART0,
1829 +                          ar5312_sys_frequency());
1830 +}
1831 --- /dev/null
1832 +++ b/arch/mips/ath25/ar2315.c
1833 @@ -0,0 +1,418 @@
1834 +/*
1835 + * This file is subject to the terms and conditions of the GNU General Public
1836 + * License.  See the file "COPYING" in the main directory of this archive
1837 + * for more details.
1838 + *
1839 + * Copyright (C) 2003 Atheros Communications, Inc.,  All Rights Reserved.
1840 + * Copyright (C) 2006 FON Technology, SL.
1841 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
1842 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
1843 + * Copyright (C) 2012 Alexandros C. Couloumbis <alex@ozo.com>
1844 + */
1845 +
1846 +/*
1847 + * Platform devices for Atheros SoCs
1848 + */
1849 +
1850 +#include <generated/autoconf.h>
1851 +#include <linux/init.h>
1852 +#include <linux/module.h>
1853 +#include <linux/types.h>
1854 +#include <linux/string.h>
1855 +#include <linux/platform_device.h>
1856 +#include <linux/kernel.h>
1857 +#include <linux/reboot.h>
1858 +#include <linux/delay.h>
1859 +#include <linux/leds.h>
1860 +#include <linux/gpio.h>
1861 +#include <asm/bootinfo.h>
1862 +#include <asm/reboot.h>
1863 +#include <asm/time.h>
1864 +#include <linux/irq.h>
1865 +#include <linux/io.h>
1866 +
1867 +#include <ath25_platform.h>
1868 +
1869 +#include "devices.h"
1870 +#include "ar2315.h"
1871 +#include "ar2315_regs.h"
1872 +
1873 +static void __iomem *ar2315_rst_base;
1874 +
1875 +static inline u32 ar2315_rst_reg_read(u32 reg)
1876 +{
1877 +       return __raw_readl(ar2315_rst_base + reg);
1878 +}
1879 +
1880 +static inline void ar2315_rst_reg_write(u32 reg, u32 val)
1881 +{
1882 +       __raw_writel(val, ar2315_rst_base + reg);
1883 +}
1884 +
1885 +static inline void ar2315_rst_reg_mask(u32 reg, u32 mask, u32 val)
1886 +{
1887 +       u32 ret = ar2315_rst_reg_read(reg);
1888 +
1889 +       ret &= ~mask;
1890 +       ret |= val;
1891 +       ar2315_rst_reg_write(reg, ret);
1892 +}
1893 +
1894 +static irqreturn_t ar2315_ahb_err_handler(int cpl, void *dev_id)
1895 +{
1896 +       ar2315_rst_reg_write(AR2315_AHB_ERR0, AR2315_AHB_ERROR_DET);
1897 +       ar2315_rst_reg_read(AR2315_AHB_ERR1);
1898 +
1899 +       pr_emerg("AHB fatal error\n");
1900 +       machine_restart("AHB error"); /* Catastrophic failure */
1901 +
1902 +       return IRQ_HANDLED;
1903 +}
1904 +
1905 +static struct irqaction ar2315_ahb_err_interrupt  = {
1906 +       .handler        = ar2315_ahb_err_handler,
1907 +       .name           = "ar2315-ahb-error",
1908 +};
1909 +
1910 +static void ar2315_misc_irq_handler(unsigned irq, struct irq_desc *desc)
1911 +{
1912 +       unsigned int misc_intr = ar2315_rst_reg_read(AR2315_ISR) &
1913 +                                ar2315_rst_reg_read(AR2315_IMR);
1914 +
1915 +       if (misc_intr & AR2315_ISR_SPI)
1916 +               generic_handle_irq(AR2315_MISC_IRQ_SPI);
1917 +       else if (misc_intr & AR2315_ISR_TIMER)
1918 +               generic_handle_irq(AR2315_MISC_IRQ_TIMER);
1919 +       else if (misc_intr & AR2315_ISR_AHB)
1920 +               generic_handle_irq(AR2315_MISC_IRQ_AHB);
1921 +       else if (misc_intr & AR2315_ISR_GPIO) {
1922 +               ar2315_rst_reg_write(AR2315_ISR, AR2315_ISR_GPIO);
1923 +               generic_handle_irq(AR2315_MISC_IRQ_GPIO);
1924 +       } else if (misc_intr & AR2315_ISR_UART0)
1925 +               generic_handle_irq(AR2315_MISC_IRQ_UART0);
1926 +       else if (misc_intr & AR2315_ISR_WD) {
1927 +               ar2315_rst_reg_write(AR2315_ISR, AR2315_ISR_WD);
1928 +               generic_handle_irq(AR2315_MISC_IRQ_WATCHDOG);
1929 +       } else
1930 +               spurious_interrupt();
1931 +}
1932 +
1933 +static void ar2315_misc_irq_unmask(struct irq_data *d)
1934 +{
1935 +       unsigned int imr;
1936 +
1937 +       imr = ar2315_rst_reg_read(AR2315_IMR);
1938 +       imr |= 1 << (d->irq - AR231X_MISC_IRQ_BASE);
1939 +       ar2315_rst_reg_write(AR2315_IMR, imr);
1940 +}
1941 +
1942 +static void ar2315_misc_irq_mask(struct irq_data *d)
1943 +{
1944 +       unsigned int imr;
1945 +
1946 +       imr = ar2315_rst_reg_read(AR2315_IMR);
1947 +       imr &= ~(1 << (d->irq - AR231X_MISC_IRQ_BASE));
1948 +       ar2315_rst_reg_write(AR2315_IMR, imr);
1949 +}
1950 +
1951 +static struct irq_chip ar2315_misc_irq_chip = {
1952 +       .name           = "ar2315-misc",
1953 +       .irq_unmask     = ar2315_misc_irq_unmask,
1954 +       .irq_mask       = ar2315_misc_irq_mask,
1955 +};
1956 +
1957 +/*
1958 + * Called when an interrupt is received, this function
1959 + * determines exactly which interrupt it was, and it
1960 + * invokes the appropriate handler.
1961 + *
1962 + * Implicitly, we also define interrupt priority by
1963 + * choosing which to dispatch first.
1964 + */
1965 +static void ar2315_irq_dispatch(void)
1966 +{
1967 +       int pending = read_c0_status() & read_c0_cause();
1968 +
1969 +       if (pending & CAUSEF_IP3)
1970 +               do_IRQ(AR2315_IRQ_WLAN0);
1971 +       else if (pending & CAUSEF_IP4)
1972 +               do_IRQ(AR2315_IRQ_ENET0);
1973 +       else if (pending & CAUSEF_IP2)
1974 +               do_IRQ(AR2315_IRQ_MISC);
1975 +       else if (pending & CAUSEF_IP7)
1976 +               do_IRQ(ATH25_IRQ_CPU_CLOCK);
1977 +       else
1978 +               spurious_interrupt();
1979 +}
1980 +
1981 +void __init ar2315_arch_init_irq(void)
1982 +{
1983 +       int i;
1984 +
1985 +       ath25_irq_dispatch = ar2315_irq_dispatch;
1986 +       for (i = 0; i < AR2315_MISC_IRQ_COUNT; i++) {
1987 +               int irq = AR231X_MISC_IRQ_BASE + i;
1988 +
1989 +               irq_set_chip_and_handler(irq, &ar2315_misc_irq_chip,
1990 +                                        handle_level_irq);
1991 +       }
1992 +       setup_irq(AR2315_MISC_IRQ_AHB, &ar2315_ahb_err_interrupt);
1993 +       irq_set_chained_handler(AR2315_IRQ_MISC, ar2315_misc_irq_handler);
1994 +}
1995 +
1996 +static void ar2315_device_reset_set(u32 mask)
1997 +{
1998 +       u32 val;
1999 +
2000 +       val = ar2315_rst_reg_read(AR2315_RESET);
2001 +       ar2315_rst_reg_write(AR2315_RESET, val | mask);
2002 +}
2003 +
2004 +static void ar2315_device_reset_clear(u32 mask)
2005 +{
2006 +       u32 val;
2007 +
2008 +       val = ar2315_rst_reg_read(AR2315_RESET);
2009 +       ar2315_rst_reg_write(AR2315_RESET, val & ~mask);
2010 +}
2011 +
2012 +static struct ar231x_eth ar2315_eth_data = {
2013 +       .reset_set = ar2315_device_reset_set,
2014 +       .reset_clear = ar2315_device_reset_clear,
2015 +       .reset_mac = AR2315_RESET_ENET0,
2016 +       .reset_phy = AR2315_RESET_EPHY0,
2017 +};
2018 +
2019 +static struct resource ar2315_spiflash_res[] = {
2020 +       {
2021 +               .name = "spiflash_read",
2022 +               .flags = IORESOURCE_MEM,
2023 +               .start = AR2315_SPI_READ_BASE,
2024 +               .end = AR2315_SPI_READ_BASE + AR2315_SPI_READ_SIZE - 1,
2025 +       },
2026 +       {
2027 +               .name = "spiflash_mmr",
2028 +               .flags = IORESOURCE_MEM,
2029 +               .start = AR2315_SPI_MMR_BASE,
2030 +               .end = AR2315_SPI_MMR_BASE + AR2315_SPI_MMR_SIZE - 1,
2031 +       },
2032 +};
2033 +
2034 +static struct platform_device ar2315_spiflash = {
2035 +       .id = 0,
2036 +       .name = "ar2315-spiflash",
2037 +       .resource = ar2315_spiflash_res,
2038 +       .num_resources = ARRAY_SIZE(ar2315_spiflash_res)
2039 +};
2040 +
2041 +static struct resource ar2315_wdt_res[] = {
2042 +       {
2043 +               .flags = IORESOURCE_MEM,
2044 +               .start = AR2315_RST_BASE + AR2315_WDT_TIMER,
2045 +               .end = AR2315_RST_BASE + AR2315_WDT_TIMER + 8 - 1,
2046 +       },
2047 +       {
2048 +               .flags = IORESOURCE_IRQ,
2049 +               .start = AR2315_MISC_IRQ_WATCHDOG,
2050 +               .end = AR2315_MISC_IRQ_WATCHDOG,
2051 +       }
2052 +};
2053 +
2054 +static struct platform_device ar2315_wdt = {
2055 +       .id = 0,
2056 +       .name = "ar2315-wdt",
2057 +       .resource = ar2315_wdt_res,
2058 +       .num_resources = ARRAY_SIZE(ar2315_wdt_res)
2059 +};
2060 +
2061 +#ifdef CONFIG_LEDS_GPIO
2062 +static struct gpio_led ar2315_leds[6];
2063 +static struct gpio_led_platform_data ar2315_led_data = {
2064 +       .leds = (void *)ar2315_leds,
2065 +};
2066 +
2067 +static struct platform_device ar2315_gpio_leds = {
2068 +       .name = "leds-gpio",
2069 +       .id = -1,
2070 +       .dev = {
2071 +               .platform_data = (void *)&ar2315_led_data,
2072 +       }
2073 +};
2074 +
2075 +static void __init ar2315_init_gpio_leds(void)
2076 +{
2077 +       static char led_names[6][6];
2078 +       int i, led = 0;
2079 +
2080 +       ar2315_led_data.num_leds = 0;
2081 +       for (i = 1; i < 8; i++) {
2082 +               if ((i == AR2315_RESET_GPIO) ||
2083 +                   (i == ath25_board.config->reset_config_gpio))
2084 +                       continue;
2085 +
2086 +               if (i == ath25_board.config->sys_led_gpio)
2087 +                       strcpy(led_names[led], "wlan");
2088 +               else
2089 +                       sprintf(led_names[led], "gpio%d", i);
2090 +
2091 +               ar2315_leds[led].name = led_names[led];
2092 +               ar2315_leds[led].gpio = i;
2093 +               ar2315_leds[led].active_low = 0;
2094 +               led++;
2095 +       }
2096 +       ar2315_led_data.num_leds = led;
2097 +       platform_device_register(&ar2315_gpio_leds);
2098 +}
2099 +#else
2100 +static inline void ar2315_init_gpio_leds(void)
2101 +{
2102 +}
2103 +#endif
2104 +
2105 +void __init ar2315_init_devices(void)
2106 +{
2107 +       /* Find board configuration */
2108 +       ath25_find_config(AR2315_SPI_READ_BASE, AR2315_SPI_READ_SIZE);
2109 +       ar2315_eth_data.macaddr = ath25_board.config->enet0_mac;
2110 +
2111 +       ar2315_init_gpio_leds();
2112 +       platform_device_register(&ar2315_wdt);
2113 +       platform_device_register(&ar2315_spiflash);
2114 +       ath25_add_ethernet(0, AR2315_ENET0_BASE, "eth0_mii",
2115 +                          AR2315_ENET0_MII_BASE, AR2315_IRQ_ENET0,
2116 +                          &ar2315_eth_data);
2117 +       ath25_add_wmac(0, AR2315_WLAN0_BASE, AR2315_IRQ_WLAN0);
2118 +}
2119 +
2120 +static void ar2315_restart(char *command)
2121 +{
2122 +       void (*mips_reset_vec)(void) = (void *)0xbfc00000;
2123 +
2124 +       local_irq_disable();
2125 +
2126 +       /* try reset the system via reset control */
2127 +       ar2315_rst_reg_write(AR2315_COLD_RESET, AR2317_RESET_SYSTEM);
2128 +
2129 +       /* Cold reset does not work on the AR2315/6, use the GPIO reset bits
2130 +        * a workaround. Give it some time to attempt a gpio based hardware
2131 +        * reset (atheros reference design workaround) */
2132 +       gpio_request_one(AR2315_RESET_GPIO, GPIOF_OUT_INIT_LOW, "Reset");
2133 +       mdelay(100);
2134 +
2135 +       /* Some boards (e.g. Senao EOC-2610) don't implement the reset logic
2136 +        * workaround. Attempt to jump to the mips reset location -
2137 +        * the boot loader itself might be able to recover the system */
2138 +       mips_reset_vec();
2139 +}
2140 +
2141 +/*
2142 + * This table is indexed by bits 5..4 of the CLOCKCTL1 register
2143 + * to determine the predevisor value.
2144 + */
2145 +static int clockctl1_predivide_table[4] __initdata = { 1, 2, 4, 5 };
2146 +static int pllc_divide_table[5] __initdata = { 2, 3, 4, 6, 3 };
2147 +
2148 +static unsigned __init ar2315_sys_clk(u32 clock_ctl)
2149 +{
2150 +       unsigned int pllc_ctrl, cpu_div;
2151 +       unsigned int pllc_out, refdiv, fdiv, divby2;
2152 +       unsigned int clk_div;
2153 +
2154 +       pllc_ctrl = ar2315_rst_reg_read(AR2315_PLLC_CTL);
2155 +       refdiv = ATH25_REG_MS(pllc_ctrl, AR2315_PLLC_REF_DIV);
2156 +       refdiv = clockctl1_predivide_table[refdiv];
2157 +       fdiv = ATH25_REG_MS(pllc_ctrl, AR2315_PLLC_FDBACK_DIV);
2158 +       divby2 = ATH25_REG_MS(pllc_ctrl, AR2315_PLLC_ADD_FDBACK_DIV) + 1;
2159 +       pllc_out = (40000000/refdiv)*(2*divby2)*fdiv;
2160 +
2161 +       /* clkm input selected */
2162 +       switch (clock_ctl & AR2315_CPUCLK_CLK_SEL_M) {
2163 +       case 0:
2164 +       case 1:
2165 +               clk_div = ATH25_REG_MS(pllc_ctrl, AR2315_PLLC_CLKM_DIV);
2166 +               clk_div = pllc_divide_table[clk_div];
2167 +               break;
2168 +       case 2:
2169 +               clk_div = ATH25_REG_MS(pllc_ctrl, AR2315_PLLC_CLKC_DIV);
2170 +               clk_div = pllc_divide_table[clk_div];
2171 +               break;
2172 +       default:
2173 +               pllc_out = 40000000;
2174 +               clk_div = 1;
2175 +               break;
2176 +       }
2177 +
2178 +       cpu_div = ATH25_REG_MS(clock_ctl, AR2315_CPUCLK_CLK_DIV);
2179 +       cpu_div = cpu_div * 2 ?: 1;
2180 +
2181 +       return pllc_out / (clk_div * cpu_div);
2182 +}
2183 +
2184 +static inline unsigned ar2315_cpu_frequency(void)
2185 +{
2186 +       return ar2315_sys_clk(ar2315_rst_reg_read(AR2315_CPUCLK));
2187 +}
2188 +
2189 +static inline unsigned ar2315_apb_frequency(void)
2190 +{
2191 +       return ar2315_sys_clk(ar2315_rst_reg_read(AR2315_AMBACLK));
2192 +}
2193 +
2194 +void __init ar2315_plat_time_init(void)
2195 +{
2196 +       mips_hpt_frequency = ar2315_cpu_frequency() / 2;
2197 +}
2198 +
2199 +void __init ar2315_plat_mem_setup(void)
2200 +{
2201 +       void __iomem *sdram_base;
2202 +       u32 memsize, memcfg;
2203 +       u32 devid;
2204 +       u32 config;
2205 +
2206 +       sdram_base = ioremap_nocache(AR2315_SDRAMCTL_BASE,
2207 +                                    AR2315_SDRAMCTL_SIZE);
2208 +       memcfg = __raw_readl(sdram_base + AR2315_MEM_CFG);
2209 +       memsize   = 1 + ATH25_REG_MS(memcfg, AR2315_MEM_CFG_DATA_WIDTH);
2210 +       memsize <<= 1 + ATH25_REG_MS(memcfg, AR2315_MEM_CFG_COL_WIDTH);
2211 +       memsize <<= 1 + ATH25_REG_MS(memcfg, AR2315_MEM_CFG_ROW_WIDTH);
2212 +       memsize <<= 3;
2213 +       add_memory_region(0, memsize, BOOT_MEM_RAM);
2214 +       iounmap(sdram_base);
2215 +
2216 +       ar2315_rst_base = ioremap_nocache(AR2315_RST_BASE, AR2315_RST_SIZE);
2217 +
2218 +       /* Detect the hardware based on the device ID */
2219 +       devid = ar2315_rst_reg_read(AR2315_SREV) & AR2315_REV_CHIP;
2220 +       switch (devid) {
2221 +       case 0x91:      /* Need to check */
2222 +               ath25_soc = ATH25_SOC_AR2318;
2223 +               break;
2224 +       case 0x90:
2225 +               ath25_soc = ATH25_SOC_AR2317;
2226 +               break;
2227 +       case 0x87:
2228 +               ath25_soc = ATH25_SOC_AR2316;
2229 +               break;
2230 +       case 0x86:
2231 +       default:
2232 +               ath25_soc = ATH25_SOC_AR2315;
2233 +               break;
2234 +       }
2235 +       ath25_board.devid = devid;
2236 +
2237 +       /* Clear any lingering AHB errors */
2238 +       config = read_c0_config();
2239 +       write_c0_config(config & ~0x3);
2240 +       ar2315_rst_reg_write(AR2315_AHB_ERR0, AR2315_AHB_ERROR_DET);
2241 +       ar2315_rst_reg_read(AR2315_AHB_ERR1);
2242 +       ar2315_rst_reg_write(AR2315_WDT_CTRL, AR2315_WDT_CTRL_IGNORE);
2243 +
2244 +       _machine_restart = ar2315_restart;
2245 +}
2246 +
2247 +void __init ar2315_arch_init(void)
2248 +{
2249 +       ath25_serial_setup(AR2315_UART0_BASE, AR2315_MISC_IRQ_UART0,
2250 +                          ar2315_apb_frequency());
2251 +}
2252 --- /dev/null
2253 +++ b/arch/mips/ath25/ar2315.h
2254 @@ -0,0 +1,36 @@
2255 +#ifndef __AR2315_H
2256 +#define __AR2315_H
2257 +
2258 +#ifdef CONFIG_SOC_AR2315
2259 +
2260 +void ar2315_arch_init_irq(void);
2261 +void ar2315_init_devices(void);
2262 +void ar2315_plat_time_init(void);
2263 +void ar2315_plat_mem_setup(void);
2264 +void ar2315_arch_init(void);
2265 +
2266 +#else
2267 +
2268 +static inline void ar2315_arch_init_irq(void)
2269 +{
2270 +}
2271 +
2272 +static inline void ar2315_init_devices(void)
2273 +{
2274 +}
2275 +
2276 +static inline void ar2315_plat_time_init(void)
2277 +{
2278 +}
2279 +
2280 +static inline void ar2315_plat_mem_setup(void)
2281 +{
2282 +}
2283 +
2284 +static inline void ar2315_arch_init(void)
2285 +{
2286 +}
2287 +
2288 +#endif
2289 +
2290 +#endif
2291 --- /dev/null
2292 +++ b/arch/mips/ath25/ar5312.h
2293 @@ -0,0 +1,36 @@
2294 +#ifndef __AR5312_H
2295 +#define __AR5312_H
2296 +
2297 +#ifdef CONFIG_SOC_AR5312
2298 +
2299 +void ar5312_arch_init_irq(void);
2300 +void ar5312_init_devices(void);
2301 +void ar5312_plat_time_init(void);
2302 +void ar5312_plat_mem_setup(void);
2303 +void ar5312_arch_init(void);
2304 +
2305 +#else
2306 +
2307 +static inline void ar5312_arch_init_irq(void)
2308 +{
2309 +}
2310 +
2311 +static inline void ar5312_init_devices(void)
2312 +{
2313 +}
2314 +
2315 +static inline void ar5312_plat_time_init(void)
2316 +{
2317 +}
2318 +
2319 +static inline void ar5312_plat_mem_setup(void)
2320 +{
2321 +}
2322 +
2323 +static inline void ar5312_arch_init(void)
2324 +{
2325 +}
2326 +
2327 +#endif
2328 +
2329 +#endif
2330 --- /dev/null
2331 +++ b/arch/mips/ath25/devices.h
2332 @@ -0,0 +1,46 @@
2333 +#ifndef __ATH25_DEVICES_H
2334 +#define __ATH25_DEVICES_H
2335 +
2336 +#define AR231X_MISC_IRQ_BASE           0x20
2337 +#define AR231X_GPIO_IRQ_BASE           0x30
2338 +
2339 +#define ATH25_REG_MS(_val, _field)     (((_val) & _field##_M) >> _field##_S)
2340 +
2341 +#define ATH25_IRQ_CPU_CLOCK    (MIPS_CPU_IRQ_BASE + 7) /* C0_CAUSE: 0x8000 */
2342 +
2343 +enum ath25_soc_type {
2344 +       /* handled by ar5312.c */
2345 +       ATH25_SOC_AR2312,
2346 +       ATH25_SOC_AR2313,
2347 +       ATH25_SOC_AR5312,
2348 +
2349 +       /* handled by ar2315.c */
2350 +       ATH25_SOC_AR2315,
2351 +       ATH25_SOC_AR2316,
2352 +       ATH25_SOC_AR2317,
2353 +       ATH25_SOC_AR2318,
2354 +
2355 +       ATH25_SOC_UNKNOWN
2356 +};
2357 +
2358 +extern enum ath25_soc_type ath25_soc;
2359 +extern struct ar231x_board_config ath25_board;
2360 +extern void (*ath25_irq_dispatch)(void);
2361 +
2362 +int ath25_find_config(phys_addr_t offset, unsigned long size);
2363 +int ath25_add_ethernet(int nr, u32 base, const char *mii_name, u32 mii_base,
2364 +                      int irq, void *pdata);
2365 +void ath25_serial_setup(u32 mapbase, int irq, unsigned int uartclk);
2366 +int ath25_add_wmac(int nr, u32 base, int irq);
2367 +
2368 +static inline bool is_ar2315(void)
2369 +{
2370 +       return (current_cpu_data.cputype == CPU_4KEC);
2371 +}
2372 +
2373 +static inline bool is_ar5312(void)
2374 +{
2375 +       return !is_ar2315();
2376 +}
2377 +
2378 +#endif
2379 --- /dev/null
2380 +++ b/arch/mips/ath25/devices.c
2381 @@ -0,0 +1,191 @@
2382 +#include <linux/kernel.h>
2383 +#include <linux/init.h>
2384 +#include <linux/serial.h>
2385 +#include <linux/serial_core.h>
2386 +#include <linux/serial_8250.h>
2387 +#include <linux/platform_device.h>
2388 +#include <asm/bootinfo.h>
2389 +
2390 +#include <ath25_platform.h>
2391 +#include "devices.h"
2392 +#include "ar5312.h"
2393 +#include "ar2315.h"
2394 +
2395 +struct ar231x_board_config ath25_board;
2396 +enum ath25_soc_type ath25_soc = ATH25_SOC_UNKNOWN;
2397 +
2398 +static struct resource ath25_eth0_res[] = {
2399 +       {
2400 +               .name = "eth0_membase",
2401 +               .flags = IORESOURCE_MEM,
2402 +       },
2403 +       {
2404 +               .name = "eth0_mii",
2405 +               .flags = IORESOURCE_MEM,
2406 +       },
2407 +       {
2408 +               .name = "eth0_irq",
2409 +               .flags = IORESOURCE_IRQ,
2410 +       }
2411 +};
2412 +
2413 +static struct resource ath25_eth1_res[] = {
2414 +       {
2415 +               .name = "eth1_membase",
2416 +               .flags = IORESOURCE_MEM,
2417 +       },
2418 +       {
2419 +               .name = "eth1_mii",
2420 +               .flags = IORESOURCE_MEM,
2421 +       },
2422 +       {
2423 +               .name = "eth1_irq",
2424 +               .flags = IORESOURCE_IRQ,
2425 +       }
2426 +};
2427 +
2428 +static struct platform_device ath25_eth[] = {
2429 +       {
2430 +               .id = 0,
2431 +               .name = "ar231x-eth",
2432 +               .resource = ath25_eth0_res,
2433 +               .num_resources = ARRAY_SIZE(ath25_eth0_res)
2434 +       },
2435 +       {
2436 +               .id = 1,
2437 +               .name = "ar231x-eth",
2438 +               .resource = ath25_eth1_res,
2439 +               .num_resources = ARRAY_SIZE(ath25_eth1_res)
2440 +       }
2441 +};
2442 +
2443 +static struct resource ath25_wmac0_res[] = {
2444 +       {
2445 +               .name = "wmac0_membase",
2446 +               .flags = IORESOURCE_MEM,
2447 +       },
2448 +       {
2449 +               .name = "wmac0_irq",
2450 +               .flags = IORESOURCE_IRQ,
2451 +       }
2452 +};
2453 +
2454 +static struct resource ath25_wmac1_res[] = {
2455 +       {
2456 +               .name = "wmac1_membase",
2457 +               .flags = IORESOURCE_MEM,
2458 +       },
2459 +       {
2460 +               .name = "wmac1_irq",
2461 +               .flags = IORESOURCE_IRQ,
2462 +       }
2463 +};
2464 +
2465 +static struct platform_device ath25_wmac[] = {
2466 +       {
2467 +               .id = 0,
2468 +               .name = "ar231x-wmac",
2469 +               .resource = ath25_wmac0_res,
2470 +               .num_resources = ARRAY_SIZE(ath25_wmac0_res),
2471 +               .dev.platform_data = &ath25_board,
2472 +       },
2473 +       {
2474 +               .id = 1,
2475 +               .name = "ar231x-wmac",
2476 +               .resource = ath25_wmac1_res,
2477 +               .num_resources = ARRAY_SIZE(ath25_wmac1_res),
2478 +               .dev.platform_data = &ath25_board,
2479 +       },
2480 +};
2481 +
2482 +static const char * const soc_type_strings[] = {
2483 +       [ATH25_SOC_AR5312] = "Atheros AR5312",
2484 +       [ATH25_SOC_AR2312] = "Atheros AR2312",
2485 +       [ATH25_SOC_AR2313] = "Atheros AR2313",
2486 +       [ATH25_SOC_AR2315] = "Atheros AR2315",
2487 +       [ATH25_SOC_AR2316] = "Atheros AR2316",
2488 +       [ATH25_SOC_AR2317] = "Atheros AR2317",
2489 +       [ATH25_SOC_AR2318] = "Atheros AR2318",
2490 +       [ATH25_SOC_UNKNOWN] = "Atheros (unknown)",
2491 +};
2492 +
2493 +const char *get_system_type(void)
2494 +{
2495 +       if ((ath25_soc >= ARRAY_SIZE(soc_type_strings)) ||
2496 +           !soc_type_strings[ath25_soc])
2497 +               return soc_type_strings[ATH25_SOC_UNKNOWN];
2498 +       return soc_type_strings[ath25_soc];
2499 +}
2500 +
2501 +int __init ath25_add_ethernet(int nr, u32 base, const char *mii_name,
2502 +                             u32 mii_base, int irq, void *pdata)
2503 +{
2504 +       struct resource *res;
2505 +
2506 +       ath25_eth[nr].dev.platform_data = pdata;
2507 +       res = &ath25_eth[nr].resource[0];
2508 +       res->start = base;
2509 +       res->end = base + 0x2000 - 1;
2510 +       res++;
2511 +       res->name = mii_name;
2512 +       res->start = mii_base;
2513 +       res->end = mii_base + 8 - 1;
2514 +       res++;
2515 +       res->start = irq;
2516 +       res->end = irq;
2517 +       return platform_device_register(&ath25_eth[nr]);
2518 +}
2519 +
2520 +void __init ath25_serial_setup(u32 mapbase, int irq, unsigned int uartclk)
2521 +{
2522 +       struct uart_port s;
2523 +
2524 +       memset(&s, 0, sizeof(s));
2525 +
2526 +       s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP;
2527 +       s.iotype = UPIO_MEM32;
2528 +       s.irq = irq;
2529 +       s.regshift = 2;
2530 +       s.mapbase = mapbase;
2531 +       s.uartclk = uartclk;
2532 +
2533 +       early_serial_setup(&s);
2534 +}
2535 +
2536 +int __init ath25_add_wmac(int nr, u32 base, int irq)
2537 +{
2538 +       struct resource *res;
2539 +
2540 +       ath25_wmac[nr].dev.platform_data = &ath25_board;
2541 +       res = &ath25_wmac[nr].resource[0];
2542 +       res->start = base;
2543 +       res->end = base + 0x10000 - 1;
2544 +       res++;
2545 +       res->start = irq;
2546 +       res->end = irq;
2547 +       return platform_device_register(&ath25_wmac[nr]);
2548 +}
2549 +
2550 +static int __init ath25_register_devices(void)
2551 +{
2552 +       if (is_ar5312())
2553 +               ar5312_init_devices();
2554 +       else
2555 +               ar2315_init_devices();
2556 +
2557 +       return 0;
2558 +}
2559 +
2560 +device_initcall(ath25_register_devices);
2561 +
2562 +static int __init ath25_arch_init(void)
2563 +{
2564 +       if (is_ar5312())
2565 +               ar5312_arch_init();
2566 +       else
2567 +               ar2315_arch_init();
2568 +
2569 +       return 0;
2570 +}
2571 +
2572 +arch_initcall(ath25_arch_init);