summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen/ist30xxb/ist30xxb_update.h
blob: f9bf28f7f58b3422b6596212950e5917057b99aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 *  Copyright (C) 2010, Imagis Technology Co. Ltd. All Rights Reserved.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 */

#ifndef __IST30XX_UPDATE_H__
#define __IST30XX_UPDATE_H__

#include "ist30xxb_tsp.h"

#define IST30XX_INTERNAL_BIN    (1)
#define IST30XX_CHECK_CALIB     (0)

#if IST30XX_INTERNAL_BIN
#define IST30XX_UPDATE_BY_WORKQUEUE     (0)
#define IST30XX_UPDATE_DELAY    (3 * HZ)
#endif // IST30XX_INTERNAL_BIN

#define IST30XX_EEPROM_SIZE     (0x8000)
#define EEPROM_PAGE_SIZE        (64)
#define EEPROM_BASE_ADDR        (0)

#define IST30XXB_ACCESS_ADDR        (1 << 31)
#define IST30XXB_BURST_ACCESS       (1 << 27)
#define IST30XXB_DA_ADDR(k)         (k | IST30XXB_ACCESS_ADDR)

#define IST30XXB_REG_TSPTYPE        IST30XXB_DA_ADDR(0x40002010)

#define IST30XXB_REG_EEPMODE        IST30XXB_DA_ADDR(0x40007000)
#define IST30XXB_REG_EEPADDR        IST30XXB_DA_ADDR(0x40007004)
#define IST30XXB_REG_EEPWDAT        IST30XXB_DA_ADDR(0x40007008)
#define IST30XXB_REG_EEPRDAT        IST30XXB_DA_ADDR(0x4000700C)
#define IST30XXB_REG_EEPISPEN       IST30XXB_DA_ADDR(0x40007010)
#define IST30XXB_REG_CHKSMOD        IST30XXB_DA_ADDR(0x40007014)
#define IST30XXB_REG_CHKSDAT        IST30XXB_DA_ADDR(0x40007038)

#define IST30XXB_REG_CHIPID         IST30XXB_DA_ADDR(0x40000000)
#define IST30XXB_REG_LDOOSC         IST30XXB_DA_ADDR(0x40000030)
#define IST30XXB_REG_CLKDIV         IST30XXB_DA_ADDR(0x4000004C)

#define IST30XXB_MEM_ADDR           (0x20000000)
#define IST30XXB_MEM_COUNT          IST30XXB_DA_ADDR(IST30XXB_MEM_ADDR | 0x5F0)
#define IST30XXB_MEM_ALGORITHM      IST30XXB_DA_ADDR(IST30XXB_MEM_ADDR | 0x34)
#define IST30XXB_MEM_CMD            IST30XXB_DA_ADDR(IST30XXB_MEM_ADDR | 0x3C)
#define IST30XXB_MEM_FINGERS        IST30XXB_DA_ADDR(IST30XXB_MEM_ADDR | 0x4)

#define IST30XX_FW_NAME         "ist30xx.fw"
#define IST30XXB_FW_NAME        "ist30xxb.fw"

#define MASK_FW_VER             (0xFFFF0000)
#define IST30XX_FW_VER1         (0x00010000)
#define IST30XX_FW_VER2         (0x00020000)
#define IST30XX_FW_VER3         (0x00030000)

#define IST30XX_FW_UPDATE_RETRY (3)

#define WAIT_CALIB_CNT          (50)
#define CALIB_THRESHOLD         (100)

#define CALIB_TO_GAP(n)         ((n >> 16) & 0xFFF)
#define CALIB_TO_STATUS(n)      ((n >> 12) & 0xF)

#define MASK_UPDATE_BIN         (1)
#define MASK_UPDATE_FW          (1)
#define MASK_UPDATE_ISP         (2)
#define MASK_UPDATE_ALL         (3)

#define CHKSUM_FW               (1)
#define CHKSUM_ALL              (2)

#define FLAG_FW                 (1)
#define FLAG_PARAM              (2)

#define TAGS_PARSE_OK           (0)

/* I2C Transaction size */
#define I2C_MAX_WRITE_SIZE      (64)            /* bytes */
#define I2C_MAX_READ_SIZE       (8)             /* bytes */

int ist30xx_read_buf(struct i2c_client *client, u32 cmd, u32 *buf, u16 len);
int ist30xx_write_buf(struct i2c_client *client, u32 cmd, u32 *buf, u16 len);

int ist30xxb_burst_read(struct i2c_client *client, u32 addr, u32 *buf32, int len);

int ist30xxb_read_chksum(struct i2c_client *client, u32 *chksum);

void ist30xx_get_update_info(struct ist30xx_data *data, const u8 *buf, const u32 size);

u32 ist30xx_parse_ver(int flag, const u8 *buf);

int ist30xx_fw_update(struct i2c_client *client, const u8 *buf, int size, bool mode);
int ist30xx_fw_param_update(struct i2c_client *client, const u8 *buf);
int ist30xx_fw_recovery(struct ist30xx_data *data);

int ist30xx_auto_fw_update(struct ist30xx_data *data);
int ist30xx_auto_param_update(struct ist30xx_data *data);
int ist30xx_auto_bin_update(struct ist30xx_data *data);

int ist30xx_calibrate(int wait_cnt);
int ist30xx_calib_wait(void);

int ist30xx_init_update_sysfs(void);

#endif  // __IST30XX_UPDATE_H__