1 --- a/arch/mips/Kconfig
2 +++ b/arch/mips/Kconfig
3 @@ -100,6 +100,19 @@ config BCM63XX
5 Support for BCM63XX 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 @@ -714,6 +727,7 @@ config CAVIUM_OCTEON_REFERENCE_BOARD
27 +source "arch/mips/ar231x/Kconfig"
28 source "arch/mips/alchemy/Kconfig"
29 source "arch/mips/bcm63xx/Kconfig"
30 source "arch/mips/jazz/Kconfig"
31 --- a/arch/mips/Kbuild.platforms
32 +++ b/arch/mips/Kbuild.platforms
33 @@ -5,6 +5,7 @@ platforms += ar7
36 platforms += cavium-octeon
42 +++ b/arch/mips/ar231x/Platform
45 +# Atheros AR5312/AR2312 WiSoC
47 +platform-$(CONFIG_ATHEROS_AR231X) += ar231x/
48 +cflags-$(CONFIG_ATHEROS_AR231X) += -I$(srctree)/arch/mips/include/asm/mach-ar231x
49 +load-$(CONFIG_ATHEROS_AR231X) += 0xffffffff80041000
51 +++ b/arch/mips/ar231x/Kconfig
53 +config ATHEROS_AR5312
54 + bool "Atheros 5312/2312+ support"
55 + depends on ATHEROS_AR231X
58 +config ATHEROS_AR2315
59 + bool "Atheros 2315+ support"
60 + depends on ATHEROS_AR231X
61 + select DMA_NONCOHERENT
65 + select SYS_HAS_CPU_MIPS32_R1
66 + select SYS_SUPPORTS_32BIT_KERNEL
67 + select SYS_SUPPORTS_BIG_ENDIAN
71 +++ b/arch/mips/ar231x/Makefile
74 +# This file is subject to the terms and conditions of the GNU General Public
75 +# License. See the file "COPYING" in the main directory of this archive
78 +# Copyright (C) 2006 FON Technology, SL.
79 +# Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
80 +# Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
83 +obj-y += board.o prom.o devices.o
84 +obj-$(CONFIG_ATHEROS_AR5312) += ar5312.o
85 +obj-$(CONFIG_ATHEROS_AR2315) += ar2315.o
87 +++ b/arch/mips/ar231x/board.c
90 + * This file is subject to the terms and conditions of the GNU General Public
91 + * License. See the file "COPYING" in the main directory of this archive
94 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
95 + * Copyright (C) 2006 FON Technology, SL.
96 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
97 + * Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
100 +#include <generated/autoconf.h>
101 +#include <linux/init.h>
102 +#include <linux/module.h>
103 +#include <linux/types.h>
104 +#include <linux/string.h>
105 +#include <linux/platform_device.h>
106 +#include <linux/kernel.h>
107 +#include <linux/random.h>
108 +#include <linux/etherdevice.h>
109 +#include <asm/irq_cpu.h>
110 +#include <asm/reboot.h>
113 +#include <ar231x_platform.h>
114 +#include "devices.h"
118 +void (*ar231x_irq_dispatch)(void);
121 +check_radio_magic(u8 *addr)
123 + addr += 0x7a; /* offset for flash magic */
124 + if ((addr[0] == 0x5a) && (addr[1] == 0xa5)) {
131 +check_board_data(u8 *flash_limit, u8 *addr, bool broken)
133 + /* config magic found */
134 + if (*((u32 *)addr) == AR531X_BD_MAGIC)
140 + if (check_radio_magic(addr + 0xf8))
141 + ar231x_board.radio = addr + 0xf8;
142 + if ((addr < flash_limit + 0x10000) &&
143 + check_radio_magic(addr + 0x10000))
144 + ar231x_board.radio = addr + 0x10000;
146 + if (ar231x_board.radio) {
147 + /* broken board data detected, use radio data to find the offset,
148 + * user will fix this */
155 +find_board_config(u8 *flash_limit, bool broken)
160 + for (addr = flash_limit - 0x1000;
161 + addr >= flash_limit - 0x30000;
164 + if (check_board_data(flash_limit, addr, broken)) {
177 +find_radio_config(u8 *flash_limit, u8 *board_config)
183 + * Now find the start of Radio Configuration data, using heuristics:
184 + * Search forward from Board Configuration data by 0x1000 bytes
185 + * at a time until we find non-0xffffffff.
188 + for (radio_config = board_config + 0x1000;
189 + (radio_config < flash_limit);
190 + radio_config += 0x1000) {
191 + if ((*(u32 *)radio_config != 0xffffffff) &&
192 + check_radio_magic(radio_config)) {
198 + /* AR2316 relocates radio config to new location */
200 + for (radio_config = board_config + 0xf8;
201 + (radio_config < flash_limit - 0x1000 + 0xf8);
202 + radio_config += 0x1000) {
203 + if ((*(u32 *)radio_config != 0xffffffff) &&
204 + check_radio_magic(radio_config)) {
212 + printk("Could not find Radio Configuration data\n");
216 + return (u8 *) radio_config;
220 +ar231x_find_config(u8 *flash_limit)
222 + struct ar231x_boarddata *config;
223 + unsigned int rcfg_size;
224 + int broken_boarddata = 0;
230 + ar231x_board.config = NULL;
231 + ar231x_board.radio = NULL;
232 + /* Copy the board and radio data to RAM, because accessing the mapped
233 + * memory of the flash directly after booting is not safe */
235 + /* Try to find valid board and radio data */
236 + bcfg = find_board_config(flash_limit, false);
238 + /* If that fails, try to at least find valid radio data */
240 + bcfg = find_board_config(flash_limit, true);
241 + broken_boarddata = 1;
245 + printk(KERN_WARNING "WARNING: No board configuration data found!\n");
249 + board_data = kzalloc(BOARD_CONFIG_BUFSZ, GFP_KERNEL);
250 + ar231x_board.config = (struct ar231x_boarddata *) board_data;
251 + memcpy(board_data, bcfg, 0x100);
252 + if (broken_boarddata) {
253 + printk(KERN_WARNING "WARNING: broken board data detected\n");
254 + config = ar231x_board.config;
255 + if (!memcmp(config->enet0_mac, "\x00\x00\x00\x00\x00\x00", 6)) {
256 + printk(KERN_INFO "Fixing up empty mac addresses\n");
257 + config->resetConfigGpio = 0xffff;
258 + config->sysLedGpio = 0xffff;
259 + random_ether_addr(config->wlan0_mac);
260 + config->wlan0_mac[0] &= ~0x06;
261 + random_ether_addr(config->enet0_mac);
262 + random_ether_addr(config->enet1_mac);
267 + /* Radio config starts 0x100 bytes after board config, regardless
268 + * of what the physical layout on the flash chip looks like */
270 + if (ar231x_board.radio)
271 + rcfg = (u8 *) ar231x_board.radio;
273 + rcfg = find_radio_config(flash_limit, bcfg);
278 + radio_data = board_data + 0x100 + ((rcfg - bcfg) & 0xfff);
279 + ar231x_board.radio = radio_data;
280 + offset = radio_data - board_data;
281 + printk(KERN_INFO "Radio config found at offset 0x%x(0x%x)\n", rcfg - bcfg, offset);
282 + rcfg_size = BOARD_CONFIG_BUFSZ - offset;
283 + memcpy(radio_data, rcfg, rcfg_size);
291 + local_irq_disable();
296 +plat_mem_setup(void)
298 + _machine_halt = ar231x_halt;
299 + pm_power_off = ar231x_halt;
301 + ar5312_plat_setup();
302 + ar2315_plat_setup();
304 + /* Disable data watchpoints */
305 + write_c0_watchlo0(0);
310 +plat_irq_dispatch(void)
312 + ar231x_irq_dispatch();
316 +plat_time_init(void)
318 + ar5312_time_init();
319 + ar2315_time_init();
322 +unsigned int __cpuinit
323 +get_c0_compare_int(void)
325 + return CP0_LEGACY_COMPARE_IRQ;
331 + clear_c0_status(ST0_IM);
332 + mips_cpu_irq_init();
334 + /* Initialize interrupt controllers */
341 +++ b/arch/mips/ar231x/prom.c
344 + * This file is subject to the terms and conditions of the GNU General Public
345 + * License. See the file "COPYING" in the main directory of this archive
346 + * for more details.
348 + * Copyright MontaVista Software Inc
349 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
350 + * Copyright (C) 2006 FON Technology, SL.
351 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
352 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
356 + * Prom setup file for ar531x
359 +#include <linux/init.h>
360 +#include <generated/autoconf.h>
361 +#include <linux/kernel.h>
362 +#include <linux/string.h>
363 +#include <linux/mm.h>
364 +#include <linux/bootmem.h>
366 +#include <asm/bootinfo.h>
367 +#include <asm/addrspace.h>
371 +void __init prom_init(void)
373 + ar5312_prom_init();
374 + ar2315_prom_init();
377 +void __init prom_free_prom_memory(void)
381 +++ b/arch/mips/include/asm/mach-ar231x/ar231x_platform.h
383 +#ifndef __AR531X_PLATFORM_H
384 +#define __AR531X_PLATFORM_H
387 + * This is board-specific data that is stored in a "fixed" location in flash.
388 + * It is shared across operating systems, so it should not be changed lightly.
389 + * The main reason we need it is in order to extract the ethernet MAC
392 +struct ar231x_boarddata {
393 + u32 magic; /* board data is valid */
394 +#define AR531X_BD_MAGIC 0x35333131 /* "5311", for all 531x platforms */
395 + u16 cksum; /* checksum (starting with BD_REV 2) */
396 + u16 rev; /* revision of this struct */
398 + char boardName[64]; /* Name of board */
399 + u16 major; /* Board major number */
400 + u16 minor; /* Board minor number */
401 + u32 flags; /* Board configuration */
402 +#define BD_ENET0 0x00000001 /* ENET0 is stuffed */
403 +#define BD_ENET1 0x00000002 /* ENET1 is stuffed */
404 +#define BD_UART1 0x00000004 /* UART1 is stuffed */
405 +#define BD_UART0 0x00000008 /* UART0 is stuffed (dma) */
406 +#define BD_RSTFACTORY 0x00000010 /* Reset factory defaults stuffed */
407 +#define BD_SYSLED 0x00000020 /* System LED stuffed */
408 +#define BD_EXTUARTCLK 0x00000040 /* External UART clock */
409 +#define BD_CPUFREQ 0x00000080 /* cpu freq is valid in nvram */
410 +#define BD_SYSFREQ 0x00000100 /* sys freq is set in nvram */
411 +#define BD_WLAN0 0x00000200 /* Enable WLAN0 */
412 +#define BD_MEMCAP 0x00000400 /* CAP SDRAM @ memCap for testing */
413 +#define BD_DISWATCHDOG 0x00000800 /* disable system watchdog */
414 +#define BD_WLAN1 0x00001000 /* Enable WLAN1 (ar5212) */
415 +#define BD_ISCASPER 0x00002000 /* FLAG for AR2312 */
416 +#define BD_WLAN0_2G_EN 0x00004000 /* FLAG for radio0_2G */
417 +#define BD_WLAN0_5G_EN 0x00008000 /* FLAG for radio0_2G */
418 +#define BD_WLAN1_2G_EN 0x00020000 /* FLAG for radio0_2G */
419 +#define BD_WLAN1_5G_EN 0x00040000 /* FLAG for radio0_2G */
420 + u16 resetConfigGpio; /* Reset factory GPIO pin */
421 + u16 sysLedGpio; /* System LED GPIO pin */
423 + u32 cpuFreq; /* CPU core frequency in Hz */
424 + u32 sysFreq; /* System frequency in Hz */
425 + u32 cntFreq; /* Calculated C0_COUNT frequency */
431 + u16 pciId; /* Pseudo PCIID for common code */
432 + u16 memCap; /* cap bank1 in MB */
435 + u8 wlan1_mac[6]; /* (ar5212) */
438 +#define BOARD_CONFIG_BUFSZ 0x1000
441 + * Platform device information for the Wireless MAC
443 +struct ar231x_board_config {
446 + /* board config data */
447 + struct ar231x_boarddata *config;
449 + /* radio calibration data */
454 + * Platform device information for the Ethernet MAC
461 + struct ar231x_board_config *config;
465 +#endif /* __AR531X_PLATFORM_H */
467 +++ b/arch/mips/include/asm/mach-ar231x/cpu-feature-overrides.h
470 + * Atheros SoC specific CPU feature overrides
472 + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
474 + * This file was derived from: include/asm-mips/cpu-features.h
475 + * Copyright (C) 2003, 2004 Ralf Baechle
476 + * Copyright (C) 2004 Maciej W. Rozycki
478 + * This program is free software; you can redistribute it and/or modify it
479 + * under the terms of the GNU General Public License version 2 as published
480 + * by the Free Software Foundation.
483 +#ifndef __ASM_MACH_ATHEROS_CPU_FEATURE_OVERRIDES_H
484 +#define __ASM_MACH_ATHEROS_CPU_FEATURE_OVERRIDES_H
487 + * The ATHEROS SoCs have MIPS 4Kc/4KEc core.
489 +#define cpu_has_tlb 1
490 +#define cpu_has_4kex 1
491 +#define cpu_has_3k_cache 0
492 +#define cpu_has_4k_cache 1
493 +#define cpu_has_tx39_cache 0
494 +#define cpu_has_sb1_cache 0
495 +#define cpu_has_fpu 0
496 +#define cpu_has_32fpr 0
497 +#define cpu_has_counter 1
498 +/* #define cpu_has_watch ? */
499 +/* #define cpu_has_divec ? */
500 +/* #define cpu_has_vce ? */
501 +/* #define cpu_has_cache_cdex_p ? */
502 +/* #define cpu_has_cache_cdex_s ? */
503 +/* #define cpu_has_prefetch ? */
504 +/* #define cpu_has_mcheck ? */
505 +#define cpu_has_ejtag 1
507 +#if !defined(CONFIG_ATHEROS_AR5312)
508 +# define cpu_has_llsc 1
511 + * The MIPS 4Kc V0.9 core in the AR5312/AR2312 have problems with the
512 + * ll/sc instructions.
514 +# define cpu_has_llsc 0
517 +#define cpu_has_mips16 0
518 +#define cpu_has_mdmx 0
519 +#define cpu_has_mips3d 0
520 +#define cpu_has_smartmips 0
522 +/* #define cpu_has_vtag_icache ? */
523 +/* #define cpu_has_dc_aliases ? */
524 +/* #define cpu_has_ic_fills_f_dc ? */
525 +/* #define cpu_has_pindexed_dcache ? */
527 +/* #define cpu_icache_snoops_remote_store ? */
529 +#define cpu_has_mips32r1 1
531 +#if !defined(CONFIG_ATHEROS_AR5312)
532 +# define cpu_has_mips32r2 1
535 +#define cpu_has_mips64r1 0
536 +#define cpu_has_mips64r2 0
538 +#define cpu_has_dsp 0
539 +#define cpu_has_mipsmt 0
541 +/* #define cpu_has_nofpuex ? */
542 +#define cpu_has_64bits 0
543 +#define cpu_has_64bit_zero_reg 0
544 +#define cpu_has_64bit_gp_regs 0
545 +#define cpu_has_64bit_addresses 0
547 +/* #define cpu_has_inclusive_pcaches ? */
549 +/* #define cpu_dcache_line_size() ? */
550 +/* #define cpu_icache_line_size() ? */
552 +#endif /* __ASM_MACH_ATHEROS_CPU_FEATURE_OVERRIDES_H */
554 +++ b/arch/mips/include/asm/mach-ar231x/dma-coherence.h
557 + * This file is subject to the terms and conditions of the GNU General Public
558 + * License. See the file "COPYING" in the main directory of this archive
559 + * for more details.
561 + * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
562 + * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org>
565 +#ifndef __ASM_MACH_GENERIC_DMA_COHERENCE_H
566 +#define __ASM_MACH_GENERIC_DMA_COHERENCE_H
568 +#define PCI_DMA_OFFSET 0x20000000
572 +static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size)
574 + return virt_to_phys(addr) + (dev != NULL ? PCI_DMA_OFFSET : 0);
577 +static inline dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
579 + return page_to_phys(page) + (dev != NULL ? PCI_DMA_OFFSET : 0);
582 +static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
583 + dma_addr_t dma_addr)
585 + return (dma_addr > PCI_DMA_OFFSET ? dma_addr - PCI_DMA_OFFSET : dma_addr);
588 +static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
589 + size_t size, enum dma_data_direction direction)
593 +static inline int plat_dma_supported(struct device *dev, u64 mask)
598 +static inline void plat_extra_sync_for_device(struct device *dev)
603 +static inline int plat_dma_mapping_error(struct device *dev,
604 + dma_addr_t dma_addr)
609 +static inline int plat_device_is_coherent(struct device *dev)
611 +#ifdef CONFIG_DMA_COHERENT
614 +#ifdef CONFIG_DMA_NONCOHERENT
619 +#endif /* __ASM_MACH_GENERIC_DMA_COHERENCE_H */
621 +++ b/arch/mips/include/asm/mach-ar231x/gpio.h
623 +#ifndef _ATHEROS_GPIO_H_
624 +#define _ATHEROS_GPIO_H_
628 +struct ar231x_gpiodev {
630 + u32 (*get_output)(void);
631 + u32 (*set_output)(u32 mask, u32 val);
633 + u32 (*set)(u32 mask, u32 val);
636 +extern const struct ar231x_gpiodev *ar231x_gpiodev;
639 + * Wrappers for the generic GPIO layer
642 +static inline int gpio_direction_input(unsigned gpio) {
643 + u32 mask = 1 << gpio;
645 + if (!(ar231x_gpiodev->valid_mask & mask))
648 + ar231x_gpiodev->set_output(mask, 0);
652 +static inline void gpio_set_value(unsigned gpio, int value) {
653 + u32 mask = 1 << gpio;
655 + if (!(ar231x_gpiodev->valid_mask & mask))
658 + ar231x_gpiodev->set(mask, (!!value) * mask);
661 +static inline int gpio_direction_output(unsigned gpio, int value) {
662 + u32 mask = 1 << gpio;
664 + if (!(ar231x_gpiodev->valid_mask & mask))
667 + ar231x_gpiodev->set_output(mask, mask);
668 + ar231x_gpiodev->set(mask, (!!value) * mask);
672 +/* Reads the gpio pin. Unchecked function */
673 +static inline int gpio_get_value(unsigned gpio) {
674 + u32 mask = 1 << gpio;
676 + if (!(ar231x_gpiodev->valid_mask & mask))
679 + return !!(ar231x_gpiodev->get() & mask);
682 +static inline int gpio_request(unsigned gpio, const char *label) {
686 +static inline void gpio_free(unsigned gpio) {
689 +/* Returns IRQ to attach for gpio. Unchecked function */
690 +static inline int gpio_to_irq(unsigned gpio) {
691 + return AR531X_GPIO_IRQ(gpio);
694 +/* Returns gpio for IRQ attached. Unchecked function */
695 +static inline int irq_to_gpio(unsigned irq) {
696 + return (irq - (AR531X_GPIO_IRQ(0)));
699 +#include <asm-generic/gpio.h> /* cansleep wrappers */
703 +++ b/arch/mips/include/asm/mach-ar231x/reset.h
705 +#ifndef __AR531X_RESET_H
706 +#define __AR531X_RESET_H
708 +void ar531x_disable_reset_button(void);
710 +#endif /* __AR531X_RESET_H */
712 +++ b/arch/mips/include/asm/mach-ar231x/war.h
715 + * This file is subject to the terms and conditions of the GNU General Public
716 + * License. See the file "COPYING" in the main directory of this archive
717 + * for more details.
719 + * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
721 +#ifndef __ASM_MIPS_MACH_ATHEROS_WAR_H
722 +#define __ASM_MIPS_MACH_ATHEROS_WAR_H
724 +#define R4600_V1_INDEX_ICACHEOP_WAR 0
725 +#define R4600_V1_HIT_CACHEOP_WAR 0
726 +#define R4600_V2_HIT_CACHEOP_WAR 0
727 +#define R5432_CP0_INTERRUPT_WAR 0
728 +#define BCM1250_M3_WAR 0
729 +#define SIBYTE_1956_WAR 0
730 +#define MIPS4K_ICACHE_REFILL_WAR 0
731 +#define MIPS_CACHE_SYNC_WAR 0
732 +#define TX49XX_ICACHE_INDEX_INV_WAR 0
733 +#define RM9000_CDEX_SMP_WAR 0
734 +#define ICACHE_REFILLS_WORKAROUND_WAR 0
735 +#define R10000_LLSC_WAR 0
736 +#define MIPS34K_MISSED_ITLB_WAR 0
738 +#endif /* __ASM_MIPS_MACH_ATHEROS_WAR_H */
740 +++ b/arch/mips/include/asm/mach-ar231x/ar2315_regs.h
743 + * Register definitions for AR2315+
745 + * This file is subject to the terms and conditions of the GNU General Public
746 + * License. See the file "COPYING" in the main directory of this archive
747 + * for more details.
749 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
750 + * Copyright (C) 2006 FON Technology, SL.
751 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
752 + * Copyright (C) 2006-2008 Felix Fietkau <nbd@openwrt.org>
755 +#ifndef __AR2315_REG_H
756 +#define __AR2315_REG_H
761 +#define AR2315_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
762 +#define AR2315_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
763 +#define AR2315_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
764 +#define AR2315_IRQ_LCBUS_PCI MIPS_CPU_IRQ_BASE+5 /* C0_CAUSE: 0x2000 */
765 +#define AR2315_IRQ_WLAN0_POLL MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
770 +#define AR2315_SPI_READ 0x08000000 /* SPI FLASH */
771 +#define AR2315_WLAN0 0xB0000000 /* Wireless MMR */
772 +#define AR2315_PCI 0xB0100000 /* PCI MMR */
773 +#define AR2315_SDRAMCTL 0xB0300000 /* SDRAM MMR */
774 +#define AR2315_LOCAL 0xB0400000 /* LOCAL BUS MMR */
775 +#define AR2315_ENET0 0xB0500000 /* ETHERNET MMR */
776 +#define AR2315_DSLBASE 0xB1000000 /* RESET CONTROL MMR */
777 +#define AR2315_UART0 0xB1100003 /* UART MMR */
778 +#define AR2315_SPI 0xB1300000 /* SPI FLASH MMR */
779 +#define AR2315_PCIEXT 0x80000000 /* pci external */
784 +#define AR2315_COLD_RESET (AR2315_DSLBASE + 0x0000)
786 +#define AR2315_RESET_COLD_AHB 0x00000001
787 +#define AR2315_RESET_COLD_APB 0x00000002
788 +#define AR2315_RESET_COLD_CPU 0x00000004
789 +#define AR2315_RESET_COLD_CPUWARM 0x00000008
790 +#define AR2315_RESET_SYSTEM (RESET_COLD_CPU | RESET_COLD_APB | RESET_COLD_AHB) /* full system */
791 +#define AR2317_RESET_SYSTEM 0x00000010
794 +#define AR2315_RESET (AR2315_DSLBASE + 0x0004)
796 +#define AR2315_RESET_WARM_WLAN0_MAC 0x00000001 /* warm reset WLAN0 MAC */
797 +#define AR2315_RESET_WARM_WLAN0_BB 0x00000002 /* warm reset WLAN0 BaseBand */
798 +#define AR2315_RESET_MPEGTS_RSVD 0x00000004 /* warm reset MPEG-TS */
799 +#define AR2315_RESET_PCIDMA 0x00000008 /* warm reset PCI ahb/dma */
800 +#define AR2315_RESET_MEMCTL 0x00000010 /* warm reset memory controller */
801 +#define AR2315_RESET_LOCAL 0x00000020 /* warm reset local bus */
802 +#define AR2315_RESET_I2C_RSVD 0x00000040 /* warm reset I2C bus */
803 +#define AR2315_RESET_SPI 0x00000080 /* warm reset SPI interface */
804 +#define AR2315_RESET_UART0 0x00000100 /* warm reset UART0 */
805 +#define AR2315_RESET_IR_RSVD 0x00000200 /* warm reset IR interface */
806 +#define AR2315_RESET_EPHY0 0x00000400 /* cold reset ENET0 phy */
807 +#define AR2315_RESET_ENET0 0x00000800 /* cold reset ENET0 mac */
810 + * AHB master arbitration control
812 +#define AR2315_AHB_ARB_CTL (AR2315_DSLBASE + 0x0008)
814 +#define AR2315_ARB_CPU 0x00000001 /* CPU, default */
815 +#define AR2315_ARB_WLAN 0x00000002 /* WLAN */
816 +#define AR2315_ARB_MPEGTS_RSVD 0x00000004 /* MPEG-TS */
817 +#define AR2315_ARB_LOCAL 0x00000008 /* LOCAL */
818 +#define AR2315_ARB_PCI 0x00000010 /* PCI */
819 +#define AR2315_ARB_ETHERNET 0x00000020 /* Ethernet */
820 +#define AR2315_ARB_RETRY 0x00000100 /* retry policy, debug only */
825 +#define AR2315_ENDIAN_CTL (AR2315_DSLBASE + 0x000c)
827 +#define AR2315_CONFIG_AHB 0x00000001 /* EC - AHB bridge endianess */
828 +#define AR2315_CONFIG_WLAN 0x00000002 /* WLAN byteswap */
829 +#define AR2315_CONFIG_MPEGTS_RSVD 0x00000004 /* MPEG-TS byteswap */
830 +#define AR2315_CONFIG_PCI 0x00000008 /* PCI byteswap */
831 +#define AR2315_CONFIG_MEMCTL 0x00000010 /* Memory controller endianess */
832 +#define AR2315_CONFIG_LOCAL 0x00000020 /* Local bus byteswap */
833 +#define AR2315_CONFIG_ETHERNET 0x00000040 /* Ethernet byteswap */
835 +#define AR2315_CONFIG_MERGE 0x00000200 /* CPU write buffer merge */
836 +#define AR2315_CONFIG_CPU 0x00000400 /* CPU big endian */
837 +#define AR2315_CONFIG_PCIAHB 0x00000800
838 +#define AR2315_CONFIG_PCIAHB_BRIDGE 0x00001000
839 +#define AR2315_CONFIG_SPI 0x00008000 /* SPI byteswap */
840 +#define AR2315_CONFIG_CPU_DRAM 0x00010000
841 +#define AR2315_CONFIG_CPU_PCI 0x00020000
842 +#define AR2315_CONFIG_CPU_MMR 0x00040000
843 +#define AR2315_CONFIG_BIG 0x00000400
849 +#define AR2315_NMI_CTL (AR2315_DSLBASE + 0x0010)
851 +#define AR2315_NMI_EN 1
854 + * Revision Register - Initial value is 0x3010 (WMAC 3.0, AR531X 1.0).
856 +#define AR2315_SREV (AR2315_DSLBASE + 0x0014)
858 +#define AR2315_REV_MAJ 0x00f0
859 +#define AR2315_REV_MAJ_S 4
860 +#define AR2315_REV_MIN 0x000f
861 +#define AR2315_REV_MIN_S 0
862 +#define AR2315_REV_CHIP (AR2315_REV_MAJ|AR2315_REV_MIN)
867 +#define AR2315_IF_CTL (AR2315_DSLBASE + 0x0018)
869 +#define AR2315_IF_MASK 0x00000007
870 +#define AR2315_IF_DISABLED 0
871 +#define AR2315_IF_PCI 1
872 +#define AR2315_IF_TS_LOCAL 2
873 +#define AR2315_IF_ALL 3 /* only for emulation with separate pins */
874 +#define AR2315_IF_LOCAL_HOST 0x00000008
875 +#define AR2315_IF_PCI_HOST 0x00000010
876 +#define AR2315_IF_PCI_INTR 0x00000020
877 +#define AR2315_IF_PCI_CLK_MASK 0x00030000
878 +#define AR2315_IF_PCI_CLK_INPUT 0
879 +#define AR2315_IF_PCI_CLK_OUTPUT_LOW 1
880 +#define AR2315_IF_PCI_CLK_OUTPUT_CLK 2
881 +#define AR2315_IF_PCI_CLK_OUTPUT_HIGH 3
882 +#define AR2315_IF_PCI_CLK_SHIFT 16
885 + * APB Interrupt control
888 +#define AR2315_ISR (AR2315_DSLBASE + 0x0020)
889 +#define AR2315_IMR (AR2315_DSLBASE + 0x0024)
890 +#define AR2315_GISR (AR2315_DSLBASE + 0x0028)
892 +#define AR2315_ISR_UART0 0x0001 /* high speed UART */
893 +#define AR2315_ISR_I2C_RSVD 0x0002 /* I2C bus */
894 +#define AR2315_ISR_SPI 0x0004 /* SPI bus */
895 +#define AR2315_ISR_AHB 0x0008 /* AHB error */
896 +#define AR2315_ISR_APB 0x0010 /* APB error */
897 +#define AR2315_ISR_TIMER 0x0020 /* timer */
898 +#define AR2315_ISR_GPIO 0x0040 /* GPIO */
899 +#define AR2315_ISR_WD 0x0080 /* watchdog */
900 +#define AR2315_ISR_IR_RSVD 0x0100 /* IR */
902 +#define AR2315_GISR_MISC 0x0001
903 +#define AR2315_GISR_WLAN0 0x0002
904 +#define AR2315_GISR_MPEGTS_RSVD 0x0004
905 +#define AR2315_GISR_LOCALPCI 0x0008
906 +#define AR2315_GISR_WMACPOLL 0x0010
907 +#define AR2315_GISR_TIMER 0x0020
908 +#define AR2315_GISR_ETHERNET 0x0040
911 + * Interrupt routing from IO to the processor IP bits
912 + * Define our inter mask and level
914 +#define AR2315_INTR_MISCIO SR_IBIT3
915 +#define AR2315_INTR_WLAN0 SR_IBIT4
916 +#define AR2315_INTR_ENET0 SR_IBIT5
917 +#define AR2315_INTR_LOCALPCI SR_IBIT6
918 +#define AR2315_INTR_WMACPOLL SR_IBIT7
919 +#define AR2315_INTR_COMPARE SR_IBIT8
924 +#define AR2315_TIMER (AR2315_DSLBASE + 0x0030)
925 +#define AR2315_RELOAD (AR2315_DSLBASE + 0x0034)
926 +#define AR2315_WD (AR2315_DSLBASE + 0x0038)
927 +#define AR2315_WDC (AR2315_DSLBASE + 0x003c)
929 +#define AR2315_WDC_IGNORE_EXPIRATION 0x00000000
930 +#define AR2315_WDC_NMI 0x00000001 /* NMI on watchdog */
931 +#define AR2315_WDC_RESET 0x00000002 /* reset on watchdog */
934 + * CPU Performance Counters
936 +#define AR2315_PERFCNT0 (AR2315_DSLBASE + 0x0048)
937 +#define AR2315_PERFCNT1 (AR2315_DSLBASE + 0x004c)
939 +#define AR2315_PERF0_DATAHIT 0x0001 /* Count Data Cache Hits */
940 +#define AR2315_PERF0_DATAMISS 0x0002 /* Count Data Cache Misses */
941 +#define AR2315_PERF0_INSTHIT 0x0004 /* Count Instruction Cache Hits */
942 +#define AR2315_PERF0_INSTMISS 0x0008 /* Count Instruction Cache Misses */
943 +#define AR2315_PERF0_ACTIVE 0x0010 /* Count Active Processor Cycles */
944 +#define AR2315_PERF0_WBHIT 0x0020 /* Count CPU Write Buffer Hits */
945 +#define AR2315_PERF0_WBMISS 0x0040 /* Count CPU Write Buffer Misses */
947 +#define AR2315_PERF1_EB_ARDY 0x0001 /* Count EB_ARdy signal */
948 +#define AR2315_PERF1_EB_AVALID 0x0002 /* Count EB_AValid signal */
949 +#define AR2315_PERF1_EB_WDRDY 0x0004 /* Count EB_WDRdy signal */
950 +#define AR2315_PERF1_EB_RDVAL 0x0008 /* Count EB_RdVal signal */
951 +#define AR2315_PERF1_VRADDR 0x0010 /* Count valid read address cycles */
952 +#define AR2315_PERF1_VWADDR 0x0020 /* Count valid write address cycles */
953 +#define AR2315_PERF1_VWDATA 0x0040 /* Count valid write data cycles */
956 + * AHB Error Reporting.
958 +#define AR2315_AHB_ERR0 (AR2315_DSLBASE + 0x0050) /* error */
959 +#define AR2315_AHB_ERR1 (AR2315_DSLBASE + 0x0054) /* haddr */
960 +#define AR2315_AHB_ERR2 (AR2315_DSLBASE + 0x0058) /* hwdata */
961 +#define AR2315_AHB_ERR3 (AR2315_DSLBASE + 0x005c) /* hrdata */
962 +#define AR2315_AHB_ERR4 (AR2315_DSLBASE + 0x0060) /* status */
964 +#define AHB_ERROR_DET 1 /* AHB Error has been detected, */
965 + /* write 1 to clear all bits in ERR0 */
966 +#define AHB_ERROR_OVR 2 /* AHB Error overflow has been detected */
967 +#define AHB_ERROR_WDT 4 /* AHB Error due to wdt instead of hresp */
969 +#define AR2315_PROCERR_HMAST 0x0000000f
970 +#define AR2315_PROCERR_HMAST_DFLT 0
971 +#define AR2315_PROCERR_HMAST_WMAC 1
972 +#define AR2315_PROCERR_HMAST_ENET 2
973 +#define AR2315_PROCERR_HMAST_PCIENDPT 3
974 +#define AR2315_PROCERR_HMAST_LOCAL 4
975 +#define AR2315_PROCERR_HMAST_CPU 5
976 +#define AR2315_PROCERR_HMAST_PCITGT 6
978 +#define AR2315_PROCERR_HMAST_S 0
979 +#define AR2315_PROCERR_HWRITE 0x00000010
980 +#define AR2315_PROCERR_HSIZE 0x00000060
981 +#define AR2315_PROCERR_HSIZE_S 5
982 +#define AR2315_PROCERR_HTRANS 0x00000180
983 +#define AR2315_PROCERR_HTRANS_S 7
984 +#define AR2315_PROCERR_HBURST 0x00000e00
985 +#define AR2315_PROCERR_HBURST_S 9
990 +#define AR2315_PLLC_CTL (AR2315_DSLBASE + 0x0064)
991 +#define AR2315_PLLV_CTL (AR2315_DSLBASE + 0x0068)
992 +#define AR2315_CPUCLK (AR2315_DSLBASE + 0x006c)
993 +#define AR2315_AMBACLK (AR2315_DSLBASE + 0x0070)
994 +#define AR2315_SYNCCLK (AR2315_DSLBASE + 0x0074)
995 +#define AR2315_DSL_SLEEP_CTL (AR2315_DSLBASE + 0x0080)
996 +#define AR2315_DSL_SLEEP_DUR (AR2315_DSLBASE + 0x0084)
998 +/* PLLc Control fields */
999 +#define PLLC_REF_DIV_M 0x00000003
1000 +#define PLLC_REF_DIV_S 0
1001 +#define PLLC_FDBACK_DIV_M 0x0000007C
1002 +#define PLLC_FDBACK_DIV_S 2
1003 +#define PLLC_ADD_FDBACK_DIV_M 0x00000080
1004 +#define PLLC_ADD_FDBACK_DIV_S 7
1005 +#define PLLC_CLKC_DIV_M 0x0001c000
1006 +#define PLLC_CLKC_DIV_S 14
1007 +#define PLLC_CLKM_DIV_M 0x00700000
1008 +#define PLLC_CLKM_DIV_S 20
1010 +/* CPU CLK Control fields */
1011 +#define CPUCLK_CLK_SEL_M 0x00000003
1012 +#define CPUCLK_CLK_SEL_S 0
1013 +#define CPUCLK_CLK_DIV_M 0x0000000c
1014 +#define CPUCLK_CLK_DIV_S 2
1016 +/* AMBA CLK Control fields */
1017 +#define AMBACLK_CLK_SEL_M 0x00000003
1018 +#define AMBACLK_CLK_SEL_S 0
1019 +#define AMBACLK_CLK_DIV_M 0x0000000c
1020 +#define AMBACLK_CLK_DIV_S 2
1025 +#define AR2315_GPIO_DI (AR2315_DSLBASE + 0x0088)
1026 +#define AR2315_GPIO_DO (AR2315_DSLBASE + 0x0090)
1027 +#define AR2315_GPIO_CR (AR2315_DSLBASE + 0x0098)
1028 +#define AR2315_GPIO_INT (AR2315_DSLBASE + 0x00a0)
1030 +#define AR2315_GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
1031 +#define AR2315_GPIO_CR_O(x) (1 << (x)) /* output */
1032 +#define AR2315_GPIO_CR_I(x) (0) /* input */
1034 +#define AR2315_GPIO_INT_S(x) (x) /* interrupt enable */
1035 +#define AR2315_GPIO_INT_M (0x3F) /* mask for int */
1036 +#define AR2315_GPIO_INT_LVL(x) ((x) << 6) /* interrupt level */
1037 +#define AR2315_GPIO_INT_LVL_M ((0x3) << 6) /* mask for int level */
1039 +#define AR2315_GPIO_INT_MAX_Y 1 /* Maximum value of Y for AR5313_GPIO_INT_* macros */
1040 +#define AR2315_GPIO_INT_LVL_OFF 0 /* Triggerring off */
1041 +#define AR2315_GPIO_INT_LVL_LOW 1 /* Low Level Triggered */
1042 +#define AR2315_GPIO_INT_LVL_HIGH 2 /* High Level Triggered */
1043 +#define AR2315_GPIO_INT_LVL_EDGE 3 /* Edge Triggered */
1045 +#define AR2315_RESET_GPIO 5
1046 +#define AR2315_NUM_GPIO 22
1049 + * PCI Clock Control
1051 +#define AR2315_PCICLK (AR2315_DSLBASE + 0x00a4)
1053 +#define AR2315_PCICLK_INPUT_M 0x3
1054 +#define AR2315_PCICLK_INPUT_S 0
1056 +#define AR2315_PCICLK_PLLC_CLKM 0
1057 +#define AR2315_PCICLK_PLLC_CLKM1 1
1058 +#define AR2315_PCICLK_PLLC_CLKC 2
1059 +#define AR2315_PCICLK_REF_CLK 3
1061 +#define AR2315_PCICLK_DIV_M 0xc
1062 +#define AR2315_PCICLK_DIV_S 2
1064 +#define AR2315_PCICLK_IN_FREQ 0
1065 +#define AR2315_PCICLK_IN_FREQ_DIV_6 1
1066 +#define AR2315_PCICLK_IN_FREQ_DIV_8 2
1067 +#define AR2315_PCICLK_IN_FREQ_DIV_10 3
1070 + * Observation Control Register
1072 +#define AR2315_OCR (AR2315_DSLBASE + 0x00b0)
1073 +#define OCR_GPIO0_IRIN 0x0040
1074 +#define OCR_GPIO1_IROUT 0x0080
1075 +#define OCR_GPIO3_RXCLR 0x0200
1078 + * General Clock Control
1081 +#define AR2315_MISCCLK (AR2315_DSLBASE + 0x00b4)
1082 +#define MISCCLK_PLLBYPASS_EN 0x00000001
1083 +#define MISCCLK_PROCREFCLK 0x00000002
1086 + * SDRAM Controller
1087 + * - No read or write buffers are included.
1089 +#define AR2315_MEM_CFG (AR2315_SDRAMCTL + 0x00)
1090 +#define AR2315_MEM_CTRL (AR2315_SDRAMCTL + 0x0c)
1091 +#define AR2315_MEM_REF (AR2315_SDRAMCTL + 0x10)
1093 +#define SDRAM_DATA_WIDTH_M 0x00006000
1094 +#define SDRAM_DATA_WIDTH_S 13
1096 +#define SDRAM_COL_WIDTH_M 0x00001E00
1097 +#define SDRAM_COL_WIDTH_S 9
1099 +#define SDRAM_ROW_WIDTH_M 0x000001E0
1100 +#define SDRAM_ROW_WIDTH_S 5
1102 +#define SDRAM_BANKADDR_BITS_M 0x00000018
1103 +#define SDRAM_BANKADDR_BITS_S 3
1106 + * SPI Flash Interface Registers
1109 +#define AR2315_SPI_CTL (AR2315_SPI + 0x00)
1110 +#define AR2315_SPI_OPCODE (AR2315_SPI + 0x04)
1111 +#define AR2315_SPI_DATA (AR2315_SPI + 0x08)
1113 +#define SPI_CTL_START 0x00000100
1114 +#define SPI_CTL_BUSY 0x00010000
1115 +#define SPI_CTL_TXCNT_MASK 0x0000000f
1116 +#define SPI_CTL_RXCNT_MASK 0x000000f0
1117 +#define SPI_CTL_TX_RX_CNT_MASK 0x000000ff
1118 +#define SPI_CTL_SIZE_MASK 0x00060000
1120 +#define SPI_CTL_CLK_SEL_MASK 0x03000000
1121 +#define SPI_OPCODE_MASK 0x000000ff
1124 + * PCI Bus Interface Registers
1126 +#define AR2315_PCI_1MS_REG (AR2315_PCI + 0x0008)
1127 +#define AR2315_PCI_1MS_MASK 0x3FFFF /* # of AHB clk cycles in 1ms */
1129 +#define AR2315_PCI_MISC_CONFIG (AR2315_PCI + 0x000c)
1130 +#define AR2315_PCIMISC_TXD_EN 0x00000001 /* Enable TXD for fragments */
1131 +#define AR2315_PCIMISC_CFG_SEL 0x00000002 /* mem or config cycles */
1132 +#define AR2315_PCIMISC_GIG_MASK 0x0000000C /* bits 31-30 for pci req */
1133 +#define AR2315_PCIMISC_RST_MODE 0x00000030
1134 +#define AR2315_PCIRST_INPUT 0x00000000 /* 4:5=0 rst is input */
1135 +#define AR2315_PCIRST_LOW 0x00000010 /* 4:5=1 rst to GND */
1136 +#define AR2315_PCIRST_HIGH 0x00000020 /* 4:5=2 rst to VDD */
1137 +#define AR2315_PCIGRANT_EN 0x00000000 /* 6:7=0 early grant en */
1138 +#define AR2315_PCIGRANT_FRAME 0x00000040 /* 6:7=1 grant waits 4 frame */
1139 +#define AR2315_PCIGRANT_IDLE 0x00000080 /* 6:7=2 grant waits 4 idle */
1140 +#define AR2315_PCIGRANT_GAP 0x00000000 /* 6:7=2 grant waits 4 idle */
1141 +#define AR2315_PCICACHE_DIS 0x00001000 /* PCI external access cache disable */
1143 +#define AR2315_PCI_OUT_TSTAMP (AR2315_PCI + 0x0010)
1145 +#define AR2315_PCI_UNCACHE_CFG (AR2315_PCI + 0x0014)
1147 +#define AR2315_PCI_IN_EN (AR2315_PCI + 0x0100)
1148 +#define AR2315_PCI_IN_EN0 0x01 /* Enable chain 0 */
1149 +#define AR2315_PCI_IN_EN1 0x02 /* Enable chain 1 */
1150 +#define AR2315_PCI_IN_EN2 0x04 /* Enable chain 2 */
1151 +#define AR2315_PCI_IN_EN3 0x08 /* Enable chain 3 */
1153 +#define AR2315_PCI_IN_DIS (AR2315_PCI + 0x0104)
1154 +#define AR2315_PCI_IN_DIS0 0x01 /* Disable chain 0 */
1155 +#define AR2315_PCI_IN_DIS1 0x02 /* Disable chain 1 */
1156 +#define AR2315_PCI_IN_DIS2 0x04 /* Disable chain 2 */
1157 +#define AR2315_PCI_IN_DIS3 0x08 /* Disable chain 3 */
1159 +#define AR2315_PCI_IN_PTR (AR2315_PCI + 0x0200)
1161 +#define AR2315_PCI_OUT_EN (AR2315_PCI + 0x0400)
1162 +#define AR2315_PCI_OUT_EN0 0x01 /* Enable chain 0 */
1164 +#define AR2315_PCI_OUT_DIS (AR2315_PCI + 0x0404)
1165 +#define AR2315_PCI_OUT_DIS0 0x01 /* Disable chain 0 */
1167 +#define AR2315_PCI_OUT_PTR (AR2315_PCI + 0x0408)
1169 +#define AR2315_PCI_INT_STATUS (AR2315_PCI + 0x0500) /* write one to clr */
1170 +#define AR2315_PCI_TXINT 0x00000001 /* Desc In Completed */
1171 +#define AR2315_PCI_TXOK 0x00000002 /* Desc In OK */
1172 +#define AR2315_PCI_TXERR 0x00000004 /* Desc In ERR */
1173 +#define AR2315_PCI_TXEOL 0x00000008 /* Desc In End-of-List */
1174 +#define AR2315_PCI_RXINT 0x00000010 /* Desc Out Completed */
1175 +#define AR2315_PCI_RXOK 0x00000020 /* Desc Out OK */
1176 +#define AR2315_PCI_RXERR 0x00000040 /* Desc Out ERR */
1177 +#define AR2315_PCI_RXEOL 0x00000080 /* Desc Out EOL */
1178 +#define AR2315_PCI_TXOOD 0x00000200 /* Desc In Out-of-Desc */
1179 +#define AR2315_PCI_MASK 0x0000FFFF /* Desc Mask */
1180 +#define AR2315_PCI_EXT_INT 0x02000000
1181 +#define AR2315_PCI_ABORT_INT 0x04000000
1183 +#define AR2315_PCI_INT_MASK (AR2315_PCI + 0x0504) /* same as INT_STATUS */
1185 +#define AR2315_PCI_INTEN_REG (AR2315_PCI + 0x0508)
1186 +#define AR2315_PCI_INT_DISABLE 0x00 /* disable pci interrupts */
1187 +#define AR2315_PCI_INT_ENABLE 0x01 /* enable pci interrupts */
1189 +#define AR2315_PCI_HOST_IN_EN (AR2315_PCI + 0x0800)
1190 +#define AR2315_PCI_HOST_IN_DIS (AR2315_PCI + 0x0804)
1191 +#define AR2315_PCI_HOST_IN_PTR (AR2315_PCI + 0x0810)
1192 +#define AR2315_PCI_HOST_OUT_EN (AR2315_PCI + 0x0900)
1193 +#define AR2315_PCI_HOST_OUT_DIS (AR2315_PCI + 0x0904)
1194 +#define AR2315_PCI_HOST_OUT_PTR (AR2315_PCI + 0x0908)
1198 + * Local Bus Interface Registers
1200 +#define AR2315_LB_CONFIG (AR2315_LOCAL + 0x0000)
1201 +#define AR2315_LBCONF_OE 0x00000001 /* =1 OE is low-true */
1202 +#define AR2315_LBCONF_CS0 0x00000002 /* =1 first CS is low-true */
1203 +#define AR2315_LBCONF_CS1 0x00000004 /* =1 2nd CS is low-true */
1204 +#define AR2315_LBCONF_RDY 0x00000008 /* =1 RDY is low-true */
1205 +#define AR2315_LBCONF_WE 0x00000010 /* =1 Write En is low-true */
1206 +#define AR2315_LBCONF_WAIT 0x00000020 /* =1 WAIT is low-true */
1207 +#define AR2315_LBCONF_ADS 0x00000040 /* =1 Adr Strobe is low-true */
1208 +#define AR2315_LBCONF_MOT 0x00000080 /* =0 Intel, =1 Motorola */
1209 +#define AR2315_LBCONF_8CS 0x00000100 /* =1 8 bits CS, 0= 16bits */
1210 +#define AR2315_LBCONF_8DS 0x00000200 /* =1 8 bits Data S, 0=16bits */
1211 +#define AR2315_LBCONF_ADS_EN 0x00000400 /* =1 Enable ADS */
1212 +#define AR2315_LBCONF_ADR_OE 0x00000800 /* =1 Adr cap on OE, WE or DS */
1213 +#define AR2315_LBCONF_ADDT_MUX 0x00001000 /* =1 Adr and Data share bus */
1214 +#define AR2315_LBCONF_DATA_OE 0x00002000 /* =1 Data cap on OE, WE, DS */
1215 +#define AR2315_LBCONF_16DATA 0x00004000 /* =1 Data is 16 bits wide */
1216 +#define AR2315_LBCONF_SWAPDT 0x00008000 /* =1 Byte swap data */
1217 +#define AR2315_LBCONF_SYNC 0x00010000 /* =1 Bus synchronous to clk */
1218 +#define AR2315_LBCONF_INT 0x00020000 /* =1 Intr is low true */
1219 +#define AR2315_LBCONF_INT_CTR0 0x00000000 /* GND high-Z, Vdd is high-Z */
1220 +#define AR2315_LBCONF_INT_CTR1 0x00040000 /* GND drive, Vdd is high-Z */
1221 +#define AR2315_LBCONF_INT_CTR2 0x00080000 /* GND high-Z, Vdd drive */
1222 +#define AR2315_LBCONF_INT_CTR3 0x000C0000 /* GND drive, Vdd drive */
1223 +#define AR2315_LBCONF_RDY_WAIT 0x00100000 /* =1 RDY is negative of WAIT */
1224 +#define AR2315_LBCONF_INT_PULSE 0x00200000 /* =1 Interrupt is a pulse */
1225 +#define AR2315_LBCONF_ENABLE 0x00400000 /* =1 Falcon respond to LB */
1227 +#define AR2315_LB_CLKSEL (AR2315_LOCAL + 0x0004)
1228 +#define AR2315_LBCLK_EXT 0x0001 /* use external clk for lb */
1230 +#define AR2315_LB_1MS (AR2315_LOCAL + 0x0008)
1231 +#define AR2315_LB1MS_MASK 0x3FFFF /* # of AHB clk cycles in 1ms */
1233 +#define AR2315_LB_MISCCFG (AR2315_LOCAL + 0x000C)
1234 +#define AR2315_LBM_TXD_EN 0x00000001 /* Enable TXD for fragments */
1235 +#define AR2315_LBM_RX_INTEN 0x00000002 /* Enable LB ints on RX ready */
1236 +#define AR2315_LBM_MBOXWR_INTEN 0x00000004 /* Enable LB ints on mbox wr */
1237 +#define AR2315_LBM_MBOXRD_INTEN 0x00000008 /* Enable LB ints on mbox rd */
1238 +#define AR2315_LMB_DESCSWAP_EN 0x00000010 /* Byte swap desc enable */
1239 +#define AR2315_LBM_TIMEOUT_MASK 0x00FFFF80
1240 +#define AR2315_LBM_TIMEOUT_SHFT 7
1241 +#define AR2315_LBM_PORTMUX 0x07000000
1244 +#define AR2315_LB_RXTSOFF (AR2315_LOCAL + 0x0010)
1246 +#define AR2315_LB_TX_CHAIN_EN (AR2315_LOCAL + 0x0100)
1247 +#define AR2315_LB_TXEN_0 0x01
1248 +#define AR2315_LB_TXEN_1 0x02
1249 +#define AR2315_LB_TXEN_2 0x04
1250 +#define AR2315_LB_TXEN_3 0x08
1252 +#define AR2315_LB_TX_CHAIN_DIS (AR2315_LOCAL + 0x0104)
1253 +#define AR2315_LB_TX_DESC_PTR (AR2315_LOCAL + 0x0200)
1255 +#define AR2315_LB_RX_CHAIN_EN (AR2315_LOCAL + 0x0400)
1256 +#define AR2315_LB_RXEN 0x01
1258 +#define AR2315_LB_RX_CHAIN_DIS (AR2315_LOCAL + 0x0404)
1259 +#define AR2315_LB_RX_DESC_PTR (AR2315_LOCAL + 0x0408)
1261 +#define AR2315_LB_INT_STATUS (AR2315_LOCAL + 0x0500)
1262 +#define AR2315_INT_TX_DESC 0x0001
1263 +#define AR2315_INT_TX_OK 0x0002
1264 +#define AR2315_INT_TX_ERR 0x0004
1265 +#define AR2315_INT_TX_EOF 0x0008
1266 +#define AR2315_INT_RX_DESC 0x0010
1267 +#define AR2315_INT_RX_OK 0x0020
1268 +#define AR2315_INT_RX_ERR 0x0040
1269 +#define AR2315_INT_RX_EOF 0x0080
1270 +#define AR2315_INT_TX_TRUNC 0x0100
1271 +#define AR2315_INT_TX_STARVE 0x0200
1272 +#define AR2315_INT_LB_TIMEOUT 0x0400
1273 +#define AR2315_INT_LB_ERR 0x0800
1274 +#define AR2315_INT_MBOX_WR 0x1000
1275 +#define AR2315_INT_MBOX_RD 0x2000
1277 +/* Bit definitions for INT MASK are the same as INT_STATUS */
1278 +#define AR2315_LB_INT_MASK (AR2315_LOCAL + 0x0504)
1280 +#define AR2315_LB_INT_EN (AR2315_LOCAL + 0x0508)
1281 +#define AR2315_LB_MBOX (AR2315_LOCAL + 0x0600)
1284 + * IR Interface Registers
1286 +#define AR2315_IR_PKTDATA (AR2315_IR + 0x0000)
1288 +#define AR2315_IR_PKTLEN (AR2315_IR + 0x07fc) /* 0 - 63 */
1290 +#define AR2315_IR_CONTROL (AR2315_IR + 0x0800)
1291 +#define AR2315_IRCTL_TX 0x00000000 /* use as tranmitter */
1292 +#define AR2315_IRCTL_RX 0x00000001 /* use as receiver */
1293 +#define AR2315_IRCTL_SAMPLECLK_MASK 0x00003ffe /* Sample clk divisor mask */
1294 +#define AR2315_IRCTL_SAMPLECLK_SHFT 1
1295 +#define AR2315_IRCTL_OUTPUTCLK_MASK 0x03ffc000 /* Output clk divisor mask */
1296 +#define AR2315_IRCTL_OUTPUTCLK_SHFT 14
1298 +#define AR2315_IR_STATUS (AR2315_IR + 0x0804)
1299 +#define AR2315_IRSTS_RX 0x00000001 /* receive in progress */
1300 +#define AR2315_IRSTS_TX 0x00000002 /* transmit in progress */
1302 +#define AR2315_IR_CONFIG (AR2315_IR + 0x0808)
1303 +#define AR2315_IRCFG_INVIN 0x00000001 /* invert input polarity */
1304 +#define AR2315_IRCFG_INVOUT 0x00000002 /* invert output polarity */
1305 +#define AR2315_IRCFG_SEQ_START_WIN_SEL 0x00000004 /* 1 => 28, 0 => 7 */
1306 +#define AR2315_IRCFG_SEQ_START_THRESH 0x000000f0 /* */
1307 +#define AR2315_IRCFG_SEQ_END_UNIT_SEL 0x00000100 /* */
1308 +#define AR2315_IRCFG_SEQ_END_UNIT_THRESH 0x00007e00 /* */
1309 +#define AR2315_IRCFG_SEQ_END_WIN_SEL 0x00008000 /* */
1310 +#define AR2315_IRCFG_SEQ_END_WIN_THRESH 0x001f0000 /* */
1311 +#define AR2315_IRCFG_NUM_BACKOFF_WORDS 0x01e00000 /* */
1313 +#define HOST_PCI_DEV_ID 3
1314 +#define HOST_PCI_MBAR0 0x10000000
1315 +#define HOST_PCI_MBAR1 0x20000000
1316 +#define HOST_PCI_MBAR2 0x30000000
1318 +#define HOST_PCI_SDRAM_BASEADDR HOST_PCI_MBAR1
1319 +#define PCI_DEVICE_MEM_SPACE 0x800000
1321 +#endif /* __AR2315_REG_H */
1323 +++ b/arch/mips/include/asm/mach-ar231x/ar5312_regs.h
1326 + * This file is subject to the terms and conditions of the GNU General Public
1327 + * License. See the file "COPYING" in the main directory of this archive
1328 + * for more details.
1330 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
1331 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
1332 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
1338 +#include <asm/addrspace.h>
1344 +#define AR5312_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
1345 +#define AR5312_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
1346 +#define AR5312_IRQ_ENET1_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
1347 +#define AR5312_IRQ_WLAN1_INTRS MIPS_CPU_IRQ_BASE+5 /* C0_CAUSE: 0x2000 */
1348 +#define AR5312_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
1352 +#define AR531X_WLAN0 0x18000000
1353 +#define AR531X_WLAN1 0x18500000
1354 +#define AR531X_ENET0 0x18100000
1355 +#define AR531X_ENET1 0x18200000
1356 +#define AR531X_SDRAMCTL 0x18300000
1357 +#define AR531X_FLASHCTL 0x18400000
1358 +#define AR531X_APBBASE 0x1c000000
1359 +#define AR531X_FLASH 0x1e000000
1360 +#define AR531X_UART0 0xbc000003 /* UART MMR */
1363 + * AR531X_NUM_ENET_MAC defines the number of ethernet MACs that
1364 + * should be considered available. The AR5312 supports 2 enet MACS,
1365 + * even though many reference boards only actually use 1 of them
1366 + * (i.e. Only MAC 0 is actually connected to an enet PHY or PHY switch.
1367 + * The AR2312 supports 1 enet MAC.
1369 +#define AR531X_NUM_ENET_MAC 2
1372 + * Need these defines to determine true number of ethernet MACs
1374 +#define AR5212_AR5312_REV2 0x0052 /* AR5312 WMAC (AP31) */
1375 +#define AR5212_AR5312_REV7 0x0057 /* AR5312 WMAC (AP30-040) */
1376 +#define AR5212_AR2313_REV8 0x0058 /* AR2313 WMAC (AP43-030) */
1377 +#define AR531X_RADIO_MASK_OFF 0xc8
1378 +#define AR531X_RADIO0_MASK 0x0003
1379 +#define AR531X_RADIO1_MASK 0x000c
1380 +#define AR531X_RADIO1_S 2
1383 + * AR531X_NUM_WMAC defines the number of Wireless MACs that\
1384 + * should be considered available.
1386 +#define AR531X_NUM_WMAC 2
1388 +/* Reset/Timer Block Address Map */
1389 +#define AR531X_RESETTMR (AR531X_APBBASE + 0x3000)
1390 +#define AR531X_TIMER (AR531X_RESETTMR + 0x0000) /* countdown timer */
1391 +#define AR531X_WD_CTRL (AR531X_RESETTMR + 0x0008) /* watchdog cntrl */
1392 +#define AR531X_WD_TIMER (AR531X_RESETTMR + 0x000c) /* watchdog timer */
1393 +#define AR531X_ISR (AR531X_RESETTMR + 0x0010) /* Intr Status Reg */
1394 +#define AR531X_IMR (AR531X_RESETTMR + 0x0014) /* Intr Mask Reg */
1395 +#define AR531X_RESET (AR531X_RESETTMR + 0x0020)
1396 +#define AR5312_CLOCKCTL1 (AR531X_RESETTMR + 0x0064)
1397 +#define AR5312_SCRATCH (AR531X_RESETTMR + 0x006c)
1398 +#define AR531X_PROCADDR (AR531X_RESETTMR + 0x0070)
1399 +#define AR531X_PROC1 (AR531X_RESETTMR + 0x0074)
1400 +#define AR531X_DMAADDR (AR531X_RESETTMR + 0x0078)
1401 +#define AR531X_DMA1 (AR531X_RESETTMR + 0x007c)
1402 +#define AR531X_ENABLE (AR531X_RESETTMR + 0x0080) /* interface enb */
1403 +#define AR531X_REV (AR531X_RESETTMR + 0x0090) /* revision */
1405 +/* AR531X_WD_CTRL register bit field definitions */
1406 +#define AR531X_WD_CTRL_IGNORE_EXPIRATION 0x0000
1407 +#define AR531X_WD_CTRL_NMI 0x0001
1408 +#define AR531X_WD_CTRL_RESET 0x0002
1410 +/* AR531X_ISR register bit field definitions */
1411 +#define AR531X_ISR_NONE 0x0000
1412 +#define AR531X_ISR_TIMER 0x0001
1413 +#define AR531X_ISR_AHBPROC 0x0002
1414 +#define AR531X_ISR_AHBDMA 0x0004
1415 +#define AR531X_ISR_GPIO 0x0008
1416 +#define AR531X_ISR_UART0 0x0010
1417 +#define AR531X_ISR_UART0DMA 0x0020
1418 +#define AR531X_ISR_WD 0x0040
1419 +#define AR531X_ISR_LOCAL 0x0080
1421 +/* AR531X_RESET register bit field definitions */
1422 +#define AR531X_RESET_SYSTEM 0x00000001 /* cold reset full system */
1423 +#define AR531X_RESET_PROC 0x00000002 /* cold reset MIPS core */
1424 +#define AR531X_RESET_WLAN0 0x00000004 /* cold reset WLAN MAC and BB */
1425 +#define AR531X_RESET_EPHY0 0x00000008 /* cold reset ENET0 phy */
1426 +#define AR531X_RESET_EPHY1 0x00000010 /* cold reset ENET1 phy */
1427 +#define AR531X_RESET_ENET0 0x00000020 /* cold reset ENET0 mac */
1428 +#define AR531X_RESET_ENET1 0x00000040 /* cold reset ENET1 mac */
1429 +#define AR531X_RESET_UART0 0x00000100 /* cold reset UART0 (high speed) */
1430 +#define AR531X_RESET_WLAN1 0x00000200 /* cold reset WLAN MAC/BB */
1431 +#define AR531X_RESET_APB 0x00000400 /* cold reset APB (ar5312) */
1432 +#define AR531X_RESET_WARM_PROC 0x00001000 /* warm reset MIPS core */
1433 +#define AR531X_RESET_WARM_WLAN0_MAC 0x00002000 /* warm reset WLAN0 MAC */
1434 +#define AR531X_RESET_WARM_WLAN0_BB 0x00004000 /* warm reset WLAN0 BaseBand */
1435 +#define AR531X_RESET_NMI 0x00010000 /* send an NMI to the processor */
1436 +#define AR531X_RESET_WARM_WLAN1_MAC 0x00020000 /* warm reset WLAN1 mac */
1437 +#define AR531X_RESET_WARM_WLAN1_BB 0x00040000 /* warm reset WLAN1 baseband */
1438 +#define AR531X_RESET_LOCAL_BUS 0x00080000 /* reset local bus */
1439 +#define AR531X_RESET_WDOG 0x00100000 /* last reset was a watchdog */
1441 +#define AR531X_RESET_WMAC0_BITS \
1442 + AR531X_RESET_WLAN0 |\
1443 + AR531X_RESET_WARM_WLAN0_MAC |\
1444 + AR531X_RESET_WARM_WLAN0_BB
1446 +#define AR531X_RESERT_WMAC1_BITS \
1447 + AR531X_RESET_WLAN1 |\
1448 + AR531X_RESET_WARM_WLAN1_MAC |\
1449 + AR531X_RESET_WARM_WLAN1_BB
1451 +/* AR5312_CLOCKCTL1 register bit field definitions */
1452 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
1453 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
1454 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
1455 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
1456 +#define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
1458 +/* Valid for AR5312 and AR2312 */
1459 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
1460 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
1461 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
1462 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
1463 +#define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
1465 +/* Valid for AR2313 */
1466 +#define AR2313_CLOCKCTL1_PREDIVIDE_MASK 0x00003000
1467 +#define AR2313_CLOCKCTL1_PREDIVIDE_SHIFT 12
1468 +#define AR2313_CLOCKCTL1_MULTIPLIER_MASK 0x001f0000
1469 +#define AR2313_CLOCKCTL1_MULTIPLIER_SHIFT 16
1470 +#define AR2313_CLOCKCTL1_DOUBLER_MASK 0x00000000
1473 +/* AR531X_ENABLE register bit field definitions */
1474 +#define AR531X_ENABLE_WLAN0 0x0001
1475 +#define AR531X_ENABLE_ENET0 0x0002
1476 +#define AR531X_ENABLE_ENET1 0x0004
1477 +#define AR531X_ENABLE_UART_AND_WLAN1_PIO 0x0008 /* UART, and WLAN1 PIOs */
1478 +#define AR531X_ENABLE_WLAN1_DMA 0x0010 /* WLAN1 DMAs */
1479 +#define AR531X_ENABLE_WLAN1 \
1480 + (AR531X_ENABLE_UART_AND_WLAN1_PIO | AR531X_ENABLE_WLAN1_DMA)
1482 +/* AR531X_REV register bit field definitions */
1483 +#define AR531X_REV_WMAC_MAJ 0xf000
1484 +#define AR531X_REV_WMAC_MAJ_S 12
1485 +#define AR531X_REV_WMAC_MIN 0x0f00
1486 +#define AR531X_REV_WMAC_MIN_S 8
1487 +#define AR531X_REV_MAJ 0x00f0
1488 +#define AR531X_REV_MAJ_S 4
1489 +#define AR531X_REV_MIN 0x000f
1490 +#define AR531X_REV_MIN_S 0
1491 +#define AR531X_REV_CHIP (AR531X_REV_MAJ|AR531X_REV_MIN)
1493 +/* Major revision numbers, bits 7..4 of Revision ID register */
1494 +#define AR531X_REV_MAJ_AR5312 0x4
1495 +#define AR531X_REV_MAJ_AR2313 0x5
1497 +/* Minor revision numbers, bits 3..0 of Revision ID register */
1498 +#define AR5312_REV_MIN_DUAL 0x0 /* Dual WLAN version */
1499 +#define AR5312_REV_MIN_SINGLE 0x1 /* Single WLAN version */
1501 +/* AR531X_FLASHCTL register bit field definitions */
1502 +#define FLASHCTL_IDCY 0x0000000f /* Idle cycle turn around time */
1503 +#define FLASHCTL_IDCY_S 0
1504 +#define FLASHCTL_WST1 0x000003e0 /* Wait state 1 */
1505 +#define FLASHCTL_WST1_S 5
1506 +#define FLASHCTL_RBLE 0x00000400 /* Read byte lane enable */
1507 +#define FLASHCTL_WST2 0x0000f800 /* Wait state 2 */
1508 +#define FLASHCTL_WST2_S 11
1509 +#define FLASHCTL_AC 0x00070000 /* Flash address check (added) */
1510 +#define FLASHCTL_AC_S 16
1511 +#define FLASHCTL_AC_128K 0x00000000
1512 +#define FLASHCTL_AC_256K 0x00010000
1513 +#define FLASHCTL_AC_512K 0x00020000
1514 +#define FLASHCTL_AC_1M 0x00030000
1515 +#define FLASHCTL_AC_2M 0x00040000
1516 +#define FLASHCTL_AC_4M 0x00050000
1517 +#define FLASHCTL_AC_8M 0x00060000
1518 +#define FLASHCTL_AC_RES 0x00070000 /* 16MB is not supported */
1519 +#define FLASHCTL_E 0x00080000 /* Flash bank enable (added) */
1520 +#define FLASHCTL_BUSERR 0x01000000 /* Bus transfer error status flag */
1521 +#define FLASHCTL_WPERR 0x02000000 /* Write protect error status flag */
1522 +#define FLASHCTL_WP 0x04000000 /* Write protect */
1523 +#define FLASHCTL_BM 0x08000000 /* Burst mode */
1524 +#define FLASHCTL_MW 0x30000000 /* Memory width */
1525 +#define FLASHCTL_MWx8 0x00000000 /* Memory width x8 */
1526 +#define FLASHCTL_MWx16 0x10000000 /* Memory width x16 */
1527 +#define FLASHCTL_MWx32 0x20000000 /* Memory width x32 (not supported) */
1528 +#define FLASHCTL_ATNR 0x00000000 /* Access type == no retry */
1529 +#define FLASHCTL_ATR 0x80000000 /* Access type == retry every */
1530 +#define FLASHCTL_ATR4 0xc0000000 /* Access type == retry every 4 */
1532 +/* ARM Flash Controller -- 3 flash banks with either x8 or x16 devices. */
1533 +#define AR531X_FLASHCTL0 (AR531X_FLASHCTL + 0x00)
1534 +#define AR531X_FLASHCTL1 (AR531X_FLASHCTL + 0x04)
1535 +#define AR531X_FLASHCTL2 (AR531X_FLASHCTL + 0x08)
1537 +/* ARM SDRAM Controller -- just enough to determine memory size */
1538 +#define AR531X_MEM_CFG1 (AR531X_SDRAMCTL + 0x04)
1539 +#define MEM_CFG1_AC0 0x00000700 /* bank 0: SDRAM addr check (added) */
1540 +#define MEM_CFG1_AC0_S 8
1541 +#define MEM_CFG1_AC1 0x00007000 /* bank 1: SDRAM addr check (added) */
1542 +#define MEM_CFG1_AC1_S 12
1544 +/* GPIO Address Map */
1545 +#define AR531X_GPIO (AR531X_APBBASE + 0x2000)
1546 +#define AR531X_GPIO_DO (AR531X_GPIO + 0x00) /* output register */
1547 +#define AR531X_GPIO_DI (AR531X_GPIO + 0x04) /* intput register */
1548 +#define AR531X_GPIO_CR (AR531X_GPIO + 0x08) /* control register */
1550 +/* GPIO Control Register bit field definitions */
1551 +#define AR531X_GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
1552 +#define AR531X_GPIO_CR_O(x) (0 << (x)) /* mask for output */
1553 +#define AR531X_GPIO_CR_I(x) (1 << (x)) /* mask for input */
1554 +#define AR531X_GPIO_CR_INT(x) (1 << ((x)+8)) /* mask for interrupt */
1555 +#define AR531X_GPIO_CR_UART(x) (1 << ((x)+16)) /* uart multiplex */
1556 +#define AR531X_NUM_GPIO 8
1562 +++ b/arch/mips/ar231x/ar5312.c
1565 + * This file is subject to the terms and conditions of the GNU General Public
1566 + * License. See the file "COPYING" in the main directory of this archive
1567 + * for more details.
1569 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
1570 + * Copyright (C) 2006 FON Technology, SL.
1571 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
1572 + * Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
1576 + * Platform devices for Atheros SoCs
1579 +#include <generated/autoconf.h>
1580 +#include <linux/init.h>
1581 +#include <linux/module.h>
1582 +#include <linux/types.h>
1583 +#include <linux/string.h>
1584 +#include <linux/mtd/physmap.h>
1585 +#include <linux/platform_device.h>
1586 +#include <linux/kernel.h>
1587 +#include <linux/reboot.h>
1588 +#include <linux/leds.h>
1589 +#include <asm/bootinfo.h>
1590 +#include <asm/reboot.h>
1591 +#include <asm/time.h>
1592 +#include <asm/irq.h>
1593 +#include <asm/io.h>
1596 +#include <ar231x_platform.h>
1597 +#include <ar5312_regs.h>
1598 +#include <ar231x.h>
1599 +#include "devices.h"
1600 +#include "ar5312.h"
1603 +ar5312_misc_irq_dispatch(void)
1605 + unsigned int ar231x_misc_intrs = ar231x_read_reg(AR531X_ISR) & ar231x_read_reg(AR531X_IMR);
1607 + if (ar231x_misc_intrs & AR531X_ISR_TIMER) {
1608 + do_IRQ(AR531X_MISC_IRQ_TIMER);
1609 + (void)ar231x_read_reg(AR531X_TIMER);
1610 + } else if (ar231x_misc_intrs & AR531X_ISR_AHBPROC)
1611 + do_IRQ(AR531X_MISC_IRQ_AHB_PROC);
1612 + else if ((ar231x_misc_intrs & AR531X_ISR_UART0))
1613 + do_IRQ(AR531X_MISC_IRQ_UART0);
1614 + else if (ar231x_misc_intrs & AR531X_ISR_WD)
1615 + do_IRQ(AR531X_MISC_IRQ_WATCHDOG);
1617 + do_IRQ(AR531X_MISC_IRQ_NONE);
1620 +static asmlinkage void
1621 +ar5312_irq_dispatch(void)
1623 + int pending = read_c0_status() & read_c0_cause();
1625 + if (pending & CAUSEF_IP2)
1626 + do_IRQ(AR5312_IRQ_WLAN0_INTRS);
1627 + else if (pending & CAUSEF_IP3)
1628 + do_IRQ(AR5312_IRQ_ENET0_INTRS);
1629 + else if (pending & CAUSEF_IP4)
1630 + do_IRQ(AR5312_IRQ_ENET1_INTRS);
1631 + else if (pending & CAUSEF_IP5)
1632 + do_IRQ(AR5312_IRQ_WLAN1_INTRS);
1633 + else if (pending & CAUSEF_IP6)
1634 + ar5312_misc_irq_dispatch();
1635 + else if (pending & CAUSEF_IP7)
1636 + do_IRQ(AR531X_IRQ_CPU_CLOCK);
1640 +/* Enable the specified AR531X_MISC_IRQ interrupt */
1642 +ar5312_misc_intr_enable(unsigned int irq)
1646 + imr = ar231x_read_reg(AR531X_IMR);
1647 + imr |= (1 << (irq - AR531X_MISC_IRQ_BASE - 1));
1648 + ar231x_write_reg(AR531X_IMR, imr);
1651 +/* Disable the specified AR531X_MISC_IRQ interrupt */
1653 +ar5312_misc_intr_disable(unsigned int irq)
1657 + imr = ar231x_read_reg(AR531X_IMR);
1658 + imr &= ~(1 << (irq - AR531X_MISC_IRQ_BASE - 1));
1659 + ar231x_write_reg(AR531X_IMR, imr);
1660 + ar231x_read_reg(AR531X_IMR); /* flush write buffer */
1664 +ar5312_misc_intr_end(unsigned int irq)
1666 + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
1667 + ar5312_misc_intr_enable(irq);
1670 +static struct irq_chip ar5312_misc_intr_controller = {
1671 + .name = "AR5312-MISC",
1672 + .disable = ar5312_misc_intr_disable,
1673 + .ack = ar5312_misc_intr_disable,
1674 + .mask_ack = ar5312_misc_intr_disable,
1675 + .mask = ar5312_misc_intr_disable,
1676 + .unmask = ar5312_misc_intr_enable,
1677 + .end = ar5312_misc_intr_end,
1681 +static irqreturn_t ar5312_ahb_proc_handler(int cpl, void *dev_id)
1683 + u32 proc1 = ar231x_read_reg(AR531X_PROC1);
1684 + u32 procAddr = ar231x_read_reg(AR531X_PROCADDR); /* clears error state */
1685 + u32 dma1 = ar231x_read_reg(AR531X_DMA1);
1686 + u32 dmaAddr = ar231x_read_reg(AR531X_DMAADDR); /* clears error state */
1688 + printk("AHB interrupt: PROCADDR=0x%8.8x PROC1=0x%8.8x DMAADDR=0x%8.8x DMA1=0x%8.8x\n",
1689 + procAddr, proc1, dmaAddr, dma1);
1691 + machine_restart("AHB error"); /* Catastrophic failure */
1692 + return IRQ_HANDLED;
1696 +static struct irqaction ar5312_ahb_proc_interrupt = {
1697 + .handler = ar5312_ahb_proc_handler,
1698 + .flags = IRQF_DISABLED,
1699 + .name = "ar5312_ahb_proc_interrupt",
1703 +static struct irqaction cascade = {
1704 + .handler = no_action,
1705 + .flags = IRQF_DISABLED,
1706 + .name = "cascade",
1709 +void __init ar5312_irq_init(void)
1716 + ar231x_irq_dispatch = ar5312_irq_dispatch;
1717 + for (i = 0; i < AR531X_MISC_IRQ_COUNT; i++) {
1718 + int irq = AR531X_MISC_IRQ_BASE + i;
1719 + set_irq_chip_and_handler(irq, &ar5312_misc_intr_controller,
1720 + handle_level_irq);
1722 + setup_irq(AR531X_MISC_IRQ_AHB_PROC, &ar5312_ahb_proc_interrupt);
1723 + setup_irq(AR5312_IRQ_MISC_INTRS, &cascade);
1726 +const struct ar231x_gpiodev ar5312_gpiodev;
1729 +ar5312_gpio_get_output(void)
1732 + reg = ~(ar231x_read_reg(AR531X_GPIO_CR));
1733 + reg &= ar5312_gpiodev.valid_mask;
1738 +ar5312_gpio_set_output(u32 mask, u32 val)
1742 + reg = ar231x_read_reg(AR531X_GPIO_CR);
1745 + ar231x_write_reg(AR531X_GPIO_CR, reg);
1750 +ar5312_gpio_get(void)
1753 + reg = ar231x_read_reg(AR531X_GPIO_DI);
1754 + reg &= ar5312_gpiodev.valid_mask;
1759 +ar5312_gpio_set(u32 mask, u32 value)
1762 + reg = ar231x_read_reg(AR531X_GPIO_DO);
1765 + ar231x_write_reg(AR531X_GPIO_DO, reg);
1769 +const struct ar231x_gpiodev ar5312_gpiodev = {
1770 + .valid_mask = (1 << 8) - 1,
1771 + .get_output = ar5312_gpio_get_output,
1772 + .set_output = ar5312_gpio_set_output,
1773 + .get = ar5312_gpio_get,
1774 + .set = ar5312_gpio_set,
1777 +static struct physmap_flash_data ar5312_flash_data = {
1781 +static struct resource ar5312_flash_resource = {
1782 + .start = AR531X_FLASH,
1783 + .end = AR531X_FLASH + 0x800000 - 1,
1784 + .flags = IORESOURCE_MEM,
1787 +static struct ar231x_eth ar5312_eth0_data = {
1788 + .reset_base = AR531X_RESET,
1789 + .reset_mac = AR531X_RESET_ENET0,
1790 + .reset_phy = AR531X_RESET_EPHY0,
1791 + .phy_base = KSEG1ADDR(AR531X_ENET0),
1792 + .config = &ar231x_board,
1795 +static struct ar231x_eth ar5312_eth1_data = {
1796 + .reset_base = AR531X_RESET,
1797 + .reset_mac = AR531X_RESET_ENET1,
1798 + .reset_phy = AR531X_RESET_EPHY1,
1799 + .phy_base = KSEG1ADDR(AR531X_ENET1),
1800 + .config = &ar231x_board,
1803 +static struct platform_device ar5312_physmap_flash = {
1804 + .name = "physmap-flash",
1806 + .dev.platform_data = &ar5312_flash_data,
1807 + .resource = &ar5312_flash_resource,
1808 + .num_resources = 1,
1811 +#ifdef CONFIG_LEDS_GPIO
1812 +static struct gpio_led ar5312_leds[] = {
1813 + { .name = "wlan", .gpio = 0, .active_low = 1, },
1816 +static const struct gpio_led_platform_data ar5312_led_data = {
1817 + .num_leds = ARRAY_SIZE(ar5312_leds),
1818 + .leds = (void *) ar5312_leds,
1821 +static struct platform_device ar5312_gpio_leds = {
1822 + .name = "leds-gpio",
1824 + .dev.platform_data = (void *) &ar5312_led_data,
1829 + * NB: This mapping size is larger than the actual flash size,
1830 + * but this shouldn't be a problem here, because the flash
1831 + * will simply be mapped multiple times.
1833 +static char __init *ar5312_flash_limit(void)
1837 + * Configure flash bank 0.
1838 + * Assume 8M window size. Flash will be aliased if it's smaller
1840 + ctl = FLASHCTL_E |
1843 + (0x01 << FLASHCTL_IDCY_S) |
1844 + (0x07 << FLASHCTL_WST1_S) |
1845 + (0x07 << FLASHCTL_WST2_S) |
1846 + (ar231x_read_reg(AR531X_FLASHCTL0) & FLASHCTL_MW);
1848 + ar231x_write_reg(AR531X_FLASHCTL0, ctl);
1850 + /* Disable other flash banks */
1851 + ar231x_write_reg(AR531X_FLASHCTL1,
1852 + ar231x_read_reg(AR531X_FLASHCTL1) & ~(FLASHCTL_E | FLASHCTL_AC));
1854 + ar231x_write_reg(AR531X_FLASHCTL2,
1855 + ar231x_read_reg(AR531X_FLASHCTL2) & ~(FLASHCTL_E | FLASHCTL_AC));
1857 + return (char *) KSEG1ADDR(AR531X_FLASH + 0x800000);
1860 +int __init ar5312_init_devices(void)
1862 + struct ar231x_boarddata *config;
1870 + /* Locate board/radio config data */
1871 + ar231x_find_config(ar5312_flash_limit());
1872 + config = ar231x_board.config;
1876 + * Chip IDs and hardware detection for some Atheros
1877 + * models are really broken!
1879 + * Atheros uses a disabled WMAC0 and Silicon ID of AR5312
1880 + * as indication for AR2312, which is otherwise
1881 + * indistinguishable from the real AR5312.
1883 + if (ar231x_board.radio) {
1884 + radio = ar231x_board.radio + AR531X_RADIO_MASK_OFF;
1885 + if ((*((const u32 *) radio) & AR531X_RADIO0_MASK) == 0)
1886 + config->flags |= BD_ISCASPER;
1890 + /* AR2313 has CPU minor rev. 10 */
1891 + if ((current_cpu_data.processor_id & 0xff) == 0x0a)
1892 + ar231x_devtype = DEV_TYPE_AR2313;
1894 + /* AR2312 shares the same Silicon ID as AR5312 */
1895 + else if (config->flags & BD_ISCASPER)
1896 + ar231x_devtype = DEV_TYPE_AR2312;
1898 + /* Everything else is probably AR5312 or compatible */
1900 + ar231x_devtype = DEV_TYPE_AR5312;
1902 + /* fixup flash width */
1903 + fctl = ar231x_read_reg(AR531X_FLASHCTL) & FLASHCTL_MW;
1905 + case FLASHCTL_MWx16:
1906 + ar5312_flash_data.width = 2;
1908 + case FLASHCTL_MWx8:
1910 + ar5312_flash_data.width = 1;
1914 + platform_device_register(&ar5312_physmap_flash);
1916 +#ifdef CONFIG_LEDS_GPIO
1917 + ar5312_leds[0].gpio = config->sysLedGpio;
1918 + platform_device_register(&ar5312_gpio_leds);
1921 + /* Fix up MAC addresses if necessary */
1922 + if (!memcmp(config->enet0_mac, "\xff\xff\xff\xff\xff\xff", 6))
1923 + memcpy(config->enet0_mac, config->enet1_mac, 6);
1925 + /* If ENET0 and ENET1 have the same mac address,
1926 + * increment the one from ENET1 */
1927 + if (memcmp(config->enet0_mac, config->enet1_mac, 6) == 0) {
1928 + c = config->enet1_mac + 5;
1929 + while ((c >= config->enet1_mac) && !(++(*c)))
1933 + switch(ar231x_devtype) {
1934 + case DEV_TYPE_AR5312:
1935 + ar5312_eth0_data.macaddr = config->enet0_mac;
1936 + ar231x_add_ethernet(0, KSEG1ADDR(AR531X_ENET0),
1937 + AR5312_IRQ_ENET0_INTRS, &ar5312_eth0_data);
1939 + ar5312_eth1_data.macaddr = config->enet1_mac;
1940 + ar231x_add_ethernet(1, KSEG1ADDR(AR531X_ENET1),
1941 + AR5312_IRQ_ENET1_INTRS, &ar5312_eth1_data);
1943 + if (!ar231x_board.radio)
1946 + if ((*((u32 *) radio) & AR531X_RADIO0_MASK) &&
1947 + (config->flags & BD_WLAN0))
1948 + ar231x_add_wmac(0, AR531X_WLAN0,
1949 + AR5312_IRQ_WLAN0_INTRS);
1953 + * AR2312/3 ethernet uses the PHY of ENET0, but the MAC
1954 + * of ENET1. Atheros calls it 'twisted' for a reason :)
1956 + case DEV_TYPE_AR2312:
1957 + case DEV_TYPE_AR2313:
1958 + ar5312_eth1_data.phy_base = ar5312_eth0_data.phy_base;
1959 + ar5312_eth1_data.reset_phy = ar5312_eth0_data.reset_phy;
1960 + ar5312_eth1_data.macaddr = config->enet0_mac;
1961 + ar231x_add_ethernet(0, KSEG1ADDR(AR531X_ENET1),
1962 + AR5312_IRQ_ENET1_INTRS, &ar5312_eth1_data);
1964 + if (!ar231x_board.radio)
1971 + if ((*((u32 *) radio) & AR531X_RADIO1_MASK) &&
1972 + (config->flags & BD_WLAN1))
1973 + ar231x_add_wmac(1, AR531X_WLAN1,
1974 + AR5312_IRQ_WLAN1_INTRS);
1980 +static void ar5312_restart(char *command)
1982 + /* reset the system */
1983 + local_irq_disable();
1985 + ar231x_write_reg(AR531X_RESET, AR531X_RESET_SYSTEM);
1991 + * This table is indexed by bits 5..4 of the CLOCKCTL1 register
1992 + * to determine the predevisor value.
1994 +static int __initdata CLOCKCTL1_PREDIVIDE_TABLE[4] = { 1, 2, 4, 5 };
1998 +ar5312_cpu_frequency(void)
2000 + unsigned int result;
2001 + unsigned int predivide_mask, predivide_shift;
2002 + unsigned int multiplier_mask, multiplier_shift;
2003 + unsigned int clockCtl1, preDivideSelect, preDivisor, multiplier;
2004 + unsigned int doubler_mask;
2007 + /* Trust the bootrom's idea of cpu frequency. */
2008 + if ((result = ar231x_read_reg(AR5312_SCRATCH)))
2011 + devid = ar231x_read_reg(AR531X_REV);
2012 + devid &= AR531X_REV_MAJ;
2013 + devid >>= AR531X_REV_MAJ_S;
2014 + if (devid == AR531X_REV_MAJ_AR2313) {
2015 + predivide_mask = AR2313_CLOCKCTL1_PREDIVIDE_MASK;
2016 + predivide_shift = AR2313_CLOCKCTL1_PREDIVIDE_SHIFT;
2017 + multiplier_mask = AR2313_CLOCKCTL1_MULTIPLIER_MASK;
2018 + multiplier_shift = AR2313_CLOCKCTL1_MULTIPLIER_SHIFT;
2019 + doubler_mask = AR2313_CLOCKCTL1_DOUBLER_MASK;
2020 + } else { /* AR5312 and AR2312 */
2021 + predivide_mask = AR5312_CLOCKCTL1_PREDIVIDE_MASK;
2022 + predivide_shift = AR5312_CLOCKCTL1_PREDIVIDE_SHIFT;
2023 + multiplier_mask = AR5312_CLOCKCTL1_MULTIPLIER_MASK;
2024 + multiplier_shift = AR5312_CLOCKCTL1_MULTIPLIER_SHIFT;
2025 + doubler_mask = AR5312_CLOCKCTL1_DOUBLER_MASK;
2029 + * Clocking is derived from a fixed 40MHz input clock.
2031 + * cpuFreq = InputClock * MULT (where MULT is PLL multiplier)
2032 + * sysFreq = cpuFreq / 4 (used for APB clock, serial,
2033 + * flash, Timer, Watchdog Timer)
2035 + * cntFreq = cpuFreq / 2 (use for CPU count/compare)
2037 + * So, for example, with a PLL multiplier of 5, we have
2039 + * cpuFreq = 200MHz
2041 + * cntFreq = 100MHz
2043 + * We compute the CPU frequency, based on PLL settings.
2046 + clockCtl1 = ar231x_read_reg(AR5312_CLOCKCTL1);
2047 + preDivideSelect = (clockCtl1 & predivide_mask) >> predivide_shift;
2048 + preDivisor = CLOCKCTL1_PREDIVIDE_TABLE[preDivideSelect];
2049 + multiplier = (clockCtl1 & multiplier_mask) >> multiplier_shift;
2051 + if (clockCtl1 & doubler_mask) {
2052 + multiplier = multiplier << 1;
2054 + return (40000000 / preDivisor) * multiplier;
2058 +ar5312_sys_frequency(void)
2060 + return ar5312_cpu_frequency() / 4;
2064 +ar5312_time_init(void)
2069 + mips_hpt_frequency = ar5312_cpu_frequency() / 2;
2074 +ar5312_prom_init(void)
2076 + u32 memsize, memcfg, bank0AC, bank1AC;
2082 + /* Detect memory size */
2083 + memcfg = ar231x_read_reg(AR531X_MEM_CFG1);
2084 + bank0AC = (memcfg & MEM_CFG1_AC0) >> MEM_CFG1_AC0_S;
2085 + bank1AC = (memcfg & MEM_CFG1_AC1) >> MEM_CFG1_AC1_S;
2086 + memsize = (bank0AC ? (1 << (bank0AC+1)) : 0)
2087 + + (bank1AC ? (1 << (bank1AC+1)) : 0);
2089 + add_memory_region(0, memsize, BOOT_MEM_RAM);
2091 + devid = ar231x_read_reg(AR531X_REV);
2092 + devid >>= AR531X_REV_WMAC_MIN_S;
2093 + devid &= AR531X_REV_CHIP;
2094 + ar231x_board.devid = (u16) devid;
2095 + ar231x_gpiodev = &ar5312_gpiodev;
2099 +ar5312_plat_setup(void)
2104 + /* Clear any lingering AHB errors */
2105 + ar231x_read_reg(AR531X_PROCADDR);
2106 + ar231x_read_reg(AR531X_DMAADDR);
2107 + ar231x_write_reg(AR531X_WD_CTRL, AR531X_WD_CTRL_IGNORE_EXPIRATION);
2109 + _machine_restart = ar5312_restart;
2110 + ar231x_serial_setup(KSEG1ADDR(AR531X_UART0), ar5312_sys_frequency());
2114 +++ b/arch/mips/ar231x/ar2315.c
2117 + * This file is subject to the terms and conditions of the GNU General Public
2118 + * License. See the file "COPYING" in the main directory of this archive
2119 + * for more details.
2121 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
2122 + * Copyright (C) 2006 FON Technology, SL.
2123 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
2124 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
2128 + * Platform devices for Atheros SoCs
2131 +#include <generated/autoconf.h>
2132 +#include <linux/init.h>
2133 +#include <linux/module.h>
2134 +#include <linux/types.h>
2135 +#include <linux/string.h>
2136 +#include <linux/platform_device.h>
2137 +#include <linux/kernel.h>
2138 +#include <linux/reboot.h>
2139 +#include <linux/delay.h>
2140 +#include <linux/leds.h>
2141 +#include <asm/bootinfo.h>
2142 +#include <asm/reboot.h>
2143 +#include <asm/time.h>
2144 +#include <asm/irq.h>
2145 +#include <asm/io.h>
2146 +#include <asm/gpio.h>
2148 +#include <ar231x_platform.h>
2149 +#include <ar2315_regs.h>
2150 +#include <ar231x.h>
2151 +#include "devices.h"
2152 +#include "ar2315.h"
2154 +static u32 gpiointmask = 0, gpiointval = 0;
2156 +static inline void ar2315_gpio_irq(void)
2161 + /* only do one gpio interrupt at a time */
2162 + pend = (ar231x_read_reg(AR2315_GPIO_DI) ^ gpiointval) & gpiointmask;
2165 + bit = fls(pend) - 1;
2166 + pend &= ~(1 << bit);
2167 + gpiointval ^= (1 << bit);
2171 + ar231x_write_reg(AR2315_ISR, AR2315_ISR_GPIO);
2173 + /* Enable interrupt with edge detection */
2174 + if ((ar231x_read_reg(AR2315_GPIO_CR) & AR2315_GPIO_CR_M(bit)) != AR2315_GPIO_CR_I(bit))
2178 + do_IRQ(AR531X_GPIO_IRQ_BASE + bit);
2183 + * Called when an interrupt is received, this function
2184 + * determines exactly which interrupt it was, and it
2185 + * invokes the appropriate handler.
2187 + * Implicitly, we also define interrupt priority by
2188 + * choosing which to dispatch first.
2190 +static asmlinkage void
2191 +ar2315_irq_dispatch(void)
2193 + int pending = read_c0_status() & read_c0_cause();
2195 + if (pending & CAUSEF_IP3)
2196 + do_IRQ(AR2315_IRQ_WLAN0_INTRS);
2197 + else if (pending & CAUSEF_IP4)
2198 + do_IRQ(AR2315_IRQ_ENET0_INTRS);
2199 + else if (pending & CAUSEF_IP2) {
2200 + unsigned int misc_intr = ar231x_read_reg(AR2315_ISR) & ar231x_read_reg(AR2315_IMR);
2202 + if (misc_intr & AR2315_ISR_SPI)
2203 + do_IRQ(AR531X_MISC_IRQ_SPI);
2204 + else if (misc_intr & AR2315_ISR_TIMER)
2205 + do_IRQ(AR531X_MISC_IRQ_TIMER);
2206 + else if (misc_intr & AR2315_ISR_AHB)
2207 + do_IRQ(AR531X_MISC_IRQ_AHB_PROC);
2208 + else if (misc_intr & AR2315_ISR_GPIO)
2209 + ar2315_gpio_irq();
2210 + else if (misc_intr & AR2315_ISR_UART0)
2211 + do_IRQ(AR531X_MISC_IRQ_UART0);
2212 + else if (misc_intr & AR2315_ISR_WD)
2213 + do_IRQ(AR531X_MISC_IRQ_WATCHDOG);
2215 + do_IRQ(AR531X_MISC_IRQ_NONE);
2216 + } else if (pending & CAUSEF_IP7)
2217 + do_IRQ(AR531X_IRQ_CPU_CLOCK);
2220 +static void ar2315_set_gpiointmask(int gpio, int level)
2224 + reg = ar231x_read_reg(AR2315_GPIO_INT);
2225 + reg &= ~(AR2315_GPIO_INT_M | AR2315_GPIO_INT_LVL_M);
2226 + reg |= gpio | AR2315_GPIO_INT_LVL(level);
2227 + ar231x_write_reg(AR2315_GPIO_INT, reg);
2230 +static void ar2315_gpio_intr_enable(unsigned int irq)
2232 + unsigned int gpio = irq - AR531X_GPIO_IRQ_BASE;
2234 + /* Enable interrupt with edge detection */
2235 + if ((ar231x_read_reg(AR2315_GPIO_CR) & AR2315_GPIO_CR_M(gpio)) != AR2315_GPIO_CR_I(gpio))
2238 + gpiointmask |= (1 << gpio);
2239 + ar2315_set_gpiointmask(gpio, 3);
2242 +static unsigned int ar2315_gpio_intr_startup(unsigned int irq)
2244 + unsigned int gpio = irq - AR531X_GPIO_IRQ_BASE;
2246 + /* reconfigure GPIO line as input */
2247 + ar231x_mask_reg(AR2315_GPIO_CR, AR2315_GPIO_CR_M(gpio), AR2315_GPIO_CR_I(gpio));
2248 + ar2315_gpio_intr_enable(irq);
2252 +static void ar2315_gpio_intr_disable(unsigned int irq)
2254 + unsigned int gpio = irq - AR531X_GPIO_IRQ_BASE;
2256 + /* Disable interrupt */
2257 + gpiointmask &= ~(1 << gpio);
2258 + ar2315_set_gpiointmask(gpio, 0);
2262 +ar2315_gpio_intr_end(unsigned int irq)
2264 + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
2265 + ar2315_gpio_intr_enable(irq);
2268 +static struct irq_chip ar2315_gpio_intr_controller = {
2269 + .name = "AR2315-GPIO",
2270 + .startup = ar2315_gpio_intr_startup,
2271 + .ack = ar2315_gpio_intr_disable,
2272 + .mask_ack = ar2315_gpio_intr_disable,
2273 + .mask = ar2315_gpio_intr_disable,
2274 + .unmask = ar2315_gpio_intr_enable,
2275 + .end = ar2315_gpio_intr_end,
2279 +ar2315_misc_intr_enable(unsigned int irq)
2283 + imr = ar231x_read_reg(AR2315_IMR);
2285 + case AR531X_MISC_IRQ_SPI:
2286 + imr |= AR2315_ISR_SPI;
2288 + case AR531X_MISC_IRQ_TIMER:
2289 + imr |= AR2315_ISR_TIMER;
2291 + case AR531X_MISC_IRQ_AHB_PROC:
2292 + imr |= AR2315_ISR_AHB;
2294 + case AR531X_MISC_IRQ_GPIO:
2295 + imr |= AR2315_ISR_GPIO;
2297 + case AR531X_MISC_IRQ_UART0:
2298 + imr |= AR2315_ISR_UART0;
2300 + case AR531X_MISC_IRQ_WATCHDOG:
2301 + imr |= AR2315_ISR_WD;
2306 + ar231x_write_reg(AR2315_IMR, imr);
2310 +ar2315_misc_intr_disable(unsigned int irq)
2314 + imr = ar231x_read_reg(AR2315_IMR);
2316 + case AR531X_MISC_IRQ_SPI:
2317 + imr &= ~AR2315_ISR_SPI;
2319 + case AR531X_MISC_IRQ_TIMER:
2320 + imr &= ~AR2315_ISR_TIMER;
2322 + case AR531X_MISC_IRQ_AHB_PROC:
2323 + imr &= ~AR2315_ISR_AHB;
2325 + case AR531X_MISC_IRQ_GPIO:
2326 + imr &= ~AR2315_ISR_GPIO;
2328 + case AR531X_MISC_IRQ_UART0:
2329 + imr &= ~AR2315_ISR_UART0;
2331 + case AR531X_MISC_IRQ_WATCHDOG:
2332 + imr &= ~AR2315_ISR_WD;
2337 + ar231x_write_reg(AR2315_IMR, imr);
2341 +ar2315_misc_intr_end(unsigned int irq)
2343 + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
2344 + ar2315_misc_intr_enable(irq);
2348 +static struct irq_chip ar2315_misc_intr_controller = {
2349 + .name = "AR2315-MISC",
2350 + .ack = ar2315_misc_intr_disable,
2351 + .mask_ack = ar2315_misc_intr_disable,
2352 + .mask = ar2315_misc_intr_disable,
2353 + .unmask = ar2315_misc_intr_enable,
2354 + .end = ar2315_misc_intr_end,
2357 +static irqreturn_t ar2315_ahb_proc_handler(int cpl, void *dev_id)
2359 + ar231x_write_reg(AR2315_AHB_ERR0, AHB_ERROR_DET);
2360 + ar231x_read_reg(AR2315_AHB_ERR1);
2362 + printk(KERN_ERR "AHB fatal error\n");
2363 + machine_restart("AHB error"); /* Catastrophic failure */
2365 + return IRQ_HANDLED;
2368 +static struct irqaction ar2315_ahb_proc_interrupt = {
2369 + .handler = ar2315_ahb_proc_handler,
2370 + .flags = IRQF_DISABLED,
2371 + .name = "ar2315_ahb_proc_interrupt",
2374 +static struct irqaction cascade = {
2375 + .handler = no_action,
2376 + .flags = IRQF_DISABLED,
2377 + .name = "cascade",
2381 +ar2315_irq_init(void)
2388 + ar231x_irq_dispatch = ar2315_irq_dispatch;
2389 + gpiointval = ar231x_read_reg(AR2315_GPIO_DI);
2390 + for (i = 0; i < AR531X_MISC_IRQ_COUNT; i++) {
2391 + int irq = AR531X_MISC_IRQ_BASE + i;
2392 + set_irq_chip_and_handler(irq, &ar2315_misc_intr_controller,
2393 + handle_level_irq);
2395 + for (i = 0; i < AR531X_GPIO_IRQ_COUNT; i++) {
2396 + int irq = AR531X_GPIO_IRQ_BASE + i;
2397 + set_irq_chip_and_handler(irq, &ar2315_gpio_intr_controller,
2398 + handle_level_irq);
2400 + setup_irq(AR531X_MISC_IRQ_GPIO, &cascade);
2401 + setup_irq(AR531X_MISC_IRQ_AHB_PROC, &ar2315_ahb_proc_interrupt);
2402 + setup_irq(AR2315_IRQ_MISC_INTRS, &cascade);
2405 +const struct ar231x_gpiodev ar2315_gpiodev;
2408 +ar2315_gpio_get_output(void)
2411 + reg = ar231x_read_reg(AR2315_GPIO_CR);
2412 + reg &= ar2315_gpiodev.valid_mask;
2417 +ar2315_gpio_set_output(u32 mask, u32 val)
2421 + reg = ar231x_read_reg(AR2315_GPIO_CR);
2424 + ar231x_write_reg(AR2315_GPIO_CR, reg);
2429 +ar2315_gpio_get(void)
2432 + reg = ar231x_read_reg(AR2315_GPIO_DI);
2433 + reg &= ar2315_gpiodev.valid_mask;
2438 +ar2315_gpio_set(u32 mask, u32 value)
2441 + reg = ar231x_read_reg(AR2315_GPIO_DO);
2444 + ar231x_write_reg(AR2315_GPIO_DO, reg);
2448 +const struct ar231x_gpiodev ar2315_gpiodev = {
2449 + .valid_mask = (1 << 22) - 1,
2450 + .get_output = ar2315_gpio_get_output,
2451 + .set_output = ar2315_gpio_set_output,
2452 + .get = ar2315_gpio_get,
2453 + .set = ar2315_gpio_set,
2456 +static struct ar231x_eth ar2315_eth_data = {
2457 + .reset_base = AR2315_RESET,
2458 + .reset_mac = AR2315_RESET_ENET0,
2459 + .reset_phy = AR2315_RESET_EPHY0,
2460 + .phy_base = AR2315_ENET0,
2461 + .config = &ar231x_board,
2464 +static struct resource ar2315_spiflash_res[] = {
2466 + .name = "flash_base",
2467 + .flags = IORESOURCE_MEM,
2468 + .start = KSEG1ADDR(AR2315_SPI_READ),
2469 + .end = KSEG1ADDR(AR2315_SPI_READ) + 0x1000000 - 1,
2472 + .name = "flash_regs",
2473 + .flags = IORESOURCE_MEM,
2474 + .start = 0x11300000,
2475 + .end = 0x11300012,
2479 +static struct platform_device ar2315_spiflash = {
2481 + .name = "spiflash",
2482 + .resource = ar2315_spiflash_res,
2483 + .num_resources = ARRAY_SIZE(ar2315_spiflash_res)
2486 +static struct platform_device ar2315_wdt = {
2488 + .name = "ar2315_wdt",
2491 +#define SPI_FLASH_CTL 0x00
2492 +#define SPI_FLASH_OPCODE 0x04
2493 +#define SPI_FLASH_DATA 0x08
2496 +spiflash_read_reg(int reg)
2498 + return ar231x_read_reg(KSEG1ADDR(AR2315_SPI) + reg);
2502 +spiflash_write_reg(int reg, u32 data)
2504 + ar231x_write_reg(KSEG1ADDR(AR2315_SPI) + reg, data);
2508 +spiflash_wait_status(void)
2513 + reg = spiflash_read_reg(SPI_FLASH_CTL);
2514 + } while (reg & SPI_CTL_BUSY);
2520 +spiflash_probe(void)
2524 + reg = spiflash_wait_status();
2525 + reg &= ~SPI_CTL_TX_RX_CNT_MASK;
2526 + reg |= (1 << 4) | 4 | SPI_CTL_START;
2528 + spiflash_write_reg(SPI_FLASH_OPCODE, 0xab);
2529 + spiflash_write_reg(SPI_FLASH_CTL, reg);
2531 + reg = spiflash_wait_status();
2532 + reg = spiflash_read_reg(SPI_FLASH_DATA);
2539 +#define STM_8MBIT_SIGNATURE 0x13
2540 +#define STM_16MBIT_SIGNATURE 0x14
2541 +#define STM_32MBIT_SIGNATURE 0x15
2542 +#define STM_64MBIT_SIGNATURE 0x16
2543 +#define STM_128MBIT_SIGNATURE 0x17
2546 +ar2315_flash_limit(void)
2548 + u32 flash_size = 0;
2550 + /* probe the flash chip size */
2551 + switch(spiflash_probe()) {
2552 + case STM_8MBIT_SIGNATURE:
2553 + flash_size = 0x00100000;
2555 + case STM_16MBIT_SIGNATURE:
2556 + flash_size = 0x00200000;
2558 + case STM_32MBIT_SIGNATURE:
2559 + flash_size = 0x00400000;
2561 + case STM_64MBIT_SIGNATURE:
2562 + flash_size = 0x00800000;
2564 + case STM_128MBIT_SIGNATURE:
2565 + flash_size = 0x01000000;
2569 + ar2315_spiflash_res[0].end = ar2315_spiflash_res[0].start +
2571 + return (u8 *) ar2315_spiflash_res[0].end + 1;
2574 +#ifdef CONFIG_LEDS_GPIO
2575 +static struct gpio_led ar2315_leds[6];
2576 +static struct gpio_led_platform_data ar2315_led_data = {
2577 + .leds = (void *) ar2315_leds,
2580 +static struct platform_device ar2315_gpio_leds = {
2581 + .name = "leds-gpio",
2584 + .platform_data = (void *) &ar2315_led_data,
2589 +ar2315_init_gpio(void)
2591 + static char led_names[6][6];
2594 + ar2315_led_data.num_leds = 0;
2595 + for(i = 1; i < 8; i++)
2597 + if((i == AR2315_RESET_GPIO) ||
2598 + (i == ar231x_board.config->resetConfigGpio))
2601 + if(i == ar231x_board.config->sysLedGpio)
2602 + strcpy(led_names[led], "wlan");
2604 + sprintf(led_names[led], "gpio%d", i);
2606 + ar2315_leds[led].name = led_names[led];
2607 + ar2315_leds[led].gpio = i;
2608 + ar2315_leds[led].active_low = 0;
2611 + ar2315_led_data.num_leds = led;
2612 + platform_device_register(&ar2315_gpio_leds);
2615 +static inline void ar2315_init_gpio(void)
2621 +ar2315_init_devices(void)
2626 + /* Find board configuration */
2627 + ar231x_find_config(ar2315_flash_limit());
2628 + ar2315_eth_data.macaddr = ar231x_board.config->enet0_mac;
2630 + ar2315_init_gpio();
2631 + platform_device_register(&ar2315_wdt);
2632 + platform_device_register(&ar2315_spiflash);
2633 + ar231x_add_ethernet(0, AR2315_ENET0, AR2315_IRQ_ENET0_INTRS,
2634 + &ar2315_eth_data);
2635 + ar231x_add_wmac(0, AR2315_WLAN0, AR2315_IRQ_WLAN0_INTRS);
2641 +ar2315_restart(char *command)
2643 + void (*mips_reset_vec)(void) = (void *) 0xbfc00000;
2645 + local_irq_disable();
2647 + /* try reset the system via reset control */
2648 + ar231x_write_reg(AR2315_COLD_RESET,AR2317_RESET_SYSTEM);
2650 + /* Cold reset does not work on the AR2315/6, use the GPIO reset bits a workaround.
2651 + * give it some time to attempt a gpio based hardware reset
2652 + * (atheros reference design workaround) */
2653 + gpio_direction_output(AR2315_RESET_GPIO, 0);
2656 + /* Some boards (e.g. Senao EOC-2610) don't implement the reset logic
2657 + * workaround. Attempt to jump to the mips reset location -
2658 + * the boot loader itself might be able to recover the system */
2664 + * This table is indexed by bits 5..4 of the CLOCKCTL1 register
2665 + * to determine the predevisor value.
2667 +static int __initdata CLOCKCTL1_PREDIVIDE_TABLE[4] = { 1, 2, 4, 5 };
2668 +static int __initdata PLLC_DIVIDE_TABLE[5] = { 2, 3, 4, 6, 3 };
2670 +static unsigned int __init
2671 +ar2315_sys_clk(unsigned int clockCtl)
2673 + unsigned int pllcCtrl,cpuDiv;
2674 + unsigned int pllcOut,refdiv,fdiv,divby2;
2675 + unsigned int clkDiv;
2677 + pllcCtrl = ar231x_read_reg(AR2315_PLLC_CTL);
2678 + refdiv = (pllcCtrl & PLLC_REF_DIV_M) >> PLLC_REF_DIV_S;
2679 + refdiv = CLOCKCTL1_PREDIVIDE_TABLE[refdiv];
2680 + fdiv = (pllcCtrl & PLLC_FDBACK_DIV_M) >> PLLC_FDBACK_DIV_S;
2681 + divby2 = (pllcCtrl & PLLC_ADD_FDBACK_DIV_M) >> PLLC_ADD_FDBACK_DIV_S;
2683 + pllcOut = (40000000/refdiv)*(2*divby2)*fdiv;
2686 + /* clkm input selected */
2687 + switch(clockCtl & CPUCLK_CLK_SEL_M) {
2690 + clkDiv = PLLC_DIVIDE_TABLE[(pllcCtrl & PLLC_CLKM_DIV_M) >> PLLC_CLKM_DIV_S];
2693 + clkDiv = PLLC_DIVIDE_TABLE[(pllcCtrl & PLLC_CLKC_DIV_M) >> PLLC_CLKC_DIV_S];
2696 + pllcOut = 40000000;
2700 + cpuDiv = (clockCtl & CPUCLK_CLK_DIV_M) >> CPUCLK_CLK_DIV_S;
2701 + cpuDiv = cpuDiv * 2 ?: 1;
2702 + return (pllcOut/(clkDiv * cpuDiv));
2705 +static inline unsigned int
2706 +ar2315_cpu_frequency(void)
2708 + return ar2315_sys_clk(ar231x_read_reg(AR2315_CPUCLK));
2711 +static inline unsigned int
2712 +ar2315_apb_frequency(void)
2714 + return ar2315_sys_clk(ar231x_read_reg(AR2315_AMBACLK));
2718 +ar2315_time_init(void)
2723 + mips_hpt_frequency = ar2315_cpu_frequency() / 2;
2727 +ar2315_prom_init(void)
2729 + u32 memsize, memcfg, devid;
2734 + memcfg = ar231x_read_reg(AR2315_MEM_CFG);
2735 + memsize = 1 + ((memcfg & SDRAM_DATA_WIDTH_M) >> SDRAM_DATA_WIDTH_S);
2736 + memsize <<= 1 + ((memcfg & SDRAM_COL_WIDTH_M) >> SDRAM_COL_WIDTH_S);
2737 + memsize <<= 1 + ((memcfg & SDRAM_ROW_WIDTH_M) >> SDRAM_ROW_WIDTH_S);
2739 + add_memory_region(0, memsize, BOOT_MEM_RAM);
2741 + /* Detect the hardware based on the device ID */
2742 + devid = ar231x_read_reg(AR2315_SREV) & AR2315_REV_CHIP;
2746 + ar231x_devtype = DEV_TYPE_AR2317;
2749 + ar231x_devtype = DEV_TYPE_AR2315;
2752 + ar231x_gpiodev = &ar2315_gpiodev;
2753 + ar231x_board.devid = devid;
2757 +ar2315_plat_setup(void)
2764 + /* Clear any lingering AHB errors */
2765 + config = read_c0_config();
2766 + write_c0_config(config & ~0x3);
2767 + ar231x_write_reg(AR2315_AHB_ERR0,AHB_ERROR_DET);
2768 + ar231x_read_reg(AR2315_AHB_ERR1);
2769 + ar231x_write_reg(AR2315_WDC, AR2315_WDC_IGNORE_EXPIRATION);
2771 + _machine_restart = ar2315_restart;
2772 + ar231x_serial_setup(KSEG1ADDR(AR2315_UART0), ar2315_apb_frequency());
2775 +++ b/arch/mips/ar231x/ar2315.h
2780 +#ifdef CONFIG_ATHEROS_AR2315
2782 +extern void ar2315_irq_init(void);
2783 +extern int ar2315_init_devices(void);
2784 +extern void ar2315_prom_init(void);
2785 +extern void ar2315_plat_setup(void);
2786 +extern void ar2315_time_init(void);
2790 +static inline void ar2315_irq_init(void)
2794 +static inline int ar2315_init_devices(void)
2799 +static inline void ar2315_prom_init(void)
2803 +static inline void ar2315_plat_setup(void)
2807 +static inline void ar2315_time_init(void)
2815 +++ b/arch/mips/ar231x/ar5312.h
2820 +#ifdef CONFIG_ATHEROS_AR5312
2822 +extern void ar5312_irq_init(void);
2823 +extern int ar5312_init_devices(void);
2824 +extern void ar5312_prom_init(void);
2825 +extern void ar5312_plat_setup(void);
2826 +extern void ar5312_time_init(void);
2827 +extern void ar5312_time_init(void);
2831 +static inline void ar5312_irq_init(void)
2835 +static inline int ar5312_init_devices(void)
2840 +static inline void ar5312_prom_init(void)
2844 +static inline void ar5312_plat_setup(void)
2848 +static inline void ar5312_time_init(void)
2856 +++ b/arch/mips/include/asm/mach-ar231x/ar231x.h
2861 +#define AR531X_MISC_IRQ_BASE 0x20
2862 +#define AR531X_GPIO_IRQ_BASE 0x30
2864 +/* Software's idea of interrupts handled by "CPU Interrupt Controller" */
2865 +#define AR531X_IRQ_NONE MIPS_CPU_IRQ_BASE+0
2866 +#define AR531X_IRQ_CPU_CLOCK MIPS_CPU_IRQ_BASE+7 /* C0_CAUSE: 0x8000 */
2868 +/* Miscellaneous interrupts, which share IP6 */
2869 +#define AR531X_MISC_IRQ_NONE AR531X_MISC_IRQ_BASE+0
2870 +#define AR531X_MISC_IRQ_TIMER AR531X_MISC_IRQ_BASE+1
2871 +#define AR531X_MISC_IRQ_AHB_PROC AR531X_MISC_IRQ_BASE+2
2872 +#define AR531X_MISC_IRQ_AHB_DMA AR531X_MISC_IRQ_BASE+3
2873 +#define AR531X_MISC_IRQ_GPIO AR531X_MISC_IRQ_BASE+4
2874 +#define AR531X_MISC_IRQ_UART0 AR531X_MISC_IRQ_BASE+5
2875 +#define AR531X_MISC_IRQ_UART0_DMA AR531X_MISC_IRQ_BASE+6
2876 +#define AR531X_MISC_IRQ_WATCHDOG AR531X_MISC_IRQ_BASE+7
2877 +#define AR531X_MISC_IRQ_LOCAL AR531X_MISC_IRQ_BASE+8
2878 +#define AR531X_MISC_IRQ_SPI AR531X_MISC_IRQ_BASE+9
2879 +#define AR531X_MISC_IRQ_COUNT 10
2881 +/* GPIO Interrupts [0..7], share AR531X_MISC_IRQ_GPIO */
2882 +#define AR531X_GPIO_IRQ_NONE AR531X_GPIO_IRQ_BASE+0
2883 +#define AR531X_GPIO_IRQ(n) AR531X_GPIO_IRQ_BASE+n
2884 +#define AR531X_GPIO_IRQ_COUNT 22
2887 +ar231x_read_reg(u32 reg)
2889 + return __raw_readl((u32 *) KSEG1ADDR(reg));
2893 +ar231x_write_reg(u32 reg, u32 val)
2895 + __raw_writel(val, (u32 *) KSEG1ADDR(reg));
2899 +ar231x_mask_reg(u32 reg, u32 mask, u32 val)
2903 + ret = ar231x_read_reg(reg);
2906 + ar231x_write_reg(reg, ret);
2913 +++ b/arch/mips/ar231x/devices.h
2915 +#ifndef __AR231X_DEVICES_H
2916 +#define __AR231X_DEVICES_H
2919 + /* handled by ar5312.c */
2924 + /* handled by ar2315.c */
2932 +extern int ar231x_devtype;
2933 +extern struct ar231x_board_config ar231x_board;
2934 +extern asmlinkage void (*ar231x_irq_dispatch)(void);
2936 +extern int ar231x_find_config(u8 *flash_limit);
2937 +extern void ar231x_serial_setup(u32 mapbase, unsigned int uartclk);
2938 +extern int ar231x_add_wmac(int nr, u32 base, int irq);
2939 +extern int ar231x_add_ethernet(int nr, u32 base, int irq, void *pdata);
2941 +static inline bool is_2315(void)
2943 + return (current_cpu_data.cputype == CPU_4KEC);
2946 +static inline bool is_5312(void)
2948 + return !is_2315();
2953 +++ b/arch/mips/ar231x/devices.c
2955 +#include <linux/kernel.h>
2956 +#include <linux/init.h>
2957 +#include <linux/serial.h>
2958 +#include <linux/serial_core.h>
2959 +#include <linux/serial_8250.h>
2960 +#include <linux/platform_device.h>
2961 +#include <ar231x_platform.h>
2962 +#include <ar231x.h>
2963 +#include "devices.h"
2964 +#include "ar5312.h"
2965 +#include "ar2315.h"
2967 +struct ar231x_board_config ar231x_board;
2968 +int ar231x_devtype = DEV_TYPE_UNKNOWN;
2969 +const struct ar231x_gpiodev *ar231x_gpiodev;
2970 +EXPORT_SYMBOL(ar231x_gpiodev);
2972 +static struct resource ar231x_eth0_res[] = {
2974 + .name = "eth0_membase",
2975 + .flags = IORESOURCE_MEM,
2978 + .name = "eth0_irq",
2979 + .flags = IORESOURCE_IRQ,
2983 +static struct resource ar231x_eth1_res[] = {
2985 + .name = "eth1_membase",
2986 + .flags = IORESOURCE_MEM,
2989 + .name = "eth1_irq",
2990 + .flags = IORESOURCE_IRQ,
2994 +static struct platform_device ar231x_eth[] = {
2997 + .name = "ar231x-eth",
2998 + .resource = ar231x_eth0_res,
2999 + .num_resources = ARRAY_SIZE(ar231x_eth0_res)
3003 + .name = "ar231x-eth",
3004 + .resource = ar231x_eth1_res,
3005 + .num_resources = ARRAY_SIZE(ar231x_eth1_res)
3009 +static struct resource ar231x_wmac0_res[] = {
3011 + .name = "wmac0_membase",
3012 + .flags = IORESOURCE_MEM,
3015 + .name = "wmac0_irq",
3016 + .flags = IORESOURCE_IRQ,
3020 +static struct resource ar231x_wmac1_res[] = {
3022 + .name = "wmac1_membase",
3023 + .flags = IORESOURCE_MEM,
3026 + .name = "wmac1_irq",
3027 + .flags = IORESOURCE_IRQ,
3032 +static struct platform_device ar231x_wmac[] = {
3035 + .name = "ar231x-wmac",
3036 + .resource = ar231x_wmac0_res,
3037 + .num_resources = ARRAY_SIZE(ar231x_wmac0_res),
3038 + .dev.platform_data = &ar231x_board,
3042 + .name = "ar231x-wmac",
3043 + .resource = ar231x_wmac1_res,
3044 + .num_resources = ARRAY_SIZE(ar231x_wmac1_res),
3045 + .dev.platform_data = &ar231x_board,
3049 +static const char *devtype_strings[] = {
3050 + [DEV_TYPE_AR5312] = "Atheros AR5312",
3051 + [DEV_TYPE_AR2312] = "Atheros AR2312",
3052 + [DEV_TYPE_AR2313] = "Atheros AR2313",
3053 + [DEV_TYPE_AR2315] = "Atheros AR2315",
3054 + [DEV_TYPE_AR2316] = "Atheros AR2316",
3055 + [DEV_TYPE_AR2317] = "Atheros AR2317",
3056 + [DEV_TYPE_UNKNOWN] = "Atheros (unknown)",
3059 +const char *get_system_type(void)
3061 + if ((ar231x_devtype >= ARRAY_SIZE(devtype_strings)) ||
3062 + !devtype_strings[ar231x_devtype])
3063 + return devtype_strings[DEV_TYPE_UNKNOWN];
3064 + return devtype_strings[ar231x_devtype];
3069 +ar231x_add_ethernet(int nr, u32 base, int irq, void *pdata)
3071 + struct resource *res;
3073 + ar231x_eth[nr].dev.platform_data = pdata;
3074 + res = &ar231x_eth[nr].resource[0];
3075 + res->start = base;
3076 + res->end = base + 0x2000 - 1;
3080 + return platform_device_register(&ar231x_eth[nr]);
3084 +ar231x_serial_setup(u32 mapbase, unsigned int uartclk)
3086 + struct uart_port s;
3088 + memset(&s, 0, sizeof(s));
3090 + s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
3091 + s.iotype = UPIO_MEM;
3092 + s.irq = AR531X_MISC_IRQ_UART0;
3094 + s.mapbase = mapbase;
3095 + s.uartclk = uartclk;
3096 + s.membase = (void __iomem *)s.mapbase;
3098 + early_serial_setup(&s);
3102 +ar231x_add_wmac(int nr, u32 base, int irq)
3104 + struct resource *res;
3106 + ar231x_wmac[nr].dev.platform_data = &ar231x_board;
3107 + res = &ar231x_wmac[nr].resource[0];
3108 + res->start = base;
3109 + res->end = base + 0x10000 - 1;
3113 + return platform_device_register(&ar231x_wmac[nr]);
3116 +static int __init ar231x_register_devices(void)
3118 + static struct resource res = {
3119 + .start = 0xFFFFFFFF,
3122 + platform_device_register_simple("GPIODEV", 0, &res, 1);
3123 + ar5312_init_devices();
3124 + ar2315_init_devices();
3129 +device_initcall(ar231x_register_devices);