2 * Atheros AP121 board support
4 * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13 #include <linux/spi/flash.h>
17 #include "dev-ar9xxx-wmac.h"
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
23 #define AP121_GPIO_LED_WLAN 0
24 #define AP121_GPIO_LED_USB 1
26 #define AP121_GPIO_BTN_JUMPSTART 11
27 #define AP121_GPIO_BTN_RESET 12
29 #define AP121_KEYS_POLL_INTERVAL 20 /* msecs */
30 #define AP121_KEYS_DEBOUNCE_INTERVAL (3 * AP121_KEYS_POLL_INTERVAL)
32 #define AP121_MAC0_OFFSET 0x0000
33 #define AP121_MAC1_OFFSET 0x0006
34 #define AP121_CALDATA_OFFSET 0x1000
35 #define AP121_WMAC_MAC_OFFSET 0x1002
37 #define AP121_MINI_GPIO_LED_WLAN 0
38 #define AP121_MINI_GPIO_BTN_JUMPSTART 12
39 #define AP121_MINI_GPIO_BTN_RESET 11
41 #ifdef CONFIG_MTD_PARTITIONS
42 static struct mtd_partition ap121_parts[] = {
47 .mask_flags = MTD_WRITEABLE,
68 .mask_flags = MTD_WRITEABLE,
71 #define ap121_nr_parts ARRAY_SIZE(ap121_parts)
73 static struct mtd_partition ap121_mini_parts[] = {
78 .mask_flags = MTD_WRITEABLE,
84 .mask_flags = MTD_WRITEABLE,
105 .mask_flags = MTD_WRITEABLE,
109 #define ap121_mini_nr_parts ARRAY_SIZE(ap121_parts)
112 #define ap121_parts NULL
113 #define ap121_nr_parts 0
114 #define ap121_mini_parts NULL
115 #define ap121_mini_nr_parts 0
116 #endif /* CONFIG_MTD_PARTITIONS */
118 static struct flash_platform_data ap121_flash_data = {
119 .parts = ap121_parts,
120 .nr_parts = ap121_nr_parts,
123 static struct gpio_led ap121_leds_gpio[] __initdata = {
125 .name = "ap121:green:usb",
126 .gpio = AP121_GPIO_LED_USB,
130 .name = "ap121:green:wlan",
131 .gpio = AP121_GPIO_LED_WLAN,
136 static struct gpio_keys_button ap121_gpio_keys[] __initdata = {
138 .desc = "jumpstart button",
140 .code = KEY_WPS_BUTTON,
141 .debounce_interval = AP121_KEYS_DEBOUNCE_INTERVAL,
142 .gpio = AP121_GPIO_BTN_JUMPSTART,
146 .desc = "reset button",
149 .debounce_interval = AP121_KEYS_DEBOUNCE_INTERVAL,
150 .gpio = AP121_GPIO_BTN_RESET,
155 static struct gpio_led ap121_mini_leds_gpio[] __initdata = {
157 .name = "ap121:green:wlan",
158 .gpio = AP121_MINI_GPIO_LED_WLAN,
163 static struct gpio_keys_button ap121_mini_gpio_keys[] __initdata = {
165 .desc = "jumpstart button",
167 .code = KEY_WPS_BUTTON,
168 .debounce_interval = AP121_KEYS_DEBOUNCE_INTERVAL,
169 .gpio = AP121_MINI_GPIO_BTN_JUMPSTART,
173 .desc = "reset button",
176 .debounce_interval = AP121_KEYS_DEBOUNCE_INTERVAL,
177 .gpio = AP121_MINI_GPIO_BTN_RESET,
182 static void __init ap121_common_setup(void)
184 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
186 ar71xx_add_device_m25p80(&ap121_flash_data);
188 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, art + AP121_MAC0_OFFSET, 0);
189 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, art + AP121_MAC1_OFFSET, 0);
191 ar71xx_add_device_mdio(0, 0x0);
194 ar71xx_add_device_eth(1);
197 ar71xx_add_device_eth(0);
199 ar9xxx_add_device_wmac(art + AP121_CALDATA_OFFSET,
200 art + AP121_WMAC_MAC_OFFSET);
203 static void __init ap121_setup(void)
205 ap121_flash_data.parts = ap121_parts;
206 ap121_flash_data.nr_parts = ap121_nr_parts;
208 ap121_common_setup();
210 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap121_leds_gpio),
212 ar71xx_register_gpio_keys_polled(-1, AP121_KEYS_POLL_INTERVAL,
213 ARRAY_SIZE(ap121_gpio_keys),
216 ar71xx_add_device_usb();
219 static void __init ap121_mini_setup(void)
221 ap121_flash_data.parts = ap121_mini_parts;
222 ap121_flash_data.nr_parts = ap121_mini_nr_parts;
224 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap121_mini_leds_gpio),
225 ap121_mini_leds_gpio);
226 ar71xx_register_gpio_keys_polled(-1, AP121_KEYS_POLL_INTERVAL,
227 ARRAY_SIZE(ap121_mini_gpio_keys),
228 ap121_mini_gpio_keys);
230 ap121_common_setup();
233 MIPS_MACHINE(AR71XX_MACH_AP121, "AP121", "Atheros AP121",
236 MIPS_MACHINE(AR71XX_MACH_AP121_MINI, "AP121-MINI", "Atheros AP121-MINI",