linux/drivers/input/touchscreen/cyttsp_core.h
<<
>>
Prefs
   1/*
   2 * Header file for:
   3 * Cypress TrueTouch(TM) Standard Product (TTSP) touchscreen drivers.
   4 * For use with Cypress Txx3xx parts.
   5 * Supported parts include:
   6 * CY8CTST341
   7 * CY8CTMA340
   8 *
   9 * Copyright (C) 2009, 2010, 2011 Cypress Semiconductor, Inc.
  10 * Copyright (C) 2012 Javier Martinez Canillas <javier@dowhile0.org>
  11 *
  12 * This program is free software; you can redistribute it and/or
  13 * modify it under the terms of the GNU General Public License
  14 * version 2, and only version 2, as published by the
  15 * Free Software Foundation.
  16 *
  17 * This program is distributed in the hope that it will be useful,
  18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20 * GNU General Public License for more details.
  21 *
  22 * You should have received a copy of the GNU General Public License along
  23 * with this program; if not, write to the Free Software Foundation, Inc.,
  24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  25 *
  26 * Contact Cypress Semiconductor at www.cypress.com <kev@cypress.com>
  27 *
  28 */
  29
  30
  31#ifndef __CYTTSP_CORE_H__
  32#define __CYTTSP_CORE_H__
  33
  34#include <linux/kernel.h>
  35#include <linux/err.h>
  36#include <linux/module.h>
  37#include <linux/types.h>
  38#include <linux/device.h>
  39#include <linux/input/cyttsp.h>
  40
  41#define CY_NUM_RETRY            16 /* max number of retries for read ops */
  42
  43struct cyttsp_tch {
  44        __be16 x, y;
  45        u8 z;
  46} __packed;
  47
  48/* TrueTouch Standard Product Gen3 interface definition */
  49struct cyttsp_xydata {
  50        u8 hst_mode;
  51        u8 tt_mode;
  52        u8 tt_stat;
  53        struct cyttsp_tch tch1;
  54        u8 touch12_id;
  55        struct cyttsp_tch tch2;
  56        u8 gest_cnt;
  57        u8 gest_id;
  58        struct cyttsp_tch tch3;
  59        u8 touch34_id;
  60        struct cyttsp_tch tch4;
  61        u8 tt_undef[3];
  62        u8 act_dist;
  63        u8 tt_reserved;
  64} __packed;
  65
  66
  67/* TTSP System Information interface definition */
  68struct cyttsp_sysinfo_data {
  69        u8 hst_mode;
  70        u8 mfg_stat;
  71        u8 mfg_cmd;
  72        u8 cid[3];
  73        u8 tt_undef1;
  74        u8 uid[8];
  75        u8 bl_verh;
  76        u8 bl_verl;
  77        u8 tts_verh;
  78        u8 tts_verl;
  79        u8 app_idh;
  80        u8 app_idl;
  81        u8 app_verh;
  82        u8 app_verl;
  83        u8 tt_undef[5];
  84        u8 scn_typ;
  85        u8 act_intrvl;
  86        u8 tch_tmout;
  87        u8 lp_intrvl;
  88};
  89
  90/* TTSP Bootloader Register Map interface definition */
  91#define CY_BL_CHKSUM_OK 0x01
  92struct cyttsp_bootloader_data {
  93        u8 bl_file;
  94        u8 bl_status;
  95        u8 bl_error;
  96        u8 blver_hi;
  97        u8 blver_lo;
  98        u8 bld_blver_hi;
  99        u8 bld_blver_lo;
 100        u8 ttspver_hi;
 101        u8 ttspver_lo;
 102        u8 appid_hi;
 103        u8 appid_lo;
 104        u8 appver_hi;
 105        u8 appver_lo;
 106        u8 cid_0;
 107        u8 cid_1;
 108        u8 cid_2;
 109};
 110
 111struct cyttsp;
 112
 113struct cyttsp_bus_ops {
 114        u16 bustype;
 115        int (*write)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length,
 116                        const void *values);
 117        int (*read)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length,
 118                        void *values);
 119};
 120
 121enum cyttsp_state {
 122        CY_IDLE_STATE,
 123        CY_ACTIVE_STATE,
 124        CY_BL_STATE,
 125};
 126
 127struct cyttsp {
 128        struct device *dev;
 129        int irq;
 130        struct input_dev *input;
 131        char phys[32];
 132        const struct cyttsp_platform_data *pdata;
 133        const struct cyttsp_bus_ops *bus_ops;
 134        struct cyttsp_bootloader_data bl_data;
 135        struct cyttsp_sysinfo_data sysinfo_data;
 136        struct cyttsp_xydata xy_data;
 137        struct completion bl_ready;
 138        enum cyttsp_state state;
 139        bool suspended;
 140
 141        u8 xfer_buf[] ____cacheline_aligned;
 142};
 143
 144struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
 145                            struct device *dev, int irq, size_t xfer_buf_size);
 146void cyttsp_remove(struct cyttsp *ts);
 147
 148int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u16 addr,
 149                u8 length, const void *values);
 150int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u16 addr,
 151                u8 length, void *values);
 152extern const struct dev_pm_ops cyttsp_pm_ops;
 153
 154#endif /* __CYTTSP_CORE_H__ */
 155