sead3-leds.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
  7. */
  8. #include <linux/module.h>
  9. #include <linux/leds.h>
  10. #include <linux/platform_device.h>
  11. #define LEDFLAGS(bits, shift) \
  12. ((bits << 8) | (shift << 8))
  13. #define LEDBITS(id, shift, bits) \
  14. .name = id #shift, \
  15. .flags = LEDFLAGS(bits, shift)
  16. struct led_info led_data_info[] = {
  17. { LEDBITS("bit", 0, 1) },
  18. { LEDBITS("bit", 1, 1) },
  19. { LEDBITS("bit", 2, 1) },
  20. { LEDBITS("bit", 3, 1) },
  21. { LEDBITS("bit", 4, 1) },
  22. { LEDBITS("bit", 5, 1) },
  23. { LEDBITS("bit", 6, 1) },
  24. { LEDBITS("bit", 7, 1) },
  25. { LEDBITS("all", 0, 8) },
  26. };
  27. static struct led_platform_data led_data = {
  28. .num_leds = ARRAY_SIZE(led_data_info),
  29. .leds = led_data_info
  30. };
  31. static struct resource pled_resources[] = {
  32. {
  33. .start = 0x1f000210,
  34. .end = 0x1f000217,
  35. .flags = IORESOURCE_MEM
  36. }
  37. };
  38. static struct platform_device pled_device = {
  39. .name = "sead3::pled",
  40. .id = 0,
  41. .dev = {
  42. .platform_data = &led_data,
  43. },
  44. .num_resources = ARRAY_SIZE(pled_resources),
  45. .resource = pled_resources
  46. };
  47. static struct resource fled_resources[] = {
  48. {
  49. .start = 0x1f000218,
  50. .end = 0x1f00021f,
  51. .flags = IORESOURCE_MEM
  52. }
  53. };
  54. static struct platform_device fled_device = {
  55. .name = "sead3::fled",
  56. .id = 0,
  57. .dev = {
  58. .platform_data = &led_data,
  59. },
  60. .num_resources = ARRAY_SIZE(fled_resources),
  61. .resource = fled_resources
  62. };
  63. static int __init led_init(void)
  64. {
  65. platform_device_register(&pled_device);
  66. return platform_device_register(&fled_device);
  67. }
  68. module_init(led_init);
  69. MODULE_AUTHOR("Chris Dearman <chris@mips.com>");
  70. MODULE_LICENSE("GPL");
  71. MODULE_DESCRIPTION("LED probe driver for SEAD-3");