0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef __CYTTSP_CORE_H__
0018 #define __CYTTSP_CORE_H__
0019
0020 #include <linux/kernel.h>
0021 #include <linux/err.h>
0022 #include <linux/module.h>
0023 #include <linux/types.h>
0024 #include <linux/device.h>
0025 #include <linux/regulator/consumer.h>
0026
0027 #define CY_NUM_RETRY 16
0028
0029 struct cyttsp_tch {
0030 __be16 x, y;
0031 u8 z;
0032 } __packed;
0033
0034
0035 struct cyttsp_xydata {
0036 u8 hst_mode;
0037 u8 tt_mode;
0038 u8 tt_stat;
0039 struct cyttsp_tch tch1;
0040 u8 touch12_id;
0041 struct cyttsp_tch tch2;
0042 u8 gest_cnt;
0043 u8 gest_id;
0044 struct cyttsp_tch tch3;
0045 u8 touch34_id;
0046 struct cyttsp_tch tch4;
0047 u8 tt_undef[3];
0048 u8 act_dist;
0049 u8 tt_reserved;
0050 } __packed;
0051
0052
0053
0054 struct cyttsp_sysinfo_data {
0055 u8 hst_mode;
0056 u8 mfg_stat;
0057 u8 mfg_cmd;
0058 u8 cid[3];
0059 u8 tt_undef1;
0060 u8 uid[8];
0061 u8 bl_verh;
0062 u8 bl_verl;
0063 u8 tts_verh;
0064 u8 tts_verl;
0065 u8 app_idh;
0066 u8 app_idl;
0067 u8 app_verh;
0068 u8 app_verl;
0069 u8 tt_undef[5];
0070 u8 scn_typ;
0071 u8 act_intrvl;
0072 u8 tch_tmout;
0073 u8 lp_intrvl;
0074 };
0075
0076
0077 #define CY_BL_CHKSUM_OK 0x01
0078 struct cyttsp_bootloader_data {
0079 u8 bl_file;
0080 u8 bl_status;
0081 u8 bl_error;
0082 u8 blver_hi;
0083 u8 blver_lo;
0084 u8 bld_blver_hi;
0085 u8 bld_blver_lo;
0086 u8 ttspver_hi;
0087 u8 ttspver_lo;
0088 u8 appid_hi;
0089 u8 appid_lo;
0090 u8 appver_hi;
0091 u8 appver_lo;
0092 u8 cid_0;
0093 u8 cid_1;
0094 u8 cid_2;
0095 };
0096
0097 struct cyttsp;
0098
0099 struct cyttsp_bus_ops {
0100 u16 bustype;
0101 int (*write)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length,
0102 const void *values);
0103 int (*read)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length,
0104 void *values);
0105 };
0106
0107 enum cyttsp_state {
0108 CY_IDLE_STATE,
0109 CY_ACTIVE_STATE,
0110 CY_BL_STATE,
0111 };
0112
0113 struct cyttsp {
0114 struct device *dev;
0115 int irq;
0116 struct input_dev *input;
0117 const struct cyttsp_bus_ops *bus_ops;
0118 struct cyttsp_bootloader_data bl_data;
0119 struct cyttsp_sysinfo_data sysinfo_data;
0120 struct cyttsp_xydata xy_data;
0121 struct completion bl_ready;
0122 enum cyttsp_state state;
0123 bool suspended;
0124
0125 struct regulator_bulk_data regulators[2];
0126 struct gpio_desc *reset_gpio;
0127 bool use_hndshk;
0128 u8 act_dist;
0129 u8 act_intrvl;
0130 u8 tch_tmout;
0131 u8 lp_intrvl;
0132 u8 *bl_keys;
0133
0134 u8 xfer_buf[] ____cacheline_aligned;
0135 };
0136
0137 struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
0138 struct device *dev, int irq, size_t xfer_buf_size);
0139
0140 int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u16 addr,
0141 u8 length, const void *values);
0142 int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u16 addr,
0143 u8 length, void *values);
0144 extern const struct dev_pm_ops cyttsp_pm_ops;
0145
0146 #endif