Commit 845c4140 authored by Ralf Bächle's avatar Ralf Bächle Committed by Linus Torvalds

[PATCH] Cobalt LCD Driver update

Mostly reformatting to get the sometimes random formatting style of the LCD
driver to something Linux compliant.  Use module_init/exit for module
initialization and cleanup.
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5d119c3c
...@@ -932,11 +932,6 @@ config AU1000_USB_DEVICE ...@@ -932,11 +932,6 @@ config AU1000_USB_DEVICE
depends on MIPS_PB1500 || MIPS_PB1100 || MIPS_PB1000 depends on MIPS_PB1500 || MIPS_PB1100 || MIPS_PB1000
default n default n
config COBALT_LCD
bool
depends on MIPS_COBALT
default y
config MIPS_GT96100 config MIPS_GT96100
bool bool
depends on MIPS_EV96100 depends on MIPS_EV96100
......
...@@ -80,7 +80,6 @@ CONFIG_I8259=y ...@@ -80,7 +80,6 @@ CONFIG_I8259=y
CONFIG_CPU_LITTLE_ENDIAN=y CONFIG_CPU_LITTLE_ENDIAN=y
CONFIG_IRQ_CPU=y CONFIG_IRQ_CPU=y
CONFIG_MIPS_GT64111=y CONFIG_MIPS_GT64111=y
CONFIG_COBALT_LCD=y
CONFIG_MIPS_L1_CACHE_SHIFT=5 CONFIG_MIPS_L1_CACHE_SHIFT=5
# CONFIG_FB is not set # CONFIG_FB is not set
...@@ -432,6 +431,7 @@ CONFIG_LEGACY_PTY_COUNT=256 ...@@ -432,6 +431,7 @@ CONFIG_LEGACY_PTY_COUNT=256
# #
# CONFIG_WATCHDOG is not set # CONFIG_WATCHDOG is not set
CONFIG_RTC=y CONFIG_RTC=y
CONFIG_COBALT_LCD=y
# CONFIG_DTLK is not set # CONFIG_DTLK is not set
# CONFIG_R3964 is not set # CONFIG_R3964 is not set
# CONFIG_APPLICOM is not set # CONFIG_APPLICOM is not set
......
...@@ -793,6 +793,13 @@ config EFI_RTC ...@@ -793,6 +793,13 @@ config EFI_RTC
bool "EFI Real Time Clock Services" bool "EFI Real Time Clock Services"
depends on IA64 depends on IA64
config COBALT_LCD
bool "Support for Cobalt LCD"
depends on MIPS_COBALT
help
This option enables support for the LCD display and buttons found
on Cobalt systems through a misc device.
config H8 config H8
bool "Tadpole ANA H8 Support (OBSOLETE)" bool "Tadpole ANA H8 Support (OBSOLETE)"
depends on OBSOLETE && ALPHA_BOOK1 depends on OBSOLETE && ALPHA_BOOK1
......
...@@ -68,6 +68,7 @@ obj-$(CONFIG_DS1620) += ds1620.o ...@@ -68,6 +68,7 @@ obj-$(CONFIG_DS1620) += ds1620.o
obj-$(CONFIG_HW_RANDOM) += hw_random.o obj-$(CONFIG_HW_RANDOM) += hw_random.o
obj-$(CONFIG_QIC02_TAPE) += tpqic02.o obj-$(CONFIG_QIC02_TAPE) += tpqic02.o
obj-$(CONFIG_FTAPE) += ftape/ obj-$(CONFIG_FTAPE) += ftape/
obj-$(CONFIG_COBALT_LCD) += lcd.o
obj-$(CONFIG_H8) += h8.o obj-$(CONFIG_H8) += h8.o
obj-$(CONFIG_PPDEV) += ppdev.o obj-$(CONFIG_PPDEV) += ppdev.o
obj-$(CONFIG_NWBUTTON) += nwbutton.o obj-$(CONFIG_NWBUTTON) += nwbutton.o
......
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
#include "lcd.h" #include "lcd.h"
static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, static int lcd_ioctl(struct inode *inode, struct file *file,
unsigned long arg); unsigned int cmd, unsigned long arg);
static int lcd_present = 1; static int lcd_present = 1;
...@@ -57,8 +57,8 @@ int lcd_register_linkcheck_func(int iface_num, void *func, void *cookie) ...@@ -57,8 +57,8 @@ int lcd_register_linkcheck_func(int iface_num, void *func, void *cookie)
} }
#endif #endif
static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, static int lcd_ioctl(struct inode *inode, struct file *file,
unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct lcd_display button_display; struct lcd_display button_display;
unsigned long address, a; unsigned long address, a;
...@@ -133,38 +133,45 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -133,38 +133,45 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
display.cursor_address = ( LCDReadInst ); display.cursor_address = (LCDReadInst);
display.cursor_address = ( display.cursor_address & 0x07F ); display.cursor_address =
if(copy_to_user((struct lcd_display*)arg, &display, sizeof(struct lcd_display))) (display.cursor_address & 0x07F);
if (copy_to_user
((struct lcd_display *) arg, &display,
sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
break; break;
} }
case LCD_Set_Cursor_Pos: { case LCD_Set_Cursor_Pos:{
struct lcd_display display; struct lcd_display display;
if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display))) if (copy_from_user
(&display, (struct lcd_display *) arg,
sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
a = (display.cursor_address | kLCD_Addr ); a = (display.cursor_address | kLCD_Addr);
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteInst( a ); LCDWriteInst(a);
break; break;
} }
case LCD_Get_Cursor: { case LCD_Get_Cursor:{
struct lcd_display display; struct lcd_display display;
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
display.character = LCDReadData; display.character = LCDReadData;
if(copy_to_user((struct lcd_display*)arg, &display, sizeof(struct lcd_display))) if (copy_to_user
((struct lcd_display *) arg, &display,
sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
...@@ -176,12 +183,14 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -176,12 +183,14 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
case LCD_Set_Cursor:{ case LCD_Set_Cursor:{
struct lcd_display display; struct lcd_display display;
if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display))) if (copy_from_user
(&display, (struct lcd_display *) arg,
sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteData( display.character ); LCDWriteData(display.character);
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteInst(0x10); LCDWriteInst(0x10);
...@@ -208,11 +217,13 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -208,11 +217,13 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
LCDWriteInst(0x02); LCDWriteInst(0x02);
break; break;
case LCD_Write: { case LCD_Write:{
struct lcd_display display; struct lcd_display display;
if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display))) if (copy_from_user
(&display, (struct lcd_display *) arg,
sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
udelay(150); udelay(150);
...@@ -224,7 +235,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -224,7 +235,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
for (index = 0; index < (display.size1); index++) { for (index = 0; index < (display.size1); index++) {
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteData( display.line1[index]); LCDWriteData(display.line1[index]);
BusyCheck(); BusyCheck();
} }
...@@ -236,44 +247,48 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -236,44 +247,48 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
for (index = 0; index < (display.size2); index++) { for (index = 0; index < (display.size2); index++) {
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteData( display.line2[index]); LCDWriteData(display.line2[index]);
} }
break; break;
} }
case LCD_Read: { case LCD_Read:{
struct lcd_display display; struct lcd_display display;
BusyCheck(); BusyCheck();
for (address = kDD_R00; address <= kDD_R01; address++) { for (address = kDD_R00; address <= kDD_R01;
a = (address | kLCD_Addr ); address++) {
a = (address | kLCD_Addr);
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteInst( a ); LCDWriteInst(a);
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
display.line1[address] = LCDReadData; display.line1[address] = LCDReadData;
} }
display.line1[ 0x27 ] = '\0'; display.line1[0x27] = '\0';
for (address = kDD_R10; address <= kDD_R11; address++) { for (address = kDD_R10; address <= kDD_R11;
a = (address | kLCD_Addr ); address++) {
a = (address | kLCD_Addr);
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteInst( a ); LCDWriteInst(a);
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
display.line2[address - 0x40 ] = LCDReadData; display.line2[address - 0x40] =
LCDReadData;
} }
display.line2[ 0x27 ] = '\0'; display.line2[0x27] = '\0';
if(copy_to_user((struct lcd_display*)arg, &display, if (copy_to_user
((struct lcd_display *) arg, &display,
sizeof(struct lcd_display))) sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
break; break;
...@@ -281,11 +296,12 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -281,11 +296,12 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
// set all GPIO leds to led_display.leds // set all GPIO leds to led_display.leds
case LED_Set: { case LED_Set:{
struct lcd_display led_display; struct lcd_display led_display;
if(copy_from_user(&led_display, (struct lcd_display*)arg, if (copy_from_user
(&led_display, (struct lcd_display *) arg,
sizeof(struct lcd_display))) sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
...@@ -298,19 +314,19 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -298,19 +314,19 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
// set only bit led_display.leds // set only bit led_display.leds
case LED_Bit_Set: { case LED_Bit_Set:{
int i; int i;
int bit=1; int bit = 1;
struct lcd_display led_display; struct lcd_display led_display;
if(copy_from_user(&led_display, (struct lcd_display*)arg, if (copy_from_user
(&led_display, (struct lcd_display *) arg,
sizeof(struct lcd_display))) sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
for (i=0;i<(int)led_display.leds;i++) for (i = 0; i < (int) led_display.leds; i++) {
{ bit = 2 * bit;
bit = 2*bit;
} }
led_state = led_state | bit; led_state = led_state | bit;
...@@ -320,19 +336,19 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -320,19 +336,19 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
// clear only bit led_display.leds // clear only bit led_display.leds
case LED_Bit_Clear: { case LED_Bit_Clear:{
int i; int i;
int bit=1; int bit = 1;
struct lcd_display led_display; struct lcd_display led_display;
if(copy_from_user(&led_display, (struct lcd_display*)arg, if (copy_from_user
(&led_display, (struct lcd_display *) arg,
sizeof(struct lcd_display))) sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
for (i=0;i<(int)led_display.leds;i++) for (i = 0; i < (int) led_display.leds; i++) {
{ bit = 2 * bit;
bit = 2*bit;
} }
led_state = led_state & ~bit; led_state = led_state & ~bit;
...@@ -341,28 +357,35 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -341,28 +357,35 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
} }
case BUTTON_Read: { case BUTTON_Read:{
button_display.buttons = GPIRead; button_display.buttons = GPIRead;
if(copy_to_user((struct lcd_display*)arg, &button_display, sizeof(struct lcd_display))) if (copy_to_user
((struct lcd_display *) arg, &button_display,
sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
break; break;
} }
case LINK_Check: { case LINK_Check:{
button_display.buttons = *((volatile unsigned long *) (0xB0100060) ); button_display.buttons =
if(copy_to_user((struct lcd_display*)arg, &button_display, sizeof(struct lcd_display))) *((volatile unsigned long *) (0xB0100060));
if (copy_to_user
((struct lcd_display *) arg, &button_display,
sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
break; break;
} }
case LINK_Check_2: { case LINK_Check_2:{
int iface_num; int iface_num;
/* panel-utils should pass in the desired interface status is wanted for /* panel-utils should pass in the desired interface status is wanted for
* in "buttons" of the structure. We will set this to non-zero if the * in "buttons" of the structure. We will set this to non-zero if the
* link is in fact up for the requested interface. --DaveM * link is in fact up for the requested interface. --DaveM
*/ */
if(copy_from_user(&button_display, (struct lcd_display *)arg, sizeof(button_display))) if (copy_from_user
(&button_display, (struct lcd_display *) arg,
sizeof(button_display)))
return -EFAULT; return -EFAULT;
iface_num = button_display.buttons; iface_num = button_display.buttons;
#if defined(CONFIG_TULIP) && 0 #if defined(CONFIG_TULIP) && 0
...@@ -370,33 +393,37 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -370,33 +393,37 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
iface_num < MAX_INTERFACES && iface_num < MAX_INTERFACES &&
linkcheck_callbacks[iface_num] != NULL) { linkcheck_callbacks[iface_num] != NULL) {
button_display.buttons = button_display.buttons =
linkcheck_callbacks[iface_num](linkcheck_cookies[iface_num]); linkcheck_callbacks[iface_num]
(linkcheck_cookies[iface_num]);
} else } else
#endif #endif
button_display.buttons = 0; button_display.buttons = 0;
if(__copy_to_user((struct lcd_display*)arg, &button_display, sizeof(struct lcd_display))) if (__copy_to_user
((struct lcd_display *) arg, &button_display,
sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
break; break;
} }
// Erase the flash // Erase the flash
case FLASH_Erase: { case FLASH_Erase:{
int ctr=0; int ctr = 0;
// Chip Erase Sequence // Chip Erase Sequence
WRITE_FLASH( kFlash_Addr1, kFlash_Data1 ); WRITE_FLASH(kFlash_Addr1, kFlash_Data1);
WRITE_FLASH( kFlash_Addr2, kFlash_Data2 ); WRITE_FLASH(kFlash_Addr2, kFlash_Data2);
WRITE_FLASH( kFlash_Addr1, kFlash_Erase3 ); WRITE_FLASH(kFlash_Addr1, kFlash_Erase3);
WRITE_FLASH( kFlash_Addr1, kFlash_Data1 ); WRITE_FLASH(kFlash_Addr1, kFlash_Data1);
WRITE_FLASH( kFlash_Addr2, kFlash_Data2 ); WRITE_FLASH(kFlash_Addr2, kFlash_Data2);
WRITE_FLASH( kFlash_Addr1, kFlash_Erase6 ); WRITE_FLASH(kFlash_Addr1, kFlash_Erase6);
printk( "Erasing Flash.\n"); printk("Erasing Flash.\n");
while ( (!dqpoll(0x00000000,0xFF)) && (!timeout(0x00000000)) ) { while ((!dqpoll(0x00000000, 0xFF))
&& (!timeout(0x00000000))) {
ctr++; ctr++;
} }
...@@ -404,15 +431,18 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -404,15 +431,18 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
printk("\n"); printk("\n");
printk("\n"); printk("\n");
if (READ_FLASH(0x07FFF0)==0xFF) { printk("Erase Successful\r\n"); } if (READ_FLASH(0x07FFF0) == 0xFF) {
else if (timeout) { printk("Erase Timed Out\r\n"); } printk("Erase Successful\r\n");
} else if (timeout) {
printk("Erase Timed Out\r\n");
}
break; break;
} }
// burn the flash // burn the flash
case FLASH_Burn: { case FLASH_Burn:{
volatile unsigned long burn_addr; volatile unsigned long burn_addr;
unsigned long flags; unsigned long flags;
...@@ -422,36 +452,51 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -422,36 +452,51 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
struct lcd_display display; struct lcd_display display;
if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display))) if (copy_from_user
(&display, (struct lcd_display *) arg,
sizeof(struct lcd_display)))
return -EFAULT; return -EFAULT;
rom = (unsigned char *) kmalloc((128),GFP_ATOMIC); rom = (unsigned char *) kmalloc((128), GFP_ATOMIC);
if ( rom == NULL ) { if (rom == NULL) {
printk ("broken\n"); printk("broken\n");
return 1; return 1;
} }
printk("Churning and Burning -"); printk("Churning and Burning -");
save_flags(flags); save_flags(flags);
for (i=0; i<FLASH_SIZE; i=i+128) { for (i = 0; i < FLASH_SIZE; i = i + 128) {
if(copy_from_user(rom, display.RomImage + i, 128)) if (copy_from_user
(rom, display.RomImage + i, 128))
return -EFAULT; return -EFAULT;
burn_addr = kFlashBase + i; burn_addr = kFlashBase + i;
cli(); cli();
for ( index = 0; index < ( 128 ) ; index++ ) for (index = 0; index < (128); index++) {
{
WRITE_FLASH(kFlash_Addr1,
WRITE_FLASH( kFlash_Addr1, kFlash_Data1 ); kFlash_Data1);
WRITE_FLASH( kFlash_Addr2, kFlash_Data2 ); WRITE_FLASH(kFlash_Addr2,
WRITE_FLASH( kFlash_Addr1, kFlash_Prog ); kFlash_Data2);
*((volatile unsigned char *)burn_addr) = (volatile unsigned char) rom[index]; WRITE_FLASH(kFlash_Addr1,
kFlash_Prog);
while ( (!dqpoll(burn_addr,(volatile unsigned char) rom[index])) && (!timeout(burn_addr)) ) { *((volatile unsigned char *)
burn_addr) =
(volatile unsigned char) rom[index];
while ((!dqpoll
(burn_addr,
(volatile unsigned char)
rom[index]))
&& (!timeout(burn_addr))) {
} }
burn_addr++; burn_addr++;
} }
restore_flags(flags); restore_flags(flags);
if ( *((volatile unsigned char *)(burn_addr-1)) == (volatile unsigned char) rom[index-1] ) { if (*
((volatile unsigned char *) (burn_addr
- 1)) ==
(volatile unsigned char) rom[index -
1]) {
} else if (timeout) { } else if (timeout) {
printk("Program timed out\r\n"); printk("Program timed out\r\n");
} }
...@@ -465,23 +510,27 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -465,23 +510,27 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
// read the flash all at once // read the flash all at once
case FLASH_Read: { case FLASH_Read:{
unsigned char *user_bytes; unsigned char *user_bytes;
volatile unsigned long read_addr; volatile unsigned long read_addr;
int i; int i;
user_bytes = &(((struct lcd_display *)arg)->RomImage[0]); user_bytes =
&(((struct lcd_display *) arg)->RomImage[0]);
if(!access_ok(VERIFY_WRITE, user_bytes, FLASH_SIZE)) if (!access_ok
(VERIFY_WRITE, user_bytes, FLASH_SIZE))
return -EFAULT; return -EFAULT;
printk("Reading Flash"); printk("Reading Flash");
for (i=0; i<FLASH_SIZE; i++) { for (i = 0; i < FLASH_SIZE; i++) {
unsigned char tmp_byte; unsigned char tmp_byte;
read_addr = kFlashBase + i; read_addr = kFlashBase + i;
tmp_byte = *((volatile unsigned char *)read_addr); tmp_byte =
if(__put_user (tmp_byte, &user_bytes[i])) *((volatile unsigned char *)
read_addr);
if (__put_user(tmp_byte, &user_bytes[i]))
return -EFAULT; return -EFAULT;
} }
...@@ -489,10 +538,6 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -489,10 +538,6 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
break; break;
} }
default: default:
return 0; return 0;
break; break;
...@@ -517,7 +562,8 @@ static inline int button_pressed(void) ...@@ -517,7 +562,8 @@ static inline int button_pressed(void)
{ {
unsigned long buttons = GPIRead; unsigned long buttons = GPIRead;
if ( (buttons == BUTTON_Next) || (buttons == BUTTON_Next_B) || (buttons == BUTTON_Reset_B) ) if ((buttons == BUTTON_Next) || (buttons == BUTTON_Next_B)
|| (buttons == BUTTON_Reset_B))
return buttons; return buttons;
return 0; return 0;
} }
...@@ -526,22 +572,23 @@ static inline int button_pressed(void) ...@@ -526,22 +572,23 @@ static inline int button_pressed(void)
static int lcd_waiters = 0; static int lcd_waiters = 0;
static long lcd_read(struct inode *inode, struct file *file, char *buf, unsigned long count) static long lcd_read(struct inode *inode, struct file *file, char *buf,
unsigned long count)
{ {
long buttons_now; long buttons_now;
if(lcd_waiters > 0) if (lcd_waiters > 0)
return -EINVAL; return -EINVAL;
lcd_waiters++; lcd_waiters++;
while(((buttons_now = (long)button_pressed()) == 0) && while (((buttons_now = (long) button_pressed()) == 0) &&
!(signal_pending(current))) { !(signal_pending(current))) {
current->state = TASK_INTERRUPTIBLE; current->state = TASK_INTERRUPTIBLE;
schedule_timeout(2 * HZ); schedule_timeout(2 * HZ);
} }
lcd_waiters--; lcd_waiters--;
if(signal_pending(current)) if (signal_pending(current))
return -ERESTARTSYS; return -ERESTARTSYS;
return buttons_now; return buttons_now;
} }
...@@ -556,16 +603,15 @@ static struct file_operations lcd_fops = { ...@@ -556,16 +603,15 @@ static struct file_operations lcd_fops = {
.open = lcd_open, .open = lcd_open,
}; };
static struct miscdevice lcd_dev= static struct miscdevice lcd_dev = {
{ MISC_DYNAMIC_MINOR,
LCD_MINOR,
"lcd", "lcd",
&lcd_fops &lcd_fops
}; };
int lcd_init(void) static int lcd_init(void)
{ {
unsigned long data; unsigned long data;
printk("%s\n", LCD_DRIVER); printk("%s\n", LCD_DRIVER);
misc_register(&lcd_dev); misc_register(&lcd_dev);
...@@ -575,19 +621,22 @@ unsigned long data; ...@@ -575,19 +621,22 @@ unsigned long data;
udelay(150); udelay(150);
data = LCDReadData; data = LCDReadData;
if ( (data & 0x000000FF) == (0x00) ) { if ((data & 0x000000FF) == (0x00)) {
lcd_present = 0; lcd_present = 0;
printk("LCD Not Present\n"); printk("LCD Not Present\n");
} } else {
else {
lcd_present = 1; lcd_present = 1;
WRITE_GAL( kGal_DevBank2PReg, kGal_DevBank2Cfg ); WRITE_GAL(kGal_DevBank2PReg, kGal_DevBank2Cfg);
WRITE_GAL( kGal_DevBank3PReg, kGal_DevBank3Cfg ); WRITE_GAL(kGal_DevBank3PReg, kGal_DevBank3Cfg);
} }
return 0; return 0;
} }
static void __exit lcd_exit(void)
{
misc_deregister(&lcd_dev);
}
// //
// Function: dqpoll // Function: dqpoll
...@@ -600,17 +649,15 @@ unsigned long data; ...@@ -600,17 +649,15 @@ unsigned long data;
// //
// //
int dqpoll( volatile unsigned long address, volatile unsigned char data ) { static int dqpoll(volatile unsigned long address, volatile unsigned char data)
{
volatile unsigned char dq7; volatile unsigned char dq7;
dq7 = data & 0x80;
return ( (READ_FLASH(address) & 0x80) == dq7 ); dq7 = data & 0x80;
return ((READ_FLASH(address) & 0x80) == dq7);
} }
// //
// Function: timeout // Function: timeout
// //
...@@ -622,12 +669,13 @@ return ( (READ_FLASH(address) & 0x80) == dq7 ); ...@@ -622,12 +669,13 @@ return ( (READ_FLASH(address) & 0x80) == dq7 );
// //
// Out: 0 = not timed out, 1 = timed out // Out: 0 = not timed out, 1 = timed out
int timeout( volatile unsigned long address ) { static int timeout(volatile unsigned long address)
{
return (READ_FLASH(address) & 0x20) == 0x20;
return ( (READ_FLASH(address) & 0x20) == 0x20 );
} }
module_init(lcd_init);
module_exit(lcd_exit);
MODULE_AUTHOR("Andrew Bose");
MODULE_LICENSE("GPL");
/*
* LED, LCD and Button panel driver for Cobalt
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 1996, 1997 by Andrew Bose
*
* Linux kernel version history:
* March 2001: Ported from 2.0.34 by Liam Davies
*
*/
// function headers
static int dqpoll(volatile unsigned long, volatile unsigned char );
static int timeout(volatile unsigned long);
#define LCD_CHARS_PER_LINE 40
#define FLASH_SIZE 524288
#define MAX_IDLE_TIME 120
struct lcd_display {
unsigned long buttons;
int size1;
int size2;
unsigned char line1[LCD_CHARS_PER_LINE];
unsigned char line2[LCD_CHARS_PER_LINE];
unsigned char cursor_address;
unsigned char character;
unsigned char leds;
unsigned char *RomImage;
};
#define LCD_DRIVER "Cobalt LCD Driver v2.10"
#define kLCD_IR 0x0F000000
#define kLCD_DR 0x0F000010
#define kGPI 0x0D000000
#define kLED 0x0C000000
#define kDD_R00 0x00
#define kDD_R01 0x27
#define kDD_R10 0x40
#define kDD_R11 0x67
#define kLCD_Addr 0x00000080
#define LCDTimeoutValue 0xfff
// Flash definitions AMD 29F040
#define kFlashBase 0x0FC00000
#define kFlash_Addr1 0x5555
#define kFlash_Addr2 0x2AAA
#define kFlash_Data1 0xAA
#define kFlash_Data2 0x55
#define kFlash_Prog 0xA0
#define kFlash_Erase3 0x80
#define kFlash_Erase6 0x10
#define kFlash_Read 0xF0
#define kFlash_ID 0x90
#define kFlash_VenAddr 0x00
#define kFlash_DevAddr 0x01
#define kFlash_VenID 0x01
#define kFlash_DevID 0xA4 // 29F040
//#define kFlash_DevID 0xAD // 29F016
// Macros
#define LCDWriteData(x) outl((x << 24), kLCD_DR)
#define LCDWriteInst(x) outl((x << 24), kLCD_IR)
#define LCDReadData (inl(kLCD_DR) >> 24)
#define LCDReadInst (inl(kLCD_IR) >> 24)
#define GPIRead (inl(kGPI) >> 24)
#define LEDSet(x) outb((char)x, kLED)
#define WRITE_GAL(x,y) outl(y, 0x04000000 | (x))
#define BusyCheck() while ((LCDReadInst & 0x80) == 0x80)
#define WRITE_FLASH(x,y) outb((char)y, kFlashBase | (x))
#define READ_FLASH(x) (inb(kFlashBase | (x)))
/*
* Function command codes for io_ctl.
*/
#define LCD_On 1
#define LCD_Off 2
#define LCD_Clear 3
#define LCD_Reset 4
#define LCD_Cursor_Left 5
#define LCD_Cursor_Right 6
#define LCD_Disp_Left 7
#define LCD_Disp_Right 8
#define LCD_Get_Cursor 9
#define LCD_Set_Cursor 10
#define LCD_Home 11
#define LCD_Read 12
#define LCD_Write 13
#define LCD_Cursor_Off 14
#define LCD_Cursor_On 15
#define LCD_Get_Cursor_Pos 16
#define LCD_Set_Cursor_Pos 17
#define LCD_Blink_Off 18
#define LED_Set 40
#define LED_Bit_Set 41
#define LED_Bit_Clear 42
// Button defs
#define BUTTON_Read 50
// Flash command codes
#define FLASH_Erase 60
#define FLASH_Burn 61
#define FLASH_Read 62
// Ethernet LINK check hackaroo
#define LINK_Check 90
#define LINK_Check_2 91
// Button patterns _B - single layer lcd boards
#define BUTTON_NONE 0x3F
#define BUTTON_NONE_B 0xFE
#define BUTTON_Left 0x3B
#define BUTTON_Left_B 0xFA
#define BUTTON_Right 0x37
#define BUTTON_Right_B 0xDE
#define BUTTON_Up 0x2F
#define BUTTON_Up_B 0xF6
#define BUTTON_Down 0x1F
#define BUTTON_Down_B 0xEE
#define BUTTON_Next 0x3D
#define BUTTON_Next_B 0x7E
#define BUTTON_Enter 0x3E
#define BUTTON_Enter_B 0xBE
#define BUTTON_Reset_B 0xFC
// debounce constants
#define BUTTON_SENSE 160000
#define BUTTON_DEBOUNCE 5000
// Galileo register stuff
#define kGal_DevBank2Cfg 0x1466DB33
#define kGal_DevBank2PReg 0x464
#define kGal_DevBank3Cfg 0x146FDFFB
#define kGal_DevBank3PReg 0x468
// Network
#define kIPADDR 1
#define kNETMASK 2
#define kGATEWAY 3
#define kDNS 4
#define kClassA 5
#define kClassB 6
#define kClassC 7
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment