xref: /linux/drivers/input/mouse/trackpoint.h (revision 3c09ec59cdea5b132212d97154d625fd34e436dd)
1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2541e316aSStephen Evanchik /*
3541e316aSStephen Evanchik  * IBM TrackPoint PS/2 mouse driver
4541e316aSStephen Evanchik  *
5541e316aSStephen Evanchik  * Stephen Evanchik <evanchsa@gmail.com>
6541e316aSStephen Evanchik  */
7541e316aSStephen Evanchik 
8541e316aSStephen Evanchik #ifndef _TRACKPOINT_H
9541e316aSStephen Evanchik #define _TRACKPOINT_H
10541e316aSStephen Evanchik 
11541e316aSStephen Evanchik /*
12541e316aSStephen Evanchik  * These constants are from the TrackPoint System
13541e316aSStephen Evanchik  * Engineering documentation Version 4 from IBM Watson
14541e316aSStephen Evanchik  * research:
15541e316aSStephen Evanchik  *	http://wwwcssrv.almaden.ibm.com/trackpoint/download.html
16541e316aSStephen Evanchik  */
17541e316aSStephen Evanchik 
18541e316aSStephen Evanchik #define TP_COMMAND		0xE2	/* Commands start with this */
19541e316aSStephen Evanchik 
20541e316aSStephen Evanchik #define TP_READ_ID		0xE1	/* Sent for device identification */
21541e316aSStephen Evanchik 
222a924d71SDmitry Torokhov /*
232a924d71SDmitry Torokhov  * Valid first byte responses to the "Read Secondary ID" (0xE1) command.
242a924d71SDmitry Torokhov  * 0x01 was the original IBM trackpoint, others implement very limited
252a924d71SDmitry Torokhov  * subset of trackpoint features.
262a924d71SDmitry Torokhov  */
272a924d71SDmitry Torokhov #define TP_VARIANT_IBM			0x01
282a924d71SDmitry Torokhov #define TP_VARIANT_ALPS			0x02
292a924d71SDmitry Torokhov #define TP_VARIANT_ELAN			0x03
302a924d71SDmitry Torokhov #define TP_VARIANT_NXP			0x04
31*6c77545aSVincent Huang #define TP_VARIANT_JYT_SYNAPTICS	0x05
32*6c77545aSVincent Huang #define TP_VARIANT_SYNAPTICS		0x06
33541e316aSStephen Evanchik 
34541e316aSStephen Evanchik /*
35541e316aSStephen Evanchik  * Commands
36541e316aSStephen Evanchik  */
37541e316aSStephen Evanchik #define TP_RECALIB		0x51	/* Recalibrate */
38541e316aSStephen Evanchik #define TP_POWER_DOWN		0x44	/* Can only be undone through HW reset */
39541e316aSStephen Evanchik #define TP_EXT_DEV		0x21	/* Determines if external device is connected (RO) */
40541e316aSStephen Evanchik #define TP_EXT_BTN		0x4B	/* Read extended button status */
41541e316aSStephen Evanchik #define TP_POR			0x7F	/* Execute Power on Reset */
42541e316aSStephen Evanchik #define TP_POR_RESULTS		0x25	/* Read Power on Self test results */
43541e316aSStephen Evanchik #define TP_DISABLE_EXT		0x40	/* Disable external pointing device */
44541e316aSStephen Evanchik #define TP_ENABLE_EXT		0x41	/* Enable external pointing device */
45541e316aSStephen Evanchik 
46541e316aSStephen Evanchik /*
47541e316aSStephen Evanchik  * Mode manipulation
48541e316aSStephen Evanchik  */
49541e316aSStephen Evanchik #define TP_SET_SOFT_TRANS	0x4E	/* Set mode */
50541e316aSStephen Evanchik #define TP_CANCEL_SOFT_TRANS	0xB9	/* Cancel mode */
51541e316aSStephen Evanchik #define TP_SET_HARD_TRANS	0x45	/* Mode can only be set */
52541e316aSStephen Evanchik 
53541e316aSStephen Evanchik 
54541e316aSStephen Evanchik /*
55541e316aSStephen Evanchik  * Register oriented commands/properties
56541e316aSStephen Evanchik  */
57541e316aSStephen Evanchik #define TP_WRITE_MEM		0x81
58541e316aSStephen Evanchik #define TP_READ_MEM		0x80	/* Not used in this implementation */
59541e316aSStephen Evanchik 
60541e316aSStephen Evanchik /*
61541e316aSStephen Evanchik * RAM Locations for properties
62541e316aSStephen Evanchik  */
63541e316aSStephen Evanchik #define TP_SENS			0x4A	/* Sensitivity */
64541e316aSStephen Evanchik #define TP_MB			0x4C	/* Read Middle Button Status (RO) */
65541e316aSStephen Evanchik #define TP_INERTIA		0x4D	/* Negative Inertia */
66541e316aSStephen Evanchik #define TP_SPEED		0x60	/* Speed of TP Cursor */
67541e316aSStephen Evanchik #define TP_REACH		0x57	/* Backup for Z-axis press */
68541e316aSStephen Evanchik #define TP_DRAGHYS		0x58	/* Drag Hysteresis */
69541e316aSStephen Evanchik 					/* (how hard it is to drag */
70541e316aSStephen Evanchik 					/* with Z-axis pressed) */
71541e316aSStephen Evanchik 
72541e316aSStephen Evanchik #define TP_MINDRAG		0x59	/* Minimum amount of force needed */
73541e316aSStephen Evanchik 					/* to trigger dragging */
74541e316aSStephen Evanchik 
75541e316aSStephen Evanchik #define TP_THRESH		0x5C	/* Minimum value for a Z-axis press */
76541e316aSStephen Evanchik #define TP_UP_THRESH		0x5A	/* Used to generate a 'click' on Z-axis */
77541e316aSStephen Evanchik #define TP_Z_TIME		0x5E	/* How sharp of a press */
78541e316aSStephen Evanchik #define TP_JENKS_CURV		0x5D	/* Minimum curvature for double click */
792ba35320Shaarp #define TP_DRIFT_TIME		0x5F	/* How long a 'hands off' condition */
802ba35320Shaarp 					/* must last (x*107ms) for drift */
812ba35320Shaarp 					/* correction to occur */
82541e316aSStephen Evanchik 
83541e316aSStephen Evanchik /*
84541e316aSStephen Evanchik  * Toggling Flag bits
85541e316aSStephen Evanchik  */
86541e316aSStephen Evanchik #define TP_TOGGLE		0x47	/* Toggle command */
87541e316aSStephen Evanchik 
88541e316aSStephen Evanchik #define TP_TOGGLE_MB		0x23	/* Disable/Enable Middle Button */
89541e316aSStephen Evanchik #define TP_MASK_MB			0x01
90b8044c74SDmitry Torokhov #define TP_TOGGLE_EXT_DEV	0x23	/* Disable external device */
91541e316aSStephen Evanchik #define TP_MASK_EXT_DEV			0x02
92541e316aSStephen Evanchik #define TP_TOGGLE_DRIFT		0x23	/* Drift Correction */
93541e316aSStephen Evanchik #define TP_MASK_DRIFT			0x80
94541e316aSStephen Evanchik #define TP_TOGGLE_BURST		0x28	/* Burst Mode */
95541e316aSStephen Evanchik #define TP_MASK_BURST			0x80
96541e316aSStephen Evanchik #define TP_TOGGLE_PTSON		0x2C	/* Press to Select */
97541e316aSStephen Evanchik #define TP_MASK_PTSON			0x01
98541e316aSStephen Evanchik #define TP_TOGGLE_HARD_TRANS	0x2C	/* Alternate method to set Hard Transparency */
99541e316aSStephen Evanchik #define TP_MASK_HARD_TRANS		0x80
100541e316aSStephen Evanchik #define TP_TOGGLE_TWOHAND	0x2D	/* Two handed */
101541e316aSStephen Evanchik #define TP_MASK_TWOHAND			0x01
102541e316aSStephen Evanchik #define TP_TOGGLE_STICKY_TWO	0x2D	/* Sticky two handed */
103541e316aSStephen Evanchik #define TP_MASK_STICKY_TWO		0x04
104541e316aSStephen Evanchik #define TP_TOGGLE_SKIPBACK	0x2D	/* Suppress movement after drag release */
105541e316aSStephen Evanchik #define TP_MASK_SKIPBACK		0x08
106541e316aSStephen Evanchik #define TP_TOGGLE_SOURCE_TAG	0x20	/* Bit 3 of the first packet will be set to
107541e316aSStephen Evanchik 					   to the origin of the packet (external or TP) */
108541e316aSStephen Evanchik #define TP_MASK_SOURCE_TAG		0x80
109541e316aSStephen Evanchik #define TP_TOGGLE_EXT_TAG	0x22	/* Bit 3 of the first packet coming from the
110541e316aSStephen Evanchik 					   external device will be forced to 1 */
111541e316aSStephen Evanchik #define TP_MASK_EXT_TAG			0x04
112541e316aSStephen Evanchik 
113541e316aSStephen Evanchik 
114541e316aSStephen Evanchik /* Power on Self Test Results */
115541e316aSStephen Evanchik #define TP_POR_SUCCESS		0x3B
116541e316aSStephen Evanchik 
117541e316aSStephen Evanchik /*
118541e316aSStephen Evanchik  * Default power on values
119541e316aSStephen Evanchik  */
120541e316aSStephen Evanchik #define TP_DEF_SENS		0x80
121541e316aSStephen Evanchik #define TP_DEF_INERTIA		0x06
122541e316aSStephen Evanchik #define TP_DEF_SPEED		0x61
123541e316aSStephen Evanchik #define TP_DEF_REACH		0x0A
124541e316aSStephen Evanchik 
125541e316aSStephen Evanchik #define TP_DEF_DRAGHYS		0xFF
126541e316aSStephen Evanchik #define TP_DEF_MINDRAG		0x14
127541e316aSStephen Evanchik 
128541e316aSStephen Evanchik #define TP_DEF_THRESH		0x08
129541e316aSStephen Evanchik #define TP_DEF_UP_THRESH	0xFF
130541e316aSStephen Evanchik #define TP_DEF_Z_TIME		0x26
131541e316aSStephen Evanchik #define TP_DEF_JENKS_CURV	0x87
1322ba35320Shaarp #define TP_DEF_DRIFT_TIME	0x05
133541e316aSStephen Evanchik 
134541e316aSStephen Evanchik /* Toggles */
135541e316aSStephen Evanchik #define TP_DEF_MB		0x00
136541e316aSStephen Evanchik #define TP_DEF_PTSON		0x00
137541e316aSStephen Evanchik #define TP_DEF_SKIPBACK		0x00
138b8044c74SDmitry Torokhov #define TP_DEF_EXT_DEV		0x00	/* 0 means enabled */
1390c6a6165SShawn Nematbakhsh #define TP_DEF_TWOHAND		0x00
1400c6a6165SShawn Nematbakhsh #define TP_DEF_SOURCE_TAG	0x00
141541e316aSStephen Evanchik 
142541e316aSStephen Evanchik #define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd))
143541e316aSStephen Evanchik 
1442a924d71SDmitry Torokhov struct trackpoint_data {
1452a924d71SDmitry Torokhov 	u8 variant_id;
1462a924d71SDmitry Torokhov 	u8 firmware_id;
1472a924d71SDmitry Torokhov 
1482a924d71SDmitry Torokhov 	u8 sensitivity, speed, inertia, reach;
1492a924d71SDmitry Torokhov 	u8 draghys, mindrag;
1502a924d71SDmitry Torokhov 	u8 thresh, upthresh;
1512a924d71SDmitry Torokhov 	u8 ztime, jenks;
1522a924d71SDmitry Torokhov 	u8 drift_time;
153541e316aSStephen Evanchik 
1540c6a6165SShawn Nematbakhsh 	/* toggles */
1552a924d71SDmitry Torokhov 	bool press_to_select;
1562a924d71SDmitry Torokhov 	bool skipback;
1572a924d71SDmitry Torokhov 	bool ext_dev;
158541e316aSStephen Evanchik };
159541e316aSStephen Evanchik 
160b7802c5cSDmitry Torokhov int trackpoint_detect(struct psmouse *psmouse, bool set_properties);
161541e316aSStephen Evanchik 
162541e316aSStephen Evanchik #endif /* _TRACKPOINT_H */
163