ebsa285.c 2.5 KB

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