leds.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * linux/arch/arm/mach-integrator/leds.c
  3. *
  4. * Integrator/AP and Integrator/CP LED control routines
  5. *
  6. * Copyright (C) 1999 ARM Limited
  7. * Copyright (C) 2000 Deep Blue Solutions Ltd
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include <linux/kernel.h>
  24. #include <linux/init.h>
  25. #include <linux/smp.h>
  26. #include <linux/spinlock.h>
  27. #include <linux/io.h>
  28. #include <mach/hardware.h>
  29. #include <mach/platform.h>
  30. #include <asm/leds.h>
  31. #include <asm/system.h>
  32. #include <asm/mach-types.h>
  33. #include <mach/cm.h>
  34. static int saved_leds;
  35. static void integrator_leds_event(led_event_t ledevt)
  36. {
  37. unsigned long flags;
  38. const unsigned int dbg_base = IO_ADDRESS(INTEGRATOR_DBG_BASE);
  39. unsigned int update_alpha_leds;
  40. // yup, change the LEDs
  41. local_irq_save(flags);
  42. update_alpha_leds = 0;
  43. switch(ledevt) {
  44. case led_idle_start:
  45. cm_control(CM_CTRL_LED, 0);
  46. break;
  47. case led_idle_end:
  48. cm_control(CM_CTRL_LED, CM_CTRL_LED);
  49. break;
  50. case led_timer:
  51. saved_leds ^= GREEN_LED;
  52. update_alpha_leds = 1;
  53. break;
  54. case led_red_on:
  55. saved_leds |= RED_LED;
  56. update_alpha_leds = 1;
  57. break;
  58. case led_red_off:
  59. saved_leds &= ~RED_LED;
  60. update_alpha_leds = 1;
  61. break;
  62. default:
  63. break;
  64. }
  65. if (update_alpha_leds) {
  66. while (__raw_readl(dbg_base + INTEGRATOR_DBG_ALPHA_OFFSET) & 1);
  67. __raw_writel(saved_leds, dbg_base + INTEGRATOR_DBG_LEDS_OFFSET);
  68. }
  69. local_irq_restore(flags);
  70. }
  71. static int __init leds_init(void)
  72. {
  73. if (machine_is_integrator() || machine_is_cintegrator())
  74. leds_event = integrator_leds_event;
  75. return 0;
  76. }
  77. core_initcall(leds_init);