14065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas/* 24065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * Header file for: 34065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * Cypress TrueTouch(TM) Standard Product (TTSP) touchscreen drivers. 44065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * For use with Cypress Txx3xx parts. 54065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * Supported parts include: 64065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * CY8CTST341 74065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * CY8CTMA340 84065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * 94065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * Copyright (C) 2009, 2010, 2011 Cypress Semiconductor, Inc. 104065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * Copyright (C) 2012 Javier Martinez Canillas <javier@dowhile0.org> 114065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * 124065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * This program is free software; you can redistribute it and/or 134065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * modify it under the terms of the GNU General Public License 144065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * version 2, and only version 2, as published by the 154065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * Free Software Foundation. 164065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * 174065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * This program is distributed in the hope that it will be useful, 184065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * but WITHOUT ANY WARRANTY; without even the implied warranty of 194065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 204065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * GNU General Public License for more details. 214065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * 224065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * You should have received a copy of the GNU General Public License along 234065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * with this program; if not, write to the Free Software Foundation, Inc., 244065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 254065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * 264065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * Contact Cypress Semiconductor at www.cypress.com <kev@cypress.com> 274065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas * 284065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas */ 294065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 304065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 314065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas#ifndef __CYTTSP_CORE_H__ 324065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas#define __CYTTSP_CORE_H__ 334065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 344065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas#include <linux/kernel.h> 354065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas#include <linux/err.h> 364065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas#include <linux/module.h> 374065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas#include <linux/types.h> 384065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas#include <linux/device.h> 394065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas#include <linux/input/cyttsp.h> 404065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 414065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas#define CY_NUM_RETRY 16 /* max number of retries for read ops */ 424065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 434065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillasstruct cyttsp_tch { 444065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas __be16 x, y; 454065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 z; 464065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas} __packed; 474065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 484065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas/* TrueTouch Standard Product Gen3 interface definition */ 494065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillasstruct cyttsp_xydata { 504065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 hst_mode; 514065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 tt_mode; 524065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 tt_stat; 534065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas struct cyttsp_tch tch1; 544065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 touch12_id; 554065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas struct cyttsp_tch tch2; 564065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 gest_cnt; 574065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 gest_id; 584065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas struct cyttsp_tch tch3; 594065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 touch34_id; 604065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas struct cyttsp_tch tch4; 614065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 tt_undef[3]; 624065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 act_dist; 634065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 tt_reserved; 644065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas} __packed; 654065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 664065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 674065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas/* TTSP System Information interface definition */ 684065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillasstruct cyttsp_sysinfo_data { 694065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 hst_mode; 704065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 mfg_stat; 71d3bf073aa7d50f06f81b4065a39fd6dc046f8bb2Matthias Kaehlcke u8 mfg_cmd; 724065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 cid[3]; 734065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 tt_undef1; 744065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 uid[8]; 754065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 bl_verh; 764065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 bl_verl; 774065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 tts_verh; 784065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 tts_verl; 794065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 app_idh; 804065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 app_idl; 814065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 app_verh; 824065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 app_verl; 834065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 tt_undef[5]; 844065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 scn_typ; 854065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 act_intrvl; 864065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 tch_tmout; 874065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 lp_intrvl; 884065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas}; 894065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 904065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas/* TTSP Bootloader Register Map interface definition */ 914065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas#define CY_BL_CHKSUM_OK 0x01 924065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillasstruct cyttsp_bootloader_data { 934065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 bl_file; 944065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 bl_status; 954065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 bl_error; 964065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 blver_hi; 974065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 blver_lo; 984065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 bld_blver_hi; 994065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 bld_blver_lo; 1004065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 ttspver_hi; 1014065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 ttspver_lo; 1024065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 appid_hi; 1034065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 appid_lo; 1044065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 appver_hi; 1054065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 appver_lo; 1064065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 cid_0; 1074065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 cid_1; 1084065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 cid_2; 1094065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas}; 1104065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 1114065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillasstruct cyttsp; 1124065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 1134065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillasstruct cyttsp_bus_ops { 1144065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u16 bustype; 11562f548d0c2d2418e39b8e4b7ec39b5ca2ef4380dFerruh Yigit int (*write)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, 1169664877ed8956b81feb3bd6b3b2621b5fcdb624fFerruh Yigit const void *values); 11762f548d0c2d2418e39b8e4b7ec39b5ca2ef4380dFerruh Yigit int (*read)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, 1189664877ed8956b81feb3bd6b3b2621b5fcdb624fFerruh Yigit void *values); 1194065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas}; 1204065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 1214065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillasenum cyttsp_state { 1224065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas CY_IDLE_STATE, 1234065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas CY_ACTIVE_STATE, 1244065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas CY_BL_STATE, 1254065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas}; 1264065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 1274065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillasstruct cyttsp { 1284065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas struct device *dev; 1294065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas int irq; 1304065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas struct input_dev *input; 1314065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas char phys[32]; 1324065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas const struct cyttsp_platform_data *pdata; 1334065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas const struct cyttsp_bus_ops *bus_ops; 1344065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas struct cyttsp_bootloader_data bl_data; 1354065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas struct cyttsp_sysinfo_data sysinfo_data; 1364065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas struct cyttsp_xydata xy_data; 1374065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas struct completion bl_ready; 1384065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas enum cyttsp_state state; 1394065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas bool suspended; 1404065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 1414065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas u8 xfer_buf[] ____cacheline_aligned; 1424065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas}; 1434065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 1444065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillasstruct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, 1454065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas struct device *dev, int irq, size_t xfer_buf_size); 1464065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillasvoid cyttsp_remove(struct cyttsp *ts); 1474065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 14862f548d0c2d2418e39b8e4b7ec39b5ca2ef4380dFerruh Yigitint cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u16 addr, 1499664877ed8956b81feb3bd6b3b2621b5fcdb624fFerruh Yigit u8 length, const void *values); 15062f548d0c2d2418e39b8e4b7ec39b5ca2ef4380dFerruh Yigitint cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u16 addr, 1519664877ed8956b81feb3bd6b3b2621b5fcdb624fFerruh Yigit u8 length, void *values); 1524065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillasextern const struct dev_pm_ops cyttsp_pm_ops; 1534065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas 1544065d1e7b2164cff4af57b58fac887df2fe75d2aJavier Martinez Canillas#endif /* __CYTTSP_CORE_H__ */ 155