ebsa285.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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", "heartbeat", },
  29. { "ebsa285:green", "cpu0", },
  30. { "ebsa285:red",},
  31. };
  32. static void ebsa285_led_set(struct led_classdev *cdev,
  33. enum led_brightness b)
  34. {
  35. struct ebsa285_led *led = container_of(cdev,
  36. struct ebsa285_led, cdev);
  37. if (b != LED_OFF)
  38. *XBUS_LEDS |= led->mask;
  39. else
  40. *XBUS_LEDS &= ~led->mask;
  41. }
  42. static enum led_brightness ebsa285_led_get(struct led_classdev *cdev)
  43. {
  44. struct ebsa285_led *led = container_of(cdev,
  45. struct ebsa285_led, cdev);
  46. return (*XBUS_LEDS & led->mask) ? LED_FULL : LED_OFF;
  47. }
  48. static int __init ebsa285_leds_init(void)
  49. {
  50. int i;
  51. if (machine_is_ebsa285())
  52. return -ENODEV;
  53. /* 3 LEDS All ON */
  54. *XBUS_LEDS |= XBUS_LED_AMBER | XBUS_LED_GREEN | XBUS_LED_RED;
  55. for (i = 0; i < ARRAY_SIZE(ebsa285_leds); i++) {
  56. struct ebsa285_led *led;
  57. led = kzalloc(sizeof(*led), GFP_KERNEL);
  58. if (!led)
  59. break;
  60. led->cdev.name = ebsa285_leds[i].name;
  61. led->cdev.brightness_set = ebsa285_led_set;
  62. led->cdev.brightness_get = ebsa285_led_get;
  63. led->cdev.default_trigger = ebsa285_leds[i].trigger;
  64. led->mask = BIT(i);
  65. if (led_classdev_register(NULL, &led->cdev) < 0) {
  66. kfree(led);
  67. break;
  68. }
  69. }
  70. return 0;
  71. }
  72. /*
  73. * Since we may have triggers on any subsystem, defer registration
  74. * until after subsystem_init.
  75. */
  76. fs_initcall(ebsa285_leds_init);
  77. #endif
  78. MACHINE_START(EBSA285, "EBSA285")
  79. /* Maintainer: Russell King */
  80. .atag_offset = 0x100,
  81. .video_start = 0x000a0000,
  82. .video_end = 0x000bffff,
  83. .map_io = footbridge_map_io,
  84. .init_irq = footbridge_init_irq,
  85. .timer = &footbridge_timer,
  86. .restart = footbridge_restart,
  87. MACHINE_END