211985ed04320518021c8eee78e848f0155bd179
[openwrt.git] / target / linux / ar71xx / files-2.6.39 / arch / mips / ar71xx / mach-dir-600-a1.c
1 /*
2 * D-Link DIR-600 rev. A1 board support
3 *
4 * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
5 *
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.
9 */
10
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13
14 #include <asm/mach-ar71xx/ar71xx.h>
15
16 #include "machtype.h"
17 #include "devices.h"
18 #include "dev-m25p80.h"
19 #include "dev-ap91-pci.h"
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22 #include "nvram.h"
23
24 #define DIR_600_A1_GPIO_LED_WPS 0
25 #define DIR_600_A1_GPIO_LED_POWER_AMBER 1
26 #define DIR_600_A1_GPIO_LED_POWER_GREEN 6
27 #define DIR_600_A1_GPIO_LED_LAN1 13
28 #define DIR_600_A1_GPIO_LED_LAN2 14
29 #define DIR_600_A1_GPIO_LED_LAN3 15
30 #define DIR_600_A1_GPIO_LED_LAN4 16
31 #define DIR_600_A1_GPIO_LED_WAN_AMBER 7
32 #define DIR_600_A1_GPIO_LED_WAN_GREEN 17
33
34 #define DIR_600_A1_GPIO_BTN_RESET 8
35 #define DIR_600_A1_GPIO_BTN_WPS 12
36
37 #define DIR_600_A1_KEYS_POLL_INTERVAL 20 /* msecs */
38 #define DIR_600_A1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_600_A1_KEYS_POLL_INTERVAL)
39
40 #define DIR_600_A1_NVRAM_ADDR 0x1f030000
41 #define DIR_600_A1_NVRAM_SIZE 0x10000
42
43 #ifdef CONFIG_MTD_PARTITIONS
44 static struct mtd_partition dir_600_a1_partitions[] = {
45 {
46 .name = "u-boot",
47 .offset = 0,
48 .size = 0x030000,
49 .mask_flags = MTD_WRITEABLE,
50 }, {
51 .name = "nvram",
52 .offset = 0x030000,
53 .size = 0x010000,
54 }, {
55 .name = "kernel",
56 .offset = 0x040000,
57 .size = 0x0e0000,
58 }, {
59 .name = "rootfs",
60 .offset = 0x120000,
61 .size = 0x2c0000,
62 }, {
63 .name = "mac",
64 .offset = 0x3e0000,
65 .size = 0x010000,
66 .mask_flags = MTD_WRITEABLE,
67 }, {
68 .name = "art",
69 .offset = 0x3f0000,
70 .size = 0x010000,
71 .mask_flags = MTD_WRITEABLE,
72 }, {
73 .name = "firmware",
74 .offset = 0x040000,
75 .size = 0x3a0000,
76 }
77 };
78 #endif /* CONFIG_MTD_PARTITIONS */
79
80 static struct flash_platform_data dir_600_a1_flash_data = {
81 #ifdef CONFIG_MTD_PARTITIONS
82 .parts = dir_600_a1_partitions,
83 .nr_parts = ARRAY_SIZE(dir_600_a1_partitions),
84 #endif
85 };
86
87 static struct gpio_led dir_600_a1_leds_gpio[] __initdata = {
88 {
89 .name = "d-link:green:power",
90 .gpio = DIR_600_A1_GPIO_LED_POWER_GREEN,
91 }, {
92 .name = "d-link:amber:power",
93 .gpio = DIR_600_A1_GPIO_LED_POWER_AMBER,
94 }, {
95 .name = "d-link:amber:wan",
96 .gpio = DIR_600_A1_GPIO_LED_WAN_AMBER,
97 }, {
98 .name = "d-link:green:wan",
99 .gpio = DIR_600_A1_GPIO_LED_WAN_GREEN,
100 .active_low = 1,
101 }, {
102 .name = "d-link:green:lan1",
103 .gpio = DIR_600_A1_GPIO_LED_LAN1,
104 .active_low = 1,
105 }, {
106 .name = "d-link:green:lan2",
107 .gpio = DIR_600_A1_GPIO_LED_LAN2,
108 .active_low = 1,
109 }, {
110 .name = "d-link:green:lan3",
111 .gpio = DIR_600_A1_GPIO_LED_LAN3,
112 .active_low = 1,
113 }, {
114 .name = "d-link:green:lan4",
115 .gpio = DIR_600_A1_GPIO_LED_LAN4,
116 .active_low = 1,
117 }, {
118 .name = "d-link:blue:wps",
119 .gpio = DIR_600_A1_GPIO_LED_WPS,
120 .active_low = 1,
121 }
122 };
123
124 static struct gpio_keys_button dir_600_a1_gpio_keys[] __initdata = {
125 {
126 .desc = "reset",
127 .type = EV_KEY,
128 .code = KEY_RESTART,
129 .debounce_interval = DIR_600_A1_KEYS_DEBOUNCE_INTERVAL,
130 .gpio = DIR_600_A1_GPIO_BTN_RESET,
131 .active_low = 1,
132 }, {
133 .desc = "wps",
134 .type = EV_KEY,
135 .code = KEY_WPS_BUTTON,
136 .debounce_interval = DIR_600_A1_KEYS_DEBOUNCE_INTERVAL,
137 .gpio = DIR_600_A1_GPIO_BTN_WPS,
138 .active_low = 1,
139 }
140 };
141
142 static void __init dir_600_a1_setup(void)
143 {
144 const char *nvram = (char *) KSEG1ADDR(DIR_600_A1_NVRAM_ADDR);
145 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
146 u8 mac_buff[6];
147 u8 *mac = NULL;
148
149 if (nvram_parse_mac_addr(nvram, DIR_600_A1_NVRAM_SIZE,
150 "lan_mac=", mac_buff) == 0) {
151 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac_buff, 0);
152 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac_buff, 1);
153 mac = mac_buff;
154 }
155
156 ar71xx_add_device_m25p80(&dir_600_a1_flash_data);
157
158 ar71xx_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
159 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
160 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
161 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
162 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
163
164 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir_600_a1_leds_gpio),
165 dir_600_a1_leds_gpio);
166
167 ar71xx_register_gpio_keys_polled(-1, DIR_600_A1_KEYS_POLL_INTERVAL,
168 ARRAY_SIZE(dir_600_a1_gpio_keys),
169 dir_600_a1_gpio_keys);
170
171 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
172 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1);
173
174 ar71xx_add_device_mdio(0, 0x0);
175
176 /* LAN ports */
177 ar71xx_add_device_eth(1);
178
179 /* WAN port */
180 ar71xx_add_device_eth(0);
181
182 ap91_pci_init(ee, mac);
183 }
184
185 MIPS_MACHINE(AR71XX_MACH_DIR_600_A1, "DIR-600-A1", "D-Link DIR-600 rev. A1",
186 dir_600_a1_setup);
This page took 0.044782 seconds and 3 git commands to generate.