Merge git://www.linux-watchdog.org/linux-watchdog
[deliverable/linux.git] / arch / mips / mti-sead3 / sead3-display.c
CommitLineData
3070033a
SH
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#include <asm/mips-boards/prom.h>
12
13static unsigned int display_count;
14static unsigned int max_display_count;
15
16#define LCD_DISPLAY_POS_BASE 0x1f000400
17#define DISPLAY_LCDINSTRUCTION (0*2)
18#define DISPLAY_LCDDATA (1*2)
19#define DISPLAY_CPLDSTATUS (2*2)
20#define DISPLAY_CPLDDATA (3*2)
21#define LCD_SETDDRAM 0x80
22#define LCD_IR_BF 0x80
23
24const char display_string[] = " LINUX ON SEAD3 ";
25
26static void scroll_display_message(unsigned long data);
27static DEFINE_TIMER(mips_scroll_timer, scroll_display_message, HZ, 0);
28
29static void lcd_wait(unsigned int __iomem *display)
30{
31 /* Wait for CPLD state machine to become idle. */
32 do { } while (__raw_readl(display + DISPLAY_CPLDSTATUS) & 1);
33
34 do {
35 __raw_readl(display + DISPLAY_LCDINSTRUCTION);
36
37 /* Wait for CPLD state machine to become idle. */
38 do { } while (__raw_readl(display + DISPLAY_CPLDSTATUS) & 1);
39 } while (__raw_readl(display + DISPLAY_CPLDDATA) & LCD_IR_BF);
40}
41
42void mips_display_message(const char *str)
43{
44 static unsigned int __iomem *display;
45 char ch;
46 int i;
47
48 if (unlikely(display == NULL))
49 display = ioremap_nocache(LCD_DISPLAY_POS_BASE,
50 (8 * sizeof(int)));
51
52 for (i = 0; i < 16; i++) {
53 if (*str)
54 ch = *str++;
55 else
56 ch = ' ';
57 lcd_wait(display);
58 __raw_writel((LCD_SETDDRAM | i),
59 (display + DISPLAY_LCDINSTRUCTION));
60 lcd_wait(display);
61 __raw_writel(ch, display + DISPLAY_LCDDATA);
62 }
63}
64
65static void scroll_display_message(unsigned long data)
66{
67 mips_display_message(&display_string[display_count++]);
68 if (display_count == max_display_count)
69 display_count = 0;
70 mod_timer(&mips_scroll_timer, jiffies + HZ);
71}
72
73void mips_scroll_message(void)
74{
75 del_timer_sync(&mips_scroll_timer);
76 max_display_count = strlen(display_string) + 1 - 16;
77 mod_timer(&mips_scroll_timer, jiffies + 1);
78}
This page took 0.044623 seconds and 5 git commands to generate.