linux/drivers/input/touchscreen/melfas_mip4.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * MELFAS MIP4 Touchscreen
 *
 * Copyright (C) 2016 MELFAS Inc.
 *
 * Author : Sangwon Jee <[email protected]>
 */

#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/firmware.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/input/mt.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/slab.h>
#include <asm/unaligned.h>

#define MIP4_DEVICE_NAME

/*****************************************************************
 * Protocol
 * Version : MIP 4.0 Rev 5.4
 *****************************************************************/

/* Address */
#define MIP4_R0_BOOT
#define MIP4_R1_BOOT_MODE
#define MIP4_R1_BOOT_BUF_ADDR
#define MIP4_R1_BOOT_STATUS
#define MIP4_R1_BOOT_CMD
#define MIP4_R1_BOOT_TARGET_ADDR
#define MIP4_R1_BOOT_SIZE

#define MIP4_R0_INFO
#define MIP4_R1_INFO_PRODUCT_NAME
#define MIP4_R1_INFO_RESOLUTION_X
#define MIP4_R1_INFO_RESOLUTION_Y
#define MIP4_R1_INFO_NODE_NUM_X
#define MIP4_R1_INFO_NODE_NUM_Y
#define MIP4_R1_INFO_KEY_NUM
#define MIP4_R1_INFO_PRESSURE_NUM
#define MIP4_R1_INFO_LENGTH_X
#define MIP4_R1_INFO_LENGTH_Y
#define MIP4_R1_INFO_PPM_X
#define MIP4_R1_INFO_PPM_Y
#define MIP4_R1_INFO_VERSION_BOOT
#define MIP4_R1_INFO_VERSION_CORE
#define MIP4_R1_INFO_VERSION_APP
#define MIP4_R1_INFO_VERSION_PARAM
#define MIP4_R1_INFO_SECT_BOOT_START
#define MIP4_R1_INFO_SECT_BOOT_END
#define MIP4_R1_INFO_SECT_CORE_START
#define MIP4_R1_INFO_SECT_CORE_END
#define MIP4_R1_INFO_SECT_APP_START
#define MIP4_R1_INFO_SECT_APP_END
#define MIP4_R1_INFO_SECT_PARAM_START
#define MIP4_R1_INFO_SECT_PARAM_END
#define MIP4_R1_INFO_BUILD_DATE
#define MIP4_R1_INFO_BUILD_TIME
#define MIP4_R1_INFO_CHECKSUM_PRECALC
#define MIP4_R1_INFO_CHECKSUM_REALTIME
#define MIP4_R1_INFO_PROTOCOL_NAME
#define MIP4_R1_INFO_PROTOCOL_VERSION
#define MIP4_R1_INFO_IC_ID
#define MIP4_R1_INFO_IC_NAME
#define MIP4_R1_INFO_IC_VENDOR_ID
#define MIP4_R1_INFO_IC_HW_CATEGORY
#define MIP4_R1_INFO_CONTACT_THD_SCR
#define MIP4_R1_INFO_CONTACT_THD_KEY
#define MIP4_R1_INFO_PID
#define MIP4_R1_INFO_VID
#define MIP4_R1_INFO_SLAVE_ADDR

#define MIP4_R0_EVENT
#define MIP4_R1_EVENT_SUPPORTED_FUNC
#define MIP4_R1_EVENT_FORMAT
#define MIP4_R1_EVENT_SIZE
#define MIP4_R1_EVENT_PACKET_INFO
#define MIP4_R1_EVENT_PACKET_DATA

#define MIP4_R0_CTRL
#define MIP4_R1_CTRL_READY_STATUS
#define MIP4_R1_CTRL_EVENT_READY
#define MIP4_R1_CTRL_MODE
#define MIP4_R1_CTRL_EVENT_TRIGGER_TYPE
#define MIP4_R1_CTRL_RECALIBRATE
#define MIP4_R1_CTRL_POWER_STATE
#define MIP4_R1_CTRL_GESTURE_TYPE
#define MIP4_R1_CTRL_DISABLE_ESD_ALERT
#define MIP4_R1_CTRL_CHARGER_MODE
#define MIP4_R1_CTRL_HIGH_SENS_MODE
#define MIP4_R1_CTRL_WINDOW_MODE
#define MIP4_R1_CTRL_PALM_REJECTION
#define MIP4_R1_CTRL_EDGE_CORRECTION
#define MIP4_R1_CTRL_ENTER_GLOVE_MODE
#define MIP4_R1_CTRL_I2C_ON_LPM
#define MIP4_R1_CTRL_GESTURE_DEBUG
#define MIP4_R1_CTRL_PALM_EVENT
#define MIP4_R1_CTRL_PROXIMITY_SENSING

/* Value */
#define MIP4_BOOT_MODE_BOOT
#define MIP4_BOOT_MODE_APP

#define MIP4_BOOT_STATUS_BUSY
#define MIP4_BOOT_STATUS_ERROR
#define MIP4_BOOT_STATUS_DONE

#define MIP4_BOOT_CMD_MASS_ERASE
#define MIP4_BOOT_CMD_PROGRAM
#define MIP4_BOOT_CMD_ERASE
#define MIP4_BOOT_CMD_WRITE
#define MIP4_BOOT_CMD_READ

#define MIP4_EVENT_INPUT_TYPE_KEY
#define MIP4_EVENT_INPUT_TYPE_SCREEN
#define MIP4_EVENT_INPUT_TYPE_PROXIMITY

#define I2C_RETRY_COUNT

#define MIP4_BUF_SIZE
#define MIP4_MAX_FINGERS
#define MIP4_MAX_KEYS

#define MIP4_TOUCH_MAJOR_MIN
#define MIP4_TOUCH_MAJOR_MAX
#define MIP4_TOUCH_MINOR_MIN
#define MIP4_TOUCH_MINOR_MAX
#define MIP4_PRESSURE_MIN
#define MIP4_PRESSURE_MAX

#define MIP4_FW_NAME
#define MIP4_FW_UPDATE_DEBUG

struct mip4_fw_version {};

struct mip4_ts {};

static int mip4_i2c_xfer(struct mip4_ts *ts,
			 char *write_buf, unsigned int write_len,
			 char *read_buf, unsigned int read_len)
{}

static void mip4_parse_fw_version(const u8 *buf, struct mip4_fw_version *v)
{}

/*
 * Read chip firmware version
 */
static int mip4_get_fw_version(struct mip4_ts *ts)
{}

/*
 * Fetch device characteristics
 */
static int mip4_query_device(struct mip4_ts *ts)
{}

static int mip4_power_on(struct mip4_ts *ts)
{}

static void mip4_power_off(struct mip4_ts *ts)
{}

/*
 * Clear touch input event status
 */
static void mip4_clear_input(struct mip4_ts *ts)
{}

static int mip4_enable(struct mip4_ts *ts)
{}

static void mip4_disable(struct mip4_ts *ts)
{}

/*****************************************************************
 * Input handling
 *****************************************************************/

static void mip4_report_keys(struct mip4_ts *ts, u8 *packet)
{}

static void mip4_report_touch(struct mip4_ts *ts, u8 *packet)
{}

static int mip4_handle_packet(struct mip4_ts *ts, u8 *packet)
{}

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

static int mip4_input_open(struct input_dev *dev)
{}

static void mip4_input_close(struct input_dev *dev)
{}

/*****************************************************************
 * Firmware update
 *****************************************************************/

/* Firmware Info */
#define MIP4_BL_PAGE_SIZE
#define MIP4_BL_PACKET_SIZE

/*
 * Firmware binary tail info
 */

struct mip4_bin_tail {} __packed;

#define MIP4_BIN_TAIL_MARK
#define MIP4_BIN_TAIL_SIZE

/*
* Bootloader - Read status
*/
static int mip4_bl_read_status(struct mip4_ts *ts)
{}

/*
* Bootloader - Change mode
*/
static int mip4_bl_change_mode(struct mip4_ts *ts, u8 mode)
{}

/*
 * Bootloader - Start bootloader mode
 */
static int mip4_bl_enter(struct mip4_ts *ts)
{}

/*
 * Bootloader - Exit bootloader mode
 */
static int mip4_bl_exit(struct mip4_ts *ts)
{}

static int mip4_bl_get_address(struct mip4_ts *ts, u16 *buf_addr)
{}

static int mip4_bl_program_page(struct mip4_ts *ts, int offset,
				const u8 *data, int length, u16 buf_addr)
{}

static int mip4_bl_verify_page(struct mip4_ts *ts, int offset,
			       const u8 *data, int length, int buf_addr)
{}

/*
 * Flash chip firmware
 */
static int mip4_flash_fw(struct mip4_ts *ts,
			 const u8 *fw_data, u32 fw_size, u32 fw_offset)
{}

static int mip4_parse_firmware(struct mip4_ts *ts, const struct firmware *fw,
			       u32 *fw_offset_start, u32 *fw_size,
			       const struct mip4_bin_tail **pfw_info)
{}

static int mip4_execute_fw_update(struct mip4_ts *ts, const struct firmware *fw)
{}

static ssize_t mip4_sysfs_fw_update(struct device *dev,
				    struct device_attribute *attr,
				    const char *buf, size_t count)
{}

static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mip4_sysfs_fw_update);

static ssize_t mip4_sysfs_read_fw_version(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{}

static DEVICE_ATTR(fw_version, S_IRUGO, mip4_sysfs_read_fw_version, NULL);

static ssize_t mip4_sysfs_read_hw_version(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{}

static DEVICE_ATTR(hw_version, S_IRUGO, mip4_sysfs_read_hw_version, NULL);

static ssize_t mip4_sysfs_read_product_id(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{}

static DEVICE_ATTR(product_id, S_IRUGO, mip4_sysfs_read_product_id, NULL);

static ssize_t mip4_sysfs_read_ic_name(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{}

static DEVICE_ATTR(ic_name, S_IRUGO, mip4_sysfs_read_ic_name, NULL);

static struct attribute *mip4_attrs[] =;
ATTRIBUTE_GROUPS();

static int mip4_probe(struct i2c_client *client)
{}

static int mip4_suspend(struct device *dev)
{}

static int mip4_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(mip4_pm_ops, mip4_suspend, mip4_resume);

#ifdef CONFIG_OF
static const struct of_device_id mip4_of_match[] =;
MODULE_DEVICE_TABLE(of, mip4_of_match);
#endif

#ifdef CONFIG_ACPI
static const struct acpi_device_id mip4_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, mip4_acpi_match);
#endif

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

static struct i2c_driver mip4_driver =;
module_i2c_driver();

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