linux/drivers/input/mouse/cyapa_gen5.c

/*
 * Cypress APA trackpad with I2C interface
 *
 * Author: Dudley Du <[email protected]>
 *
 * Copyright (C) 2014-2015 Cypress Semiconductor, Inc.
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file COPYING in the main directory of this archive for
 * more details.
 */

#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/input/mt.h>
#include <linux/mutex.h>
#include <linux/completion.h>
#include <linux/slab.h>
#include <linux/unaligned.h>
#include <linux/crc-itu-t.h>
#include <linux/pm_runtime.h>
#include "cyapa.h"


/* Macro of TSG firmware image */
#define CYAPA_TSG_FLASH_MAP_BLOCK_SIZE
#define CYAPA_TSG_IMG_FW_HDR_SIZE
#define CYAPA_TSG_FW_ROW_SIZE
#define CYAPA_TSG_IMG_START_ROW_NUM
#define CYAPA_TSG_IMG_END_ROW_NUM
#define CYAPA_TSG_IMG_APP_INTEGRITY_ROW_NUM
#define CYAPA_TSG_IMG_MAX_RECORDS
#define CYAPA_TSG_IMG_READ_SIZE
#define CYAPA_TSG_START_OF_APPLICATION
#define CYAPA_TSG_APP_INTEGRITY_SIZE
#define CYAPA_TSG_FLASH_MAP_METADATA_SIZE
#define CYAPA_TSG_BL_KEY_SIZE

#define CYAPA_TSG_MAX_CMD_SIZE

/* Macro of PIP interface */
#define PIP_BL_INITIATE_RESP_LEN
#define PIP_BL_FAIL_EXIT_RESP_LEN
#define PIP_BL_FAIL_EXIT_STATUS_CODE
#define PIP_BL_VERIFY_INTEGRITY_RESP_LEN
#define PIP_BL_INTEGRITY_CHEKC_PASS
#define PIP_BL_BLOCK_WRITE_RESP_LEN

#define PIP_TOUCH_REPORT_ID
#define PIP_BTN_REPORT_ID
#define PIP_WAKEUP_EVENT_REPORT_ID
#define PIP_PUSH_BTN_REPORT_ID
#define GEN5_OLD_PUSH_BTN_REPORT_ID
#define PIP_PROXIMITY_REPORT_ID

#define PIP_PROXIMITY_REPORT_SIZE
#define PIP_PROXIMITY_DISTANCE_OFFSET
#define PIP_PROXIMITY_DISTANCE_MASK

#define PIP_TOUCH_REPORT_HEAD_SIZE
#define PIP_TOUCH_REPORT_MAX_SIZE
#define PIP_BTN_REPORT_HEAD_SIZE
#define PIP_BTN_REPORT_MAX_SIZE
#define PIP_WAKEUP_EVENT_SIZE

#define PIP_NUMBER_OF_TOUCH_OFFSET
#define PIP_NUMBER_OF_TOUCH_MASK
#define PIP_BUTTONS_OFFSET
#define PIP_BUTTONS_MASK
#define PIP_GET_EVENT_ID(reg)
#define PIP_GET_TOUCH_ID(reg)
#define PIP_TOUCH_TYPE_FINGER
#define PIP_TOUCH_TYPE_PROXIMITY
#define PIP_TOUCH_TYPE_HOVER
#define PIP_GET_TOUCH_TYPE(reg)

#define RECORD_EVENT_NONE
#define RECORD_EVENT_TOUCHDOWN
#define RECORD_EVENT_DISPLACE
#define RECORD_EVENT_LIFTOFF

#define PIP_SENSING_MODE_MUTUAL_CAP_FINE
#define PIP_SENSING_MODE_SELF_CAP

#define PIP_SET_PROXIMITY

/* Macro of Gen5 */
#define GEN5_BL_MAX_OUTPUT_LENGTH
#define GEN5_APP_MAX_OUTPUT_LENGTH

#define GEN5_POWER_STATE_ACTIVE
#define GEN5_POWER_STATE_LOOK_FOR_TOUCH
#define GEN5_POWER_STATE_READY
#define GEN5_POWER_STATE_IDLE
#define GEN5_POWER_STATE_BTN_ONLY
#define GEN5_POWER_STATE_OFF

#define GEN5_POWER_READY_MAX_INTRVL_TIME
#define GEN5_POWER_IDLE_MAX_INTRVL_TIME

#define GEN5_CMD_GET_PARAMETER
#define GEN5_CMD_SET_PARAMETER
#define GEN5_PARAMETER_ACT_INTERVL_ID
#define GEN5_PARAMETER_ACT_INTERVL_SIZE
#define GEN5_PARAMETER_ACT_LFT_INTERVL_ID
#define GEN5_PARAMETER_ACT_LFT_INTERVL_SIZE
#define GEN5_PARAMETER_LP_INTRVL_ID
#define GEN5_PARAMETER_LP_INTRVL_SIZE

#define GEN5_PARAMETER_DISABLE_PIP_REPORT

#define GEN5_BL_REPORT_DESCRIPTOR_SIZE
#define GEN5_BL_REPORT_DESCRIPTOR_ID
#define GEN5_APP_REPORT_DESCRIPTOR_SIZE
#define GEN5_APP_CONTRACT_REPORT_DESCRIPTOR_SIZE
#define GEN5_APP_REPORT_DESCRIPTOR_ID

#define GEN5_RETRIEVE_MUTUAL_PWC_DATA
#define GEN5_RETRIEVE_SELF_CAP_PWC_DATA

#define GEN5_RETRIEVE_DATA_ELEMENT_SIZE_MASK

#define GEN5_CMD_EXECUTE_PANEL_SCAN
#define GEN5_CMD_RETRIEVE_PANEL_SCAN
#define GEN5_PANEL_SCAN_MUTUAL_RAW_DATA
#define GEN5_PANEL_SCAN_MUTUAL_BASELINE
#define GEN5_PANEL_SCAN_MUTUAL_DIFFCOUNT
#define GEN5_PANEL_SCAN_SELF_RAW_DATA
#define GEN5_PANEL_SCAN_SELF_BASELINE
#define GEN5_PANEL_SCAN_SELF_DIFFCOUNT

/* The offset only valid for retrieve PWC and panel scan commands */
#define GEN5_RESP_DATA_STRUCTURE_OFFSET
#define GEN5_PWC_DATA_ELEMENT_SIZE_MASK


struct cyapa_pip_touch_record {} __packed;

struct cyapa_pip_report_data {} __packed;

struct cyapa_tsg_bin_image_head {} __packed;

struct cyapa_tsg_bin_image_data_record {} __packed;

struct cyapa_tsg_bin_image {} __packed;

struct pip_bl_packet_start {} __packed;

struct pip_bl_packet_end {} __packed;

struct pip_bl_cmd_head {} __packed;

/* Initiate bootload command data structure. */
struct pip_bl_initiate_cmd_data {} __packed;

struct tsg_bl_metadata_row_params {} __packed;

/* Bootload program and verify row command data structure */
struct tsg_bl_flash_row_head {} __packed;

struct pip_app_cmd_head {} __packed;

/* Application get/set parameter command data structure */
struct gen5_app_set_parameter_data {} __packed;

struct gen5_app_get_parameter_data {} __packed;

struct gen5_retrieve_panel_scan_data {} __packed;

u8 pip_read_sys_info[] =;
u8 pip_bl_read_app_info[] =;

static u8 cyapa_pip_bl_cmd_key[] =;

static int cyapa_pip_event_process(struct cyapa *cyapa,
				   struct cyapa_pip_report_data *report_data);

int cyapa_pip_cmd_state_initialize(struct cyapa *cyapa)
{}

/* Return negative errno, or else the number of bytes read. */
ssize_t cyapa_i2c_pip_read(struct cyapa *cyapa, u8 *buf, size_t size)
{}

/*
 * Return a negative errno code else zero on success.
 */
ssize_t cyapa_i2c_pip_write(struct cyapa *cyapa, u8 *buf, size_t size)
{}

static void cyapa_set_pip_pm_state(struct cyapa *cyapa,
				   enum cyapa_pm_stage pm_stage)
{}

static void cyapa_reset_pip_pm_state(struct cyapa *cyapa)
{}

static enum cyapa_pm_stage cyapa_get_pip_pm_state(struct cyapa *cyapa)
{}

/*
 * This function is aimed to dump all not read data in Gen5 trackpad
 * before send any command, otherwise, the interrupt line will be blocked.
 */
int cyapa_empty_pip_output_data(struct cyapa *cyapa,
		u8 *buf, int *len, cb_sort func)
{}

static int cyapa_do_i2c_pip_cmd_irq_sync(
		struct cyapa *cyapa,
		u8 *cmd, size_t cmd_len,
		unsigned long timeout)
{}

static int cyapa_do_i2c_pip_cmd_polling(
		struct cyapa *cyapa,
		u8 *cmd, size_t cmd_len,
		u8 *resp_data, int *resp_len,
		unsigned long timeout,
		cb_sort func)
{}

int cyapa_i2c_pip_cmd_irq_sync(
		struct cyapa *cyapa,
		u8 *cmd, int cmd_len,
		u8 *resp_data, int *resp_len,
		unsigned long timeout,
		cb_sort func,
		bool irq_mode)
{}

bool cyapa_sort_tsg_pip_bl_resp_data(struct cyapa *cyapa,
		u8 *data, int len)
{}

bool cyapa_sort_tsg_pip_app_resp_data(struct cyapa *cyapa,
		u8 *data, int len)
{}

static bool cyapa_sort_pip_application_launch_data(struct cyapa *cyapa,
		u8 *buf, int len)
{}

static bool cyapa_sort_gen5_hid_descriptor_data(struct cyapa *cyapa,
		u8 *buf, int len)
{}

static bool cyapa_sort_pip_deep_sleep_data(struct cyapa *cyapa,
		u8 *buf, int len)
{}

static int gen5_idle_state_parse(struct cyapa *cyapa)
{}

static int gen5_hid_description_header_parse(struct cyapa *cyapa, u8 *reg_data)
{}

static int gen5_report_data_header_parse(struct cyapa *cyapa, u8 *reg_data)
{}

static int gen5_cmd_resp_header_parse(struct cyapa *cyapa, u8 *reg_data)
{}

static int cyapa_gen5_state_parse(struct cyapa *cyapa, u8 *reg_data, int len)
{}

static struct cyapa_tsg_bin_image_data_record *
cyapa_get_image_record_data_num(const struct firmware *fw,
		int *record_num)
{}

int cyapa_pip_bl_initiate(struct cyapa *cyapa, const struct firmware *fw)
{}

static bool cyapa_sort_pip_bl_exit_data(struct cyapa *cyapa, u8 *buf, int len)
{}

int cyapa_pip_bl_exit(struct cyapa *cyapa)
{}

int cyapa_pip_bl_enter(struct cyapa *cyapa)
{}

static int cyapa_pip_fw_head_check(struct cyapa *cyapa,
		struct cyapa_tsg_bin_image_head *image_head)
{}

int cyapa_pip_check_fw(struct cyapa *cyapa, const struct firmware *fw)
{}

static int cyapa_pip_write_fw_block(struct cyapa *cyapa,
		struct cyapa_tsg_bin_image_data_record *flash_record)
{}

int cyapa_pip_do_fw_update(struct cyapa *cyapa,
		const struct firmware *fw)
{}

static int cyapa_gen5_change_power_state(struct cyapa *cyapa, u8 power_state)
{}

static int cyapa_gen5_set_interval_time(struct cyapa *cyapa,
		u8 parameter_id, u16 interval_time)
{}

static int cyapa_gen5_get_interval_time(struct cyapa *cyapa,
		u8 parameter_id, u16 *interval_time)
{}

static int cyapa_gen5_disable_pip_report(struct cyapa *cyapa)
{}

int cyapa_pip_set_proximity(struct cyapa *cyapa, bool enable)
{}

int cyapa_pip_deep_sleep(struct cyapa *cyapa, u8 state)
{}

static int cyapa_gen5_set_power_mode(struct cyapa *cyapa,
		u8 power_mode, u16 sleep_time, enum cyapa_pm_stage pm_stage)
{}

int cyapa_pip_resume_scanning(struct cyapa *cyapa)
{}

int cyapa_pip_suspend_scanning(struct cyapa *cyapa)
{}

static int cyapa_pip_calibrate_pwcs(struct cyapa *cyapa,
		u8 calibrate_sensing_mode_type)
{}

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

static s32 twos_complement_to_s32(s32 value, int num_bits)
{}

static s32 cyapa_parse_structure_data(u8 data_format, u8 *buf, int buf_len)
{}

static void cyapa_gen5_guess_electrodes(struct cyapa *cyapa,
		int *electrodes_rx, int *electrodes_tx)
{}

/*
 * Read all the global mutual or self idac data or mutual or self local PWC
 * data based on the @idac_data_type.
 * If the input value of @data_size is 0, then means read global mutual or
 * self idac data. For read global mutual idac data, @idac_max, @idac_min and
 * @idac_ave are in order used to return the max value of global mutual idac
 * data, the min value of global mutual idac and the average value of the
 * global mutual idac data. For read global self idac data, @idac_max is used
 * to return the global self cap idac data in Rx direction, @idac_min is used
 * to return the global self cap idac data in Tx direction. @idac_ave is not
 * used.
 * If the input value of @data_size is not 0, than means read the mutual or
 * self local PWC data. The @idac_max, @idac_min and @idac_ave are used to
 * return the max, min and average value of the mutual or self local PWC data.
 * Note, in order to read mutual local PWC data, must read invoke this function
 * to read the mutual global idac data firstly to set the correct Rx number
 * value, otherwise, the read mutual idac and PWC data may not correct.
 */
static int cyapa_gen5_read_idac_data(struct cyapa *cyapa,
		u8 cmd_code, u8 idac_data_type, int *data_size,
		int *idac_max, int *idac_min, int *idac_ave)
{}

static int cyapa_gen5_read_mutual_idac_data(struct cyapa *cyapa,
	int *gidac_mutual_max, int *gidac_mutual_min, int *gidac_mutual_ave,
	int *lidac_mutual_max, int *lidac_mutual_min, int *lidac_mutual_ave)
{}

static int cyapa_gen5_read_self_idac_data(struct cyapa *cyapa,
		int *gidac_self_rx, int *gidac_self_tx,
		int *lidac_self_max, int *lidac_self_min, int *lidac_self_ave)
{}

static ssize_t cyapa_gen5_execute_panel_scan(struct cyapa *cyapa)
{}

static int cyapa_gen5_read_panel_scan_raw_data(struct cyapa *cyapa,
		u8 cmd_code, u8 raw_data_type, int raw_data_max_num,
		int *raw_data_max, int *raw_data_min, int *raw_data_ave,
		u8 *buffer)
{}

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

bool cyapa_pip_sort_system_info_data(struct cyapa *cyapa,
		u8 *buf, int len)
{}

static int cyapa_gen5_bl_query_data(struct cyapa *cyapa)
{}

static int cyapa_gen5_get_query_data(struct cyapa *cyapa)
{}

static int cyapa_gen5_do_operational_check(struct cyapa *cyapa)
{}

/*
 * Return false, do not continue process
 * Return true, continue process.
 */
bool cyapa_pip_irq_cmd_handler(struct cyapa *cyapa)
{}

static void cyapa_pip_report_buttons(struct cyapa *cyapa,
		const struct cyapa_pip_report_data *report_data)
{}

static void cyapa_pip_report_proximity(struct cyapa *cyapa,
		const struct cyapa_pip_report_data *report_data)
{}

static void cyapa_pip_report_slot_data(struct cyapa *cyapa,
		const struct cyapa_pip_touch_record *touch)
{}

static void cyapa_pip_report_touches(struct cyapa *cyapa,
		const struct cyapa_pip_report_data *report_data)
{}

int cyapa_pip_irq_handler(struct cyapa *cyapa)
{}

static int cyapa_pip_event_process(struct cyapa *cyapa,
				   struct cyapa_pip_report_data *report_data)
{}

int cyapa_pip_bl_activate(struct cyapa *cyapa) {}
int cyapa_pip_bl_deactivate(struct cyapa *cyapa) {}


const struct cyapa_dev_ops cyapa_gen5_ops =;