ar71xx: build ALFA AP96 images with default profile as well
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-dir-615-c1.c
1 /*
2 * D-Link DIR-615 rev C1 board support
3 *
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14
15 #include <asm/mach-ar71xx/ar71xx.h>
16
17 #include "machtype.h"
18 #include "devices.h"
19 #include "dev-m25p80.h"
20 #include "dev-ar9xxx-wmac.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "nvram.h"
24
25 #define DIR_615C1_GPIO_LED_ORANGE_STATUS 1 /* ORANGE:STATUS:TRICOLOR */
26 #define DIR_615C1_GPIO_LED_BLUE_WPS 3 /* BLUE:WPS */
27 #define DIR_615C1_GPIO_LED_GREEN_WAN 4 /* GREEN:WAN:TRICOLOR */
28 #define DIR_615C1_GPIO_LED_GREEN_WANCPU 5 /* GREEN:WAN:CPU:TRICOLOR */
29 #define DIR_615C1_GPIO_LED_GREEN_WLAN 6 /* GREEN:WLAN */
30 #define DIR_615C1_GPIO_LED_GREEN_STATUS 14 /* GREEN:STATUS:TRICOLOR */
31 #define DIR_615C1_GPIO_LED_ORANGE_WAN 15 /* ORANGE:WAN:TRICOLOR */
32
33 /* buttons may need refinement */
34
35 #define DIR_615C1_GPIO_BTN_WPS 12
36 #define DIR_615C1_GPIO_BTN_RESET 21
37
38 #define DIR_615C1_KEYS_POLL_INTERVAL 20 /* msecs */
39 #define DIR_615C1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_615C1_KEYS_POLL_INTERVAL)
40
41 #define DIR_615C1_CONFIG_ADDR 0x1f020000
42 #define DIR_615C1_CONFIG_SIZE 0x10000
43
44 #ifdef CONFIG_MTD_PARTITIONS
45 static struct mtd_partition dir_615c1_partitions[] = {
46 {
47 .name = "u-boot",
48 .offset = 0,
49 .size = 0x020000,
50 .mask_flags = MTD_WRITEABLE,
51 }, {
52 .name = "config",
53 .offset = 0x020000,
54 .size = 0x010000,
55 }, {
56 .name = "kernel",
57 .offset = 0x030000,
58 .size = 0x0e0000,
59 }, {
60 .name = "rootfs",
61 .offset = 0x110000,
62 .size = 0x2e0000,
63 }, {
64 .name = "art",
65 .offset = 0x3f0000,
66 .size = 0x010000,
67 .mask_flags = MTD_WRITEABLE,
68 }, {
69 .name = "firmware",
70 .offset = 0x030000,
71 .size = 0x3c0000,
72 }
73 };
74 #endif /* CONFIG_MTD_PARTITIONS */
75
76 static struct flash_platform_data dir_615c1_flash_data = {
77 #ifdef CONFIG_MTD_PARTITIONS
78 .parts = dir_615c1_partitions,
79 .nr_parts = ARRAY_SIZE(dir_615c1_partitions),
80 #endif
81 };
82
83 static struct gpio_led dir_615c1_leds_gpio[] __initdata = {
84 {
85 .name = "dir-615c1:orange:status",
86 .gpio = DIR_615C1_GPIO_LED_ORANGE_STATUS,
87 .active_low = 1,
88 }, {
89 .name = "dir-615c1:blue:wps",
90 .gpio = DIR_615C1_GPIO_LED_BLUE_WPS,
91 .active_low = 1,
92 }, {
93 .name = "dir-615c1:green:wan",
94 .gpio = DIR_615C1_GPIO_LED_GREEN_WAN,
95 .active_low = 1,
96 }, {
97 .name = "dir-615c1:green:wancpu",
98 .gpio = DIR_615C1_GPIO_LED_GREEN_WANCPU,
99 .active_low = 1,
100 }, {
101 .name = "dir-615c1:green:wlan",
102 .gpio = DIR_615C1_GPIO_LED_GREEN_WLAN,
103 .active_low = 1,
104 }, {
105 .name = "dir-615c1:green:status",
106 .gpio = DIR_615C1_GPIO_LED_GREEN_STATUS,
107 .active_low = 1,
108 }, {
109 .name = "dir-615c1:orange:wan",
110 .gpio = DIR_615C1_GPIO_LED_ORANGE_WAN,
111 .active_low = 1,
112 }
113
114 };
115
116 static struct gpio_keys_button dir_615c1_gpio_keys[] __initdata = {
117 {
118 .desc = "reset",
119 .type = EV_KEY,
120 .code = KEY_RESTART,
121 .debounce_interval = DIR_615C1_KEYS_DEBOUNCE_INTERVAL,
122 .gpio = DIR_615C1_GPIO_BTN_RESET,
123 }, {
124 .desc = "wps",
125 .type = EV_KEY,
126 .code = KEY_WPS_BUTTON,
127 .debounce_interval = DIR_615C1_KEYS_DEBOUNCE_INTERVAL,
128 .gpio = DIR_615C1_GPIO_BTN_WPS,
129 }
130 };
131
132 #define DIR_615C1_LAN_PHYMASK BIT(0)
133 #define DIR_615C1_WAN_PHYMASK BIT(4)
134 #define DIR_615C1_MDIO_MASK (~(DIR_615C1_LAN_PHYMASK | \
135 DIR_615C1_WAN_PHYMASK))
136
137 static void __init dir_615c1_setup(void)
138 {
139 const char *config = (char *) KSEG1ADDR(DIR_615C1_CONFIG_ADDR);
140 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
141 u8 mac[6];
142 u8 *wlan_mac = NULL;
143
144 if (nvram_parse_mac_addr(config, DIR_615C1_CONFIG_SIZE,
145 "lan_mac=", mac) == 0) {
146 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
147 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1);
148 wlan_mac = mac;
149 }
150
151 ar71xx_add_device_mdio(0, DIR_615C1_MDIO_MASK);
152
153 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
154 ar71xx_eth0_data.phy_mask = DIR_615C1_LAN_PHYMASK;
155
156 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
157 ar71xx_eth1_data.phy_mask = DIR_615C1_WAN_PHYMASK;
158
159 ar71xx_add_device_eth(0);
160 ar71xx_add_device_eth(1);
161
162 ar71xx_add_device_m25p80(&dir_615c1_flash_data);
163
164 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir_615c1_leds_gpio),
165 dir_615c1_leds_gpio);
166
167 ar71xx_register_gpio_keys_polled(-1, DIR_615C1_KEYS_POLL_INTERVAL,
168 ARRAY_SIZE(dir_615c1_gpio_keys),
169 dir_615c1_gpio_keys);
170
171 ar9xxx_add_device_wmac(eeprom, wlan_mac);
172 }
173
174 MIPS_MACHINE(AR71XX_MACH_DIR_615_C1, "DIR-615-C1", "D-Link DIR-615 rev. C1",
175 dir_615c1_setup);