ebsa285.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * linux/arch/arm/mach-footbridge/ebsa285.c
  3. *
  4. * EBSA285 machine fixup
  5. */
  6. #include <linux/init.h>
  7. #include <linux/spinlock.h>
  8. #include <linux/slab.h>
  9. #include <linux/leds.h>
  10. #include <asm/hardware/dec21285.h>
  11. #include <asm/mach-types.h>
  12. #include <asm/mach/arch.h>
  13. #include "common.h"
  14. /* LEDs */
  15. #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
  16. struct ebsa285_led {
  17. struct led_classdev cdev;
  18. u8 mask;
  19. };
  20. /*
  21. * The triggers lines up below will only be used if the
  22. * LED triggers are compiled in.
  23. */
  24. static const struct {
  25. const char *name;
  26. const char *trigger;
  27. } ebsa285_leds[] = {
  28. { "ebsa285:amber", "cpu0", },
  29. { "ebsa285:green", "heartbeat", },
  30. { "ebsa285:red",},
  31. };
  32. static unsigned char hw_led_state;
  33. static void ebsa285_led_set(struct led_classdev *cdev,
  34. enum led_brightness b)
  35. {
  36. struct ebsa285_led *led = container_of(cdev,
  37. struct ebsa285_led, cdev);
  38. if (b == LED_OFF)
  39. hw_led_state |= led->mask;
  40. else
  41. hw_led_state &= ~led->mask;
  42. *XBUS_LEDS = hw_led_state;
  43. }
  44. static enum led_brightness ebsa285_led_get(struct led_classdev *cdev)
  45. {
  46. struct ebsa285_led *led = container_of(cdev,
  47. struct ebsa285_led, cdev);
  48. return hw_led_state & led->mask ? LED_OFF : LED_FULL;
  49. }
  50. static int __init ebsa285_leds_init(void)
  51. {
  52. int i;
  53. if (!machine_is_ebsa285())
  54. return -ENODEV;
  55. /* 3 LEDS all off */
  56. hw_led_state = XBUS_LED_AMBER | XBUS_LED_GREEN | XBUS_LED_RED;
  57. *XBUS_LEDS = hw_led_state;
  58. for (i = 0; i < ARRAY_SIZE(ebsa285_leds); i++) {
  59. struct ebsa285_led *led;
  60. led = kzalloc(sizeof(*led), GFP_KERNEL);
  61. if (!led)
  62. break;
  63. led->cdev.name = ebsa285_leds[i].name;
  64. led->cdev.brightness_set = ebsa285_led_set;
  65. led->cdev.brightness_get = ebsa285_led_get;
  66. led->cdev.default_trigger = ebsa285_leds[i].trigger;
  67. led->mask = BIT(i);
  68. if (led_classdev_register(NULL, &led->cdev) < 0) {
  69. kfree(led);
  70. break;
  71. }
  72. }
  73. return 0;
  74. }
  75. /*
  76. * Since we may have triggers on any subsystem, defer registration
  77. * until after subsystem_init.
  78. */
  79. fs_initcall(ebsa285_leds_init);
  80. #endif
  81. MACHINE_START(EBSA285, "EBSA285")
  82. /* Maintainer: Russell King */
  83. .atag_offset = 0x100,
  84. .video_start = 0x000a0000,
  85. .video_end = 0x000bffff,
  86. .map_io = footbridge_map_io,
  87. .init_irq = footbridge_init_irq,
  88. .init_time = footbridge_timer_init,
  89. .restart = footbridge_restart,
  90. MACHINE_END