linux/drivers/input/touchscreen/hynitron_cstxxx.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  Driver for Hynitron cstxxx Touchscreen
 *
 *  Copyright (c) 2022 Chris Morgan <[email protected]>
 *
 *  This code is based on hynitron_core.c authored by Hynitron.
 *  Note that no datasheet was available, so much of these registers
 *  are undocumented. This is essentially a cleaned-up version of the
 *  vendor driver with support removed for hardware I cannot test and
 *  device-specific functions replated with generic functions wherever
 *  possible.
 */

#include <linux/delay.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/input/mt.h>
#include <linux/input/touchscreen.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/property.h>
#include <linux/unaligned.h>

/* Per chip data */
struct hynitron_ts_chip_data {};

/* Data generic to all (supported and non-supported) controllers. */
struct hynitron_ts_data {};

/*
 * Since I have no datasheet, these values are guessed and/or assumed
 * based on observation and testing.
 */
#define CST3XX_FIRMWARE_INFO_START_CMD
#define CST3XX_FIRMWARE_INFO_END_CMD
#define CST3XX_FIRMWARE_CHK_CODE_REG
#define CST3XX_FIRMWARE_VERSION_REG
#define CST3XX_FIRMWARE_VER_INVALID_VAL

#define CST3XX_BOOTLDR_PROG_CMD
#define CST3XX_BOOTLDR_PROG_CHK_REG
#define CST3XX_BOOTLDR_CHK_VAL

#define CST3XX_TOUCH_DATA_PART_REG
#define CST3XX_TOUCH_DATA_FULL_REG
#define CST3XX_TOUCH_DATA_CHK_VAL
#define CST3XX_TOUCH_DATA_TOUCH_VAL
#define CST3XX_TOUCH_DATA_STOP_CMD
#define CST3XX_TOUCH_COUNT_MASK


/*
 * Hard coded reset delay value of 20ms not IC dependent in
 * vendor driver.
 */
static void hyn_reset_proc(struct i2c_client *client, int delay)
{}

static irqreturn_t hyn_interrupt_handler(int irq, void *dev_id)
{}

/*
 * The vendor driver would retry twice before failing to read or write
 * to the i2c device.
 */

static int cst3xx_i2c_write(struct i2c_client *client,
			    unsigned char *buf, int len)
{}

static int cst3xx_i2c_read_register(struct i2c_client *client, u16 reg,
				    u8 *val, u16 len)
{}

static int cst3xx_firmware_info(struct i2c_client *client)
{}

static int cst3xx_bootloader_enter(struct i2c_client *client)
{}

static void cst3xx_report_contact(struct hynitron_ts_data *ts_data,
				  u8 id, unsigned int x, unsigned int y, u8 w)
{}

static int cst3xx_finish_touch_read(struct i2c_client *client)
{}

/*
 * Handle events from IRQ. Note that for cst3xx it appears that IRQ
 * fires continuously while touched, otherwise once every 1500ms
 * when not touched (assume touchscreen waking up periodically).
 * Note buffer is sized for 5 fingers, if more needed buffer must
 * be increased. The buffer contains 5 bytes for each touch point,
 * a touch count byte, a check byte, and then a second check byte after
 * all other touch points.
 *
 * For example 1 touch would look like this:
 * touch1[5]:touch_count[1]:chk_byte[1]
 *
 * 3 touches would look like this:
 * touch1[5]:touch_count[1]:chk_byte[1]:touch2[5]:touch3[5]:chk_byte[1]
 */
static void cst3xx_touch_report(struct i2c_client *client)
{}

static int cst3xx_input_dev_int(struct i2c_client *client)
{}

static int hyn_probe(struct i2c_client *client)
{}

static const struct hynitron_ts_chip_data cst3xx_data =;

static const struct i2c_device_id hyn_tpd_id[] =;
MODULE_DEVICE_TABLE(i2c, hyn_tpd_id);

static const struct of_device_id hyn_dt_match[] =;
MODULE_DEVICE_TABLE(of, hyn_dt_match);

static struct i2c_driver hynitron_i2c_driver =;

module_i2c_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();