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
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
*/ */
#define RTC_IO_EXTENT 0x10 /*Only really two ports, but... */ #define RTC_IO_EXTENT 0x10 /*Only really two ports, but... */
#include <linux/config.h> #include <linux/config.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -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;
...@@ -69,7 +69,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -69,7 +69,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteInst(0x0F); LCDWriteInst(0x0F);
break; break;
case LCD_Off: case LCD_Off:
udelay(150); udelay(150);
...@@ -95,7 +95,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -95,7 +95,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
case LCD_Clear: case LCD_Clear:
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteInst(0x01); LCDWriteInst(0x01);
break; break;
case LCD_Cursor_Left: case LCD_Cursor_Left:
...@@ -108,86 +108,95 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -108,86 +108,95 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteInst(0x14); LCDWriteInst(0x14);
break; break;
case LCD_Cursor_Off: case LCD_Cursor_Off:
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteInst(0x0C); LCDWriteInst(0x0C);
break; break;
case LCD_Cursor_On:
udelay(150);
BusyCheck();
LCDWriteInst(0x0F);
break;
case LCD_Blink_Off:
udelay(150);
BusyCheck();
LCDWriteInst(0x0E);
break;
case LCD_Get_Cursor_Pos:{
struct lcd_display display;
case LCD_Cursor_On:
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
display.cursor_address = ( LCDReadInst ); LCDWriteInst(0x0F);
display.cursor_address = ( display.cursor_address & 0x07F ); break;
if(copy_to_user((struct lcd_display*)arg, &display, sizeof(struct lcd_display)))
return -EFAULT;
case LCD_Blink_Off:
udelay(150);
BusyCheck();
LCDWriteInst(0x0E);
break; break;
case LCD_Get_Cursor_Pos:{
struct lcd_display display;
udelay(150);
BusyCheck();
display.cursor_address = (LCDReadInst);
display.cursor_address =
(display.cursor_address & 0x07F);
if (copy_to_user
((struct lcd_display *) arg, &display,
sizeof(struct lcd_display)))
return -EFAULT;
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
return -EFAULT; (&display, (struct lcd_display *) arg,
sizeof(struct lcd_display)))
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: {
struct lcd_display display;
udelay(150); case LCD_Get_Cursor:{
BusyCheck(); struct lcd_display display;
display.character = LCDReadData;
if(copy_to_user((struct lcd_display*)arg, &display, sizeof(struct lcd_display))) udelay(150);
return -EFAULT; BusyCheck();
udelay(150); display.character = LCDReadData;
BusyCheck();
LCDWriteInst(0x10);
break; if (copy_to_user
((struct lcd_display *) arg, &display,
sizeof(struct lcd_display)))
return -EFAULT;
udelay(150);
BusyCheck();
LCDWriteInst(0x10);
break;
} }
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)))
return -EFAULT;
udelay(150); if (copy_from_user
BusyCheck(); (&display, (struct lcd_display *) arg,
LCDWriteData( display.character ); sizeof(struct lcd_display)))
udelay(150); return -EFAULT;
BusyCheck();
LCDWriteInst(0x10);
break; udelay(150);
} BusyCheck();
LCDWriteData(display.character);
udelay(150);
BusyCheck();
LCDWriteInst(0x10);
break;
}
case LCD_Disp_Left: case LCD_Disp_Left:
...@@ -208,294 +217,330 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -208,294 +217,330 @@ 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)))
return -EFAULT;
if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display)))
return -EFAULT;
udelay(150);
BusyCheck();
LCDWriteInst(0x80);
udelay(150);
BusyCheck();
for (index = 0; index < (display.size1); index++) {
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteData( display.line1[index]); LCDWriteInst(0x80);
BusyCheck(); udelay(150);
} BusyCheck();
udelay(150);
BusyCheck();
LCDWriteInst(0xC0);
udelay(150);
BusyCheck();
for (index = 0; index < (display.size2); index++) {
udelay(150);
BusyCheck();
LCDWriteData( display.line2[index]);
}
break;
}
case LCD_Read: {
struct lcd_display display;
BusyCheck(); for (index = 0; index < (display.size1); index++) {
for (address = kDD_R00; address <= kDD_R01; address++) { udelay(150);
a = (address | kLCD_Addr ); BusyCheck();
LCDWriteData(display.line1[index]);
BusyCheck();
}
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
LCDWriteInst( a ); LCDWriteInst(0xC0);
udelay(150); udelay(150);
BusyCheck(); BusyCheck();
display.line1[address] = LCDReadData; for (index = 0; index < (display.size2); index++) {
udelay(150);
BusyCheck();
LCDWriteData(display.line2[index]);
}
break;
} }
display.line1[ 0x27 ] = '\0'; case LCD_Read:{
struct lcd_display display;
for (address = kDD_R10; address <= kDD_R11; address++) {
a = (address | kLCD_Addr );
udelay(150);
BusyCheck();
LCDWriteInst( a );
udelay(150);
BusyCheck();
display.line2[address - 0x40 ] = LCDReadData;
}
display.line2[ 0x27 ] = '\0';
if(copy_to_user((struct lcd_display*)arg, &display,
sizeof(struct lcd_display)))
return -EFAULT;
break;
}
// set all GPIO leds to led_display.leds BusyCheck();
for (address = kDD_R00; address <= kDD_R01;
address++) {
a = (address | kLCD_Addr);
udelay(150);
BusyCheck();
LCDWriteInst(a);
udelay(150);
BusyCheck();
display.line1[address] = LCDReadData;
}
case LED_Set: { display.line1[0x27] = '\0';
struct lcd_display led_display;
if(copy_from_user(&led_display, (struct lcd_display*)arg, for (address = kDD_R10; address <= kDD_R11;
sizeof(struct lcd_display))) address++) {
return -EFAULT; a = (address | kLCD_Addr);
led_state = led_display.leds; udelay(150);
LEDSet(led_state); BusyCheck();
LCDWriteInst(a);
udelay(150);
BusyCheck();
display.line2[address - 0x40] =
LCDReadData;
}
display.line2[0x27] = '\0';
if (copy_to_user
((struct lcd_display *) arg, &display,
sizeof(struct lcd_display)))
return -EFAULT;
break;
}
// set all GPIO leds to led_display.leds
case LED_Set:{
struct lcd_display led_display;
break;
} if (copy_from_user
(&led_display, (struct lcd_display *) arg,
sizeof(struct lcd_display)))
return -EFAULT;
led_state = led_display.leds;
LEDSet(led_state);
break;
}
// 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
sizeof(struct lcd_display))) (&led_display, (struct lcd_display *) arg,
return -EFAULT; sizeof(struct lcd_display)))
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;
LEDSet(led_state); LEDSet(led_state);
break; break;
} }
// 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
sizeof(struct lcd_display))) (&led_display, (struct lcd_display *) arg,
return -EFAULT; sizeof(struct lcd_display)))
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;
LEDSet(led_state); LEDSet(led_state);
break; break;
} }
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
return -EFAULT; ((struct lcd_display *) arg, &button_display,
break; sizeof(struct lcd_display)))
} return -EFAULT;
break;
}
case LINK_Check: { case LINK_Check:{
button_display.buttons = *((volatile unsigned long *) (0xB0100060) );
if(copy_to_user((struct lcd_display*)arg, &button_display, sizeof(struct lcd_display)))
return -EFAULT;
break;
}
case LINK_Check_2: {
int iface_num;
/* 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
* link is in fact up for the requested interface. --DaveM
*/
if(copy_from_user(&button_display, (struct lcd_display *)arg, sizeof(button_display)))
return -EFAULT;
iface_num = button_display.buttons;
#if defined(CONFIG_TULIP) && 0
if (iface_num >= 0 &&
iface_num < MAX_INTERFACES &&
linkcheck_callbacks[iface_num] != NULL) {
button_display.buttons = button_display.buttons =
linkcheck_callbacks[iface_num](linkcheck_cookies[iface_num]); *((volatile unsigned long *) (0xB0100060));
} else if (copy_to_user
((struct lcd_display *) arg, &button_display,
sizeof(struct lcd_display)))
return -EFAULT;
break;
}
case LINK_Check_2:{
int iface_num;
/* 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
* link is in fact up for the requested interface. --DaveM
*/
if (copy_from_user
(&button_display, (struct lcd_display *) arg,
sizeof(button_display)))
return -EFAULT;
iface_num = button_display.buttons;
#if defined(CONFIG_TULIP) && 0
if (iface_num >= 0 &&
iface_num < MAX_INTERFACES &&
linkcheck_callbacks[iface_num] != NULL) {
button_display.buttons =
linkcheck_callbacks[iface_num]
(linkcheck_cookies[iface_num]);
} 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
return -EFAULT; ((struct lcd_display *) arg, &button_display,
break; sizeof(struct lcd_display)))
} return -EFAULT;
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))
ctr++; && (!timeout(0x00000000))) {
} ctr++;
}
printk("\n"); printk("\n");
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: {
volatile unsigned long burn_addr;
unsigned long flags;
int i;
unsigned char *rom;
struct lcd_display display;
if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display)))
return -EFAULT;
rom = (unsigned char *) kmalloc((128),GFP_ATOMIC);
if ( rom == NULL ) {
printk ("broken\n");
return 1;
}
printk("Churning and Burning -");
save_flags(flags);
for (i=0; i<FLASH_SIZE; i=i+128) {
if(copy_from_user(rom, display.RomImage + i, 128))
return -EFAULT;
burn_addr = kFlashBase + i;
cli();
for ( index = 0; index < ( 128 ) ; index++ )
{
WRITE_FLASH( kFlash_Addr1, kFlash_Data1 );
WRITE_FLASH( kFlash_Addr2, kFlash_Data2 );
WRITE_FLASH( kFlash_Addr1, kFlash_Prog );
*((volatile unsigned char *)burn_addr) = (volatile unsigned char) rom[index];
while ( (!dqpoll(burn_addr,(volatile unsigned char) rom[index])) && (!timeout(burn_addr)) ) {
}
burn_addr++;
}
restore_flags(flags);
if ( *((volatile unsigned char *)(burn_addr-1)) == (volatile unsigned char) rom[index-1] ) {
} else if (timeout) {
printk("Program timed out\r\n");
}
case FLASH_Burn:{
} volatile unsigned long burn_addr;
kfree(rom); unsigned long flags;
int i;
unsigned char *rom;
break;
}
// read the flash all at once struct lcd_display display;
case FLASH_Read: {
unsigned char *user_bytes; if (copy_from_user
volatile unsigned long read_addr; (&display, (struct lcd_display *) arg,
int i; sizeof(struct lcd_display)))
return -EFAULT;
rom = (unsigned char *) kmalloc((128), GFP_ATOMIC);
if (rom == NULL) {
printk("broken\n");
return 1;
}
user_bytes = &(((struct lcd_display *)arg)->RomImage[0]); printk("Churning and Burning -");
save_flags(flags);
for (i = 0; i < FLASH_SIZE; i = i + 128) {
if (copy_from_user
(rom, display.RomImage + i, 128))
return -EFAULT;
burn_addr = kFlashBase + i;
cli();
for (index = 0; index < (128); index++) {
WRITE_FLASH(kFlash_Addr1,
kFlash_Data1);
WRITE_FLASH(kFlash_Addr2,
kFlash_Data2);
WRITE_FLASH(kFlash_Addr1,
kFlash_Prog);
*((volatile unsigned char *)
burn_addr) =
(volatile unsigned char) rom[index];
while ((!dqpoll
(burn_addr,
(volatile unsigned char)
rom[index]))
&& (!timeout(burn_addr))) {
}
burn_addr++;
}
restore_flags(flags);
if (*
((volatile unsigned char *) (burn_addr
- 1)) ==
(volatile unsigned char) rom[index -
1]) {
} else if (timeout) {
printk("Program timed out\r\n");
}
if(!access_ok(VERIFY_WRITE, user_bytes, FLASH_SIZE))
return -EFAULT;
printk("Reading Flash"); }
for (i=0; i<FLASH_SIZE; i++) { kfree(rom);
unsigned char tmp_byte;
read_addr = kFlashBase + i; break;
tmp_byte = *((volatile unsigned char *)read_addr);
if(__put_user (tmp_byte, &user_bytes[i]))
return -EFAULT;
} }
// read the flash all at once
break; case FLASH_Read:{
}
unsigned char *user_bytes;
volatile unsigned long read_addr;
int i;
user_bytes =
&(((struct lcd_display *) arg)->RomImage[0]);
if (!access_ok
(VERIFY_WRITE, user_bytes, FLASH_SIZE))
return -EFAULT;
printk("Reading Flash");
for (i = 0; i < FLASH_SIZE; i++) {
unsigned char tmp_byte;
read_addr = kFlashBase + i;
tmp_byte =
*((volatile unsigned char *)
read_addr);
if (__put_user(tmp_byte, &user_bytes[i]))
return -EFAULT;
}
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;
} }
...@@ -551,21 +598,20 @@ static long lcd_read(struct inode *inode, struct file *file, char *buf, unsigned ...@@ -551,21 +598,20 @@ static long lcd_read(struct inode *inode, struct file *file, char *buf, unsigned
*/ */
static struct file_operations lcd_fops = { static struct file_operations lcd_fops = {
.read = lcd_read, .read = lcd_read,
.ioctl = lcd_ioctl, .ioctl = lcd_ioctl,
.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