platform.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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/platform_device.h>
  22. #include <linux/leds.h>
  23. #include <linux/gpio.h>
  24. #include <linux/gpio_keys.h>
  25. #include <linux/input.h>
  26. static struct gpio_keys_button mtx1_gpio_button[] = {
  27. {
  28. .gpio = 207,
  29. .code = BTN_0,
  30. .desc = "System button",
  31. }
  32. };
  33. static struct gpio_keys_platform_data mtx1_buttons_data = {
  34. .buttons = mtx1_gpio_button,
  35. .nbuttons = ARRAY_SIZE(mtx1_gpio_button),
  36. };
  37. static struct platform_device mtx1_button = {
  38. .name = "gpio-keys",
  39. .id = -1,
  40. .dev = {
  41. .platform_data = &mtx1_buttons_data,
  42. }
  43. };
  44. static struct resource mtx1_wdt_res[] = {
  45. [0] = {
  46. .start = 15,
  47. .end = 15,
  48. .name = "mtx1-wdt-gpio",
  49. .flags = IORESOURCE_IRQ,
  50. }
  51. };
  52. static struct platform_device mtx1_wdt = {
  53. .name = "mtx1-wdt",
  54. .id = 0,
  55. .num_resources = ARRAY_SIZE(mtx1_wdt_res),
  56. .resource = mtx1_wdt_res,
  57. };
  58. static struct gpio_led default_leds[] = {
  59. {
  60. .name = "mtx1:green",
  61. .gpio = 211,
  62. }, {
  63. .name = "mtx1:red",
  64. .gpio = 212,
  65. },
  66. };
  67. static struct gpio_led_platform_data mtx1_led_data = {
  68. .num_leds = ARRAY_SIZE(default_leds),
  69. .leds = default_leds,
  70. };
  71. static struct platform_device mtx1_gpio_leds = {
  72. .name = "leds-gpio",
  73. .id = -1,
  74. .dev = {
  75. .platform_data = &mtx1_led_data,
  76. }
  77. };
  78. static struct __initdata platform_device * mtx1_devs[] = {
  79. &mtx1_gpio_leds,
  80. &mtx1_wdt,
  81. &mtx1_button
  82. };
  83. static int __init mtx1_register_devices(void)
  84. {
  85. gpio_direction_input(207);
  86. return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs));
  87. }
  88. arch_initcall(mtx1_register_devices);