brcm63xx: move buttons and leds to dts files
[openwrt.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 --- a/arch/mips/bcm63xx/boards/board_common.c
23 +++ b/arch/mips/bcm63xx/boards/board_common.c
24 @@ -12,6 +12,7 @@
25  #include <linux/string.h>
26  #include <linux/platform_device.h>
27  #include <linux/ssb/ssb.h>
28 +#include <linux/gpio_keys.h>
29  #include <asm/addrspace.h>
30  #include <bcm63xx_board.h>
31  #include <bcm63xx_cpu.h>
32 @@ -32,6 +33,8 @@
33  
34  #define PFX    "board: "
35  
36 +#define BCM963XX_KEYS_POLL_INTERVAL    20
37 +
38  static struct board_info board;
39  
40  /*
41 @@ -151,11 +154,23 @@ static struct platform_device bcm63xx_gp
42         .dev.platform_data      = &bcm63xx_led_data,
43  };
44  
45 +static struct gpio_keys_platform_data bcm63xx_gpio_keys_data = {
46 +       .poll_interval  = BCM963XX_KEYS_POLL_INTERVAL,
47 +};
48 +
49 +static struct platform_device bcm63xx_gpio_keys_device = {
50 +       .name           = "gpio-keys-polled",
51 +       .id             = 0,
52 +       .dev.platform_data = &bcm63xx_gpio_keys_data,
53 +};
54 +
55  /*
56   * third stage init callback, register all board devices.
57   */
58  int __init board_register_devices(void)
59  {
60 +       int button_count = 0;
61 +
62         if (board.has_uart0)
63                 bcm63xx_uart_register(0);
64  
65 @@ -217,5 +232,16 @@ int __init board_register_devices(void)
66                 gpio_request_one(board.ephy_reset_gpio,
67                                 board.ephy_reset_gpio_flags, "ephy-reset");
68  
69 +       /* count number of BUTTONs defined by this device */
70 +       while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
71 +               button_count++;
72 +
73 +       if (button_count) {
74 +               bcm63xx_gpio_keys_data.nbuttons = button_count;
75 +               bcm63xx_gpio_keys_data.buttons = board.buttons;
76 +
77 +               platform_device_register(&bcm63xx_gpio_keys_device);
78 +       }
79 +
80         return 0;
81  }
82 --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
83 +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
84 @@ -3,6 +3,7 @@
85  
86  #include <linux/types.h>
87  #include <linux/gpio.h>
88 +#include <linux/gpio_keys.h>
89  #include <linux/leds.h>
90  #include <bcm63xx_dev_enet.h>
91  #include <bcm63xx_dev_usb_usbd.h>
92 @@ -48,6 +49,9 @@ struct board_info {
93         /* GPIO LEDs */
94         struct gpio_led leds[5];
95  
96 +       /* Buttons */
97 +       struct gpio_keys_button buttons[4];
98 +
99         /* External PHY reset GPIO */
100         unsigned int ephy_reset_gpio;
101