1 --- a/arch/mips/Kconfig
2 +++ b/arch/mips/Kconfig
3 @@ -60,6 +60,19 @@ config BCM47XX
5 Support for BCM47XX based boards
8 + bool "Atheros 231x/531x SoC support"
11 + select DMA_NONCOHERENT
13 + select SYS_HAS_CPU_MIPS32_R1
14 + select SYS_SUPPORTS_BIG_ENDIAN
15 + select SYS_SUPPORTS_32BIT_KERNEL
18 + Support for AR231x and AR531x based boards
23 @@ -597,6 +610,7 @@ config WR_PPMC
27 +source "arch/mips/ar231x/Kconfig"
28 source "arch/mips/alchemy/Kconfig"
29 source "arch/mips/basler/excite/Kconfig"
30 source "arch/mips/emma/Kconfig"
31 --- a/arch/mips/Makefile
32 +++ b/arch/mips/Makefile
33 @@ -278,6 +278,13 @@ libs-$(CONFIG_MIPS_XXS1500) += arch/mips
34 load-$(CONFIG_MIPS_XXS1500) += 0xffffffff80100000
37 +# Atheros AR5312/AR2312 WiSoC
39 +core-$(CONFIG_ATHEROS) += arch/mips/ar231x/
40 +cflags-$(CONFIG_ATHEROS) += -I$(srctree)/arch/mips/include/asm/mach-ar231x
41 +load-$(CONFIG_ATHEROS) += 0xffffffff80041000
46 core-$(CONFIG_MIPS_COBALT) += arch/mips/cobalt/
48 +++ b/arch/mips/ar231x/Kconfig
50 +config ATHEROS_AR5312
51 + bool "Atheros 5312/2312+ support"
55 +config ATHEROS_AR2315
56 + bool "Atheros 2315+ support"
58 + select DMA_NONCOHERENT
62 + select SYS_HAS_CPU_MIPS32_R1
63 + select SYS_SUPPORTS_32BIT_KERNEL
64 + select SYS_SUPPORTS_BIG_ENDIAN
68 +++ b/arch/mips/ar231x/Makefile
71 +# This file is subject to the terms and conditions of the GNU General Public
72 +# License. See the file "COPYING" in the main directory of this archive
75 +# Copyright (C) 2006 FON Technology, SL.
76 +# Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
77 +# Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
80 +obj-y += board.o prom.o devices.o
81 +obj-$(CONFIG_ATHEROS_AR5312) += ar5312.o
82 +obj-$(CONFIG_ATHEROS_AR2315) += ar2315.o
84 +++ b/arch/mips/ar231x/board.c
87 + * This file is subject to the terms and conditions of the GNU General Public
88 + * License. See the file "COPYING" in the main directory of this archive
91 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
92 + * Copyright (C) 2006 FON Technology, SL.
93 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
94 + * Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
97 +#include <linux/autoconf.h>
98 +#include <linux/init.h>
99 +#include <linux/module.h>
100 +#include <linux/types.h>
101 +#include <linux/string.h>
102 +#include <linux/platform_device.h>
103 +#include <linux/kernel.h>
104 +#include <linux/random.h>
105 +#include <linux/etherdevice.h>
106 +#include <asm/irq_cpu.h>
107 +#include <asm/reboot.h>
110 +#include <ar231x_platform.h>
111 +#include "devices.h"
115 +void (*ar231x_irq_dispatch)(void);
118 +check_radio_magic(u8 *addr)
120 + addr += 0x7a; /* offset for flash magic */
121 + if ((addr[0] == 0x5a) && (addr[1] == 0xa5)) {
128 +check_board_data(u8 *flash_limit, u8 *addr, bool broken)
130 + /* config magic found */
131 + if (*((u32 *)addr) == AR531X_BD_MAGIC)
137 + if (check_radio_magic(addr + 0xf8))
138 + ar231x_board.radio = addr + 0xf8;
139 + if ((addr < flash_limit + 0x10000) &&
140 + check_radio_magic(addr + 0x10000))
141 + ar231x_board.radio = addr + 0x10000;
143 + if (ar231x_board.radio) {
144 + /* broken board data detected, use radio data to find the offset,
145 + * user will fix this */
152 +find_board_config(u8 *flash_limit, bool broken)
157 + for (addr = flash_limit - 0x1000;
158 + addr >= flash_limit - 0x30000;
161 + if (check_board_data(flash_limit, addr, broken)) {
174 +find_radio_config(u8 *flash_limit, u8 *board_config)
180 + * Now find the start of Radio Configuration data, using heuristics:
181 + * Search forward from Board Configuration data by 0x1000 bytes
182 + * at a time until we find non-0xffffffff.
185 + for (radio_config = board_config + 0x1000;
186 + (radio_config < flash_limit);
187 + radio_config += 0x1000) {
188 + if ((*(u32 *)radio_config != 0xffffffff) &&
189 + check_radio_magic(radio_config)) {
195 + /* AR2316 relocates radio config to new location */
197 + for (radio_config = board_config + 0xf8;
198 + (radio_config < flash_limit - 0x1000 + 0xf8);
199 + radio_config += 0x1000) {
200 + if ((*(u32 *)radio_config != 0xffffffff) &&
201 + check_radio_magic(radio_config)) {
209 + printk("Could not find Radio Configuration data\n");
213 + return (u8 *) radio_config;
217 +ar231x_find_config(u8 *flash_limit)
219 + struct ar231x_boarddata *config;
220 + unsigned int rcfg_size;
221 + int broken_boarddata = 0;
227 + ar231x_board.config = NULL;
228 + ar231x_board.radio = NULL;
229 + /* Copy the board and radio data to RAM, because accessing the mapped
230 + * memory of the flash directly after booting is not safe */
232 + /* Try to find valid board and radio data */
233 + bcfg = find_board_config(flash_limit, false);
235 + /* If that fails, try to at least find valid radio data */
237 + bcfg = find_board_config(flash_limit, true);
238 + broken_boarddata = 1;
242 + printk(KERN_WARNING "WARNING: No board configuration data found!\n");
246 + board_data = kzalloc(BOARD_CONFIG_BUFSZ, GFP_KERNEL);
247 + ar231x_board.config = (struct ar231x_boarddata *) board_data;
248 + memcpy(board_data, bcfg, 0x100);
249 + if (broken_boarddata) {
250 + printk(KERN_WARNING "WARNING: broken board data detected\n");
251 + config = ar231x_board.config;
252 + if (!memcmp(config->enet0_mac, "\x00\x00\x00\x00\x00\x00", 6)) {
253 + printk(KERN_INFO "Fixing up empty mac addresses\n");
254 + random_ether_addr(config->wlan0_mac);
255 + config->wlan0_mac[0] &= ~0x06;
256 + random_ether_addr(config->enet0_mac);
257 + random_ether_addr(config->enet1_mac);
262 + /* Radio config starts 0x100 bytes after board config, regardless
263 + * of what the physical layout on the flash chip looks like */
265 + if (ar231x_board.radio)
266 + rcfg = (u8 *) ar231x_board.radio;
268 + rcfg = find_radio_config(flash_limit, bcfg);
273 + radio_data = board_data + 0x100 + ((rcfg - bcfg) & 0xfff);
274 + ar231x_board.radio = radio_data;
275 + offset = radio_data - board_data;
276 + printk(KERN_INFO "Radio config found at offset 0x%x(0x%x)\n", rcfg - bcfg, offset);
277 + rcfg_size = BOARD_CONFIG_BUFSZ - offset;
278 + memcpy(radio_data, rcfg, rcfg_size);
286 + local_irq_disable();
291 +plat_mem_setup(void)
293 + _machine_halt = ar231x_halt;
294 + pm_power_off = ar231x_halt;
296 + ar5312_plat_setup();
297 + ar2315_plat_setup();
299 + /* Disable data watchpoints */
300 + write_c0_watchlo0(0);
305 +plat_irq_dispatch(void)
307 + ar231x_irq_dispatch();
311 +plat_time_init(void)
313 + ar5312_time_init();
314 + ar2315_time_init();
317 +unsigned int __cpuinit
318 +get_c0_compare_irq(void)
320 + return CP0_LEGACY_COMPARE_IRQ;
326 + clear_c0_status(ST0_IM);
327 + mips_cpu_irq_init();
329 + /* Initialize interrupt controllers */
336 +++ b/arch/mips/ar231x/prom.c
339 + * This file is subject to the terms and conditions of the GNU General Public
340 + * License. See the file "COPYING" in the main directory of this archive
341 + * for more details.
343 + * Copyright MontaVista Software Inc
344 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
345 + * Copyright (C) 2006 FON Technology, SL.
346 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
347 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
351 + * Prom setup file for ar531x
354 +#include <linux/init.h>
355 +#include <linux/autoconf.h>
356 +#include <linux/kernel.h>
357 +#include <linux/string.h>
358 +#include <linux/mm.h>
359 +#include <linux/bootmem.h>
361 +#include <asm/bootinfo.h>
362 +#include <asm/addrspace.h>
366 +void __init prom_init(void)
368 + ar5312_prom_init();
369 + ar2315_prom_init();
372 +void __init prom_free_prom_memory(void)
376 +++ b/arch/mips/include/asm/mach-ar231x/ar231x_platform.h
378 +#ifndef __AR531X_PLATFORM_H
379 +#define __AR531X_PLATFORM_H
382 + * This is board-specific data that is stored in a "fixed" location in flash.
383 + * It is shared across operating systems, so it should not be changed lightly.
384 + * The main reason we need it is in order to extract the ethernet MAC
387 +struct ar231x_boarddata {
388 + u32 magic; /* board data is valid */
389 +#define AR531X_BD_MAGIC 0x35333131 /* "5311", for all 531x platforms */
390 + u16 cksum; /* checksum (starting with BD_REV 2) */
391 + u16 rev; /* revision of this struct */
393 + char boardName[64]; /* Name of board */
394 + u16 major; /* Board major number */
395 + u16 minor; /* Board minor number */
396 + u32 flags; /* Board configuration */
397 +#define BD_ENET0 0x00000001 /* ENET0 is stuffed */
398 +#define BD_ENET1 0x00000002 /* ENET1 is stuffed */
399 +#define BD_UART1 0x00000004 /* UART1 is stuffed */
400 +#define BD_UART0 0x00000008 /* UART0 is stuffed (dma) */
401 +#define BD_RSTFACTORY 0x00000010 /* Reset factory defaults stuffed */
402 +#define BD_SYSLED 0x00000020 /* System LED stuffed */
403 +#define BD_EXTUARTCLK 0x00000040 /* External UART clock */
404 +#define BD_CPUFREQ 0x00000080 /* cpu freq is valid in nvram */
405 +#define BD_SYSFREQ 0x00000100 /* sys freq is set in nvram */
406 +#define BD_WLAN0 0x00000200 /* Enable WLAN0 */
407 +#define BD_MEMCAP 0x00000400 /* CAP SDRAM @ memCap for testing */
408 +#define BD_DISWATCHDOG 0x00000800 /* disable system watchdog */
409 +#define BD_WLAN1 0x00001000 /* Enable WLAN1 (ar5212) */
410 +#define BD_ISCASPER 0x00002000 /* FLAG for AR2312 */
411 +#define BD_WLAN0_2G_EN 0x00004000 /* FLAG for radio0_2G */
412 +#define BD_WLAN0_5G_EN 0x00008000 /* FLAG for radio0_2G */
413 +#define BD_WLAN1_2G_EN 0x00020000 /* FLAG for radio0_2G */
414 +#define BD_WLAN1_5G_EN 0x00040000 /* FLAG for radio0_2G */
415 + u16 resetConfigGpio; /* Reset factory GPIO pin */
416 + u16 sysLedGpio; /* System LED GPIO pin */
418 + u32 cpuFreq; /* CPU core frequency in Hz */
419 + u32 sysFreq; /* System frequency in Hz */
420 + u32 cntFreq; /* Calculated C0_COUNT frequency */
426 + u16 pciId; /* Pseudo PCIID for common code */
427 + u16 memCap; /* cap bank1 in MB */
430 + u8 wlan1_mac[6]; /* (ar5212) */
433 +#define BOARD_CONFIG_BUFSZ 0x1000
436 + * Platform device information for the Wireless MAC
438 +struct ar231x_board_config {
441 + /* board config data */
442 + struct ar231x_boarddata *config;
444 + /* radio calibration data */
449 + * Platform device information for the Ethernet MAC
456 + struct ar231x_board_config *config;
460 +#endif /* __AR531X_PLATFORM_H */
462 +++ b/arch/mips/include/asm/mach-ar231x/cpu-feature-overrides.h
465 + * Atheros SoC specific CPU feature overrides
467 + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
469 + * This file was derived from: include/asm-mips/cpu-features.h
470 + * Copyright (C) 2003, 2004 Ralf Baechle
471 + * Copyright (C) 2004 Maciej W. Rozycki
473 + * This program is free software; you can redistribute it and/or modify it
474 + * under the terms of the GNU General Public License version 2 as published
475 + * by the Free Software Foundation.
478 +#ifndef __ASM_MACH_ATHEROS_CPU_FEATURE_OVERRIDES_H
479 +#define __ASM_MACH_ATHEROS_CPU_FEATURE_OVERRIDES_H
482 + * The ATHEROS SoCs have MIPS 4Kc/4KEc core.
484 +#define cpu_has_tlb 1
485 +#define cpu_has_4kex 1
486 +#define cpu_has_3k_cache 0
487 +#define cpu_has_4k_cache 1
488 +#define cpu_has_tx39_cache 0
489 +#define cpu_has_sb1_cache 0
490 +#define cpu_has_fpu 0
491 +#define cpu_has_32fpr 0
492 +#define cpu_has_counter 1
493 +/* #define cpu_has_watch ? */
494 +/* #define cpu_has_divec ? */
495 +/* #define cpu_has_vce ? */
496 +/* #define cpu_has_cache_cdex_p ? */
497 +/* #define cpu_has_cache_cdex_s ? */
498 +/* #define cpu_has_prefetch ? */
499 +/* #define cpu_has_mcheck ? */
500 +#define cpu_has_ejtag 1
502 +#if !defined(CONFIG_ATHEROS_AR5312)
503 +# define cpu_has_llsc 1
506 + * The MIPS 4Kc V0.9 core in the AR5312/AR2312 have problems with the
507 + * ll/sc instructions.
509 +# define cpu_has_llsc 0
512 +#define cpu_has_mips16 0
513 +#define cpu_has_mdmx 0
514 +#define cpu_has_mips3d 0
515 +#define cpu_has_smartmips 0
517 +/* #define cpu_has_vtag_icache ? */
518 +/* #define cpu_has_dc_aliases ? */
519 +/* #define cpu_has_ic_fills_f_dc ? */
520 +/* #define cpu_has_pindexed_dcache ? */
522 +/* #define cpu_icache_snoops_remote_store ? */
524 +#define cpu_has_mips32r1 1
526 +#if !defined(CONFIG_ATHEROS_AR5312)
527 +# define cpu_has_mips32r2 1
530 +#define cpu_has_mips64r1 0
531 +#define cpu_has_mips64r2 0
533 +#define cpu_has_dsp 0
534 +#define cpu_has_mipsmt 0
536 +/* #define cpu_has_nofpuex ? */
537 +#define cpu_has_64bits 0
538 +#define cpu_has_64bit_zero_reg 0
539 +#define cpu_has_64bit_gp_regs 0
540 +#define cpu_has_64bit_addresses 0
542 +/* #define cpu_has_inclusive_pcaches ? */
544 +/* #define cpu_dcache_line_size() ? */
545 +/* #define cpu_icache_line_size() ? */
547 +#endif /* __ASM_MACH_ATHEROS_CPU_FEATURE_OVERRIDES_H */
549 +++ b/arch/mips/include/asm/mach-ar231x/dma-coherence.h
552 + * This file is subject to the terms and conditions of the GNU General Public
553 + * License. See the file "COPYING" in the main directory of this archive
554 + * for more details.
556 + * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
557 + * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org>
560 +#ifndef __ASM_MACH_GENERIC_DMA_COHERENCE_H
561 +#define __ASM_MACH_GENERIC_DMA_COHERENCE_H
563 +#define PCI_DMA_OFFSET 0x20000000
567 +static dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size)
569 + return virt_to_phys(addr) + (dev != NULL ? PCI_DMA_OFFSET : 0);
572 +static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
574 + return page_to_phys(page) + (dev != NULL ? PCI_DMA_OFFSET : 0);
577 +static unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
579 + return (dma_addr > PCI_DMA_OFFSET ? dma_addr - PCI_DMA_OFFSET : dma_addr);
582 +static void plat_unmap_dma_mem(dma_addr_t dma_addr)
586 +static inline int plat_device_is_coherent(struct device *dev)
591 +#endif /* __ASM_MACH_GENERIC_DMA_COHERENCE_H */
593 +++ b/arch/mips/include/asm/mach-ar231x/gpio.h
595 +#ifndef _ATHEROS_GPIO_H_
596 +#define _ATHEROS_GPIO_H_
600 +struct ar231x_gpiodev {
602 + u32 (*get_output)(void);
603 + u32 (*set_output)(u32 mask, u32 val);
605 + u32 (*set)(u32 mask, u32 val);
608 +extern const struct ar231x_gpiodev *ar231x_gpiodev;
611 + * Wrappers for the generic GPIO layer
614 +static inline int gpio_direction_input(unsigned gpio) {
615 + u32 mask = 1 << gpio;
617 + if (!(ar231x_gpiodev->valid_mask & mask))
620 + ar231x_gpiodev->set_output(mask, 0);
624 +static inline void gpio_set_value(unsigned gpio, int value) {
625 + u32 mask = 1 << gpio;
627 + if (!(ar231x_gpiodev->valid_mask & mask))
630 + ar231x_gpiodev->set(mask, (!!value) * mask);
633 +static inline int gpio_direction_output(unsigned gpio, int value) {
634 + u32 mask = 1 << gpio;
636 + if (!(ar231x_gpiodev->valid_mask & mask))
639 + ar231x_gpiodev->set_output(mask, mask);
640 + ar231x_gpiodev->set(mask, (!!value) * mask);
644 +/* Reads the gpio pin. Unchecked function */
645 +static inline int gpio_get_value(unsigned gpio) {
646 + u32 mask = 1 << gpio;
648 + if (!(ar231x_gpiodev->valid_mask & mask))
651 + return !!(ar231x_gpiodev->get() & mask);
654 +static inline int gpio_request(unsigned gpio, const char *label) {
658 +static inline void gpio_free(unsigned gpio) {
661 +/* Returns IRQ to attach for gpio. Unchecked function */
662 +static inline int gpio_to_irq(unsigned gpio) {
663 + return AR531X_GPIO_IRQ(gpio);
666 +/* Returns gpio for IRQ attached. Unchecked function */
667 +static inline int irq_to_gpio(unsigned irq) {
668 + return (irq - (AR531X_GPIO_IRQ(0)));
671 +#include <asm-generic/gpio.h> /* cansleep wrappers */
675 +++ b/arch/mips/include/asm/mach-ar231x/reset.h
677 +#ifndef __AR531X_RESET_H
678 +#define __AR531X_RESET_H
680 +void ar531x_disable_reset_button(void);
682 +#endif /* __AR531X_RESET_H */
684 +++ b/arch/mips/include/asm/mach-ar231x/war.h
687 + * This file is subject to the terms and conditions of the GNU General Public
688 + * License. See the file "COPYING" in the main directory of this archive
689 + * for more details.
691 + * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
693 +#ifndef __ASM_MIPS_MACH_ATHEROS_WAR_H
694 +#define __ASM_MIPS_MACH_ATHEROS_WAR_H
696 +#define R4600_V1_INDEX_ICACHEOP_WAR 0
697 +#define R4600_V1_HIT_CACHEOP_WAR 0
698 +#define R4600_V2_HIT_CACHEOP_WAR 0
699 +#define R5432_CP0_INTERRUPT_WAR 0
700 +#define BCM1250_M3_WAR 0
701 +#define SIBYTE_1956_WAR 0
702 +#define MIPS4K_ICACHE_REFILL_WAR 0
703 +#define MIPS_CACHE_SYNC_WAR 0
704 +#define TX49XX_ICACHE_INDEX_INV_WAR 0
705 +#define RM9000_CDEX_SMP_WAR 0
706 +#define ICACHE_REFILLS_WORKAROUND_WAR 0
707 +#define R10000_LLSC_WAR 0
708 +#define MIPS34K_MISSED_ITLB_WAR 0
710 +#endif /* __ASM_MIPS_MACH_ATHEROS_WAR_H */
712 +++ b/arch/mips/include/asm/mach-ar231x/ar2315_regs.h
715 + * Register definitions for AR2315+
717 + * This file is subject to the terms and conditions of the GNU General Public
718 + * License. See the file "COPYING" in the main directory of this archive
719 + * for more details.
721 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
722 + * Copyright (C) 2006 FON Technology, SL.
723 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
724 + * Copyright (C) 2006-2008 Felix Fietkau <nbd@openwrt.org>
727 +#ifndef __AR2315_REG_H
728 +#define __AR2315_REG_H
733 +#define AR2315_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
734 +#define AR2315_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
735 +#define AR2315_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
736 +#define AR2315_IRQ_LCBUS_PCI MIPS_CPU_IRQ_BASE+5 /* C0_CAUSE: 0x2000 */
737 +#define AR2315_IRQ_WLAN0_POLL MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
742 +#define AR2315_SPI_READ 0x08000000 /* SPI FLASH */
743 +#define AR2315_WLAN0 0xB0000000 /* Wireless MMR */
744 +#define AR2315_PCI 0xB0100000 /* PCI MMR */
745 +#define AR2315_SDRAMCTL 0xB0300000 /* SDRAM MMR */
746 +#define AR2315_LOCAL 0xB0400000 /* LOCAL BUS MMR */
747 +#define AR2315_ENET0 0xB0500000 /* ETHERNET MMR */
748 +#define AR2315_DSLBASE 0xB1000000 /* RESET CONTROL MMR */
749 +#define AR2315_UART0 0xB1100003 /* UART MMR */
750 +#define AR2315_SPI 0xB1300000 /* SPI FLASH MMR */
751 +#define AR2315_PCIEXT 0x80000000 /* pci external */
756 +#define AR2315_COLD_RESET (AR2315_DSLBASE + 0x0000)
758 +#define AR2315_RESET_COLD_AHB 0x00000001
759 +#define AR2315_RESET_COLD_APB 0x00000002
760 +#define AR2315_RESET_COLD_CPU 0x00000004
761 +#define AR2315_RESET_COLD_CPUWARM 0x00000008
762 +#define AR2315_RESET_SYSTEM (RESET_COLD_CPU | RESET_COLD_APB | RESET_COLD_AHB) /* full system */
763 +#define AR2317_RESET_SYSTEM 0x00000010
766 +#define AR2315_RESET (AR2315_DSLBASE + 0x0004)
768 +#define AR2315_RESET_WARM_WLAN0_MAC 0x00000001 /* warm reset WLAN0 MAC */
769 +#define AR2315_RESET_WARM_WLAN0_BB 0x00000002 /* warm reset WLAN0 BaseBand */
770 +#define AR2315_RESET_MPEGTS_RSVD 0x00000004 /* warm reset MPEG-TS */
771 +#define AR2315_RESET_PCIDMA 0x00000008 /* warm reset PCI ahb/dma */
772 +#define AR2315_RESET_MEMCTL 0x00000010 /* warm reset memory controller */
773 +#define AR2315_RESET_LOCAL 0x00000020 /* warm reset local bus */
774 +#define AR2315_RESET_I2C_RSVD 0x00000040 /* warm reset I2C bus */
775 +#define AR2315_RESET_SPI 0x00000080 /* warm reset SPI interface */
776 +#define AR2315_RESET_UART0 0x00000100 /* warm reset UART0 */
777 +#define AR2315_RESET_IR_RSVD 0x00000200 /* warm reset IR interface */
778 +#define AR2315_RESET_EPHY0 0x00000400 /* cold reset ENET0 phy */
779 +#define AR2315_RESET_ENET0 0x00000800 /* cold reset ENET0 mac */
782 + * AHB master arbitration control
784 +#define AR2315_AHB_ARB_CTL (AR2315_DSLBASE + 0x0008)
786 +#define AR2315_ARB_CPU 0x00000001 /* CPU, default */
787 +#define AR2315_ARB_WLAN 0x00000002 /* WLAN */
788 +#define AR2315_ARB_MPEGTS_RSVD 0x00000004 /* MPEG-TS */
789 +#define AR2315_ARB_LOCAL 0x00000008 /* LOCAL */
790 +#define AR2315_ARB_PCI 0x00000010 /* PCI */
791 +#define AR2315_ARB_ETHERNET 0x00000020 /* Ethernet */
792 +#define AR2315_ARB_RETRY 0x00000100 /* retry policy, debug only */
797 +#define AR2315_ENDIAN_CTL (AR2315_DSLBASE + 0x000c)
799 +#define AR2315_CONFIG_AHB 0x00000001 /* EC - AHB bridge endianess */
800 +#define AR2315_CONFIG_WLAN 0x00000002 /* WLAN byteswap */
801 +#define AR2315_CONFIG_MPEGTS_RSVD 0x00000004 /* MPEG-TS byteswap */
802 +#define AR2315_CONFIG_PCI 0x00000008 /* PCI byteswap */
803 +#define AR2315_CONFIG_MEMCTL 0x00000010 /* Memory controller endianess */
804 +#define AR2315_CONFIG_LOCAL 0x00000020 /* Local bus byteswap */
805 +#define AR2315_CONFIG_ETHERNET 0x00000040 /* Ethernet byteswap */
807 +#define AR2315_CONFIG_MERGE 0x00000200 /* CPU write buffer merge */
808 +#define AR2315_CONFIG_CPU 0x00000400 /* CPU big endian */
809 +#define AR2315_CONFIG_PCIAHB 0x00000800
810 +#define AR2315_CONFIG_PCIAHB_BRIDGE 0x00001000
811 +#define AR2315_CONFIG_SPI 0x00008000 /* SPI byteswap */
812 +#define AR2315_CONFIG_CPU_DRAM 0x00010000
813 +#define AR2315_CONFIG_CPU_PCI 0x00020000
814 +#define AR2315_CONFIG_CPU_MMR 0x00040000
815 +#define AR2315_CONFIG_BIG 0x00000400
821 +#define AR2315_NMI_CTL (AR2315_DSLBASE + 0x0010)
823 +#define AR2315_NMI_EN 1
826 + * Revision Register - Initial value is 0x3010 (WMAC 3.0, AR531X 1.0).
828 +#define AR2315_SREV (AR2315_DSLBASE + 0x0014)
830 +#define AR2315_REV_MAJ 0x00f0
831 +#define AR2315_REV_MAJ_S 4
832 +#define AR2315_REV_MIN 0x000f
833 +#define AR2315_REV_MIN_S 0
834 +#define AR2315_REV_CHIP (AR2315_REV_MAJ|AR2315_REV_MIN)
839 +#define AR2315_IF_CTL (AR2315_DSLBASE + 0x0018)
841 +#define AR2315_IF_MASK 0x00000007
842 +#define AR2315_IF_DISABLED 0
843 +#define AR2315_IF_PCI 1
844 +#define AR2315_IF_TS_LOCAL 2
845 +#define AR2315_IF_ALL 3 /* only for emulation with separate pins */
846 +#define AR2315_IF_LOCAL_HOST 0x00000008
847 +#define AR2315_IF_PCI_HOST 0x00000010
848 +#define AR2315_IF_PCI_INTR 0x00000020
849 +#define AR2315_IF_PCI_CLK_MASK 0x00030000
850 +#define AR2315_IF_PCI_CLK_INPUT 0
851 +#define AR2315_IF_PCI_CLK_OUTPUT_LOW 1
852 +#define AR2315_IF_PCI_CLK_OUTPUT_CLK 2
853 +#define AR2315_IF_PCI_CLK_OUTPUT_HIGH 3
854 +#define AR2315_IF_PCI_CLK_SHIFT 16
857 + * APB Interrupt control
860 +#define AR2315_ISR (AR2315_DSLBASE + 0x0020)
861 +#define AR2315_IMR (AR2315_DSLBASE + 0x0024)
862 +#define AR2315_GISR (AR2315_DSLBASE + 0x0028)
864 +#define AR2315_ISR_UART0 0x0001 /* high speed UART */
865 +#define AR2315_ISR_I2C_RSVD 0x0002 /* I2C bus */
866 +#define AR2315_ISR_SPI 0x0004 /* SPI bus */
867 +#define AR2315_ISR_AHB 0x0008 /* AHB error */
868 +#define AR2315_ISR_APB 0x0010 /* APB error */
869 +#define AR2315_ISR_TIMER 0x0020 /* timer */
870 +#define AR2315_ISR_GPIO 0x0040 /* GPIO */
871 +#define AR2315_ISR_WD 0x0080 /* watchdog */
872 +#define AR2315_ISR_IR_RSVD 0x0100 /* IR */
874 +#define AR2315_GISR_MISC 0x0001
875 +#define AR2315_GISR_WLAN0 0x0002
876 +#define AR2315_GISR_MPEGTS_RSVD 0x0004
877 +#define AR2315_GISR_LOCALPCI 0x0008
878 +#define AR2315_GISR_WMACPOLL 0x0010
879 +#define AR2315_GISR_TIMER 0x0020
880 +#define AR2315_GISR_ETHERNET 0x0040
883 + * Interrupt routing from IO to the processor IP bits
884 + * Define our inter mask and level
886 +#define AR2315_INTR_MISCIO SR_IBIT3
887 +#define AR2315_INTR_WLAN0 SR_IBIT4
888 +#define AR2315_INTR_ENET0 SR_IBIT5
889 +#define AR2315_INTR_LOCALPCI SR_IBIT6
890 +#define AR2315_INTR_WMACPOLL SR_IBIT7
891 +#define AR2315_INTR_COMPARE SR_IBIT8
896 +#define AR2315_TIMER (AR2315_DSLBASE + 0x0030)
897 +#define AR2315_RELOAD (AR2315_DSLBASE + 0x0034)
898 +#define AR2315_WD (AR2315_DSLBASE + 0x0038)
899 +#define AR2315_WDC (AR2315_DSLBASE + 0x003c)
901 +#define AR2315_WDC_IGNORE_EXPIRATION 0x00000000
902 +#define AR2315_WDC_NMI 0x00000001 /* NMI on watchdog */
903 +#define AR2315_WDC_RESET 0x00000002 /* reset on watchdog */
906 + * CPU Performance Counters
908 +#define AR2315_PERFCNT0 (AR2315_DSLBASE + 0x0048)
909 +#define AR2315_PERFCNT1 (AR2315_DSLBASE + 0x004c)
911 +#define AR2315_PERF0_DATAHIT 0x0001 /* Count Data Cache Hits */
912 +#define AR2315_PERF0_DATAMISS 0x0002 /* Count Data Cache Misses */
913 +#define AR2315_PERF0_INSTHIT 0x0004 /* Count Instruction Cache Hits */
914 +#define AR2315_PERF0_INSTMISS 0x0008 /* Count Instruction Cache Misses */
915 +#define AR2315_PERF0_ACTIVE 0x0010 /* Count Active Processor Cycles */
916 +#define AR2315_PERF0_WBHIT 0x0020 /* Count CPU Write Buffer Hits */
917 +#define AR2315_PERF0_WBMISS 0x0040 /* Count CPU Write Buffer Misses */
919 +#define AR2315_PERF1_EB_ARDY 0x0001 /* Count EB_ARdy signal */
920 +#define AR2315_PERF1_EB_AVALID 0x0002 /* Count EB_AValid signal */
921 +#define AR2315_PERF1_EB_WDRDY 0x0004 /* Count EB_WDRdy signal */
922 +#define AR2315_PERF1_EB_RDVAL 0x0008 /* Count EB_RdVal signal */
923 +#define AR2315_PERF1_VRADDR 0x0010 /* Count valid read address cycles */
924 +#define AR2315_PERF1_VWADDR 0x0020 /* Count valid write address cycles */
925 +#define AR2315_PERF1_VWDATA 0x0040 /* Count valid write data cycles */
928 + * AHB Error Reporting.
930 +#define AR2315_AHB_ERR0 (AR2315_DSLBASE + 0x0050) /* error */
931 +#define AR2315_AHB_ERR1 (AR2315_DSLBASE + 0x0054) /* haddr */
932 +#define AR2315_AHB_ERR2 (AR2315_DSLBASE + 0x0058) /* hwdata */
933 +#define AR2315_AHB_ERR3 (AR2315_DSLBASE + 0x005c) /* hrdata */
934 +#define AR2315_AHB_ERR4 (AR2315_DSLBASE + 0x0060) /* status */
936 +#define AHB_ERROR_DET 1 /* AHB Error has been detected, */
937 + /* write 1 to clear all bits in ERR0 */
938 +#define AHB_ERROR_OVR 2 /* AHB Error overflow has been detected */
939 +#define AHB_ERROR_WDT 4 /* AHB Error due to wdt instead of hresp */
941 +#define AR2315_PROCERR_HMAST 0x0000000f
942 +#define AR2315_PROCERR_HMAST_DFLT 0
943 +#define AR2315_PROCERR_HMAST_WMAC 1
944 +#define AR2315_PROCERR_HMAST_ENET 2
945 +#define AR2315_PROCERR_HMAST_PCIENDPT 3
946 +#define AR2315_PROCERR_HMAST_LOCAL 4
947 +#define AR2315_PROCERR_HMAST_CPU 5
948 +#define AR2315_PROCERR_HMAST_PCITGT 6
950 +#define AR2315_PROCERR_HMAST_S 0
951 +#define AR2315_PROCERR_HWRITE 0x00000010
952 +#define AR2315_PROCERR_HSIZE 0x00000060
953 +#define AR2315_PROCERR_HSIZE_S 5
954 +#define AR2315_PROCERR_HTRANS 0x00000180
955 +#define AR2315_PROCERR_HTRANS_S 7
956 +#define AR2315_PROCERR_HBURST 0x00000e00
957 +#define AR2315_PROCERR_HBURST_S 9
962 +#define AR2315_PLLC_CTL (AR2315_DSLBASE + 0x0064)
963 +#define AR2315_PLLV_CTL (AR2315_DSLBASE + 0x0068)
964 +#define AR2315_CPUCLK (AR2315_DSLBASE + 0x006c)
965 +#define AR2315_AMBACLK (AR2315_DSLBASE + 0x0070)
966 +#define AR2315_SYNCCLK (AR2315_DSLBASE + 0x0074)
967 +#define AR2315_DSL_SLEEP_CTL (AR2315_DSLBASE + 0x0080)
968 +#define AR2315_DSL_SLEEP_DUR (AR2315_DSLBASE + 0x0084)
970 +/* PLLc Control fields */
971 +#define PLLC_REF_DIV_M 0x00000003
972 +#define PLLC_REF_DIV_S 0
973 +#define PLLC_FDBACK_DIV_M 0x0000007C
974 +#define PLLC_FDBACK_DIV_S 2
975 +#define PLLC_ADD_FDBACK_DIV_M 0x00000080
976 +#define PLLC_ADD_FDBACK_DIV_S 7
977 +#define PLLC_CLKC_DIV_M 0x0001c000
978 +#define PLLC_CLKC_DIV_S 14
979 +#define PLLC_CLKM_DIV_M 0x00700000
980 +#define PLLC_CLKM_DIV_S 20
982 +/* CPU CLK Control fields */
983 +#define CPUCLK_CLK_SEL_M 0x00000003
984 +#define CPUCLK_CLK_SEL_S 0
985 +#define CPUCLK_CLK_DIV_M 0x0000000c
986 +#define CPUCLK_CLK_DIV_S 2
988 +/* AMBA CLK Control fields */
989 +#define AMBACLK_CLK_SEL_M 0x00000003
990 +#define AMBACLK_CLK_SEL_S 0
991 +#define AMBACLK_CLK_DIV_M 0x0000000c
992 +#define AMBACLK_CLK_DIV_S 2
997 +#define AR2315_GPIO_DI (AR2315_DSLBASE + 0x0088)
998 +#define AR2315_GPIO_DO (AR2315_DSLBASE + 0x0090)
999 +#define AR2315_GPIO_CR (AR2315_DSLBASE + 0x0098)
1000 +#define AR2315_GPIO_INT (AR2315_DSLBASE + 0x00a0)
1002 +#define AR2315_GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
1003 +#define AR2315_GPIO_CR_O(x) (1 << (x)) /* output */
1004 +#define AR2315_GPIO_CR_I(x) (0) /* input */
1006 +#define AR2315_GPIO_INT_S(x) (x) /* interrupt enable */
1007 +#define AR2315_GPIO_INT_M (0x3F) /* mask for int */
1008 +#define AR2315_GPIO_INT_LVL(x) ((x) << 6) /* interrupt level */
1009 +#define AR2315_GPIO_INT_LVL_M ((0x3) << 6) /* mask for int level */
1011 +#define AR2315_GPIO_INT_MAX_Y 1 /* Maximum value of Y for AR5313_GPIO_INT_* macros */
1012 +#define AR2315_GPIO_INT_LVL_OFF 0 /* Triggerring off */
1013 +#define AR2315_GPIO_INT_LVL_LOW 1 /* Low Level Triggered */
1014 +#define AR2315_GPIO_INT_LVL_HIGH 2 /* High Level Triggered */
1015 +#define AR2315_GPIO_INT_LVL_EDGE 3 /* Edge Triggered */
1017 +#define AR2315_RESET_GPIO 5
1018 +#define AR2315_NUM_GPIO 22
1021 + * PCI Clock Control
1023 +#define AR2315_PCICLK (AR2315_DSLBASE + 0x00a4)
1025 +#define AR2315_PCICLK_INPUT_M 0x3
1026 +#define AR2315_PCICLK_INPUT_S 0
1028 +#define AR2315_PCICLK_PLLC_CLKM 0
1029 +#define AR2315_PCICLK_PLLC_CLKM1 1
1030 +#define AR2315_PCICLK_PLLC_CLKC 2
1031 +#define AR2315_PCICLK_REF_CLK 3
1033 +#define AR2315_PCICLK_DIV_M 0xc
1034 +#define AR2315_PCICLK_DIV_S 2
1036 +#define AR2315_PCICLK_IN_FREQ 0
1037 +#define AR2315_PCICLK_IN_FREQ_DIV_6 1
1038 +#define AR2315_PCICLK_IN_FREQ_DIV_8 2
1039 +#define AR2315_PCICLK_IN_FREQ_DIV_10 3
1042 + * Observation Control Register
1044 +#define AR2315_OCR (AR2315_DSLBASE + 0x00b0)
1045 +#define OCR_GPIO0_IRIN 0x0040
1046 +#define OCR_GPIO1_IROUT 0x0080
1047 +#define OCR_GPIO3_RXCLR 0x0200
1050 + * General Clock Control
1053 +#define AR2315_MISCCLK (AR2315_DSLBASE + 0x00b4)
1054 +#define MISCCLK_PLLBYPASS_EN 0x00000001
1055 +#define MISCCLK_PROCREFCLK 0x00000002
1058 + * SDRAM Controller
1059 + * - No read or write buffers are included.
1061 +#define AR2315_MEM_CFG (AR2315_SDRAMCTL + 0x00)
1062 +#define AR2315_MEM_CTRL (AR2315_SDRAMCTL + 0x0c)
1063 +#define AR2315_MEM_REF (AR2315_SDRAMCTL + 0x10)
1065 +#define SDRAM_DATA_WIDTH_M 0x00006000
1066 +#define SDRAM_DATA_WIDTH_S 13
1068 +#define SDRAM_COL_WIDTH_M 0x00001E00
1069 +#define SDRAM_COL_WIDTH_S 9
1071 +#define SDRAM_ROW_WIDTH_M 0x000001E0
1072 +#define SDRAM_ROW_WIDTH_S 5
1074 +#define SDRAM_BANKADDR_BITS_M 0x00000018
1075 +#define SDRAM_BANKADDR_BITS_S 3
1078 + * SPI Flash Interface Registers
1081 +#define AR2315_SPI_CTL (AR2315_SPI + 0x00)
1082 +#define AR2315_SPI_OPCODE (AR2315_SPI + 0x04)
1083 +#define AR2315_SPI_DATA (AR2315_SPI + 0x08)
1085 +#define SPI_CTL_START 0x00000100
1086 +#define SPI_CTL_BUSY 0x00010000
1087 +#define SPI_CTL_TXCNT_MASK 0x0000000f
1088 +#define SPI_CTL_RXCNT_MASK 0x000000f0
1089 +#define SPI_CTL_TX_RX_CNT_MASK 0x000000ff
1090 +#define SPI_CTL_SIZE_MASK 0x00060000
1092 +#define SPI_CTL_CLK_SEL_MASK 0x03000000
1093 +#define SPI_OPCODE_MASK 0x000000ff
1096 + * PCI Bus Interface Registers
1098 +#define AR2315_PCI_1MS_REG (AR2315_PCI + 0x0008)
1099 +#define AR2315_PCI_1MS_MASK 0x3FFFF /* # of AHB clk cycles in 1ms */
1101 +#define AR2315_PCI_MISC_CONFIG (AR2315_PCI + 0x000c)
1102 +#define AR2315_PCIMISC_TXD_EN 0x00000001 /* Enable TXD for fragments */
1103 +#define AR2315_PCIMISC_CFG_SEL 0x00000002 /* mem or config cycles */
1104 +#define AR2315_PCIMISC_GIG_MASK 0x0000000C /* bits 31-30 for pci req */
1105 +#define AR2315_PCIMISC_RST_MODE 0x00000030
1106 +#define AR2315_PCIRST_INPUT 0x00000000 /* 4:5=0 rst is input */
1107 +#define AR2315_PCIRST_LOW 0x00000010 /* 4:5=1 rst to GND */
1108 +#define AR2315_PCIRST_HIGH 0x00000020 /* 4:5=2 rst to VDD */
1109 +#define AR2315_PCIGRANT_EN 0x00000000 /* 6:7=0 early grant en */
1110 +#define AR2315_PCIGRANT_FRAME 0x00000040 /* 6:7=1 grant waits 4 frame */
1111 +#define AR2315_PCIGRANT_IDLE 0x00000080 /* 6:7=2 grant waits 4 idle */
1112 +#define AR2315_PCIGRANT_GAP 0x00000000 /* 6:7=2 grant waits 4 idle */
1113 +#define AR2315_PCICACHE_DIS 0x00001000 /* PCI external access cache disable */
1115 +#define AR2315_PCI_OUT_TSTAMP (AR2315_PCI + 0x0010)
1117 +#define AR2315_PCI_UNCACHE_CFG (AR2315_PCI + 0x0014)
1119 +#define AR2315_PCI_IN_EN (AR2315_PCI + 0x0100)
1120 +#define AR2315_PCI_IN_EN0 0x01 /* Enable chain 0 */
1121 +#define AR2315_PCI_IN_EN1 0x02 /* Enable chain 1 */
1122 +#define AR2315_PCI_IN_EN2 0x04 /* Enable chain 2 */
1123 +#define AR2315_PCI_IN_EN3 0x08 /* Enable chain 3 */
1125 +#define AR2315_PCI_IN_DIS (AR2315_PCI + 0x0104)
1126 +#define AR2315_PCI_IN_DIS0 0x01 /* Disable chain 0 */
1127 +#define AR2315_PCI_IN_DIS1 0x02 /* Disable chain 1 */
1128 +#define AR2315_PCI_IN_DIS2 0x04 /* Disable chain 2 */
1129 +#define AR2315_PCI_IN_DIS3 0x08 /* Disable chain 3 */
1131 +#define AR2315_PCI_IN_PTR (AR2315_PCI + 0x0200)
1133 +#define AR2315_PCI_OUT_EN (AR2315_PCI + 0x0400)
1134 +#define AR2315_PCI_OUT_EN0 0x01 /* Enable chain 0 */
1136 +#define AR2315_PCI_OUT_DIS (AR2315_PCI + 0x0404)
1137 +#define AR2315_PCI_OUT_DIS0 0x01 /* Disable chain 0 */
1139 +#define AR2315_PCI_OUT_PTR (AR2315_PCI + 0x0408)
1141 +#define AR2315_PCI_INT_STATUS (AR2315_PCI + 0x0500) /* write one to clr */
1142 +#define AR2315_PCI_TXINT 0x00000001 /* Desc In Completed */
1143 +#define AR2315_PCI_TXOK 0x00000002 /* Desc In OK */
1144 +#define AR2315_PCI_TXERR 0x00000004 /* Desc In ERR */
1145 +#define AR2315_PCI_TXEOL 0x00000008 /* Desc In End-of-List */
1146 +#define AR2315_PCI_RXINT 0x00000010 /* Desc Out Completed */
1147 +#define AR2315_PCI_RXOK 0x00000020 /* Desc Out OK */
1148 +#define AR2315_PCI_RXERR 0x00000040 /* Desc Out ERR */
1149 +#define AR2315_PCI_RXEOL 0x00000080 /* Desc Out EOL */
1150 +#define AR2315_PCI_TXOOD 0x00000200 /* Desc In Out-of-Desc */
1151 +#define AR2315_PCI_MASK 0x0000FFFF /* Desc Mask */
1152 +#define AR2315_PCI_EXT_INT 0x02000000
1153 +#define AR2315_PCI_ABORT_INT 0x04000000
1155 +#define AR2315_PCI_INT_MASK (AR2315_PCI + 0x0504) /* same as INT_STATUS */
1157 +#define AR2315_PCI_INTEN_REG (AR2315_PCI + 0x0508)
1158 +#define AR2315_PCI_INT_DISABLE 0x00 /* disable pci interrupts */
1159 +#define AR2315_PCI_INT_ENABLE 0x01 /* enable pci interrupts */
1161 +#define AR2315_PCI_HOST_IN_EN (AR2315_PCI + 0x0800)
1162 +#define AR2315_PCI_HOST_IN_DIS (AR2315_PCI + 0x0804)
1163 +#define AR2315_PCI_HOST_IN_PTR (AR2315_PCI + 0x0810)
1164 +#define AR2315_PCI_HOST_OUT_EN (AR2315_PCI + 0x0900)
1165 +#define AR2315_PCI_HOST_OUT_DIS (AR2315_PCI + 0x0904)
1166 +#define AR2315_PCI_HOST_OUT_PTR (AR2315_PCI + 0x0908)
1170 + * Local Bus Interface Registers
1172 +#define AR2315_LB_CONFIG (AR2315_LOCAL + 0x0000)
1173 +#define AR2315_LBCONF_OE 0x00000001 /* =1 OE is low-true */
1174 +#define AR2315_LBCONF_CS0 0x00000002 /* =1 first CS is low-true */
1175 +#define AR2315_LBCONF_CS1 0x00000004 /* =1 2nd CS is low-true */
1176 +#define AR2315_LBCONF_RDY 0x00000008 /* =1 RDY is low-true */
1177 +#define AR2315_LBCONF_WE 0x00000010 /* =1 Write En is low-true */
1178 +#define AR2315_LBCONF_WAIT 0x00000020 /* =1 WAIT is low-true */
1179 +#define AR2315_LBCONF_ADS 0x00000040 /* =1 Adr Strobe is low-true */
1180 +#define AR2315_LBCONF_MOT 0x00000080 /* =0 Intel, =1 Motorola */
1181 +#define AR2315_LBCONF_8CS 0x00000100 /* =1 8 bits CS, 0= 16bits */
1182 +#define AR2315_LBCONF_8DS 0x00000200 /* =1 8 bits Data S, 0=16bits */
1183 +#define AR2315_LBCONF_ADS_EN 0x00000400 /* =1 Enable ADS */
1184 +#define AR2315_LBCONF_ADR_OE 0x00000800 /* =1 Adr cap on OE, WE or DS */
1185 +#define AR2315_LBCONF_ADDT_MUX 0x00001000 /* =1 Adr and Data share bus */
1186 +#define AR2315_LBCONF_DATA_OE 0x00002000 /* =1 Data cap on OE, WE, DS */
1187 +#define AR2315_LBCONF_16DATA 0x00004000 /* =1 Data is 16 bits wide */
1188 +#define AR2315_LBCONF_SWAPDT 0x00008000 /* =1 Byte swap data */
1189 +#define AR2315_LBCONF_SYNC 0x00010000 /* =1 Bus synchronous to clk */
1190 +#define AR2315_LBCONF_INT 0x00020000 /* =1 Intr is low true */
1191 +#define AR2315_LBCONF_INT_CTR0 0x00000000 /* GND high-Z, Vdd is high-Z */
1192 +#define AR2315_LBCONF_INT_CTR1 0x00040000 /* GND drive, Vdd is high-Z */
1193 +#define AR2315_LBCONF_INT_CTR2 0x00080000 /* GND high-Z, Vdd drive */
1194 +#define AR2315_LBCONF_INT_CTR3 0x000C0000 /* GND drive, Vdd drive */
1195 +#define AR2315_LBCONF_RDY_WAIT 0x00100000 /* =1 RDY is negative of WAIT */
1196 +#define AR2315_LBCONF_INT_PULSE 0x00200000 /* =1 Interrupt is a pulse */
1197 +#define AR2315_LBCONF_ENABLE 0x00400000 /* =1 Falcon respond to LB */
1199 +#define AR2315_LB_CLKSEL (AR2315_LOCAL + 0x0004)
1200 +#define AR2315_LBCLK_EXT 0x0001 /* use external clk for lb */
1202 +#define AR2315_LB_1MS (AR2315_LOCAL + 0x0008)
1203 +#define AR2315_LB1MS_MASK 0x3FFFF /* # of AHB clk cycles in 1ms */
1205 +#define AR2315_LB_MISCCFG (AR2315_LOCAL + 0x000C)
1206 +#define AR2315_LBM_TXD_EN 0x00000001 /* Enable TXD for fragments */
1207 +#define AR2315_LBM_RX_INTEN 0x00000002 /* Enable LB ints on RX ready */
1208 +#define AR2315_LBM_MBOXWR_INTEN 0x00000004 /* Enable LB ints on mbox wr */
1209 +#define AR2315_LBM_MBOXRD_INTEN 0x00000008 /* Enable LB ints on mbox rd */
1210 +#define AR2315_LMB_DESCSWAP_EN 0x00000010 /* Byte swap desc enable */
1211 +#define AR2315_LBM_TIMEOUT_MASK 0x00FFFF80
1212 +#define AR2315_LBM_TIMEOUT_SHFT 7
1213 +#define AR2315_LBM_PORTMUX 0x07000000
1216 +#define AR2315_LB_RXTSOFF (AR2315_LOCAL + 0x0010)
1218 +#define AR2315_LB_TX_CHAIN_EN (AR2315_LOCAL + 0x0100)
1219 +#define AR2315_LB_TXEN_0 0x01
1220 +#define AR2315_LB_TXEN_1 0x02
1221 +#define AR2315_LB_TXEN_2 0x04
1222 +#define AR2315_LB_TXEN_3 0x08
1224 +#define AR2315_LB_TX_CHAIN_DIS (AR2315_LOCAL + 0x0104)
1225 +#define AR2315_LB_TX_DESC_PTR (AR2315_LOCAL + 0x0200)
1227 +#define AR2315_LB_RX_CHAIN_EN (AR2315_LOCAL + 0x0400)
1228 +#define AR2315_LB_RXEN 0x01
1230 +#define AR2315_LB_RX_CHAIN_DIS (AR2315_LOCAL + 0x0404)
1231 +#define AR2315_LB_RX_DESC_PTR (AR2315_LOCAL + 0x0408)
1233 +#define AR2315_LB_INT_STATUS (AR2315_LOCAL + 0x0500)
1234 +#define AR2315_INT_TX_DESC 0x0001
1235 +#define AR2315_INT_TX_OK 0x0002
1236 +#define AR2315_INT_TX_ERR 0x0004
1237 +#define AR2315_INT_TX_EOF 0x0008
1238 +#define AR2315_INT_RX_DESC 0x0010
1239 +#define AR2315_INT_RX_OK 0x0020
1240 +#define AR2315_INT_RX_ERR 0x0040
1241 +#define AR2315_INT_RX_EOF 0x0080
1242 +#define AR2315_INT_TX_TRUNC 0x0100
1243 +#define AR2315_INT_TX_STARVE 0x0200
1244 +#define AR2315_INT_LB_TIMEOUT 0x0400
1245 +#define AR2315_INT_LB_ERR 0x0800
1246 +#define AR2315_INT_MBOX_WR 0x1000
1247 +#define AR2315_INT_MBOX_RD 0x2000
1249 +/* Bit definitions for INT MASK are the same as INT_STATUS */
1250 +#define AR2315_LB_INT_MASK (AR2315_LOCAL + 0x0504)
1252 +#define AR2315_LB_INT_EN (AR2315_LOCAL + 0x0508)
1253 +#define AR2315_LB_MBOX (AR2315_LOCAL + 0x0600)
1256 + * IR Interface Registers
1258 +#define AR2315_IR_PKTDATA (AR2315_IR + 0x0000)
1260 +#define AR2315_IR_PKTLEN (AR2315_IR + 0x07fc) /* 0 - 63 */
1262 +#define AR2315_IR_CONTROL (AR2315_IR + 0x0800)
1263 +#define AR2315_IRCTL_TX 0x00000000 /* use as tranmitter */
1264 +#define AR2315_IRCTL_RX 0x00000001 /* use as receiver */
1265 +#define AR2315_IRCTL_SAMPLECLK_MASK 0x00003ffe /* Sample clk divisor mask */
1266 +#define AR2315_IRCTL_SAMPLECLK_SHFT 1
1267 +#define AR2315_IRCTL_OUTPUTCLK_MASK 0x03ffc000 /* Output clk divisor mask */
1268 +#define AR2315_IRCTL_OUTPUTCLK_SHFT 14
1270 +#define AR2315_IR_STATUS (AR2315_IR + 0x0804)
1271 +#define AR2315_IRSTS_RX 0x00000001 /* receive in progress */
1272 +#define AR2315_IRSTS_TX 0x00000002 /* transmit in progress */
1274 +#define AR2315_IR_CONFIG (AR2315_IR + 0x0808)
1275 +#define AR2315_IRCFG_INVIN 0x00000001 /* invert input polarity */
1276 +#define AR2315_IRCFG_INVOUT 0x00000002 /* invert output polarity */
1277 +#define AR2315_IRCFG_SEQ_START_WIN_SEL 0x00000004 /* 1 => 28, 0 => 7 */
1278 +#define AR2315_IRCFG_SEQ_START_THRESH 0x000000f0 /* */
1279 +#define AR2315_IRCFG_SEQ_END_UNIT_SEL 0x00000100 /* */
1280 +#define AR2315_IRCFG_SEQ_END_UNIT_THRESH 0x00007e00 /* */
1281 +#define AR2315_IRCFG_SEQ_END_WIN_SEL 0x00008000 /* */
1282 +#define AR2315_IRCFG_SEQ_END_WIN_THRESH 0x001f0000 /* */
1283 +#define AR2315_IRCFG_NUM_BACKOFF_WORDS 0x01e00000 /* */
1285 +#define HOST_PCI_DEV_ID 3
1286 +#define HOST_PCI_MBAR0 0x10000000
1287 +#define HOST_PCI_MBAR1 0x20000000
1288 +#define HOST_PCI_MBAR2 0x30000000
1290 +#define HOST_PCI_SDRAM_BASEADDR HOST_PCI_MBAR1
1291 +#define PCI_DEVICE_MEM_SPACE 0x800000
1293 +#endif /* __AR2315_REG_H */
1295 +++ b/arch/mips/include/asm/mach-ar231x/ar5312_regs.h
1298 + * This file is subject to the terms and conditions of the GNU General Public
1299 + * License. See the file "COPYING" in the main directory of this archive
1300 + * for more details.
1302 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
1303 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
1304 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
1310 +#include <asm/addrspace.h>
1316 +#define AR5312_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
1317 +#define AR5312_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
1318 +#define AR5312_IRQ_ENET1_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
1319 +#define AR5312_IRQ_WLAN1_INTRS MIPS_CPU_IRQ_BASE+5 /* C0_CAUSE: 0x2000 */
1320 +#define AR5312_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
1324 +#define AR531X_WLAN0 0x18000000
1325 +#define AR531X_WLAN1 0x18500000
1326 +#define AR531X_ENET0 0x18100000
1327 +#define AR531X_ENET1 0x18200000
1328 +#define AR531X_SDRAMCTL 0x18300000
1329 +#define AR531X_FLASHCTL 0x18400000
1330 +#define AR531X_APBBASE 0x1c000000
1331 +#define AR531X_FLASH 0x1e000000
1332 +#define AR531X_UART0 0xbc000003 /* UART MMR */
1335 + * AR531X_NUM_ENET_MAC defines the number of ethernet MACs that
1336 + * should be considered available. The AR5312 supports 2 enet MACS,
1337 + * even though many reference boards only actually use 1 of them
1338 + * (i.e. Only MAC 0 is actually connected to an enet PHY or PHY switch.
1339 + * The AR2312 supports 1 enet MAC.
1341 +#define AR531X_NUM_ENET_MAC 2
1344 + * Need these defines to determine true number of ethernet MACs
1346 +#define AR5212_AR5312_REV2 0x0052 /* AR5312 WMAC (AP31) */
1347 +#define AR5212_AR5312_REV7 0x0057 /* AR5312 WMAC (AP30-040) */
1348 +#define AR5212_AR2313_REV8 0x0058 /* AR2313 WMAC (AP43-030) */
1349 +#define AR531X_RADIO_MASK_OFF 0xc8
1350 +#define AR531X_RADIO0_MASK 0x0003
1351 +#define AR531X_RADIO1_MASK 0x000c
1352 +#define AR531X_RADIO1_S 2
1355 + * AR531X_NUM_WMAC defines the number of Wireless MACs that\
1356 + * should be considered available.
1358 +#define AR531X_NUM_WMAC 2
1360 +/* Reset/Timer Block Address Map */
1361 +#define AR531X_RESETTMR (AR531X_APBBASE + 0x3000)
1362 +#define AR531X_TIMER (AR531X_RESETTMR + 0x0000) /* countdown timer */
1363 +#define AR531X_WD_CTRL (AR531X_RESETTMR + 0x0008) /* watchdog cntrl */
1364 +#define AR531X_WD_TIMER (AR531X_RESETTMR + 0x000c) /* watchdog timer */
1365 +#define AR531X_ISR (AR531X_RESETTMR + 0x0010) /* Intr Status Reg */
1366 +#define AR531X_IMR (AR531X_RESETTMR + 0x0014) /* Intr Mask Reg */
1367 +#define AR531X_RESET (AR531X_RESETTMR + 0x0020)
1368 +#define AR5312_CLOCKCTL1 (AR531X_RESETTMR + 0x0064)
1369 +#define AR5312_SCRATCH (AR531X_RESETTMR + 0x006c)
1370 +#define AR531X_PROCADDR (AR531X_RESETTMR + 0x0070)
1371 +#define AR531X_PROC1 (AR531X_RESETTMR + 0x0074)
1372 +#define AR531X_DMAADDR (AR531X_RESETTMR + 0x0078)
1373 +#define AR531X_DMA1 (AR531X_RESETTMR + 0x007c)
1374 +#define AR531X_ENABLE (AR531X_RESETTMR + 0x0080) /* interface enb */
1375 +#define AR531X_REV (AR531X_RESETTMR + 0x0090) /* revision */
1377 +/* AR531X_WD_CTRL register bit field definitions */
1378 +#define AR531X_WD_CTRL_IGNORE_EXPIRATION 0x0000
1379 +#define AR531X_WD_CTRL_NMI 0x0001
1380 +#define AR531X_WD_CTRL_RESET 0x0002
1382 +/* AR531X_ISR register bit field definitions */
1383 +#define AR531X_ISR_NONE 0x0000
1384 +#define AR531X_ISR_TIMER 0x0001
1385 +#define AR531X_ISR_AHBPROC 0x0002
1386 +#define AR531X_ISR_AHBDMA 0x0004
1387 +#define AR531X_ISR_GPIO 0x0008
1388 +#define AR531X_ISR_UART0 0x0010
1389 +#define AR531X_ISR_UART0DMA 0x0020
1390 +#define AR531X_ISR_WD 0x0040
1391 +#define AR531X_ISR_LOCAL 0x0080
1393 +/* AR531X_RESET register bit field definitions */
1394 +#define AR531X_RESET_SYSTEM 0x00000001 /* cold reset full system */
1395 +#define AR531X_RESET_PROC 0x00000002 /* cold reset MIPS core */
1396 +#define AR531X_RESET_WLAN0 0x00000004 /* cold reset WLAN MAC and BB */
1397 +#define AR531X_RESET_EPHY0 0x00000008 /* cold reset ENET0 phy */
1398 +#define AR531X_RESET_EPHY1 0x00000010 /* cold reset ENET1 phy */
1399 +#define AR531X_RESET_ENET0 0x00000020 /* cold reset ENET0 mac */
1400 +#define AR531X_RESET_ENET1 0x00000040 /* cold reset ENET1 mac */
1401 +#define AR531X_RESET_UART0 0x00000100 /* cold reset UART0 (high speed) */
1402 +#define AR531X_RESET_WLAN1 0x00000200 /* cold reset WLAN MAC/BB */
1403 +#define AR531X_RESET_APB 0x00000400 /* cold reset APB (ar5312) */
1404 +#define AR531X_RESET_WARM_PROC 0x00001000 /* warm reset MIPS core */
1405 +#define AR531X_RESET_WARM_WLAN0_MAC 0x00002000 /* warm reset WLAN0 MAC */
1406 +#define AR531X_RESET_WARM_WLAN0_BB 0x00004000 /* warm reset WLAN0 BaseBand */
1407 +#define AR531X_RESET_NMI 0x00010000 /* send an NMI to the processor */
1408 +#define AR531X_RESET_WARM_WLAN1_MAC 0x00020000 /* warm reset WLAN1 mac */
1409 +#define AR531X_RESET_WARM_WLAN1_BB 0x00040000 /* warm reset WLAN1 baseband */
1410 +#define AR531X_RESET_LOCAL_BUS 0x00080000 /* reset local bus */
1411 +#define AR531X_RESET_WDOG 0x00100000 /* last reset was a watchdog */
1413 +#define AR531X_RESET_WMAC0_BITS \
1414 + AR531X_RESET_WLAN0 |\
1415 + AR531X_RESET_WARM_WLAN0_MAC |\
1416 + AR531X_RESET_WARM_WLAN0_BB
1418 +#define AR531X_RESERT_WMAC1_BITS \
1419 + AR531X_RESET_WLAN1 |\
1420 + AR531X_RESET_WARM_WLAN1_MAC |\
1421 + AR531X_RESET_WARM_WLAN1_BB
1423 +/* AR5312_CLOCKCTL1 register bit field definitions */
1424 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
1425 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
1426 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
1427 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
1428 +#define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
1430 +/* Valid for AR5312 and AR2312 */
1431 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
1432 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
1433 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
1434 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
1435 +#define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
1437 +/* Valid for AR2313 */
1438 +#define AR2313_CLOCKCTL1_PREDIVIDE_MASK 0x00003000
1439 +#define AR2313_CLOCKCTL1_PREDIVIDE_SHIFT 12
1440 +#define AR2313_CLOCKCTL1_MULTIPLIER_MASK 0x001f0000
1441 +#define AR2313_CLOCKCTL1_MULTIPLIER_SHIFT 16
1442 +#define AR2313_CLOCKCTL1_DOUBLER_MASK 0x00000000
1445 +/* AR531X_ENABLE register bit field definitions */
1446 +#define AR531X_ENABLE_WLAN0 0x0001
1447 +#define AR531X_ENABLE_ENET0 0x0002
1448 +#define AR531X_ENABLE_ENET1 0x0004
1449 +#define AR531X_ENABLE_UART_AND_WLAN1_PIO 0x0008 /* UART, and WLAN1 PIOs */
1450 +#define AR531X_ENABLE_WLAN1_DMA 0x0010 /* WLAN1 DMAs */
1451 +#define AR531X_ENABLE_WLAN1 \
1452 + (AR531X_ENABLE_UART_AND_WLAN1_PIO | AR531X_ENABLE_WLAN1_DMA)
1454 +/* AR531X_REV register bit field definitions */
1455 +#define AR531X_REV_WMAC_MAJ 0xf000
1456 +#define AR531X_REV_WMAC_MAJ_S 12
1457 +#define AR531X_REV_WMAC_MIN 0x0f00
1458 +#define AR531X_REV_WMAC_MIN_S 8
1459 +#define AR531X_REV_MAJ 0x00f0
1460 +#define AR531X_REV_MAJ_S 4
1461 +#define AR531X_REV_MIN 0x000f
1462 +#define AR531X_REV_MIN_S 0
1463 +#define AR531X_REV_CHIP (AR531X_REV_MAJ|AR531X_REV_MIN)
1465 +/* Major revision numbers, bits 7..4 of Revision ID register */
1466 +#define AR531X_REV_MAJ_AR5312 0x4
1467 +#define AR531X_REV_MAJ_AR2313 0x5
1469 +/* Minor revision numbers, bits 3..0 of Revision ID register */
1470 +#define AR5312_REV_MIN_DUAL 0x0 /* Dual WLAN version */
1471 +#define AR5312_REV_MIN_SINGLE 0x1 /* Single WLAN version */
1473 +/* AR531X_FLASHCTL register bit field definitions */
1474 +#define FLASHCTL_IDCY 0x0000000f /* Idle cycle turn around time */
1475 +#define FLASHCTL_IDCY_S 0
1476 +#define FLASHCTL_WST1 0x000003e0 /* Wait state 1 */
1477 +#define FLASHCTL_WST1_S 5
1478 +#define FLASHCTL_RBLE 0x00000400 /* Read byte lane enable */
1479 +#define FLASHCTL_WST2 0x0000f800 /* Wait state 2 */
1480 +#define FLASHCTL_WST2_S 11
1481 +#define FLASHCTL_AC 0x00070000 /* Flash address check (added) */
1482 +#define FLASHCTL_AC_S 16
1483 +#define FLASHCTL_AC_128K 0x00000000
1484 +#define FLASHCTL_AC_256K 0x00010000
1485 +#define FLASHCTL_AC_512K 0x00020000
1486 +#define FLASHCTL_AC_1M 0x00030000
1487 +#define FLASHCTL_AC_2M 0x00040000
1488 +#define FLASHCTL_AC_4M 0x00050000
1489 +#define FLASHCTL_AC_8M 0x00060000
1490 +#define FLASHCTL_AC_RES 0x00070000 /* 16MB is not supported */
1491 +#define FLASHCTL_E 0x00080000 /* Flash bank enable (added) */
1492 +#define FLASHCTL_BUSERR 0x01000000 /* Bus transfer error status flag */
1493 +#define FLASHCTL_WPERR 0x02000000 /* Write protect error status flag */
1494 +#define FLASHCTL_WP 0x04000000 /* Write protect */
1495 +#define FLASHCTL_BM 0x08000000 /* Burst mode */
1496 +#define FLASHCTL_MW 0x30000000 /* Memory width */
1497 +#define FLASHCTL_MWx8 0x00000000 /* Memory width x8 */
1498 +#define FLASHCTL_MWx16 0x10000000 /* Memory width x16 */
1499 +#define FLASHCTL_MWx32 0x20000000 /* Memory width x32 (not supported) */
1500 +#define FLASHCTL_ATNR 0x00000000 /* Access type == no retry */
1501 +#define FLASHCTL_ATR 0x80000000 /* Access type == retry every */
1502 +#define FLASHCTL_ATR4 0xc0000000 /* Access type == retry every 4 */
1504 +/* ARM Flash Controller -- 3 flash banks with either x8 or x16 devices. */
1505 +#define AR531X_FLASHCTL0 (AR531X_FLASHCTL + 0x00)
1506 +#define AR531X_FLASHCTL1 (AR531X_FLASHCTL + 0x04)
1507 +#define AR531X_FLASHCTL2 (AR531X_FLASHCTL + 0x08)
1509 +/* ARM SDRAM Controller -- just enough to determine memory size */
1510 +#define AR531X_MEM_CFG1 (AR531X_SDRAMCTL + 0x04)
1511 +#define MEM_CFG1_AC0 0x00000700 /* bank 0: SDRAM addr check (added) */
1512 +#define MEM_CFG1_AC0_S 8
1513 +#define MEM_CFG1_AC1 0x00007000 /* bank 1: SDRAM addr check (added) */
1514 +#define MEM_CFG1_AC1_S 12
1516 +/* GPIO Address Map */
1517 +#define AR531X_GPIO (AR531X_APBBASE + 0x2000)
1518 +#define AR531X_GPIO_DO (AR531X_GPIO + 0x00) /* output register */
1519 +#define AR531X_GPIO_DI (AR531X_GPIO + 0x04) /* intput register */
1520 +#define AR531X_GPIO_CR (AR531X_GPIO + 0x08) /* control register */
1522 +/* GPIO Control Register bit field definitions */
1523 +#define AR531X_GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
1524 +#define AR531X_GPIO_CR_O(x) (0 << (x)) /* mask for output */
1525 +#define AR531X_GPIO_CR_I(x) (1 << (x)) /* mask for input */
1526 +#define AR531X_GPIO_CR_INT(x) (1 << ((x)+8)) /* mask for interrupt */
1527 +#define AR531X_GPIO_CR_UART(x) (1 << ((x)+16)) /* uart multiplex */
1528 +#define AR531X_NUM_GPIO 8
1534 +++ b/arch/mips/ar231x/ar5312.c
1537 + * This file is subject to the terms and conditions of the GNU General Public
1538 + * License. See the file "COPYING" in the main directory of this archive
1539 + * for more details.
1541 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
1542 + * Copyright (C) 2006 FON Technology, SL.
1543 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
1544 + * Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
1548 + * Platform devices for Atheros SoCs
1551 +#include <linux/autoconf.h>
1552 +#include <linux/init.h>
1553 +#include <linux/module.h>
1554 +#include <linux/types.h>
1555 +#include <linux/string.h>
1556 +#include <linux/mtd/physmap.h>
1557 +#include <linux/platform_device.h>
1558 +#include <linux/kernel.h>
1559 +#include <linux/reboot.h>
1560 +#include <linux/leds.h>
1561 +#include <asm/bootinfo.h>
1562 +#include <asm/reboot.h>
1563 +#include <asm/time.h>
1564 +#include <asm/irq.h>
1565 +#include <asm/io.h>
1568 +#include <ar231x_platform.h>
1569 +#include <ar5312_regs.h>
1570 +#include <ar231x.h>
1571 +#include "devices.h"
1572 +#include "ar5312.h"
1574 +#define IS_5312() (current_cpu_data.cputype != CPU_4KEC)
1577 +ar5312_misc_irq_dispatch(void)
1579 + unsigned int ar231x_misc_intrs = ar231x_read_reg(AR531X_ISR) & ar231x_read_reg(AR531X_IMR);
1581 + if (ar231x_misc_intrs & AR531X_ISR_TIMER) {
1582 + do_IRQ(AR531X_MISC_IRQ_TIMER);
1583 + (void)ar231x_read_reg(AR531X_TIMER);
1584 + } else if (ar231x_misc_intrs & AR531X_ISR_AHBPROC)
1585 + do_IRQ(AR531X_MISC_IRQ_AHB_PROC);
1586 + else if ((ar231x_misc_intrs & AR531X_ISR_UART0))
1587 + do_IRQ(AR531X_MISC_IRQ_UART0);
1588 + else if (ar231x_misc_intrs & AR531X_ISR_WD)
1589 + do_IRQ(AR531X_MISC_IRQ_WATCHDOG);
1591 + do_IRQ(AR531X_MISC_IRQ_NONE);
1595 +ar5312_irq_dispatch(void)
1597 + int pending = read_c0_status() & read_c0_cause();
1599 + if (pending & CAUSEF_IP2)
1600 + do_IRQ(AR5312_IRQ_WLAN0_INTRS);
1601 + else if (pending & CAUSEF_IP3)
1602 + do_IRQ(AR5312_IRQ_ENET0_INTRS);
1603 + else if (pending & CAUSEF_IP4)
1604 + do_IRQ(AR5312_IRQ_ENET1_INTRS);
1605 + else if (pending & CAUSEF_IP5)
1606 + do_IRQ(AR5312_IRQ_WLAN1_INTRS);
1607 + else if (pending & CAUSEF_IP6)
1608 + ar5312_misc_irq_dispatch();
1609 + else if (pending & CAUSEF_IP7)
1610 + do_IRQ(AR531X_IRQ_CPU_CLOCK);
1614 +/* Enable the specified AR531X_MISC_IRQ interrupt */
1616 +ar5312_misc_intr_enable(unsigned int irq)
1620 + imr = ar231x_read_reg(AR531X_IMR);
1621 + imr |= (1 << (irq - AR531X_MISC_IRQ_BASE - 1));
1622 + ar231x_write_reg(AR531X_IMR, imr);
1625 +/* Disable the specified AR531X_MISC_IRQ interrupt */
1627 +ar5312_misc_intr_disable(unsigned int irq)
1631 + imr = ar231x_read_reg(AR531X_IMR);
1632 + imr &= ~(1 << (irq - AR531X_MISC_IRQ_BASE - 1));
1633 + ar231x_write_reg(AR531X_IMR, imr);
1634 + ar231x_read_reg(AR531X_IMR); /* flush write buffer */
1637 +static unsigned int
1638 +ar5312_misc_intr_startup(unsigned int irq)
1640 + ar5312_misc_intr_enable(irq);
1645 +ar5312_misc_intr_end(unsigned int irq)
1647 + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
1648 + ar5312_misc_intr_enable(irq);
1651 +static struct irq_chip ar5312_misc_intr_controller = {
1652 + .name = "AR5312-MISC",
1653 + .startup = ar5312_misc_intr_startup,
1654 + .shutdown = ar5312_misc_intr_disable,
1655 + .enable = ar5312_misc_intr_enable,
1656 + .disable = ar5312_misc_intr_disable,
1657 + .ack = ar5312_misc_intr_disable,
1658 + .end = ar5312_misc_intr_end,
1662 +static irqreturn_t ar5312_ahb_proc_handler(int cpl, void *dev_id)
1664 + u32 proc1 = ar231x_read_reg(AR531X_PROC1);
1665 + u32 procAddr = ar231x_read_reg(AR531X_PROCADDR); /* clears error state */
1666 + u32 dma1 = ar231x_read_reg(AR531X_DMA1);
1667 + u32 dmaAddr = ar231x_read_reg(AR531X_DMAADDR); /* clears error state */
1669 + printk("AHB interrupt: PROCADDR=0x%8.8x PROC1=0x%8.8x DMAADDR=0x%8.8x DMA1=0x%8.8x\n",
1670 + procAddr, proc1, dmaAddr, dma1);
1672 + machine_restart("AHB error"); /* Catastrophic failure */
1673 + return IRQ_HANDLED;
1677 +static struct irqaction ar5312_ahb_proc_interrupt = {
1678 + .handler = ar5312_ahb_proc_handler,
1679 + .flags = IRQF_DISABLED,
1680 + .name = "ar5312_ahb_proc_interrupt",
1684 +static struct irqaction cascade = {
1685 + .handler = no_action,
1686 + .flags = IRQF_DISABLED,
1687 + .name = "cascade",
1690 +void __init ar5312_irq_init(void)
1697 + ar231x_irq_dispatch = ar5312_irq_dispatch;
1698 + for (i = 0; i < AR531X_MISC_IRQ_COUNT; i++) {
1699 + int irq = AR531X_MISC_IRQ_BASE + i;
1700 + irq_desc[irq].status = IRQ_DISABLED;
1701 + irq_desc[irq].action = NULL;
1702 + irq_desc[irq].depth = 1;
1703 + irq_desc[irq].chip = &ar5312_misc_intr_controller;
1705 + setup_irq(AR531X_MISC_IRQ_AHB_PROC, &ar5312_ahb_proc_interrupt);
1706 + setup_irq(AR5312_IRQ_MISC_INTRS, &cascade);
1709 +const struct ar231x_gpiodev ar5312_gpiodev;
1712 +ar5312_gpio_get_output(void)
1715 + reg = ~(ar231x_read_reg(AR531X_GPIO_CR));
1716 + reg &= ar5312_gpiodev.valid_mask;
1721 +ar5312_gpio_set_output(u32 mask, u32 val)
1725 + reg = ar231x_read_reg(AR531X_GPIO_CR);
1728 + ar231x_write_reg(AR531X_GPIO_CR, reg);
1733 +ar5312_gpio_get(void)
1736 + reg = ar231x_read_reg(AR531X_GPIO_DI);
1737 + reg &= ar5312_gpiodev.valid_mask;
1742 +ar5312_gpio_set(u32 mask, u32 value)
1745 + reg = ar231x_read_reg(AR531X_GPIO_DO);
1748 + ar231x_write_reg(AR531X_GPIO_DO, reg);
1752 +const struct ar231x_gpiodev ar5312_gpiodev = {
1753 + .valid_mask = (1 << 8) - 1,
1754 + .get_output = ar5312_gpio_get_output,
1755 + .set_output = ar5312_gpio_set_output,
1756 + .get = ar5312_gpio_get,
1757 + .set = ar5312_gpio_set,
1760 +static struct physmap_flash_data ar5312_flash_data = {
1764 +static struct resource ar5312_flash_resource = {
1765 + .start = AR531X_FLASH,
1766 + .end = AR531X_FLASH + 0x800000 - 1,
1767 + .flags = IORESOURCE_MEM,
1770 +static struct ar231x_eth ar5312_eth0_data = {
1771 + .reset_base = AR531X_RESET,
1772 + .reset_mac = AR531X_RESET_ENET0,
1773 + .reset_phy = AR531X_RESET_EPHY0,
1774 + .phy_base = KSEG1ADDR(AR531X_ENET0),
1775 + .config = &ar231x_board,
1778 +static struct ar231x_eth ar5312_eth1_data = {
1779 + .reset_base = AR531X_RESET,
1780 + .reset_mac = AR531X_RESET_ENET1,
1781 + .reset_phy = AR531X_RESET_EPHY1,
1782 + .phy_base = KSEG1ADDR(AR531X_ENET1),
1783 + .config = &ar231x_board,
1786 +static struct platform_device ar5312_physmap_flash = {
1787 + .name = "physmap-flash",
1789 + .dev.platform_data = &ar5312_flash_data,
1790 + .resource = &ar5312_flash_resource,
1791 + .num_resources = 1,
1794 +#ifdef CONFIG_LEDS_GPIO
1795 +static struct gpio_led ar5312_leds[] = {
1796 + { .name = "wlan", .gpio = 0, .active_low = 1, },
1799 +static const struct gpio_led_platform_data ar5312_led_data = {
1800 + .num_leds = ARRAY_SIZE(ar5312_leds),
1801 + .leds = (void *) ar5312_leds,
1804 +static struct platform_device ar5312_gpio_leds = {
1805 + .name = "leds-gpio",
1807 + .dev.platform_data = (void *) &ar5312_led_data,
1812 + * NB: This mapping size is larger than the actual flash size,
1813 + * but this shouldn't be a problem here, because the flash
1814 + * will simply be mapped multiple times.
1816 +static char __init *ar5312_flash_limit(void)
1820 + * Configure flash bank 0.
1821 + * Assume 8M window size. Flash will be aliased if it's smaller
1823 + ctl = FLASHCTL_E |
1826 + (0x01 << FLASHCTL_IDCY_S) |
1827 + (0x07 << FLASHCTL_WST1_S) |
1828 + (0x07 << FLASHCTL_WST2_S) |
1829 + (ar231x_read_reg(AR531X_FLASHCTL0) & FLASHCTL_MW);
1831 + ar231x_write_reg(AR531X_FLASHCTL0, ctl);
1833 + /* Disable other flash banks */
1834 + ar231x_write_reg(AR531X_FLASHCTL1,
1835 + ar231x_read_reg(AR531X_FLASHCTL1) & ~(FLASHCTL_E | FLASHCTL_AC));
1837 + ar231x_write_reg(AR531X_FLASHCTL2,
1838 + ar231x_read_reg(AR531X_FLASHCTL2) & ~(FLASHCTL_E | FLASHCTL_AC));
1840 + return (char *) KSEG1ADDR(AR531X_FLASH + 0x800000);
1843 +int __init ar5312_init_devices(void)
1845 + struct ar231x_boarddata *config;
1853 + /* Locate board/radio config data */
1854 + ar231x_find_config(ar5312_flash_limit());
1855 + config = ar231x_board.config;
1859 + * Chip IDs and hardware detection for some Atheros
1860 + * models are really broken!
1862 + * Atheros uses a disabled WMAC0 and Silicon ID of AR5312
1863 + * as indication for AR2312, which is otherwise
1864 + * indistinguishable from the real AR5312.
1866 + if (ar231x_board.radio) {
1867 + radio = ar231x_board.radio + AR531X_RADIO_MASK_OFF;
1868 + if ((*((const u32 *) radio) & AR531X_RADIO0_MASK) == 0)
1869 + config->flags |= BD_ISCASPER;
1873 + /* AR2313 has CPU minor rev. 10 */
1874 + if ((current_cpu_data.processor_id & 0xff) == 0x0a)
1875 + ar231x_devtype = DEV_TYPE_AR2313;
1877 + /* AR2312 shares the same Silicon ID as AR5312 */
1878 + else if (config->flags & BD_ISCASPER)
1879 + ar231x_devtype = DEV_TYPE_AR2312;
1881 + /* Everything else is probably AR5312 or compatible */
1883 + ar231x_devtype = DEV_TYPE_AR5312;
1885 + /* fixup flash width */
1886 + fctl = ar231x_read_reg(AR531X_FLASHCTL) & FLASHCTL_MW;
1888 + case FLASHCTL_MWx16:
1889 + ar5312_flash_data.width = 2;
1891 + case FLASHCTL_MWx8:
1893 + ar5312_flash_data.width = 1;
1897 + platform_device_register(&ar5312_physmap_flash);
1899 +#ifdef CONFIG_LEDS_GPIO
1900 + ar5312_leds[0].gpio = config->sysLedGpio;
1901 + platform_device_register(&ar5312_gpio_leds);
1904 + /* Fix up MAC addresses if necessary */
1905 + if (!memcmp(config->enet0_mac, "\xff\xff\xff\xff\xff\xff", 6))
1906 + memcpy(config->enet0_mac, config->enet1_mac, 6);
1908 + /* If ENET0 and ENET1 have the same mac address,
1909 + * increment the one from ENET1 */
1910 + if (memcmp(config->enet0_mac, config->enet1_mac, 6) == 0) {
1911 + c = config->enet1_mac + 5;
1912 + while ((c >= config->enet1_mac) && !(++(*c)))
1916 + switch(ar231x_devtype) {
1917 + case DEV_TYPE_AR5312:
1918 + ar5312_eth0_data.macaddr = config->enet0_mac;
1919 + ar231x_add_ethernet(0, KSEG1ADDR(AR531X_ENET0),
1920 + AR5312_IRQ_ENET0_INTRS, &ar5312_eth0_data);
1922 + ar5312_eth1_data.macaddr = config->enet1_mac;
1923 + ar231x_add_ethernet(1, KSEG1ADDR(AR531X_ENET1),
1924 + AR5312_IRQ_ENET1_INTRS, &ar5312_eth1_data);
1926 + if (!ar231x_board.radio)
1929 + if (*((u32 *) radio) & AR531X_RADIO0_MASK)
1930 + ar231x_add_wmac(0, AR531X_WLAN0,
1931 + AR5312_IRQ_WLAN0_INTRS);
1935 + * AR2312/3 ethernet uses the PHY of ENET0, but the MAC
1936 + * of ENET1. Atheros calls it 'twisted' for a reason :)
1938 + case DEV_TYPE_AR2312:
1939 + case DEV_TYPE_AR2313:
1940 + ar5312_eth1_data.phy_base = ar5312_eth0_data.phy_base;
1941 + ar5312_eth1_data.reset_phy = ar5312_eth0_data.reset_phy;
1942 + ar5312_eth1_data.macaddr = config->enet0_mac;
1943 + ar231x_add_ethernet(0, KSEG1ADDR(AR531X_ENET1),
1944 + AR5312_IRQ_ENET1_INTRS, &ar5312_eth1_data);
1946 + if (!ar231x_board.radio)
1953 + if (*((u32 *) radio) & AR531X_RADIO1_MASK)
1954 + ar231x_add_wmac(1, AR531X_WLAN1,
1955 + AR5312_IRQ_WLAN1_INTRS);
1961 +static void ar5312_restart(char *command)
1963 + /* reset the system */
1964 + local_irq_disable();
1966 + ar231x_write_reg(AR531X_RESET, AR531X_RESET_SYSTEM);
1972 + * This table is indexed by bits 5..4 of the CLOCKCTL1 register
1973 + * to determine the predevisor value.
1975 +static int __initdata CLOCKCTL1_PREDIVIDE_TABLE[4] = {
1984 +ar5312_cpu_frequency(void)
1986 + unsigned int result;
1987 + unsigned int predivide_mask, predivide_shift;
1988 + unsigned int multiplier_mask, multiplier_shift;
1989 + unsigned int clockCtl1, preDivideSelect, preDivisor, multiplier;
1990 + unsigned int doubler_mask;
1993 + /* Trust the bootrom's idea of cpu frequency. */
1994 + if ((result = ar231x_read_reg(AR5312_SCRATCH)))
1997 + devid = ar231x_read_reg(AR531X_REV);
1998 + devid &= AR531X_REV_MAJ;
1999 + devid >>= AR531X_REV_MAJ_S;
2000 + if (devid == AR531X_REV_MAJ_AR2313) {
2001 + predivide_mask = AR2313_CLOCKCTL1_PREDIVIDE_MASK;
2002 + predivide_shift = AR2313_CLOCKCTL1_PREDIVIDE_SHIFT;
2003 + multiplier_mask = AR2313_CLOCKCTL1_MULTIPLIER_MASK;
2004 + multiplier_shift = AR2313_CLOCKCTL1_MULTIPLIER_SHIFT;
2005 + doubler_mask = AR2313_CLOCKCTL1_DOUBLER_MASK;
2006 + } else { /* AR5312 and AR2312 */
2007 + predivide_mask = AR5312_CLOCKCTL1_PREDIVIDE_MASK;
2008 + predivide_shift = AR5312_CLOCKCTL1_PREDIVIDE_SHIFT;
2009 + multiplier_mask = AR5312_CLOCKCTL1_MULTIPLIER_MASK;
2010 + multiplier_shift = AR5312_CLOCKCTL1_MULTIPLIER_SHIFT;
2011 + doubler_mask = AR5312_CLOCKCTL1_DOUBLER_MASK;
2015 + * Clocking is derived from a fixed 40MHz input clock.
2017 + * cpuFreq = InputClock * MULT (where MULT is PLL multiplier)
2018 + * sysFreq = cpuFreq / 4 (used for APB clock, serial,
2019 + * flash, Timer, Watchdog Timer)
2021 + * cntFreq = cpuFreq / 2 (use for CPU count/compare)
2023 + * So, for example, with a PLL multiplier of 5, we have
2025 + * cpuFreq = 200MHz
2027 + * cntFreq = 100MHz
2029 + * We compute the CPU frequency, based on PLL settings.
2032 + clockCtl1 = ar231x_read_reg(AR5312_CLOCKCTL1);
2033 + preDivideSelect = (clockCtl1 & predivide_mask) >> predivide_shift;
2034 + preDivisor = CLOCKCTL1_PREDIVIDE_TABLE[preDivideSelect];
2035 + multiplier = (clockCtl1 & multiplier_mask) >> multiplier_shift;
2037 + if (clockCtl1 & doubler_mask) {
2038 + multiplier = multiplier << 1;
2040 + return (40000000 / preDivisor) * multiplier;
2044 +ar5312_sys_frequency(void)
2046 + return ar5312_cpu_frequency() / 4;
2050 +ar5312_time_init(void)
2055 + mips_hpt_frequency = ar5312_cpu_frequency() / 2;
2060 +ar5312_prom_init(void)
2062 + u32 memsize, memcfg, bank0AC, bank1AC;
2068 + /* Detect memory size */
2069 + memcfg = ar231x_read_reg(AR531X_MEM_CFG1);
2070 + bank0AC = (memcfg & MEM_CFG1_AC0) >> MEM_CFG1_AC0_S;
2071 + bank1AC = (memcfg & MEM_CFG1_AC1) >> MEM_CFG1_AC1_S;
2072 + memsize = (bank0AC ? (1 << (bank0AC+1)) : 0)
2073 + + (bank1AC ? (1 << (bank1AC+1)) : 0);
2075 + add_memory_region(0, memsize, BOOT_MEM_RAM);
2077 + devid = ar231x_read_reg(AR531X_REV);
2078 + devid >>= AR531X_REV_WMAC_MIN_S;
2079 + devid &= AR531X_REV_CHIP;
2080 + ar231x_board.devid = (u16) devid;
2081 + ar231x_gpiodev = &ar5312_gpiodev;
2085 +ar5312_plat_setup(void)
2090 + /* Clear any lingering AHB errors */
2091 + ar231x_read_reg(AR531X_PROCADDR);
2092 + ar231x_read_reg(AR531X_DMAADDR);
2093 + ar231x_write_reg(AR531X_WD_CTRL, AR531X_WD_CTRL_IGNORE_EXPIRATION);
2095 + _machine_restart = ar5312_restart;
2096 + ar231x_serial_setup(KSEG1ADDR(AR531X_UART0), ar5312_sys_frequency());
2100 +++ b/arch/mips/ar231x/ar2315.c
2103 + * This file is subject to the terms and conditions of the GNU General Public
2104 + * License. See the file "COPYING" in the main directory of this archive
2105 + * for more details.
2107 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
2108 + * Copyright (C) 2006 FON Technology, SL.
2109 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
2110 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
2114 + * Platform devices for Atheros SoCs
2117 +#include <linux/autoconf.h>
2118 +#include <linux/init.h>
2119 +#include <linux/module.h>
2120 +#include <linux/types.h>
2121 +#include <linux/string.h>
2122 +#include <linux/platform_device.h>
2123 +#include <linux/kernel.h>
2124 +#include <linux/reboot.h>
2125 +#include <linux/delay.h>
2126 +#include <linux/leds.h>
2127 +#include <asm/bootinfo.h>
2128 +#include <asm/reboot.h>
2129 +#include <asm/time.h>
2130 +#include <asm/irq.h>
2131 +#include <asm/io.h>
2132 +#include <asm/gpio.h>
2134 +#include <ar231x_platform.h>
2135 +#include <ar2315_regs.h>
2136 +#include <ar231x.h>
2137 +#include "devices.h"
2138 +#include "ar2315.h"
2140 +#define IS_2315() (current_cpu_data.cputype == CPU_4KEC)
2142 +static u32 gpiointmask = 0, gpiointval = 0;
2144 +static inline void ar2315_gpio_irq(void)
2149 + /* only do one gpio interrupt at a time */
2150 + pend = (ar231x_read_reg(AR2315_GPIO_DI) ^ gpiointval) & gpiointmask;
2153 + bit = fls(pend) - 1;
2154 + pend &= ~(1 << bit);
2155 + gpiointval ^= (1 << bit);
2159 + ar231x_write_reg(AR2315_ISR, AR2315_ISR_GPIO);
2162 + do_IRQ(AR531X_GPIO_IRQ_BASE + bit);
2167 + * Called when an interrupt is received, this function
2168 + * determines exactly which interrupt it was, and it
2169 + * invokes the appropriate handler.
2171 + * Implicitly, we also define interrupt priority by
2172 + * choosing which to dispatch first.
2175 +ar2315_irq_dispatch(void)
2177 + int pending = read_c0_status() & read_c0_cause();
2179 + if (pending & CAUSEF_IP3)
2180 + do_IRQ(AR2315_IRQ_WLAN0_INTRS);
2181 + else if (pending & CAUSEF_IP4)
2182 + do_IRQ(AR2315_IRQ_ENET0_INTRS);
2183 + else if (pending & CAUSEF_IP2) {
2184 + unsigned int misc_intr = ar231x_read_reg(AR2315_ISR) & ar231x_read_reg(AR2315_IMR);
2186 + if (misc_intr & AR2315_ISR_SPI)
2187 + do_IRQ(AR531X_MISC_IRQ_SPI);
2188 + else if (misc_intr & AR2315_ISR_TIMER)
2189 + do_IRQ(AR531X_MISC_IRQ_TIMER);
2190 + else if (misc_intr & AR2315_ISR_AHB)
2191 + do_IRQ(AR531X_MISC_IRQ_AHB_PROC);
2192 + else if (misc_intr & AR2315_ISR_GPIO)
2193 + ar2315_gpio_irq();
2194 + else if (misc_intr & AR2315_ISR_UART0)
2195 + do_IRQ(AR531X_MISC_IRQ_UART0);
2196 + else if (misc_intr & AR2315_ISR_WD)
2197 + do_IRQ(AR531X_MISC_IRQ_WATCHDOG);
2199 + do_IRQ(AR531X_MISC_IRQ_NONE);
2200 + } else if (pending & CAUSEF_IP7)
2201 + do_IRQ(AR531X_IRQ_CPU_CLOCK);
2204 +static void ar2315_set_gpiointmask(int gpio, int level)
2208 + reg = ar231x_read_reg(AR2315_GPIO_INT);
2209 + reg &= ~(AR2315_GPIO_INT_M | AR2315_GPIO_INT_LVL_M);
2210 + reg |= gpio | AR2315_GPIO_INT_LVL(level);
2211 + ar231x_write_reg(AR2315_GPIO_INT, reg);
2214 +static void ar2315_gpio_intr_enable(unsigned int irq)
2216 + unsigned int gpio = irq - AR531X_GPIO_IRQ_BASE;
2218 + /* reconfigure GPIO line as input */
2219 + ar231x_mask_reg(AR2315_GPIO_CR, AR2315_GPIO_CR_M(gpio), AR2315_GPIO_CR_I(gpio));
2221 + /* Enable interrupt with edge detection */
2222 + gpiointmask |= (1 << gpio);
2223 + ar2315_set_gpiointmask(gpio, 3);
2226 +static void ar2315_gpio_intr_disable(unsigned int irq)
2228 + unsigned int gpio = irq - AR531X_GPIO_IRQ_BASE;
2230 + /* Disable interrupt */
2231 + gpiointmask &= ~(1 << gpio);
2232 + ar2315_set_gpiointmask(gpio, 0);
2235 +static unsigned int
2236 +ar2315_gpio_intr_startup(unsigned int irq)
2238 + ar2315_gpio_intr_enable(irq);
2243 +ar2315_gpio_intr_end(unsigned int irq)
2245 + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
2246 + ar2315_gpio_intr_enable(irq);
2249 +static struct irq_chip ar2315_gpio_intr_controller = {
2250 + .typename = "AR2315-GPIO",
2251 + .startup = ar2315_gpio_intr_startup,
2252 + .shutdown = ar2315_gpio_intr_disable,
2253 + .enable = ar2315_gpio_intr_enable,
2254 + .disable = ar2315_gpio_intr_disable,
2255 + .ack = ar2315_gpio_intr_disable,
2256 + .end = ar2315_gpio_intr_end,
2260 +ar2315_misc_intr_enable(unsigned int irq)
2264 + imr = ar231x_read_reg(AR2315_IMR);
2266 + case AR531X_MISC_IRQ_SPI:
2267 + imr |= AR2315_ISR_SPI;
2269 + case AR531X_MISC_IRQ_TIMER:
2270 + imr |= AR2315_ISR_TIMER;
2272 + case AR531X_MISC_IRQ_AHB_PROC:
2273 + imr |= AR2315_ISR_AHB;
2275 + case AR531X_MISC_IRQ_GPIO:
2276 + imr |= AR2315_ISR_GPIO;
2278 + case AR531X_MISC_IRQ_UART0:
2279 + imr |= AR2315_ISR_UART0;
2281 + case AR531X_MISC_IRQ_WATCHDOG:
2282 + imr |= AR2315_ISR_WD;
2287 + ar231x_write_reg(AR2315_IMR, imr);
2291 +ar2315_misc_intr_disable(unsigned int irq)
2295 + imr = ar231x_read_reg(AR2315_IMR);
2297 + case AR531X_MISC_IRQ_SPI:
2298 + imr &= ~AR2315_ISR_SPI;
2300 + case AR531X_MISC_IRQ_TIMER:
2301 + imr &= ~AR2315_ISR_TIMER;
2303 + case AR531X_MISC_IRQ_AHB_PROC:
2304 + imr &= ~AR2315_ISR_AHB;
2306 + case AR531X_MISC_IRQ_GPIO:
2307 + imr &= ~AR2315_ISR_GPIO;
2309 + case AR531X_MISC_IRQ_UART0:
2310 + imr &= ~AR2315_ISR_UART0;
2312 + case AR531X_MISC_IRQ_WATCHDOG:
2313 + imr &= ~AR2315_ISR_WD;
2318 + ar231x_write_reg(AR2315_IMR, imr);
2321 +static unsigned int
2322 +ar2315_misc_intr_startup(unsigned int irq)
2324 + ar2315_misc_intr_enable(irq);
2329 +ar2315_misc_intr_end(unsigned int irq)
2331 + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
2332 + ar2315_misc_intr_enable(irq);
2336 +static struct irq_chip ar2315_misc_intr_controller = {
2337 + .typename = "AR2315-MISC",
2338 + .startup = ar2315_misc_intr_startup,
2339 + .shutdown = ar2315_misc_intr_disable,
2340 + .enable = ar2315_misc_intr_enable,
2341 + .disable = ar2315_misc_intr_disable,
2342 + .ack = ar2315_misc_intr_disable,
2343 + .end = ar2315_misc_intr_end,
2346 +static irqreturn_t ar2315_ahb_proc_handler(int cpl, void *dev_id)
2348 + ar231x_write_reg(AR2315_AHB_ERR0, AHB_ERROR_DET);
2349 + ar231x_read_reg(AR2315_AHB_ERR1);
2351 + printk(KERN_ERR "AHB fatal error\n");
2352 + machine_restart("AHB error"); /* Catastrophic failure */
2354 + return IRQ_HANDLED;
2357 +static struct irqaction ar2315_ahb_proc_interrupt = {
2358 + .handler = ar2315_ahb_proc_handler,
2359 + .flags = IRQF_DISABLED,
2360 + .name = "ar2315_ahb_proc_interrupt",
2363 +static struct irqaction cascade = {
2364 + .handler = no_action,
2365 + .flags = IRQF_DISABLED,
2366 + .name = "cascade",
2370 +ar2315_irq_init(void)
2377 + ar231x_irq_dispatch = ar2315_irq_dispatch;
2378 + gpiointval = ar231x_read_reg(AR2315_GPIO_DI);
2379 + for (i = 0; i < AR531X_MISC_IRQ_COUNT; i++) {
2380 + int irq = AR531X_MISC_IRQ_BASE + i;
2381 + irq_desc[irq].status = IRQ_DISABLED;
2382 + irq_desc[irq].action = NULL;
2383 + irq_desc[irq].depth = 1;
2384 + irq_desc[irq].chip = &ar2315_misc_intr_controller;
2386 + for (i = 0; i < AR531X_GPIO_IRQ_COUNT; i++) {
2387 + int irq = AR531X_GPIO_IRQ_BASE + i;
2388 + irq_desc[irq].status = IRQ_DISABLED;
2389 + irq_desc[irq].action = NULL;
2390 + irq_desc[irq].depth = 1;
2391 + irq_desc[irq].chip = &ar2315_gpio_intr_controller;
2393 + setup_irq(AR531X_MISC_IRQ_GPIO, &cascade);
2394 + setup_irq(AR531X_MISC_IRQ_AHB_PROC, &ar2315_ahb_proc_interrupt);
2395 + setup_irq(AR2315_IRQ_MISC_INTRS, &cascade);
2398 +const struct ar231x_gpiodev ar2315_gpiodev;
2401 +ar2315_gpio_get_output(void)
2404 + reg = ar231x_read_reg(AR2315_GPIO_CR);
2405 + reg &= ar2315_gpiodev.valid_mask;
2410 +ar2315_gpio_set_output(u32 mask, u32 val)
2414 + reg = ar231x_read_reg(AR2315_GPIO_CR);
2417 + ar231x_write_reg(AR2315_GPIO_CR, reg);
2422 +ar2315_gpio_get(void)
2425 + reg = ar231x_read_reg(AR2315_GPIO_DI);
2426 + reg &= ar2315_gpiodev.valid_mask;
2431 +ar2315_gpio_set(u32 mask, u32 value)
2434 + reg = ar231x_read_reg(AR2315_GPIO_DO);
2437 + ar231x_write_reg(AR2315_GPIO_DO, reg);
2441 +const struct ar231x_gpiodev ar2315_gpiodev = {
2442 + .valid_mask = (1 << 22) - 1,
2443 + .get_output = ar2315_gpio_get_output,
2444 + .set_output = ar2315_gpio_set_output,
2445 + .get = ar2315_gpio_get,
2446 + .set = ar2315_gpio_set,
2449 +static struct ar231x_eth ar2315_eth_data = {
2450 + .reset_base = AR2315_RESET,
2451 + .reset_mac = AR2315_RESET_ENET0,
2452 + .reset_phy = AR2315_RESET_EPHY0,
2453 + .phy_base = AR2315_ENET0,
2454 + .config = &ar231x_board,
2457 +static struct resource ar2315_spiflash_res[] = {
2459 + .name = "flash_base",
2460 + .flags = IORESOURCE_MEM,
2461 + .start = KSEG1ADDR(AR2315_SPI_READ),
2462 + .end = KSEG1ADDR(AR2315_SPI_READ) + 0x1000000 - 1,
2465 + .name = "flash_regs",
2466 + .flags = IORESOURCE_MEM,
2467 + .start = 0x11300000,
2468 + .end = 0x11300012,
2472 +static struct platform_device ar2315_spiflash = {
2474 + .name = "spiflash",
2475 + .resource = ar2315_spiflash_res,
2476 + .num_resources = ARRAY_SIZE(ar2315_spiflash_res)
2479 +static struct platform_device ar2315_wdt = {
2481 + .name = "ar2315_wdt",
2484 +#define SPI_FLASH_CTL 0x00
2485 +#define SPI_FLASH_OPCODE 0x04
2486 +#define SPI_FLASH_DATA 0x08
2489 +spiflash_read_reg(int reg)
2491 + return ar231x_read_reg(KSEG1ADDR(AR2315_SPI) + reg);
2495 +spiflash_write_reg(int reg, u32 data)
2497 + ar231x_write_reg(KSEG1ADDR(AR2315_SPI) + reg, data);
2501 +spiflash_wait_status(void)
2506 + reg = spiflash_read_reg(SPI_FLASH_CTL);
2507 + } while (reg & SPI_CTL_BUSY);
2513 +spiflash_probe(void)
2517 + reg = spiflash_wait_status();
2518 + reg &= ~SPI_CTL_TX_RX_CNT_MASK;
2519 + reg |= (1 << 4) | 4 | SPI_CTL_START;
2521 + spiflash_write_reg(SPI_FLASH_OPCODE, 0xab);
2522 + spiflash_write_reg(SPI_FLASH_CTL, reg);
2524 + reg = spiflash_wait_status();
2525 + reg = spiflash_read_reg(SPI_FLASH_DATA);
2532 +#define STM_8MBIT_SIGNATURE 0x13
2533 +#define STM_16MBIT_SIGNATURE 0x14
2534 +#define STM_32MBIT_SIGNATURE 0x15
2535 +#define STM_64MBIT_SIGNATURE 0x16
2536 +#define STM_128MBIT_SIGNATURE 0x17
2539 +ar2315_flash_limit(void)
2541 + u32 flash_size = 0;
2543 + /* probe the flash chip size */
2544 + switch(spiflash_probe()) {
2545 + case STM_8MBIT_SIGNATURE:
2546 + flash_size = 0x00100000;
2548 + case STM_16MBIT_SIGNATURE:
2549 + flash_size = 0x00200000;
2551 + case STM_32MBIT_SIGNATURE:
2552 + flash_size = 0x00400000;
2554 + case STM_64MBIT_SIGNATURE:
2555 + flash_size = 0x00800000;
2557 + case STM_128MBIT_SIGNATURE:
2558 + flash_size = 0x01000000;
2562 + ar2315_spiflash_res[0].end = ar2315_spiflash_res[0].start +
2564 + return (u8 *) ar2315_spiflash_res[0].end + 1;
2567 +#ifdef CONFIG_LEDS_GPIO
2568 +static struct gpio_led ar2315_leds[6];
2569 +static struct gpio_led_platform_data ar2315_led_data = {
2570 + .leds = (void *) ar2315_leds,
2573 +static struct platform_device ar2315_gpio_leds = {
2574 + .name = "leds-gpio",
2577 + .platform_data = (void *) &ar2315_led_data,
2582 +ar2315_init_gpio(void)
2584 + static char led_names[6][6];
2587 + ar2315_led_data.num_leds = 0;
2588 + for(i = 1; i < 8; i++)
2590 + if((i == AR2315_RESET_GPIO) ||
2591 + (i == ar231x_board.config->resetConfigGpio))
2594 + if(i == ar231x_board.config->sysLedGpio)
2595 + strcpy(led_names[led], "wlan");
2597 + sprintf(led_names[led], "gpio%d", i);
2599 + ar2315_leds[led].name = led_names[led];
2600 + ar2315_leds[led].gpio = i;
2601 + ar2315_leds[led].active_low = 0;
2604 + ar2315_led_data.num_leds = led;
2605 + platform_device_register(&ar2315_gpio_leds);
2608 +static inline void ar2315_init_gpio(void)
2614 +ar2315_init_devices(void)
2619 + /* Find board configuration */
2620 + ar231x_find_config(ar2315_flash_limit());
2621 + ar2315_eth_data.macaddr = ar231x_board.config->enet0_mac;
2623 + ar2315_init_gpio();
2624 + platform_device_register(&ar2315_wdt);
2625 + platform_device_register(&ar2315_spiflash);
2626 + ar231x_add_ethernet(0, AR2315_ENET0, AR2315_IRQ_ENET0_INTRS,
2627 + &ar2315_eth_data);
2628 + ar231x_add_wmac(0, AR2315_WLAN0, AR2315_IRQ_WLAN0_INTRS);
2634 +ar2315_restart(char *command)
2636 + void (*mips_reset_vec)(void) = (void *) 0xbfc00000;
2638 + local_irq_disable();
2640 + /* try reset the system via reset control */
2641 + ar231x_write_reg(AR2315_COLD_RESET,AR2317_RESET_SYSTEM);
2643 + /* Cold reset does not work on the AR2315/6, use the GPIO reset bits a workaround.
2644 + * give it some time to attempt a gpio based hardware reset
2645 + * (atheros reference design workaround) */
2646 + gpio_direction_output(AR2315_RESET_GPIO, 0);
2649 + /* Some boards (e.g. Senao EOC-2610) don't implement the reset logic
2650 + * workaround. Attempt to jump to the mips reset location -
2651 + * the boot loader itself might be able to recover the system */
2657 + * This table is indexed by bits 5..4 of the CLOCKCTL1 register
2658 + * to determine the predevisor value.
2660 +static int __initdata CLOCKCTL1_PREDIVIDE_TABLE[4] = {
2667 +static int __initdata PLLC_DIVIDE_TABLE[5] = {
2675 +static unsigned int __init
2676 +ar2315_sys_clk(unsigned int clockCtl)
2678 + unsigned int pllcCtrl,cpuDiv;
2679 + unsigned int pllcOut,refdiv,fdiv,divby2;
2680 + unsigned int clkDiv;
2682 + pllcCtrl = ar231x_read_reg(AR2315_PLLC_CTL);
2683 + refdiv = (pllcCtrl & PLLC_REF_DIV_M) >> PLLC_REF_DIV_S;
2684 + refdiv = CLOCKCTL1_PREDIVIDE_TABLE[refdiv];
2685 + fdiv = (pllcCtrl & PLLC_FDBACK_DIV_M) >> PLLC_FDBACK_DIV_S;
2686 + divby2 = (pllcCtrl & PLLC_ADD_FDBACK_DIV_M) >> PLLC_ADD_FDBACK_DIV_S;
2688 + pllcOut = (40000000/refdiv)*(2*divby2)*fdiv;
2691 + /* clkm input selected */
2692 + switch(clockCtl & CPUCLK_CLK_SEL_M) {
2695 + clkDiv = PLLC_DIVIDE_TABLE[(pllcCtrl & PLLC_CLKM_DIV_M) >> PLLC_CLKM_DIV_S];
2698 + clkDiv = PLLC_DIVIDE_TABLE[(pllcCtrl & PLLC_CLKC_DIV_M) >> PLLC_CLKC_DIV_S];
2701 + pllcOut = 40000000;
2705 + cpuDiv = (clockCtl & CPUCLK_CLK_DIV_M) >> CPUCLK_CLK_DIV_S;
2706 + cpuDiv = cpuDiv * 2 ?: 1;
2707 + return (pllcOut/(clkDiv * cpuDiv));
2710 +static inline unsigned int
2711 +ar2315_cpu_frequency(void)
2713 + return ar2315_sys_clk(ar231x_read_reg(AR2315_CPUCLK));
2716 +static inline unsigned int
2717 +ar2315_apb_frequency(void)
2719 + return ar2315_sys_clk(ar231x_read_reg(AR2315_AMBACLK));
2723 +ar2315_time_init(void)
2728 + mips_hpt_frequency = ar2315_cpu_frequency() / 2;
2732 +ar2315_prom_init(void)
2734 + u32 memsize, memcfg, devid;
2739 + memcfg = ar231x_read_reg(AR2315_MEM_CFG);
2740 + memsize = 1 + ((memcfg & SDRAM_DATA_WIDTH_M) >> SDRAM_DATA_WIDTH_S);
2741 + memsize <<= 1 + ((memcfg & SDRAM_COL_WIDTH_M) >> SDRAM_COL_WIDTH_S);
2742 + memsize <<= 1 + ((memcfg & SDRAM_ROW_WIDTH_M) >> SDRAM_ROW_WIDTH_S);
2744 + add_memory_region(0, memsize, BOOT_MEM_RAM);
2746 + /* Detect the hardware based on the device ID */
2747 + devid = ar231x_read_reg(AR2315_SREV) & AR2315_REV_CHIP;
2751 + ar231x_devtype = DEV_TYPE_AR2317;
2754 + ar231x_devtype = DEV_TYPE_AR2315;
2757 + ar231x_gpiodev = &ar2315_gpiodev;
2758 + ar231x_board.devid = devid;
2762 +ar2315_plat_setup(void)
2769 + /* Clear any lingering AHB errors */
2770 + config = read_c0_config();
2771 + write_c0_config(config & ~0x3);
2772 + ar231x_write_reg(AR2315_AHB_ERR0,AHB_ERROR_DET);
2773 + ar231x_read_reg(AR2315_AHB_ERR1);
2774 + ar231x_write_reg(AR2315_WDC, AR2315_WDC_IGNORE_EXPIRATION);
2776 + _machine_restart = ar2315_restart;
2777 + ar231x_serial_setup(KSEG1ADDR(AR2315_UART0), ar2315_apb_frequency());
2780 +++ b/arch/mips/ar231x/ar2315.h
2785 +#ifdef CONFIG_ATHEROS_AR2315
2787 +extern void ar2315_irq_init(void);
2788 +extern int ar2315_init_devices(void);
2789 +extern void ar2315_prom_init(void);
2790 +extern void ar2315_plat_setup(void);
2791 +extern void ar2315_time_init(void);
2795 +static inline void ar2315_irq_init(void)
2799 +static inline int ar2315_init_devices(void)
2804 +static inline void ar2315_prom_init(void)
2808 +static inline void ar2315_plat_setup(void)
2812 +static inline void ar2315_time_init(void)
2820 +++ b/arch/mips/ar231x/ar5312.h
2825 +#ifdef CONFIG_ATHEROS_AR5312
2827 +extern void ar5312_irq_init(void);
2828 +extern int ar5312_init_devices(void);
2829 +extern void ar5312_prom_init(void);
2830 +extern void ar5312_plat_setup(void);
2831 +extern void ar5312_time_init(void);
2832 +extern void ar5312_time_init(void);
2836 +static inline void ar5312_irq_init(void)
2840 +static inline int ar5312_init_devices(void)
2845 +static inline void ar5312_prom_init(void)
2849 +static inline void ar5312_plat_setup(void)
2853 +static inline void ar5312_time_init(void)
2861 +++ b/arch/mips/include/asm/mach-ar231x/ar231x.h
2866 +#define AR531X_MISC_IRQ_BASE 0x20
2867 +#define AR531X_GPIO_IRQ_BASE 0x30
2869 +/* Software's idea of interrupts handled by "CPU Interrupt Controller" */
2870 +#define AR531X_IRQ_NONE MIPS_CPU_IRQ_BASE+0
2871 +#define AR531X_IRQ_CPU_CLOCK MIPS_CPU_IRQ_BASE+7 /* C0_CAUSE: 0x8000 */
2873 +/* Miscellaneous interrupts, which share IP6 */
2874 +#define AR531X_MISC_IRQ_NONE AR531X_MISC_IRQ_BASE+0
2875 +#define AR531X_MISC_IRQ_TIMER AR531X_MISC_IRQ_BASE+1
2876 +#define AR531X_MISC_IRQ_AHB_PROC AR531X_MISC_IRQ_BASE+2
2877 +#define AR531X_MISC_IRQ_AHB_DMA AR531X_MISC_IRQ_BASE+3
2878 +#define AR531X_MISC_IRQ_GPIO AR531X_MISC_IRQ_BASE+4
2879 +#define AR531X_MISC_IRQ_UART0 AR531X_MISC_IRQ_BASE+5
2880 +#define AR531X_MISC_IRQ_UART0_DMA AR531X_MISC_IRQ_BASE+6
2881 +#define AR531X_MISC_IRQ_WATCHDOG AR531X_MISC_IRQ_BASE+7
2882 +#define AR531X_MISC_IRQ_LOCAL AR531X_MISC_IRQ_BASE+8
2883 +#define AR531X_MISC_IRQ_SPI AR531X_MISC_IRQ_BASE+9
2884 +#define AR531X_MISC_IRQ_COUNT 10
2886 +/* GPIO Interrupts [0..7], share AR531X_MISC_IRQ_GPIO */
2887 +#define AR531X_GPIO_IRQ_NONE AR531X_GPIO_IRQ_BASE+0
2888 +#define AR531X_GPIO_IRQ(n) AR531X_GPIO_IRQ_BASE+n
2889 +#define AR531X_GPIO_IRQ_COUNT 22
2892 +ar231x_read_reg(u32 reg)
2894 + return __raw_readl((u32 *) KSEG1ADDR(reg));
2898 +ar231x_write_reg(u32 reg, u32 val)
2900 + __raw_writel(val, (u32 *) KSEG1ADDR(reg));
2904 +ar231x_mask_reg(u32 reg, u32 mask, u32 val)
2908 + ret = ar231x_read_reg(reg);
2911 + ar231x_write_reg(reg, ret);
2918 +++ b/arch/mips/ar231x/devices.h
2920 +#ifndef __AR231X_DEVICES_H
2921 +#define __AR231X_DEVICES_H
2924 + /* handled by ar5312.c */
2929 + /* handled by ar2315.c */
2937 +extern int ar231x_devtype;
2938 +extern struct ar231x_board_config ar231x_board;
2939 +extern void (*ar231x_irq_dispatch)(void);
2941 +extern int ar231x_find_config(u8 *flash_limit);
2942 +extern void ar231x_serial_setup(u32 mapbase, unsigned int uartclk);
2943 +extern int ar231x_add_wmac(int nr, u32 base, int irq);
2944 +extern int ar231x_add_ethernet(int nr, u32 base, int irq, void *pdata);
2948 +++ b/arch/mips/ar231x/devices.c
2950 +#include <linux/kernel.h>
2951 +#include <linux/init.h>
2952 +#include <linux/serial.h>
2953 +#include <linux/serial_core.h>
2954 +#include <linux/serial_8250.h>
2955 +#include <linux/platform_device.h>
2956 +#include <ar231x_platform.h>
2957 +#include <ar231x.h>
2958 +#include "devices.h"
2959 +#include "ar5312.h"
2960 +#include "ar2315.h"
2962 +struct ar231x_board_config ar231x_board;
2963 +int ar231x_devtype = DEV_TYPE_UNKNOWN;
2964 +const struct ar231x_gpiodev *ar231x_gpiodev;
2966 +static struct resource ar231x_eth0_res[] = {
2968 + .name = "eth0_membase",
2969 + .flags = IORESOURCE_MEM,
2972 + .name = "eth0_irq",
2973 + .flags = IORESOURCE_IRQ,
2977 +static struct resource ar231x_eth1_res[] = {
2979 + .name = "eth1_membase",
2980 + .flags = IORESOURCE_MEM,
2983 + .name = "eth1_irq",
2984 + .flags = IORESOURCE_IRQ,
2988 +static struct platform_device ar231x_eth[] = {
2991 + .name = "ar231x-eth",
2992 + .resource = ar231x_eth0_res,
2993 + .num_resources = ARRAY_SIZE(ar231x_eth0_res)
2997 + .name = "ar231x-eth",
2998 + .resource = ar231x_eth1_res,
2999 + .num_resources = ARRAY_SIZE(ar231x_eth1_res)
3003 +static struct resource ar231x_wmac0_res[] = {
3005 + .name = "wmac0_membase",
3006 + .flags = IORESOURCE_MEM,
3009 + .name = "wmac0_irq",
3010 + .flags = IORESOURCE_IRQ,
3014 +static struct resource ar231x_wmac1_res[] = {
3016 + .name = "wmac1_membase",
3017 + .flags = IORESOURCE_MEM,
3020 + .name = "wmac1_irq",
3021 + .flags = IORESOURCE_IRQ,
3026 +static struct platform_device ar231x_wmac[] = {
3029 + .name = "ar231x-wmac",
3030 + .resource = ar231x_wmac0_res,
3031 + .num_resources = ARRAY_SIZE(ar231x_wmac0_res),
3032 + .dev.platform_data = &ar231x_board,
3036 + .name = "ar231x-wmac",
3037 + .resource = ar231x_wmac1_res,
3038 + .num_resources = ARRAY_SIZE(ar231x_wmac1_res),
3039 + .dev.platform_data = &ar231x_board,
3043 +static const char *devtype_strings[] = {
3044 + [DEV_TYPE_AR5312] = "Atheros AR5312",
3045 + [DEV_TYPE_AR2312] = "Atheros AR2312",
3046 + [DEV_TYPE_AR2313] = "Atheros AR2313",
3047 + [DEV_TYPE_AR2315] = "Atheros AR2315",
3048 + [DEV_TYPE_AR2316] = "Atheros AR2316",
3049 + [DEV_TYPE_AR2317] = "Atheros AR2317",
3050 + [DEV_TYPE_UNKNOWN] = "Atheros (unknown)",
3053 +const char *get_system_type(void)
3055 + if ((ar231x_devtype >= ARRAY_SIZE(devtype_strings)) ||
3056 + !devtype_strings[ar231x_devtype])
3057 + return devtype_strings[DEV_TYPE_UNKNOWN];
3058 + return devtype_strings[ar231x_devtype];
3063 +ar231x_add_ethernet(int nr, u32 base, int irq, void *pdata)
3065 + struct resource *res;
3067 + ar231x_eth[nr].dev.platform_data = pdata;
3068 + res = &ar231x_eth[nr].resource[0];
3069 + res->start = base;
3070 + res->end = base + 0x2000 - 1;
3074 + return platform_device_register(&ar231x_eth[nr]);
3078 +ar231x_serial_setup(u32 mapbase, unsigned int uartclk)
3080 + struct uart_port s;
3082 + memset(&s, 0, sizeof(s));
3084 + s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
3085 + s.iotype = UPIO_MEM;
3086 + s.irq = AR531X_MISC_IRQ_UART0;
3088 + s.mapbase = mapbase;
3089 + s.uartclk = uartclk;
3090 + s.membase = (void __iomem *)s.mapbase;
3092 + early_serial_setup(&s);
3096 +ar231x_add_wmac(int nr, u32 base, int irq)
3098 + struct resource *res;
3100 + ar231x_wmac[nr].dev.platform_data = &ar231x_board;
3101 + res = &ar231x_wmac[nr].resource[0];
3102 + res->start = base;
3103 + res->end = base + 0x10000 - 1;
3107 + return platform_device_register(&ar231x_wmac[nr]);
3110 +static int __init ar231x_register_devices(void)
3112 + static struct resource res = {
3113 + .start = 0xFFFFFFFF,
3116 + platform_device_register_simple("GPIODEV", 0, &res, 1);
3117 + ar5312_init_devices();
3118 + ar2315_init_devices();
3123 +device_initcall(ar231x_register_devices);