brcm63xx: add preliminary support for 3.13
[openwrt/svn-archive/archive.git] / target / linux / brcm63xx / patches-3.13 / 300-reset_buttons.patch
1 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
2 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
3 @@ -12,6 +12,8 @@
4 #include <linux/string.h>
5 #include <linux/platform_device.h>
6 #include <linux/ssb/ssb.h>
7 +#include <linux/gpio_keys.h>
8 +#include <linux/input.h>
9 #include <asm/addrspace.h>
10 #include <bcm63xx_board.h>
11 #include <bcm63xx_cpu.h>
12 @@ -37,6 +39,9 @@
13
14 #define HCS_OFFSET_128K 0x20000
15
16 +#define BCM963XX_KEYS_POLL_INTERVAL 20
17 +#define BCM963XX_KEYS_DEBOUNCE_INTERVAL (BCM963XX_KEYS_POLL_INTERVAL * 3)
18 +
19 static struct board_info board;
20
21 /*
22 @@ -380,6 +385,16 @@ static struct board_info __initdata boar
23 .active_low = 1,
24 },
25 },
26 + .buttons = {
27 + {
28 + .desc = "reset",
29 + .gpio = 33,
30 + .active_low = 1,
31 + .type = EV_KEY,
32 + .code = KEY_RESTART,
33 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
34 + },
35 + },
36 };
37
38 static struct board_info __initdata board_96348gw = {
39 @@ -438,6 +453,16 @@ static struct board_info __initdata boar
40 .active_low = 1,
41 },
42 },
43 + .buttons = {
44 + {
45 + .desc = "reset",
46 + .gpio = 36,
47 + .active_low = 1,
48 + .type = EV_KEY,
49 + .code = KEY_RESTART,
50 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
51 + },
52 + },
53 };
54
55 static struct board_info __initdata board_FAST2404 = {
56 @@ -871,11 +896,23 @@ static struct platform_device bcm63xx_gp
57 .dev.platform_data = &bcm63xx_led_data,
58 };
59
60 +static struct gpio_keys_platform_data bcm63xx_gpio_keys_data = {
61 + .poll_interval = BCM963XX_KEYS_POLL_INTERVAL,
62 +};
63 +
64 +static struct platform_device bcm63xx_gpio_keys_device = {
65 + .name = "gpio-keys-polled",
66 + .id = 0,
67 + .dev.platform_data = &bcm63xx_gpio_keys_data,
68 +};
69 +
70 /*
71 * third stage init callback, register all board devices.
72 */
73 int __init board_register_devices(void)
74 {
75 + int button_count = 0;
76 +
77 if (board.has_uart0)
78 bcm63xx_uart_register(0);
79
80 @@ -937,5 +974,16 @@ int __init board_register_devices(void)
81 gpio_request_one(board.ephy_reset_gpio,
82 board.ephy_reset_gpio_flags, "ephy-reset");
83
84 + /* count number of BUTTONs defined by this device */
85 + while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
86 + button_count++;
87 +
88 + if (button_count) {
89 + bcm63xx_gpio_keys_data.nbuttons = button_count;
90 + bcm63xx_gpio_keys_data.buttons = board.buttons;
91 +
92 + platform_device_register(&bcm63xx_gpio_keys_device);
93 + }
94 +
95 return 0;
96 }
97 --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
98 +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
99 @@ -3,6 +3,7 @@
100
101 #include <linux/types.h>
102 #include <linux/gpio.h>
103 +#include <linux/gpio_keys.h>
104 #include <linux/leds.h>
105 #include <bcm63xx_dev_enet.h>
106 #include <bcm63xx_dev_usb_usbd.h>
107 @@ -48,6 +49,9 @@ struct board_info {
108 /* GPIO LEDs */
109 struct gpio_led leds[5];
110
111 + /* Buttons */
112 + struct gpio_keys_button buttons[4];
113 +
114 /* External PHY reset GPIO */
115 unsigned int ephy_reset_gpio;
116