1 --- a/arch/mips/Kconfig
2 +++ b/arch/mips/Kconfig
3 @@ -120,6 +120,19 @@ config BCM63XX
5 Support for BCM63XX based boards
8 + bool "Atheros 231x/531x SoC support"
11 + select DMA_NONCOHERENT
13 + select SYS_HAS_CPU_MIPS32_R1
14 + select SYS_SUPPORTS_BIG_ENDIAN
15 + select SYS_SUPPORTS_32BIT_KERNEL
16 + select ARCH_REQUIRE_GPIOLIB
18 + Support for AR231x and AR531x based boards
23 @@ -813,6 +826,7 @@ config NLM_XLP_BOARD
27 +source "arch/mips/ar231x/Kconfig"
28 source "arch/mips/alchemy/Kconfig"
29 source "arch/mips/ath79/Kconfig"
30 source "arch/mips/bcm47xx/Kconfig"
31 --- a/arch/mips/Kbuild.platforms
32 +++ b/arch/mips/Kbuild.platforms
33 @@ -6,6 +6,7 @@ platforms += ath79
36 platforms += cavium-octeon
42 +++ b/arch/mips/ar231x/Platform
45 +# Atheros AR5312/AR2312 WiSoC
47 +platform-$(CONFIG_ATHEROS_AR231X) += ar231x/
48 +cflags-$(CONFIG_ATHEROS_AR231X) += -I$(srctree)/arch/mips/include/asm/mach-ar231x
49 +load-$(CONFIG_ATHEROS_AR231X) += 0xffffffff80041000
51 +++ b/arch/mips/ar231x/Kconfig
53 +config ATHEROS_AR5312
54 + bool "Atheros 5312/2312+ support"
55 + depends on ATHEROS_AR231X
58 +config ATHEROS_AR2315
59 + bool "Atheros 2315+ support"
60 + depends on ATHEROS_AR231X
61 + select DMA_NONCOHERENT
65 + select SYS_HAS_CPU_MIPS32_R1
66 + select SYS_SUPPORTS_32BIT_KERNEL
67 + select SYS_SUPPORTS_BIG_ENDIAN
70 +++ b/arch/mips/ar231x/Makefile
73 +# This file is subject to the terms and conditions of the GNU General Public
74 +# License. See the file "COPYING" in the main directory of this archive
77 +# Copyright (C) 2006 FON Technology, SL.
78 +# Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
79 +# Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
82 +obj-y += board.o prom.o devices.o
83 +obj-$(CONFIG_ATHEROS_AR5312) += ar5312.o
84 +obj-$(CONFIG_ATHEROS_AR2315) += ar2315.o
86 +++ b/arch/mips/ar231x/board.c
89 + * This file is subject to the terms and conditions of the GNU General Public
90 + * License. See the file "COPYING" in the main directory of this archive
93 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
94 + * Copyright (C) 2006 FON Technology, SL.
95 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
96 + * Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
99 +#include <generated/autoconf.h>
100 +#include <linux/init.h>
101 +#include <linux/module.h>
102 +#include <linux/types.h>
103 +#include <linux/string.h>
104 +#include <linux/platform_device.h>
105 +#include <linux/kernel.h>
106 +#include <linux/random.h>
107 +#include <linux/etherdevice.h>
108 +#include <linux/irq.h>
109 +#include <asm/irq_cpu.h>
110 +#include <asm/reboot.h>
113 +#include <ar231x_platform.h>
114 +#include "devices.h"
118 +void (*ar231x_irq_dispatch)(void);
121 +check_radio_magic(u8 *addr)
123 + addr += 0x7a; /* offset for flash magic */
124 + if ((addr[0] == 0x5a) && (addr[1] == 0xa5)) {
131 +check_board_data(u8 *flash_limit, u8 *addr, bool broken)
133 + /* config magic found */
134 + if (*((u32 *)addr) == AR531X_BD_MAGIC)
140 + if (check_radio_magic(addr + 0xf8))
141 + ar231x_board.radio = addr + 0xf8;
142 + if ((addr < flash_limit + 0x10000) &&
143 + check_radio_magic(addr + 0x10000))
144 + ar231x_board.radio = addr + 0x10000;
146 + if (ar231x_board.radio) {
147 + /* broken board data detected, use radio data to find the offset,
148 + * user will fix this */
155 +find_board_config(u8 *flash_limit, bool broken)
160 + for (addr = flash_limit - 0x1000;
161 + addr >= flash_limit - 0x30000;
164 + if (check_board_data(flash_limit, addr, broken)) {
177 +find_radio_config(u8 *flash_limit, u8 *board_config)
183 + * Now find the start of Radio Configuration data, using heuristics:
184 + * Search forward from Board Configuration data by 0x1000 bytes
185 + * at a time until we find non-0xffffffff.
188 + for (radio_config = board_config + 0x1000;
189 + (radio_config < flash_limit);
190 + radio_config += 0x1000) {
191 + if ((*(u32 *)radio_config != 0xffffffff) &&
192 + check_radio_magic(radio_config)) {
198 + /* AR2316 relocates radio config to new location */
200 + for (radio_config = board_config + 0xf8;
201 + (radio_config < flash_limit - 0x1000 + 0xf8);
202 + radio_config += 0x1000) {
203 + if ((*(u32 *)radio_config != 0xffffffff) &&
204 + check_radio_magic(radio_config)) {
212 + printk("Could not find Radio Configuration data\n");
216 + return (u8 *) radio_config;
220 +ar231x_find_config(u8 *flash_limit)
222 + struct ar231x_boarddata *config;
223 + unsigned int rcfg_size;
224 + int broken_boarddata = 0;
231 + ar231x_board.config = NULL;
232 + ar231x_board.radio = NULL;
233 + /* Copy the board and radio data to RAM, because accessing the mapped
234 + * memory of the flash directly after booting is not safe */
236 + /* Try to find valid board and radio data */
237 + bcfg = find_board_config(flash_limit, false);
239 + /* If that fails, try to at least find valid radio data */
241 + bcfg = find_board_config(flash_limit, true);
242 + broken_boarddata = 1;
246 + printk(KERN_WARNING "WARNING: No board configuration data found!\n");
250 + board_data = kzalloc(BOARD_CONFIG_BUFSZ, GFP_KERNEL);
251 + ar231x_board.config = (struct ar231x_boarddata *) board_data;
252 + memcpy(board_data, bcfg, 0x100);
253 + if (broken_boarddata) {
254 + printk(KERN_WARNING "WARNING: broken board data detected\n");
255 + config = ar231x_board.config;
256 + if (!memcmp(config->enet0_mac, "\x00\x00\x00\x00\x00\x00", 6)) {
257 + printk(KERN_INFO "Fixing up empty mac addresses\n");
258 + config->resetConfigGpio = 0xffff;
259 + config->sysLedGpio = 0xffff;
260 + random_ether_addr(config->wlan0_mac);
261 + config->wlan0_mac[0] &= ~0x06;
262 + random_ether_addr(config->enet0_mac);
263 + random_ether_addr(config->enet1_mac);
268 + /* Radio config starts 0x100 bytes after board config, regardless
269 + * of what the physical layout on the flash chip looks like */
271 + if (ar231x_board.radio)
272 + rcfg = (u8 *) ar231x_board.radio;
274 + rcfg = find_radio_config(flash_limit, bcfg);
279 + radio_data = board_data + 0x100 + ((rcfg - bcfg) & 0xfff);
280 + ar231x_board.radio = radio_data;
281 + offset = radio_data - board_data;
282 + printk(KERN_INFO "Radio config found at offset 0x%x(0x%x)\n", rcfg - bcfg, offset);
283 + rcfg_size = BOARD_CONFIG_BUFSZ - offset;
284 + memcpy(radio_data, rcfg, rcfg_size);
286 + mac_addr = &radio_data[0x1d * 2];
287 + if (is_broadcast_ether_addr(mac_addr)) {
288 + printk(KERN_INFO "Radio MAC is blank; using board-data\n");
289 + memcpy(mac_addr, ar231x_board.config->wlan0_mac, ETH_ALEN);
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 */
348 +++ b/arch/mips/ar231x/prom.c
351 + * This file is subject to the terms and conditions of the GNU General Public
352 + * License. See the file "COPYING" in the main directory of this archive
353 + * for more details.
355 + * Copyright MontaVista Software Inc
356 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
357 + * Copyright (C) 2006 FON Technology, SL.
358 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
359 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
363 + * Prom setup file for ar531x
366 +#include <linux/init.h>
367 +#include <generated/autoconf.h>
368 +#include <linux/kernel.h>
369 +#include <linux/string.h>
370 +#include <linux/mm.h>
371 +#include <linux/bootmem.h>
373 +#include <asm/bootinfo.h>
374 +#include <asm/addrspace.h>
378 +void __init prom_init(void)
380 + ar5312_prom_init();
381 + ar2315_prom_init();
384 +void __init prom_free_prom_memory(void)
388 +++ b/arch/mips/include/asm/mach-ar231x/ar231x_platform.h
390 +#ifndef __AR531X_PLATFORM_H
391 +#define __AR531X_PLATFORM_H
394 + * This is board-specific data that is stored in a "fixed" location in flash.
395 + * It is shared across operating systems, so it should not be changed lightly.
396 + * The main reason we need it is in order to extract the ethernet MAC
399 +struct ar231x_boarddata {
400 + u32 magic; /* board data is valid */
401 +#define AR531X_BD_MAGIC 0x35333131 /* "5311", for all 531x platforms */
402 + u16 cksum; /* checksum (starting with BD_REV 2) */
403 + u16 rev; /* revision of this struct */
405 + char boardName[64]; /* Name of board */
406 + u16 major; /* Board major number */
407 + u16 minor; /* Board minor number */
408 + u32 flags; /* Board configuration */
409 +#define BD_ENET0 0x00000001 /* ENET0 is stuffed */
410 +#define BD_ENET1 0x00000002 /* ENET1 is stuffed */
411 +#define BD_UART1 0x00000004 /* UART1 is stuffed */
412 +#define BD_UART0 0x00000008 /* UART0 is stuffed (dma) */
413 +#define BD_RSTFACTORY 0x00000010 /* Reset factory defaults stuffed */
414 +#define BD_SYSLED 0x00000020 /* System LED stuffed */
415 +#define BD_EXTUARTCLK 0x00000040 /* External UART clock */
416 +#define BD_CPUFREQ 0x00000080 /* cpu freq is valid in nvram */
417 +#define BD_SYSFREQ 0x00000100 /* sys freq is set in nvram */
418 +#define BD_WLAN0 0x00000200 /* Enable WLAN0 */
419 +#define BD_MEMCAP 0x00000400 /* CAP SDRAM @ memCap for testing */
420 +#define BD_DISWATCHDOG 0x00000800 /* disable system watchdog */
421 +#define BD_WLAN1 0x00001000 /* Enable WLAN1 (ar5212) */
422 +#define BD_ISCASPER 0x00002000 /* FLAG for AR2312 */
423 +#define BD_WLAN0_2G_EN 0x00004000 /* FLAG for radio0_2G */
424 +#define BD_WLAN0_5G_EN 0x00008000 /* FLAG for radio0_2G */
425 +#define BD_WLAN1_2G_EN 0x00020000 /* FLAG for radio0_2G */
426 +#define BD_WLAN1_5G_EN 0x00040000 /* FLAG for radio0_2G */
427 + u16 resetConfigGpio; /* Reset factory GPIO pin */
428 + u16 sysLedGpio; /* System LED GPIO pin */
430 + u32 cpuFreq; /* CPU core frequency in Hz */
431 + u32 sysFreq; /* System frequency in Hz */
432 + u32 cntFreq; /* Calculated C0_COUNT frequency */
438 + u16 pciId; /* Pseudo PCIID for common code */
439 + u16 memCap; /* cap bank1 in MB */
442 + u8 wlan1_mac[6]; /* (ar5212) */
445 +#define BOARD_CONFIG_BUFSZ 0x1000
448 + * Platform device information for the Wireless MAC
450 +struct ar231x_board_config {
453 + /* board config data */
454 + struct ar231x_boarddata *config;
456 + /* radio calibration data */
461 + * Platform device information for the Ethernet MAC
468 + struct ar231x_board_config *config;
472 +#endif /* __AR531X_PLATFORM_H */
474 +++ b/arch/mips/include/asm/mach-ar231x/cpu-feature-overrides.h
477 + * Atheros SoC specific CPU feature overrides
479 + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
481 + * This file was derived from: include/asm-mips/cpu-features.h
482 + * Copyright (C) 2003, 2004 Ralf Baechle
483 + * Copyright (C) 2004 Maciej W. Rozycki
485 + * This program is free software; you can redistribute it and/or modify it
486 + * under the terms of the GNU General Public License version 2 as published
487 + * by the Free Software Foundation.
490 +#ifndef __ASM_MACH_ATHEROS_CPU_FEATURE_OVERRIDES_H
491 +#define __ASM_MACH_ATHEROS_CPU_FEATURE_OVERRIDES_H
494 + * The ATHEROS SoCs have MIPS 4Kc/4KEc core.
496 +#define cpu_has_tlb 1
497 +#define cpu_has_4kex 1
498 +#define cpu_has_3k_cache 0
499 +#define cpu_has_4k_cache 1
500 +#define cpu_has_tx39_cache 0
501 +#define cpu_has_sb1_cache 0
502 +#define cpu_has_fpu 0
503 +#define cpu_has_32fpr 0
504 +#define cpu_has_counter 1
505 +/* #define cpu_has_watch ? */
506 +/* #define cpu_has_divec ? */
507 +/* #define cpu_has_vce ? */
508 +/* #define cpu_has_cache_cdex_p ? */
509 +/* #define cpu_has_cache_cdex_s ? */
510 +/* #define cpu_has_prefetch ? */
511 +/* #define cpu_has_mcheck ? */
512 +#define cpu_has_ejtag 1
514 +#if !defined(CONFIG_ATHEROS_AR5312)
515 +# define cpu_has_llsc 1
518 + * The MIPS 4Kc V0.9 core in the AR5312/AR2312 have problems with the
519 + * ll/sc instructions.
521 +# define cpu_has_llsc 0
524 +#define cpu_has_mips16 0
525 +#define cpu_has_mdmx 0
526 +#define cpu_has_mips3d 0
527 +#define cpu_has_smartmips 0
529 +/* #define cpu_has_vtag_icache ? */
530 +/* #define cpu_has_dc_aliases ? */
531 +/* #define cpu_has_ic_fills_f_dc ? */
532 +/* #define cpu_has_pindexed_dcache ? */
534 +/* #define cpu_icache_snoops_remote_store ? */
536 +#define cpu_has_mips32r1 1
538 +#if !defined(CONFIG_ATHEROS_AR5312)
539 +# define cpu_has_mips32r2 1
542 +#define cpu_has_mips64r1 0
543 +#define cpu_has_mips64r2 0
545 +#define cpu_has_dsp 0
546 +#define cpu_has_mipsmt 0
548 +/* #define cpu_has_nofpuex ? */
549 +#define cpu_has_64bits 0
550 +#define cpu_has_64bit_zero_reg 0
551 +#define cpu_has_64bit_gp_regs 0
552 +#define cpu_has_64bit_addresses 0
554 +/* #define cpu_has_inclusive_pcaches ? */
556 +/* #define cpu_dcache_line_size() ? */
557 +/* #define cpu_icache_line_size() ? */
559 +#endif /* __ASM_MACH_ATHEROS_CPU_FEATURE_OVERRIDES_H */
561 +++ b/arch/mips/include/asm/mach-ar231x/dma-coherence.h
564 + * This file is subject to the terms and conditions of the GNU General Public
565 + * License. See the file "COPYING" in the main directory of this archive
566 + * for more details.
568 + * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
569 + * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org>
572 +#ifndef __ASM_MACH_GENERIC_DMA_COHERENCE_H
573 +#define __ASM_MACH_GENERIC_DMA_COHERENCE_H
575 +#define PCI_DMA_OFFSET 0x20000000
577 +#include <linux/device.h>
579 +static inline dma_addr_t ar231x_dev_offset(struct device *dev)
582 + extern struct bus_type pci_bus_type;
584 + if (dev && dev->bus == &pci_bus_type)
585 + return PCI_DMA_OFFSET;
591 +static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size)
593 + return virt_to_phys(addr) + ar231x_dev_offset(dev);
596 +static inline dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
598 + return page_to_phys(page) + ar231x_dev_offset(dev);
601 +static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
602 + dma_addr_t dma_addr)
604 + return dma_addr - ar231x_dev_offset(dev);
607 +static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
608 + size_t size, enum dma_data_direction direction)
612 +static inline int plat_dma_supported(struct device *dev, u64 mask)
617 +static inline void plat_extra_sync_for_device(struct device *dev)
622 +static inline int plat_dma_mapping_error(struct device *dev,
623 + dma_addr_t dma_addr)
628 +static inline int plat_device_is_coherent(struct device *dev)
630 +#ifdef CONFIG_DMA_COHERENT
633 +#ifdef CONFIG_DMA_NONCOHERENT
638 +#endif /* __ASM_MACH_GENERIC_DMA_COHERENCE_H */
640 +++ b/arch/mips/include/asm/mach-ar231x/gpio.h
642 +#ifndef _ATHEROS_GPIO_H_
643 +#define _ATHEROS_GPIO_H_
647 +#define gpio_get_value __gpio_get_value
648 +#define gpio_set_value __gpio_set_value
649 +#define gpio_cansleep __gpio_cansleep
652 + * Wrappers for the generic GPIO layer
655 +/* not sure if these are used? */
657 +/* Returns IRQ to attach for gpio. Unchecked function */
658 +static inline int gpio_to_irq(unsigned gpio) {
659 + return AR531X_GPIO_IRQ(gpio);
662 +/* Returns gpio for IRQ attached. Unchecked function */
663 +static inline int irq_to_gpio(unsigned irq) {
664 + return (irq - (AR531X_GPIO_IRQ(0)));
667 +#include <asm-generic/gpio.h> /* cansleep wrappers */
671 +++ b/arch/mips/include/asm/mach-ar231x/reset.h
673 +#ifndef __AR531X_RESET_H
674 +#define __AR531X_RESET_H
676 +void ar531x_disable_reset_button(void);
678 +#endif /* __AR531X_RESET_H */
680 +++ b/arch/mips/include/asm/mach-ar231x/war.h
683 + * This file is subject to the terms and conditions of the GNU General Public
684 + * License. See the file "COPYING" in the main directory of this archive
685 + * for more details.
687 + * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
689 +#ifndef __ASM_MIPS_MACH_ATHEROS_WAR_H
690 +#define __ASM_MIPS_MACH_ATHEROS_WAR_H
692 +#define R4600_V1_INDEX_ICACHEOP_WAR 0
693 +#define R4600_V1_HIT_CACHEOP_WAR 0
694 +#define R4600_V2_HIT_CACHEOP_WAR 0
695 +#define R5432_CP0_INTERRUPT_WAR 0
696 +#define BCM1250_M3_WAR 0
697 +#define SIBYTE_1956_WAR 0
698 +#define MIPS4K_ICACHE_REFILL_WAR 0
699 +#define MIPS_CACHE_SYNC_WAR 0
700 +#define TX49XX_ICACHE_INDEX_INV_WAR 0
701 +#define RM9000_CDEX_SMP_WAR 0
702 +#define ICACHE_REFILLS_WORKAROUND_WAR 0
703 +#define R10000_LLSC_WAR 0
704 +#define MIPS34K_MISSED_ITLB_WAR 0
706 +#endif /* __ASM_MIPS_MACH_ATHEROS_WAR_H */
708 +++ b/arch/mips/include/asm/mach-ar231x/ar2315_regs.h
711 + * Register definitions for AR2315+
713 + * This file is subject to the terms and conditions of the GNU General Public
714 + * License. See the file "COPYING" in the main directory of this archive
715 + * for more details.
717 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
718 + * Copyright (C) 2006 FON Technology, SL.
719 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
720 + * Copyright (C) 2006-2008 Felix Fietkau <nbd@openwrt.org>
723 +#ifndef __AR2315_REG_H
724 +#define __AR2315_REG_H
729 +#define AR2315_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
730 +#define AR2315_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
731 +#define AR2315_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
732 +#define AR2315_IRQ_LCBUS_PCI MIPS_CPU_IRQ_BASE+5 /* C0_CAUSE: 0x2000 */
733 +#define AR2315_IRQ_WLAN0_POLL MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
738 +#define AR2315_SPI_READ 0x08000000 /* SPI FLASH */
739 +#define AR2315_WLAN0 0x10000000 /* Wireless MMR */
740 +#define AR2315_PCI 0x10100000 /* PCI MMR */
741 +#define AR2315_SDRAMCTL 0x10300000 /* SDRAM MMR */
742 +#define AR2315_LOCAL 0x10400000 /* LOCAL BUS MMR */
743 +#define AR2315_ENET0 0x10500000 /* ETHERNET MMR */
744 +#define AR2315_DSLBASE 0x11000000 /* RESET CONTROL MMR */
745 +#define AR2315_UART0 0x11100003 /* UART MMR */
746 +#define AR2315_SPI 0x11300000 /* SPI FLASH MMR */
747 +#define AR2315_PCIEXT 0x80000000 /* pci external */
752 +#define AR2315_COLD_RESET (AR2315_DSLBASE + 0x0000)
754 +#define AR2315_RESET_COLD_AHB 0x00000001
755 +#define AR2315_RESET_COLD_APB 0x00000002
756 +#define AR2315_RESET_COLD_CPU 0x00000004
757 +#define AR2315_RESET_COLD_CPUWARM 0x00000008
758 +#define AR2315_RESET_SYSTEM (RESET_COLD_CPU | RESET_COLD_APB | RESET_COLD_AHB) /* full system */
759 +#define AR2317_RESET_SYSTEM 0x00000010
762 +#define AR2315_RESET (AR2315_DSLBASE + 0x0004)
764 +#define AR2315_RESET_WARM_WLAN0_MAC 0x00000001 /* warm reset WLAN0 MAC */
765 +#define AR2315_RESET_WARM_WLAN0_BB 0x00000002 /* warm reset WLAN0 BaseBand */
766 +#define AR2315_RESET_MPEGTS_RSVD 0x00000004 /* warm reset MPEG-TS */
767 +#define AR2315_RESET_PCIDMA 0x00000008 /* warm reset PCI ahb/dma */
768 +#define AR2315_RESET_MEMCTL 0x00000010 /* warm reset memory controller */
769 +#define AR2315_RESET_LOCAL 0x00000020 /* warm reset local bus */
770 +#define AR2315_RESET_I2C_RSVD 0x00000040 /* warm reset I2C bus */
771 +#define AR2315_RESET_SPI 0x00000080 /* warm reset SPI interface */
772 +#define AR2315_RESET_UART0 0x00000100 /* warm reset UART0 */
773 +#define AR2315_RESET_IR_RSVD 0x00000200 /* warm reset IR interface */
774 +#define AR2315_RESET_EPHY0 0x00000400 /* cold reset ENET0 phy */
775 +#define AR2315_RESET_ENET0 0x00000800 /* cold reset ENET0 mac */
778 + * AHB master arbitration control
780 +#define AR2315_AHB_ARB_CTL (AR2315_DSLBASE + 0x0008)
782 +#define AR2315_ARB_CPU 0x00000001 /* CPU, default */
783 +#define AR2315_ARB_WLAN 0x00000002 /* WLAN */
784 +#define AR2315_ARB_MPEGTS_RSVD 0x00000004 /* MPEG-TS */
785 +#define AR2315_ARB_LOCAL 0x00000008 /* LOCAL */
786 +#define AR2315_ARB_PCI 0x00000010 /* PCI */
787 +#define AR2315_ARB_ETHERNET 0x00000020 /* Ethernet */
788 +#define AR2315_ARB_RETRY 0x00000100 /* retry policy, debug only */
793 +#define AR2315_ENDIAN_CTL (AR2315_DSLBASE + 0x000c)
795 +#define AR2315_CONFIG_AHB 0x00000001 /* EC - AHB bridge endianess */
796 +#define AR2315_CONFIG_WLAN 0x00000002 /* WLAN byteswap */
797 +#define AR2315_CONFIG_MPEGTS_RSVD 0x00000004 /* MPEG-TS byteswap */
798 +#define AR2315_CONFIG_PCI 0x00000008 /* PCI byteswap */
799 +#define AR2315_CONFIG_MEMCTL 0x00000010 /* Memory controller endianess */
800 +#define AR2315_CONFIG_LOCAL 0x00000020 /* Local bus byteswap */
801 +#define AR2315_CONFIG_ETHERNET 0x00000040 /* Ethernet byteswap */
803 +#define AR2315_CONFIG_MERGE 0x00000200 /* CPU write buffer merge */
804 +#define AR2315_CONFIG_CPU 0x00000400 /* CPU big endian */
805 +#define AR2315_CONFIG_PCIAHB 0x00000800
806 +#define AR2315_CONFIG_PCIAHB_BRIDGE 0x00001000
807 +#define AR2315_CONFIG_SPI 0x00008000 /* SPI byteswap */
808 +#define AR2315_CONFIG_CPU_DRAM 0x00010000
809 +#define AR2315_CONFIG_CPU_PCI 0x00020000
810 +#define AR2315_CONFIG_CPU_MMR 0x00040000
811 +#define AR2315_CONFIG_BIG 0x00000400
817 +#define AR2315_NMI_CTL (AR2315_DSLBASE + 0x0010)
819 +#define AR2315_NMI_EN 1
822 + * Revision Register - Initial value is 0x3010 (WMAC 3.0, AR531X 1.0).
824 +#define AR2315_SREV (AR2315_DSLBASE + 0x0014)
826 +#define AR2315_REV_MAJ 0x00f0
827 +#define AR2315_REV_MAJ_S 4
828 +#define AR2315_REV_MIN 0x000f
829 +#define AR2315_REV_MIN_S 0
830 +#define AR2315_REV_CHIP (AR2315_REV_MAJ|AR2315_REV_MIN)
835 +#define AR2315_IF_CTL (AR2315_DSLBASE + 0x0018)
837 +#define AR2315_IF_MASK 0x00000007
838 +#define AR2315_IF_DISABLED 0
839 +#define AR2315_IF_PCI 1
840 +#define AR2315_IF_TS_LOCAL 2
841 +#define AR2315_IF_ALL 3 /* only for emulation with separate pins */
842 +#define AR2315_IF_LOCAL_HOST 0x00000008
843 +#define AR2315_IF_PCI_HOST 0x00000010
844 +#define AR2315_IF_PCI_INTR 0x00000020
845 +#define AR2315_IF_PCI_CLK_MASK 0x00030000
846 +#define AR2315_IF_PCI_CLK_INPUT 0
847 +#define AR2315_IF_PCI_CLK_OUTPUT_LOW 1
848 +#define AR2315_IF_PCI_CLK_OUTPUT_CLK 2
849 +#define AR2315_IF_PCI_CLK_OUTPUT_HIGH 3
850 +#define AR2315_IF_PCI_CLK_SHIFT 16
853 + * APB Interrupt control
856 +#define AR2315_ISR (AR2315_DSLBASE + 0x0020)
857 +#define AR2315_IMR (AR2315_DSLBASE + 0x0024)
858 +#define AR2315_GISR (AR2315_DSLBASE + 0x0028)
860 +#define AR2315_ISR_UART0 0x0001 /* high speed UART */
861 +#define AR2315_ISR_I2C_RSVD 0x0002 /* I2C bus */
862 +#define AR2315_ISR_SPI 0x0004 /* SPI bus */
863 +#define AR2315_ISR_AHB 0x0008 /* AHB error */
864 +#define AR2315_ISR_APB 0x0010 /* APB error */
865 +#define AR2315_ISR_TIMER 0x0020 /* timer */
866 +#define AR2315_ISR_GPIO 0x0040 /* GPIO */
867 +#define AR2315_ISR_WD 0x0080 /* watchdog */
868 +#define AR2315_ISR_IR_RSVD 0x0100 /* IR */
870 +#define AR2315_GISR_MISC 0x0001
871 +#define AR2315_GISR_WLAN0 0x0002
872 +#define AR2315_GISR_MPEGTS_RSVD 0x0004
873 +#define AR2315_GISR_LOCALPCI 0x0008
874 +#define AR2315_GISR_WMACPOLL 0x0010
875 +#define AR2315_GISR_TIMER 0x0020
876 +#define AR2315_GISR_ETHERNET 0x0040
879 + * Interrupt routing from IO to the processor IP bits
880 + * Define our inter mask and level
882 +#define AR2315_INTR_MISCIO SR_IBIT3
883 +#define AR2315_INTR_WLAN0 SR_IBIT4
884 +#define AR2315_INTR_ENET0 SR_IBIT5
885 +#define AR2315_INTR_LOCALPCI SR_IBIT6
886 +#define AR2315_INTR_WMACPOLL SR_IBIT7
887 +#define AR2315_INTR_COMPARE SR_IBIT8
892 +#define AR2315_TIMER (AR2315_DSLBASE + 0x0030)
893 +#define AR2315_RELOAD (AR2315_DSLBASE + 0x0034)
894 +#define AR2315_WD (AR2315_DSLBASE + 0x0038)
895 +#define AR2315_WDC (AR2315_DSLBASE + 0x003c)
897 +#define AR2315_WDC_IGNORE_EXPIRATION 0x00000000
898 +#define AR2315_WDC_NMI 0x00000001 /* NMI on watchdog */
899 +#define AR2315_WDC_RESET 0x00000002 /* reset on watchdog */
902 + * CPU Performance Counters
904 +#define AR2315_PERFCNT0 (AR2315_DSLBASE + 0x0048)
905 +#define AR2315_PERFCNT1 (AR2315_DSLBASE + 0x004c)
907 +#define AR2315_PERF0_DATAHIT 0x0001 /* Count Data Cache Hits */
908 +#define AR2315_PERF0_DATAMISS 0x0002 /* Count Data Cache Misses */
909 +#define AR2315_PERF0_INSTHIT 0x0004 /* Count Instruction Cache Hits */
910 +#define AR2315_PERF0_INSTMISS 0x0008 /* Count Instruction Cache Misses */
911 +#define AR2315_PERF0_ACTIVE 0x0010 /* Count Active Processor Cycles */
912 +#define AR2315_PERF0_WBHIT 0x0020 /* Count CPU Write Buffer Hits */
913 +#define AR2315_PERF0_WBMISS 0x0040 /* Count CPU Write Buffer Misses */
915 +#define AR2315_PERF1_EB_ARDY 0x0001 /* Count EB_ARdy signal */
916 +#define AR2315_PERF1_EB_AVALID 0x0002 /* Count EB_AValid signal */
917 +#define AR2315_PERF1_EB_WDRDY 0x0004 /* Count EB_WDRdy signal */
918 +#define AR2315_PERF1_EB_RDVAL 0x0008 /* Count EB_RdVal signal */
919 +#define AR2315_PERF1_VRADDR 0x0010 /* Count valid read address cycles */
920 +#define AR2315_PERF1_VWADDR 0x0020 /* Count valid write address cycles */
921 +#define AR2315_PERF1_VWDATA 0x0040 /* Count valid write data cycles */
924 + * AHB Error Reporting.
926 +#define AR2315_AHB_ERR0 (AR2315_DSLBASE + 0x0050) /* error */
927 +#define AR2315_AHB_ERR1 (AR2315_DSLBASE + 0x0054) /* haddr */
928 +#define AR2315_AHB_ERR2 (AR2315_DSLBASE + 0x0058) /* hwdata */
929 +#define AR2315_AHB_ERR3 (AR2315_DSLBASE + 0x005c) /* hrdata */
930 +#define AR2315_AHB_ERR4 (AR2315_DSLBASE + 0x0060) /* status */
932 +#define AHB_ERROR_DET 1 /* AHB Error has been detected, */
933 + /* write 1 to clear all bits in ERR0 */
934 +#define AHB_ERROR_OVR 2 /* AHB Error overflow has been detected */
935 +#define AHB_ERROR_WDT 4 /* AHB Error due to wdt instead of hresp */
937 +#define AR2315_PROCERR_HMAST 0x0000000f
938 +#define AR2315_PROCERR_HMAST_DFLT 0
939 +#define AR2315_PROCERR_HMAST_WMAC 1
940 +#define AR2315_PROCERR_HMAST_ENET 2
941 +#define AR2315_PROCERR_HMAST_PCIENDPT 3
942 +#define AR2315_PROCERR_HMAST_LOCAL 4
943 +#define AR2315_PROCERR_HMAST_CPU 5
944 +#define AR2315_PROCERR_HMAST_PCITGT 6
946 +#define AR2315_PROCERR_HMAST_S 0
947 +#define AR2315_PROCERR_HWRITE 0x00000010
948 +#define AR2315_PROCERR_HSIZE 0x00000060
949 +#define AR2315_PROCERR_HSIZE_S 5
950 +#define AR2315_PROCERR_HTRANS 0x00000180
951 +#define AR2315_PROCERR_HTRANS_S 7
952 +#define AR2315_PROCERR_HBURST 0x00000e00
953 +#define AR2315_PROCERR_HBURST_S 9
958 +#define AR2315_PLLC_CTL (AR2315_DSLBASE + 0x0064)
959 +#define AR2315_PLLV_CTL (AR2315_DSLBASE + 0x0068)
960 +#define AR2315_CPUCLK (AR2315_DSLBASE + 0x006c)
961 +#define AR2315_AMBACLK (AR2315_DSLBASE + 0x0070)
962 +#define AR2315_SYNCCLK (AR2315_DSLBASE + 0x0074)
963 +#define AR2315_DSL_SLEEP_CTL (AR2315_DSLBASE + 0x0080)
964 +#define AR2315_DSL_SLEEP_DUR (AR2315_DSLBASE + 0x0084)
966 +/* PLLc Control fields */
967 +#define PLLC_REF_DIV_M 0x00000003
968 +#define PLLC_REF_DIV_S 0
969 +#define PLLC_FDBACK_DIV_M 0x0000007C
970 +#define PLLC_FDBACK_DIV_S 2
971 +#define PLLC_ADD_FDBACK_DIV_M 0x00000080
972 +#define PLLC_ADD_FDBACK_DIV_S 7
973 +#define PLLC_CLKC_DIV_M 0x0001c000
974 +#define PLLC_CLKC_DIV_S 14
975 +#define PLLC_CLKM_DIV_M 0x00700000
976 +#define PLLC_CLKM_DIV_S 20
978 +/* CPU CLK Control fields */
979 +#define CPUCLK_CLK_SEL_M 0x00000003
980 +#define CPUCLK_CLK_SEL_S 0
981 +#define CPUCLK_CLK_DIV_M 0x0000000c
982 +#define CPUCLK_CLK_DIV_S 2
984 +/* AMBA CLK Control fields */
985 +#define AMBACLK_CLK_SEL_M 0x00000003
986 +#define AMBACLK_CLK_SEL_S 0
987 +#define AMBACLK_CLK_DIV_M 0x0000000c
988 +#define AMBACLK_CLK_DIV_S 2
993 +#define AR2315_GPIO_DI (AR2315_DSLBASE + 0x0088)
994 +#define AR2315_GPIO_DO (AR2315_DSLBASE + 0x0090)
995 +#define AR2315_GPIO_CR (AR2315_DSLBASE + 0x0098)
996 +#define AR2315_GPIO_INT (AR2315_DSLBASE + 0x00a0)
998 +#define AR2315_GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
999 +#define AR2315_GPIO_CR_O(x) (1 << (x)) /* output */
1000 +#define AR2315_GPIO_CR_I(x) (0) /* input */
1002 +#define AR2315_GPIO_INT_S(x) (x) /* interrupt enable */
1003 +#define AR2315_GPIO_INT_M (0x3F) /* mask for int */
1004 +#define AR2315_GPIO_INT_LVL(x) ((x) << 6) /* interrupt level */
1005 +#define AR2315_GPIO_INT_LVL_M ((0x3) << 6) /* mask for int level */
1007 +#define AR2315_GPIO_INT_MAX_Y 1 /* Maximum value of Y for AR5313_GPIO_INT_* macros */
1008 +#define AR2315_GPIO_INT_LVL_OFF 0 /* Triggerring off */
1009 +#define AR2315_GPIO_INT_LVL_LOW 1 /* Low Level Triggered */
1010 +#define AR2315_GPIO_INT_LVL_HIGH 2 /* High Level Triggered */
1011 +#define AR2315_GPIO_INT_LVL_EDGE 3 /* Edge Triggered */
1013 +#define AR2315_RESET_GPIO 5
1014 +#define AR2315_NUM_GPIO 22
1017 + * PCI Clock Control
1019 +#define AR2315_PCICLK (AR2315_DSLBASE + 0x00a4)
1021 +#define AR2315_PCICLK_INPUT_M 0x3
1022 +#define AR2315_PCICLK_INPUT_S 0
1024 +#define AR2315_PCICLK_PLLC_CLKM 0
1025 +#define AR2315_PCICLK_PLLC_CLKM1 1
1026 +#define AR2315_PCICLK_PLLC_CLKC 2
1027 +#define AR2315_PCICLK_REF_CLK 3
1029 +#define AR2315_PCICLK_DIV_M 0xc
1030 +#define AR2315_PCICLK_DIV_S 2
1032 +#define AR2315_PCICLK_IN_FREQ 0
1033 +#define AR2315_PCICLK_IN_FREQ_DIV_6 1
1034 +#define AR2315_PCICLK_IN_FREQ_DIV_8 2
1035 +#define AR2315_PCICLK_IN_FREQ_DIV_10 3
1038 + * Observation Control Register
1040 +#define AR2315_OCR (AR2315_DSLBASE + 0x00b0)
1041 +#define OCR_GPIO0_IRIN 0x0040
1042 +#define OCR_GPIO1_IROUT 0x0080
1043 +#define OCR_GPIO3_RXCLR 0x0200
1046 + * General Clock Control
1049 +#define AR2315_MISCCLK (AR2315_DSLBASE + 0x00b4)
1050 +#define MISCCLK_PLLBYPASS_EN 0x00000001
1051 +#define MISCCLK_PROCREFCLK 0x00000002
1054 + * SDRAM Controller
1055 + * - No read or write buffers are included.
1057 +#define AR2315_MEM_CFG (AR2315_SDRAMCTL + 0x00)
1058 +#define AR2315_MEM_CTRL (AR2315_SDRAMCTL + 0x0c)
1059 +#define AR2315_MEM_REF (AR2315_SDRAMCTL + 0x10)
1061 +#define SDRAM_DATA_WIDTH_M 0x00006000
1062 +#define SDRAM_DATA_WIDTH_S 13
1064 +#define SDRAM_COL_WIDTH_M 0x00001E00
1065 +#define SDRAM_COL_WIDTH_S 9
1067 +#define SDRAM_ROW_WIDTH_M 0x000001E0
1068 +#define SDRAM_ROW_WIDTH_S 5
1070 +#define SDRAM_BANKADDR_BITS_M 0x00000018
1071 +#define SDRAM_BANKADDR_BITS_S 3
1074 + * SPI Flash Interface Registers
1077 +#define AR2315_SPI_CTL (AR2315_SPI + 0x00)
1078 +#define AR2315_SPI_OPCODE (AR2315_SPI + 0x04)
1079 +#define AR2315_SPI_DATA (AR2315_SPI + 0x08)
1081 +#define SPI_CTL_START 0x00000100
1082 +#define SPI_CTL_BUSY 0x00010000
1083 +#define SPI_CTL_TXCNT_MASK 0x0000000f
1084 +#define SPI_CTL_RXCNT_MASK 0x000000f0
1085 +#define SPI_CTL_TX_RX_CNT_MASK 0x000000ff
1086 +#define SPI_CTL_SIZE_MASK 0x00060000
1088 +#define SPI_CTL_CLK_SEL_MASK 0x03000000
1089 +#define SPI_OPCODE_MASK 0x000000ff
1092 + * PCI Bus Interface Registers
1094 +#define AR2315_PCI_1MS_REG (AR2315_PCI + 0x0008)
1095 +#define AR2315_PCI_1MS_MASK 0x3FFFF /* # of AHB clk cycles in 1ms */
1097 +#define AR2315_PCI_MISC_CONFIG (AR2315_PCI + 0x000c)
1098 +#define AR2315_PCIMISC_TXD_EN 0x00000001 /* Enable TXD for fragments */
1099 +#define AR2315_PCIMISC_CFG_SEL 0x00000002 /* mem or config cycles */
1100 +#define AR2315_PCIMISC_GIG_MASK 0x0000000C /* bits 31-30 for pci req */
1101 +#define AR2315_PCIMISC_RST_MODE 0x00000030
1102 +#define AR2315_PCIRST_INPUT 0x00000000 /* 4:5=0 rst is input */
1103 +#define AR2315_PCIRST_LOW 0x00000010 /* 4:5=1 rst to GND */
1104 +#define AR2315_PCIRST_HIGH 0x00000020 /* 4:5=2 rst to VDD */
1105 +#define AR2315_PCIGRANT_EN 0x00000000 /* 6:7=0 early grant en */
1106 +#define AR2315_PCIGRANT_FRAME 0x00000040 /* 6:7=1 grant waits 4 frame */
1107 +#define AR2315_PCIGRANT_IDLE 0x00000080 /* 6:7=2 grant waits 4 idle */
1108 +#define AR2315_PCIGRANT_GAP 0x00000000 /* 6:7=2 grant waits 4 idle */
1109 +#define AR2315_PCICACHE_DIS 0x00001000 /* PCI external access cache disable */
1111 +#define AR2315_PCI_OUT_TSTAMP (AR2315_PCI + 0x0010)
1113 +#define AR2315_PCI_UNCACHE_CFG (AR2315_PCI + 0x0014)
1115 +#define AR2315_PCI_IN_EN (AR2315_PCI + 0x0100)
1116 +#define AR2315_PCI_IN_EN0 0x01 /* Enable chain 0 */
1117 +#define AR2315_PCI_IN_EN1 0x02 /* Enable chain 1 */
1118 +#define AR2315_PCI_IN_EN2 0x04 /* Enable chain 2 */
1119 +#define AR2315_PCI_IN_EN3 0x08 /* Enable chain 3 */
1121 +#define AR2315_PCI_IN_DIS (AR2315_PCI + 0x0104)
1122 +#define AR2315_PCI_IN_DIS0 0x01 /* Disable chain 0 */
1123 +#define AR2315_PCI_IN_DIS1 0x02 /* Disable chain 1 */
1124 +#define AR2315_PCI_IN_DIS2 0x04 /* Disable chain 2 */
1125 +#define AR2315_PCI_IN_DIS3 0x08 /* Disable chain 3 */
1127 +#define AR2315_PCI_IN_PTR (AR2315_PCI + 0x0200)
1129 +#define AR2315_PCI_OUT_EN (AR2315_PCI + 0x0400)
1130 +#define AR2315_PCI_OUT_EN0 0x01 /* Enable chain 0 */
1132 +#define AR2315_PCI_OUT_DIS (AR2315_PCI + 0x0404)
1133 +#define AR2315_PCI_OUT_DIS0 0x01 /* Disable chain 0 */
1135 +#define AR2315_PCI_OUT_PTR (AR2315_PCI + 0x0408)
1137 +#define AR2315_PCI_INT_STATUS (AR2315_PCI + 0x0500) /* write one to clr */
1138 +#define AR2315_PCI_TXINT 0x00000001 /* Desc In Completed */
1139 +#define AR2315_PCI_TXOK 0x00000002 /* Desc In OK */
1140 +#define AR2315_PCI_TXERR 0x00000004 /* Desc In ERR */
1141 +#define AR2315_PCI_TXEOL 0x00000008 /* Desc In End-of-List */
1142 +#define AR2315_PCI_RXINT 0x00000010 /* Desc Out Completed */
1143 +#define AR2315_PCI_RXOK 0x00000020 /* Desc Out OK */
1144 +#define AR2315_PCI_RXERR 0x00000040 /* Desc Out ERR */
1145 +#define AR2315_PCI_RXEOL 0x00000080 /* Desc Out EOL */
1146 +#define AR2315_PCI_TXOOD 0x00000200 /* Desc In Out-of-Desc */
1147 +#define AR2315_PCI_MASK 0x0000FFFF /* Desc Mask */
1148 +#define AR2315_PCI_EXT_INT 0x02000000
1149 +#define AR2315_PCI_ABORT_INT 0x04000000
1151 +#define AR2315_PCI_INT_MASK (AR2315_PCI + 0x0504) /* same as INT_STATUS */
1153 +#define AR2315_PCI_INTEN_REG (AR2315_PCI + 0x0508)
1154 +#define AR2315_PCI_INT_DISABLE 0x00 /* disable pci interrupts */
1155 +#define AR2315_PCI_INT_ENABLE 0x01 /* enable pci interrupts */
1157 +#define AR2315_PCI_HOST_IN_EN (AR2315_PCI + 0x0800)
1158 +#define AR2315_PCI_HOST_IN_DIS (AR2315_PCI + 0x0804)
1159 +#define AR2315_PCI_HOST_IN_PTR (AR2315_PCI + 0x0810)
1160 +#define AR2315_PCI_HOST_OUT_EN (AR2315_PCI + 0x0900)
1161 +#define AR2315_PCI_HOST_OUT_DIS (AR2315_PCI + 0x0904)
1162 +#define AR2315_PCI_HOST_OUT_PTR (AR2315_PCI + 0x0908)
1166 + * Local Bus Interface Registers
1168 +#define AR2315_LB_CONFIG (AR2315_LOCAL + 0x0000)
1169 +#define AR2315_LBCONF_OE 0x00000001 /* =1 OE is low-true */
1170 +#define AR2315_LBCONF_CS0 0x00000002 /* =1 first CS is low-true */
1171 +#define AR2315_LBCONF_CS1 0x00000004 /* =1 2nd CS is low-true */
1172 +#define AR2315_LBCONF_RDY 0x00000008 /* =1 RDY is low-true */
1173 +#define AR2315_LBCONF_WE 0x00000010 /* =1 Write En is low-true */
1174 +#define AR2315_LBCONF_WAIT 0x00000020 /* =1 WAIT is low-true */
1175 +#define AR2315_LBCONF_ADS 0x00000040 /* =1 Adr Strobe is low-true */
1176 +#define AR2315_LBCONF_MOT 0x00000080 /* =0 Intel, =1 Motorola */
1177 +#define AR2315_LBCONF_8CS 0x00000100 /* =1 8 bits CS, 0= 16bits */
1178 +#define AR2315_LBCONF_8DS 0x00000200 /* =1 8 bits Data S, 0=16bits */
1179 +#define AR2315_LBCONF_ADS_EN 0x00000400 /* =1 Enable ADS */
1180 +#define AR2315_LBCONF_ADR_OE 0x00000800 /* =1 Adr cap on OE, WE or DS */
1181 +#define AR2315_LBCONF_ADDT_MUX 0x00001000 /* =1 Adr and Data share bus */
1182 +#define AR2315_LBCONF_DATA_OE 0x00002000 /* =1 Data cap on OE, WE, DS */
1183 +#define AR2315_LBCONF_16DATA 0x00004000 /* =1 Data is 16 bits wide */
1184 +#define AR2315_LBCONF_SWAPDT 0x00008000 /* =1 Byte swap data */
1185 +#define AR2315_LBCONF_SYNC 0x00010000 /* =1 Bus synchronous to clk */
1186 +#define AR2315_LBCONF_INT 0x00020000 /* =1 Intr is low true */
1187 +#define AR2315_LBCONF_INT_CTR0 0x00000000 /* GND high-Z, Vdd is high-Z */
1188 +#define AR2315_LBCONF_INT_CTR1 0x00040000 /* GND drive, Vdd is high-Z */
1189 +#define AR2315_LBCONF_INT_CTR2 0x00080000 /* GND high-Z, Vdd drive */
1190 +#define AR2315_LBCONF_INT_CTR3 0x000C0000 /* GND drive, Vdd drive */
1191 +#define AR2315_LBCONF_RDY_WAIT 0x00100000 /* =1 RDY is negative of WAIT */
1192 +#define AR2315_LBCONF_INT_PULSE 0x00200000 /* =1 Interrupt is a pulse */
1193 +#define AR2315_LBCONF_ENABLE 0x00400000 /* =1 Falcon respond to LB */
1195 +#define AR2315_LB_CLKSEL (AR2315_LOCAL + 0x0004)
1196 +#define AR2315_LBCLK_EXT 0x0001 /* use external clk for lb */
1198 +#define AR2315_LB_1MS (AR2315_LOCAL + 0x0008)
1199 +#define AR2315_LB1MS_MASK 0x3FFFF /* # of AHB clk cycles in 1ms */
1201 +#define AR2315_LB_MISCCFG (AR2315_LOCAL + 0x000C)
1202 +#define AR2315_LBM_TXD_EN 0x00000001 /* Enable TXD for fragments */
1203 +#define AR2315_LBM_RX_INTEN 0x00000002 /* Enable LB ints on RX ready */
1204 +#define AR2315_LBM_MBOXWR_INTEN 0x00000004 /* Enable LB ints on mbox wr */
1205 +#define AR2315_LBM_MBOXRD_INTEN 0x00000008 /* Enable LB ints on mbox rd */
1206 +#define AR2315_LMB_DESCSWAP_EN 0x00000010 /* Byte swap desc enable */
1207 +#define AR2315_LBM_TIMEOUT_MASK 0x00FFFF80
1208 +#define AR2315_LBM_TIMEOUT_SHFT 7
1209 +#define AR2315_LBM_PORTMUX 0x07000000
1212 +#define AR2315_LB_RXTSOFF (AR2315_LOCAL + 0x0010)
1214 +#define AR2315_LB_TX_CHAIN_EN (AR2315_LOCAL + 0x0100)
1215 +#define AR2315_LB_TXEN_0 0x01
1216 +#define AR2315_LB_TXEN_1 0x02
1217 +#define AR2315_LB_TXEN_2 0x04
1218 +#define AR2315_LB_TXEN_3 0x08
1220 +#define AR2315_LB_TX_CHAIN_DIS (AR2315_LOCAL + 0x0104)
1221 +#define AR2315_LB_TX_DESC_PTR (AR2315_LOCAL + 0x0200)
1223 +#define AR2315_LB_RX_CHAIN_EN (AR2315_LOCAL + 0x0400)
1224 +#define AR2315_LB_RXEN 0x01
1226 +#define AR2315_LB_RX_CHAIN_DIS (AR2315_LOCAL + 0x0404)
1227 +#define AR2315_LB_RX_DESC_PTR (AR2315_LOCAL + 0x0408)
1229 +#define AR2315_LB_INT_STATUS (AR2315_LOCAL + 0x0500)
1230 +#define AR2315_INT_TX_DESC 0x0001
1231 +#define AR2315_INT_TX_OK 0x0002
1232 +#define AR2315_INT_TX_ERR 0x0004
1233 +#define AR2315_INT_TX_EOF 0x0008
1234 +#define AR2315_INT_RX_DESC 0x0010
1235 +#define AR2315_INT_RX_OK 0x0020
1236 +#define AR2315_INT_RX_ERR 0x0040
1237 +#define AR2315_INT_RX_EOF 0x0080
1238 +#define AR2315_INT_TX_TRUNC 0x0100
1239 +#define AR2315_INT_TX_STARVE 0x0200
1240 +#define AR2315_INT_LB_TIMEOUT 0x0400
1241 +#define AR2315_INT_LB_ERR 0x0800
1242 +#define AR2315_INT_MBOX_WR 0x1000
1243 +#define AR2315_INT_MBOX_RD 0x2000
1245 +/* Bit definitions for INT MASK are the same as INT_STATUS */
1246 +#define AR2315_LB_INT_MASK (AR2315_LOCAL + 0x0504)
1248 +#define AR2315_LB_INT_EN (AR2315_LOCAL + 0x0508)
1249 +#define AR2315_LB_MBOX (AR2315_LOCAL + 0x0600)
1252 + * IR Interface Registers
1254 +#define AR2315_IR_PKTDATA (AR2315_IR + 0x0000)
1256 +#define AR2315_IR_PKTLEN (AR2315_IR + 0x07fc) /* 0 - 63 */
1258 +#define AR2315_IR_CONTROL (AR2315_IR + 0x0800)
1259 +#define AR2315_IRCTL_TX 0x00000000 /* use as tranmitter */
1260 +#define AR2315_IRCTL_RX 0x00000001 /* use as receiver */
1261 +#define AR2315_IRCTL_SAMPLECLK_MASK 0x00003ffe /* Sample clk divisor mask */
1262 +#define AR2315_IRCTL_SAMPLECLK_SHFT 1
1263 +#define AR2315_IRCTL_OUTPUTCLK_MASK 0x03ffc000 /* Output clk divisor mask */
1264 +#define AR2315_IRCTL_OUTPUTCLK_SHFT 14
1266 +#define AR2315_IR_STATUS (AR2315_IR + 0x0804)
1267 +#define AR2315_IRSTS_RX 0x00000001 /* receive in progress */
1268 +#define AR2315_IRSTS_TX 0x00000002 /* transmit in progress */
1270 +#define AR2315_IR_CONFIG (AR2315_IR + 0x0808)
1271 +#define AR2315_IRCFG_INVIN 0x00000001 /* invert input polarity */
1272 +#define AR2315_IRCFG_INVOUT 0x00000002 /* invert output polarity */
1273 +#define AR2315_IRCFG_SEQ_START_WIN_SEL 0x00000004 /* 1 => 28, 0 => 7 */
1274 +#define AR2315_IRCFG_SEQ_START_THRESH 0x000000f0 /* */
1275 +#define AR2315_IRCFG_SEQ_END_UNIT_SEL 0x00000100 /* */
1276 +#define AR2315_IRCFG_SEQ_END_UNIT_THRESH 0x00007e00 /* */
1277 +#define AR2315_IRCFG_SEQ_END_WIN_SEL 0x00008000 /* */
1278 +#define AR2315_IRCFG_SEQ_END_WIN_THRESH 0x001f0000 /* */
1279 +#define AR2315_IRCFG_NUM_BACKOFF_WORDS 0x01e00000 /* */
1281 +#define HOST_PCI_DEV_ID 3
1282 +#define HOST_PCI_MBAR0 0x10000000
1283 +#define HOST_PCI_MBAR1 0x20000000
1284 +#define HOST_PCI_MBAR2 0x30000000
1286 +#define HOST_PCI_SDRAM_BASEADDR HOST_PCI_MBAR1
1287 +#define PCI_DEVICE_MEM_SPACE 0x800000
1289 +#endif /* __AR2315_REG_H */
1291 +++ b/arch/mips/include/asm/mach-ar231x/ar5312_regs.h
1294 + * This file is subject to the terms and conditions of the GNU General Public
1295 + * License. See the file "COPYING" in the main directory of this archive
1296 + * for more details.
1298 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
1299 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
1300 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
1306 +#include <asm/addrspace.h>
1312 +#define AR5312_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
1313 +#define AR5312_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
1314 +#define AR5312_IRQ_ENET1_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
1315 +#define AR5312_IRQ_WLAN1_INTRS MIPS_CPU_IRQ_BASE+5 /* C0_CAUSE: 0x2000 */
1316 +#define AR5312_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
1320 +#define AR531X_WLAN0 0x18000000
1321 +#define AR531X_WLAN1 0x18500000
1322 +#define AR531X_ENET0 0x18100000
1323 +#define AR531X_ENET1 0x18200000
1324 +#define AR531X_SDRAMCTL 0x18300000
1325 +#define AR531X_FLASHCTL 0x18400000
1326 +#define AR531X_APBBASE 0x1c000000
1327 +#define AR531X_FLASH 0x1e000000
1328 +#define AR531X_UART0 0xbc000003 /* UART MMR */
1331 + * AR531X_NUM_ENET_MAC defines the number of ethernet MACs that
1332 + * should be considered available. The AR5312 supports 2 enet MACS,
1333 + * even though many reference boards only actually use 1 of them
1334 + * (i.e. Only MAC 0 is actually connected to an enet PHY or PHY switch.
1335 + * The AR2312 supports 1 enet MAC.
1337 +#define AR531X_NUM_ENET_MAC 2
1340 + * Need these defines to determine true number of ethernet MACs
1342 +#define AR5212_AR5312_REV2 0x0052 /* AR5312 WMAC (AP31) */
1343 +#define AR5212_AR5312_REV7 0x0057 /* AR5312 WMAC (AP30-040) */
1344 +#define AR5212_AR2313_REV8 0x0058 /* AR2313 WMAC (AP43-030) */
1347 + * AR531X_NUM_WMAC defines the number of Wireless MACs that\
1348 + * should be considered available.
1350 +#define AR531X_NUM_WMAC 2
1352 +/* Reset/Timer Block Address Map */
1353 +#define AR531X_RESETTMR (AR531X_APBBASE + 0x3000)
1354 +#define AR531X_TIMER (AR531X_RESETTMR + 0x0000) /* countdown timer */
1355 +#define AR531X_WD_CTRL (AR531X_RESETTMR + 0x0008) /* watchdog cntrl */
1356 +#define AR531X_WD_TIMER (AR531X_RESETTMR + 0x000c) /* watchdog timer */
1357 +#define AR531X_ISR (AR531X_RESETTMR + 0x0010) /* Intr Status Reg */
1358 +#define AR531X_IMR (AR531X_RESETTMR + 0x0014) /* Intr Mask Reg */
1359 +#define AR531X_RESET (AR531X_RESETTMR + 0x0020)
1360 +#define AR5312_CLOCKCTL1 (AR531X_RESETTMR + 0x0064)
1361 +#define AR5312_SCRATCH (AR531X_RESETTMR + 0x006c)
1362 +#define AR531X_PROCADDR (AR531X_RESETTMR + 0x0070)
1363 +#define AR531X_PROC1 (AR531X_RESETTMR + 0x0074)
1364 +#define AR531X_DMAADDR (AR531X_RESETTMR + 0x0078)
1365 +#define AR531X_DMA1 (AR531X_RESETTMR + 0x007c)
1366 +#define AR531X_ENABLE (AR531X_RESETTMR + 0x0080) /* interface enb */
1367 +#define AR531X_REV (AR531X_RESETTMR + 0x0090) /* revision */
1369 +/* AR531X_WD_CTRL register bit field definitions */
1370 +#define AR531X_WD_CTRL_IGNORE_EXPIRATION 0x0000
1371 +#define AR531X_WD_CTRL_NMI 0x0001
1372 +#define AR531X_WD_CTRL_RESET 0x0002
1374 +/* AR531X_ISR register bit field definitions */
1375 +#define AR531X_ISR_NONE 0x0000
1376 +#define AR531X_ISR_TIMER 0x0001
1377 +#define AR531X_ISR_AHBPROC 0x0002
1378 +#define AR531X_ISR_AHBDMA 0x0004
1379 +#define AR531X_ISR_GPIO 0x0008
1380 +#define AR531X_ISR_UART0 0x0010
1381 +#define AR531X_ISR_UART0DMA 0x0020
1382 +#define AR531X_ISR_WD 0x0040
1383 +#define AR531X_ISR_LOCAL 0x0080
1385 +/* AR531X_RESET register bit field definitions */
1386 +#define AR531X_RESET_SYSTEM 0x00000001 /* cold reset full system */
1387 +#define AR531X_RESET_PROC 0x00000002 /* cold reset MIPS core */
1388 +#define AR531X_RESET_WLAN0 0x00000004 /* cold reset WLAN MAC and BB */
1389 +#define AR531X_RESET_EPHY0 0x00000008 /* cold reset ENET0 phy */
1390 +#define AR531X_RESET_EPHY1 0x00000010 /* cold reset ENET1 phy */
1391 +#define AR531X_RESET_ENET0 0x00000020 /* cold reset ENET0 mac */
1392 +#define AR531X_RESET_ENET1 0x00000040 /* cold reset ENET1 mac */
1393 +#define AR531X_RESET_UART0 0x00000100 /* cold reset UART0 (high speed) */
1394 +#define AR531X_RESET_WLAN1 0x00000200 /* cold reset WLAN MAC/BB */
1395 +#define AR531X_RESET_APB 0x00000400 /* cold reset APB (ar5312) */
1396 +#define AR531X_RESET_WARM_PROC 0x00001000 /* warm reset MIPS core */
1397 +#define AR531X_RESET_WARM_WLAN0_MAC 0x00002000 /* warm reset WLAN0 MAC */
1398 +#define AR531X_RESET_WARM_WLAN0_BB 0x00004000 /* warm reset WLAN0 BaseBand */
1399 +#define AR531X_RESET_NMI 0x00010000 /* send an NMI to the processor */
1400 +#define AR531X_RESET_WARM_WLAN1_MAC 0x00020000 /* warm reset WLAN1 mac */
1401 +#define AR531X_RESET_WARM_WLAN1_BB 0x00040000 /* warm reset WLAN1 baseband */
1402 +#define AR531X_RESET_LOCAL_BUS 0x00080000 /* reset local bus */
1403 +#define AR531X_RESET_WDOG 0x00100000 /* last reset was a watchdog */
1405 +#define AR531X_RESET_WMAC0_BITS \
1406 + AR531X_RESET_WLAN0 |\
1407 + AR531X_RESET_WARM_WLAN0_MAC |\
1408 + AR531X_RESET_WARM_WLAN0_BB
1410 +#define AR531X_RESERT_WMAC1_BITS \
1411 + AR531X_RESET_WLAN1 |\
1412 + AR531X_RESET_WARM_WLAN1_MAC |\
1413 + AR531X_RESET_WARM_WLAN1_BB
1415 +/* AR5312_CLOCKCTL1 register bit field definitions */
1416 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
1417 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
1418 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
1419 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
1420 +#define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
1422 +/* Valid for AR5312 and AR2312 */
1423 +#define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
1424 +#define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
1425 +#define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
1426 +#define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
1427 +#define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
1429 +/* Valid for AR2313 */
1430 +#define AR2313_CLOCKCTL1_PREDIVIDE_MASK 0x00003000
1431 +#define AR2313_CLOCKCTL1_PREDIVIDE_SHIFT 12
1432 +#define AR2313_CLOCKCTL1_MULTIPLIER_MASK 0x001f0000
1433 +#define AR2313_CLOCKCTL1_MULTIPLIER_SHIFT 16
1434 +#define AR2313_CLOCKCTL1_DOUBLER_MASK 0x00000000
1437 +/* AR531X_ENABLE register bit field definitions */
1438 +#define AR531X_ENABLE_WLAN0 0x0001
1439 +#define AR531X_ENABLE_ENET0 0x0002
1440 +#define AR531X_ENABLE_ENET1 0x0004
1441 +#define AR531X_ENABLE_UART_AND_WLAN1_PIO 0x0008 /* UART, and WLAN1 PIOs */
1442 +#define AR531X_ENABLE_WLAN1_DMA 0x0010 /* WLAN1 DMAs */
1443 +#define AR531X_ENABLE_WLAN1 \
1444 + (AR531X_ENABLE_UART_AND_WLAN1_PIO | AR531X_ENABLE_WLAN1_DMA)
1446 +/* AR531X_REV register bit field definitions */
1447 +#define AR531X_REV_WMAC_MAJ 0xf000
1448 +#define AR531X_REV_WMAC_MAJ_S 12
1449 +#define AR531X_REV_WMAC_MIN 0x0f00
1450 +#define AR531X_REV_WMAC_MIN_S 8
1451 +#define AR531X_REV_MAJ 0x00f0
1452 +#define AR531X_REV_MAJ_S 4
1453 +#define AR531X_REV_MIN 0x000f
1454 +#define AR531X_REV_MIN_S 0
1455 +#define AR531X_REV_CHIP (AR531X_REV_MAJ|AR531X_REV_MIN)
1457 +/* Major revision numbers, bits 7..4 of Revision ID register */
1458 +#define AR531X_REV_MAJ_AR5312 0x4
1459 +#define AR531X_REV_MAJ_AR2313 0x5
1461 +/* Minor revision numbers, bits 3..0 of Revision ID register */
1462 +#define AR5312_REV_MIN_DUAL 0x0 /* Dual WLAN version */
1463 +#define AR5312_REV_MIN_SINGLE 0x1 /* Single WLAN version */
1465 +/* AR531X_FLASHCTL register bit field definitions */
1466 +#define FLASHCTL_IDCY 0x0000000f /* Idle cycle turn around time */
1467 +#define FLASHCTL_IDCY_S 0
1468 +#define FLASHCTL_WST1 0x000003e0 /* Wait state 1 */
1469 +#define FLASHCTL_WST1_S 5
1470 +#define FLASHCTL_RBLE 0x00000400 /* Read byte lane enable */
1471 +#define FLASHCTL_WST2 0x0000f800 /* Wait state 2 */
1472 +#define FLASHCTL_WST2_S 11
1473 +#define FLASHCTL_AC 0x00070000 /* Flash address check (added) */
1474 +#define FLASHCTL_AC_S 16
1475 +#define FLASHCTL_AC_128K 0x00000000
1476 +#define FLASHCTL_AC_256K 0x00010000
1477 +#define FLASHCTL_AC_512K 0x00020000
1478 +#define FLASHCTL_AC_1M 0x00030000
1479 +#define FLASHCTL_AC_2M 0x00040000
1480 +#define FLASHCTL_AC_4M 0x00050000
1481 +#define FLASHCTL_AC_8M 0x00060000
1482 +#define FLASHCTL_AC_RES 0x00070000 /* 16MB is not supported */
1483 +#define FLASHCTL_E 0x00080000 /* Flash bank enable (added) */
1484 +#define FLASHCTL_BUSERR 0x01000000 /* Bus transfer error status flag */
1485 +#define FLASHCTL_WPERR 0x02000000 /* Write protect error status flag */
1486 +#define FLASHCTL_WP 0x04000000 /* Write protect */
1487 +#define FLASHCTL_BM 0x08000000 /* Burst mode */
1488 +#define FLASHCTL_MW 0x30000000 /* Memory width */
1489 +#define FLASHCTL_MWx8 0x00000000 /* Memory width x8 */
1490 +#define FLASHCTL_MWx16 0x10000000 /* Memory width x16 */
1491 +#define FLASHCTL_MWx32 0x20000000 /* Memory width x32 (not supported) */
1492 +#define FLASHCTL_ATNR 0x00000000 /* Access type == no retry */
1493 +#define FLASHCTL_ATR 0x80000000 /* Access type == retry every */
1494 +#define FLASHCTL_ATR4 0xc0000000 /* Access type == retry every 4 */
1496 +/* ARM Flash Controller -- 3 flash banks with either x8 or x16 devices. */
1497 +#define AR531X_FLASHCTL0 (AR531X_FLASHCTL + 0x00)
1498 +#define AR531X_FLASHCTL1 (AR531X_FLASHCTL + 0x04)
1499 +#define AR531X_FLASHCTL2 (AR531X_FLASHCTL + 0x08)
1501 +/* ARM SDRAM Controller -- just enough to determine memory size */
1502 +#define AR531X_MEM_CFG1 (AR531X_SDRAMCTL + 0x04)
1503 +#define MEM_CFG1_AC0 0x00000700 /* bank 0: SDRAM addr check (added) */
1504 +#define MEM_CFG1_AC0_S 8
1505 +#define MEM_CFG1_AC1 0x00007000 /* bank 1: SDRAM addr check (added) */
1506 +#define MEM_CFG1_AC1_S 12
1508 +/* GPIO Address Map */
1509 +#define AR531X_GPIO (AR531X_APBBASE + 0x2000)
1510 +#define AR531X_GPIO_DO (AR531X_GPIO + 0x00) /* output register */
1511 +#define AR531X_GPIO_DI (AR531X_GPIO + 0x04) /* intput register */
1512 +#define AR531X_GPIO_CR (AR531X_GPIO + 0x08) /* control register */
1514 +/* GPIO Control Register bit field definitions */
1515 +#define AR531X_GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
1516 +#define AR531X_GPIO_CR_O(x) (0 << (x)) /* mask for output */
1517 +#define AR531X_GPIO_CR_I(x) (1 << (x)) /* mask for input */
1518 +#define AR531X_GPIO_CR_INT(x) (1 << ((x)+8)) /* mask for interrupt */
1519 +#define AR531X_GPIO_CR_UART(x) (1 << ((x)+16)) /* uart multiplex */
1520 +#define AR531X_NUM_GPIO 8
1526 +++ b/arch/mips/ar231x/ar5312.c
1529 + * This file is subject to the terms and conditions of the GNU General Public
1530 + * License. See the file "COPYING" in the main directory of this archive
1531 + * for more details.
1533 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
1534 + * Copyright (C) 2006 FON Technology, SL.
1535 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
1536 + * Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
1537 + * Copyright (C) 2012 Alexandros C. Couloumbis <alex@ozo.com>
1541 + * Platform devices for Atheros SoCs
1544 +#include <generated/autoconf.h>
1545 +#include <linux/init.h>
1546 +#include <linux/module.h>
1547 +#include <linux/types.h>
1548 +#include <linux/string.h>
1549 +#include <linux/mtd/physmap.h>
1550 +#include <linux/platform_device.h>
1551 +#include <linux/kernel.h>
1552 +#include <linux/reboot.h>
1553 +#include <linux/leds.h>
1554 +#include <linux/gpio.h>
1555 +#include <asm/bootinfo.h>
1556 +#include <asm/reboot.h>
1557 +#include <asm/time.h>
1558 +#include <linux/irq.h>
1559 +#include <asm/io.h>
1561 +#include <ar231x_platform.h>
1562 +#include <ar5312_regs.h>
1563 +#include <ar231x.h>
1564 +#include "devices.h"
1565 +#include "ar5312.h"
1568 +ar5312_misc_irq_dispatch(void)
1570 + unsigned int ar231x_misc_intrs = ar231x_read_reg(AR531X_ISR) & ar231x_read_reg(AR531X_IMR);
1572 + if (ar231x_misc_intrs & AR531X_ISR_TIMER) {
1573 + do_IRQ(AR531X_MISC_IRQ_TIMER);
1574 + (void)ar231x_read_reg(AR531X_TIMER);
1575 + } else if (ar231x_misc_intrs & AR531X_ISR_AHBPROC)
1576 + do_IRQ(AR531X_MISC_IRQ_AHB_PROC);
1577 + else if ((ar231x_misc_intrs & AR531X_ISR_UART0))
1578 + do_IRQ(AR531X_MISC_IRQ_UART0);
1579 + else if (ar231x_misc_intrs & AR531X_ISR_WD)
1580 + do_IRQ(AR531X_MISC_IRQ_WATCHDOG);
1582 + do_IRQ(AR531X_MISC_IRQ_NONE);
1585 +static asmlinkage void
1586 +ar5312_irq_dispatch(void)
1588 + int pending = read_c0_status() & read_c0_cause();
1590 + if (pending & CAUSEF_IP2)
1591 + do_IRQ(AR5312_IRQ_WLAN0_INTRS);
1592 + else if (pending & CAUSEF_IP3)
1593 + do_IRQ(AR5312_IRQ_ENET0_INTRS);
1594 + else if (pending & CAUSEF_IP4)
1595 + do_IRQ(AR5312_IRQ_ENET1_INTRS);
1596 + else if (pending & CAUSEF_IP5)
1597 + do_IRQ(AR5312_IRQ_WLAN1_INTRS);
1598 + else if (pending & CAUSEF_IP6)
1599 + ar5312_misc_irq_dispatch();
1600 + else if (pending & CAUSEF_IP7)
1601 + do_IRQ(AR531X_IRQ_CPU_CLOCK);
1605 +/* Enable the specified AR531X_MISC_IRQ interrupt */
1607 +ar5312_misc_intr_enable(struct irq_data *d)
1611 + imr = ar231x_read_reg(AR531X_IMR);
1612 + imr |= (1 << (d->irq - AR531X_MISC_IRQ_BASE - 1));
1613 + ar231x_write_reg(AR531X_IMR, imr);
1616 +/* Disable the specified AR531X_MISC_IRQ interrupt */
1618 +ar5312_misc_intr_disable(struct irq_data *d)
1622 + imr = ar231x_read_reg(AR531X_IMR);
1623 + imr &= ~(1 << (d->irq - AR531X_MISC_IRQ_BASE - 1));
1624 + ar231x_write_reg(AR531X_IMR, imr);
1625 + ar231x_read_reg(AR531X_IMR); /* flush write buffer */
1628 +static struct irq_chip ar5312_misc_intr_controller = {
1629 + .irq_mask = ar5312_misc_intr_disable,
1630 + .irq_unmask = ar5312_misc_intr_enable,
1634 +static irqreturn_t ar5312_ahb_proc_handler(int cpl, void *dev_id)
1636 + u32 proc1 = ar231x_read_reg(AR531X_PROC1);
1637 + u32 procAddr = ar231x_read_reg(AR531X_PROCADDR); /* clears error state */
1638 + u32 dma1 = ar231x_read_reg(AR531X_DMA1);
1639 + u32 dmaAddr = ar231x_read_reg(AR531X_DMAADDR); /* clears error state */
1641 + printk("AHB interrupt: PROCADDR=0x%8.8x PROC1=0x%8.8x DMAADDR=0x%8.8x DMA1=0x%8.8x\n",
1642 + procAddr, proc1, dmaAddr, dma1);
1644 + machine_restart("AHB error"); /* Catastrophic failure */
1645 + return IRQ_HANDLED;
1649 +static struct irqaction ar5312_ahb_proc_interrupt = {
1650 + .handler = ar5312_ahb_proc_handler,
1651 + .name = "ar5312_ahb_proc_interrupt",
1655 +static struct irqaction cascade = {
1656 + .handler = no_action,
1657 + .name = "cascade",
1660 +void __init ar5312_irq_init(void)
1667 + ar231x_irq_dispatch = ar5312_irq_dispatch;
1668 + for (i = 0; i < AR531X_MISC_IRQ_COUNT; i++) {
1669 + int irq = AR531X_MISC_IRQ_BASE + i;
1670 + irq_set_chip_and_handler(irq, &ar5312_misc_intr_controller,
1671 + handle_level_irq);
1673 + setup_irq(AR531X_MISC_IRQ_AHB_PROC, &ar5312_ahb_proc_interrupt);
1674 + setup_irq(AR5312_IRQ_MISC_INTRS, &cascade);
1678 +ar5312_gpio_set_output(u32 mask, u32 val)
1682 + reg = ar231x_read_reg(AR531X_GPIO_CR);
1685 + ar231x_write_reg(AR531X_GPIO_CR, reg);
1690 +ar5312_gpio_get(u32 valid_mask)
1693 + reg = ar231x_read_reg(AR531X_GPIO_DI);
1694 + reg &= valid_mask;
1699 +ar5312_gpio_set(u32 mask, u32 value)
1702 + reg = ar231x_read_reg(AR531X_GPIO_DO);
1705 + ar231x_write_reg(AR531X_GPIO_DO, reg);
1710 + * gpiolib implementations. Original mask based methods preserved
1713 +ar5312_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
1715 + struct ar231x_gpio_chip *gpch =
1716 + container_of(chip, struct ar231x_gpio_chip, chip);
1717 + u32 mask = 1 << gpio;
1719 + if (!(gpch->valid_mask & mask))
1721 + rett = ar5312_gpio_get(gpch->valid_mask);
1722 + return !!(rett & mask);
1726 +ar5312_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
1728 + struct ar231x_gpio_chip *gpch =
1729 + container_of(chip, struct ar231x_gpio_chip, chip);
1730 + u32 mask = 1 << gpio;
1731 + if (!(gpch->valid_mask & mask))
1733 + ar5312_gpio_set(mask, (!!value) * mask);
1737 +ar5312_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
1739 + struct ar231x_gpio_chip *gpch =
1740 + container_of(chip, struct ar231x_gpio_chip, chip);
1741 + u32 mask = 1 << gpio;
1742 + if (!(gpch->valid_mask & mask))
1744 + ar5312_gpio_set_output(mask, 0);
1748 +ar5312_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value)
1750 + struct ar231x_gpio_chip *gpch =
1751 + container_of(chip, struct ar231x_gpio_chip, chip);
1752 + u32 mask = 1 << gpio;
1753 + if (!(gpch->valid_mask & mask))
1755 + ar5312_gpio_set_output(mask, mask);
1756 + ar5312_gpio_set(mask, (!!value) * mask);
1760 +static struct ar231x_gpio_chip ar5312_gpio_chip = {
1761 + .valid_mask = (1 << 22) - 1,
1763 + .label = "ar5312-gpio",
1764 + .direction_input = ar5312_gpio_direction_input,
1765 + .direction_output = ar5312_gpio_direction_output,
1766 + .set = ar5312_gpio_set_value,
1767 + .get = ar5312_gpio_get_value,
1769 + .ngpio = AR531X_GPIO_IRQ_COUNT, // 22
1775 +static struct physmap_flash_data ar5312_flash_data = {
1779 +static struct resource ar5312_flash_resource = {
1780 + .start = AR531X_FLASH,
1781 + .end = AR531X_FLASH + 0x800000 - 1,
1782 + .flags = IORESOURCE_MEM,
1785 +static struct ar231x_eth ar5312_eth0_data = {
1786 + .reset_base = AR531X_RESET,
1787 + .reset_mac = AR531X_RESET_ENET0,
1788 + .reset_phy = AR531X_RESET_EPHY0,
1789 + .phy_base = KSEG1ADDR(AR531X_ENET0),
1790 + .config = &ar231x_board,
1793 +static struct ar231x_eth ar5312_eth1_data = {
1794 + .reset_base = AR531X_RESET,
1795 + .reset_mac = AR531X_RESET_ENET1,
1796 + .reset_phy = AR531X_RESET_EPHY1,
1797 + .phy_base = KSEG1ADDR(AR531X_ENET1),
1798 + .config = &ar231x_board,
1801 +static struct platform_device ar5312_physmap_flash = {
1802 + .name = "physmap-flash",
1804 + .dev.platform_data = &ar5312_flash_data,
1805 + .resource = &ar5312_flash_resource,
1806 + .num_resources = 1,
1809 +#ifdef CONFIG_LEDS_GPIO
1810 +static struct gpio_led ar5312_leds[] = {
1811 + { .name = "wlan", .gpio = 0, .active_low = 1, },
1814 +static const struct gpio_led_platform_data ar5312_led_data = {
1815 + .num_leds = ARRAY_SIZE(ar5312_leds),
1816 + .leds = (void *) ar5312_leds,
1819 +static struct platform_device ar5312_gpio_leds = {
1820 + .name = "leds-gpio",
1822 + .dev.platform_data = (void *) &ar5312_led_data,
1827 + * NB: This mapping size is larger than the actual flash size,
1828 + * but this shouldn't be a problem here, because the flash
1829 + * will simply be mapped multiple times.
1831 +static char __init *ar5312_flash_limit(void)
1835 + * Configure flash bank 0.
1836 + * Assume 8M window size. Flash will be aliased if it's smaller
1838 + ctl = FLASHCTL_E |
1841 + (0x01 << FLASHCTL_IDCY_S) |
1842 + (0x07 << FLASHCTL_WST1_S) |
1843 + (0x07 << FLASHCTL_WST2_S) |
1844 + (ar231x_read_reg(AR531X_FLASHCTL0) & FLASHCTL_MW);
1846 + ar231x_write_reg(AR531X_FLASHCTL0, ctl);
1848 + /* Disable other flash banks */
1849 + ar231x_write_reg(AR531X_FLASHCTL1,
1850 + ar231x_read_reg(AR531X_FLASHCTL1) & ~(FLASHCTL_E | FLASHCTL_AC));
1852 + ar231x_write_reg(AR531X_FLASHCTL2,
1853 + ar231x_read_reg(AR531X_FLASHCTL2) & ~(FLASHCTL_E | FLASHCTL_AC));
1855 + return (char *) KSEG1ADDR(AR531X_FLASH + 0x800000);
1858 +int __init ar5312_init_devices(void)
1860 + struct ar231x_boarddata *config;
1867 + /* Locate board/radio config data */
1868 + ar231x_find_config(ar5312_flash_limit());
1869 + config = ar231x_board.config;
1871 + /* AR2313 has CPU minor rev. 10 */
1872 + if ((current_cpu_data.processor_id & 0xff) == 0x0a)
1873 + ar231x_devtype = DEV_TYPE_AR2313;
1875 + /* AR2312 shares the same Silicon ID as AR5312 */
1876 + else if (config->flags & BD_ISCASPER)
1877 + ar231x_devtype = DEV_TYPE_AR2312;
1879 + /* Everything else is probably AR5312 or compatible */
1881 + ar231x_devtype = DEV_TYPE_AR5312;
1883 + /* fixup flash width */
1884 + fctl = ar231x_read_reg(AR531X_FLASHCTL) & FLASHCTL_MW;
1886 + case FLASHCTL_MWx16:
1887 + ar5312_flash_data.width = 2;
1889 + case FLASHCTL_MWx8:
1891 + ar5312_flash_data.width = 1;
1895 + platform_device_register(&ar5312_physmap_flash);
1897 +#ifdef CONFIG_LEDS_GPIO
1898 + ar5312_leds[0].gpio = config->sysLedGpio;
1899 + platform_device_register(&ar5312_gpio_leds);
1902 + /* Fix up MAC addresses if necessary */
1903 + if (!memcmp(config->enet0_mac, "\xff\xff\xff\xff\xff\xff", 6))
1904 + memcpy(config->enet0_mac, config->enet1_mac, 6);
1906 + /* If ENET0 and ENET1 have the same mac address,
1907 + * increment the one from ENET1 */
1908 + if (memcmp(config->enet0_mac, config->enet1_mac, 6) == 0) {
1909 + c = config->enet1_mac + 5;
1910 + while ((c >= config->enet1_mac) && !(++(*c)))
1914 + switch(ar231x_devtype) {
1915 + case DEV_TYPE_AR5312:
1916 + ar5312_eth0_data.macaddr = config->enet0_mac;
1917 + ar231x_add_ethernet(0, KSEG1ADDR(AR531X_ENET0),
1918 + AR5312_IRQ_ENET0_INTRS, &ar5312_eth0_data);
1920 + ar5312_eth1_data.macaddr = config->enet1_mac;
1921 + ar231x_add_ethernet(1, KSEG1ADDR(AR531X_ENET1),
1922 + AR5312_IRQ_ENET1_INTRS, &ar5312_eth1_data);
1924 + if (!ar231x_board.radio)
1927 + if (!(config->flags & BD_WLAN0))
1930 + ar231x_add_wmac(0, AR531X_WLAN0, AR5312_IRQ_WLAN0_INTRS);
1933 + * AR2312/3 ethernet uses the PHY of ENET0, but the MAC
1934 + * of ENET1. Atheros calls it 'twisted' for a reason :)
1936 + case DEV_TYPE_AR2312:
1937 + case DEV_TYPE_AR2313:
1938 + ar5312_eth1_data.phy_base = ar5312_eth0_data.phy_base;
1939 + ar5312_eth1_data.reset_phy = ar5312_eth0_data.reset_phy;
1940 + ar5312_eth1_data.macaddr = config->enet0_mac;
1941 + ar231x_add_ethernet(0, KSEG1ADDR(AR531X_ENET1),
1942 + AR5312_IRQ_ENET1_INTRS, &ar5312_eth1_data);
1944 + if (!ar231x_board.radio)
1951 + if (config->flags & BD_WLAN1)
1952 + ar231x_add_wmac(1, AR531X_WLAN1, AR5312_IRQ_WLAN1_INTRS);
1958 +static void ar5312_restart(char *command)
1960 + /* reset the system */
1961 + local_irq_disable();
1963 + ar231x_write_reg(AR531X_RESET, AR531X_RESET_SYSTEM);
1969 + * This table is indexed by bits 5..4 of the CLOCKCTL1 register
1970 + * to determine the predevisor value.
1972 +static int __initdata CLOCKCTL1_PREDIVIDE_TABLE[4] = { 1, 2, 4, 5 };
1976 +ar5312_cpu_frequency(void)
1978 + unsigned int result;
1979 + unsigned int predivide_mask, predivide_shift;
1980 + unsigned int multiplier_mask, multiplier_shift;
1981 + unsigned int clockCtl1, preDivideSelect, preDivisor, multiplier;
1982 + unsigned int doubler_mask;
1985 + /* Trust the bootrom's idea of cpu frequency. */
1986 + if ((result = ar231x_read_reg(AR5312_SCRATCH)))
1989 + devid = ar231x_read_reg(AR531X_REV);
1990 + devid &= AR531X_REV_MAJ;
1991 + devid >>= AR531X_REV_MAJ_S;
1992 + if (devid == AR531X_REV_MAJ_AR2313) {
1993 + predivide_mask = AR2313_CLOCKCTL1_PREDIVIDE_MASK;
1994 + predivide_shift = AR2313_CLOCKCTL1_PREDIVIDE_SHIFT;
1995 + multiplier_mask = AR2313_CLOCKCTL1_MULTIPLIER_MASK;
1996 + multiplier_shift = AR2313_CLOCKCTL1_MULTIPLIER_SHIFT;
1997 + doubler_mask = AR2313_CLOCKCTL1_DOUBLER_MASK;
1998 + } else { /* AR5312 and AR2312 */
1999 + predivide_mask = AR5312_CLOCKCTL1_PREDIVIDE_MASK;
2000 + predivide_shift = AR5312_CLOCKCTL1_PREDIVIDE_SHIFT;
2001 + multiplier_mask = AR5312_CLOCKCTL1_MULTIPLIER_MASK;
2002 + multiplier_shift = AR5312_CLOCKCTL1_MULTIPLIER_SHIFT;
2003 + doubler_mask = AR5312_CLOCKCTL1_DOUBLER_MASK;
2007 + * Clocking is derived from a fixed 40MHz input clock.
2009 + * cpuFreq = InputClock * MULT (where MULT is PLL multiplier)
2010 + * sysFreq = cpuFreq / 4 (used for APB clock, serial,
2011 + * flash, Timer, Watchdog Timer)
2013 + * cntFreq = cpuFreq / 2 (use for CPU count/compare)
2015 + * So, for example, with a PLL multiplier of 5, we have
2017 + * cpuFreq = 200MHz
2019 + * cntFreq = 100MHz
2021 + * We compute the CPU frequency, based on PLL settings.
2024 + clockCtl1 = ar231x_read_reg(AR5312_CLOCKCTL1);
2025 + preDivideSelect = (clockCtl1 & predivide_mask) >> predivide_shift;
2026 + preDivisor = CLOCKCTL1_PREDIVIDE_TABLE[preDivideSelect];
2027 + multiplier = (clockCtl1 & multiplier_mask) >> multiplier_shift;
2029 + if (clockCtl1 & doubler_mask) {
2030 + multiplier = multiplier << 1;
2032 + return (40000000 / preDivisor) * multiplier;
2036 +ar5312_sys_frequency(void)
2038 + return ar5312_cpu_frequency() / 4;
2042 +ar5312_time_init(void)
2047 + mips_hpt_frequency = ar5312_cpu_frequency() / 2;
2051 +ar5312_gpio_init(void)
2054 + struct ar231x_gpio_chip *gpch;
2055 + gpch = &ar5312_gpio_chip;
2056 + ret = gpiochip_add(&gpch->chip);
2058 + printk(KERN_ERR "%s: failed to add gpiochip\n",
2059 + gpch->chip.label);
2062 + printk(KERN_INFO "%s: registered %d GPIOs\n",
2063 + gpch->chip.label, gpch->chip.ngpio);
2068 +ar5312_prom_init(void)
2070 + u32 memsize, memcfg, bank0AC, bank1AC;
2076 + /* Detect memory size */
2077 + memcfg = ar231x_read_reg(AR531X_MEM_CFG1);
2078 + bank0AC = (memcfg & MEM_CFG1_AC0) >> MEM_CFG1_AC0_S;
2079 + bank1AC = (memcfg & MEM_CFG1_AC1) >> MEM_CFG1_AC1_S;
2080 + memsize = (bank0AC ? (1 << (bank0AC+1)) : 0)
2081 + + (bank1AC ? (1 << (bank1AC+1)) : 0);
2083 + add_memory_region(0, memsize, BOOT_MEM_RAM);
2085 + devid = ar231x_read_reg(AR531X_REV);
2086 + devid >>= AR531X_REV_WMAC_MIN_S;
2087 + devid &= AR531X_REV_CHIP;
2088 + ar231x_board.devid = (u16) devid;
2089 + ar5312_gpio_init();
2093 +ar5312_plat_setup(void)
2098 + /* Clear any lingering AHB errors */
2099 + ar231x_read_reg(AR531X_PROCADDR);
2100 + ar231x_read_reg(AR531X_DMAADDR);
2101 + ar231x_write_reg(AR531X_WD_CTRL, AR531X_WD_CTRL_IGNORE_EXPIRATION);
2103 + _machine_restart = ar5312_restart;
2104 + ar231x_serial_setup(KSEG1ADDR(AR531X_UART0), ar5312_sys_frequency());
2108 +++ b/arch/mips/ar231x/ar2315.c
2111 + * This file is subject to the terms and conditions of the GNU General Public
2112 + * License. See the file "COPYING" in the main directory of this archive
2113 + * for more details.
2115 + * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
2116 + * Copyright (C) 2006 FON Technology, SL.
2117 + * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
2118 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
2119 + * Copyright (C) 2012 Alexandros C. Couloumbis <alex@ozo.com>
2123 + * Platform devices for Atheros SoCs
2126 +#include <generated/autoconf.h>
2127 +#include <linux/init.h>
2128 +#include <linux/module.h>
2129 +#include <linux/types.h>
2130 +#include <linux/string.h>
2131 +#include <linux/platform_device.h>
2132 +#include <linux/kernel.h>
2133 +#include <linux/reboot.h>
2134 +#include <linux/delay.h>
2135 +#include <linux/leds.h>
2136 +#include <linux/gpio.h>
2137 +#include <asm/bootinfo.h>
2138 +#include <asm/reboot.h>
2139 +#include <asm/time.h>
2140 +#include <linux/irq.h>
2141 +#include <asm/io.h>
2143 +#include <ar231x_platform.h>
2144 +#include <ar2315_regs.h>
2145 +#include <ar231x.h>
2146 +#include "devices.h"
2147 +#include "ar2315.h"
2149 +static u32 gpiointmask = 0, gpiointval = 0;
2151 +static inline void ar2315_gpio_irq(void)
2156 + /* only do one gpio interrupt at a time */
2157 + pend = (ar231x_read_reg(AR2315_GPIO_DI) ^ gpiointval) & gpiointmask;
2160 + bit = fls(pend) - 1;
2161 + pend &= ~(1 << bit);
2162 + gpiointval ^= (1 << bit);
2166 + ar231x_write_reg(AR2315_ISR, AR2315_ISR_GPIO);
2168 + /* Enable interrupt with edge detection */
2169 + if ((ar231x_read_reg(AR2315_GPIO_CR) & AR2315_GPIO_CR_M(bit)) != AR2315_GPIO_CR_I(bit))
2173 + do_IRQ(AR531X_GPIO_IRQ_BASE + bit);
2178 + * Called when an interrupt is received, this function
2179 + * determines exactly which interrupt it was, and it
2180 + * invokes the appropriate handler.
2182 + * Implicitly, we also define interrupt priority by
2183 + * choosing which to dispatch first.
2185 +static asmlinkage void
2186 +ar2315_irq_dispatch(void)
2188 + int pending = read_c0_status() & read_c0_cause();
2190 + if (pending & CAUSEF_IP3)
2191 + do_IRQ(AR2315_IRQ_WLAN0_INTRS);
2192 + else if (pending & CAUSEF_IP4)
2193 + do_IRQ(AR2315_IRQ_ENET0_INTRS);
2194 + else if (pending & CAUSEF_IP2) {
2195 + unsigned int misc_intr = ar231x_read_reg(AR2315_ISR) & ar231x_read_reg(AR2315_IMR);
2197 + if (misc_intr & AR2315_ISR_SPI)
2198 + do_IRQ(AR531X_MISC_IRQ_SPI);
2199 + else if (misc_intr & AR2315_ISR_TIMER)
2200 + do_IRQ(AR531X_MISC_IRQ_TIMER);
2201 + else if (misc_intr & AR2315_ISR_AHB)
2202 + do_IRQ(AR531X_MISC_IRQ_AHB_PROC);
2203 + else if (misc_intr & AR2315_ISR_GPIO)
2204 + ar2315_gpio_irq();
2205 + else if (misc_intr & AR2315_ISR_UART0)
2206 + do_IRQ(AR531X_MISC_IRQ_UART0);
2207 + else if (misc_intr & AR2315_ISR_WD)
2208 + do_IRQ(AR531X_MISC_IRQ_WATCHDOG);
2210 + do_IRQ(AR531X_MISC_IRQ_NONE);
2211 + } else if (pending & CAUSEF_IP7)
2212 + do_IRQ(AR531X_IRQ_CPU_CLOCK);
2215 +static void ar2315_set_gpiointmask(int gpio, int level)
2219 + reg = ar231x_read_reg(AR2315_GPIO_INT);
2220 + reg &= ~(AR2315_GPIO_INT_M | AR2315_GPIO_INT_LVL_M);
2221 + reg |= gpio | AR2315_GPIO_INT_LVL(level);
2222 + ar231x_write_reg(AR2315_GPIO_INT, reg);
2225 +static void ar2315_gpio_intr_enable(struct irq_data *d)
2227 + unsigned int gpio = d->irq - AR531X_GPIO_IRQ_BASE;
2229 + /* Enable interrupt with edge detection */
2230 + if ((ar231x_read_reg(AR2315_GPIO_CR) & AR2315_GPIO_CR_M(gpio)) != AR2315_GPIO_CR_I(gpio))
2233 + gpiointmask |= (1 << gpio);
2234 + ar2315_set_gpiointmask(gpio, 3);
2237 +static void ar2315_gpio_intr_disable(struct irq_data *d)
2239 + unsigned int gpio = d->irq - AR531X_GPIO_IRQ_BASE;
2241 + /* Disable interrupt */
2242 + gpiointmask &= ~(1 << gpio);
2243 + ar2315_set_gpiointmask(gpio, 0);
2246 +static struct irq_chip ar2315_gpio_intr_controller = {
2247 + .irq_mask = ar2315_gpio_intr_disable,
2248 + .irq_unmask = ar2315_gpio_intr_enable,
2252 +ar2315_misc_intr_enable(struct irq_data *d)
2256 + imr = ar231x_read_reg(AR2315_IMR);
2258 + case AR531X_MISC_IRQ_SPI:
2259 + imr |= AR2315_ISR_SPI;
2261 + case AR531X_MISC_IRQ_TIMER:
2262 + imr |= AR2315_ISR_TIMER;
2264 + case AR531X_MISC_IRQ_AHB_PROC:
2265 + imr |= AR2315_ISR_AHB;
2267 + case AR531X_MISC_IRQ_GPIO:
2268 + imr |= AR2315_ISR_GPIO;
2270 + case AR531X_MISC_IRQ_UART0:
2271 + imr |= AR2315_ISR_UART0;
2273 + case AR531X_MISC_IRQ_WATCHDOG:
2274 + imr |= AR2315_ISR_WD;
2279 + ar231x_write_reg(AR2315_IMR, imr);
2283 +ar2315_misc_intr_disable(struct irq_data *d)
2287 + imr = ar231x_read_reg(AR2315_IMR);
2289 + case AR531X_MISC_IRQ_SPI:
2290 + imr &= ~AR2315_ISR_SPI;
2292 + case AR531X_MISC_IRQ_TIMER:
2293 + imr &= ~AR2315_ISR_TIMER;
2295 + case AR531X_MISC_IRQ_AHB_PROC:
2296 + imr &= ~AR2315_ISR_AHB;
2298 + case AR531X_MISC_IRQ_GPIO:
2299 + imr &= ~AR2315_ISR_GPIO;
2301 + case AR531X_MISC_IRQ_UART0:
2302 + imr &= ~AR2315_ISR_UART0;
2304 + case AR531X_MISC_IRQ_WATCHDOG:
2305 + imr &= ~AR2315_ISR_WD;
2310 + ar231x_write_reg(AR2315_IMR, imr);
2313 +static struct irq_chip ar2315_misc_intr_controller = {
2314 + .irq_mask = ar2315_misc_intr_disable,
2315 + .irq_unmask = ar2315_misc_intr_enable,
2318 +static irqreturn_t ar2315_ahb_proc_handler(int cpl, void *dev_id)
2320 + ar231x_write_reg(AR2315_AHB_ERR0, AHB_ERROR_DET);
2321 + ar231x_read_reg(AR2315_AHB_ERR1);
2323 + printk(KERN_ERR "AHB fatal error\n");
2324 + machine_restart("AHB error"); /* Catastrophic failure */
2326 + return IRQ_HANDLED;
2329 +static struct irqaction ar2315_ahb_proc_interrupt = {
2330 + .handler = ar2315_ahb_proc_handler,
2331 + .name = "ar2315_ahb_proc_interrupt",
2334 +static struct irqaction cascade = {
2335 + .handler = no_action,
2336 + .name = "cascade",
2340 +ar2315_irq_init(void)
2347 + ar231x_irq_dispatch = ar2315_irq_dispatch;
2348 + gpiointval = ar231x_read_reg(AR2315_GPIO_DI);
2349 + for (i = 0; i < AR531X_MISC_IRQ_COUNT; i++) {
2350 + int irq = AR531X_MISC_IRQ_BASE + i;
2351 + irq_set_chip_and_handler(irq, &ar2315_misc_intr_controller,
2352 + handle_level_irq);
2354 + for (i = 0; i < AR531X_GPIO_IRQ_COUNT; i++) {
2355 + int irq = AR531X_GPIO_IRQ_BASE + i;
2356 + irq_set_chip_and_handler(irq, &ar2315_gpio_intr_controller,
2357 + handle_level_irq);
2359 + setup_irq(AR531X_MISC_IRQ_GPIO, &cascade);
2360 + setup_irq(AR531X_MISC_IRQ_AHB_PROC, &ar2315_ahb_proc_interrupt);
2361 + setup_irq(AR2315_IRQ_MISC_INTRS, &cascade);
2365 +ar2315_gpio_set_output(u32 mask, u32 val)
2369 + reg = ar231x_read_reg(AR2315_GPIO_CR);
2372 + ar231x_write_reg(AR2315_GPIO_CR, reg);
2377 +ar2315_gpio_get(u32 valid_mask)
2380 + reg = ar231x_read_reg(AR2315_GPIO_DI);
2381 + reg &= valid_mask;
2386 +ar2315_gpio_set(u32 mask, u32 value)
2389 + reg = ar231x_read_reg(AR2315_GPIO_DO);
2392 + ar231x_write_reg(AR2315_GPIO_DO, reg);
2397 + * gpiolib implementation. Original legacy mask based methods
2398 + * preserved for now.
2401 +ar2315_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
2403 + struct ar231x_gpio_chip *gpch =
2404 + container_of(chip, struct ar231x_gpio_chip, chip);
2405 + u32 mask = 1 << gpio;
2407 + if (!(gpch->valid_mask & mask))
2409 + rett = ar2315_gpio_get(gpch->valid_mask); // legacy code
2410 + return !!(rett & mask);
2414 +ar2315_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
2416 + struct ar231x_gpio_chip *gpch =
2417 + container_of(chip, struct ar231x_gpio_chip, chip);
2418 + u32 mask = 1 << gpio;
2419 + if (!(gpch->valid_mask & mask))
2421 + ar2315_gpio_set(mask, (!!value) * mask); // legacy
2425 +ar2315_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
2427 + struct ar231x_gpio_chip *gpch =
2428 + container_of(chip, struct ar231x_gpio_chip, chip);
2429 + u32 mask = 1 << gpio;
2430 + if (!(gpch->valid_mask & mask))
2432 + ar2315_gpio_set_output(mask, 0); // legacy
2437 +ar2315_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value)
2439 + struct ar231x_gpio_chip *gpch =
2440 + container_of(chip, struct ar231x_gpio_chip, chip);
2441 + u32 mask = 1 << gpio;
2442 + if (!(gpch->valid_mask & mask))
2444 + ar2315_gpio_set_output(mask, mask); // both legacy
2445 + ar2315_gpio_set(mask, (!!value) * mask);
2449 +static struct ar231x_gpio_chip ar2315_gpio_chip = {
2450 + .valid_mask = (1 << 22) - 1,
2452 + .label = "ar2315-gpio",
2453 + .direction_input = ar2315_gpio_direction_input,
2454 + .direction_output = ar2315_gpio_direction_output,
2455 + .set = ar2315_gpio_set_value,
2456 + .get = ar2315_gpio_get_value,
2458 + .ngpio = AR531X_GPIO_IRQ_COUNT, // 22
2465 +static struct ar231x_eth ar2315_eth_data = {
2466 + .reset_base = AR2315_RESET,
2467 + .reset_mac = AR2315_RESET_ENET0,
2468 + .reset_phy = AR2315_RESET_EPHY0,
2469 + .phy_base = KSEG1ADDR(AR2315_ENET0),
2470 + .config = &ar231x_board,
2473 +static struct resource ar2315_spiflash_res[] = {
2475 + .name = "flash_base",
2476 + .flags = IORESOURCE_MEM,
2477 + .start = KSEG1ADDR(AR2315_SPI_READ),
2478 + .end = KSEG1ADDR(AR2315_SPI_READ) + 0x1000000 - 1,
2481 + .name = "flash_regs",
2482 + .flags = IORESOURCE_MEM,
2483 + .start = 0x11300000,
2484 + .end = 0x11300012,
2488 +static struct platform_device ar2315_spiflash = {
2490 + .name = "spiflash",
2491 + .resource = ar2315_spiflash_res,
2492 + .num_resources = ARRAY_SIZE(ar2315_spiflash_res)
2495 +static struct platform_device ar2315_wdt = {
2497 + .name = "ar2315_wdt",
2500 +#define SPI_FLASH_CTL 0x00
2501 +#define SPI_FLASH_OPCODE 0x04
2502 +#define SPI_FLASH_DATA 0x08
2505 +spiflash_read_reg(int reg)
2507 + return ar231x_read_reg(AR2315_SPI + reg);
2511 +spiflash_write_reg(int reg, u32 data)
2513 + ar231x_write_reg(AR2315_SPI + reg, data);
2517 +spiflash_wait_status(void)
2522 + reg = spiflash_read_reg(SPI_FLASH_CTL);
2523 + } while (reg & SPI_CTL_BUSY);
2529 +spiflash_probe(void)
2533 + reg = spiflash_wait_status();
2534 + reg &= ~SPI_CTL_TX_RX_CNT_MASK;
2535 + reg |= (1 << 4) | 4 | SPI_CTL_START;
2537 + spiflash_write_reg(SPI_FLASH_OPCODE, 0xab);
2538 + spiflash_write_reg(SPI_FLASH_CTL, reg);
2540 + reg = spiflash_wait_status();
2541 + reg = spiflash_read_reg(SPI_FLASH_DATA);
2548 +#define STM_8MBIT_SIGNATURE 0x13
2549 +#define STM_16MBIT_SIGNATURE 0x14
2550 +#define STM_32MBIT_SIGNATURE 0x15
2551 +#define STM_64MBIT_SIGNATURE 0x16
2552 +#define STM_128MBIT_SIGNATURE 0x17
2555 +ar2315_flash_limit(void)
2557 + u32 flash_size = 0;
2559 + /* probe the flash chip size */
2560 + switch(spiflash_probe()) {
2561 + case STM_8MBIT_SIGNATURE:
2562 + flash_size = 0x00100000;
2564 + case STM_16MBIT_SIGNATURE:
2565 + flash_size = 0x00200000;
2567 + case STM_32MBIT_SIGNATURE:
2568 + flash_size = 0x00400000;
2570 + case STM_64MBIT_SIGNATURE:
2571 + flash_size = 0x00800000;
2573 + case STM_128MBIT_SIGNATURE:
2574 + flash_size = 0x01000000;
2578 + ar2315_spiflash_res[0].end = ar2315_spiflash_res[0].start +
2580 + return (u8 *) ar2315_spiflash_res[0].end + 1;
2583 +#ifdef CONFIG_LEDS_GPIO
2584 +static struct gpio_led ar2315_leds[6];
2585 +static struct gpio_led_platform_data ar2315_led_data = {
2586 + .leds = (void *) ar2315_leds,
2589 +static struct platform_device ar2315_gpio_leds = {
2590 + .name = "leds-gpio",
2593 + .platform_data = (void *) &ar2315_led_data,
2598 +ar2315_init_gpio_leds(void)
2600 + static char led_names[6][6];
2603 + ar2315_led_data.num_leds = 0;
2604 + for(i = 1; i < 8; i++)
2606 + if((i == AR2315_RESET_GPIO) ||
2607 + (i == ar231x_board.config->resetConfigGpio))
2610 + if(i == ar231x_board.config->sysLedGpio)
2611 + strcpy(led_names[led], "wlan");
2613 + sprintf(led_names[led], "gpio%d", i);
2615 + ar2315_leds[led].name = led_names[led];
2616 + ar2315_leds[led].gpio = i;
2617 + ar2315_leds[led].active_low = 0;
2620 + ar2315_led_data.num_leds = led;
2621 + platform_device_register(&ar2315_gpio_leds);
2624 +static inline void ar2315_init_gpio_leds(void)
2630 +ar2315_init_devices(void)
2635 + /* Find board configuration */
2636 + ar231x_find_config(ar2315_flash_limit());
2637 + ar2315_eth_data.macaddr = ar231x_board.config->enet0_mac;
2639 + ar2315_init_gpio_leds();
2640 + platform_device_register(&ar2315_wdt);
2641 + platform_device_register(&ar2315_spiflash);
2642 + ar231x_add_ethernet(0, KSEG1ADDR(AR2315_ENET0), AR2315_IRQ_ENET0_INTRS,
2643 + &ar2315_eth_data);
2644 + ar231x_add_wmac(0, AR2315_WLAN0, AR2315_IRQ_WLAN0_INTRS);
2650 +ar2315_restart(char *command)
2652 + void (*mips_reset_vec)(void) = (void *) 0xbfc00000;
2654 + local_irq_disable();
2656 + /* try reset the system via reset control */
2657 + ar231x_write_reg(AR2315_COLD_RESET,AR2317_RESET_SYSTEM);
2659 + /* Cold reset does not work on the AR2315/6, use the GPIO reset bits a workaround.
2660 + * give it some time to attempt a gpio based hardware reset
2661 + * (atheros reference design workaround) */
2662 + gpio_direction_output(AR2315_RESET_GPIO, 0);
2665 + /* Some boards (e.g. Senao EOC-2610) don't implement the reset logic
2666 + * workaround. Attempt to jump to the mips reset location -
2667 + * the boot loader itself might be able to recover the system */
2673 + * This table is indexed by bits 5..4 of the CLOCKCTL1 register
2674 + * to determine the predevisor value.
2676 +static int __initdata CLOCKCTL1_PREDIVIDE_TABLE[4] = { 1, 2, 4, 5 };
2677 +static int __initdata PLLC_DIVIDE_TABLE[5] = { 2, 3, 4, 6, 3 };
2679 +static unsigned int __init
2680 +ar2315_sys_clk(unsigned int clockCtl)
2682 + unsigned int pllcCtrl,cpuDiv;
2683 + unsigned int pllcOut,refdiv,fdiv,divby2;
2684 + unsigned int clkDiv;
2686 + pllcCtrl = ar231x_read_reg(AR2315_PLLC_CTL);
2687 + refdiv = (pllcCtrl & PLLC_REF_DIV_M) >> PLLC_REF_DIV_S;
2688 + refdiv = CLOCKCTL1_PREDIVIDE_TABLE[refdiv];
2689 + fdiv = (pllcCtrl & PLLC_FDBACK_DIV_M) >> PLLC_FDBACK_DIV_S;
2690 + divby2 = (pllcCtrl & PLLC_ADD_FDBACK_DIV_M) >> PLLC_ADD_FDBACK_DIV_S;
2692 + pllcOut = (40000000/refdiv)*(2*divby2)*fdiv;
2695 + /* clkm input selected */
2696 + switch(clockCtl & CPUCLK_CLK_SEL_M) {
2699 + clkDiv = PLLC_DIVIDE_TABLE[(pllcCtrl & PLLC_CLKM_DIV_M) >> PLLC_CLKM_DIV_S];
2702 + clkDiv = PLLC_DIVIDE_TABLE[(pllcCtrl & PLLC_CLKC_DIV_M) >> PLLC_CLKC_DIV_S];
2705 + pllcOut = 40000000;
2709 + cpuDiv = (clockCtl & CPUCLK_CLK_DIV_M) >> CPUCLK_CLK_DIV_S;
2710 + cpuDiv = cpuDiv * 2 ?: 1;
2711 + return (pllcOut/(clkDiv * cpuDiv));
2714 +static inline unsigned int
2715 +ar2315_cpu_frequency(void)
2717 + return ar2315_sys_clk(ar231x_read_reg(AR2315_CPUCLK));
2720 +static inline unsigned int
2721 +ar2315_apb_frequency(void)
2723 + return ar2315_sys_clk(ar231x_read_reg(AR2315_AMBACLK));
2727 +ar2315_time_init(void)
2732 + mips_hpt_frequency = ar2315_cpu_frequency() / 2;
2736 +ar2315_gpio_init(void)
2739 + struct ar231x_gpio_chip *gpch;
2740 + gpch = &ar2315_gpio_chip;
2741 + ret = gpiochip_add(&gpch->chip);
2743 + printk(KERN_ERR "%s: failed to add gpiochip\n",
2744 + gpch->chip.label);
2747 + printk(KERN_INFO "%s: registered %d GPIOs\n",
2748 + gpch->chip.label, gpch->chip.ngpio);
2755 +ar2315_prom_init(void)
2757 + u32 memsize, memcfg, devid;
2762 + memcfg = ar231x_read_reg(AR2315_MEM_CFG);
2763 + memsize = 1 + ((memcfg & SDRAM_DATA_WIDTH_M) >> SDRAM_DATA_WIDTH_S);
2764 + memsize <<= 1 + ((memcfg & SDRAM_COL_WIDTH_M) >> SDRAM_COL_WIDTH_S);
2765 + memsize <<= 1 + ((memcfg & SDRAM_ROW_WIDTH_M) >> SDRAM_ROW_WIDTH_S);
2767 + add_memory_region(0, memsize, BOOT_MEM_RAM);
2769 + /* Detect the hardware based on the device ID */
2770 + devid = ar231x_read_reg(AR2315_SREV) & AR2315_REV_CHIP;
2774 + ar231x_devtype = DEV_TYPE_AR2317;
2777 + ar231x_devtype = DEV_TYPE_AR2315;
2780 + ar2315_gpio_init();
2781 + ar231x_board.devid = devid;
2785 +ar2315_plat_setup(void)
2792 + gpio_request(AR2315_RESET_GPIO, "reset");
2794 + /* Clear any lingering AHB errors */
2795 + config = read_c0_config();
2796 + write_c0_config(config & ~0x3);
2797 + ar231x_write_reg(AR2315_AHB_ERR0,AHB_ERROR_DET);
2798 + ar231x_read_reg(AR2315_AHB_ERR1);
2799 + ar231x_write_reg(AR2315_WDC, AR2315_WDC_IGNORE_EXPIRATION);
2801 + _machine_restart = ar2315_restart;
2802 + ar231x_serial_setup(KSEG1ADDR(AR2315_UART0), ar2315_apb_frequency());
2805 +++ b/arch/mips/ar231x/ar2315.h
2810 +#ifdef CONFIG_ATHEROS_AR2315
2812 +extern void ar2315_irq_init(void);
2813 +extern int ar2315_init_devices(void);
2814 +extern void ar2315_prom_init(void);
2815 +extern void ar2315_plat_setup(void);
2816 +extern void ar2315_time_init(void);
2820 +static inline void ar2315_irq_init(void)
2824 +static inline int ar2315_init_devices(void)
2829 +static inline void ar2315_prom_init(void)
2833 +static inline void ar2315_plat_setup(void)
2837 +static inline void ar2315_time_init(void)
2845 +++ b/arch/mips/ar231x/ar5312.h
2850 +#ifdef CONFIG_ATHEROS_AR5312
2852 +extern void ar5312_irq_init(void);
2853 +extern int ar5312_init_devices(void);
2854 +extern void ar5312_prom_init(void);
2855 +extern void ar5312_plat_setup(void);
2856 +extern void ar5312_time_init(void);
2857 +extern void ar5312_time_init(void);
2861 +static inline void ar5312_irq_init(void)
2865 +static inline int ar5312_init_devices(void)
2870 +static inline void ar5312_prom_init(void)
2874 +static inline void ar5312_plat_setup(void)
2878 +static inline void ar5312_time_init(void)
2886 +++ b/arch/mips/include/asm/mach-ar231x/ar231x.h
2891 +#define AR531X_MISC_IRQ_BASE 0x20
2892 +#define AR531X_GPIO_IRQ_BASE 0x30
2894 +/* Software's idea of interrupts handled by "CPU Interrupt Controller" */
2895 +#define AR531X_IRQ_NONE MIPS_CPU_IRQ_BASE+0
2896 +#define AR531X_IRQ_CPU_CLOCK MIPS_CPU_IRQ_BASE+7 /* C0_CAUSE: 0x8000 */
2898 +/* Miscellaneous interrupts, which share IP6 */
2899 +#define AR531X_MISC_IRQ_NONE AR531X_MISC_IRQ_BASE+0
2900 +#define AR531X_MISC_IRQ_TIMER AR531X_MISC_IRQ_BASE+1
2901 +#define AR531X_MISC_IRQ_AHB_PROC AR531X_MISC_IRQ_BASE+2
2902 +#define AR531X_MISC_IRQ_AHB_DMA AR531X_MISC_IRQ_BASE+3
2903 +#define AR531X_MISC_IRQ_GPIO AR531X_MISC_IRQ_BASE+4
2904 +#define AR531X_MISC_IRQ_UART0 AR531X_MISC_IRQ_BASE+5
2905 +#define AR531X_MISC_IRQ_UART0_DMA AR531X_MISC_IRQ_BASE+6
2906 +#define AR531X_MISC_IRQ_WATCHDOG AR531X_MISC_IRQ_BASE+7
2907 +#define AR531X_MISC_IRQ_LOCAL AR531X_MISC_IRQ_BASE+8
2908 +#define AR531X_MISC_IRQ_SPI AR531X_MISC_IRQ_BASE+9
2909 +#define AR531X_MISC_IRQ_COUNT 10
2911 +/* GPIO Interrupts [0..7], share AR531X_MISC_IRQ_GPIO */
2912 +#define AR531X_GPIO_IRQ_NONE AR531X_GPIO_IRQ_BASE+0
2913 +#define AR531X_GPIO_IRQ(n) AR531X_GPIO_IRQ_BASE+n
2914 +#define AR531X_GPIO_IRQ_COUNT 22
2917 +ar231x_read_reg(u32 reg)
2919 + return __raw_readl((u32 *) KSEG1ADDR(reg));
2923 +ar231x_write_reg(u32 reg, u32 val)
2925 + __raw_writel(val, (u32 *) KSEG1ADDR(reg));
2929 +ar231x_mask_reg(u32 reg, u32 mask, u32 val)
2933 + ret = ar231x_read_reg(reg);
2936 + ar231x_write_reg(reg, ret);
2943 +++ b/arch/mips/ar231x/devices.h
2945 +#ifndef __AR231X_DEVICES_H
2946 +#define __AR231X_DEVICES_H
2947 +#include <linux/gpio.h>
2950 + /* handled by ar5312.c */
2955 + /* handled by ar2315.c */
2963 +extern int ar231x_devtype;
2964 +extern struct ar231x_board_config ar231x_board;
2965 +extern asmlinkage void (*ar231x_irq_dispatch)(void);
2967 +extern int ar231x_find_config(u8 *flash_limit);
2968 +extern void ar231x_serial_setup(u32 mapbase, unsigned int uartclk);
2969 +extern int ar231x_add_wmac(int nr, u32 base, int irq);
2970 +extern int ar231x_add_ethernet(int nr, u32 base, int irq, void *pdata);
2972 +static inline bool is_2315(void)
2974 + return (current_cpu_data.cputype == CPU_4KEC);
2977 +static inline bool is_5312(void)
2979 + return !is_2315();
2982 +struct ar231x_gpio_chip {
2984 + struct gpio_chip chip;
2988 +++ b/arch/mips/ar231x/devices.c
2990 +#include <linux/kernel.h>
2991 +#include <linux/init.h>
2992 +#include <linux/serial.h>
2993 +#include <linux/serial_core.h>
2994 +#include <linux/serial_8250.h>
2995 +#include <linux/platform_device.h>
2996 +#include <ar231x_platform.h>
2997 +#include <ar231x.h>
2998 +#include "devices.h"
2999 +#include "ar5312.h"
3000 +#include "ar2315.h"
3002 +struct ar231x_board_config ar231x_board;
3003 +int ar231x_devtype = DEV_TYPE_UNKNOWN;
3005 +static struct resource ar231x_eth0_res[] = {
3007 + .name = "eth0_membase",
3008 + .flags = IORESOURCE_MEM,
3011 + .name = "eth0_irq",
3012 + .flags = IORESOURCE_IRQ,
3016 +static struct resource ar231x_eth1_res[] = {
3018 + .name = "eth1_membase",
3019 + .flags = IORESOURCE_MEM,
3022 + .name = "eth1_irq",
3023 + .flags = IORESOURCE_IRQ,
3027 +static struct platform_device ar231x_eth[] = {
3030 + .name = "ar231x-eth",
3031 + .resource = ar231x_eth0_res,
3032 + .num_resources = ARRAY_SIZE(ar231x_eth0_res)
3036 + .name = "ar231x-eth",
3037 + .resource = ar231x_eth1_res,
3038 + .num_resources = ARRAY_SIZE(ar231x_eth1_res)
3042 +static struct resource ar231x_wmac0_res[] = {
3044 + .name = "wmac0_membase",
3045 + .flags = IORESOURCE_MEM,
3048 + .name = "wmac0_irq",
3049 + .flags = IORESOURCE_IRQ,
3053 +static struct resource ar231x_wmac1_res[] = {
3055 + .name = "wmac1_membase",
3056 + .flags = IORESOURCE_MEM,
3059 + .name = "wmac1_irq",
3060 + .flags = IORESOURCE_IRQ,
3065 +static struct platform_device ar231x_wmac[] = {
3068 + .name = "ar231x-wmac",
3069 + .resource = ar231x_wmac0_res,
3070 + .num_resources = ARRAY_SIZE(ar231x_wmac0_res),
3071 + .dev.platform_data = &ar231x_board,
3075 + .name = "ar231x-wmac",
3076 + .resource = ar231x_wmac1_res,
3077 + .num_resources = ARRAY_SIZE(ar231x_wmac1_res),
3078 + .dev.platform_data = &ar231x_board,
3082 +static const char *devtype_strings[] = {
3083 + [DEV_TYPE_AR5312] = "Atheros AR5312",
3084 + [DEV_TYPE_AR2312] = "Atheros AR2312",
3085 + [DEV_TYPE_AR2313] = "Atheros AR2313",
3086 + [DEV_TYPE_AR2315] = "Atheros AR2315",
3087 + [DEV_TYPE_AR2316] = "Atheros AR2316",
3088 + [DEV_TYPE_AR2317] = "Atheros AR2317",
3089 + [DEV_TYPE_UNKNOWN] = "Atheros (unknown)",
3092 +const char *get_system_type(void)
3094 + if ((ar231x_devtype >= ARRAY_SIZE(devtype_strings)) ||
3095 + !devtype_strings[ar231x_devtype])
3096 + return devtype_strings[DEV_TYPE_UNKNOWN];
3097 + return devtype_strings[ar231x_devtype];
3102 +ar231x_add_ethernet(int nr, u32 base, int irq, void *pdata)
3104 + struct resource *res;
3106 + ar231x_eth[nr].dev.platform_data = pdata;
3107 + res = &ar231x_eth[nr].resource[0];
3108 + res->start = base;
3109 + res->end = base + 0x2000 - 1;
3113 + return platform_device_register(&ar231x_eth[nr]);
3117 +ar231x_serial_setup(u32 mapbase, unsigned int uartclk)
3119 + struct uart_port s;
3121 + memset(&s, 0, sizeof(s));
3123 + s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
3124 + s.iotype = UPIO_MEM;
3125 + s.irq = AR531X_MISC_IRQ_UART0;
3127 + s.mapbase = mapbase;
3128 + s.uartclk = uartclk;
3129 + s.membase = (void __iomem *)s.mapbase;
3131 + early_serial_setup(&s);
3135 +ar231x_add_wmac(int nr, u32 base, int irq)
3137 + struct resource *res;
3139 + ar231x_wmac[nr].dev.platform_data = &ar231x_board;
3140 + res = &ar231x_wmac[nr].resource[0];
3141 + res->start = base;
3142 + res->end = base + 0x10000 - 1;
3146 + return platform_device_register(&ar231x_wmac[nr]);
3149 +static int __init ar231x_register_devices(void)
3151 + static struct resource res = {
3152 + .start = 0xFFFFFFFF,
3155 + platform_device_register_simple("GPIODEV", 0, &res, 1);
3156 + ar5312_init_devices();
3157 + ar2315_init_devices();
3162 +device_initcall(ar231x_register_devices);