210-reset_button.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. --- a/arch/mips/ath25/Makefile
  2. +++ b/arch/mips/ath25/Makefile
  3. @@ -8,7 +8,7 @@
  4. # Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org>
  5. #
  6. -obj-y += board.o prom.o devices.o
  7. +obj-y += board.o prom.o devices.o reset.o
  8. obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
  9. --- /dev/null
  10. +++ b/arch/mips/ath25/reset.c
  11. @@ -0,0 +1,57 @@
  12. +#include <linux/init.h>
  13. +#include <linux/slab.h>
  14. +#include <linux/platform_device.h>
  15. +#include <linux/gpio_keys.h>
  16. +#include <linux/input.h>
  17. +#include <ath25_platform.h>
  18. +#include "devices.h"
  19. +
  20. +static int __init
  21. +ar231x_init_reset(void)
  22. +{
  23. + struct platform_device *pdev;
  24. + struct gpio_keys_platform_data pdata;
  25. + struct gpio_keys_button *p;
  26. + int err;
  27. +
  28. + if (ath25_board.config->reset_config_gpio == 0xffff)
  29. + return -ENODEV;
  30. +
  31. + p = kzalloc(sizeof(*p), GFP_KERNEL);
  32. + if (!p)
  33. + goto err;
  34. +
  35. + p->desc = "reset";
  36. + p->type = EV_KEY;
  37. + p->code = KEY_RESTART;
  38. + p->debounce_interval = 60;
  39. + p->gpio = ath25_board.config->reset_config_gpio;
  40. +
  41. + memset(&pdata, 0, sizeof(pdata));
  42. + pdata.poll_interval = 20;
  43. + pdata.buttons = p;
  44. + pdata.nbuttons = 1;
  45. +
  46. + pdev = platform_device_alloc("gpio-keys-polled", 0);
  47. + if (!pdev)
  48. + goto err_free;
  49. +
  50. + err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
  51. + if (err)
  52. + goto err_put_pdev;
  53. +
  54. + err = platform_device_add(pdev);
  55. + if (err)
  56. + goto err_put_pdev;
  57. +
  58. + return 0;
  59. +
  60. +err_put_pdev:
  61. + platform_device_put(pdev);
  62. +err_free:
  63. + kfree(p);
  64. +err:
  65. + return -ENOMEM;
  66. +}
  67. +
  68. +module_init(ar231x_init_reset);