ar71xx: reduce button threshold values
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / 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-ar71xx/ar71xx.h>
17
18 #include "machtype.h"
19 #include "devices.h"
20 #include "dev-m25p80.h"
21 #include "dev-ar913x-wmac.h"
22 #include "dev-gpio-buttons.h"
23 #include "dev-leds-gpio.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_BUTTONS_POLL_INTERVAL 20
33
34 #ifdef CONFIG_MTD_PARTITIONS
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 #endif /* CONFIG_MTD_PARTITIONS */
73
74 static struct flash_platform_data wnr2000_flash_data = {
75 #ifdef CONFIG_MTD_PARTITIONS
76 .parts = wnr2000_partitions,
77 .nr_parts = ARRAY_SIZE(wnr2000_partitions),
78 #endif
79 };
80
81 static struct gpio_led wnr2000_leds_gpio[] __initdata = {
82 {
83 .name = "wnr2000:green:power",
84 .gpio = WNR2000_GPIO_LED_PWR_GREEN,
85 .active_low = 1,
86 }, {
87 .name = "wnr2000:amber:power",
88 .gpio = WNR2000_GPIO_LED_PWR_AMBER,
89 .active_low = 1,
90 }, {
91 .name = "wnr2000:green:wps",
92 .gpio = WNR2000_GPIO_LED_WPS,
93 .active_low = 1,
94 }, {
95 .name = "wnr2000:blue:wlan",
96 .gpio = WNR2000_GPIO_LED_WLAN,
97 .active_low = 1,
98 }
99 };
100
101 static struct gpio_button wnr2000_gpio_buttons[] __initdata = {
102 {
103 .desc = "reset",
104 .type = EV_KEY,
105 .code = BTN_0,
106 .threshold = 3,
107 .gpio = WNR2000_GPIO_BTN_RESET,
108 }, {
109 .desc = "wps",
110 .type = EV_KEY,
111 .code = BTN_1,
112 .threshold = 3,
113 .gpio = WNR2000_GPIO_BTN_WPS,
114 }
115 };
116
117 static void __init wnr2000_setup(void)
118 {
119 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
120
121 ar71xx_set_mac_base(eeprom);
122 ar71xx_add_device_mdio(0x0);
123
124 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
125 ar71xx_eth0_data.phy_mask = 0xf;
126 ar71xx_eth0_data.speed = SPEED_100;
127 ar71xx_eth0_data.duplex = DUPLEX_FULL;
128 ar71xx_eth0_data.has_ar8216 = 1;
129
130 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
131 ar71xx_eth1_data.phy_mask = 0x10;
132
133 ar71xx_add_device_eth(0);
134 ar71xx_add_device_eth(1);
135
136 ar71xx_add_device_m25p80(&wnr2000_flash_data);
137
138 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wnr2000_leds_gpio),
139 wnr2000_leds_gpio);
140
141 ar71xx_add_device_gpio_buttons(-1, WNR2000_BUTTONS_POLL_INTERVAL,
142 ARRAY_SIZE(wnr2000_gpio_buttons),
143 wnr2000_gpio_buttons);
144
145
146 ar913x_add_device_wmac(eeprom, NULL);
147 }
148
149 MIPS_MACHINE(AR71XX_MACH_WNR2000, "WNR2000", "NETGEAR WNR2000", wnr2000_setup);