csb701.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <linux/kernel.h>
  2. #include <linux/module.h>
  3. #include <linux/platform_device.h>
  4. #include <linux/gpio_keys.h>
  5. #include <linux/input.h>
  6. #include <linux/leds.h>
  7. static struct gpio_keys_button csb701_buttons[] = {
  8. {
  9. .code = 0x7,
  10. .gpio = 1,
  11. .active_low = 1,
  12. .desc = "SW2",
  13. .type = EV_SW,
  14. .wakeup = 1,
  15. },
  16. };
  17. static struct gpio_keys_platform_data csb701_gpio_keys_data = {
  18. .buttons = csb701_buttons,
  19. .nbuttons = ARRAY_SIZE(csb701_buttons),
  20. };
  21. static struct gpio_led csb701_leds[] = {
  22. {
  23. .name = "csb701:yellow:heartbeat",
  24. .default_trigger = "heartbeat",
  25. .gpio = 11,
  26. .active_low = 1,
  27. },
  28. };
  29. static struct platform_device csb701_gpio_keys = {
  30. .name = "gpio-keys",
  31. .id = -1,
  32. .dev.platform_data = &csb701_gpio_keys_data,
  33. };
  34. static struct gpio_led_platform_data csb701_leds_gpio_data = {
  35. .leds = csb701_leds,
  36. .num_leds = ARRAY_SIZE(csb701_leds),
  37. };
  38. static struct platform_device csb701_leds_gpio = {
  39. .name = "leds-gpio",
  40. .id = -1,
  41. .dev.platform_data = &csb701_leds_gpio_data,
  42. };
  43. static struct platform_device *devices[] __initdata = {
  44. &csb701_gpio_keys,
  45. &csb701_leds_gpio,
  46. };
  47. static int __init csb701_init(void)
  48. {
  49. return platform_add_devices(devices, ARRAY_SIZE(devices));
  50. }
  51. module_init(csb701_init);