Linux 2.6.20.7
[linux/fpc-iii.git] / drivers / char / lcd.h
bloba8d4ae737158b4905f6f3c3acb079f9bbc04091a
1 /*
2 * LED, LCD and Button panel driver for Cobalt
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
8 * Copyright (C) 1996, 1997 by Andrew Bose
10 * Linux kernel version history:
11 * March 2001: Ported from 2.0.34 by Liam Davies
15 // function headers
17 static int dqpoll(volatile unsigned long, volatile unsigned char );
18 static int timeout(volatile unsigned long);
20 #define LCD_CHARS_PER_LINE 40
21 #define FLASH_SIZE 524288
22 #define MAX_IDLE_TIME 120
24 struct lcd_display {
25 unsigned buttons;
26 int size1;
27 int size2;
28 unsigned char line1[LCD_CHARS_PER_LINE];
29 unsigned char line2[LCD_CHARS_PER_LINE];
30 unsigned char cursor_address;
31 unsigned char character;
32 unsigned char leds;
33 unsigned char *RomImage;
38 #define LCD_DRIVER "Cobalt LCD Driver v2.10"
40 #define LCD "lcd: "
42 #define kLCD_IR 0x0F000000
43 #define kLCD_DR 0x0F000010
44 #define kGPI 0x0D000000
45 #define kLED 0x0C000000
47 #define kDD_R00 0x00
48 #define kDD_R01 0x27
49 #define kDD_R10 0x40
50 #define kDD_R11 0x67
52 #define kLCD_Addr 0x00000080
54 #define LCDTimeoutValue 0xfff
57 // Flash definitions AMD 29F040
58 #define kFlashBase 0x0FC00000
60 #define kFlash_Addr1 0x5555
61 #define kFlash_Addr2 0x2AAA
62 #define kFlash_Data1 0xAA
63 #define kFlash_Data2 0x55
64 #define kFlash_Prog 0xA0
65 #define kFlash_Erase3 0x80
66 #define kFlash_Erase6 0x10
67 #define kFlash_Read 0xF0
69 #define kFlash_ID 0x90
70 #define kFlash_VenAddr 0x00
71 #define kFlash_DevAddr 0x01
72 #define kFlash_VenID 0x01
73 #define kFlash_DevID 0xA4 // 29F040
74 //#define kFlash_DevID 0xAD // 29F016
77 // Macros
79 #define LCDWriteData(x) outl((x << 24), kLCD_DR)
80 #define LCDWriteInst(x) outl((x << 24), kLCD_IR)
82 #define LCDReadData (inl(kLCD_DR) >> 24)
83 #define LCDReadInst (inl(kLCD_IR) >> 24)
85 #define GPIRead (inl(kGPI) >> 24)
87 #define LEDSet(x) outb((char)x, kLED)
89 #define WRITE_GAL(x,y) outl(y, 0x04000000 | (x))
90 #define BusyCheck() while ((LCDReadInst & 0x80) == 0x80)
92 #define WRITE_FLASH(x,y) outb((char)y, kFlashBase | (x))
93 #define READ_FLASH(x) (inb(kFlashBase | (x)))
98 * Function command codes for io_ctl.
100 #define LCD_On 1
101 #define LCD_Off 2
102 #define LCD_Clear 3
103 #define LCD_Reset 4
104 #define LCD_Cursor_Left 5
105 #define LCD_Cursor_Right 6
106 #define LCD_Disp_Left 7
107 #define LCD_Disp_Right 8
108 #define LCD_Get_Cursor 9
109 #define LCD_Set_Cursor 10
110 #define LCD_Home 11
111 #define LCD_Read 12
112 #define LCD_Write 13
113 #define LCD_Cursor_Off 14
114 #define LCD_Cursor_On 15
115 #define LCD_Get_Cursor_Pos 16
116 #define LCD_Set_Cursor_Pos 17
117 #define LCD_Blink_Off 18
119 #define LED_Set 40
120 #define LED_Bit_Set 41
121 #define LED_Bit_Clear 42
124 // Button defs
125 #define BUTTON_Read 50
127 // Flash command codes
128 #define FLASH_Erase 60
129 #define FLASH_Burn 61
130 #define FLASH_Read 62
133 // Ethernet LINK check hackaroo
134 #define LINK_Check 90
135 #define LINK_Check_2 91
137 // Button patterns _B - single layer lcd boards
139 #define BUTTON_NONE 0x3F
140 #define BUTTON_NONE_B 0xFE
142 #define BUTTON_Left 0x3B
143 #define BUTTON_Left_B 0xFA
145 #define BUTTON_Right 0x37
146 #define BUTTON_Right_B 0xDE
148 #define BUTTON_Up 0x2F
149 #define BUTTON_Up_B 0xF6
151 #define BUTTON_Down 0x1F
152 #define BUTTON_Down_B 0xEE
154 #define BUTTON_Next 0x3D
155 #define BUTTON_Next_B 0x7E
157 #define BUTTON_Enter 0x3E
158 #define BUTTON_Enter_B 0xBE
160 #define BUTTON_Reset_B 0xFC
163 // debounce constants
165 #define BUTTON_SENSE 160000
166 #define BUTTON_DEBOUNCE 5000
169 // Galileo register stuff
171 #define kGal_DevBank2Cfg 0x1466DB33
172 #define kGal_DevBank2PReg 0x464
173 #define kGal_DevBank3Cfg 0x146FDFFB
174 #define kGal_DevBank3PReg 0x468
176 // Network
178 #define kIPADDR 1
179 #define kNETMASK 2
180 #define kGATEWAY 3
181 #define kDNS 4
183 #define kClassA 5
184 #define kClassB 6
185 #define kClassC 7