108dbd0f8SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 24065d1e7SJavier Martinez Canillas /* 34065d1e7SJavier Martinez Canillas * Header file for: 44065d1e7SJavier Martinez Canillas * Cypress TrueTouch(TM) Standard Product (TTSP) touchscreen drivers. 54065d1e7SJavier Martinez Canillas * For use with Cypress Txx3xx parts. 64065d1e7SJavier Martinez Canillas * Supported parts include: 74065d1e7SJavier Martinez Canillas * CY8CTST341 84065d1e7SJavier Martinez Canillas * CY8CTMA340 94065d1e7SJavier Martinez Canillas * 104065d1e7SJavier Martinez Canillas * Copyright (C) 2009, 2010, 2011 Cypress Semiconductor, Inc. 114065d1e7SJavier Martinez Canillas * Copyright (C) 2012 Javier Martinez Canillas <javier@dowhile0.org> 124065d1e7SJavier Martinez Canillas * 134065d1e7SJavier Martinez Canillas * Contact Cypress Semiconductor at www.cypress.com <kev@cypress.com> 144065d1e7SJavier Martinez Canillas */ 154065d1e7SJavier Martinez Canillas 164065d1e7SJavier Martinez Canillas 174065d1e7SJavier Martinez Canillas #ifndef __CYTTSP_CORE_H__ 184065d1e7SJavier Martinez Canillas #define __CYTTSP_CORE_H__ 194065d1e7SJavier Martinez Canillas 204065d1e7SJavier Martinez Canillas #include <linux/kernel.h> 214065d1e7SJavier Martinez Canillas #include <linux/err.h> 224065d1e7SJavier Martinez Canillas #include <linux/module.h> 234065d1e7SJavier Martinez Canillas #include <linux/types.h> 244065d1e7SJavier Martinez Canillas #include <linux/device.h> 25*6cf3b3abSLinus Walleij #include <linux/regulator/consumer.h> 264065d1e7SJavier Martinez Canillas 274065d1e7SJavier Martinez Canillas #define CY_NUM_RETRY 16 /* max number of retries for read ops */ 284065d1e7SJavier Martinez Canillas 294065d1e7SJavier Martinez Canillas struct cyttsp_tch { 304065d1e7SJavier Martinez Canillas __be16 x, y; 314065d1e7SJavier Martinez Canillas u8 z; 324065d1e7SJavier Martinez Canillas } __packed; 334065d1e7SJavier Martinez Canillas 344065d1e7SJavier Martinez Canillas /* TrueTouch Standard Product Gen3 interface definition */ 354065d1e7SJavier Martinez Canillas struct cyttsp_xydata { 364065d1e7SJavier Martinez Canillas u8 hst_mode; 374065d1e7SJavier Martinez Canillas u8 tt_mode; 384065d1e7SJavier Martinez Canillas u8 tt_stat; 394065d1e7SJavier Martinez Canillas struct cyttsp_tch tch1; 404065d1e7SJavier Martinez Canillas u8 touch12_id; 414065d1e7SJavier Martinez Canillas struct cyttsp_tch tch2; 424065d1e7SJavier Martinez Canillas u8 gest_cnt; 434065d1e7SJavier Martinez Canillas u8 gest_id; 444065d1e7SJavier Martinez Canillas struct cyttsp_tch tch3; 454065d1e7SJavier Martinez Canillas u8 touch34_id; 464065d1e7SJavier Martinez Canillas struct cyttsp_tch tch4; 474065d1e7SJavier Martinez Canillas u8 tt_undef[3]; 484065d1e7SJavier Martinez Canillas u8 act_dist; 494065d1e7SJavier Martinez Canillas u8 tt_reserved; 504065d1e7SJavier Martinez Canillas } __packed; 514065d1e7SJavier Martinez Canillas 524065d1e7SJavier Martinez Canillas 534065d1e7SJavier Martinez Canillas /* TTSP System Information interface definition */ 544065d1e7SJavier Martinez Canillas struct cyttsp_sysinfo_data { 554065d1e7SJavier Martinez Canillas u8 hst_mode; 564065d1e7SJavier Martinez Canillas u8 mfg_stat; 57d3bf073aSMatthias Kaehlcke u8 mfg_cmd; 584065d1e7SJavier Martinez Canillas u8 cid[3]; 594065d1e7SJavier Martinez Canillas u8 tt_undef1; 604065d1e7SJavier Martinez Canillas u8 uid[8]; 614065d1e7SJavier Martinez Canillas u8 bl_verh; 624065d1e7SJavier Martinez Canillas u8 bl_verl; 634065d1e7SJavier Martinez Canillas u8 tts_verh; 644065d1e7SJavier Martinez Canillas u8 tts_verl; 654065d1e7SJavier Martinez Canillas u8 app_idh; 664065d1e7SJavier Martinez Canillas u8 app_idl; 674065d1e7SJavier Martinez Canillas u8 app_verh; 684065d1e7SJavier Martinez Canillas u8 app_verl; 694065d1e7SJavier Martinez Canillas u8 tt_undef[5]; 704065d1e7SJavier Martinez Canillas u8 scn_typ; 714065d1e7SJavier Martinez Canillas u8 act_intrvl; 724065d1e7SJavier Martinez Canillas u8 tch_tmout; 734065d1e7SJavier Martinez Canillas u8 lp_intrvl; 744065d1e7SJavier Martinez Canillas }; 754065d1e7SJavier Martinez Canillas 764065d1e7SJavier Martinez Canillas /* TTSP Bootloader Register Map interface definition */ 774065d1e7SJavier Martinez Canillas #define CY_BL_CHKSUM_OK 0x01 784065d1e7SJavier Martinez Canillas struct cyttsp_bootloader_data { 794065d1e7SJavier Martinez Canillas u8 bl_file; 804065d1e7SJavier Martinez Canillas u8 bl_status; 814065d1e7SJavier Martinez Canillas u8 bl_error; 824065d1e7SJavier Martinez Canillas u8 blver_hi; 834065d1e7SJavier Martinez Canillas u8 blver_lo; 844065d1e7SJavier Martinez Canillas u8 bld_blver_hi; 854065d1e7SJavier Martinez Canillas u8 bld_blver_lo; 864065d1e7SJavier Martinez Canillas u8 ttspver_hi; 874065d1e7SJavier Martinez Canillas u8 ttspver_lo; 884065d1e7SJavier Martinez Canillas u8 appid_hi; 894065d1e7SJavier Martinez Canillas u8 appid_lo; 904065d1e7SJavier Martinez Canillas u8 appver_hi; 914065d1e7SJavier Martinez Canillas u8 appver_lo; 924065d1e7SJavier Martinez Canillas u8 cid_0; 934065d1e7SJavier Martinez Canillas u8 cid_1; 944065d1e7SJavier Martinez Canillas u8 cid_2; 954065d1e7SJavier Martinez Canillas }; 964065d1e7SJavier Martinez Canillas 974065d1e7SJavier Martinez Canillas struct cyttsp; 984065d1e7SJavier Martinez Canillas 994065d1e7SJavier Martinez Canillas struct cyttsp_bus_ops { 1004065d1e7SJavier Martinez Canillas u16 bustype; 10162f548d0SFerruh Yigit int (*write)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, 1029664877eSFerruh Yigit const void *values); 10362f548d0SFerruh Yigit int (*read)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, 1049664877eSFerruh Yigit void *values); 1054065d1e7SJavier Martinez Canillas }; 1064065d1e7SJavier Martinez Canillas 1074065d1e7SJavier Martinez Canillas enum cyttsp_state { 1084065d1e7SJavier Martinez Canillas CY_IDLE_STATE, 1094065d1e7SJavier Martinez Canillas CY_ACTIVE_STATE, 1104065d1e7SJavier Martinez Canillas CY_BL_STATE, 1114065d1e7SJavier Martinez Canillas }; 1124065d1e7SJavier Martinez Canillas 1134065d1e7SJavier Martinez Canillas struct cyttsp { 1144065d1e7SJavier Martinez Canillas struct device *dev; 1154065d1e7SJavier Martinez Canillas int irq; 1164065d1e7SJavier Martinez Canillas struct input_dev *input; 1174065d1e7SJavier Martinez Canillas const struct cyttsp_bus_ops *bus_ops; 1184065d1e7SJavier Martinez Canillas struct cyttsp_bootloader_data bl_data; 1194065d1e7SJavier Martinez Canillas struct cyttsp_sysinfo_data sysinfo_data; 1204065d1e7SJavier Martinez Canillas struct cyttsp_xydata xy_data; 1214065d1e7SJavier Martinez Canillas struct completion bl_ready; 1224065d1e7SJavier Martinez Canillas enum cyttsp_state state; 1234065d1e7SJavier Martinez Canillas bool suspended; 1244065d1e7SJavier Martinez Canillas 125707b61bbSOreste Salerno struct gpio_desc *reset_gpio; 126707b61bbSOreste Salerno bool use_hndshk; 127707b61bbSOreste Salerno u8 act_dist; 128707b61bbSOreste Salerno u8 act_intrvl; 129707b61bbSOreste Salerno u8 tch_tmout; 130707b61bbSOreste Salerno u8 lp_intrvl; 131707b61bbSOreste Salerno u8 *bl_keys; 132707b61bbSOreste Salerno 1334065d1e7SJavier Martinez Canillas u8 xfer_buf[] ____cacheline_aligned; 1344065d1e7SJavier Martinez Canillas }; 1354065d1e7SJavier Martinez Canillas 1364065d1e7SJavier Martinez Canillas struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, 1374065d1e7SJavier Martinez Canillas struct device *dev, int irq, size_t xfer_buf_size); 1384065d1e7SJavier Martinez Canillas 1394065d1e7SJavier Martinez Canillas extern const struct dev_pm_ops cyttsp_pm_ops; 1404065d1e7SJavier Martinez Canillas 1414065d1e7SJavier Martinez Canillas #endif /* __CYTTSP_CORE_H__ */ 142