1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /*
4 * IBM ASM Service Processor Device Driver
5 *
6 * Copyright (C) IBM Corporation, 2004
7 *
8 * Author: Max Asböck <amax@us.ibm.com>
9 *
10 * Originally written by Pete Reynolds
11 */
12
13 #ifndef _IBMASM_REMOTE_H_
14 #define _IBMASM_REMOTE_H_
15
16 #include <asm/io.h>
17
18 /* pci offsets */
19 #define CONDOR_MOUSE_DATA 0x000AC000
20 #define CONDOR_MOUSE_ISR_CONTROL 0x00
21 #define CONDOR_MOUSE_ISR_STATUS 0x04
22 #define CONDOR_MOUSE_Q_READER 0x08
23 #define CONDOR_MOUSE_Q_WRITER 0x0C
24 #define CONDOR_MOUSE_Q_BEGIN 0x10
25 #define CONDOR_MOUSE_MAX_X 0x14
26 #define CONDOR_MOUSE_MAX_Y 0x18
27
28 #define CONDOR_INPUT_DESKTOP_INFO 0x1F0
29 #define CONDOR_INPUT_DISPLAY_RESX 0x1F4
30 #define CONDOR_INPUT_DISPLAY_RESY 0x1F8
31 #define CONDOR_INPUT_DISPLAY_BITS 0x1FC
32 #define CONDOR_OUTPUT_VNC_STATUS 0x200
33
34 #define CONDOR_MOUSE_INTR_STATUS_MASK 0x00000001
35
36 #define INPUT_TYPE_MOUSE 0x1
37 #define INPUT_TYPE_KEYBOARD 0x2
38
39
40 /* mouse button states received from SP */
41 #define REMOTE_DOUBLE_CLICK 0xF0
42 #define REMOTE_BUTTON_LEFT 0x01
43 #define REMOTE_BUTTON_MIDDLE 0x02
44 #define REMOTE_BUTTON_RIGHT 0x04
45
46 /* size of keysym/keycode translation matricies */
47 #define XLATE_SIZE 256
48
49 struct mouse_input {
50 unsigned short y;
51 unsigned short x;
52 };
53
54
55 struct keyboard_input {
56 unsigned short key_code;
57 unsigned char key_flag;
58 unsigned char key_down;
59 };
60
61
62
63 struct remote_input {
64 union {
65 struct mouse_input mouse;
66 struct keyboard_input keyboard;
67 } data;
68
69 unsigned char type;
70 unsigned char pad1;
71 unsigned char mouse_buttons;
72 unsigned char pad3;
73 };
74
75 #define mouse_addr(sp) (sp->base_address + CONDOR_MOUSE_DATA)
76 #define display_width(sp) (mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESX)
77 #define display_height(sp) (mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESY)
78 #define display_depth(sp) (mouse_addr(sp) + CONDOR_INPUT_DISPLAY_BITS)
79 #define desktop_info(sp) (mouse_addr(sp) + CONDOR_INPUT_DESKTOP_INFO)
80 #define vnc_status(sp) (mouse_addr(sp) + CONDOR_OUTPUT_VNC_STATUS)
81 #define isr_control(sp) (mouse_addr(sp) + CONDOR_MOUSE_ISR_CONTROL)
82
83 #define mouse_interrupt_pending(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS)
84 #define clear_mouse_interrupt(sp) writel(0, mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS)
85 #define enable_mouse_interrupts(sp) writel(1, mouse_addr(sp) + CONDOR_MOUSE_ISR_CONTROL)
86 #define disable_mouse_interrupts(sp) writel(0, mouse_addr(sp) + CONDOR_MOUSE_ISR_CONTROL)
87
88 /* remote input queue operations */
89 #define REMOTE_QUEUE_SIZE 60
90
91 #define get_queue_writer(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_Q_WRITER)
92 #define get_queue_reader(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_Q_READER)
93 #define set_queue_reader(sp, reader) writel(reader, mouse_addr(sp) + CONDOR_MOUSE_Q_READER)
94
95 #define queue_begin (mouse_addr(sp) + CONDOR_MOUSE_Q_BEGIN)
96
97 #define get_queue_entry(sp, read_index) \
98 ((void*)(queue_begin + read_index * sizeof(struct remote_input)))
99
advance_queue_reader(struct service_processor * sp,unsigned long reader)100 static inline int advance_queue_reader(struct service_processor *sp, unsigned long reader)
101 {
102 reader++;
103 if (reader == REMOTE_QUEUE_SIZE)
104 reader = 0;
105
106 set_queue_reader(sp, reader);
107 return reader;
108 }
109
110 #define NO_KEYCODE 0
111 #define KEY_SYM_BK_SPC 0xFF08
112 #define KEY_SYM_TAB 0xFF09
113 #define KEY_SYM_ENTER 0xFF0D
114 #define KEY_SYM_SCR_LOCK 0xFF14
115 #define KEY_SYM_ESCAPE 0xFF1B
116 #define KEY_SYM_HOME 0xFF50
117 #define KEY_SYM_LARROW 0xFF51
118 #define KEY_SYM_UARROW 0xFF52
119 #define KEY_SYM_RARROW 0xFF53
120 #define KEY_SYM_DARROW 0xFF54
121 #define KEY_SYM_PAGEUP 0xFF55
122 #define KEY_SYM_PAGEDOWN 0xFF56
123 #define KEY_SYM_END 0xFF57
124 #define KEY_SYM_INSERT 0xFF63
125 #define KEY_SYM_NUM_LOCK 0xFF7F
126 #define KEY_SYM_KPSTAR 0xFFAA
127 #define KEY_SYM_KPPLUS 0xFFAB
128 #define KEY_SYM_KPMINUS 0xFFAD
129 #define KEY_SYM_KPDOT 0xFFAE
130 #define KEY_SYM_KPSLASH 0xFFAF
131 #define KEY_SYM_KPRIGHT 0xFF96
132 #define KEY_SYM_KPUP 0xFF97
133 #define KEY_SYM_KPLEFT 0xFF98
134 #define KEY_SYM_KPDOWN 0xFF99
135 #define KEY_SYM_KP0 0xFFB0
136 #define KEY_SYM_KP1 0xFFB1
137 #define KEY_SYM_KP2 0xFFB2
138 #define KEY_SYM_KP3 0xFFB3
139 #define KEY_SYM_KP4 0xFFB4
140 #define KEY_SYM_KP5 0xFFB5
141 #define KEY_SYM_KP6 0xFFB6
142 #define KEY_SYM_KP7 0xFFB7
143 #define KEY_SYM_KP8 0xFFB8
144 #define KEY_SYM_KP9 0xFFB9
145 #define KEY_SYM_F1 0xFFBE // 1B 5B 5B 41
146 #define KEY_SYM_F2 0xFFBF // 1B 5B 5B 42
147 #define KEY_SYM_F3 0xFFC0 // 1B 5B 5B 43
148 #define KEY_SYM_F4 0xFFC1 // 1B 5B 5B 44
149 #define KEY_SYM_F5 0xFFC2 // 1B 5B 5B 45
150 #define KEY_SYM_F6 0xFFC3 // 1B 5B 31 37 7E
151 #define KEY_SYM_F7 0xFFC4 // 1B 5B 31 38 7E
152 #define KEY_SYM_F8 0xFFC5 // 1B 5B 31 39 7E
153 #define KEY_SYM_F9 0xFFC6 // 1B 5B 32 30 7E
154 #define KEY_SYM_F10 0xFFC7 // 1B 5B 32 31 7E
155 #define KEY_SYM_F11 0xFFC8 // 1B 5B 32 33 7E
156 #define KEY_SYM_F12 0xFFC9 // 1B 5B 32 34 7E
157 #define KEY_SYM_SHIFT 0xFFE1
158 #define KEY_SYM_CTRL 0xFFE3
159 #define KEY_SYM_ALT 0xFFE9
160 #define KEY_SYM_CAP_LOCK 0xFFE5
161 #define KEY_SYM_DELETE 0xFFFF
162 #define KEY_SYM_TILDE 0x60
163 #define KEY_SYM_BKTIC 0x7E
164 #define KEY_SYM_ONE 0x31
165 #define KEY_SYM_BANG 0x21
166 #define KEY_SYM_TWO 0x32
167 #define KEY_SYM_AT 0x40
168 #define KEY_SYM_THREE 0x33
169 #define KEY_SYM_POUND 0x23
170 #define KEY_SYM_FOUR 0x34
171 #define KEY_SYM_DOLLAR 0x24
172 #define KEY_SYM_FIVE 0x35
173 #define KEY_SYM_PERCENT 0x25
174 #define KEY_SYM_SIX 0x36
175 #define KEY_SYM_CARAT 0x5E
176 #define KEY_SYM_SEVEN 0x37
177 #define KEY_SYM_AMPER 0x26
178 #define KEY_SYM_EIGHT 0x38
179 #define KEY_SYM_STAR 0x2A
180 #define KEY_SYM_NINE 0x39
181 #define KEY_SYM_LPAREN 0x28
182 #define KEY_SYM_ZERO 0x30
183 #define KEY_SYM_RPAREN 0x29
184 #define KEY_SYM_MINUS 0x2D
185 #define KEY_SYM_USCORE 0x5F
186 #define KEY_SYM_EQUAL 0x2B
187 #define KEY_SYM_PLUS 0x3D
188 #define KEY_SYM_LBRKT 0x5B
189 #define KEY_SYM_LCURLY 0x7B
190 #define KEY_SYM_RBRKT 0x5D
191 #define KEY_SYM_RCURLY 0x7D
192 #define KEY_SYM_SLASH 0x5C
193 #define KEY_SYM_PIPE 0x7C
194 #define KEY_SYM_TIC 0x27
195 #define KEY_SYM_QUOTE 0x22
196 #define KEY_SYM_SEMIC 0x3B
197 #define KEY_SYM_COLON 0x3A
198 #define KEY_SYM_COMMA 0x2C
199 #define KEY_SYM_LT 0x3C
200 #define KEY_SYM_PERIOD 0x2E
201 #define KEY_SYM_GT 0x3E
202 #define KEY_SYM_BSLASH 0x2F
203 #define KEY_SYM_QMARK 0x3F
204 #define KEY_SYM_A 0x41
205 #define KEY_SYM_B 0x42
206 #define KEY_SYM_C 0x43
207 #define KEY_SYM_D 0x44
208 #define KEY_SYM_E 0x45
209 #define KEY_SYM_F 0x46
210 #define KEY_SYM_G 0x47
211 #define KEY_SYM_H 0x48
212 #define KEY_SYM_I 0x49
213 #define KEY_SYM_J 0x4A
214 #define KEY_SYM_K 0x4B
215 #define KEY_SYM_L 0x4C
216 #define KEY_SYM_M 0x4D
217 #define KEY_SYM_N 0x4E
218 #define KEY_SYM_O 0x4F
219 #define KEY_SYM_P 0x50
220 #define KEY_SYM_Q 0x51
221 #define KEY_SYM_R 0x52
222 #define KEY_SYM_S 0x53
223 #define KEY_SYM_T 0x54
224 #define KEY_SYM_U 0x55
225 #define KEY_SYM_V 0x56
226 #define KEY_SYM_W 0x57
227 #define KEY_SYM_X 0x58
228 #define KEY_SYM_Y 0x59
229 #define KEY_SYM_Z 0x5A
230 #define KEY_SYM_a 0x61
231 #define KEY_SYM_b 0x62
232 #define KEY_SYM_c 0x63
233 #define KEY_SYM_d 0x64
234 #define KEY_SYM_e 0x65
235 #define KEY_SYM_f 0x66
236 #define KEY_SYM_g 0x67
237 #define KEY_SYM_h 0x68
238 #define KEY_SYM_i 0x69
239 #define KEY_SYM_j 0x6A
240 #define KEY_SYM_k 0x6B
241 #define KEY_SYM_l 0x6C
242 #define KEY_SYM_m 0x6D
243 #define KEY_SYM_n 0x6E
244 #define KEY_SYM_o 0x6F
245 #define KEY_SYM_p 0x70
246 #define KEY_SYM_q 0x71
247 #define KEY_SYM_r 0x72
248 #define KEY_SYM_s 0x73
249 #define KEY_SYM_t 0x74
250 #define KEY_SYM_u 0x75
251 #define KEY_SYM_v 0x76
252 #define KEY_SYM_w 0x77
253 #define KEY_SYM_x 0x78
254 #define KEY_SYM_y 0x79
255 #define KEY_SYM_z 0x7A
256 #define KEY_SYM_SPACE 0x20
257 #endif /* _IBMASM_REMOTE_H_ */
258