tracychui | 3515162 | 2020-04-29 16:24:36 +0800 | [diff] [blame^] | 1 | /* 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 | |
| 22 | enum 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 | |
| 32 | int himax_hand_shaking(struct i2c_client *client); |
| 33 | void himax_set_SMWP_enable(struct i2c_client *client,uint8_t SMWP_enable, bool suspended); |
| 34 | void himax_set_HSEN_enable(struct i2c_client *client,uint8_t HSEN_enable, bool suspended); |
| 35 | void himax_usb_detect_set(struct i2c_client *client,uint8_t *cable_config); |
| 36 | int himax_determin_diag_rawdata(int diag_command); |
| 37 | int himax_determin_diag_storage(int diag_command); |
| 38 | void himax_diag_register_set(struct i2c_client *client, uint8_t diag_command); |
| 39 | void himax_flash_dump_func(struct i2c_client *client, uint8_t local_flash_command, int Flash_Size, uint8_t *flash_buffer); |
| 40 | int himax_chip_self_test(struct i2c_client *client); |
| 41 | void himax_burst_enable(struct i2c_client *client, uint8_t auto_add_4_byte); ////himax_83110_BURST_INC0_EN |
| 42 | void himax_register_read(struct i2c_client *client, uint8_t *read_addr, int read_length, uint8_t *read_data, bool cfg_flag); ////RegisterRead83110 |
| 43 | void himax_flash_read(struct i2c_client *client, uint8_t *reg_byte, uint8_t *read_data); ////himax_83110_Flash_Read |
| 44 | void himax_flash_write_burst(struct i2c_client *client, uint8_t * reg_byte, uint8_t * write_data); ////himax_83110_Flash_Write_Burst |
| 45 | void 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 |
| 46 | void himax_register_write(struct i2c_client *client, uint8_t *write_addr, int write_length, uint8_t *write_data, bool cfg_flag); ////RegisterWrite83110 |
| 47 | bool himax_sense_off(struct i2c_client *client); ////himax_83110_SenseOff |
| 48 | bool himax_enter_safe_mode(struct i2c_client *client); |
| 49 | void himax_interface_on(struct i2c_client *client); ////himax_83110_Interface_on |
| 50 | bool wait_wip(struct i2c_client *client, int Timing); |
| 51 | void himax_sense_on(struct i2c_client *client, uint8_t FlashMode); ////himax_83110_SenseOn |
| 52 | void himax_chip_erase(struct i2c_client *client); ////himax_83110_Chip_Erase |
| 53 | bool himax_block_erase(struct i2c_client *client); ////himax_83110_Block_Erase |
| 54 | void himax_flash_programming(struct i2c_client *client, uint8_t *FW_content, int FW_Size); ////himax_83110_Flash_Programming |
| 55 | bool himax_check_chip_version(struct i2c_client *client); ////himax_83110_CheckChipVersion |
| 56 | int himax_check_CRC(struct i2c_client *client, int mode); ////himax_83110_Check_CRC |
| 57 | int fts_ctpm_fw_upgrade_with_sys_fs_32k(struct i2c_client *client, unsigned char *fw, int len, bool change_iref); |
| 58 | int fts_ctpm_fw_upgrade_with_sys_fs_60k(struct i2c_client *client, unsigned char *fw, int len, bool change_iref); |
| 59 | int fts_ctpm_fw_upgrade_with_sys_fs_64k(struct i2c_client *client, unsigned char *fw, int len, bool change_iref); |
| 60 | int fts_ctpm_fw_upgrade_with_sys_fs_124k(struct i2c_client *client, unsigned char *fw, int len, bool change_iref); |
| 61 | int fts_ctpm_fw_upgrade_with_sys_fs_128k(struct i2c_client *client, unsigned char *fw, int len, bool change_iref); |
| 62 | void himax_touch_information(struct i2c_client *client); |
| 63 | int himax_read_i2c_status(struct i2c_client *client); |
| 64 | int himax_read_ic_trigger_type(struct i2c_client *client); |
| 65 | void himax_read_FW_ver(struct i2c_client *client); |
| 66 | bool himax_ic_package_check(struct i2c_client *client); |
| 67 | void himax_power_on_init(struct i2c_client *client); |
| 68 | bool himax_read_event_stack(struct i2c_client *client, uint8_t *buf, uint8_t length); |
| 69 | void himax_get_DSRAM_data(struct i2c_client *client, uint8_t *info_data); |
| 70 | bool himax_calculateChecksum(struct i2c_client *client, bool change_iref); |
| 71 | bool himax_program_reload(struct i2c_client *client);//5442 Program_Reload |
| 72 | uint8_t himax_read_DD_status(uint8_t *cmd_set, uint8_t *tmp_data); |
| 73 | int himax_read_FW_status(uint8_t *state_addr, uint8_t *tmp_addr); |
| 74 | void himax_resume_ic_action(struct i2c_client *client); |
| 75 | void himax_suspend_ic_action(struct i2c_client *client); |
| 76 | |
| 77 | //ts_work |
| 78 | int cal_data_len(int raw_cnt_rmd, int HX_MAX_PT, int raw_cnt_max); |
| 79 | bool diag_check_sum(struct himax_report_data *hx_touch_data); //return checksum value |
| 80 | void 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); |