2 * Atheros AP96 board support
4 * Copyright (C) 2009 Marco Porsch
5 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
6 * Copyright (C) 2010 Atheros Communications
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/delay.h>
18 #include <asm/mach-ar71xx/ar71xx.h>
22 #include "dev-m25p80.h"
23 #include "dev-ap94-pci.h"
24 #include "dev-gpio-buttons.h"
25 #include "dev-leds-gpio.h"
28 #define AP96_GPIO_LED_12_GREEN 0
29 #define AP96_GPIO_LED_3_GREEN 1
30 #define AP96_GPIO_LED_2_GREEN 2
31 #define AP96_GPIO_LED_WPS_GREEN 4
32 #define AP96_GPIO_LED_5_GREEN 5
33 #define AP96_GPIO_LED_4_ORANGE 6
35 /* Reset button - next to the power connector */
36 #define AP96_GPIO_BTN_RESET 3
37 /* WPS button - next to a led on right */
38 #define AP96_GPIO_BTN_WPS 8
40 #define AP96_BUTTONS_POLL_INTERVAL 20
42 #define AP96_WMAC0_MAC_OFFSET 0x120c
43 #define AP96_WMAC1_MAC_OFFSET 0x520c
44 #define AP96_CALDATA0_OFFSET 0x1000
45 #define AP96_CALDATA1_OFFSET 0x5000
47 #ifdef CONFIG_MTD_PARTITIONS
48 static struct mtd_partition ap96_partitions[] = {
53 .mask_flags = MTD_WRITEABLE,
58 .mask_flags = MTD_WRITEABLE,
71 .mask_flags = MTD_WRITEABLE,
74 #endif /* CONFIG_MTD_PARTITIONS */
76 static struct flash_platform_data ap96_flash_data = {
77 #ifdef CONFIG_MTD_PARTITIONS
78 .parts = ap96_partitions,
79 .nr_parts = ARRAY_SIZE(ap96_partitions),
84 * AP96 has 12 unlabeled leds in the front; these are numbered from 1 to 12
85 * below (from left to right on the board). Led 1 seems to be on whenever the
86 * board is powered. Led 11 shows LAN link activity actity. Led 3 is orange;
89 * In addition, there is one led next to a button on the right side for WPS.
91 static struct gpio_led ap96_leds_gpio[] __initdata = {
93 .name = "ap96:green:led2",
94 .gpio = AP96_GPIO_LED_2_GREEN,
97 .name = "ap96:green:led3",
98 .gpio = AP96_GPIO_LED_3_GREEN,
101 .name = "ap96:orange:led4",
102 .gpio = AP96_GPIO_LED_4_ORANGE,
105 .name = "ap96:green:led5",
106 .gpio = AP96_GPIO_LED_5_GREEN,
109 .name = "ap96:green:led12",
110 .gpio = AP96_GPIO_LED_12_GREEN,
112 }, { /* next to a button on right */
113 .name = "ap96:green:wps",
114 .gpio = AP96_GPIO_LED_WPS_GREEN,
119 static struct gpio_button ap96_gpio_buttons[] __initdata = {
125 .gpio = AP96_GPIO_BTN_RESET,
130 .code = KEY_WPS_BUTTON,
132 .gpio = AP96_GPIO_BTN_WPS,
137 static void __init ap96_setup(void)
139 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
141 ar71xx_add_device_mdio(0xfffffffe);
143 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, art, 0);
144 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
145 ar71xx_eth0_data.phy_mask = 0x1;
147 ar71xx_add_device_eth(0);
149 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, art, 1);
150 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
151 ar71xx_eth1_data.speed = SPEED_1000;
152 ar71xx_eth1_data.duplex = DUPLEX_FULL;
154 ar71xx_eth1_pll_data.pll_1000 = 0x1f000000;
156 ar71xx_add_device_eth(1);
158 ar71xx_add_device_usb();
160 ar71xx_add_device_m25p80(&ap96_flash_data);
162 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap96_leds_gpio),
165 ar71xx_add_device_gpio_buttons(-1, AP96_BUTTONS_POLL_INTERVAL,
166 ARRAY_SIZE(ap96_gpio_buttons),
169 ap94_pci_init(art + AP96_CALDATA0_OFFSET,
170 art + AP96_WMAC0_MAC_OFFSET,
171 art + AP96_CALDATA1_OFFSET,
172 art + AP96_WMAC1_MAC_OFFSET);
175 MIPS_MACHINE(AR71XX_MACH_AP96, "AP96", "Atheros AP96", ap96_setup);