11a59d1b8SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
21da177e4SLinus Torvalds
31da177e4SLinus Torvalds /*
41da177e4SLinus Torvalds * IBM ASM Service Processor Device Driver
51da177e4SLinus Torvalds *
61da177e4SLinus Torvalds * Copyright (C) IBM Corporation, 2004
71da177e4SLinus Torvalds *
8d36b6910SAl Viro * Author: Max Asböck <amax@us.ibm.com>
91da177e4SLinus Torvalds *
1025985edcSLucas De Marchi * Originally written by Pete Reynolds
111da177e4SLinus Torvalds */
121da177e4SLinus Torvalds
131da177e4SLinus Torvalds #ifndef _IBMASM_REMOTE_H_
141da177e4SLinus Torvalds #define _IBMASM_REMOTE_H_
151da177e4SLinus Torvalds
161da177e4SLinus Torvalds #include <asm/io.h>
171da177e4SLinus Torvalds
181da177e4SLinus Torvalds /* pci offsets */
191da177e4SLinus Torvalds #define CONDOR_MOUSE_DATA 0x000AC000
201da177e4SLinus Torvalds #define CONDOR_MOUSE_ISR_CONTROL 0x00
211da177e4SLinus Torvalds #define CONDOR_MOUSE_ISR_STATUS 0x04
221da177e4SLinus Torvalds #define CONDOR_MOUSE_Q_READER 0x08
231da177e4SLinus Torvalds #define CONDOR_MOUSE_Q_WRITER 0x0C
241da177e4SLinus Torvalds #define CONDOR_MOUSE_Q_BEGIN 0x10
251da177e4SLinus Torvalds #define CONDOR_MOUSE_MAX_X 0x14
261da177e4SLinus Torvalds #define CONDOR_MOUSE_MAX_Y 0x18
271da177e4SLinus Torvalds
281da177e4SLinus Torvalds #define CONDOR_INPUT_DESKTOP_INFO 0x1F0
291da177e4SLinus Torvalds #define CONDOR_INPUT_DISPLAY_RESX 0x1F4
301da177e4SLinus Torvalds #define CONDOR_INPUT_DISPLAY_RESY 0x1F8
311da177e4SLinus Torvalds #define CONDOR_INPUT_DISPLAY_BITS 0x1FC
321da177e4SLinus Torvalds #define CONDOR_OUTPUT_VNC_STATUS 0x200
331da177e4SLinus Torvalds
341da177e4SLinus Torvalds #define CONDOR_MOUSE_INTR_STATUS_MASK 0x00000001
351da177e4SLinus Torvalds
361da177e4SLinus Torvalds #define INPUT_TYPE_MOUSE 0x1
371da177e4SLinus Torvalds #define INPUT_TYPE_KEYBOARD 0x2
381da177e4SLinus Torvalds
391da177e4SLinus Torvalds
401da177e4SLinus Torvalds /* mouse button states received from SP */
41278d72aeSMax Asbock #define REMOTE_DOUBLE_CLICK 0xF0
42278d72aeSMax Asbock #define REMOTE_BUTTON_LEFT 0x01
43278d72aeSMax Asbock #define REMOTE_BUTTON_MIDDLE 0x02
44278d72aeSMax Asbock #define REMOTE_BUTTON_RIGHT 0x04
451da177e4SLinus Torvalds
46*1db37611SGuoqing Chi /* size of keysym/keycode translation matrices */
47278d72aeSMax Asbock #define XLATE_SIZE 256
481da177e4SLinus Torvalds
491da177e4SLinus Torvalds struct mouse_input {
501da177e4SLinus Torvalds unsigned short y;
511da177e4SLinus Torvalds unsigned short x;
521da177e4SLinus Torvalds };
531da177e4SLinus Torvalds
541da177e4SLinus Torvalds
551da177e4SLinus Torvalds struct keyboard_input {
561da177e4SLinus Torvalds unsigned short key_code;
571da177e4SLinus Torvalds unsigned char key_flag;
581da177e4SLinus Torvalds unsigned char key_down;
591da177e4SLinus Torvalds };
601da177e4SLinus Torvalds
611da177e4SLinus Torvalds
621da177e4SLinus Torvalds
631da177e4SLinus Torvalds struct remote_input {
641da177e4SLinus Torvalds union {
651da177e4SLinus Torvalds struct mouse_input mouse;
661da177e4SLinus Torvalds struct keyboard_input keyboard;
671da177e4SLinus Torvalds } data;
681da177e4SLinus Torvalds
691da177e4SLinus Torvalds unsigned char type;
701da177e4SLinus Torvalds unsigned char pad1;
711da177e4SLinus Torvalds unsigned char mouse_buttons;
721da177e4SLinus Torvalds unsigned char pad3;
731da177e4SLinus Torvalds };
741da177e4SLinus Torvalds
75278d72aeSMax Asbock #define mouse_addr(sp) (sp->base_address + CONDOR_MOUSE_DATA)
76278d72aeSMax Asbock #define display_width(sp) (mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESX)
77278d72aeSMax Asbock #define display_height(sp) (mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESY)
78278d72aeSMax Asbock #define display_depth(sp) (mouse_addr(sp) + CONDOR_INPUT_DISPLAY_BITS)
79278d72aeSMax Asbock #define desktop_info(sp) (mouse_addr(sp) + CONDOR_INPUT_DESKTOP_INFO)
80278d72aeSMax Asbock #define vnc_status(sp) (mouse_addr(sp) + CONDOR_OUTPUT_VNC_STATUS)
81278d72aeSMax Asbock #define isr_control(sp) (mouse_addr(sp) + CONDOR_MOUSE_ISR_CONTROL)
821da177e4SLinus Torvalds
831da177e4SLinus Torvalds #define mouse_interrupt_pending(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS)
841da177e4SLinus Torvalds #define clear_mouse_interrupt(sp) writel(0, mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS)
851da177e4SLinus Torvalds #define enable_mouse_interrupts(sp) writel(1, mouse_addr(sp) + CONDOR_MOUSE_ISR_CONTROL)
861da177e4SLinus Torvalds #define disable_mouse_interrupts(sp) writel(0, mouse_addr(sp) + CONDOR_MOUSE_ISR_CONTROL)
871da177e4SLinus Torvalds
881da177e4SLinus Torvalds /* remote input queue operations */
891da177e4SLinus Torvalds #define REMOTE_QUEUE_SIZE 60
901da177e4SLinus Torvalds
911da177e4SLinus Torvalds #define get_queue_writer(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_Q_WRITER)
921da177e4SLinus Torvalds #define get_queue_reader(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_Q_READER)
931da177e4SLinus Torvalds #define set_queue_reader(sp, reader) writel(reader, mouse_addr(sp) + CONDOR_MOUSE_Q_READER)
941da177e4SLinus Torvalds
95278d72aeSMax Asbock #define queue_begin (mouse_addr(sp) + CONDOR_MOUSE_Q_BEGIN)
961da177e4SLinus Torvalds
971da177e4SLinus Torvalds #define get_queue_entry(sp, read_index) \
98278d72aeSMax Asbock ((void*)(queue_begin + read_index * sizeof(struct remote_input)))
991da177e4SLinus Torvalds
advance_queue_reader(struct service_processor * sp,unsigned long reader)1001da177e4SLinus Torvalds static inline int advance_queue_reader(struct service_processor *sp, unsigned long reader)
1011da177e4SLinus Torvalds {
1021da177e4SLinus Torvalds reader++;
1031da177e4SLinus Torvalds if (reader == REMOTE_QUEUE_SIZE)
1041da177e4SLinus Torvalds reader = 0;
1051da177e4SLinus Torvalds
1061da177e4SLinus Torvalds set_queue_reader(sp, reader);
1071da177e4SLinus Torvalds return reader;
1081da177e4SLinus Torvalds }
1091da177e4SLinus Torvalds
110278d72aeSMax Asbock #define NO_KEYCODE 0
111278d72aeSMax Asbock #define KEY_SYM_BK_SPC 0xFF08
112278d72aeSMax Asbock #define KEY_SYM_TAB 0xFF09
113278d72aeSMax Asbock #define KEY_SYM_ENTER 0xFF0D
114278d72aeSMax Asbock #define KEY_SYM_SCR_LOCK 0xFF14
115278d72aeSMax Asbock #define KEY_SYM_ESCAPE 0xFF1B
116278d72aeSMax Asbock #define KEY_SYM_HOME 0xFF50
117278d72aeSMax Asbock #define KEY_SYM_LARROW 0xFF51
118278d72aeSMax Asbock #define KEY_SYM_UARROW 0xFF52
119278d72aeSMax Asbock #define KEY_SYM_RARROW 0xFF53
120278d72aeSMax Asbock #define KEY_SYM_DARROW 0xFF54
121278d72aeSMax Asbock #define KEY_SYM_PAGEUP 0xFF55
122278d72aeSMax Asbock #define KEY_SYM_PAGEDOWN 0xFF56
123278d72aeSMax Asbock #define KEY_SYM_END 0xFF57
124278d72aeSMax Asbock #define KEY_SYM_INSERT 0xFF63
125278d72aeSMax Asbock #define KEY_SYM_NUM_LOCK 0xFF7F
126278d72aeSMax Asbock #define KEY_SYM_KPSTAR 0xFFAA
127278d72aeSMax Asbock #define KEY_SYM_KPPLUS 0xFFAB
128278d72aeSMax Asbock #define KEY_SYM_KPMINUS 0xFFAD
129278d72aeSMax Asbock #define KEY_SYM_KPDOT 0xFFAE
130278d72aeSMax Asbock #define KEY_SYM_KPSLASH 0xFFAF
131278d72aeSMax Asbock #define KEY_SYM_KPRIGHT 0xFF96
132278d72aeSMax Asbock #define KEY_SYM_KPUP 0xFF97
133278d72aeSMax Asbock #define KEY_SYM_KPLEFT 0xFF98
134278d72aeSMax Asbock #define KEY_SYM_KPDOWN 0xFF99
135278d72aeSMax Asbock #define KEY_SYM_KP0 0xFFB0
136278d72aeSMax Asbock #define KEY_SYM_KP1 0xFFB1
137278d72aeSMax Asbock #define KEY_SYM_KP2 0xFFB2
138278d72aeSMax Asbock #define KEY_SYM_KP3 0xFFB3
139278d72aeSMax Asbock #define KEY_SYM_KP4 0xFFB4
140278d72aeSMax Asbock #define KEY_SYM_KP5 0xFFB5
141278d72aeSMax Asbock #define KEY_SYM_KP6 0xFFB6
142278d72aeSMax Asbock #define KEY_SYM_KP7 0xFFB7
143278d72aeSMax Asbock #define KEY_SYM_KP8 0xFFB8
144278d72aeSMax Asbock #define KEY_SYM_KP9 0xFFB9
145278d72aeSMax Asbock #define KEY_SYM_F1 0xFFBE // 1B 5B 5B 41
146278d72aeSMax Asbock #define KEY_SYM_F2 0xFFBF // 1B 5B 5B 42
147278d72aeSMax Asbock #define KEY_SYM_F3 0xFFC0 // 1B 5B 5B 43
148278d72aeSMax Asbock #define KEY_SYM_F4 0xFFC1 // 1B 5B 5B 44
149278d72aeSMax Asbock #define KEY_SYM_F5 0xFFC2 // 1B 5B 5B 45
150278d72aeSMax Asbock #define KEY_SYM_F6 0xFFC3 // 1B 5B 31 37 7E
151278d72aeSMax Asbock #define KEY_SYM_F7 0xFFC4 // 1B 5B 31 38 7E
152278d72aeSMax Asbock #define KEY_SYM_F8 0xFFC5 // 1B 5B 31 39 7E
153278d72aeSMax Asbock #define KEY_SYM_F9 0xFFC6 // 1B 5B 32 30 7E
154278d72aeSMax Asbock #define KEY_SYM_F10 0xFFC7 // 1B 5B 32 31 7E
155278d72aeSMax Asbock #define KEY_SYM_F11 0xFFC8 // 1B 5B 32 33 7E
156278d72aeSMax Asbock #define KEY_SYM_F12 0xFFC9 // 1B 5B 32 34 7E
157278d72aeSMax Asbock #define KEY_SYM_SHIFT 0xFFE1
158278d72aeSMax Asbock #define KEY_SYM_CTRL 0xFFE3
159278d72aeSMax Asbock #define KEY_SYM_ALT 0xFFE9
160278d72aeSMax Asbock #define KEY_SYM_CAP_LOCK 0xFFE5
161278d72aeSMax Asbock #define KEY_SYM_DELETE 0xFFFF
162278d72aeSMax Asbock #define KEY_SYM_TILDE 0x60
163278d72aeSMax Asbock #define KEY_SYM_BKTIC 0x7E
164278d72aeSMax Asbock #define KEY_SYM_ONE 0x31
165278d72aeSMax Asbock #define KEY_SYM_BANG 0x21
166278d72aeSMax Asbock #define KEY_SYM_TWO 0x32
167278d72aeSMax Asbock #define KEY_SYM_AT 0x40
168278d72aeSMax Asbock #define KEY_SYM_THREE 0x33
169278d72aeSMax Asbock #define KEY_SYM_POUND 0x23
170278d72aeSMax Asbock #define KEY_SYM_FOUR 0x34
171278d72aeSMax Asbock #define KEY_SYM_DOLLAR 0x24
172278d72aeSMax Asbock #define KEY_SYM_FIVE 0x35
173278d72aeSMax Asbock #define KEY_SYM_PERCENT 0x25
174278d72aeSMax Asbock #define KEY_SYM_SIX 0x36
175278d72aeSMax Asbock #define KEY_SYM_CARAT 0x5E
176278d72aeSMax Asbock #define KEY_SYM_SEVEN 0x37
177278d72aeSMax Asbock #define KEY_SYM_AMPER 0x26
178278d72aeSMax Asbock #define KEY_SYM_EIGHT 0x38
179278d72aeSMax Asbock #define KEY_SYM_STAR 0x2A
180278d72aeSMax Asbock #define KEY_SYM_NINE 0x39
181278d72aeSMax Asbock #define KEY_SYM_LPAREN 0x28
182278d72aeSMax Asbock #define KEY_SYM_ZERO 0x30
183278d72aeSMax Asbock #define KEY_SYM_RPAREN 0x29
184278d72aeSMax Asbock #define KEY_SYM_MINUS 0x2D
185278d72aeSMax Asbock #define KEY_SYM_USCORE 0x5F
186278d72aeSMax Asbock #define KEY_SYM_EQUAL 0x2B
187278d72aeSMax Asbock #define KEY_SYM_PLUS 0x3D
188278d72aeSMax Asbock #define KEY_SYM_LBRKT 0x5B
189278d72aeSMax Asbock #define KEY_SYM_LCURLY 0x7B
190278d72aeSMax Asbock #define KEY_SYM_RBRKT 0x5D
191278d72aeSMax Asbock #define KEY_SYM_RCURLY 0x7D
192278d72aeSMax Asbock #define KEY_SYM_SLASH 0x5C
193278d72aeSMax Asbock #define KEY_SYM_PIPE 0x7C
194278d72aeSMax Asbock #define KEY_SYM_TIC 0x27
195278d72aeSMax Asbock #define KEY_SYM_QUOTE 0x22
196278d72aeSMax Asbock #define KEY_SYM_SEMIC 0x3B
197278d72aeSMax Asbock #define KEY_SYM_COLON 0x3A
198278d72aeSMax Asbock #define KEY_SYM_COMMA 0x2C
199278d72aeSMax Asbock #define KEY_SYM_LT 0x3C
200278d72aeSMax Asbock #define KEY_SYM_PERIOD 0x2E
201278d72aeSMax Asbock #define KEY_SYM_GT 0x3E
202278d72aeSMax Asbock #define KEY_SYM_BSLASH 0x2F
203278d72aeSMax Asbock #define KEY_SYM_QMARK 0x3F
204278d72aeSMax Asbock #define KEY_SYM_A 0x41
205278d72aeSMax Asbock #define KEY_SYM_B 0x42
206278d72aeSMax Asbock #define KEY_SYM_C 0x43
207278d72aeSMax Asbock #define KEY_SYM_D 0x44
208278d72aeSMax Asbock #define KEY_SYM_E 0x45
209278d72aeSMax Asbock #define KEY_SYM_F 0x46
210278d72aeSMax Asbock #define KEY_SYM_G 0x47
211278d72aeSMax Asbock #define KEY_SYM_H 0x48
212278d72aeSMax Asbock #define KEY_SYM_I 0x49
213278d72aeSMax Asbock #define KEY_SYM_J 0x4A
214278d72aeSMax Asbock #define KEY_SYM_K 0x4B
215278d72aeSMax Asbock #define KEY_SYM_L 0x4C
216278d72aeSMax Asbock #define KEY_SYM_M 0x4D
217278d72aeSMax Asbock #define KEY_SYM_N 0x4E
218278d72aeSMax Asbock #define KEY_SYM_O 0x4F
219278d72aeSMax Asbock #define KEY_SYM_P 0x50
220278d72aeSMax Asbock #define KEY_SYM_Q 0x51
221278d72aeSMax Asbock #define KEY_SYM_R 0x52
222278d72aeSMax Asbock #define KEY_SYM_S 0x53
223278d72aeSMax Asbock #define KEY_SYM_T 0x54
224278d72aeSMax Asbock #define KEY_SYM_U 0x55
225278d72aeSMax Asbock #define KEY_SYM_V 0x56
226278d72aeSMax Asbock #define KEY_SYM_W 0x57
227278d72aeSMax Asbock #define KEY_SYM_X 0x58
228278d72aeSMax Asbock #define KEY_SYM_Y 0x59
229278d72aeSMax Asbock #define KEY_SYM_Z 0x5A
230278d72aeSMax Asbock #define KEY_SYM_a 0x61
231278d72aeSMax Asbock #define KEY_SYM_b 0x62
232278d72aeSMax Asbock #define KEY_SYM_c 0x63
233278d72aeSMax Asbock #define KEY_SYM_d 0x64
234278d72aeSMax Asbock #define KEY_SYM_e 0x65
235278d72aeSMax Asbock #define KEY_SYM_f 0x66
236278d72aeSMax Asbock #define KEY_SYM_g 0x67
237278d72aeSMax Asbock #define KEY_SYM_h 0x68
238278d72aeSMax Asbock #define KEY_SYM_i 0x69
239278d72aeSMax Asbock #define KEY_SYM_j 0x6A
240278d72aeSMax Asbock #define KEY_SYM_k 0x6B
241278d72aeSMax Asbock #define KEY_SYM_l 0x6C
242278d72aeSMax Asbock #define KEY_SYM_m 0x6D
243278d72aeSMax Asbock #define KEY_SYM_n 0x6E
244278d72aeSMax Asbock #define KEY_SYM_o 0x6F
245278d72aeSMax Asbock #define KEY_SYM_p 0x70
246278d72aeSMax Asbock #define KEY_SYM_q 0x71
247278d72aeSMax Asbock #define KEY_SYM_r 0x72
248278d72aeSMax Asbock #define KEY_SYM_s 0x73
249278d72aeSMax Asbock #define KEY_SYM_t 0x74
250278d72aeSMax Asbock #define KEY_SYM_u 0x75
251278d72aeSMax Asbock #define KEY_SYM_v 0x76
252278d72aeSMax Asbock #define KEY_SYM_w 0x77
253278d72aeSMax Asbock #define KEY_SYM_x 0x78
254278d72aeSMax Asbock #define KEY_SYM_y 0x79
255278d72aeSMax Asbock #define KEY_SYM_z 0x7A
256278d72aeSMax Asbock #define KEY_SYM_SPACE 0x20
2571da177e4SLinus Torvalds #endif /* _IBMASM_REMOTE_H_ */
258