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_KEYS_POLL_INTERVAL 20 /* msecs */
41 #define AP96_KEYS_DEBOUNCE_INTERVAL (3 * AP96_KEYS_POLL_INTERVAL)
43 #define AP96_WMAC0_MAC_OFFSET 0x120c
44 #define AP96_WMAC1_MAC_OFFSET 0x520c
45 #define AP96_CALDATA0_OFFSET 0x1000
46 #define AP96_CALDATA1_OFFSET 0x5000
48 #ifdef CONFIG_MTD_PARTITIONS
49 static struct mtd_partition ap96_partitions
[] = {
54 .mask_flags
= MTD_WRITEABLE
,
59 .mask_flags
= MTD_WRITEABLE
,
72 .mask_flags
= MTD_WRITEABLE
,
75 #endif /* CONFIG_MTD_PARTITIONS */
77 static struct flash_platform_data ap96_flash_data
= {
78 #ifdef CONFIG_MTD_PARTITIONS
79 .parts
= ap96_partitions
,
80 .nr_parts
= ARRAY_SIZE(ap96_partitions
),
85 * AP96 has 12 unlabeled leds in the front; these are numbered from 1 to 12
86 * below (from left to right on the board). Led 1 seems to be on whenever the
87 * board is powered. Led 11 shows LAN link activity actity. Led 3 is orange;
90 * In addition, there is one led next to a button on the right side for WPS.
92 static struct gpio_led ap96_leds_gpio
[] __initdata
= {
94 .name
= "ap96:green:led2",
95 .gpio
= AP96_GPIO_LED_2_GREEN
,
98 .name
= "ap96:green:led3",
99 .gpio
= AP96_GPIO_LED_3_GREEN
,
102 .name
= "ap96:orange:led4",
103 .gpio
= AP96_GPIO_LED_4_ORANGE
,
106 .name
= "ap96:green:led5",
107 .gpio
= AP96_GPIO_LED_5_GREEN
,
110 .name
= "ap96:green:led12",
111 .gpio
= AP96_GPIO_LED_12_GREEN
,
113 }, { /* next to a button on right */
114 .name
= "ap96:green:wps",
115 .gpio
= AP96_GPIO_LED_WPS_GREEN
,
120 static struct gpio_keys_button ap96_gpio_keys
[] __initdata
= {
125 .debounce_interval
= AP96_KEYS_DEBOUNCE_INTERVAL
,
126 .gpio
= AP96_GPIO_BTN_RESET
,
131 .code
= KEY_WPS_BUTTON
,
132 .debounce_interval
= AP96_KEYS_DEBOUNCE_INTERVAL
,
133 .gpio
= AP96_GPIO_BTN_WPS
,
138 #define AP96_WAN_PHYMASK 0x10
139 #define AP96_LAN_PHYMASK 0x0f
141 static void __init
ap96_setup(void)
143 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
145 ar71xx_add_device_mdio(0, ~(AP96_WAN_PHYMASK
| AP96_LAN_PHYMASK
));
147 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, art
, 0);
148 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
149 ar71xx_eth0_data
.phy_mask
= AP96_LAN_PHYMASK
;
150 ar71xx_eth0_data
.speed
= SPEED_1000
;
151 ar71xx_eth0_data
.duplex
= DUPLEX_FULL
;
153 ar71xx_add_device_eth(0);
155 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, art
, 1);
156 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
157 ar71xx_eth1_data
.phy_mask
= AP96_WAN_PHYMASK
;
159 ar71xx_eth1_pll_data
.pll_1000
= 0x1f000000;
161 ar71xx_add_device_eth(1);
163 ar71xx_add_device_usb();
165 ar71xx_add_device_m25p80(&ap96_flash_data
);
167 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap96_leds_gpio
),
170 ar71xx_register_gpio_keys_polled(-1, AP96_KEYS_POLL_INTERVAL
,
171 ARRAY_SIZE(ap96_gpio_keys
),
174 ap94_pci_init(art
+ AP96_CALDATA0_OFFSET
,
175 art
+ AP96_WMAC0_MAC_OFFSET
,
176 art
+ AP96_CALDATA1_OFFSET
,
177 art
+ AP96_WMAC1_MAC_OFFSET
);
180 MIPS_MACHINE(AR71XX_MACH_AP96
, "AP96", "Atheros AP96", ap96_setup
);