brcm63xx: Add DT support for A4001N
[openwrt/svn-archive/archive.git] / target / linux / brcm63xx / patches-3.14 / 300-reset_buttons.patch
1 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
2 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
3 @@ -10,6 +10,8 @@
4 #include <linux/init.h>
5 #include <linux/kernel.h>
6 #include <linux/string.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 @@ -26,6 +28,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 /*
20 * known 3368 boards
21 */
22 @@ -367,6 +372,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 @@ -425,6 +440,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 --- a/arch/mips/bcm63xx/boards/board_common.c
57 +++ b/arch/mips/bcm63xx/boards/board_common.c
58 @@ -12,6 +12,7 @@
59 #include <linux/string.h>
60 #include <linux/platform_device.h>
61 #include <linux/ssb/ssb.h>
62 +#include <linux/gpio_keys.h>
63 #include <asm/addrspace.h>
64 #include <bcm63xx_board.h>
65 #include <bcm63xx_cpu.h>
66 @@ -32,6 +33,8 @@
67
68 #define PFX "board: "
69
70 +#define BCM963XX_KEYS_POLL_INTERVAL 20
71 +
72 static struct board_info board;
73
74 /*
75 @@ -151,11 +154,23 @@ static struct platform_device bcm63xx_gp
76 .dev.platform_data = &bcm63xx_led_data,
77 };
78
79 +static struct gpio_keys_platform_data bcm63xx_gpio_keys_data = {
80 + .poll_interval = BCM963XX_KEYS_POLL_INTERVAL,
81 +};
82 +
83 +static struct platform_device bcm63xx_gpio_keys_device = {
84 + .name = "gpio-keys-polled",
85 + .id = 0,
86 + .dev.platform_data = &bcm63xx_gpio_keys_data,
87 +};
88 +
89 /*
90 * third stage init callback, register all board devices.
91 */
92 int __init board_register_devices(void)
93 {
94 + int button_count = 0;
95 +
96 if (board.has_uart0)
97 bcm63xx_uart_register(0);
98
99 @@ -217,5 +232,16 @@ int __init board_register_devices(void)
100 gpio_request_one(board.ephy_reset_gpio,
101 board.ephy_reset_gpio_flags, "ephy-reset");
102
103 + /* count number of BUTTONs defined by this device */
104 + while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
105 + button_count++;
106 +
107 + if (button_count) {
108 + bcm63xx_gpio_keys_data.nbuttons = button_count;
109 + bcm63xx_gpio_keys_data.buttons = board.buttons;
110 +
111 + platform_device_register(&bcm63xx_gpio_keys_device);
112 + }
113 +
114 return 0;
115 }
116 --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
117 +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
118 @@ -3,6 +3,7 @@
119
120 #include <linux/types.h>
121 #include <linux/gpio.h>
122 +#include <linux/gpio_keys.h>
123 #include <linux/leds.h>
124 #include <bcm63xx_dev_enet.h>
125 #include <bcm63xx_dev_usb_usbd.h>
126 @@ -48,6 +49,9 @@ struct board_info {
127 /* GPIO LEDs */
128 struct gpio_led leds[5];
129
130 + /* Buttons */
131 + struct gpio_keys_button buttons[4];
132 +
133 /* External PHY reset GPIO */
134 unsigned int ephy_reset_gpio;
135