1 Index: linux-2.6.33/arch/mips/Kconfig
2 ===================================================================
3 --- linux-2.6.33.orig/arch/mips/Kconfig 2010-03-03 12:20:01.790293217 +0100
4 +++ linux-2.6.33/arch/mips/Kconfig 2010-03-03 12:20:05.554288074 +0100
7 Support for BCM63XX based boards
10 + bool "Atheros 231x/531x SoC support"
13 + select DMA_NONCOHERENT
15 + select SYS_HAS_CPU_MIPS32_R1
16 + select SYS_SUPPORTS_BIG_ENDIAN
17 + select SYS_SUPPORTS_32BIT_KERNEL
20 + Support for AR231x and AR531x based boards
29 +source "arch/mips/ar231x/Kconfig"
30 source "arch/mips/alchemy/Kconfig"
31 source "arch/mips/bcm63xx/Kconfig"
32 source "arch/mips/jazz/Kconfig"
33 Index: linux-2.6.33/arch/mips/Makefile
34 ===================================================================
35 --- linux-2.6.33.orig/arch/mips/Makefile 2010-03-03 12:20:01.742287339 +0100
36 +++ linux-2.6.33/arch/mips/Makefile 2010-03-03 12:20:05.554288074 +0100
41 +# Atheros AR5312/AR2312 WiSoC
43 +core-$(CONFIG_ATHEROS_AR231X) += arch/mips/ar231x/
44 +cflags-$(CONFIG_ATHEROS_AR231X) += -I$(srctree)/arch/mips/include/asm/mach-ar231x
45 +load-$(CONFIG_ATHEROS_AR231X) += 0xffffffff80041000
50 core-$(CONFIG_MIPS_COBALT) += arch/mips/cobalt/
51 Index: linux-2.6.33/arch/mips/ar231x/Kconfig
52 ===================================================================
53 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
54 +++ linux-2.6.33/arch/mips/ar231x/Kconfig 2010-03-03 12:20:05.554288074 +0100
56 +config ATHEROS_AR5312
57 + bool "Atheros 5312/2312+ support"
58 + depends on ATHEROS_AR231X
61 +config ATHEROS_AR2315
62 + bool "Atheros 2315+ support"
63 + depends on ATHEROS_AR231X
64 + select DMA_NONCOHERENT
68 + select SYS_HAS_CPU_MIPS32_R1
69 + select SYS_SUPPORTS_32BIT_KERNEL
70 + select SYS_SUPPORTS_BIG_ENDIAN
73 Index: linux-2.6.33/arch/mips/ar231x/Makefile
74 ===================================================================
75 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
76 +++ linux-2.6.33/arch/mips/ar231x/Makefile 2010-03-03 12:20:05.554288074 +0100
79 +# This file is subject to the terms and conditions of the GNU General Public
80 +# License. See the file "COPYING" in the main directory of this archive
83 +# Copyright (C) 2006 FON Technology, SL.
84 +# Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
85 +# Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
88 +obj-y += board.o prom.o devices.o
89 +obj-$(CONFIG_ATHEROS_AR5312) += ar5312.o
90 +obj-$(CONFIG_ATHEROS_AR2315) += ar2315.o
91 Index: linux-2.6.33/arch/mips/ar231x/board.c
92 ===================================================================
93 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
94 +++ linux-2.6.33/arch/mips/ar231x/board.c 2010-03-03 12:20:22.306286892 +0100
97 + * This file is subject to the terms and conditions of the GNU General Public
98 + * License. See the file "COPYING" in the main directory of this archive
101 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
102 + * Copyright (C) 2006 FON Technology, SL.
103 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
104 + * Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
107 +#include <generated/autoconf.h>
108 +#include <linux/init.h>
109 +#include <linux/module.h>
110 +#include <linux/types.h>
111 +#include <linux/string.h>
112 +#include <linux/platform_device.h>
113 +#include <linux/kernel.h>
114 +#include <linux/random.h>
115 +#include <linux/etherdevice.h>
116 +#include <asm/irq_cpu.h>
117 +#include <asm/reboot.h>
120 +#include <ar231x_platform.h>
121 +#include "devices.h"
125 +void (*ar231x_irq_dispatch)(void);
128 +check_radio_magic(u8 *addr)
130 + addr += 0x7a; /* offset for flash magic */
131 + if ((addr[0] == 0x5a) && (addr[1] == 0xa5)) {
138 +check_board_data(u8 *flash_limit, u8 *addr, bool broken)
140 + /* config magic found */
141 + if (*((u32 *)addr) == AR531X_BD_MAGIC)
147 + if (check_radio_magic(addr + 0xf8))
148 + ar231x_board.radio = addr + 0xf8;
149 + if ((addr < flash_limit + 0x10000) &&
150 + check_radio_magic(addr + 0x10000))
151 + ar231x_board.radio = addr + 0x10000;
153 + if (ar231x_board.radio) {
154 + /* broken board data detected, use radio data to find the offset,
155 + * user will fix this */
162 +find_board_config(u8 *flash_limit, bool broken)
167 + for (addr = flash_limit - 0x1000;
168 + addr >= flash_limit - 0x30000;
171 + if (check_board_data(flash_limit, addr, broken)) {
184 +find_radio_config(u8 *flash_limit, u8 *board_config)
190 + * Now find the start of Radio Configuration data, using heuristics:
191 + * Search forward from Board Configuration data by 0x1000 bytes
192 + * at a time until we find non-0xffffffff.
195 + for (radio_config = board_config + 0x1000;
196 + (radio_config < flash_limit);
197 + radio_config += 0x1000) {
198 + if ((*(u32 *)radio_config != 0xffffffff) &&
199 + check_radio_magic(radio_config)) {
205 + /* AR2316 relocates radio config to new location */
207 + for (radio_config = board_config + 0xf8;
208 + (radio_config < flash_limit - 0x1000 + 0xf8);
209 + radio_config += 0x1000) {
210 + if ((*(u32 *)radio_config != 0xffffffff) &&
211 + check_radio_magic(radio_config)) {
219 + printk("Could not find Radio Configuration data\n");
223 + return (u8 *) radio_config;
227 +ar231x_find_config(u8 *flash_limit)
229 + struct ar231x_boarddata *config;
230 + unsigned int rcfg_size;
231 + int broken_boarddata = 0;
237 + ar231x_board.config = NULL;
238 + ar231x_board.radio = NULL;
239 + /* Copy the board and radio data to RAM, because accessing the mapped
240 + * memory of the flash directly after booting is not safe */
242 + /* Try to find valid board and radio data */
243 + bcfg = find_board_config(flash_limit, false);
245 + /* If that fails, try to at least find valid radio data */
247 + bcfg = find_board_config(flash_limit, true);
248 + broken_boarddata = 1;
252 + printk(KERN_WARNING "WARNING: No board configuration data found!\n");
256 + board_data = kzalloc(BOARD_CONFIG_BUFSZ, GFP_KERNEL);
257 + ar231x_board.config = (struct ar231x_boarddata *) board_data;
258 + memcpy(board_data, bcfg, 0x100);
259 + if (broken_boarddata) {
260 + printk(KERN_WARNING "WARNING: broken board data detected\n");
261 + config = ar231x_board.config;
262 + if (!memcmp(config->enet0_mac, "\x00\x00\x00\x00\x00\x00", 6)) {
263 + printk(KERN_INFO "Fixing up empty mac addresses\n");
264 + config->resetConfigGpio = 0xffff;
265 + config->sysLedGpio = 0xffff;
266 + random_ether_addr(config->wlan0_mac);
267 + config->wlan0_mac[0] &= ~0x06;
268 + random_ether_addr(config->enet0_mac);
269 + random_ether_addr(config->enet1_mac);
274 + /* Radio config starts 0x100 bytes after board config, regardless
275 + * of what the physical layout on the flash chip looks like */
277 + if (ar231x_board.radio)
278 + rcfg = (u8 *) ar231x_board.radio;
280 + rcfg = find_radio_config(flash_limit, bcfg);
285 + radio_data = board_data + 0x100 + ((rcfg - bcfg) & 0xfff);
286 + ar231x_board.radio = radio_data;
287 + offset = radio_data - board_data;
288 + printk(KERN_INFO "Radio config found at offset 0x%x(0x%x)\n", rcfg - bcfg, offset);
289 + rcfg_size = BOARD_CONFIG_BUFSZ - offset;
290 + memcpy(radio_data, rcfg, rcfg_size);
298 + local_irq_disable();
303 +plat_mem_setup(void)
305 + _machine_halt = ar231x_halt;
306 + pm_power_off = ar231x_halt;
308 + ar5312_plat_setup();
309 + ar2315_plat_setup();
311 + /* Disable data watchpoints */
312 + write_c0_watchlo0(0);
317 +plat_irq_dispatch(void)
319 + ar231x_irq_dispatch();
323 +plat_time_init(void)
325 + ar5312_time_init();
326 + ar2315_time_init();
329 +unsigned int __cpuinit
330 +get_c0_compare_int(void)
332 + return CP0_LEGACY_COMPARE_IRQ;
338 + clear_c0_status(ST0_IM);
339 + mips_cpu_irq_init();
341 + /* Initialize interrupt controllers */
347 Index: linux-2.6.33/arch/mips/ar231x/prom.c
348 ===================================================================
349 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
350 +++ linux-2.6.33/arch/mips/ar231x/prom.c 2010-03-03 12:20:05.554288074 +0100
353 + * This file is subject to the terms and conditions of the GNU General Public
354 + * License. See the file "COPYING" in the main directory of this archive
355 + * for more details.
357 + * Copyright MontaVista Software Inc
358 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
359 + * Copyright (C) 2006 FON Technology, SL.
360 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
361 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
365 + * Prom setup file for ar531x
368 +#include <linux/init.h>
369 +#include <generated/autoconf.h>
370 +#include <linux/kernel.h>
371 +#include <linux/string.h>
372 +#include <linux/mm.h>
373 +#include <linux/bootmem.h>
375 +#include <asm/bootinfo.h>
376 +#include <asm/addrspace.h>
380 +void __init prom_init(void)
382 + ar5312_prom_init();
383 + ar2315_prom_init();
386 +void __init prom_free_prom_memory(void)
389 Index: linux-2.6.33/arch/mips/include/asm/mach-ar231x/ar231x_platform.h
390 ===================================================================
391 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
392 +++ linux-2.6.33/arch/mips/include/asm/mach-ar231x/ar231x_platform.h 2010-03-03 12:20:05.554288074 +0100
394 +#ifndef __AR531X_PLATFORM_H
395 +#define __AR531X_PLATFORM_H
398 + * This is board-specific data that is stored in a "fixed" location in flash.
399 + * It is shared across operating systems, so it should not be changed lightly.
400 + * The main reason we need it is in order to extract the ethernet MAC
403 +struct ar231x_boarddata {
404 + u32 magic; /* board data is valid */
405 +#define AR531X_BD_MAGIC 0x35333131 /* "5311", for all 531x platforms */
406 + u16 cksum; /* checksum (starting with BD_REV 2) */
407 + u16 rev; /* revision of this struct */
409 + char boardName[64]; /* Name of board */
410 + u16 major; /* Board major number */
411 + u16 minor; /* Board minor number */
412 + u32 flags; /* Board configuration */
413 +#define BD_ENET0 0x00000001 /* ENET0 is stuffed */
414 +#define BD_ENET1 0x00000002 /* ENET1 is stuffed */
415 +#define BD_UART1 0x00000004 /* UART1 is stuffed */
416 +#define BD_UART0 0x00000008 /* UART0 is stuffed (dma) */
417 +#define BD_RSTFACTORY 0x00000010 /* Reset factory defaults stuffed */
418 +#define BD_SYSLED 0x00000020 /* System LED stuffed */
419 +#define BD_EXTUARTCLK 0x00000040 /* External UART clock */
420 +#define BD_CPUFREQ 0x00000080 /* cpu freq is valid in nvram */
421 +#define BD_SYSFREQ 0x00000100 /* sys freq is set in nvram */
422 +#define BD_WLAN0 0x00000200 /* Enable WLAN0 */
423 +#define BD_MEMCAP 0x00000400 /* CAP SDRAM @ memCap for testing */
424 +#define BD_DISWATCHDOG 0x00000800 /* disable system watchdog */
425 +#define BD_WLAN1 0x00001000 /* Enable WLAN1 (ar5212) */
426 +#define BD_ISCASPER 0x00002000 /* FLAG for AR2312 */
427 +#define BD_WLAN0_2G_EN 0x00004000 /* FLAG for radio0_2G */
428 +#define BD_WLAN0_5G_EN 0x00008000 /* FLAG for radio0_2G */
429 +#define BD_WLAN1_2G_EN 0x00020000 /* FLAG for radio0_2G */
430 +#define BD_WLAN1_5G_EN 0x00040000 /* FLAG for radio0_2G */
431 + u16 resetConfigGpio; /* Reset factory GPIO pin */
432 + u16 sysLedGpio; /* System LED GPIO pin */
434 + u32 cpuFreq; /* CPU core frequency in Hz */
435 + u32 sysFreq; /* System frequency in Hz */
436 + u32 cntFreq; /* Calculated C0_COUNT frequency */
442 + u16 pciId; /* Pseudo PCIID for common code */
443 + u16 memCap; /* cap bank1 in MB */
446 + u8 wlan1_mac[6]; /* (ar5212) */
449 +#define BOARD_CONFIG_BUFSZ 0x1000
452 + * Platform device information for the Wireless MAC
454 +struct ar231x_board_config {
457 + /* board config data */
458 + struct ar231x_boarddata *config;
460 + /* radio calibration data */
465 + * Platform device information for the Ethernet MAC
472 + struct ar231x_board_config *config;
476 +#endif /* __AR531X_PLATFORM_H */
477 Index: linux-2.6.33/arch/mips/include/asm/mach-ar231x/cpu-feature-overrides.h
478 ===================================================================
479 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
480 +++ linux-2.6.33/arch/mips/include/asm/mach-ar231x/cpu-feature-overrides.h 2010-03-03 12:20:05.554288074 +0100
483 + * Atheros SoC specific CPU feature overrides
485 + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
487 + * This file was derived from: include/asm-mips/cpu-features.h
488 + * Copyright (C) 2003, 2004 Ralf Baechle
489 + * Copyright (C) 2004 Maciej W. Rozycki
491 + * This program is free software; you can redistribute it and/or modify it
492 + * under the terms of the GNU General Public License version 2 as published
493 + * by the Free Software Foundation.
496 +#ifndef __ASM_MACH_ATHEROS_CPU_FEATURE_OVERRIDES_H
497 +#define __ASM_MACH_ATHEROS_CPU_FEATURE_OVERRIDES_H
500 + * The ATHEROS SoCs have MIPS 4Kc/4KEc core.
502 +#define cpu_has_tlb 1
503 +#define cpu_has_4kex 1
504 +#define cpu_has_3k_cache 0
505 +#define cpu_has_4k_cache 1
506 +#define cpu_has_tx39_cache 0
507 +#define cpu_has_sb1_cache 0
508 +#define cpu_has_fpu 0
509 +#define cpu_has_32fpr 0
510 +#define cpu_has_counter 1
511 +/* #define cpu_has_watch ? */
512 +/* #define cpu_has_divec ? */
513 +/* #define cpu_has_vce ? */
514 +/* #define cpu_has_cache_cdex_p ? */
515 +/* #define cpu_has_cache_cdex_s ? */
516 +/* #define cpu_has_prefetch ? */
517 +/* #define cpu_has_mcheck ? */
518 +#define cpu_has_ejtag 1
520 +#if !defined(CONFIG_ATHEROS_AR5312)
521 +# define cpu_has_llsc 1
524 + * The MIPS 4Kc V0.9 core in the AR5312/AR2312 have problems with the
525 + * ll/sc instructions.
527 +# define cpu_has_llsc 0
530 +#define cpu_has_mips16 0
531 +#define cpu_has_mdmx 0
532 +#define cpu_has_mips3d 0
533 +#define cpu_has_smartmips 0
535 +/* #define cpu_has_vtag_icache ? */
536 +/* #define cpu_has_dc_aliases ? */
537 +/* #define cpu_has_ic_fills_f_dc ? */
538 +/* #define cpu_has_pindexed_dcache ? */
540 +/* #define cpu_icache_snoops_remote_store ? */
542 +#define cpu_has_mips32r1 1
544 +#if !defined(CONFIG_ATHEROS_AR5312)
545 +# define cpu_has_mips32r2 1
548 +#define cpu_has_mips64r1 0
549 +#define cpu_has_mips64r2 0
551 +#define cpu_has_dsp 0
552 +#define cpu_has_mipsmt 0
554 +/* #define cpu_has_nofpuex ? */
555 +#define cpu_has_64bits 0
556 +#define cpu_has_64bit_zero_reg 0
557 +#define cpu_has_64bit_gp_regs 0
558 +#define cpu_has_64bit_addresses 0
560 +/* #define cpu_has_inclusive_pcaches ? */
562 +/* #define cpu_dcache_line_size() ? */
563 +/* #define cpu_icache_line_size() ? */
565 +#endif /* __ASM_MACH_ATHEROS_CPU_FEATURE_OVERRIDES_H */
566 Index: linux-2.6.33/arch/mips/include/asm/mach-ar231x/dma-coherence.h
567 ===================================================================
568 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
569 +++ linux-2.6.33/arch/mips/include/asm/mach-ar231x/dma-coherence.h 2010-03-03 12:20:05.554288074 +0100
572 + * This file is subject to the terms and conditions of the GNU General Public
573 + * License. See the file "COPYING" in the main directory of this archive
574 + * for more details.
576 + * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
577 + * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org>
580 +#ifndef __ASM_MACH_GENERIC_DMA_COHERENCE_H
581 +#define __ASM_MACH_GENERIC_DMA_COHERENCE_H
583 +#define PCI_DMA_OFFSET 0x20000000
587 +static dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size)
589 + return virt_to_phys(addr) + (dev != NULL ? PCI_DMA_OFFSET : 0);
592 +static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
594 + return page_to_phys(page) + (dev != NULL ? PCI_DMA_OFFSET : 0);
597 +static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
598 + dma_addr_t dma_addr)
600 + return (dma_addr > PCI_DMA_OFFSET ? dma_addr - PCI_DMA_OFFSET : dma_addr);
603 +static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
604 + size_t size, enum dma_data_direction direction)
608 +static inline int plat_dma_supported(struct device *dev, u64 mask)
613 +static inline void plat_extra_sync_for_device(struct device *dev)
618 +static inline int plat_dma_mapping_error(struct device *dev,
619 + dma_addr_t dma_addr)
624 +static inline int plat_device_is_coherent(struct device *dev)
626 +#ifdef CONFIG_DMA_COHERENT
629 +#ifdef CONFIG_DMA_NONCOHERENT
634 +#endif /* __ASM_MACH_GENERIC_DMA_COHERENCE_H */
635 Index: linux-2.6.33/arch/mips/include/asm/mach-ar231x/gpio.h
636 ===================================================================
637 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
638 +++ linux-2.6.33/arch/mips/include/asm/mach-ar231x/gpio.h 2010-03-03 12:20:05.554288074 +0100
640 +#ifndef _ATHEROS_GPIO_H_
641 +#define _ATHEROS_GPIO_H_
645 +struct ar231x_gpiodev {
647 + u32 (*get_output)(void);
648 + u32 (*set_output)(u32 mask, u32 val);
650 + u32 (*set)(u32 mask, u32 val);
653 +extern const struct ar231x_gpiodev *ar231x_gpiodev;
656 + * Wrappers for the generic GPIO layer
659 +static inline int gpio_direction_input(unsigned gpio) {
660 + u32 mask = 1 << gpio;
662 + if (!(ar231x_gpiodev->valid_mask & mask))
665 + ar231x_gpiodev->set_output(mask, 0);
669 +static inline void gpio_set_value(unsigned gpio, int value) {
670 + u32 mask = 1 << gpio;
672 + if (!(ar231x_gpiodev->valid_mask & mask))
675 + ar231x_gpiodev->set(mask, (!!value) * mask);
678 +static inline int gpio_direction_output(unsigned gpio, int value) {
679 + u32 mask = 1 << gpio;
681 + if (!(ar231x_gpiodev->valid_mask & mask))
684 + ar231x_gpiodev->set_output(mask, mask);
685 + ar231x_gpiodev->set(mask, (!!value) * mask);
689 +/* Reads the gpio pin. Unchecked function */
690 +static inline int gpio_get_value(unsigned gpio) {
691 + u32 mask = 1 << gpio;
693 + if (!(ar231x_gpiodev->valid_mask & mask))
696 + return !!(ar231x_gpiodev->get() & mask);
699 +static inline int gpio_request(unsigned gpio, const char *label) {
703 +static inline void gpio_free(unsigned gpio) {
706 +/* Returns IRQ to attach for gpio. Unchecked function */
707 +static inline int gpio_to_irq(unsigned gpio) {
708 + return AR531X_GPIO_IRQ(gpio);
711 +/* Returns gpio for IRQ attached. Unchecked function */
712 +static inline int irq_to_gpio(unsigned irq) {
713 + return (irq - (AR531X_GPIO_IRQ(0)));
716 +#include <asm-generic/gpio.h> /* cansleep wrappers */
719 Index: linux-2.6.33/arch/mips/include/asm/mach-ar231x/reset.h
720 ===================================================================
721 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
722 +++ linux-2.6.33/arch/mips/include/asm/mach-ar231x/reset.h 2010-03-03 12:20:05.554288074 +0100
724 +#ifndef __AR531X_RESET_H
725 +#define __AR531X_RESET_H
727 +void ar531x_disable_reset_button(void);
729 +#endif /* __AR531X_RESET_H */
730 Index: linux-2.6.33/arch/mips/include/asm/mach-ar231x/war.h
731 ===================================================================
732 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
733 +++ linux-2.6.33/arch/mips/include/asm/mach-ar231x/war.h 2010-03-03 12:20:05.558287696 +0100
736 + * This file is subject to the terms and conditions of the GNU General Public
737 + * License. See the file "COPYING" in the main directory of this archive
738 + * for more details.
740 + * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
742 +#ifndef __ASM_MIPS_MACH_ATHEROS_WAR_H
743 +#define __ASM_MIPS_MACH_ATHEROS_WAR_H
745 +#define R4600_V1_INDEX_ICACHEOP_WAR 0
746 +#define R4600_V1_HIT_CACHEOP_WAR 0
747 +#define R4600_V2_HIT_CACHEOP_WAR 0
748 +#define R5432_CP0_INTERRUPT_WAR 0
749 +#define BCM1250_M3_WAR 0
750 +#define SIBYTE_1956_WAR 0
751 +#define MIPS4K_ICACHE_REFILL_WAR 0
752 +#define MIPS_CACHE_SYNC_WAR 0
753 +#define TX49XX_ICACHE_INDEX_INV_WAR 0
754 +#define RM9000_CDEX_SMP_WAR 0
755 +#define ICACHE_REFILLS_WORKAROUND_WAR 0
756 +#define R10000_LLSC_WAR 0
757 +#define MIPS34K_MISSED_ITLB_WAR 0
759 +#endif /* __ASM_MIPS_MACH_ATHEROS_WAR_H */
760 Index: linux-2.6.33/arch/mips/include/asm/mach-ar231x/ar2315_regs.h
761 ===================================================================
762 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
763 +++ linux-2.6.33/arch/mips/include/asm/mach-ar231x/ar2315_regs.h 2010-03-03 12:20:05.558287696 +0100
766 + * Register definitions for AR2315+
768 + * This file is subject to the terms and conditions of the GNU General Public
769 + * License. See the file "COPYING" in the main directory of this archive
770 + * for more details.
772 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
773 + * Copyright (C) 2006 FON Technology, SL.
774 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
775 + * Copyright (C) 2006-2008 Felix Fietkau <nbd@openwrt.org>
778 +#ifndef __AR2315_REG_H
779 +#define __AR2315_REG_H
784 +#define AR2315_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
785 +#define AR2315_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
786 +#define AR2315_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
787 +#define AR2315_IRQ_LCBUS_PCI MIPS_CPU_IRQ_BASE+5 /* C0_CAUSE: 0x2000 */
788 +#define AR2315_IRQ_WLAN0_POLL MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
793 +#define AR2315_SPI_READ 0x08000000 /* SPI FLASH */
794 +#define AR2315_WLAN0 0xB0000000 /* Wireless MMR */
795 +#define AR2315_PCI 0xB0100000 /* PCI MMR */
796 +#define AR2315_SDRAMCTL 0xB0300000 /* SDRAM MMR */
797 +#define AR2315_LOCAL 0xB0400000 /* LOCAL BUS MMR */
798 +#define AR2315_ENET0 0xB0500000 /* ETHERNET MMR */
799 +#define AR2315_DSLBASE 0xB1000000 /* RESET CONTROL MMR */
800 +#define AR2315_UART0 0xB1100003 /* UART MMR */
801 +#define AR2315_SPI 0xB1300000 /* SPI FLASH MMR */
802 +#define AR2315_PCIEXT 0x80000000 /* pci external */
807 +#define AR2315_COLD_RESET (AR2315_DSLBASE + 0x0000)
809 +#define AR2315_RESET_COLD_AHB 0x00000001
810 +#define AR2315_RESET_COLD_APB 0x00000002
811 +#define AR2315_RESET_COLD_CPU 0x00000004
812 +#define AR2315_RESET_COLD_CPUWARM 0x00000008
813 +#define AR2315_RESET_SYSTEM (RESET_COLD_CPU | RESET_COLD_APB | RESET_COLD_AHB) /* full system */
814 +#define AR2317_RESET_SYSTEM 0x00000010
817 +#define AR2315_RESET (AR2315_DSLBASE + 0x0004)
819 +#define AR2315_RESET_WARM_WLAN0_MAC 0x00000001 /* warm reset WLAN0 MAC */
820 +#define AR2315_RESET_WARM_WLAN0_BB 0x00000002 /* warm reset WLAN0 BaseBand */
821 +#define AR2315_RESET_MPEGTS_RSVD 0x00000004 /* warm reset MPEG-TS */
822 +#define AR2315_RESET_PCIDMA 0x00000008 /* warm reset PCI ahb/dma */
823 +#define AR2315_RESET_MEMCTL 0x00000010 /* warm reset memory controller */
824 +#define AR2315_RESET_LOCAL 0x00000020 /* warm reset local bus */
825 +#define AR2315_RESET_I2C_RSVD 0x00000040 /* warm reset I2C bus */
826 +#define AR2315_RESET_SPI 0x00000080 /* warm reset SPI interface */
827 +#define AR2315_RESET_UART0 0x00000100 /* warm reset UART0 */
828 +#define AR2315_RESET_IR_RSVD 0x00000200 /* warm reset IR interface */
829 +#define AR2315_RESET_EPHY0 0x00000400 /* cold reset ENET0 phy */
830 +#define AR2315_RESET_ENET0 0x00000800 /* cold reset ENET0 mac */
833 + * AHB master arbitration control
835 +#define AR2315_AHB_ARB_CTL (AR2315_DSLBASE + 0x0008)
837 +#define AR2315_ARB_CPU 0x00000001 /* CPU, default */
838 +#define AR2315_ARB_WLAN 0x00000002 /* WLAN */
839 +#define AR2315_ARB_MPEGTS_RSVD 0x00000004 /* MPEG-TS */
840 +#define AR2315_ARB_LOCAL 0x00000008 /* LOCAL */
841 +#define AR2315_ARB_PCI 0x00000010 /* PCI */
842 +#define AR2315_ARB_ETHERNET 0x00000020 /* Ethernet */
843 +#define AR2315_ARB_RETRY 0x00000100 /* retry policy, debug only */
848 +#define AR2315_ENDIAN_CTL (AR2315_DSLBASE + 0x000c)
850 +#define AR2315_CONFIG_AHB 0x00000001 /* EC - AHB bridge endianess */
851 +#define AR2315_CONFIG_WLAN 0x00000002 /* WLAN byteswap */
852 +#define AR2315_CONFIG_MPEGTS_RSVD 0x00000004 /* MPEG-TS byteswap */
853 +#define AR2315_CONFIG_PCI 0x00000008 /* PCI byteswap */
854 +#define AR2315_CONFIG_MEMCTL 0x00000010 /* Memory controller endianess */
855 +#define AR2315_CONFIG_LOCAL 0x00000020 /* Local bus byteswap */
856 +#define AR2315_CONFIG_ETHERNET 0x00000040 /* Ethernet byteswap */
858 +#define AR2315_CONFIG_MERGE 0x00000200 /* CPU write buffer merge */
859 +#define AR2315_CONFIG_CPU 0x00000400 /* CPU big endian */
860 +#define AR2315_CONFIG_PCIAHB 0x00000800
861 +#define AR2315_CONFIG_PCIAHB_BRIDGE 0x00001000
862 +#define AR2315_CONFIG_SPI 0x00008000 /* SPI byteswap */
863 +#define AR2315_CONFIG_CPU_DRAM 0x00010000
864 +#define AR2315_CONFIG_CPU_PCI 0x00020000
865 +#define AR2315_CONFIG_CPU_MMR 0x00040000
866 +#define AR2315_CONFIG_BIG 0x00000400
872 +#define AR2315_NMI_CTL (AR2315_DSLBASE + 0x0010)
874 +#define AR2315_NMI_EN 1
877 + * Revision Register - Initial value is 0x3010 (WMAC 3.0, AR531X 1.0).
879 +#define AR2315_SREV (AR2315_DSLBASE + 0x0014)
881 +#define AR2315_REV_MAJ 0x00f0
882 +#define AR2315_REV_MAJ_S 4
883 +#define AR2315_REV_MIN 0x000f
884 +#define AR2315_REV_MIN_S 0
885 +#define AR2315_REV_CHIP (AR2315_REV_MAJ|AR2315_REV_MIN)
890 +#define AR2315_IF_CTL (AR2315_DSLBASE + 0x0018)
892 +#define AR2315_IF_MASK 0x00000007
893 +#define AR2315_IF_DISABLED 0
894 +#define AR2315_IF_PCI 1
895 +#define AR2315_IF_TS_LOCAL 2
896 +#define AR2315_IF_ALL 3 /* only for emulation with separate pins */
897 +#define AR2315_IF_LOCAL_HOST 0x00000008
898 +#define AR2315_IF_PCI_HOST 0x00000010
899 +#define AR2315_IF_PCI_INTR 0x00000020
900 +#define AR2315_IF_PCI_CLK_MASK 0x00030000
901 +#define AR2315_IF_PCI_CLK_INPUT 0
902 +#define AR2315_IF_PCI_CLK_OUTPUT_LOW 1
903 +#define AR2315_IF_PCI_CLK_OUTPUT_CLK 2
904 +#define AR2315_IF_PCI_CLK_OUTPUT_HIGH 3
905 +#define AR2315_IF_PCI_CLK_SHIFT 16
908 + * APB Interrupt control
911 +#define AR2315_ISR (AR2315_DSLBASE + 0x0020)
912 +#define AR2315_IMR (AR2315_DSLBASE + 0x0024)
913 +#define AR2315_GISR (AR2315_DSLBASE + 0x0028)
915 +#define AR2315_ISR_UART0 0x0001 /* high speed UART */
916 +#define AR2315_ISR_I2C_RSVD 0x0002 /* I2C bus */
917 +#define AR2315_ISR_SPI 0x0004 /* SPI bus */
918 +#define AR2315_ISR_AHB 0x0008 /* AHB error */
919 +#define AR2315_ISR_APB 0x0010 /* APB error */
920 +#define AR2315_ISR_TIMER 0x0020 /* timer */
921 +#define AR2315_ISR_GPIO 0x0040 /* GPIO */
922 +#define AR2315_ISR_WD 0x0080 /* watchdog */
923 +#define AR2315_ISR_IR_RSVD 0x0100 /* IR */
925 +#define AR2315_GISR_MISC 0x0001
926 +#define AR2315_GISR_WLAN0 0x0002
927 +#define AR2315_GISR_MPEGTS_RSVD 0x0004
928 +#define AR2315_GISR_LOCALPCI 0x0008
929 +#define AR2315_GISR_WMACPOLL 0x0010
930 +#define AR2315_GISR_TIMER 0x0020
931 +#define AR2315_GISR_ETHERNET 0x0040
934 + * Interrupt routing from IO to the processor IP bits
935 + * Define our inter mask and level
937 +#define AR2315_INTR_MISCIO SR_IBIT3
938 +#define AR2315_INTR_WLAN0 SR_IBIT4
939 +#define AR2315_INTR_ENET0 SR_IBIT5
940 +#define AR2315_INTR_LOCALPCI SR_IBIT6
941 +#define AR2315_INTR_WMACPOLL SR_IBIT7
942 +#define AR2315_INTR_COMPARE SR_IBIT8
947 +#define AR2315_TIMER (AR2315_DSLBASE + 0x0030)
948 +#define AR2315_RELOAD (AR2315_DSLBASE + 0x0034)
949 +#define AR2315_WD (AR2315_DSLBASE + 0x0038)
950 +#define AR2315_WDC (AR2315_DSLBASE + 0x003c)
952 +#define AR2315_WDC_IGNORE_EXPIRATION 0x00000000
953 +#define AR2315_WDC_NMI 0x00000001 /* NMI on watchdog */
954 +#define AR2315_WDC_RESET 0x00000002 /* reset on watchdog */
957 + * CPU Performance Counters
959 +#define AR2315_PERFCNT0 (AR2315_DSLBASE + 0x0048)
960 +#define AR2315_PERFCNT1 (AR2315_DSLBASE + 0x004c)
962 +#define AR2315_PERF0_DATAHIT 0x0001 /* Count Data Cache Hits */
963 +#define AR2315_PERF0_DATAMISS 0x0002 /* Count Data Cache Misses */
964 +#define AR2315_PERF0_INSTHIT 0x0004 /* Count Instruction Cache Hits */
965 +#define AR2315_PERF0_INSTMISS 0x0008 /* Count Instruction Cache Misses */
966 +#define AR2315_PERF0_ACTIVE 0x0010 /* Count Active Processor Cycles */
967 +#define AR2315_PERF0_WBHIT 0x0020 /* Count CPU Write Buffer Hits */
968 +#define AR2315_PERF0_WBMISS 0x0040 /* Count CPU Write Buffer Misses */
970 +#define AR2315_PERF1_EB_ARDY 0x0001 /* Count EB_ARdy signal */
971 +#define AR2315_PERF1_EB_AVALID 0x0002 /* Count EB_AValid signal */
972 +#define AR2315_PERF1_EB_WDRDY 0x0004 /* Count EB_WDRdy signal */
973 +#define AR2315_PERF1_EB_RDVAL 0x0008 /* Count EB_RdVal signal */
974 +#define AR2315_PERF1_VRADDR 0x0010 /* Count valid read address cycles */
975 +#define AR2315_PERF1_VWADDR 0x0020 /* Count valid write address cycles */
976 +#define AR2315_PERF1_VWDATA 0x0040 /* Count valid write data cycles */
979 + * AHB Error Reporting.
981 +#define AR2315_AHB_ERR0 (AR2315_DSLBASE + 0x0050) /* error */
982 +#define AR2315_AHB_ERR1 (AR2315_DSLBASE + 0x0054) /* haddr */
983 +#define AR2315_AHB_ERR2 (AR2315_DSLBASE + 0x0058) /* hwdata */
984 +#define AR2315_AHB_ERR3 (AR2315_DSLBASE + 0x005c) /* hrdata */
985 +#define AR2315_AHB_ERR4 (AR2315_DSLBASE + 0x0060) /* status */
987 +#define AHB_ERROR_DET 1 /* AHB Error has been detected, */
988 + /* write 1 to clear all bits in ERR0 */
989 +#define AHB_ERROR_OVR 2 /* AHB Error overflow has been detected */
990 +#define AHB_ERROR_WDT 4 /* AHB Error due to wdt instead of hresp */
992 +#define AR2315_PROCERR_HMAST 0x0000000f
993 +#define AR2315_PROCERR_HMAST_DFLT 0
994 +#define AR2315_PROCERR_HMAST_WMAC 1
995 +#define AR2315_PROCERR_HMAST_ENET 2
996 +#define AR2315_PROCERR_HMAST_PCIENDPT 3
997 +#define AR2315_PROCERR_HMAST_LOCAL 4
998 +#define AR2315_PROCERR_HMAST_CPU 5
999 +#define AR2315_PROCERR_HMAST_PCITGT 6
1001 +#define AR2315_PROCERR_HMAST_S 0
1002 +#define AR2315_PROCERR_HWRITE 0x00000010
1003 +#define AR2315_PROCERR_HSIZE 0x00000060
1004 +#define AR2315_PROCERR_HSIZE_S 5
1005 +#define AR2315_PROCERR_HTRANS 0x00000180
1006 +#define AR2315_PROCERR_HTRANS_S 7
1007 +#define AR2315_PROCERR_HBURST 0x00000e00
1008 +#define AR2315_PROCERR_HBURST_S 9
1013 +#define AR2315_PLLC_CTL (AR2315_DSLBASE + 0x0064)
1014 +#define AR2315_PLLV_CTL (AR2315_DSLBASE + 0x0068)
1015 +#define AR2315_CPUCLK (AR2315_DSLBASE + 0x006c)
1016 +#define AR2315_AMBACLK (AR2315_DSLBASE + 0x0070)
1017 +#define AR2315_SYNCCLK (AR2315_DSLBASE + 0x0074)
1018 +#define AR2315_DSL_SLEEP_CTL (AR2315_DSLBASE + 0x0080)
1019 +#define AR2315_DSL_SLEEP_DUR (AR2315_DSLBASE + 0x0084)
1021 +/* PLLc Control fields */
1022 +#define PLLC_REF_DIV_M 0x00000003
1023 +#define PLLC_REF_DIV_S 0
1024 +#define PLLC_FDBACK_DIV_M 0x0000007C
1025 +#define PLLC_FDBACK_DIV_S 2
1026 +#define PLLC_ADD_FDBACK_DIV_M 0x00000080
1027 +#define PLLC_ADD_FDBACK_DIV_S 7
1028 +#define PLLC_CLKC_DIV_M 0x0001c000
1029 +#define PLLC_CLKC_DIV_S 14
1030 +#define PLLC_CLKM_DIV_M 0x00700000
1031 +#define PLLC_CLKM_DIV_S 20
1033 +/* CPU CLK Control fields */
1034 +#define CPUCLK_CLK_SEL_M 0x00000003
1035 +#define CPUCLK_CLK_SEL_S 0
1036 +#define CPUCLK_CLK_DIV_M 0x0000000c
1037 +#define CPUCLK_CLK_DIV_S 2
1039 +/* AMBA CLK Control fields */
1040 +#define AMBACLK_CLK_SEL_M 0x00000003
1041 +#define AMBACLK_CLK_SEL_S 0
1042 +#define AMBACLK_CLK_DIV_M 0x0000000c
1043 +#define AMBACLK_CLK_DIV_S 2
1048 +#define AR2315_GPIO_DI (AR2315_DSLBASE + 0x0088)
1049 +#define AR2315_GPIO_DO (AR2315_DSLBASE + 0x0090)
1050 +#define AR2315_GPIO_CR (AR2315_DSLBASE + 0x0098)
1051 +#define AR2315_GPIO_INT (AR2315_DSLBASE + 0x00a0)
1053 +#define AR2315_GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
1054 +#define AR2315_GPIO_CR_O(x) (1 << (x)) /* output */
1055 +#define AR2315_GPIO_CR_I(x) (0) /* input */
1057 +#define AR2315_GPIO_INT_S(x) (x) /* interrupt enable */
1058 +#define AR2315_GPIO_INT_M (0x3F) /* mask for int */
1059 +#define AR2315_GPIO_INT_LVL(x) ((x) << 6) /* interrupt level */
1060 +#define AR2315_GPIO_INT_LVL_M ((0x3) << 6) /* mask for int level */
1062 +#define AR2315_GPIO_INT_MAX_Y 1 /* Maximum value of Y for AR5313_GPIO_INT_* macros */
1063 +#define AR2315_GPIO_INT_LVL_OFF 0 /* Triggerring off */
1064 +#define AR2315_GPIO_INT_LVL_LOW 1 /* Low Level Triggered */
1065 +#define AR2315_GPIO_INT_LVL_HIGH 2 /* High Level Triggered */
1066 +#define AR2315_GPIO_INT_LVL_EDGE 3 /* Edge Triggered */
1068 +#define AR2315_RESET_GPIO 5
1069 +#define AR2315_NUM_GPIO 22
1072 + * PCI Clock Control
1074 +#define AR2315_PCICLK (AR2315_DSLBASE + 0x00a4)
1076 +#define AR2315_PCICLK_INPUT_M 0x3
1077 +#define AR2315_PCICLK_INPUT_S 0
1079 +#define AR2315_PCICLK_PLLC_CLKM 0
1080 +#define AR2315_PCICLK_PLLC_CLKM1 1
1081 +#define AR2315_PCICLK_PLLC_CLKC 2
1082 +#define AR2315_PCICLK_REF_CLK 3
1084 +#define AR2315_PCICLK_DIV_M 0xc
1085 +#define AR2315_PCICLK_DIV_S 2
1087 +#define AR2315_PCICLK_IN_FREQ 0
1088 +#define AR2315_PCICLK_IN_FREQ_DIV_6 1
1089 +#define AR2315_PCICLK_IN_FREQ_DIV_8 2
1090 +#define AR2315_PCICLK_IN_FREQ_DIV_10 3
1093 + * Observation Control Register
1095 +#define AR2315_OCR (AR2315_DSLBASE + 0x00b0)
1096 +#define OCR_GPIO0_IRIN 0x0040
1097 +#define OCR_GPIO1_IROUT 0x0080
1098 +#define OCR_GPIO3_RXCLR 0x0200
1101 + * General Clock Control
1104 +#define AR2315_MISCCLK (AR2315_DSLBASE + 0x00b4)
1105 +#define MISCCLK_PLLBYPASS_EN 0x00000001
1106 +#define MISCCLK_PROCREFCLK 0x00000002
1109 + * SDRAM Controller
1110 + * - No read or write buffers are included.
1112 +#define AR2315_MEM_CFG (AR2315_SDRAMCTL + 0x00)
1113 +#define AR2315_MEM_CTRL (AR2315_SDRAMCTL + 0x0c)
1114 +#define AR2315_MEM_REF (AR2315_SDRAMCTL + 0x10)
1116 +#define SDRAM_DATA_WIDTH_M 0x00006000
1117 +#define SDRAM_DATA_WIDTH_S 13
1119 +#define SDRAM_COL_WIDTH_M 0x00001E00
1120 +#define SDRAM_COL_WIDTH_S 9
1122 +#define SDRAM_ROW_WIDTH_M 0x000001E0
1123 +#define SDRAM_ROW_WIDTH_S 5
1125 +#define SDRAM_BANKADDR_BITS_M 0x00000018
1126 +#define SDRAM_BANKADDR_BITS_S 3
1129 + * SPI Flash Interface Registers
1132 +#define AR2315_SPI_CTL (AR2315_SPI + 0x00)
1133 +#define AR2315_SPI_OPCODE (AR2315_SPI + 0x04)
1134 +#define AR2315_SPI_DATA (AR2315_SPI + 0x08)
1136 +#define SPI_CTL_START 0x00000100
1137 +#define SPI_CTL_BUSY 0x00010000
1138 +#define SPI_CTL_TXCNT_MASK 0x0000000f
1139 +#define SPI_CTL_RXCNT_MASK 0x000000f0
1140 +#define SPI_CTL_TX_RX_CNT_MASK 0x000000ff
1141 +#define SPI_CTL_SIZE_MASK 0x00060000
1143 +#define SPI_CTL_CLK_SEL_MASK 0x03000000
1144 +#define SPI_OPCODE_MASK 0x000000ff
1147 + * PCI Bus Interface Registers
1149 +#define AR2315_PCI_1MS_REG (AR2315_PCI + 0x0008)
1150 +#define AR2315_PCI_1MS_MASK 0x3FFFF /* # of AHB clk cycles in 1ms */
1152 +#define AR2315_PCI_MISC_CONFIG (AR2315_PCI + 0x000c)
1153 +#define AR2315_PCIMISC_TXD_EN 0x00000001 /* Enable TXD for fragments */
1154 +#define AR2315_PCIMISC_CFG_SEL 0x00000002 /* mem or config cycles */
1155 +#define AR2315_PCIMISC_GIG_MASK 0x0000000C /* bits 31-30 for pci req */
1156 +#define AR2315_PCIMISC_RST_MODE 0x00000030
1157 +#define AR2315_PCIRST_INPUT 0x00000000 /* 4:5=0 rst is input */
1158 +#define AR2315_PCIRST_LOW 0x00000010 /* 4:5=1 rst to GND */
1159 +#define AR2315_PCIRST_HIGH 0x00000020 /* 4:5=2 rst to VDD */
1160 +#define AR2315_PCIGRANT_EN 0x00000000 /* 6:7=0 early grant en */
1161 +#define AR2315_PCIGRANT_FRAME 0x00000040 /* 6:7=1 grant waits 4 frame */
1162 +#define AR2315_PCIGRANT_IDLE 0x00000080 /* 6:7=2 grant waits 4 idle */
1163 +#define AR2315_PCIGRANT_GAP 0x00000000 /* 6:7=2 grant waits 4 idle */
1164 +#define AR2315_PCICACHE_DIS 0x00001000 /* PCI external access cache disable */
1166 +#define AR2315_PCI_OUT_TSTAMP (AR2315_PCI + 0x0010)
1168 +#define AR2315_PCI_UNCACHE_CFG (AR2315_PCI + 0x0014)
1170 +#define AR2315_PCI_IN_EN (AR2315_PCI + 0x0100)
1171 +#define AR2315_PCI_IN_EN0 0x01 /* Enable chain 0 */
1172 +#define AR2315_PCI_IN_EN1 0x02 /* Enable chain 1 */
1173 +#define AR2315_PCI_IN_EN2 0x04 /* Enable chain 2 */
1174 +#define AR2315_PCI_IN_EN3 0x08 /* Enable chain 3 */
1176 +#define AR2315_PCI_IN_DIS (AR2315_PCI + 0x0104)
1177 +#define AR2315_PCI_IN_DIS0 0x01 /* Disable chain 0 */
1178 +#define AR2315_PCI_IN_DIS1 0x02 /* Disable chain 1 */
1179 +#define AR2315_PCI_IN_DIS2 0x04 /* Disable chain 2 */
1180 +#define AR2315_PCI_IN_DIS3 0x08 /* Disable chain 3 */
1182 +#define AR2315_PCI_IN_PTR (AR2315_PCI + 0x0200)
1184 +#define AR2315_PCI_OUT_EN (AR2315_PCI + 0x0400)
1185 +#define AR2315_PCI_OUT_EN0 0x01 /* Enable chain 0 */
1187 +#define AR2315_PCI_OUT_DIS (AR2315_PCI + 0x0404)
1188 +#define AR2315_PCI_OUT_DIS0 0x01 /* Disable chain 0 */
1190 +#define AR2315_PCI_OUT_PTR (AR2315_PCI + 0x0408)
1192 +#define AR2315_PCI_INT_STATUS (AR2315_PCI + 0x0500) /* write one to clr */
1193 +#define AR2315_PCI_TXINT 0x00000001 /* Desc In Completed */
1194 +#define AR2315_PCI_TXOK 0x00000002 /* Desc In OK */
1195 +#define AR2315_PCI_TXERR 0x00000004 /* Desc In ERR */
1196 +#define AR2315_PCI_TXEOL 0x00000008 /* Desc In End-of-List */
1197 +#define AR2315_PCI_RXINT 0x00000010 /* Desc Out Completed */
1198 +#define AR2315_PCI_RXOK 0x00000020 /* Desc Out OK */
1199 +#define AR2315_PCI_RXERR 0x00000040 /* Desc Out ERR */
1200 +#define AR2315_PCI_RXEOL 0x00000080 /* Desc Out EOL */
1201 +#define AR2315_PCI_TXOOD 0x00000200 /* Desc In Out-of-Desc */
1202 +#define AR2315_PCI_MASK 0x0000FFFF /* Desc Mask */
1203 +#define AR2315_PCI_EXT_INT 0x02000000
1204 +#define AR2315_PCI_ABORT_INT 0x04000000
1206 +#define AR2315_PCI_INT_MASK (AR2315_PCI + 0x0504) /* same as INT_STATUS */
1208 +#define AR2315_PCI_INTEN_REG (AR2315_PCI + 0x0508)
1209 +#define AR2315_PCI_INT_DISABLE 0x00 /* disable pci interrupts */
1210 +#define AR2315_PCI_INT_ENABLE 0x01 /* enable pci interrupts */
1212 +#define AR2315_PCI_HOST_IN_EN (AR2315_PCI + 0x0800)
1213 +#define AR2315_PCI_HOST_IN_DIS (AR2315_PCI + 0x0804)
1214 +#define AR2315_PCI_HOST_IN_PTR (AR2315_PCI + 0x0810)
1215 +#define AR2315_PCI_HOST_OUT_EN (AR2315_PCI + 0x0900)
1216 +#define AR2315_PCI_HOST_OUT_DIS (AR2315_PCI + 0x0904)
1217 +#define AR2315_PCI_HOST_OUT_PTR (AR2315_PCI + 0x0908)
1221 + * Local Bus Interface Registers
1223 +#define AR2315_LB_CONFIG (AR2315_LOCAL + 0x0000)
1224 +#define AR2315_LBCONF_OE 0x00000001 /* =1 OE is low-true */
1225 +#define AR2315_LBCONF_CS0 0x00000002 /* =1 first CS is low-true */
1226 +#define AR2315_LBCONF_CS1 0x00000004 /* =1 2nd CS is low-true */
1227 +#define AR2315_LBCONF_RDY 0x00000008 /* =1 RDY is low-true */
1228 +#define AR2315_LBCONF_WE 0x00000010 /* =1 Write En is low-true */
1229 +#define AR2315_LBCONF_WAIT 0x00000020 /* =1 WAIT is low-true */
1230 +#define AR2315_LBCONF_ADS 0x00000040 /* =1 Adr Strobe is low-true */
1231 +#define AR2315_LBCONF_MOT 0x00000080 /* =0 Intel, =1 Motorola */
1232 +#define AR2315_LBCONF_8CS 0x00000100 /* =1 8 bits CS, 0= 16bits */
1233 +#define AR2315_LBCONF_8DS 0x00000200 /* =1 8 bits Data S, 0=16bits */
1234 +#define AR2315_LBCONF_ADS_EN 0x00000400 /* =1 Enable ADS */
1235 +#define AR2315_LBCONF_ADR_OE 0x00000800 /* =1 Adr cap on OE, WE or DS */
1236 +#define AR2315_LBCONF_ADDT_MUX 0x00001000 /* =1 Adr and Data share bus */
1237 +#define AR2315_LBCONF_DATA_OE 0x00002000 /* =1 Data cap on OE, WE, DS */
1238 +#define AR2315_LBCONF_16DATA 0x00004000 /* =1 Data is 16 bits wide */
1239 +#define AR2315_LBCONF_SWAPDT 0x00008000 /* =1 Byte swap data */
1240 +#define AR2315_LBCONF_SYNC 0x00010000 /* =1 Bus synchronous to clk */
1241 +#define AR2315_LBCONF_INT 0x00020000 /* =1 Intr is low true */
1242 +#define AR2315_LBCONF_INT_CTR0 0x00000000 /* GND high-Z, Vdd is high-Z */
1243 +#define AR2315_LBCONF_INT_CTR1 0x00040000 /* GND drive, Vdd is high-Z */
1244 +#define AR2315_LBCONF_INT_CTR2 0x00080000 /* GND high-Z, Vdd drive */
1245 +#define AR2315_LBCONF_INT_CTR3 0x000C0000 /* GND drive, Vdd drive */
1246 +#define AR2315_LBCONF_RDY_WAIT 0x00100000 /* =1 RDY is negative of WAIT */
1247 +#define AR2315_LBCONF_INT_PULSE 0x00200000 /* =1 Interrupt is a pulse */
1248 +#define AR2315_LBCONF_ENABLE 0x00400000 /* =1 Falcon respond to LB */
1250 +#define AR2315_LB_CLKSEL (AR2315_LOCAL + 0x0004)
1251 +#define AR2315_LBCLK_EXT 0x0001 /* use external clk for lb */
1253 +#define AR2315_LB_1MS (AR2315_LOCAL + 0x0008)
1254 +#define AR2315_LB1MS_MASK 0x3FFFF /* # of AHB clk cycles in 1ms */
1256 +#define AR2315_LB_MISCCFG (AR2315_LOCAL + 0x000C)
1257 +#define AR2315_LBM_TXD_EN 0x00000001 /* Enable TXD for fragments */
1258 +#define AR2315_LBM_RX_INTEN 0x00000002 /* Enable LB ints on RX ready */
1259 +#define AR2315_LBM_MBOXWR_INTEN 0x00000004 /* Enable LB ints on mbox wr */
1260 +#define AR2315_LBM_MBOXRD_INTEN 0x00000008 /* Enable LB ints on mbox rd */
1261 +#define AR2315_LMB_DESCSWAP_EN 0x00000010 /* Byte swap desc enable */
1262 +#define AR2315_LBM_TIMEOUT_MASK 0x00FFFF80
1263 +#define AR2315_LBM_TIMEOUT_SHFT 7
1264 +#define AR2315_LBM_PORTMUX 0x07000000
1267 +#define AR2315_LB_RXTSOFF (AR2315_LOCAL + 0x0010)
1269 +#define AR2315_LB_TX_CHAIN_EN (AR2315_LOCAL + 0x0100)
1270 +#define AR2315_LB_TXEN_0 0x01
1271 +#define AR2315_LB_TXEN_1 0x02
1272 +#define AR2315_LB_TXEN_2 0x04
1273 +#define AR2315_LB_TXEN_3 0x08
1275 +#define AR2315_LB_TX_CHAIN_DIS (AR2315_LOCAL + 0x0104)
1276 +#define AR2315_LB_TX_DESC_PTR (AR2315_LOCAL + 0x0200)
1278 +#define AR2315_LB_RX_CHAIN_EN (AR2315_LOCAL + 0x0400)
1279 +#define AR2315_LB_RXEN 0x01
1281 +#define AR2315_LB_RX_CHAIN_DIS (AR2315_LOCAL + 0x0404)
1282 +#define AR2315_LB_RX_DESC_PTR (AR2315_LOCAL + 0x0408)
1284 +#define AR2315_LB_INT_STATUS (AR2315_LOCAL + 0x0500)
1285 +#define AR2315_INT_TX_DESC 0x0001
1286 +#define AR2315_INT_TX_OK 0x0002
1287 +#define AR2315_INT_TX_ERR 0x0004
1288 +#define AR2315_INT_TX_EOF 0x0008
1289 +#define AR2315_INT_RX_DESC 0x0010
1290 +#define AR2315_INT_RX_OK 0x0020
1291 +#define AR2315_INT_RX_ERR 0x0040
1292 +#define AR2315_INT_RX_EOF 0x0080
1293 +#define AR2315_INT_TX_TRUNC 0x0100
1294 +#define AR2315_INT_TX_STARVE 0x0200
1295 +#define AR2315_INT_LB_TIMEOUT 0x0400
1296 +#define AR2315_INT_LB_ERR 0x0800
1297 +#define AR2315_INT_MBOX_WR 0x1000
1298 +#define AR2315_INT_MBOX_RD 0x2000
1300 +/* Bit definitions for INT MASK are the same as INT_STATUS */
1301 +#define AR2315_LB_INT_MASK (AR2315_LOCAL + 0x0504)
1303 +#define AR2315_LB_INT_EN (AR2315_LOCAL + 0x0508)
1304 +#define AR2315_LB_MBOX (AR2315_LOCAL + 0x0600)
1307 + * IR Interface Registers
1309 +#define AR2315_IR_PKTDATA (AR2315_IR + 0x0000)
1311 +#define AR2315_IR_PKTLEN (AR2315_IR + 0x07fc) /* 0 - 63 */
1313 +#define AR2315_IR_CONTROL (AR2315_IR + 0x0800)
1314 +#define AR2315_IRCTL_TX 0x00000000 /* use as tranmitter */
1315 +#define AR2315_IRCTL_RX 0x00000001 /* use as receiver */
1316 +#define AR2315_IRCTL_SAMPLECLK_MASK 0x00003ffe /* Sample clk divisor mask */
1317 +#define AR2315_IRCTL_SAMPLECLK_SHFT 1
1318 +#define AR2315_IRCTL_OUTPUTCLK_MASK 0x03ffc000 /* Output clk divisor mask */
1319 +#define AR2315_IRCTL_OUTPUTCLK_SHFT 14
1321 +#define AR2315_IR_STATUS (AR2315_IR + 0x0804)
1322 +#define AR2315_IRSTS_RX 0x00000001 /* receive in progress */
1323 +#define AR2315_IRSTS_TX 0x00000002 /* transmit in progress */
1325 +#define AR2315_IR_CONFIG (AR2315_IR + 0x0808)
1326 +#define AR2315_IRCFG_INVIN 0x00000001 /* invert input polarity */
1327 +#define AR2315_IRCFG_INVOUT 0x00000002 /* invert output polarity */
1328 +#define AR2315_IRCFG_SEQ_START_WIN_SEL 0x00000004 /* 1 => 28, 0 => 7 */
1329 +#define AR2315_IRCFG_SEQ_START_THRESH 0x000000f0 /* */
1330 +#define AR2315_IRCFG_SEQ_END_UNIT_SEL 0x00000100 /* */
1331 +#define AR2315_IRCFG_SEQ_END_UNIT_THRESH 0x00007e00 /* */
1332 +#define AR2315_IRCFG_SEQ_END_WIN_SEL 0x00008000 /* */
1333 +#define AR2315_IRCFG_SEQ_END_WIN_THRESH 0x001f0000 /* */
1334 +#define AR2315_IRCFG_NUM_BACKOFF_WORDS 0x01e00000 /* */
1336 +#define HOST_PCI_DEV_ID 3
1337 +#define HOST_PCI_MBAR0 0x10000000
1338 +#define HOST_PCI_MBAR1 0x20000000
1339 +#define HOST_PCI_MBAR2 0x30000000
1341 +#define HOST_PCI_SDRAM_BASEADDR HOST_PCI_MBAR1
1342 +#define PCI_DEVICE_MEM_SPACE 0x800000
1344 +#endif /* __AR2315_REG_H */
1345 Index: linux-2.6.33/arch/mips/include/asm/mach-ar231x/ar5312_regs.h
1346 ===================================================================
1347 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1348 +++ linux-2.6.33/arch/mips/include/asm/mach-ar231x/ar5312_regs.h 2010-03-03 12:20:05.558287696 +0100
1351 + * This file is subject to the terms and conditions of the GNU General Public
1352 + * License. See the file "COPYING" in the main directory of this archive
1353 + * for more details.
1355 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
1356 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
1357 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
1363 +#include <asm/addrspace.h>
1369 +#define AR5312_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
1370 +#define AR5312_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
1371 +#define AR5312_IRQ_ENET1_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
1372 +#define AR5312_IRQ_WLAN1_INTRS MIPS_CPU_IRQ_BASE+5 /* C0_CAUSE: 0x2000 */
1373 +#define AR5312_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
1377 +#define AR531X_WLAN0 0x18000000
1378 +#define AR531X_WLAN1 0x18500000
1379 +#define AR531X_ENET0 0x18100000
1380 +#define AR531X_ENET1 0x18200000
1381 +#define AR531X_SDRAMCTL 0x18300000
1382 +#define AR531X_FLASHCTL 0x18400000
1383 +#define AR531X_APBBASE 0x1c000000
1384 +#define AR531X_FLASH 0x1e000000
1385 +#define AR531X_UART0 0xbc000003 /* UART MMR */
1388 + * AR531X_NUM_ENET_MAC defines the number of ethernet MACs that
1389 + * should be considered available. The AR5312 supports 2 enet MACS,
1390 + * even though many reference boards only actually use 1 of them
1391 + * (i.e. Only MAC 0 is actually connected to an enet PHY or PHY switch.
1392 + * The AR2312 supports 1 enet MAC.
1394 +#define AR531X_NUM_ENET_MAC 2
1397 + * Need these defines to determine true number of ethernet MACs
1399 +#define AR5212_AR5312_REV2 0x0052 /* AR5312 WMAC (AP31) */
1400 +#define AR5212_AR5312_REV7 0x0057 /* AR5312 WMAC (AP30-040) */
1401 +#define AR5212_AR2313_REV8 0x0058 /* AR2313 WMAC (AP43-030) */
1402 +#define AR531X_RADIO_MASK_OFF 0xc8
1403 +#define AR531X_RADIO0_MASK 0x0003
1404 +#define AR531X_RADIO1_MASK 0x000c
1405 +#define AR531X_RADIO1_S 2
1408 + * AR531X_NUM_WMAC defines the number of Wireless MACs that\
1409 + * should be considered available.
1411 +#define AR531X_NUM_WMAC 2
1413 +/* Reset/Timer Block Address Map */
1414 +#define AR531X_RESETTMR (AR531X_APBBASE + 0x3000)
1415 +#define AR531X_TIMER (AR531X_RESETTMR + 0x0000) /* countdown timer */
1416 +#define AR531X_WD_CTRL (AR531X_RESETTMR + 0x0008) /* watchdog cntrl */
1417 +#define AR531X_WD_TIMER (AR531X_RESETTMR + 0x000c) /* watchdog timer */
1418 +#define AR531X_ISR (AR531X_RESETTMR + 0x0010) /* Intr Status Reg */
1419 +#define AR531X_IMR (AR531X_RESETTMR + 0x0014) /* Intr Mask Reg */
1420 +#define AR531X_RESET (AR531X_RESETTMR + 0x0020)
1421 +#define AR5312_CLOCKCTL1 (AR531X_RESETTMR + 0x0064)
1422 +#define AR5312_SCRATCH (AR531X_RESETTMR + 0x006c)
1423 +#define AR531X_PROCADDR (AR531X_RESETTMR + 0x0070)
1424 +#define AR531X_PROC1 (AR531X_RESETTMR + 0x0074)
1425 +#define AR531X_DMAADDR (AR531X_RESETTMR + 0x0078)
1426 +#define AR531X_DMA1 (AR531X_RESETTMR + 0x007c)
1427 +#define AR531X_ENABLE (AR531X_RESETTMR + 0x0080) /* interface enb */
1428 +#define AR531X_REV (AR531X_RESETTMR + 0x0090) /* revision */
1430 +/* AR531X_WD_CTRL register bit field definitions */
1431 +#define AR531X_WD_CTRL_IGNORE_EXPIRATION 0x0000
1432 +#define AR531X_WD_CTRL_NMI 0x0001
1433 +#define AR531X_WD_CTRL_RESET 0x0002
1435 +/* AR531X_ISR register bit field definitions */
1436 +#define AR531X_ISR_NONE 0x0000
1437 +#define AR531X_ISR_TIMER 0x0001
1438 +#define AR531X_ISR_AHBPROC 0x0002
1439 +#define AR531X_ISR_AHBDMA 0x0004
1440 +#define AR531X_ISR_GPIO 0x0008
1441 +#define AR531X_ISR_UART0 0x0010
1442 +#define AR531X_ISR_UART0DMA 0x0020
1443 +#define AR531X_ISR_WD 0x0040
1444 +#define AR531X_ISR_LOCAL 0x0080
1446 +/* AR531X_RESET register bit field definitions */
1447 +#define AR531X_RESET_SYSTEM 0x00000001 /* cold reset full system */
1448 +#define AR531X_RESET_PROC 0x00000002 /* cold reset MIPS core */
1449 +#define AR531X_RESET_WLAN0 0x00000004 /* cold reset WLAN MAC and BB */
1450 +#define AR531X_RESET_EPHY0 0x00000008 /* cold reset ENET0 phy */
1451 +#define AR531X_RESET_EPHY1 0x00000010 /* cold reset ENET1 phy */
1452 +#define AR531X_RESET_ENET0 0x00000020 /* cold reset ENET0 mac */
1453 +#define AR531X_RESET_ENET1 0x00000040 /* cold reset ENET1 mac */
1454 +#define AR531X_RESET_UART0 0x00000100 /* cold reset UART0 (high speed) */
1455 +#define AR531X_RESET_WLAN1 0x00000200 /* cold reset WLAN MAC/BB */
1456 +#define AR531X_RESET_APB 0x00000400 /* cold reset APB (ar5312) */
1457 +#define AR531X_RESET_WARM_PROC 0x00001000 /* warm reset MIPS core */
1458 +#define AR531X_RESET_WARM_WLAN0_MAC 0x00002000 /* warm reset WLAN0 MAC */
1459 +#define AR531X_RESET_WARM_WLAN0_BB 0x00004000 /* warm reset WLAN0 BaseBand */
1460 +#define AR531X_RESET_NMI 0x00010000 /* send an NMI to the processor */
1461 +#define AR531X_RESET_WARM_WLAN1_MAC 0x00020000 /* warm reset WLAN1 mac */
1462 +#define AR531X_RESET_WARM_WLAN1_BB 0x00040000 /* warm reset WLAN1 baseband */
1463 +#define AR531X_RESET_LOCAL_BUS 0x00080000 /* reset local bus */
1464 +#define AR531X_RESET_WDOG 0x00100000 /* last reset was a watchdog */
1466 +#define AR531X_RESET_WMAC0_BITS \
1467 + AR531X_RESET_WLAN0 |\
1468 + AR531X_RESET_WARM_WLAN0_MAC |\
1469 + AR531X_RESET_WARM_WLAN0_BB
1471 +#define AR531X_RESERT_WMAC1_BITS \
1472 + AR531X_RESET_WLAN1 |\
1473 + AR531X_RESET_WARM_WLAN1_MAC |\
1474 + AR531X_RESET_WARM_WLAN1_BB
1476 +/* AR5312_CLOCKCTL1 register bit field definitions */
1477 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
1478 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
1479 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
1480 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
1481 +#define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
1483 +/* Valid for AR5312 and AR2312 */
1484 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
1485 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
1486 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
1487 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
1488 +#define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
1490 +/* Valid for AR2313 */
1491 +#define AR2313_CLOCKCTL1_PREDIVIDE_MASK 0x00003000
1492 +#define AR2313_CLOCKCTL1_PREDIVIDE_SHIFT 12
1493 +#define AR2313_CLOCKCTL1_MULTIPLIER_MASK 0x001f0000
1494 +#define AR2313_CLOCKCTL1_MULTIPLIER_SHIFT 16
1495 +#define AR2313_CLOCKCTL1_DOUBLER_MASK 0x00000000
1498 +/* AR531X_ENABLE register bit field definitions */
1499 +#define AR531X_ENABLE_WLAN0 0x0001
1500 +#define AR531X_ENABLE_ENET0 0x0002
1501 +#define AR531X_ENABLE_ENET1 0x0004
1502 +#define AR531X_ENABLE_UART_AND_WLAN1_PIO 0x0008 /* UART, and WLAN1 PIOs */
1503 +#define AR531X_ENABLE_WLAN1_DMA 0x0010 /* WLAN1 DMAs */
1504 +#define AR531X_ENABLE_WLAN1 \
1505 + (AR531X_ENABLE_UART_AND_WLAN1_PIO | AR531X_ENABLE_WLAN1_DMA)
1507 +/* AR531X_REV register bit field definitions */
1508 +#define AR531X_REV_WMAC_MAJ 0xf000
1509 +#define AR531X_REV_WMAC_MAJ_S 12
1510 +#define AR531X_REV_WMAC_MIN 0x0f00
1511 +#define AR531X_REV_WMAC_MIN_S 8
1512 +#define AR531X_REV_MAJ 0x00f0
1513 +#define AR531X_REV_MAJ_S 4
1514 +#define AR531X_REV_MIN 0x000f
1515 +#define AR531X_REV_MIN_S 0
1516 +#define AR531X_REV_CHIP (AR531X_REV_MAJ|AR531X_REV_MIN)
1518 +/* Major revision numbers, bits 7..4 of Revision ID register */
1519 +#define AR531X_REV_MAJ_AR5312 0x4
1520 +#define AR531X_REV_MAJ_AR2313 0x5
1522 +/* Minor revision numbers, bits 3..0 of Revision ID register */
1523 +#define AR5312_REV_MIN_DUAL 0x0 /* Dual WLAN version */
1524 +#define AR5312_REV_MIN_SINGLE 0x1 /* Single WLAN version */
1526 +/* AR531X_FLASHCTL register bit field definitions */
1527 +#define FLASHCTL_IDCY 0x0000000f /* Idle cycle turn around time */
1528 +#define FLASHCTL_IDCY_S 0
1529 +#define FLASHCTL_WST1 0x000003e0 /* Wait state 1 */
1530 +#define FLASHCTL_WST1_S 5
1531 +#define FLASHCTL_RBLE 0x00000400 /* Read byte lane enable */
1532 +#define FLASHCTL_WST2 0x0000f800 /* Wait state 2 */
1533 +#define FLASHCTL_WST2_S 11
1534 +#define FLASHCTL_AC 0x00070000 /* Flash address check (added) */
1535 +#define FLASHCTL_AC_S 16
1536 +#define FLASHCTL_AC_128K 0x00000000
1537 +#define FLASHCTL_AC_256K 0x00010000
1538 +#define FLASHCTL_AC_512K 0x00020000
1539 +#define FLASHCTL_AC_1M 0x00030000
1540 +#define FLASHCTL_AC_2M 0x00040000
1541 +#define FLASHCTL_AC_4M 0x00050000
1542 +#define FLASHCTL_AC_8M 0x00060000
1543 +#define FLASHCTL_AC_RES 0x00070000 /* 16MB is not supported */
1544 +#define FLASHCTL_E 0x00080000 /* Flash bank enable (added) */
1545 +#define FLASHCTL_BUSERR 0x01000000 /* Bus transfer error status flag */
1546 +#define FLASHCTL_WPERR 0x02000000 /* Write protect error status flag */
1547 +#define FLASHCTL_WP 0x04000000 /* Write protect */
1548 +#define FLASHCTL_BM 0x08000000 /* Burst mode */
1549 +#define FLASHCTL_MW 0x30000000 /* Memory width */
1550 +#define FLASHCTL_MWx8 0x00000000 /* Memory width x8 */
1551 +#define FLASHCTL_MWx16 0x10000000 /* Memory width x16 */
1552 +#define FLASHCTL_MWx32 0x20000000 /* Memory width x32 (not supported) */
1553 +#define FLASHCTL_ATNR 0x00000000 /* Access type == no retry */
1554 +#define FLASHCTL_ATR 0x80000000 /* Access type == retry every */
1555 +#define FLASHCTL_ATR4 0xc0000000 /* Access type == retry every 4 */
1557 +/* ARM Flash Controller -- 3 flash banks with either x8 or x16 devices. */
1558 +#define AR531X_FLASHCTL0 (AR531X_FLASHCTL + 0x00)
1559 +#define AR531X_FLASHCTL1 (AR531X_FLASHCTL + 0x04)
1560 +#define AR531X_FLASHCTL2 (AR531X_FLASHCTL + 0x08)
1562 +/* ARM SDRAM Controller -- just enough to determine memory size */
1563 +#define AR531X_MEM_CFG1 (AR531X_SDRAMCTL + 0x04)
1564 +#define MEM_CFG1_AC0 0x00000700 /* bank 0: SDRAM addr check (added) */
1565 +#define MEM_CFG1_AC0_S 8
1566 +#define MEM_CFG1_AC1 0x00007000 /* bank 1: SDRAM addr check (added) */
1567 +#define MEM_CFG1_AC1_S 12
1569 +/* GPIO Address Map */
1570 +#define AR531X_GPIO (AR531X_APBBASE + 0x2000)
1571 +#define AR531X_GPIO_DO (AR531X_GPIO + 0x00) /* output register */
1572 +#define AR531X_GPIO_DI (AR531X_GPIO + 0x04) /* intput register */
1573 +#define AR531X_GPIO_CR (AR531X_GPIO + 0x08) /* control register */
1575 +/* GPIO Control Register bit field definitions */
1576 +#define AR531X_GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
1577 +#define AR531X_GPIO_CR_O(x) (0 << (x)) /* mask for output */
1578 +#define AR531X_GPIO_CR_I(x) (1 << (x)) /* mask for input */
1579 +#define AR531X_GPIO_CR_INT(x) (1 << ((x)+8)) /* mask for interrupt */
1580 +#define AR531X_GPIO_CR_UART(x) (1 << ((x)+16)) /* uart multiplex */
1581 +#define AR531X_NUM_GPIO 8
1586 Index: linux-2.6.33/arch/mips/ar231x/ar5312.c
1587 ===================================================================
1588 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1589 +++ linux-2.6.33/arch/mips/ar231x/ar5312.c 2010-03-03 12:20:05.558287696 +0100
1592 + * This file is subject to the terms and conditions of the GNU General Public
1593 + * License. See the file "COPYING" in the main directory of this archive
1594 + * for more details.
1596 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
1597 + * Copyright (C) 2006 FON Technology, SL.
1598 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
1599 + * Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
1603 + * Platform devices for Atheros SoCs
1606 +#include <generated/autoconf.h>
1607 +#include <linux/init.h>
1608 +#include <linux/module.h>
1609 +#include <linux/types.h>
1610 +#include <linux/string.h>
1611 +#include <linux/mtd/physmap.h>
1612 +#include <linux/platform_device.h>
1613 +#include <linux/kernel.h>
1614 +#include <linux/reboot.h>
1615 +#include <linux/leds.h>
1616 +#include <asm/bootinfo.h>
1617 +#include <asm/reboot.h>
1618 +#include <asm/time.h>
1619 +#include <asm/irq.h>
1620 +#include <asm/io.h>
1623 +#include <ar231x_platform.h>
1624 +#include <ar5312_regs.h>
1625 +#include <ar231x.h>
1626 +#include "devices.h"
1627 +#include "ar5312.h"
1630 +ar5312_misc_irq_dispatch(void)
1632 + unsigned int ar231x_misc_intrs = ar231x_read_reg(AR531X_ISR) & ar231x_read_reg(AR531X_IMR);
1634 + if (ar231x_misc_intrs & AR531X_ISR_TIMER) {
1635 + do_IRQ(AR531X_MISC_IRQ_TIMER);
1636 + (void)ar231x_read_reg(AR531X_TIMER);
1637 + } else if (ar231x_misc_intrs & AR531X_ISR_AHBPROC)
1638 + do_IRQ(AR531X_MISC_IRQ_AHB_PROC);
1639 + else if ((ar231x_misc_intrs & AR531X_ISR_UART0))
1640 + do_IRQ(AR531X_MISC_IRQ_UART0);
1641 + else if (ar231x_misc_intrs & AR531X_ISR_WD)
1642 + do_IRQ(AR531X_MISC_IRQ_WATCHDOG);
1644 + do_IRQ(AR531X_MISC_IRQ_NONE);
1647 +static asmlinkage void
1648 +ar5312_irq_dispatch(void)
1650 + int pending = read_c0_status() & read_c0_cause();
1652 + if (pending & CAUSEF_IP2)
1653 + do_IRQ(AR5312_IRQ_WLAN0_INTRS);
1654 + else if (pending & CAUSEF_IP3)
1655 + do_IRQ(AR5312_IRQ_ENET0_INTRS);
1656 + else if (pending & CAUSEF_IP4)
1657 + do_IRQ(AR5312_IRQ_ENET1_INTRS);
1658 + else if (pending & CAUSEF_IP5)
1659 + do_IRQ(AR5312_IRQ_WLAN1_INTRS);
1660 + else if (pending & CAUSEF_IP6)
1661 + ar5312_misc_irq_dispatch();
1662 + else if (pending & CAUSEF_IP7)
1663 + do_IRQ(AR531X_IRQ_CPU_CLOCK);
1667 +/* Enable the specified AR531X_MISC_IRQ interrupt */
1669 +ar5312_misc_intr_enable(unsigned int irq)
1673 + imr = ar231x_read_reg(AR531X_IMR);
1674 + imr |= (1 << (irq - AR531X_MISC_IRQ_BASE - 1));
1675 + ar231x_write_reg(AR531X_IMR, imr);
1678 +/* Disable the specified AR531X_MISC_IRQ interrupt */
1680 +ar5312_misc_intr_disable(unsigned int irq)
1684 + imr = ar231x_read_reg(AR531X_IMR);
1685 + imr &= ~(1 << (irq - AR531X_MISC_IRQ_BASE - 1));
1686 + ar231x_write_reg(AR531X_IMR, imr);
1687 + ar231x_read_reg(AR531X_IMR); /* flush write buffer */
1691 +ar5312_misc_intr_end(unsigned int irq)
1693 + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
1694 + ar5312_misc_intr_enable(irq);
1697 +static struct irq_chip ar5312_misc_intr_controller = {
1698 + .name = "AR5312-MISC",
1699 + .disable = ar5312_misc_intr_disable,
1700 + .ack = ar5312_misc_intr_disable,
1701 + .mask_ack = ar5312_misc_intr_disable,
1702 + .mask = ar5312_misc_intr_disable,
1703 + .unmask = ar5312_misc_intr_enable,
1704 + .end = ar5312_misc_intr_end,
1708 +static irqreturn_t ar5312_ahb_proc_handler(int cpl, void *dev_id)
1710 + u32 proc1 = ar231x_read_reg(AR531X_PROC1);
1711 + u32 procAddr = ar231x_read_reg(AR531X_PROCADDR); /* clears error state */
1712 + u32 dma1 = ar231x_read_reg(AR531X_DMA1);
1713 + u32 dmaAddr = ar231x_read_reg(AR531X_DMAADDR); /* clears error state */
1715 + printk("AHB interrupt: PROCADDR=0x%8.8x PROC1=0x%8.8x DMAADDR=0x%8.8x DMA1=0x%8.8x\n",
1716 + procAddr, proc1, dmaAddr, dma1);
1718 + machine_restart("AHB error"); /* Catastrophic failure */
1719 + return IRQ_HANDLED;
1723 +static struct irqaction ar5312_ahb_proc_interrupt = {
1724 + .handler = ar5312_ahb_proc_handler,
1725 + .flags = IRQF_DISABLED,
1726 + .name = "ar5312_ahb_proc_interrupt",
1730 +static struct irqaction cascade = {
1731 + .handler = no_action,
1732 + .flags = IRQF_DISABLED,
1733 + .name = "cascade",
1736 +void __init ar5312_irq_init(void)
1743 + ar231x_irq_dispatch = ar5312_irq_dispatch;
1744 + for (i = 0; i < AR531X_MISC_IRQ_COUNT; i++) {
1745 + int irq = AR531X_MISC_IRQ_BASE + i;
1746 + set_irq_chip_and_handler(irq, &ar5312_misc_intr_controller,
1747 + handle_level_irq);
1749 + setup_irq(AR531X_MISC_IRQ_AHB_PROC, &ar5312_ahb_proc_interrupt);
1750 + setup_irq(AR5312_IRQ_MISC_INTRS, &cascade);
1753 +const struct ar231x_gpiodev ar5312_gpiodev;
1756 +ar5312_gpio_get_output(void)
1759 + reg = ~(ar231x_read_reg(AR531X_GPIO_CR));
1760 + reg &= ar5312_gpiodev.valid_mask;
1765 +ar5312_gpio_set_output(u32 mask, u32 val)
1769 + reg = ar231x_read_reg(AR531X_GPIO_CR);
1772 + ar231x_write_reg(AR531X_GPIO_CR, reg);
1777 +ar5312_gpio_get(void)
1780 + reg = ar231x_read_reg(AR531X_GPIO_DI);
1781 + reg &= ar5312_gpiodev.valid_mask;
1786 +ar5312_gpio_set(u32 mask, u32 value)
1789 + reg = ar231x_read_reg(AR531X_GPIO_DO);
1792 + ar231x_write_reg(AR531X_GPIO_DO, reg);
1796 +const struct ar231x_gpiodev ar5312_gpiodev = {
1797 + .valid_mask = (1 << 8) - 1,
1798 + .get_output = ar5312_gpio_get_output,
1799 + .set_output = ar5312_gpio_set_output,
1800 + .get = ar5312_gpio_get,
1801 + .set = ar5312_gpio_set,
1804 +static struct physmap_flash_data ar5312_flash_data = {
1808 +static struct resource ar5312_flash_resource = {
1809 + .start = AR531X_FLASH,
1810 + .end = AR531X_FLASH + 0x800000 - 1,
1811 + .flags = IORESOURCE_MEM,
1814 +static struct ar231x_eth ar5312_eth0_data = {
1815 + .reset_base = AR531X_RESET,
1816 + .reset_mac = AR531X_RESET_ENET0,
1817 + .reset_phy = AR531X_RESET_EPHY0,
1818 + .phy_base = KSEG1ADDR(AR531X_ENET0),
1819 + .config = &ar231x_board,
1822 +static struct ar231x_eth ar5312_eth1_data = {
1823 + .reset_base = AR531X_RESET,
1824 + .reset_mac = AR531X_RESET_ENET1,
1825 + .reset_phy = AR531X_RESET_EPHY1,
1826 + .phy_base = KSEG1ADDR(AR531X_ENET1),
1827 + .config = &ar231x_board,
1830 +static struct platform_device ar5312_physmap_flash = {
1831 + .name = "physmap-flash",
1833 + .dev.platform_data = &ar5312_flash_data,
1834 + .resource = &ar5312_flash_resource,
1835 + .num_resources = 1,
1838 +#ifdef CONFIG_LEDS_GPIO
1839 +static struct gpio_led ar5312_leds[] = {
1840 + { .name = "wlan", .gpio = 0, .active_low = 1, },
1843 +static const struct gpio_led_platform_data ar5312_led_data = {
1844 + .num_leds = ARRAY_SIZE(ar5312_leds),
1845 + .leds = (void *) ar5312_leds,
1848 +static struct platform_device ar5312_gpio_leds = {
1849 + .name = "leds-gpio",
1851 + .dev.platform_data = (void *) &ar5312_led_data,
1856 + * NB: This mapping size is larger than the actual flash size,
1857 + * but this shouldn't be a problem here, because the flash
1858 + * will simply be mapped multiple times.
1860 +static char __init *ar5312_flash_limit(void)
1864 + * Configure flash bank 0.
1865 + * Assume 8M window size. Flash will be aliased if it's smaller
1867 + ctl = FLASHCTL_E |
1870 + (0x01 << FLASHCTL_IDCY_S) |
1871 + (0x07 << FLASHCTL_WST1_S) |
1872 + (0x07 << FLASHCTL_WST2_S) |
1873 + (ar231x_read_reg(AR531X_FLASHCTL0) & FLASHCTL_MW);
1875 + ar231x_write_reg(AR531X_FLASHCTL0, ctl);
1877 + /* Disable other flash banks */
1878 + ar231x_write_reg(AR531X_FLASHCTL1,
1879 + ar231x_read_reg(AR531X_FLASHCTL1) & ~(FLASHCTL_E | FLASHCTL_AC));
1881 + ar231x_write_reg(AR531X_FLASHCTL2,
1882 + ar231x_read_reg(AR531X_FLASHCTL2) & ~(FLASHCTL_E | FLASHCTL_AC));
1884 + return (char *) KSEG1ADDR(AR531X_FLASH + 0x800000);
1887 +int __init ar5312_init_devices(void)
1889 + struct ar231x_boarddata *config;
1897 + /* Locate board/radio config data */
1898 + ar231x_find_config(ar5312_flash_limit());
1899 + config = ar231x_board.config;
1903 + * Chip IDs and hardware detection for some Atheros
1904 + * models are really broken!
1906 + * Atheros uses a disabled WMAC0 and Silicon ID of AR5312
1907 + * as indication for AR2312, which is otherwise
1908 + * indistinguishable from the real AR5312.
1910 + if (ar231x_board.radio) {
1911 + radio = ar231x_board.radio + AR531X_RADIO_MASK_OFF;
1912 + if ((*((const u32 *) radio) & AR531X_RADIO0_MASK) == 0)
1913 + config->flags |= BD_ISCASPER;
1917 + /* AR2313 has CPU minor rev. 10 */
1918 + if ((current_cpu_data.processor_id & 0xff) == 0x0a)
1919 + ar231x_devtype = DEV_TYPE_AR2313;
1921 + /* AR2312 shares the same Silicon ID as AR5312 */
1922 + else if (config->flags & BD_ISCASPER)
1923 + ar231x_devtype = DEV_TYPE_AR2312;
1925 + /* Everything else is probably AR5312 or compatible */
1927 + ar231x_devtype = DEV_TYPE_AR5312;
1929 + /* fixup flash width */
1930 + fctl = ar231x_read_reg(AR531X_FLASHCTL) & FLASHCTL_MW;
1932 + case FLASHCTL_MWx16:
1933 + ar5312_flash_data.width = 2;
1935 + case FLASHCTL_MWx8:
1937 + ar5312_flash_data.width = 1;
1941 + platform_device_register(&ar5312_physmap_flash);
1943 +#ifdef CONFIG_LEDS_GPIO
1944 + ar5312_leds[0].gpio = config->sysLedGpio;
1945 + platform_device_register(&ar5312_gpio_leds);
1948 + /* Fix up MAC addresses if necessary */
1949 + if (!memcmp(config->enet0_mac, "\xff\xff\xff\xff\xff\xff", 6))
1950 + memcpy(config->enet0_mac, config->enet1_mac, 6);
1952 + /* If ENET0 and ENET1 have the same mac address,
1953 + * increment the one from ENET1 */
1954 + if (memcmp(config->enet0_mac, config->enet1_mac, 6) == 0) {
1955 + c = config->enet1_mac + 5;
1956 + while ((c >= config->enet1_mac) && !(++(*c)))
1960 + switch(ar231x_devtype) {
1961 + case DEV_TYPE_AR5312:
1962 + ar5312_eth0_data.macaddr = config->enet0_mac;
1963 + ar231x_add_ethernet(0, KSEG1ADDR(AR531X_ENET0),
1964 + AR5312_IRQ_ENET0_INTRS, &ar5312_eth0_data);
1966 + ar5312_eth1_data.macaddr = config->enet1_mac;
1967 + ar231x_add_ethernet(1, KSEG1ADDR(AR531X_ENET1),
1968 + AR5312_IRQ_ENET1_INTRS, &ar5312_eth1_data);
1970 + if (!ar231x_board.radio)
1973 + if (*((u32 *) radio) & AR531X_RADIO0_MASK)
1974 + ar231x_add_wmac(0, AR531X_WLAN0,
1975 + AR5312_IRQ_WLAN0_INTRS);
1979 + * AR2312/3 ethernet uses the PHY of ENET0, but the MAC
1980 + * of ENET1. Atheros calls it 'twisted' for a reason :)
1982 + case DEV_TYPE_AR2312:
1983 + case DEV_TYPE_AR2313:
1984 + ar5312_eth1_data.phy_base = ar5312_eth0_data.phy_base;
1985 + ar5312_eth1_data.reset_phy = ar5312_eth0_data.reset_phy;
1986 + ar5312_eth1_data.macaddr = config->enet0_mac;
1987 + ar231x_add_ethernet(0, KSEG1ADDR(AR531X_ENET1),
1988 + AR5312_IRQ_ENET1_INTRS, &ar5312_eth1_data);
1990 + if (!ar231x_board.radio)
1997 + if (*((u32 *) radio) & AR531X_RADIO1_MASK)
1998 + ar231x_add_wmac(1, AR531X_WLAN1,
1999 + AR5312_IRQ_WLAN1_INTRS);
2005 +static void ar5312_restart(char *command)
2007 + /* reset the system */
2008 + local_irq_disable();
2010 + ar231x_write_reg(AR531X_RESET, AR531X_RESET_SYSTEM);
2016 + * This table is indexed by bits 5..4 of the CLOCKCTL1 register
2017 + * to determine the predevisor value.
2019 +static int __initdata CLOCKCTL1_PREDIVIDE_TABLE[4] = { 1, 2, 4, 5 };
2023 +ar5312_cpu_frequency(void)
2025 + unsigned int result;
2026 + unsigned int predivide_mask, predivide_shift;
2027 + unsigned int multiplier_mask, multiplier_shift;
2028 + unsigned int clockCtl1, preDivideSelect, preDivisor, multiplier;
2029 + unsigned int doubler_mask;
2032 + /* Trust the bootrom's idea of cpu frequency. */
2033 + if ((result = ar231x_read_reg(AR5312_SCRATCH)))
2036 + devid = ar231x_read_reg(AR531X_REV);
2037 + devid &= AR531X_REV_MAJ;
2038 + devid >>= AR531X_REV_MAJ_S;
2039 + if (devid == AR531X_REV_MAJ_AR2313) {
2040 + predivide_mask = AR2313_CLOCKCTL1_PREDIVIDE_MASK;
2041 + predivide_shift = AR2313_CLOCKCTL1_PREDIVIDE_SHIFT;
2042 + multiplier_mask = AR2313_CLOCKCTL1_MULTIPLIER_MASK;
2043 + multiplier_shift = AR2313_CLOCKCTL1_MULTIPLIER_SHIFT;
2044 + doubler_mask = AR2313_CLOCKCTL1_DOUBLER_MASK;
2045 + } else { /* AR5312 and AR2312 */
2046 + predivide_mask = AR5312_CLOCKCTL1_PREDIVIDE_MASK;
2047 + predivide_shift = AR5312_CLOCKCTL1_PREDIVIDE_SHIFT;
2048 + multiplier_mask = AR5312_CLOCKCTL1_MULTIPLIER_MASK;
2049 + multiplier_shift = AR5312_CLOCKCTL1_MULTIPLIER_SHIFT;
2050 + doubler_mask = AR5312_CLOCKCTL1_DOUBLER_MASK;
2054 + * Clocking is derived from a fixed 40MHz input clock.
2056 + * cpuFreq = InputClock * MULT (where MULT is PLL multiplier)
2057 + * sysFreq = cpuFreq / 4 (used for APB clock, serial,
2058 + * flash, Timer, Watchdog Timer)
2060 + * cntFreq = cpuFreq / 2 (use for CPU count/compare)
2062 + * So, for example, with a PLL multiplier of 5, we have
2064 + * cpuFreq = 200MHz
2066 + * cntFreq = 100MHz
2068 + * We compute the CPU frequency, based on PLL settings.
2071 + clockCtl1 = ar231x_read_reg(AR5312_CLOCKCTL1);
2072 + preDivideSelect = (clockCtl1 & predivide_mask) >> predivide_shift;
2073 + preDivisor = CLOCKCTL1_PREDIVIDE_TABLE[preDivideSelect];
2074 + multiplier = (clockCtl1 & multiplier_mask) >> multiplier_shift;
2076 + if (clockCtl1 & doubler_mask) {
2077 + multiplier = multiplier << 1;
2079 + return (40000000 / preDivisor) * multiplier;
2083 +ar5312_sys_frequency(void)
2085 + return ar5312_cpu_frequency() / 4;
2089 +ar5312_time_init(void)
2094 + mips_hpt_frequency = ar5312_cpu_frequency() / 2;
2099 +ar5312_prom_init(void)
2101 + u32 memsize, memcfg, bank0AC, bank1AC;
2107 + /* Detect memory size */
2108 + memcfg = ar231x_read_reg(AR531X_MEM_CFG1);
2109 + bank0AC = (memcfg & MEM_CFG1_AC0) >> MEM_CFG1_AC0_S;
2110 + bank1AC = (memcfg & MEM_CFG1_AC1) >> MEM_CFG1_AC1_S;
2111 + memsize = (bank0AC ? (1 << (bank0AC+1)) : 0)
2112 + + (bank1AC ? (1 << (bank1AC+1)) : 0);
2114 + add_memory_region(0, memsize, BOOT_MEM_RAM);
2116 + devid = ar231x_read_reg(AR531X_REV);
2117 + devid >>= AR531X_REV_WMAC_MIN_S;
2118 + devid &= AR531X_REV_CHIP;
2119 + ar231x_board.devid = (u16) devid;
2120 + ar231x_gpiodev = &ar5312_gpiodev;
2124 +ar5312_plat_setup(void)
2129 + /* Clear any lingering AHB errors */
2130 + ar231x_read_reg(AR531X_PROCADDR);
2131 + ar231x_read_reg(AR531X_DMAADDR);
2132 + ar231x_write_reg(AR531X_WD_CTRL, AR531X_WD_CTRL_IGNORE_EXPIRATION);
2134 + _machine_restart = ar5312_restart;
2135 + ar231x_serial_setup(KSEG1ADDR(AR531X_UART0), ar5312_sys_frequency());
2138 Index: linux-2.6.33/arch/mips/ar231x/ar2315.c
2139 ===================================================================
2140 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2141 +++ linux-2.6.33/arch/mips/ar231x/ar2315.c 2010-03-03 12:20:05.558287696 +0100
2144 + * This file is subject to the terms and conditions of the GNU General Public
2145 + * License. See the file "COPYING" in the main directory of this archive
2146 + * for more details.
2148 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
2149 + * Copyright (C) 2006 FON Technology, SL.
2150 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
2151 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
2155 + * Platform devices for Atheros SoCs
2158 +#include <generated/autoconf.h>
2159 +#include <linux/init.h>
2160 +#include <linux/module.h>
2161 +#include <linux/types.h>
2162 +#include <linux/string.h>
2163 +#include <linux/platform_device.h>
2164 +#include <linux/kernel.h>
2165 +#include <linux/reboot.h>
2166 +#include <linux/delay.h>
2167 +#include <linux/leds.h>
2168 +#include <asm/bootinfo.h>
2169 +#include <asm/reboot.h>
2170 +#include <asm/time.h>
2171 +#include <asm/irq.h>
2172 +#include <asm/io.h>
2173 +#include <asm/gpio.h>
2175 +#include <ar231x_platform.h>
2176 +#include <ar2315_regs.h>
2177 +#include <ar231x.h>
2178 +#include "devices.h"
2179 +#include "ar2315.h"
2181 +static u32 gpiointmask = 0, gpiointval = 0;
2183 +static inline void ar2315_gpio_irq(void)
2188 + /* only do one gpio interrupt at a time */
2189 + pend = (ar231x_read_reg(AR2315_GPIO_DI) ^ gpiointval) & gpiointmask;
2192 + bit = fls(pend) - 1;
2193 + pend &= ~(1 << bit);
2194 + gpiointval ^= (1 << bit);
2198 + ar231x_write_reg(AR2315_ISR, AR2315_ISR_GPIO);
2200 + /* Enable interrupt with edge detection */
2201 + if ((ar231x_read_reg(AR2315_GPIO_CR) & AR2315_GPIO_CR_M(bit)) != AR2315_GPIO_CR_I(bit))
2205 + do_IRQ(AR531X_GPIO_IRQ_BASE + bit);
2210 + * Called when an interrupt is received, this function
2211 + * determines exactly which interrupt it was, and it
2212 + * invokes the appropriate handler.
2214 + * Implicitly, we also define interrupt priority by
2215 + * choosing which to dispatch first.
2217 +static asmlinkage void
2218 +ar2315_irq_dispatch(void)
2220 + int pending = read_c0_status() & read_c0_cause();
2222 + if (pending & CAUSEF_IP3)
2223 + do_IRQ(AR2315_IRQ_WLAN0_INTRS);
2224 + else if (pending & CAUSEF_IP4)
2225 + do_IRQ(AR2315_IRQ_ENET0_INTRS);
2226 + else if (pending & CAUSEF_IP2) {
2227 + unsigned int misc_intr = ar231x_read_reg(AR2315_ISR) & ar231x_read_reg(AR2315_IMR);
2229 + if (misc_intr & AR2315_ISR_SPI)
2230 + do_IRQ(AR531X_MISC_IRQ_SPI);
2231 + else if (misc_intr & AR2315_ISR_TIMER)
2232 + do_IRQ(AR531X_MISC_IRQ_TIMER);
2233 + else if (misc_intr & AR2315_ISR_AHB)
2234 + do_IRQ(AR531X_MISC_IRQ_AHB_PROC);
2235 + else if (misc_intr & AR2315_ISR_GPIO)
2236 + ar2315_gpio_irq();
2237 + else if (misc_intr & AR2315_ISR_UART0)
2238 + do_IRQ(AR531X_MISC_IRQ_UART0);
2239 + else if (misc_intr & AR2315_ISR_WD)
2240 + do_IRQ(AR531X_MISC_IRQ_WATCHDOG);
2242 + do_IRQ(AR531X_MISC_IRQ_NONE);
2243 + } else if (pending & CAUSEF_IP7)
2244 + do_IRQ(AR531X_IRQ_CPU_CLOCK);
2247 +static void ar2315_set_gpiointmask(int gpio, int level)
2251 + reg = ar231x_read_reg(AR2315_GPIO_INT);
2252 + reg &= ~(AR2315_GPIO_INT_M | AR2315_GPIO_INT_LVL_M);
2253 + reg |= gpio | AR2315_GPIO_INT_LVL(level);
2254 + ar231x_write_reg(AR2315_GPIO_INT, reg);
2257 +static void ar2315_gpio_intr_enable(unsigned int irq)
2259 + unsigned int gpio = irq - AR531X_GPIO_IRQ_BASE;
2261 + /* Enable interrupt with edge detection */
2262 + if ((ar231x_read_reg(AR2315_GPIO_CR) & AR2315_GPIO_CR_M(gpio)) != AR2315_GPIO_CR_I(gpio))
2265 + gpiointmask |= (1 << gpio);
2266 + ar2315_set_gpiointmask(gpio, 3);
2269 +static unsigned int ar2315_gpio_intr_startup(unsigned int irq)
2271 + unsigned int gpio = irq - AR531X_GPIO_IRQ_BASE;
2273 + /* reconfigure GPIO line as input */
2274 + ar231x_mask_reg(AR2315_GPIO_CR, AR2315_GPIO_CR_M(gpio), AR2315_GPIO_CR_I(gpio));
2275 + ar2315_gpio_intr_enable(irq);
2279 +static void ar2315_gpio_intr_disable(unsigned int irq)
2281 + unsigned int gpio = irq - AR531X_GPIO_IRQ_BASE;
2283 + /* Disable interrupt */
2284 + gpiointmask &= ~(1 << gpio);
2285 + ar2315_set_gpiointmask(gpio, 0);
2289 +ar2315_gpio_intr_end(unsigned int irq)
2291 + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
2292 + ar2315_gpio_intr_enable(irq);
2295 +static struct irq_chip ar2315_gpio_intr_controller = {
2296 + .typename = "AR2315-GPIO",
2297 + .startup = ar2315_gpio_intr_startup,
2298 + .ack = ar2315_gpio_intr_disable,
2299 + .mask_ack = ar2315_gpio_intr_disable,
2300 + .mask = ar2315_gpio_intr_disable,
2301 + .unmask = ar2315_gpio_intr_enable,
2302 + .end = ar2315_gpio_intr_end,
2306 +ar2315_misc_intr_enable(unsigned int irq)
2310 + imr = ar231x_read_reg(AR2315_IMR);
2312 + case AR531X_MISC_IRQ_SPI:
2313 + imr |= AR2315_ISR_SPI;
2315 + case AR531X_MISC_IRQ_TIMER:
2316 + imr |= AR2315_ISR_TIMER;
2318 + case AR531X_MISC_IRQ_AHB_PROC:
2319 + imr |= AR2315_ISR_AHB;
2321 + case AR531X_MISC_IRQ_GPIO:
2322 + imr |= AR2315_ISR_GPIO;
2324 + case AR531X_MISC_IRQ_UART0:
2325 + imr |= AR2315_ISR_UART0;
2327 + case AR531X_MISC_IRQ_WATCHDOG:
2328 + imr |= AR2315_ISR_WD;
2333 + ar231x_write_reg(AR2315_IMR, imr);
2337 +ar2315_misc_intr_disable(unsigned int irq)
2341 + imr = ar231x_read_reg(AR2315_IMR);
2343 + case AR531X_MISC_IRQ_SPI:
2344 + imr &= ~AR2315_ISR_SPI;
2346 + case AR531X_MISC_IRQ_TIMER:
2347 + imr &= ~AR2315_ISR_TIMER;
2349 + case AR531X_MISC_IRQ_AHB_PROC:
2350 + imr &= ~AR2315_ISR_AHB;
2352 + case AR531X_MISC_IRQ_GPIO:
2353 + imr &= ~AR2315_ISR_GPIO;
2355 + case AR531X_MISC_IRQ_UART0:
2356 + imr &= ~AR2315_ISR_UART0;
2358 + case AR531X_MISC_IRQ_WATCHDOG:
2359 + imr &= ~AR2315_ISR_WD;
2364 + ar231x_write_reg(AR2315_IMR, imr);
2368 +ar2315_misc_intr_end(unsigned int irq)
2370 + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
2371 + ar2315_misc_intr_enable(irq);
2375 +static struct irq_chip ar2315_misc_intr_controller = {
2376 + .typename = "AR2315-MISC",
2377 + .ack = ar2315_misc_intr_disable,
2378 + .mask_ack = ar2315_misc_intr_disable,
2379 + .mask = ar2315_misc_intr_disable,
2380 + .unmask = ar2315_misc_intr_enable,
2381 + .end = ar2315_misc_intr_end,
2384 +static irqreturn_t ar2315_ahb_proc_handler(int cpl, void *dev_id)
2386 + ar231x_write_reg(AR2315_AHB_ERR0, AHB_ERROR_DET);
2387 + ar231x_read_reg(AR2315_AHB_ERR1);
2389 + printk(KERN_ERR "AHB fatal error\n");
2390 + machine_restart("AHB error"); /* Catastrophic failure */
2392 + return IRQ_HANDLED;
2395 +static struct irqaction ar2315_ahb_proc_interrupt = {
2396 + .handler = ar2315_ahb_proc_handler,
2397 + .flags = IRQF_DISABLED,
2398 + .name = "ar2315_ahb_proc_interrupt",
2401 +static struct irqaction cascade = {
2402 + .handler = no_action,
2403 + .flags = IRQF_DISABLED,
2404 + .name = "cascade",
2408 +ar2315_irq_init(void)
2415 + ar231x_irq_dispatch = ar2315_irq_dispatch;
2416 + gpiointval = ar231x_read_reg(AR2315_GPIO_DI);
2417 + for (i = 0; i < AR531X_MISC_IRQ_COUNT; i++) {
2418 + int irq = AR531X_MISC_IRQ_BASE + i;
2419 + set_irq_chip_and_handler(irq, &ar2315_misc_intr_controller,
2420 + handle_level_irq);
2422 + for (i = 0; i < AR531X_GPIO_IRQ_COUNT; i++) {
2423 + int irq = AR531X_GPIO_IRQ_BASE + i;
2424 + set_irq_chip_and_handler(irq, &ar2315_gpio_intr_controller,
2425 + handle_level_irq);
2427 + setup_irq(AR531X_MISC_IRQ_GPIO, &cascade);
2428 + setup_irq(AR531X_MISC_IRQ_AHB_PROC, &ar2315_ahb_proc_interrupt);
2429 + setup_irq(AR2315_IRQ_MISC_INTRS, &cascade);
2432 +const struct ar231x_gpiodev ar2315_gpiodev;
2435 +ar2315_gpio_get_output(void)
2438 + reg = ar231x_read_reg(AR2315_GPIO_CR);
2439 + reg &= ar2315_gpiodev.valid_mask;
2444 +ar2315_gpio_set_output(u32 mask, u32 val)
2448 + reg = ar231x_read_reg(AR2315_GPIO_CR);
2451 + ar231x_write_reg(AR2315_GPIO_CR, reg);
2456 +ar2315_gpio_get(void)
2459 + reg = ar231x_read_reg(AR2315_GPIO_DI);
2460 + reg &= ar2315_gpiodev.valid_mask;
2465 +ar2315_gpio_set(u32 mask, u32 value)
2468 + reg = ar231x_read_reg(AR2315_GPIO_DO);
2471 + ar231x_write_reg(AR2315_GPIO_DO, reg);
2475 +const struct ar231x_gpiodev ar2315_gpiodev = {
2476 + .valid_mask = (1 << 22) - 1,
2477 + .get_output = ar2315_gpio_get_output,
2478 + .set_output = ar2315_gpio_set_output,
2479 + .get = ar2315_gpio_get,
2480 + .set = ar2315_gpio_set,
2483 +static struct ar231x_eth ar2315_eth_data = {
2484 + .reset_base = AR2315_RESET,
2485 + .reset_mac = AR2315_RESET_ENET0,
2486 + .reset_phy = AR2315_RESET_EPHY0,
2487 + .phy_base = AR2315_ENET0,
2488 + .config = &ar231x_board,
2491 +static struct resource ar2315_spiflash_res[] = {
2493 + .name = "flash_base",
2494 + .flags = IORESOURCE_MEM,
2495 + .start = KSEG1ADDR(AR2315_SPI_READ),
2496 + .end = KSEG1ADDR(AR2315_SPI_READ) + 0x1000000 - 1,
2499 + .name = "flash_regs",
2500 + .flags = IORESOURCE_MEM,
2501 + .start = 0x11300000,
2502 + .end = 0x11300012,
2506 +static struct platform_device ar2315_spiflash = {
2508 + .name = "spiflash",
2509 + .resource = ar2315_spiflash_res,
2510 + .num_resources = ARRAY_SIZE(ar2315_spiflash_res)
2513 +static struct platform_device ar2315_wdt = {
2515 + .name = "ar2315_wdt",
2518 +#define SPI_FLASH_CTL 0x00
2519 +#define SPI_FLASH_OPCODE 0x04
2520 +#define SPI_FLASH_DATA 0x08
2523 +spiflash_read_reg(int reg)
2525 + return ar231x_read_reg(KSEG1ADDR(AR2315_SPI) + reg);
2529 +spiflash_write_reg(int reg, u32 data)
2531 + ar231x_write_reg(KSEG1ADDR(AR2315_SPI) + reg, data);
2535 +spiflash_wait_status(void)
2540 + reg = spiflash_read_reg(SPI_FLASH_CTL);
2541 + } while (reg & SPI_CTL_BUSY);
2547 +spiflash_probe(void)
2551 + reg = spiflash_wait_status();
2552 + reg &= ~SPI_CTL_TX_RX_CNT_MASK;
2553 + reg |= (1 << 4) | 4 | SPI_CTL_START;
2555 + spiflash_write_reg(SPI_FLASH_OPCODE, 0xab);
2556 + spiflash_write_reg(SPI_FLASH_CTL, reg);
2558 + reg = spiflash_wait_status();
2559 + reg = spiflash_read_reg(SPI_FLASH_DATA);
2566 +#define STM_8MBIT_SIGNATURE 0x13
2567 +#define STM_16MBIT_SIGNATURE 0x14
2568 +#define STM_32MBIT_SIGNATURE 0x15
2569 +#define STM_64MBIT_SIGNATURE 0x16
2570 +#define STM_128MBIT_SIGNATURE 0x17
2573 +ar2315_flash_limit(void)
2575 + u32 flash_size = 0;
2577 + /* probe the flash chip size */
2578 + switch(spiflash_probe()) {
2579 + case STM_8MBIT_SIGNATURE:
2580 + flash_size = 0x00100000;
2582 + case STM_16MBIT_SIGNATURE:
2583 + flash_size = 0x00200000;
2585 + case STM_32MBIT_SIGNATURE:
2586 + flash_size = 0x00400000;
2588 + case STM_64MBIT_SIGNATURE:
2589 + flash_size = 0x00800000;
2591 + case STM_128MBIT_SIGNATURE:
2592 + flash_size = 0x01000000;
2596 + ar2315_spiflash_res[0].end = ar2315_spiflash_res[0].start +
2598 + return (u8 *) ar2315_spiflash_res[0].end + 1;
2601 +#ifdef CONFIG_LEDS_GPIO
2602 +static struct gpio_led ar2315_leds[6];
2603 +static struct gpio_led_platform_data ar2315_led_data = {
2604 + .leds = (void *) ar2315_leds,
2607 +static struct platform_device ar2315_gpio_leds = {
2608 + .name = "leds-gpio",
2611 + .platform_data = (void *) &ar2315_led_data,
2616 +ar2315_init_gpio(void)
2618 + static char led_names[6][6];
2621 + ar2315_led_data.num_leds = 0;
2622 + for(i = 1; i < 8; i++)
2624 + if((i == AR2315_RESET_GPIO) ||
2625 + (i == ar231x_board.config->resetConfigGpio))
2628 + if(i == ar231x_board.config->sysLedGpio)
2629 + strcpy(led_names[led], "wlan");
2631 + sprintf(led_names[led], "gpio%d", i);
2633 + ar2315_leds[led].name = led_names[led];
2634 + ar2315_leds[led].gpio = i;
2635 + ar2315_leds[led].active_low = 0;
2638 + ar2315_led_data.num_leds = led;
2639 + platform_device_register(&ar2315_gpio_leds);
2642 +static inline void ar2315_init_gpio(void)
2648 +ar2315_init_devices(void)
2653 + /* Find board configuration */
2654 + ar231x_find_config(ar2315_flash_limit());
2655 + ar2315_eth_data.macaddr = ar231x_board.config->enet0_mac;
2657 + ar2315_init_gpio();
2658 + platform_device_register(&ar2315_wdt);
2659 + platform_device_register(&ar2315_spiflash);
2660 + ar231x_add_ethernet(0, AR2315_ENET0, AR2315_IRQ_ENET0_INTRS,
2661 + &ar2315_eth_data);
2662 + ar231x_add_wmac(0, AR2315_WLAN0, AR2315_IRQ_WLAN0_INTRS);
2668 +ar2315_restart(char *command)
2670 + void (*mips_reset_vec)(void) = (void *) 0xbfc00000;
2672 + local_irq_disable();
2674 + /* try reset the system via reset control */
2675 + ar231x_write_reg(AR2315_COLD_RESET,AR2317_RESET_SYSTEM);
2677 + /* Cold reset does not work on the AR2315/6, use the GPIO reset bits a workaround.
2678 + * give it some time to attempt a gpio based hardware reset
2679 + * (atheros reference design workaround) */
2680 + gpio_direction_output(AR2315_RESET_GPIO, 0);
2683 + /* Some boards (e.g. Senao EOC-2610) don't implement the reset logic
2684 + * workaround. Attempt to jump to the mips reset location -
2685 + * the boot loader itself might be able to recover the system */
2691 + * This table is indexed by bits 5..4 of the CLOCKCTL1 register
2692 + * to determine the predevisor value.
2694 +static int __initdata CLOCKCTL1_PREDIVIDE_TABLE[4] = { 1, 2, 4, 5 };
2695 +static int __initdata PLLC_DIVIDE_TABLE[5] = { 2, 3, 4, 6, 3 };
2697 +static unsigned int __init
2698 +ar2315_sys_clk(unsigned int clockCtl)
2700 + unsigned int pllcCtrl,cpuDiv;
2701 + unsigned int pllcOut,refdiv,fdiv,divby2;
2702 + unsigned int clkDiv;
2704 + pllcCtrl = ar231x_read_reg(AR2315_PLLC_CTL);
2705 + refdiv = (pllcCtrl & PLLC_REF_DIV_M) >> PLLC_REF_DIV_S;
2706 + refdiv = CLOCKCTL1_PREDIVIDE_TABLE[refdiv];
2707 + fdiv = (pllcCtrl & PLLC_FDBACK_DIV_M) >> PLLC_FDBACK_DIV_S;
2708 + divby2 = (pllcCtrl & PLLC_ADD_FDBACK_DIV_M) >> PLLC_ADD_FDBACK_DIV_S;
2710 + pllcOut = (40000000/refdiv)*(2*divby2)*fdiv;
2713 + /* clkm input selected */
2714 + switch(clockCtl & CPUCLK_CLK_SEL_M) {
2717 + clkDiv = PLLC_DIVIDE_TABLE[(pllcCtrl & PLLC_CLKM_DIV_M) >> PLLC_CLKM_DIV_S];
2720 + clkDiv = PLLC_DIVIDE_TABLE[(pllcCtrl & PLLC_CLKC_DIV_M) >> PLLC_CLKC_DIV_S];
2723 + pllcOut = 40000000;
2727 + cpuDiv = (clockCtl & CPUCLK_CLK_DIV_M) >> CPUCLK_CLK_DIV_S;
2728 + cpuDiv = cpuDiv * 2 ?: 1;
2729 + return (pllcOut/(clkDiv * cpuDiv));
2732 +static inline unsigned int
2733 +ar2315_cpu_frequency(void)
2735 + return ar2315_sys_clk(ar231x_read_reg(AR2315_CPUCLK));
2738 +static inline unsigned int
2739 +ar2315_apb_frequency(void)
2741 + return ar2315_sys_clk(ar231x_read_reg(AR2315_AMBACLK));
2745 +ar2315_time_init(void)
2750 + mips_hpt_frequency = ar2315_cpu_frequency() / 2;
2754 +ar2315_prom_init(void)
2756 + u32 memsize, memcfg, devid;
2761 + memcfg = ar231x_read_reg(AR2315_MEM_CFG);
2762 + memsize = 1 + ((memcfg & SDRAM_DATA_WIDTH_M) >> SDRAM_DATA_WIDTH_S);
2763 + memsize <<= 1 + ((memcfg & SDRAM_COL_WIDTH_M) >> SDRAM_COL_WIDTH_S);
2764 + memsize <<= 1 + ((memcfg & SDRAM_ROW_WIDTH_M) >> SDRAM_ROW_WIDTH_S);
2766 + add_memory_region(0, memsize, BOOT_MEM_RAM);
2768 + /* Detect the hardware based on the device ID */
2769 + devid = ar231x_read_reg(AR2315_SREV) & AR2315_REV_CHIP;
2773 + ar231x_devtype = DEV_TYPE_AR2317;
2776 + ar231x_devtype = DEV_TYPE_AR2315;
2779 + ar231x_gpiodev = &ar2315_gpiodev;
2780 + ar231x_board.devid = devid;
2784 +ar2315_plat_setup(void)
2791 + /* Clear any lingering AHB errors */
2792 + config = read_c0_config();
2793 + write_c0_config(config & ~0x3);
2794 + ar231x_write_reg(AR2315_AHB_ERR0,AHB_ERROR_DET);
2795 + ar231x_read_reg(AR2315_AHB_ERR1);
2796 + ar231x_write_reg(AR2315_WDC, AR2315_WDC_IGNORE_EXPIRATION);
2798 + _machine_restart = ar2315_restart;
2799 + ar231x_serial_setup(KSEG1ADDR(AR2315_UART0), ar2315_apb_frequency());
2801 Index: linux-2.6.33/arch/mips/ar231x/ar2315.h
2802 ===================================================================
2803 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2804 +++ linux-2.6.33/arch/mips/ar231x/ar2315.h 2010-03-03 12:20:05.558287696 +0100
2809 +#ifdef CONFIG_ATHEROS_AR2315
2811 +extern void ar2315_irq_init(void);
2812 +extern int ar2315_init_devices(void);
2813 +extern void ar2315_prom_init(void);
2814 +extern void ar2315_plat_setup(void);
2815 +extern void ar2315_time_init(void);
2819 +static inline void ar2315_irq_init(void)
2823 +static inline int ar2315_init_devices(void)
2828 +static inline void ar2315_prom_init(void)
2832 +static inline void ar2315_plat_setup(void)
2836 +static inline void ar2315_time_init(void)
2843 Index: linux-2.6.33/arch/mips/ar231x/ar5312.h
2844 ===================================================================
2845 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2846 +++ linux-2.6.33/arch/mips/ar231x/ar5312.h 2010-03-03 12:20:05.558287696 +0100
2851 +#ifdef CONFIG_ATHEROS_AR5312
2853 +extern void ar5312_irq_init(void);
2854 +extern int ar5312_init_devices(void);
2855 +extern void ar5312_prom_init(void);
2856 +extern void ar5312_plat_setup(void);
2857 +extern void ar5312_time_init(void);
2858 +extern void ar5312_time_init(void);
2862 +static inline void ar5312_irq_init(void)
2866 +static inline int ar5312_init_devices(void)
2871 +static inline void ar5312_prom_init(void)
2875 +static inline void ar5312_plat_setup(void)
2879 +static inline void ar5312_time_init(void)
2886 Index: linux-2.6.33/arch/mips/include/asm/mach-ar231x/ar231x.h
2887 ===================================================================
2888 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2889 +++ linux-2.6.33/arch/mips/include/asm/mach-ar231x/ar231x.h 2010-03-03 12:20:05.558287696 +0100
2894 +#define AR531X_MISC_IRQ_BASE 0x20
2895 +#define AR531X_GPIO_IRQ_BASE 0x30
2897 +/* Software's idea of interrupts handled by "CPU Interrupt Controller" */
2898 +#define AR531X_IRQ_NONE MIPS_CPU_IRQ_BASE+0
2899 +#define AR531X_IRQ_CPU_CLOCK MIPS_CPU_IRQ_BASE+7 /* C0_CAUSE: 0x8000 */
2901 +/* Miscellaneous interrupts, which share IP6 */
2902 +#define AR531X_MISC_IRQ_NONE AR531X_MISC_IRQ_BASE+0
2903 +#define AR531X_MISC_IRQ_TIMER AR531X_MISC_IRQ_BASE+1
2904 +#define AR531X_MISC_IRQ_AHB_PROC AR531X_MISC_IRQ_BASE+2
2905 +#define AR531X_MISC_IRQ_AHB_DMA AR531X_MISC_IRQ_BASE+3
2906 +#define AR531X_MISC_IRQ_GPIO AR531X_MISC_IRQ_BASE+4
2907 +#define AR531X_MISC_IRQ_UART0 AR531X_MISC_IRQ_BASE+5
2908 +#define AR531X_MISC_IRQ_UART0_DMA AR531X_MISC_IRQ_BASE+6
2909 +#define AR531X_MISC_IRQ_WATCHDOG AR531X_MISC_IRQ_BASE+7
2910 +#define AR531X_MISC_IRQ_LOCAL AR531X_MISC_IRQ_BASE+8
2911 +#define AR531X_MISC_IRQ_SPI AR531X_MISC_IRQ_BASE+9
2912 +#define AR531X_MISC_IRQ_COUNT 10
2914 +/* GPIO Interrupts [0..7], share AR531X_MISC_IRQ_GPIO */
2915 +#define AR531X_GPIO_IRQ_NONE AR531X_GPIO_IRQ_BASE+0
2916 +#define AR531X_GPIO_IRQ(n) AR531X_GPIO_IRQ_BASE+n
2917 +#define AR531X_GPIO_IRQ_COUNT 22
2920 +ar231x_read_reg(u32 reg)
2922 + return __raw_readl((u32 *) KSEG1ADDR(reg));
2926 +ar231x_write_reg(u32 reg, u32 val)
2928 + __raw_writel(val, (u32 *) KSEG1ADDR(reg));
2932 +ar231x_mask_reg(u32 reg, u32 mask, u32 val)
2936 + ret = ar231x_read_reg(reg);
2939 + ar231x_write_reg(reg, ret);
2945 Index: linux-2.6.33/arch/mips/ar231x/devices.h
2946 ===================================================================
2947 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2948 +++ linux-2.6.33/arch/mips/ar231x/devices.h 2010-03-03 12:20:05.558287696 +0100
2950 +#ifndef __AR231X_DEVICES_H
2951 +#define __AR231X_DEVICES_H
2954 + /* handled by ar5312.c */
2959 + /* handled by ar2315.c */
2967 +extern int ar231x_devtype;
2968 +extern struct ar231x_board_config ar231x_board;
2969 +extern asmlinkage void (*ar231x_irq_dispatch)(void);
2971 +extern int ar231x_find_config(u8 *flash_limit);
2972 +extern void ar231x_serial_setup(u32 mapbase, unsigned int uartclk);
2973 +extern int ar231x_add_wmac(int nr, u32 base, int irq);
2974 +extern int ar231x_add_ethernet(int nr, u32 base, int irq, void *pdata);
2976 +static inline bool is_2315(void)
2978 + return (current_cpu_data.cputype == CPU_4KEC);
2981 +static inline bool is_5312(void)
2983 + return !is_2315();
2987 Index: linux-2.6.33/arch/mips/ar231x/devices.c
2988 ===================================================================
2989 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2990 +++ linux-2.6.33/arch/mips/ar231x/devices.c 2010-03-03 12:20:05.558287696 +0100
2992 +#include <linux/kernel.h>
2993 +#include <linux/init.h>
2994 +#include <linux/serial.h>
2995 +#include <linux/serial_core.h>
2996 +#include <linux/serial_8250.h>
2997 +#include <linux/platform_device.h>
2998 +#include <ar231x_platform.h>
2999 +#include <ar231x.h>
3000 +#include "devices.h"
3001 +#include "ar5312.h"
3002 +#include "ar2315.h"
3004 +struct ar231x_board_config ar231x_board;
3005 +int ar231x_devtype = DEV_TYPE_UNKNOWN;
3006 +const struct ar231x_gpiodev *ar231x_gpiodev;
3007 +EXPORT_SYMBOL(ar231x_gpiodev);
3009 +static struct resource ar231x_eth0_res[] = {
3011 + .name = "eth0_membase",
3012 + .flags = IORESOURCE_MEM,
3015 + .name = "eth0_irq",
3016 + .flags = IORESOURCE_IRQ,
3020 +static struct resource ar231x_eth1_res[] = {
3022 + .name = "eth1_membase",
3023 + .flags = IORESOURCE_MEM,
3026 + .name = "eth1_irq",
3027 + .flags = IORESOURCE_IRQ,
3031 +static struct platform_device ar231x_eth[] = {
3034 + .name = "ar231x-eth",
3035 + .resource = ar231x_eth0_res,
3036 + .num_resources = ARRAY_SIZE(ar231x_eth0_res)
3040 + .name = "ar231x-eth",
3041 + .resource = ar231x_eth1_res,
3042 + .num_resources = ARRAY_SIZE(ar231x_eth1_res)
3046 +static struct resource ar231x_wmac0_res[] = {
3048 + .name = "wmac0_membase",
3049 + .flags = IORESOURCE_MEM,
3052 + .name = "wmac0_irq",
3053 + .flags = IORESOURCE_IRQ,
3057 +static struct resource ar231x_wmac1_res[] = {
3059 + .name = "wmac1_membase",
3060 + .flags = IORESOURCE_MEM,
3063 + .name = "wmac1_irq",
3064 + .flags = IORESOURCE_IRQ,
3069 +static struct platform_device ar231x_wmac[] = {
3072 + .name = "ar231x-wmac",
3073 + .resource = ar231x_wmac0_res,
3074 + .num_resources = ARRAY_SIZE(ar231x_wmac0_res),
3075 + .dev.platform_data = &ar231x_board,
3079 + .name = "ar231x-wmac",
3080 + .resource = ar231x_wmac1_res,
3081 + .num_resources = ARRAY_SIZE(ar231x_wmac1_res),
3082 + .dev.platform_data = &ar231x_board,
3086 +static const char *devtype_strings[] = {
3087 + [DEV_TYPE_AR5312] = "Atheros AR5312",
3088 + [DEV_TYPE_AR2312] = "Atheros AR2312",
3089 + [DEV_TYPE_AR2313] = "Atheros AR2313",
3090 + [DEV_TYPE_AR2315] = "Atheros AR2315",
3091 + [DEV_TYPE_AR2316] = "Atheros AR2316",
3092 + [DEV_TYPE_AR2317] = "Atheros AR2317",
3093 + [DEV_TYPE_UNKNOWN] = "Atheros (unknown)",
3096 +const char *get_system_type(void)
3098 + if ((ar231x_devtype >= ARRAY_SIZE(devtype_strings)) ||
3099 + !devtype_strings[ar231x_devtype])
3100 + return devtype_strings[DEV_TYPE_UNKNOWN];
3101 + return devtype_strings[ar231x_devtype];
3106 +ar231x_add_ethernet(int nr, u32 base, int irq, void *pdata)
3108 + struct resource *res;
3110 + ar231x_eth[nr].dev.platform_data = pdata;
3111 + res = &ar231x_eth[nr].resource[0];
3112 + res->start = base;
3113 + res->end = base + 0x2000 - 1;
3117 + return platform_device_register(&ar231x_eth[nr]);
3121 +ar231x_serial_setup(u32 mapbase, unsigned int uartclk)
3123 + struct uart_port s;
3125 + memset(&s, 0, sizeof(s));
3127 + s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
3128 + s.iotype = UPIO_MEM;
3129 + s.irq = AR531X_MISC_IRQ_UART0;
3131 + s.mapbase = mapbase;
3132 + s.uartclk = uartclk;
3133 + s.membase = (void __iomem *)s.mapbase;
3135 + early_serial_setup(&s);
3139 +ar231x_add_wmac(int nr, u32 base, int irq)
3141 + struct resource *res;
3143 + ar231x_wmac[nr].dev.platform_data = &ar231x_board;
3144 + res = &ar231x_wmac[nr].resource[0];
3145 + res->start = base;
3146 + res->end = base + 0x10000 - 1;
3150 + return platform_device_register(&ar231x_wmac[nr]);
3153 +static int __init ar231x_register_devices(void)
3155 + static struct resource res = {
3156 + .start = 0xFFFFFFFF,
3159 + platform_device_register_simple("GPIODEV", 0, &res, 1);
3160 + ar5312_init_devices();
3161 + ar2315_init_devices();
3166 +device_initcall(ar231x_register_devices);