Duson Lin | 6696777 | 2014-10-03 13:24:27 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Elan I2C/SMBus Touchpad driver |
| 3 | * |
| 4 | * Copyright (c) 2013 ELAN Microelectronics Corp. |
| 5 | * |
| 6 | * Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw> |
Duson Lin | 6696777 | 2014-10-03 13:24:27 -0700 | [diff] [blame] | 7 | * |
| 8 | * Based on cyapa driver: |
| 9 | * copyright (c) 2011-2012 Cypress Semiconductor, Inc. |
| 10 | * copyright (c) 2011-2012 Google, Inc. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify it |
| 13 | * under the terms of the GNU General Public License version 2 as published |
| 14 | * by the Free Software Foundation. |
| 15 | * |
| 16 | * Trademarks are the property of their respective owners. |
| 17 | */ |
| 18 | |
| 19 | #ifndef _ELAN_I2C_H |
Nicolas Iooss | 61c797d | 2015-03-19 09:13:34 -0700 | [diff] [blame] | 20 | #define _ELAN_I2C_H |
Duson Lin | 6696777 | 2014-10-03 13:24:27 -0700 | [diff] [blame] | 21 | |
| 22 | #include <linux/types.h> |
| 23 | |
| 24 | #define ETP_ENABLE_ABS 0x0001 |
| 25 | #define ETP_ENABLE_CALIBRATE 0x0002 |
| 26 | #define ETP_DISABLE_CALIBRATE 0x0000 |
| 27 | #define ETP_DISABLE_POWER 0x0001 |
duson | b9bced0 | 2015-04-12 16:01:05 -0700 | [diff] [blame] | 28 | #define ETP_PRESSURE_OFFSET 25 |
Duson Lin | 6696777 | 2014-10-03 13:24:27 -0700 | [diff] [blame] | 29 | |
| 30 | /* IAP Firmware handling */ |
Charlie Mooney | 7b9f183 | 2015-06-08 16:48:23 -0700 | [diff] [blame] | 31 | #define ETP_PRODUCT_ID_FORMAT_STRING "%d.0" |
| 32 | #define ETP_FW_NAME "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin" |
Duson Lin | 6696777 | 2014-10-03 13:24:27 -0700 | [diff] [blame] | 33 | #define ETP_IAP_START_ADDR 0x0083 |
| 34 | #define ETP_FW_IAP_PAGE_ERR (1 << 5) |
| 35 | #define ETP_FW_IAP_INTF_ERR (1 << 4) |
| 36 | #define ETP_FW_PAGE_SIZE 64 |
Duson Lin | bb03bf3 | 2015-01-23 09:35:07 -0800 | [diff] [blame] | 37 | #define ETP_FW_SIGNATURE_SIZE 6 |
Duson Lin | 6696777 | 2014-10-03 13:24:27 -0700 | [diff] [blame] | 38 | |
| 39 | struct i2c_client; |
| 40 | struct completion; |
| 41 | |
| 42 | enum tp_mode { |
| 43 | IAP_MODE = 1, |
| 44 | MAIN_MODE |
| 45 | }; |
| 46 | |
| 47 | struct elan_transport_ops { |
| 48 | int (*initialize)(struct i2c_client *client); |
| 49 | int (*sleep_control)(struct i2c_client *, bool sleep); |
| 50 | int (*power_control)(struct i2c_client *, bool enable); |
| 51 | int (*set_mode)(struct i2c_client *client, u8 mode); |
| 52 | |
| 53 | int (*calibrate)(struct i2c_client *client); |
| 54 | int (*calibrate_result)(struct i2c_client *client, u8 *val); |
| 55 | |
| 56 | int (*get_baseline_data)(struct i2c_client *client, |
| 57 | bool max_baseliune, u8 *value); |
| 58 | |
| 59 | int (*get_version)(struct i2c_client *client, bool iap, u8 *version); |
Duson Lin | 12018ac | 2015-06-08 16:39:35 -0700 | [diff] [blame] | 60 | int (*get_sm_version)(struct i2c_client *client, |
| 61 | u8* ic_type, u8 *version); |
Duson Lin | 6696777 | 2014-10-03 13:24:27 -0700 | [diff] [blame] | 62 | int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum); |
Duson Lin | ed75a14 | 2015-09-21 09:26:46 -0700 | [diff] [blame] | 63 | int (*get_product_id)(struct i2c_client *client, u16 *id); |
Duson Lin | 6696777 | 2014-10-03 13:24:27 -0700 | [diff] [blame] | 64 | |
| 65 | int (*get_max)(struct i2c_client *client, |
| 66 | unsigned int *max_x, unsigned int *max_y); |
| 67 | int (*get_resolution)(struct i2c_client *client, |
| 68 | u8 *hw_res_x, u8 *hw_res_y); |
| 69 | int (*get_num_traces)(struct i2c_client *client, |
| 70 | unsigned int *x_tracenum, |
| 71 | unsigned int *y_tracenum); |
| 72 | |
| 73 | int (*iap_get_mode)(struct i2c_client *client, enum tp_mode *mode); |
| 74 | int (*iap_reset)(struct i2c_client *client); |
| 75 | |
| 76 | int (*prepare_fw_update)(struct i2c_client *client); |
| 77 | int (*write_fw_block)(struct i2c_client *client, |
| 78 | const u8 *page, u16 checksum, int idx); |
| 79 | int (*finish_fw_update)(struct i2c_client *client, |
| 80 | struct completion *reset_done); |
| 81 | |
| 82 | int (*get_report)(struct i2c_client *client, u8 *report); |
duson | b9bced0 | 2015-04-12 16:01:05 -0700 | [diff] [blame] | 83 | int (*get_pressure_adjustment)(struct i2c_client *client, |
| 84 | int *adjustment); |
Duson Lin | 6696777 | 2014-10-03 13:24:27 -0700 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | extern const struct elan_transport_ops elan_smbus_ops, elan_i2c_ops; |
| 88 | |
| 89 | #endif /* _ELAN_I2C_H */ |