csb701.c 1.3 KB

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