powerpc/fsl-booke: add the reg prop for pci bridge device node for T4/B4
[cascardo/linux.git] / drivers / input / mouse / alps.h
1 /*
2  * ALPS touchpad PS/2 mouse driver
3  *
4  * Copyright (c) 2003 Peter Osterlund <petero2@telia.com>
5  * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz>
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License version 2 as published by
9  * the Free Software Foundation.
10  */
11
12 #ifndef _ALPS_H
13 #define _ALPS_H
14
15 #define ALPS_PROTO_V1   1
16 #define ALPS_PROTO_V2   2
17 #define ALPS_PROTO_V3   3
18 #define ALPS_PROTO_V4   4
19
20 /**
21  * struct alps_model_info - touchpad ID table
22  * @signature: E7 response string to match.
23  * @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response
24  *   (aka command mode response) identifies the firmware minor version.  This
25  *   can be used to distinguish different hardware models which are not
26  *   uniquely identifiable through their E7 responses.
27  * @proto_version: Indicates V1/V2/V3/...
28  * @byte0: Helps figure out whether a position report packet matches the
29  *   known format for this model.  The first byte of the report, ANDed with
30  *   mask0, should match byte0.
31  * @mask0: The mask used to check the first byte of the report.
32  * @flags: Additional device capabilities (passthrough port, trackstick, etc.).
33  *
34  * Many (but not all) ALPS touchpads can be identified by looking at the
35  * values returned in the "E7 report" and/or the "EC report."  This table
36  * lists a number of such touchpads.
37  */
38 struct alps_model_info {
39         unsigned char signature[3];
40         unsigned char command_mode_resp;
41         unsigned char proto_version;
42         unsigned char byte0, mask0;
43         unsigned char flags;
44 };
45
46 /**
47  * struct alps_nibble_commands - encodings for register accesses
48  * @command: PS/2 command used for the nibble
49  * @data: Data supplied as an argument to the PS/2 command, if applicable
50  *
51  * The ALPS protocol uses magic sequences to transmit binary data to the
52  * touchpad, as it is generally not OK to send arbitrary bytes out the
53  * PS/2 port.  Each of the sequences in this table sends one nibble of the
54  * register address or (write) data.  Different versions of the ALPS protocol
55  * use slightly different encodings.
56  */
57 struct alps_nibble_commands {
58         int command;
59         unsigned char data;
60 };
61
62 /**
63  * struct alps_fields - decoded version of the report packet
64  * @x_map: Bitmap of active X positions for MT.
65  * @y_map: Bitmap of active Y positions for MT.
66  * @fingers: Number of fingers for MT.
67  * @x: X position for ST.
68  * @y: Y position for ST.
69  * @z: Z position for ST.
70  * @first_mp: Packet is the first of a multi-packet report.
71  * @is_mp: Packet is part of a multi-packet report.
72  * @left: Left touchpad button is active.
73  * @right: Right touchpad button is active.
74  * @middle: Middle touchpad button is active.
75  * @ts_left: Left trackstick button is active.
76  * @ts_right: Right trackstick button is active.
77  * @ts_middle: Middle trackstick button is active.
78  */
79 struct alps_fields {
80         unsigned int x_map;
81         unsigned int y_map;
82         unsigned int fingers;
83         unsigned int x;
84         unsigned int y;
85         unsigned int z;
86         unsigned int first_mp:1;
87         unsigned int is_mp:1;
88
89         unsigned int left:1;
90         unsigned int right:1;
91         unsigned int middle:1;
92
93         unsigned int ts_left:1;
94         unsigned int ts_right:1;
95         unsigned int ts_middle:1;
96 };
97
98 /**
99  * struct alps_data - private data structure for the ALPS driver
100  * @dev2: "Relative" device used to report trackstick or mouse activity.
101  * @phys: Physical path for the relative device.
102  * @nibble_commands: Command mapping used for touchpad register accesses.
103  * @addr_command: Command used to tell the touchpad that a register address
104  *   follows.
105  * @proto_version: Indicates V1/V2/V3/...
106  * @byte0: Helps figure out whether a position report packet matches the
107  *   known format for this model.  The first byte of the report, ANDed with
108  *   mask0, should match byte0.
109  * @mask0: The mask used to check the first byte of the report.
110  * @flags: Additional device capabilities (passthrough port, trackstick, etc.).
111  * @x_max: Largest possible X position value.
112  * @y_max: Largest possible Y position value.
113  * @x_bits: Number of X bits in the MT bitmap.
114  * @y_bits: Number of Y bits in the MT bitmap.
115  * @hw_init: Protocol-specific hardware init function.
116  * @process_packet: Protocol-specific function to process a report packet.
117  * @decode_fields: Protocol-specific function to read packet bitfields.
118  * @set_abs_params: Protocol-specific function to configure the input_dev.
119  * @prev_fin: Finger bit from previous packet.
120  * @multi_packet: Multi-packet data in progress.
121  * @multi_data: Saved multi-packet data.
122  * @x1: First X coordinate from last MT report.
123  * @x2: Second X coordinate from last MT report.
124  * @y1: First Y coordinate from last MT report.
125  * @y2: Second Y coordinate from last MT report.
126  * @fingers: Number of fingers from last MT report.
127  * @quirks: Bitmap of ALPS_QUIRK_*.
128  * @timer: Timer for flushing out the final report packet in the stream.
129  */
130 struct alps_data {
131         struct input_dev *dev2;
132         char phys[32];
133
134         /* these are autodetected when the device is identified */
135         const struct alps_nibble_commands *nibble_commands;
136         int addr_command;
137         unsigned char proto_version;
138         unsigned char byte0, mask0;
139         unsigned char flags;
140         int x_max;
141         int y_max;
142         int x_bits;
143         int y_bits;
144
145         int (*hw_init)(struct psmouse *psmouse);
146         void (*process_packet)(struct psmouse *psmouse);
147         void (*decode_fields)(struct alps_fields *f, unsigned char *p);
148         void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1);
149
150         int prev_fin;
151         int multi_packet;
152         unsigned char multi_data[6];
153         int x1, x2, y1, y2;
154         int fingers;
155         u8 quirks;
156         struct timer_list timer;
157 };
158
159 #define ALPS_QUIRK_TRACKSTICK_BUTTONS   1 /* trakcstick buttons in trackstick packet */
160
161 #ifdef CONFIG_MOUSE_PS2_ALPS
162 int alps_detect(struct psmouse *psmouse, bool set_properties);
163 int alps_init(struct psmouse *psmouse);
164 #else
165 inline int alps_detect(struct psmouse *psmouse, bool set_properties)
166 {
167         return -ENOSYS;
168 }
169 inline int alps_init(struct psmouse *psmouse)
170 {
171         return -ENOSYS;
172 }
173 #endif /* CONFIG_MOUSE_PS2_ALPS */
174
175 #endif