leds.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* ASB2303 peripheral 7-segment LEDs x1 support
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/param.h>
  13. #include <linux/init.h>
  14. #include <asm/io.h>
  15. #include <asm/processor.h>
  16. #include <asm/intctl-regs.h>
  17. #include <asm/rtc-regs.h>
  18. #include <unit/leds.h>
  19. #if 0
  20. static const u8 asb2303_led_hex_tbl[16] = {
  21. 0x80, 0xf2, 0x48, 0x60, 0x32, 0x24, 0x04, 0xf0,
  22. 0x00, 0x20, 0x10, 0x06, 0x8c, 0x42, 0x0c, 0x1c
  23. };
  24. #endif
  25. static const u8 asb2303_led_chase_tbl[6] = {
  26. ~0x02, /* top - segA */
  27. ~0x04, /* right top - segB */
  28. ~0x08, /* right bottom - segC */
  29. ~0x10, /* bottom - segD */
  30. ~0x20, /* left bottom - segE */
  31. ~0x40, /* left top - segF */
  32. };
  33. static unsigned asb2303_led_chase;
  34. void peripheral_leds_display_exception(enum exception_code code)
  35. {
  36. ASB2303_GPIO0DEF = 0x5555; /* configure as an output port */
  37. ASB2303_7SEGLEDS = 0x6d; /* triple horizontal bar */
  38. }
  39. void peripheral_leds_led_chase(void)
  40. {
  41. ASB2303_GPIO0DEF = 0x5555; /* configure as an output port */
  42. ASB2303_7SEGLEDS = asb2303_led_chase_tbl[asb2303_led_chase];
  43. asb2303_led_chase++;
  44. if (asb2303_led_chase >= 6)
  45. asb2303_led_chase = 0;
  46. }