1/* 2 * Carsten Langgaard, carstenl@mips.com 3 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. 4 * 5 * This program is free software; you can distribute it and/or modify it 6 * under the terms of the GNU General Public License (Version 2) as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * for more details. 13 * 14 * You should have received a copy of the GNU General Public License along 15 * with this program; if not, write to the Free Software Foundation, Inc., 16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 17 * 18 */ 19 20#include <linux/compiler.h> 21#include <linux/timer.h> 22#include <asm/io.h> 23#include <asm/mips-boards/generic.h> 24#include <asm/mips-boards/prom.h> 25 26extern const char display_string[]; 27static unsigned int display_count; 28static unsigned int max_display_count; 29 30#define DISPLAY_LCDINSTRUCTION (0*2) 31#define DISPLAY_LCDDATA (1*2) 32#define DISPLAY_CPLDSTATUS (2*2) 33#define DISPLAY_CPLDDATA (3*2) 34#define LCD_SETDDRAM 0x80 35#define LCD_IR_BF 0x80 36 37static void lcd_wait(unsigned int __iomem *display) 38{ 39 /* wait for CPLD state machine to become idle */ 40 do { 41 } while (__raw_readl(display + DISPLAY_CPLDSTATUS) & 1); 42 43 do { 44 __raw_readl(display + DISPLAY_LCDINSTRUCTION); 45 46 /* wait for CPLD state machine to become idle */ 47 do { 48 } while (__raw_readl(display + DISPLAY_CPLDSTATUS) & 1); 49 } while (__raw_readl(display + DISPLAY_CPLDDATA) & LCD_IR_BF); 50} 51 52void mips_display_message(const char *str) 53{ 54 static unsigned int __iomem *display; /* static => auto initialized to NULL */ 55 int i; 56 char ch; 57 58 if (unlikely(display == NULL)) 59 display = ioremap_nocache(LCD_DISPLAY_POS_BASE, 4*2*sizeof(int)); 60 61 for (i = 0; i < 16; i++) { 62 if (*str) 63 ch = *str++; 64 else 65 ch = ' '; 66 lcd_wait(display); 67 __raw_writel(LCD_SETDDRAM | i, display + DISPLAY_LCDINSTRUCTION); 68 lcd_wait(display); 69 __raw_writel(ch, display + DISPLAY_LCDDATA); 70 } 71} 72 73static void scroll_display_message(unsigned long data); 74static DEFINE_TIMER(mips_scroll_timer, scroll_display_message, HZ, 0); 75 76static void scroll_display_message(unsigned long data) 77{ 78 mips_display_message(&display_string[display_count++]); 79 if (display_count == max_display_count) 80 display_count = 0; 81 82 mod_timer(&mips_scroll_timer, jiffies + HZ); 83} 84 85void mips_scroll_message(void) 86{ 87 del_timer_sync(&mips_scroll_timer); 88 max_display_count = strlen(display_string) + 1 - 16; 89 mod_timer(&mips_scroll_timer, jiffies + 1); 90} 91