ramips: use gpio-keys-polled instead of gpio-buttons
[lede.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-argus-atp52b.c
1 /*
2  *  Argus ATP-52B router support
3  *  http://www.argus-co.com/english/productsview.php?id=70&cid=81
4  *
5  *  Copyright (C) 2011 Roman Yeryomin <roman@advem.lv>
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/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/mtd/physmap.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 ARGUS_ATP52B_GPIO_LED_RUN               9
27 #define ARGUS_ATP52B_GPIO_LED_NET               13
28 #define ARGUS_ATP52B_GPIO_BUTTON_WPS            0
29 #define ARGUS_ATP52B_GPIO_BUTTON_RESET          10
30 #define ARGUS_ATP52B_KEYS_POLL_INTERVAL         20
31 #define ARGUS_ATP52B_KEYS_DEBOUNCE_INTERVAL     (3 * ARGUS_ATP52B_KEYS_POLL_INTERVAL)
32
33 static struct gpio_led argus_atp52b_leds_gpio[] __initdata = {
34         {
35                 .name       = "argus-atp52b:green:run",
36                 .gpio       = ARGUS_ATP52B_GPIO_LED_RUN,
37                 .active_low = 1,
38         },
39         {
40                 .name       = "argus-atp52b:amber:net",
41                 .gpio       = ARGUS_ATP52B_GPIO_LED_NET,
42                 .active_low = 1,
43         }
44 };
45
46 static struct gpio_keys_button argus_atp52b_gpio_buttons[] __initdata = {
47         {
48                 .desc       = "wps",
49                 .type       = EV_KEY,
50                 .code       = KEY_WPS_BUTTON,
51                 .debounce_interval = ARGUS_ATP52B_KEYS_DEBOUNCE_INTERVAL,
52                 .gpio       = ARGUS_ATP52B_GPIO_BUTTON_WPS,
53                 .active_low = 1,
54         },
55         {
56                 .desc       = "reset",
57                 .type       = EV_KEY,
58                 .code       = KEY_RESTART,
59                 .debounce_interval = ARGUS_ATP52B_KEYS_DEBOUNCE_INTERVAL,
60                 .gpio       = ARGUS_ATP52B_GPIO_BUTTON_RESET,
61                 .active_low = 1,
62         }
63 };
64
65 static struct mtd_partition argus_atp52b_partitions[] = {
66         {
67                 .name   = "bootloader",
68                 .offset = 0,
69                 .size   = 0x030000,
70                 .mask_flags = MTD_WRITEABLE,
71         }, {
72                 .name   = "config",
73                 .offset = 0x030000,
74                 .size   = 0x010000,
75                 .mask_flags = MTD_WRITEABLE,
76         }, {
77                 .name   = "factory",
78                 .offset = 0x040000,
79                 .size   = 0x010000,
80                 .mask_flags = MTD_WRITEABLE,
81         }, {
82                 .name   = "kernel",
83                 .offset = 0x050000,
84                 .size   = 0x120000,
85         }, {
86                 .name   = "rootfs",
87                 .offset = 0x170000,
88                 .size   = 0x690000,
89         }
90 };
91
92 static struct physmap_flash_data argus_atp52b_flash_data = {
93         .nr_parts       = ARRAY_SIZE(argus_atp52b_partitions),
94         .parts          = argus_atp52b_partitions,
95 };
96
97 static void __init argus_atp52b_init(void)
98 {
99         rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
100         rt305x_register_flash(0, &argus_atp52b_flash_data);
101         ramips_register_gpio_leds(-1, ARRAY_SIZE(argus_atp52b_leds_gpio),
102                                         argus_atp52b_leds_gpio);
103         ramips_register_gpio_buttons(-1, ARGUS_ATP52B_KEYS_POLL_INTERVAL,
104                                         ARRAY_SIZE(argus_atp52b_gpio_buttons),
105                                         argus_atp52b_gpio_buttons);
106         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
107         rt305x_register_ethernet();
108         rt305x_register_wifi();
109         rt305x_register_wdt();
110         rt305x_register_usb();
111 }
112
113 MIPS_MACHINE(RAMIPS_MACH_ARGUS_ATP52B, "ARGUS_ATP52B", "Argus ATP-52B",
114                                         argus_atp52b_init);