ar71xx: nuke 2.6.39 support
[openwrt/openwrt.git] / target / linux / ar71xx / files-3.2 / arch / mips / ath79 / mach-wnr2000.c
1 /*
2 * NETGEAR WNR2000 board support
3 *
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
7 *
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.
11 */
12
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15
16 #include <asm/mach-ath79/ath79.h>
17
18 #include "dev-eth.h"
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
22 #include "dev-wmac.h"
23 #include "machtypes.h"
24
25 #define WNR2000_GPIO_LED_PWR_GREEN 14
26 #define WNR2000_GPIO_LED_PWR_AMBER 7
27 #define WNR2000_GPIO_LED_WPS 4
28 #define WNR2000_GPIO_LED_WLAN 6
29 #define WNR2000_GPIO_BTN_RESET 21
30 #define WNR2000_GPIO_BTN_WPS 8
31
32 #define WNR2000_KEYS_POLL_INTERVAL 20 /* msecs */
33 #define WNR2000_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000_KEYS_POLL_INTERVAL)
34
35 static struct mtd_partition wnr2000_partitions[] = {
36 {
37 .name = "u-boot",
38 .offset = 0,
39 .size = 0x040000,
40 .mask_flags = MTD_WRITEABLE,
41 }, {
42 .name = "u-boot-env",
43 .offset = 0x040000,
44 .size = 0x010000,
45 }, {
46 .name = "rootfs",
47 .offset = 0x050000,
48 .size = 0x240000,
49 }, {
50 .name = "user-config",
51 .offset = 0x290000,
52 .size = 0x010000,
53 }, {
54 .name = "uImage",
55 .offset = 0x2a0000,
56 .size = 0x120000,
57 }, {
58 .name = "language_table",
59 .offset = 0x3c0000,
60 .size = 0x020000,
61 }, {
62 .name = "rootfs_checksum",
63 .offset = 0x3e0000,
64 .size = 0x010000,
65 }, {
66 .name = "art",
67 .offset = 0x3f0000,
68 .size = 0x010000,
69 .mask_flags = MTD_WRITEABLE,
70 }
71 };
72
73 static struct flash_platform_data wnr2000_flash_data = {
74 .parts = wnr2000_partitions,
75 .nr_parts = ARRAY_SIZE(wnr2000_partitions),
76 };
77
78 static struct gpio_led wnr2000_leds_gpio[] __initdata = {
79 {
80 .name = "wnr2000:green:power",
81 .gpio = WNR2000_GPIO_LED_PWR_GREEN,
82 .active_low = 1,
83 }, {
84 .name = "wnr2000:amber:power",
85 .gpio = WNR2000_GPIO_LED_PWR_AMBER,
86 .active_low = 1,
87 }, {
88 .name = "wnr2000:green:wps",
89 .gpio = WNR2000_GPIO_LED_WPS,
90 .active_low = 1,
91 }, {
92 .name = "wnr2000:blue:wlan",
93 .gpio = WNR2000_GPIO_LED_WLAN,
94 .active_low = 1,
95 }
96 };
97
98 static struct gpio_keys_button wnr2000_gpio_keys[] __initdata = {
99 {
100 .desc = "reset",
101 .type = EV_KEY,
102 .code = KEY_RESTART,
103 .debounce_interval = WNR2000_KEYS_DEBOUNCE_INTERVAL,
104 .gpio = WNR2000_GPIO_BTN_RESET,
105 }, {
106 .desc = "wps",
107 .type = EV_KEY,
108 .code = KEY_WPS_BUTTON,
109 .debounce_interval = WNR2000_KEYS_DEBOUNCE_INTERVAL,
110 .gpio = WNR2000_GPIO_BTN_WPS,
111 }
112 };
113
114 static void __init wnr2000_setup(void)
115 {
116 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
117
118 ath79_register_mdio(0, 0x0);
119
120 ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
121 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
122 ath79_eth0_data.speed = SPEED_100;
123 ath79_eth0_data.duplex = DUPLEX_FULL;
124 ath79_eth0_data.has_ar8216 = 1;
125
126 ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
127 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
128 ath79_eth1_data.phy_mask = 0x10;
129
130 ath79_register_eth(0);
131 ath79_register_eth(1);
132
133 ath79_register_m25p80(&wnr2000_flash_data);
134
135 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000_leds_gpio),
136 wnr2000_leds_gpio);
137
138 ath79_register_gpio_keys_polled(-1, WNR2000_KEYS_POLL_INTERVAL,
139 ARRAY_SIZE(wnr2000_gpio_keys),
140 wnr2000_gpio_keys);
141
142 ath79_register_wmac(eeprom, NULL);
143 }
144
145 MIPS_MACHINE(ATH79_MACH_WNR2000, "WNR2000", "NETGEAR WNR2000", wnr2000_setup);