platform.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * MTX-1 platform devices registration
  3. *
  4. * Copyright (C) 2007, Florian Fainelli <florian@openwrt.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/init.h>
  21. #include <linux/types.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/leds.h>
  24. #include <linux/gpio_keys.h>
  25. #include <linux/input.h>
  26. #include <asm/gpio.h>
  27. static struct gpio_keys_button mtx1_gpio_button[] = {
  28. {
  29. .gpio = 207,
  30. .code = BTN_0,
  31. .desc = "System button",
  32. }
  33. };
  34. static struct gpio_keys_platform_data mtx1_buttons_data = {
  35. .buttons = mtx1_gpio_button,
  36. .nbuttons = ARRAY_SIZE(mtx1_gpio_button),
  37. };
  38. static struct platform_device mtx1_button = {
  39. .name = "gpio-keys",
  40. .id = -1,
  41. .dev = {
  42. .platform_data = &mtx1_buttons_data,
  43. }
  44. };
  45. static struct resource mtx1_wdt_res[] = {
  46. [0] = {
  47. .start = 15,
  48. .end = 15,
  49. .name = "mtx1-wdt-gpio",
  50. .flags = IORESOURCE_IRQ,
  51. }
  52. };
  53. static struct platform_device mtx1_wdt = {
  54. .name = "mtx1-wdt",
  55. .id = 0,
  56. .num_resources = ARRAY_SIZE(mtx1_wdt_res),
  57. .resource = mtx1_wdt_res,
  58. };
  59. static struct gpio_led default_leds[] = {
  60. {
  61. .name = "mtx1:green",
  62. .gpio = 211,
  63. }, {
  64. .name = "mtx1:red",
  65. .gpio = 212,
  66. },
  67. };
  68. static struct gpio_led_platform_data mtx1_led_data = {
  69. .num_leds = ARRAY_SIZE(default_leds),
  70. .leds = default_leds,
  71. };
  72. static struct platform_device mtx1_gpio_leds = {
  73. .name = "leds-gpio",
  74. .id = -1,
  75. .dev = {
  76. .platform_data = &mtx1_led_data,
  77. }
  78. };
  79. static struct __initdata platform_device * mtx1_devs[] = {
  80. &mtx1_gpio_leds,
  81. &mtx1_wdt,
  82. &mtx1_button
  83. };
  84. static int __init mtx1_register_devices(void)
  85. {
  86. gpio_direction_input(207);
  87. return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs));
  88. }
  89. arch_initcall(mtx1_register_devices);