blob: 2654ac2666c40c4be12af4cb00230d03dd03dbe6 [file] [log] [blame]
tracychui35151622020-04-29 16:24:36 +08001/* Himax Android Driver Sample Code for HX83112 chipset
2*
3* Copyright (C) 2017 Himax Corporation.
4*
5* This software is licensed under the terms of the GNU General Public
6* License version 2, as published by the Free Software Foundation, and
7* may be copied, distributed, and modified under those terms.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14*/
15
16#include "himax_platform.h"
17#include "himax_common.h"
18#include <linux/slab.h>
19
20#define HIMAX_REG_RETRY_TIMES 5
21
22enum fw_image_type
23{
24 fw_image_32k = 0x01,
25 fw_image_48k,
26 fw_image_60k,
27 fw_image_64k,
28 fw_image_124k,
29 fw_image_128k,
30};
31
32int himax_hand_shaking(struct i2c_client *client);
33void himax_set_SMWP_enable(struct i2c_client *client,uint8_t SMWP_enable, bool suspended);
34void himax_set_HSEN_enable(struct i2c_client *client,uint8_t HSEN_enable, bool suspended);
35void himax_usb_detect_set(struct i2c_client *client,uint8_t *cable_config);
36int himax_determin_diag_rawdata(int diag_command);
37int himax_determin_diag_storage(int diag_command);
38void himax_diag_register_set(struct i2c_client *client, uint8_t diag_command);
39void himax_flash_dump_func(struct i2c_client *client, uint8_t local_flash_command, int Flash_Size, uint8_t *flash_buffer);
40int himax_chip_self_test(struct i2c_client *client);
41void himax_burst_enable(struct i2c_client *client, uint8_t auto_add_4_byte); ////himax_83110_BURST_INC0_EN
42void himax_register_read(struct i2c_client *client, uint8_t *read_addr, int read_length, uint8_t *read_data, bool cfg_flag); ////RegisterRead83110
43void himax_flash_read(struct i2c_client *client, uint8_t *reg_byte, uint8_t *read_data); ////himax_83110_Flash_Read
44void himax_flash_write_burst(struct i2c_client *client, uint8_t * reg_byte, uint8_t * write_data); ////himax_83110_Flash_Write_Burst
45void himax_flash_write_burst_lenth(struct i2c_client *client, uint8_t *reg_byte, uint8_t *write_data, int length); ////himax_83110_Flash_Write_Burst_lenth
46void himax_register_write(struct i2c_client *client, uint8_t *write_addr, int write_length, uint8_t *write_data, bool cfg_flag); ////RegisterWrite83110
47bool himax_sense_off(struct i2c_client *client); ////himax_83110_SenseOff
48bool himax_enter_safe_mode(struct i2c_client *client);
49void himax_interface_on(struct i2c_client *client); ////himax_83110_Interface_on
50bool wait_wip(struct i2c_client *client, int Timing);
51void himax_sense_on(struct i2c_client *client, uint8_t FlashMode); ////himax_83110_SenseOn
52void himax_chip_erase(struct i2c_client *client); ////himax_83110_Chip_Erase
53bool himax_block_erase(struct i2c_client *client); ////himax_83110_Block_Erase
54void himax_flash_programming(struct i2c_client *client, uint8_t *FW_content, int FW_Size); ////himax_83110_Flash_Programming
55bool himax_check_chip_version(struct i2c_client *client); ////himax_83110_CheckChipVersion
56int himax_check_CRC(struct i2c_client *client, int mode); ////himax_83110_Check_CRC
57int fts_ctpm_fw_upgrade_with_sys_fs_32k(struct i2c_client *client, unsigned char *fw, int len, bool change_iref);
58int fts_ctpm_fw_upgrade_with_sys_fs_60k(struct i2c_client *client, unsigned char *fw, int len, bool change_iref);
59int fts_ctpm_fw_upgrade_with_sys_fs_64k(struct i2c_client *client, unsigned char *fw, int len, bool change_iref);
60int fts_ctpm_fw_upgrade_with_sys_fs_124k(struct i2c_client *client, unsigned char *fw, int len, bool change_iref);
61int fts_ctpm_fw_upgrade_with_sys_fs_128k(struct i2c_client *client, unsigned char *fw, int len, bool change_iref);
62void himax_touch_information(struct i2c_client *client);
63int himax_read_i2c_status(struct i2c_client *client);
64int himax_read_ic_trigger_type(struct i2c_client *client);
65void himax_read_FW_ver(struct i2c_client *client);
66bool himax_ic_package_check(struct i2c_client *client);
67void himax_power_on_init(struct i2c_client *client);
68bool himax_read_event_stack(struct i2c_client *client, uint8_t *buf, uint8_t length);
69void himax_get_DSRAM_data(struct i2c_client *client, uint8_t *info_data);
70bool himax_calculateChecksum(struct i2c_client *client, bool change_iref);
71bool himax_program_reload(struct i2c_client *client);//5442 Program_Reload
72uint8_t himax_read_DD_status(uint8_t *cmd_set, uint8_t *tmp_data);
73int himax_read_FW_status(uint8_t *state_addr, uint8_t *tmp_addr);
74void himax_resume_ic_action(struct i2c_client *client);
75void himax_suspend_ic_action(struct i2c_client *client);
76
77//ts_work
78int cal_data_len(int raw_cnt_rmd, int HX_MAX_PT, int raw_cnt_max);
79bool diag_check_sum(struct himax_report_data *hx_touch_data); //return checksum value
80void diag_parse_raw_data(struct himax_report_data *hx_touch_data,int mul_num, int self_num,uint8_t diag_cmd, int32_t *mutual_data, int32_t *self_data);