18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * IBM TrackPoint PS/2 mouse driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Stephen Evanchik <evanchsa@gmail.com> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _TRACKPOINT_H 98c2ecf20Sopenharmony_ci#define _TRACKPOINT_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/* 128c2ecf20Sopenharmony_ci * These constants are from the TrackPoint System 138c2ecf20Sopenharmony_ci * Engineering documentation Version 4 from IBM Watson 148c2ecf20Sopenharmony_ci * research: 158c2ecf20Sopenharmony_ci * http://wwwcssrv.almaden.ibm.com/trackpoint/download.html 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define TP_COMMAND 0xE2 /* Commands start with this */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define TP_READ_ID 0xE1 /* Sent for device identification */ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* 238c2ecf20Sopenharmony_ci * Valid first byte responses to the "Read Secondary ID" (0xE1) command. 248c2ecf20Sopenharmony_ci * 0x01 was the original IBM trackpoint, others implement very limited 258c2ecf20Sopenharmony_ci * subset of trackpoint features. 268c2ecf20Sopenharmony_ci */ 278c2ecf20Sopenharmony_ci#define TP_VARIANT_IBM 0x01 288c2ecf20Sopenharmony_ci#define TP_VARIANT_ALPS 0x02 298c2ecf20Sopenharmony_ci#define TP_VARIANT_ELAN 0x03 308c2ecf20Sopenharmony_ci#define TP_VARIANT_NXP 0x04 318c2ecf20Sopenharmony_ci#define TP_VARIANT_JYT_SYNAPTICS 0x05 328c2ecf20Sopenharmony_ci#define TP_VARIANT_SYNAPTICS 0x06 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* 358c2ecf20Sopenharmony_ci * Commands 368c2ecf20Sopenharmony_ci */ 378c2ecf20Sopenharmony_ci#define TP_RECALIB 0x51 /* Recalibrate */ 388c2ecf20Sopenharmony_ci#define TP_POWER_DOWN 0x44 /* Can only be undone through HW reset */ 398c2ecf20Sopenharmony_ci#define TP_EXT_DEV 0x21 /* Determines if external device is connected (RO) */ 408c2ecf20Sopenharmony_ci#define TP_EXT_BTN 0x4B /* Read extended button status */ 418c2ecf20Sopenharmony_ci#define TP_POR 0x7F /* Execute Power on Reset */ 428c2ecf20Sopenharmony_ci#define TP_POR_RESULTS 0x25 /* Read Power on Self test results */ 438c2ecf20Sopenharmony_ci#define TP_DISABLE_EXT 0x40 /* Disable external pointing device */ 448c2ecf20Sopenharmony_ci#define TP_ENABLE_EXT 0x41 /* Enable external pointing device */ 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* 478c2ecf20Sopenharmony_ci * Mode manipulation 488c2ecf20Sopenharmony_ci */ 498c2ecf20Sopenharmony_ci#define TP_SET_SOFT_TRANS 0x4E /* Set mode */ 508c2ecf20Sopenharmony_ci#define TP_CANCEL_SOFT_TRANS 0xB9 /* Cancel mode */ 518c2ecf20Sopenharmony_ci#define TP_SET_HARD_TRANS 0x45 /* Mode can only be set */ 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* 558c2ecf20Sopenharmony_ci * Register oriented commands/properties 568c2ecf20Sopenharmony_ci */ 578c2ecf20Sopenharmony_ci#define TP_WRITE_MEM 0x81 588c2ecf20Sopenharmony_ci#define TP_READ_MEM 0x80 /* Not used in this implementation */ 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/* 618c2ecf20Sopenharmony_ci* RAM Locations for properties 628c2ecf20Sopenharmony_ci */ 638c2ecf20Sopenharmony_ci#define TP_SENS 0x4A /* Sensitivity */ 648c2ecf20Sopenharmony_ci#define TP_MB 0x4C /* Read Middle Button Status (RO) */ 658c2ecf20Sopenharmony_ci#define TP_INERTIA 0x4D /* Negative Inertia */ 668c2ecf20Sopenharmony_ci#define TP_SPEED 0x60 /* Speed of TP Cursor */ 678c2ecf20Sopenharmony_ci#define TP_REACH 0x57 /* Backup for Z-axis press */ 688c2ecf20Sopenharmony_ci#define TP_DRAGHYS 0x58 /* Drag Hysteresis */ 698c2ecf20Sopenharmony_ci /* (how hard it is to drag */ 708c2ecf20Sopenharmony_ci /* with Z-axis pressed) */ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#define TP_MINDRAG 0x59 /* Minimum amount of force needed */ 738c2ecf20Sopenharmony_ci /* to trigger dragging */ 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define TP_THRESH 0x5C /* Minimum value for a Z-axis press */ 768c2ecf20Sopenharmony_ci#define TP_UP_THRESH 0x5A /* Used to generate a 'click' on Z-axis */ 778c2ecf20Sopenharmony_ci#define TP_Z_TIME 0x5E /* How sharp of a press */ 788c2ecf20Sopenharmony_ci#define TP_JENKS_CURV 0x5D /* Minimum curvature for double click */ 798c2ecf20Sopenharmony_ci#define TP_DRIFT_TIME 0x5F /* How long a 'hands off' condition */ 808c2ecf20Sopenharmony_ci /* must last (x*107ms) for drift */ 818c2ecf20Sopenharmony_ci /* correction to occur */ 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci/* 848c2ecf20Sopenharmony_ci * Toggling Flag bits 858c2ecf20Sopenharmony_ci */ 868c2ecf20Sopenharmony_ci#define TP_TOGGLE 0x47 /* Toggle command */ 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define TP_TOGGLE_MB 0x23 /* Disable/Enable Middle Button */ 898c2ecf20Sopenharmony_ci#define TP_MASK_MB 0x01 908c2ecf20Sopenharmony_ci#define TP_TOGGLE_EXT_DEV 0x23 /* Disable external device */ 918c2ecf20Sopenharmony_ci#define TP_MASK_EXT_DEV 0x02 928c2ecf20Sopenharmony_ci#define TP_TOGGLE_DRIFT 0x23 /* Drift Correction */ 938c2ecf20Sopenharmony_ci#define TP_MASK_DRIFT 0x80 948c2ecf20Sopenharmony_ci#define TP_TOGGLE_BURST 0x28 /* Burst Mode */ 958c2ecf20Sopenharmony_ci#define TP_MASK_BURST 0x80 968c2ecf20Sopenharmony_ci#define TP_TOGGLE_PTSON 0x2C /* Press to Select */ 978c2ecf20Sopenharmony_ci#define TP_MASK_PTSON 0x01 988c2ecf20Sopenharmony_ci#define TP_TOGGLE_HARD_TRANS 0x2C /* Alternate method to set Hard Transparency */ 998c2ecf20Sopenharmony_ci#define TP_MASK_HARD_TRANS 0x80 1008c2ecf20Sopenharmony_ci#define TP_TOGGLE_TWOHAND 0x2D /* Two handed */ 1018c2ecf20Sopenharmony_ci#define TP_MASK_TWOHAND 0x01 1028c2ecf20Sopenharmony_ci#define TP_TOGGLE_STICKY_TWO 0x2D /* Sticky two handed */ 1038c2ecf20Sopenharmony_ci#define TP_MASK_STICKY_TWO 0x04 1048c2ecf20Sopenharmony_ci#define TP_TOGGLE_SKIPBACK 0x2D /* Suppress movement after drag release */ 1058c2ecf20Sopenharmony_ci#define TP_MASK_SKIPBACK 0x08 1068c2ecf20Sopenharmony_ci#define TP_TOGGLE_SOURCE_TAG 0x20 /* Bit 3 of the first packet will be set to 1078c2ecf20Sopenharmony_ci to the origin of the packet (external or TP) */ 1088c2ecf20Sopenharmony_ci#define TP_MASK_SOURCE_TAG 0x80 1098c2ecf20Sopenharmony_ci#define TP_TOGGLE_EXT_TAG 0x22 /* Bit 3 of the first packet coming from the 1108c2ecf20Sopenharmony_ci external device will be forced to 1 */ 1118c2ecf20Sopenharmony_ci#define TP_MASK_EXT_TAG 0x04 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci/* Power on Self Test Results */ 1158c2ecf20Sopenharmony_ci#define TP_POR_SUCCESS 0x3B 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci/* 1188c2ecf20Sopenharmony_ci * Default power on values 1198c2ecf20Sopenharmony_ci */ 1208c2ecf20Sopenharmony_ci#define TP_DEF_SENS 0x80 1218c2ecf20Sopenharmony_ci#define TP_DEF_INERTIA 0x06 1228c2ecf20Sopenharmony_ci#define TP_DEF_SPEED 0x61 1238c2ecf20Sopenharmony_ci#define TP_DEF_REACH 0x0A 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci#define TP_DEF_DRAGHYS 0xFF 1268c2ecf20Sopenharmony_ci#define TP_DEF_MINDRAG 0x14 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci#define TP_DEF_THRESH 0x08 1298c2ecf20Sopenharmony_ci#define TP_DEF_UP_THRESH 0xFF 1308c2ecf20Sopenharmony_ci#define TP_DEF_Z_TIME 0x26 1318c2ecf20Sopenharmony_ci#define TP_DEF_JENKS_CURV 0x87 1328c2ecf20Sopenharmony_ci#define TP_DEF_DRIFT_TIME 0x05 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci/* Toggles */ 1358c2ecf20Sopenharmony_ci#define TP_DEF_MB 0x00 1368c2ecf20Sopenharmony_ci#define TP_DEF_PTSON 0x00 1378c2ecf20Sopenharmony_ci#define TP_DEF_SKIPBACK 0x00 1388c2ecf20Sopenharmony_ci#define TP_DEF_EXT_DEV 0x00 /* 0 means enabled */ 1398c2ecf20Sopenharmony_ci#define TP_DEF_TWOHAND 0x00 1408c2ecf20Sopenharmony_ci#define TP_DEF_SOURCE_TAG 0x00 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci#define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd)) 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_cistruct trackpoint_data { 1458c2ecf20Sopenharmony_ci u8 variant_id; 1468c2ecf20Sopenharmony_ci u8 firmware_id; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci u8 sensitivity, speed, inertia, reach; 1498c2ecf20Sopenharmony_ci u8 draghys, mindrag; 1508c2ecf20Sopenharmony_ci u8 thresh, upthresh; 1518c2ecf20Sopenharmony_ci u8 ztime, jenks; 1528c2ecf20Sopenharmony_ci u8 drift_time; 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci /* toggles */ 1558c2ecf20Sopenharmony_ci bool press_to_select; 1568c2ecf20Sopenharmony_ci bool skipback; 1578c2ecf20Sopenharmony_ci bool ext_dev; 1588c2ecf20Sopenharmony_ci}; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ciint trackpoint_detect(struct psmouse *psmouse, bool set_properties); 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci#endif /* _TRACKPOINT_H */ 163