diff options
author | Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> | 2007-02-20 14:11:57 +0900 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-02-20 17:11:55 +0000 |
commit | c316eb1eee2c803c33b1f826fe744c922d2e354f (patch) | |
tree | fe20495759af06890169d2ea2612b19a42eb6086 /drivers/char | |
parent | 575d5e72aab57beb6d5fa2a7d66be9fc681a5e00 (diff) |
[MIPS] Add MTD device support for Cobalt
This patch has added MTD device support for Cobalt.
Moreover, removes old type FlashROM support.
Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/lcd.c | 168 | ||||
-rw-r--r-- | drivers/char/lcd.h | 32 |
2 files changed, 0 insertions, 200 deletions
diff --git a/drivers/char/lcd.c b/drivers/char/lcd.c index d649abbf085..5f4fdcf7c96 100644 --- a/drivers/char/lcd.c +++ b/drivers/char/lcd.c @@ -409,138 +409,6 @@ static int lcd_ioctl(struct inode *inode, struct file *file, break; } -// Erase the flash - - case FLASH_Erase:{ - - int ctr = 0; - - if ( !capable(CAP_SYS_ADMIN) ) return -EPERM; - - pr_info(LCD "Erasing Flash\n"); - - // Chip Erase Sequence - WRITE_FLASH(kFlash_Addr1, kFlash_Data1); - WRITE_FLASH(kFlash_Addr2, kFlash_Data2); - WRITE_FLASH(kFlash_Addr1, kFlash_Erase3); - WRITE_FLASH(kFlash_Addr1, kFlash_Data1); - WRITE_FLASH(kFlash_Addr2, kFlash_Data2); - WRITE_FLASH(kFlash_Addr1, kFlash_Erase6); - - while ((!dqpoll(0x00000000, 0xFF)) - && (!timeout(0x00000000))) { - ctr++; - } - - if (READ_FLASH(0x07FFF0) == 0xFF) { - pr_info(LCD "Erase Successful\n"); - } else if (timeout) { - pr_info(LCD "Erase Timed Out\n"); - } - - break; - } - -// burn the flash - - case FLASH_Burn:{ - - volatile unsigned long burn_addr; - unsigned long flags; - unsigned int i, index; - unsigned char *rom; - - - struct lcd_display display; - - if ( !capable(CAP_SYS_ADMIN) ) return -EPERM; - - if (copy_from_user - (&display, (struct lcd_display *) arg, - sizeof(struct lcd_display))) - return -EFAULT; - rom = kmalloc((128), GFP_ATOMIC); - if (rom == NULL) { - printk(KERN_ERR LCD "kmalloc() failed in %s\n", - __FUNCTION__); - return -ENOMEM; - } - - pr_info(LCD "Starting Flash burn\n"); - for (i = 0; i < FLASH_SIZE; i = i + 128) { - - if (copy_from_user - (rom, display.RomImage + i, 128)) { - kfree(rom); - return -EFAULT; - } - burn_addr = kFlashBase + i; - spin_lock_irqsave(&lcd_lock, flags); - 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++; - } - spin_unlock_irqrestore(&lcd_lock, flags); - if (* ((volatile unsigned char *) - (burn_addr - 1)) == - (volatile unsigned char) - rom[index - 1]) { - } else if (timeout) { - pr_info(LCD "Flash burn timed out\n"); - } - - - } - kfree(rom); - - pr_info(LCD "Flash successfully burned\n"); - - break; - } - -// read the flash all at once - - case FLASH_Read:{ - - unsigned char *user_bytes; - volatile unsigned long read_addr; - unsigned int i; - - user_bytes = - &(((struct lcd_display *) arg)->RomImage[0]); - - if (!access_ok - (VERIFY_WRITE, user_bytes, FLASH_SIZE)) - return -EFAULT; - - pr_info(LCD "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: return -EINVAL; @@ -644,42 +512,6 @@ static void __exit lcd_exit(void) misc_deregister(&lcd_dev); } -// -// Function: dqpoll -// -// Description: Polls the data lines to see if the flash is busy -// -// In: address, byte data -// -// Out: 0 = busy, 1 = write or erase complete -// -// - -static int dqpoll(volatile unsigned long address, volatile unsigned char data) -{ - volatile unsigned char dq7; - - dq7 = data & 0x80; - - return ((READ_FLASH(address) & 0x80) == dq7); -} - -// -// Function: timeout -// -// Description: Checks to see if erase or write has timed out -// By polling dq5 -// -// In: address -// -// -// Out: 0 = not timed out, 1 = timed out - -static int timeout(volatile unsigned long address) -{ - return (READ_FLASH(address) & 0x20) == 0x20; -} - module_init(lcd_init); module_exit(lcd_exit); diff --git a/drivers/char/lcd.h b/drivers/char/lcd.h index a8d4ae73715..290b3ff23b0 100644 --- a/drivers/char/lcd.h +++ b/drivers/char/lcd.h @@ -14,11 +14,7 @@ // 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 { @@ -54,26 +50,6 @@ struct lcd_display { #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) @@ -89,9 +65,6 @@ struct lcd_display { #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))) - /* @@ -124,11 +97,6 @@ struct lcd_display { // 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 |