blob: 83dd0ce3ad2a57683fea27842e67d6b3ebe19ca2 [file] [log] [blame]
Duson Lin66967772014-10-03 13:24:27 -07001/*
2 * Elan I2C/SMBus Touchpad driver
3 *
4 * Copyright (c) 2013 ELAN Microelectronics Corp.
5 *
6 * Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw>
Duson Lin66967772014-10-03 13:24:27 -07007 *
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 Iooss61c797d2015-03-19 09:13:34 -070020#define _ELAN_I2C_H
Duson Lin66967772014-10-03 13:24:27 -070021
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
dusonb9bced02015-04-12 16:01:05 -070028#define ETP_PRESSURE_OFFSET 25
Duson Lin66967772014-10-03 13:24:27 -070029
Ben Hutchings54ae5642018-06-19 11:17:32 -070030#define ETP_CALIBRATE_MAX_LEN 3
31
Duson Lin66967772014-10-03 13:24:27 -070032/* IAP Firmware handling */
Charlie Mooney7b9f1832015-06-08 16:48:23 -070033#define ETP_PRODUCT_ID_FORMAT_STRING "%d.0"
34#define ETP_FW_NAME "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin"
Duson Lin66967772014-10-03 13:24:27 -070035#define ETP_IAP_START_ADDR 0x0083
36#define ETP_FW_IAP_PAGE_ERR (1 << 5)
37#define ETP_FW_IAP_INTF_ERR (1 << 4)
38#define ETP_FW_PAGE_SIZE 64
Duson Linbb03bf32015-01-23 09:35:07 -080039#define ETP_FW_SIGNATURE_SIZE 6
Duson Lin66967772014-10-03 13:24:27 -070040
41struct i2c_client;
42struct completion;
43
44enum tp_mode {
45 IAP_MODE = 1,
46 MAIN_MODE
47};
48
49struct elan_transport_ops {
50 int (*initialize)(struct i2c_client *client);
51 int (*sleep_control)(struct i2c_client *, bool sleep);
52 int (*power_control)(struct i2c_client *, bool enable);
53 int (*set_mode)(struct i2c_client *client, u8 mode);
54
55 int (*calibrate)(struct i2c_client *client);
56 int (*calibrate_result)(struct i2c_client *client, u8 *val);
57
58 int (*get_baseline_data)(struct i2c_client *client,
59 bool max_baseliune, u8 *value);
60
61 int (*get_version)(struct i2c_client *client, bool iap, u8 *version);
Duson Lin12018ac2015-06-08 16:39:35 -070062 int (*get_sm_version)(struct i2c_client *client,
63 u8* ic_type, u8 *version);
Duson Lin66967772014-10-03 13:24:27 -070064 int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum);
Duson Lined75a142015-09-21 09:26:46 -070065 int (*get_product_id)(struct i2c_client *client, u16 *id);
Duson Lin66967772014-10-03 13:24:27 -070066
67 int (*get_max)(struct i2c_client *client,
68 unsigned int *max_x, unsigned int *max_y);
69 int (*get_resolution)(struct i2c_client *client,
70 u8 *hw_res_x, u8 *hw_res_y);
71 int (*get_num_traces)(struct i2c_client *client,
72 unsigned int *x_tracenum,
73 unsigned int *y_tracenum);
74
75 int (*iap_get_mode)(struct i2c_client *client, enum tp_mode *mode);
76 int (*iap_reset)(struct i2c_client *client);
77
78 int (*prepare_fw_update)(struct i2c_client *client);
79 int (*write_fw_block)(struct i2c_client *client,
80 const u8 *page, u16 checksum, int idx);
81 int (*finish_fw_update)(struct i2c_client *client,
82 struct completion *reset_done);
83
84 int (*get_report)(struct i2c_client *client, u8 *report);
dusonb9bced02015-04-12 16:01:05 -070085 int (*get_pressure_adjustment)(struct i2c_client *client,
86 int *adjustment);
Duson Lin66967772014-10-03 13:24:27 -070087};
88
89extern const struct elan_transport_ops elan_smbus_ops, elan_i2c_ops;
90
91#endif /* _ELAN_I2C_H */