Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / misc / ibmasm / remote.h
bloba8eb19f02d3f5010b8eadc5e3735018a85091023
2 /*
3 * IBM ASM Service Processor Device Driver
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.
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.
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.
19 * Copyright (C) IBM Corporation, 2004
21 * Author: Max Asböck <amax@us.ibm.com>
23 * Orignally written by Pete Reynolds
26 #ifndef _IBMASM_REMOTE_H_
27 #define _IBMASM_REMOTE_H_
29 #include <asm/io.h>
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
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
47 #define CONDOR_MOUSE_INTR_STATUS_MASK 0x00000001
49 #define INPUT_TYPE_MOUSE 0x1
50 #define INPUT_TYPE_KEYBOARD 0x2
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
60 struct mouse_input {
61 unsigned short y;
62 unsigned short x;
66 struct keyboard_input {
67 unsigned short key_code;
68 unsigned char key_flag;
69 unsigned char key_down;
74 struct remote_input {
75 union {
76 struct mouse_input mouse;
77 struct keyboard_input keyboard;
78 } data;
80 unsigned char type;
81 unsigned char pad1;
82 unsigned char mouse_buttons;
83 unsigned char pad3;
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
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)
97 /* remote input queue operations */
98 #define REMOTE_QUEUE_SIZE 60
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)
104 #define queue_begin mouse_addr(sp) + CONDOR_MOUSE_Q_BEGIN
106 #define get_queue_entry(sp, read_index) \
107 queue_begin + read_index * sizeof(struct remote_input)
109 static inline int advance_queue_reader(struct service_processor *sp, unsigned long reader)
111 reader++;
112 if (reader == REMOTE_QUEUE_SIZE)
113 reader = 0;
115 set_queue_reader(sp, reader);
116 return reader;
119 #endif /* _IBMASM_REMOTE_H_ */