ramips: use gpio-keys-polled instead of gpio-buttons
[openwrt.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-wr6202.c
1 /*
2 * AWB WR6202 board support
3 *
4 * Copyright (C) 2012 Johnathan Boyce<jon.boyce@globalreach.eu.com>
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/init.h>
12 #include<linux/platform_device.h>
13 #include<linux/mtd/mtd.h>
14 #include<linux/mtd/partitions.h>
15 #include<linux/mtd/physmap.h>
16 #include<linux/gpio.h>
17
18 #include<asm/mach-ralink/machine.h>
19 #include<asm/mach-ralink/dev-gpio-buttons.h>
20 #include<asm/mach-ralink/dev-gpio-leds.h>
21 #include<asm/mach-ralink/rt305x.h>
22 #include<asm/mach-ralink/rt305x_regs.h>
23
24 #include "devices.h"
25
26 #define WR6202_GPIO_BUTTON_RESET 10 /* active low */
27 #define WR6202_GPIO_BUTTON_WPS 0 /* active low */
28
29 #define WR6202_KEYS_POLL_INTERVAL 20
30 #define WR6202_KEYS_DEBOUNCE_INTERVAL (3 * WR6202_KEYS_POLL_INTERVAL)
31
32 #define WR6202_GPIO_USB_POWER 11
33
34 #define WR6202_GPIO_LED_3G 13
35 #define WR6202_GPIO_LED_WPS 14
36
37 static struct mtd_partition wr6202_partitions[] = {
38 {
39 .name = "uboot",
40 .offset = 0,
41 .size = 0x030000,
42 }, {
43 .name = "uboot-config",
44 .offset = 0x030000,
45 .size = 0x040000,
46 .mask_flags = MTD_WRITEABLE,
47 }, {
48 .name = "factory",
49 .offset = 0x040000,
50 .size = 0x050000,
51 .mask_flags = MTD_WRITEABLE,
52 }, {
53 .name = "linux",
54 .offset = 0x050000,
55 .size = 0x100000,
56 }, {
57 .name = "rootfs",
58 .offset = 0x150000,
59 .size = 0x6B0000,
60 }
61 };
62
63 static struct physmap_flash_data wr6202_flash_data = {
64 .nr_parts = ARRAY_SIZE(wr6202_partitions),
65 .parts = wr6202_partitions,
66 };
67
68 static struct gpio_led wr6202_leds_gpio[] __initdata = {
69 {
70 .name = "wr6202:blue:wps",
71 .gpio = WR6202_GPIO_LED_WPS,
72 .active_low = 1,
73 }, {
74 .name = "wr6202:blue:3g",
75 .gpio = WR6202_GPIO_LED_3G,
76 .active_low = 1,
77 }
78 };
79
80 static struct gpio_keys_button wr6202_gpio_buttons[] __initdata = {
81 {
82 .desc = "reset",
83 .type = EV_KEY,
84 .code = KEY_RESTART,
85 .debounce_interval = WR6202_KEYS_DEBOUNCE_INTERVAL,
86 .gpio = WR6202_GPIO_BUTTON_RESET,
87 .active_low = 1,
88 }, {
89 .desc = "wps",
90 .type = EV_KEY,
91 .code = KEY_WPS_BUTTON,
92 .debounce_interval = WR6202_KEYS_DEBOUNCE_INTERVAL,
93 .gpio = WR6202_GPIO_BUTTON_WPS,
94 .active_low = 1,
95 }
96 };
97
98 static void __init wr6202_init(void)
99 {
100 rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
101
102 rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
103
104 ramips_register_gpio_leds(-1, ARRAY_SIZE(wr6202_leds_gpio),
105 wr6202_leds_gpio);
106 ramips_register_gpio_buttons(-1, WR6202_KEYS_POLL_INTERVAL,
107 ARRAY_SIZE(wr6202_gpio_buttons),
108 wr6202_gpio_buttons);
109
110 /* Power to the USB port is controlled by GPIO line */
111 gpio_request(WR6202_GPIO_USB_POWER, "WR6202_GPIO_USB_POWER");
112 gpio_direction_output(WR6202_GPIO_USB_POWER, 0);
113 gpio_free(WR6202_GPIO_USB_POWER);
114
115 rt305x_register_flash(0, &wr6202_flash_data);
116 rt305x_register_ethernet();
117 rt305x_register_wifi();
118 rt305x_register_wdt();
119 rt305x_register_usb();
120 }
121
122 MIPS_MACHINE(RAMIPS_MACH_WR6202, "WR6202", "AWB WR6202",
123 wr6202_init);
This page took 0.060217 seconds and 5 git commands to generate.