Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Elan I2C/SMBus Touchpad driver
0004  *
0005  * Copyright (c) 2013 ELAN Microelectronics Corp.
0006  *
0007  * Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw>
0008  *
0009  * Based on cyapa driver:
0010  * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
0011  * copyright (c) 2011-2012 Google, Inc.
0012  *
0013  * Trademarks are the property of their respective owners.
0014  */
0015 
0016 #ifndef _ELAN_I2C_H
0017 #define _ELAN_I2C_H
0018 
0019 #include <linux/types.h>
0020 
0021 #define ETP_ENABLE_ABS      0x0001
0022 #define ETP_ENABLE_CALIBRATE    0x0002
0023 #define ETP_DISABLE_CALIBRATE   0x0000
0024 #define ETP_DISABLE_POWER   0x0001
0025 #define ETP_PRESSURE_OFFSET 25
0026 
0027 #define ETP_CALIBRATE_MAX_LEN   3
0028 
0029 #define ETP_FEATURE_REPORT_MK   BIT(0)
0030 
0031 #define ETP_REPORT_ID       0x5D
0032 #define ETP_TP_REPORT_ID    0x5E
0033 #define ETP_TP_REPORT_ID2   0x5F
0034 #define ETP_REPORT_ID2      0x60    /* High precision report */
0035 
0036 #define ETP_REPORT_ID_OFFSET    2
0037 #define ETP_TOUCH_INFO_OFFSET   3
0038 #define ETP_FINGER_DATA_OFFSET  4
0039 #define ETP_HOVER_INFO_OFFSET   30
0040 #define ETP_MK_DATA_OFFSET  33  /* For high precision reports */
0041 
0042 #define ETP_MAX_REPORT_LEN  39
0043 
0044 #define ETP_MAX_FINGERS     5
0045 #define ETP_FINGER_DATA_LEN 5
0046 
0047 /* IAP Firmware handling */
0048 #define ETP_PRODUCT_ID_FORMAT_STRING    "%d.0"
0049 #define ETP_FW_NAME     "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin"
0050 #define ETP_IAP_START_ADDR  0x0083
0051 #define ETP_FW_IAP_PAGE_ERR (1 << 5)
0052 #define ETP_FW_IAP_INTF_ERR (1 << 4)
0053 #define ETP_FW_PAGE_SIZE    64
0054 #define ETP_FW_PAGE_SIZE_128    128
0055 #define ETP_FW_PAGE_SIZE_512    512
0056 #define ETP_FW_SIGNATURE_SIZE   6
0057 
0058 #define ETP_PRODUCT_ID_WHITEBOX 0x00B8
0059 #define ETP_PRODUCT_ID_VOXEL    0x00BF
0060 #define ETP_PRODUCT_ID_DELBIN   0x00C2
0061 #define ETP_PRODUCT_ID_MAGPIE   0x0120
0062 #define ETP_PRODUCT_ID_BOBBA    0x0121
0063 
0064 struct i2c_client;
0065 struct completion;
0066 
0067 enum tp_mode {
0068     IAP_MODE = 1,
0069     MAIN_MODE
0070 };
0071 
0072 struct elan_transport_ops {
0073     int (*initialize)(struct i2c_client *client);
0074     int (*sleep_control)(struct i2c_client *, bool sleep);
0075     int (*power_control)(struct i2c_client *, bool enable);
0076     int (*set_mode)(struct i2c_client *client, u8 mode);
0077 
0078     int (*calibrate)(struct i2c_client *client);
0079     int (*calibrate_result)(struct i2c_client *client, u8 *val);
0080 
0081     int (*get_baseline_data)(struct i2c_client *client,
0082                  bool max_baseline, u8 *value);
0083 
0084     int (*get_version)(struct i2c_client *client, u8 pattern, bool iap,
0085                u8 *version);
0086     int (*get_sm_version)(struct i2c_client *client, u8 pattern,
0087                   u16 *ic_type, u8 *version, u8 *clickpad);
0088     int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum);
0089     int (*get_product_id)(struct i2c_client *client, u16 *id);
0090 
0091     int (*get_max)(struct i2c_client *client,
0092                unsigned int *max_x, unsigned int *max_y);
0093     int (*get_resolution)(struct i2c_client *client,
0094                   u8 *hw_res_x, u8 *hw_res_y);
0095     int (*get_num_traces)(struct i2c_client *client,
0096                   unsigned int *x_tracenum,
0097                   unsigned int *y_tracenum);
0098 
0099     int (*iap_get_mode)(struct i2c_client *client, enum tp_mode *mode);
0100     int (*iap_reset)(struct i2c_client *client);
0101 
0102     int (*prepare_fw_update)(struct i2c_client *client, u16 ic_type,
0103                  u8 iap_version, u16 fw_page_size);
0104     int (*write_fw_block)(struct i2c_client *client, u16 fw_page_size,
0105                   const u8 *page, u16 checksum, int idx);
0106     int (*finish_fw_update)(struct i2c_client *client,
0107                 struct completion *reset_done);
0108 
0109     int (*get_report_features)(struct i2c_client *client, u8 pattern,
0110                    unsigned int *features,
0111                    unsigned int *report_len);
0112     int (*get_report)(struct i2c_client *client, u8 *report,
0113               unsigned int report_len);
0114     int (*get_pressure_adjustment)(struct i2c_client *client,
0115                        int *adjustment);
0116     int (*get_pattern)(struct i2c_client *client, u8 *pattern);
0117 };
0118 
0119 extern const struct elan_transport_ops elan_smbus_ops, elan_i2c_ops;
0120 
0121 #endif /* _ELAN_I2C_H */