sead3-display.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
  7. */
  8. #include <linux/timer.h>
  9. #include <linux/io.h>
  10. #include <asm/mips-boards/generic.h>
  11. static unsigned int display_count;
  12. static unsigned int max_display_count;
  13. #define LCD_DISPLAY_POS_BASE 0x1f000400
  14. #define DISPLAY_LCDINSTRUCTION (0*2)
  15. #define DISPLAY_LCDDATA (1*2)
  16. #define DISPLAY_CPLDSTATUS (2*2)
  17. #define DISPLAY_CPLDDATA (3*2)
  18. #define LCD_SETDDRAM 0x80
  19. #define LCD_IR_BF 0x80
  20. const char display_string[] = " LINUX ON SEAD3 ";
  21. static void scroll_display_message(unsigned long data);
  22. static DEFINE_TIMER(mips_scroll_timer, scroll_display_message, HZ, 0);
  23. static void lcd_wait(unsigned int __iomem *display)
  24. {
  25. /* Wait for CPLD state machine to become idle. */
  26. do { } while (__raw_readl(display + DISPLAY_CPLDSTATUS) & 1);
  27. do {
  28. __raw_readl(display + DISPLAY_LCDINSTRUCTION);
  29. /* Wait for CPLD state machine to become idle. */
  30. do { } while (__raw_readl(display + DISPLAY_CPLDSTATUS) & 1);
  31. } while (__raw_readl(display + DISPLAY_CPLDDATA) & LCD_IR_BF);
  32. }
  33. void mips_display_message(const char *str)
  34. {
  35. static unsigned int __iomem *display;
  36. char ch;
  37. int i;
  38. if (unlikely(display == NULL))
  39. display = ioremap_nocache(LCD_DISPLAY_POS_BASE,
  40. (8 * sizeof(int)));
  41. for (i = 0; i < 16; i++) {
  42. if (*str)
  43. ch = *str++;
  44. else
  45. ch = ' ';
  46. lcd_wait(display);
  47. __raw_writel((LCD_SETDDRAM | i),
  48. (display + DISPLAY_LCDINSTRUCTION));
  49. lcd_wait(display);
  50. __raw_writel(ch, display + DISPLAY_LCDDATA);
  51. }
  52. }
  53. static void scroll_display_message(unsigned long data)
  54. {
  55. mips_display_message(&display_string[display_count++]);
  56. if (display_count == max_display_count)
  57. display_count = 0;
  58. mod_timer(&mips_scroll_timer, jiffies + HZ);
  59. }
  60. void mips_scroll_message(void)
  61. {
  62. del_timer_sync(&mips_scroll_timer);
  63. max_display_count = strlen(display_string) + 1 - 16;
  64. mod_timer(&mips_scroll_timer, jiffies + 1);
  65. }