1 /*
2  * LED, LCD and Button panel driver for Cobalt
3  *
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.
7  *
8  * Copyright (C) 1996, 1997 by Andrew Bose
9  *
10  * Linux kernel version history:
11  *       March 2001: Ported from 2.0.34  by Liam Davies
12  *
13  */
14 
15 // function headers
16 
17 int dqpoll( volatile unsigned long, volatile unsigned char );
18 int timeout( volatile unsigned long );
19 
20 #define LCD_CHARS_PER_LINE 40
21 #define FLASH_SIZE 524288
22 #define MAX_IDLE_TIME 120
23 
24 struct lcd_display {
25         unsigned long 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;
34 };
35 
36 
37 
38 #define LCD_DRIVER	"Cobalt LCD Driver v2.10"
39 
40 #define kLCD_IR		0x0F000000
41 #define kLCD_DR		0x0F000010
42 #define kGPI		0x0D000000
43 #define kLED		0x0C000000
44 
45 #define kDD_R00         0x00
46 #define kDD_R01         0x27
47 #define kDD_R10         0x40
48 #define kDD_R11         0x67
49 
50 #define kLCD_Addr       0x00000080
51 
52 #define LCDTimeoutValue	0xfff
53 
54 
55 // Flash definitions AMD 29F040
56 #define kFlashBase	0x0FC00000
57 
58 #define kFlash_Addr1    0x5555
59 #define kFlash_Addr2    0x2AAA
60 #define kFlash_Data1    0xAA
61 #define kFlash_Data2    0x55
62 #define kFlash_Prog     0xA0
63 #define kFlash_Erase3   0x80
64 #define kFlash_Erase6   0x10
65 #define kFlash_Read     0xF0
66 
67 #define kFlash_ID       0x90
68 #define kFlash_VenAddr  0x00
69 #define kFlash_DevAddr  0x01
70 #define kFlash_VenID    0x01
71 #define kFlash_DevID    0xA4    // 29F040
72 //#define kFlash_DevID  0xAD    // 29F016
73 
74 
75 // Macros
76 
77 #define LCDWriteData(x)	outl((x << 24), kLCD_DR)
78 #define LCDWriteInst(x)	outl((x << 24), kLCD_IR)
79 
80 #define LCDReadData	(inl(kLCD_DR) >> 24)
81 #define LCDReadInst	(inl(kLCD_IR) >> 24)
82 
83 #define GPIRead		(inl(kGPI) >> 24)
84 
85 #define LEDSet(x)	outb((char)x, kLED)
86 
87 #define WRITE_GAL(x,y)	outl(y, 0x04000000 | (x))
88 #define BusyCheck()	while ((LCDReadInst & 0x80) == 0x80)
89 
90 #define WRITE_FLASH(x,y) outb((char)y, kFlashBase | (x))
91 #define READ_FLASH(x)	(inb(kFlashBase | (x)))
92 
93 
94 
95 /*
96  * Function command codes for io_ctl.
97  */
98 #define LCD_On			1
99 #define LCD_Off			2
100 #define LCD_Clear		3
101 #define LCD_Reset		4
102 #define LCD_Cursor_Left		5
103 #define LCD_Cursor_Right	6
104 #define LCD_Disp_Left		7
105 #define LCD_Disp_Right		8
106 #define LCD_Get_Cursor		9
107 #define LCD_Set_Cursor		10
108 #define LCD_Home		11
109 #define LCD_Read		12
110 #define LCD_Write		13
111 #define LCD_Cursor_Off		14
112 #define LCD_Cursor_On		15
113 #define LCD_Get_Cursor_Pos	16
114 #define LCD_Set_Cursor_Pos	17
115 #define LCD_Blink_Off           18
116 
117 #define LED_Set			40
118 #define LED_Bit_Set		41
119 #define LED_Bit_Clear		42
120 
121 
122 //  Button defs
123 #define BUTTON_Read             50
124 
125 //  Flash command codes
126 #define FLASH_Erase		60
127 #define FLASH_Burn		61
128 #define FLASH_Read		62
129 
130 
131 // Ethernet LINK check hackaroo
132 #define LINK_Check              90
133 #define LINK_Check_2		91
134 
135 //  Button patterns  _B - single layer lcd boards
136 
137 #define BUTTON_NONE               0x3F
138 #define BUTTON_NONE_B             0xFE
139 
140 #define BUTTON_Left               0x3B
141 #define BUTTON_Left_B             0xFA
142 
143 #define BUTTON_Right              0x37
144 #define BUTTON_Right_B            0xDE
145 
146 #define BUTTON_Up                 0x2F
147 #define BUTTON_Up_B               0xF6
148 
149 #define BUTTON_Down               0x1F
150 #define BUTTON_Down_B             0xEE
151 
152 #define BUTTON_Next               0x3D
153 #define BUTTON_Next_B             0x7E
154 
155 #define BUTTON_Enter              0x3E
156 #define BUTTON_Enter_B            0xBE
157 
158 #define BUTTON_Reset_B            0xFC
159 
160 
161 // debounce constants
162 
163 #define BUTTON_SENSE            160000
164 #define BUTTON_DEBOUNCE		5000
165 
166 
167 //  Galileo register stuff
168 
169 #define kGal_DevBank2Cfg        0x1466DB33
170 #define kGal_DevBank2PReg       0x464
171 #define kGal_DevBank3Cfg        0x146FDFFB
172 #define kGal_DevBank3PReg       0x468
173 
174 // Network
175 
176 #define kIPADDR			1
177 #define kNETMASK		2
178 #define kGATEWAY		3
179 #define kDNS			4
180 
181 #define kClassA			5
182 #define kClassB			6
183 #define kClassC			7
184 
185