blob: 878a95280e877abbcbc333b999f04383dd095b2a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
17static int dqpoll(volatile unsigned long, volatile unsigned char );
18static 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
24struct 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 LCD "lcd: "
41
42#define kLCD_IR 0x0F000000
43#define kLCD_DR 0x0F000010
44#define kGPI 0x0D000000
45#define kLED 0x0C000000
46
47#define kDD_R00 0x00
48#define kDD_R01 0x27
49#define kDD_R10 0x40
50#define kDD_R11 0x67
51
52#define kLCD_Addr 0x00000080
53
54#define LCDTimeoutValue 0xfff
55
56
57// Flash definitions AMD 29F040
58#define kFlashBase 0x0FC00000
59
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
68
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
75
76
77// Macros
78
79#define LCDWriteData(x) outl((x << 24), kLCD_DR)
80#define LCDWriteInst(x) outl((x << 24), kLCD_IR)
81
82#define LCDReadData (inl(kLCD_DR) >> 24)
83#define LCDReadInst (inl(kLCD_IR) >> 24)
84
85#define GPIRead (inl(kGPI) >> 24)
86
87#define LEDSet(x) outb((char)x, kLED)
88
89#define WRITE_GAL(x,y) outl(y, 0x04000000 | (x))
90#define BusyCheck() while ((LCDReadInst & 0x80) == 0x80)
91
92#define WRITE_FLASH(x,y) outb((char)y, kFlashBase | (x))
93#define READ_FLASH(x) (inb(kFlashBase | (x)))
94
95
96
97/*
98 * Function command codes for io_ctl.
99 */
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
118
119#define LED_Set 40
120#define LED_Bit_Set 41
121#define LED_Bit_Clear 42
122
123
124// Button defs
125#define BUTTON_Read 50
126
127// Flash command codes
128#define FLASH_Erase 60
129#define FLASH_Burn 61
130#define FLASH_Read 62
131
132
133// Ethernet LINK check hackaroo
134#define LINK_Check 90
135#define LINK_Check_2 91
136
137// Button patterns _B - single layer lcd boards
138
139#define BUTTON_NONE 0x3F
140#define BUTTON_NONE_B 0xFE
141
142#define BUTTON_Left 0x3B
143#define BUTTON_Left_B 0xFA
144
145#define BUTTON_Right 0x37
146#define BUTTON_Right_B 0xDE
147
148#define BUTTON_Up 0x2F
149#define BUTTON_Up_B 0xF6
150
151#define BUTTON_Down 0x1F
152#define BUTTON_Down_B 0xEE
153
154#define BUTTON_Next 0x3D
155#define BUTTON_Next_B 0x7E
156
157#define BUTTON_Enter 0x3E
158#define BUTTON_Enter_B 0xBE
159
160#define BUTTON_Reset_B 0xFC
161
162
163// debounce constants
164
165#define BUTTON_SENSE 160000
166#define BUTTON_DEBOUNCE 5000
167
168
169// Galileo register stuff
170
171#define kGal_DevBank2Cfg 0x1466DB33
172#define kGal_DevBank2PReg 0x464
173#define kGal_DevBank3Cfg 0x146FDFFB
174#define kGal_DevBank3PReg 0x468
175
176// Network
177
178#define kIPADDR 1
179#define kNETMASK 2
180#define kGATEWAY 3
181#define kDNS 4
182
183#define kClassA 5
184#define kClassB 6
185#define kClassC 7
186