Linux-2.6.12-rc2
[pandora-kernel.git] / drivers / misc / ibmasm / remote.h
1
2 /*
3  * IBM ASM Service Processor Device Driver
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Copyright (C) IBM Corporation, 2004
20  *
21  * Author: Max Asböck <amax@us.ibm.com> 
22  *
23  * Orignally written by Pete Reynolds
24  */
25
26 #ifndef _IBMASM_REMOTE_H_
27 #define _IBMASM_REMOTE_H_
28
29 #include <asm/io.h>
30
31 /* pci offsets */
32 #define CONDOR_MOUSE_DATA               0x000AC000
33 #define CONDOR_MOUSE_ISR_CONTROL        0x00
34 #define CONDOR_MOUSE_ISR_STATUS         0x04
35 #define CONDOR_MOUSE_Q_READER           0x08
36 #define CONDOR_MOUSE_Q_WRITER           0x0C
37 #define CONDOR_MOUSE_Q_BEGIN            0x10
38 #define CONDOR_MOUSE_MAX_X              0x14
39 #define CONDOR_MOUSE_MAX_Y              0x18
40
41 #define CONDOR_INPUT_DESKTOP_INFO       0x1F0
42 #define CONDOR_INPUT_DISPLAY_RESX       0x1F4
43 #define CONDOR_INPUT_DISPLAY_RESY       0x1F8
44 #define CONDOR_INPUT_DISPLAY_BITS       0x1FC
45 #define CONDOR_OUTPUT_VNC_STATUS        0x200
46
47 #define CONDOR_MOUSE_INTR_STATUS_MASK   0x00000001
48
49 #define INPUT_TYPE_MOUSE        0x1
50 #define INPUT_TYPE_KEYBOARD     0x2
51
52
53 /* mouse button states received from SP */
54 #define REMOTE_MOUSE_DOUBLE_CLICK       0xF0
55 #define REMOTE_MOUSE_BUTTON_LEFT        0x01
56 #define REMOTE_MOUSE_BUTTON_MIDDLE      0x02
57 #define REMOTE_MOUSE_BUTTON_RIGHT       0x04
58
59
60 struct mouse_input {
61         unsigned short  y;
62         unsigned short  x;
63 };
64
65
66 struct keyboard_input {
67         unsigned short  key_code;
68         unsigned char   key_flag;
69         unsigned char   key_down;
70 };
71
72
73
74 struct remote_input { 
75         union {
76                 struct mouse_input      mouse;
77                 struct keyboard_input   keyboard;
78         } data;
79
80         unsigned char   type;
81         unsigned char   pad1;
82         unsigned char   mouse_buttons;
83         unsigned char   pad3;
84 };
85
86 #define mouse_addr(sp)          sp->base_address + CONDOR_MOUSE_DATA
87 #define display_width(sp)       mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESX
88 #define display_height(sp)      mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESY
89 #define display_depth(sp)       mouse_addr(sp) + CONDOR_INPUT_DISPLAY_BITS
90 #define vnc_status(sp)          mouse_addr(sp) + CONDOR_OUTPUT_VNC_STATUS
91
92 #define mouse_interrupt_pending(sp)     readl(mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS)
93 #define clear_mouse_interrupt(sp)       writel(0, mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS)
94 #define enable_mouse_interrupts(sp)     writel(1, mouse_addr(sp) + CONDOR_MOUSE_ISR_CONTROL)
95 #define disable_mouse_interrupts(sp)    writel(0, mouse_addr(sp) + CONDOR_MOUSE_ISR_CONTROL)
96
97 /* remote input queue operations */
98 #define REMOTE_QUEUE_SIZE       60
99
100 #define get_queue_writer(sp)    readl(mouse_addr(sp) + CONDOR_MOUSE_Q_WRITER)
101 #define get_queue_reader(sp)    readl(mouse_addr(sp) + CONDOR_MOUSE_Q_READER)
102 #define set_queue_reader(sp, reader)    writel(reader, mouse_addr(sp) + CONDOR_MOUSE_Q_READER)
103
104 #define queue_begin     mouse_addr(sp) + CONDOR_MOUSE_Q_BEGIN
105
106 #define get_queue_entry(sp, read_index) \
107         queue_begin + read_index * sizeof(struct remote_input)
108
109 static inline int advance_queue_reader(struct service_processor *sp, unsigned long reader)
110 {
111         reader++;
112         if (reader == REMOTE_QUEUE_SIZE)
113                 reader = 0;
114
115         set_queue_reader(sp, reader);
116         return reader;
117 }
118
119 #endif /* _IBMASM_REMOTE_H_ */