300-reset_buttons.patch 2.5 KB

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