f303_ic_reg.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /* f303_ic_reg.h
  2. *
  3. * Raydium TouchScreen driver.
  4. *
  5. * Copyright (c) 2021 Raydium tech Ltd.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. */
  18. // ['h5000_0900], [32'hFFFF_FFFF], PRAM_LOCK
  19. #define I2CTB_LOCK (0x00000001<<6) // [0] (R/W) I2C Table lock
  20. #define BOTLR_LOCK (0x00000001<<5) // [0] (R/W) Boot loader lock
  21. #define USEFW_LOCK (0x00000001<<4) // [0] (R/W) User fw lock
  22. #define CONFIG_LOCK (0x00000001<<3) // [0] (R/W) Configuration lock
  23. #define COMP_LOCK (0x00000001<<2) // [0] (R/W) compensation lock
  24. #define BASEL_LOCK (0x00000001<<1) // [0] (R/W) baseline lock
  25. #define INICO_LOCK (0x00000001<<0) // [0] (R/W) Initial code lock
  26. // ['h5000_0904], [32'h0000_0000], Program RAM store type, PRAM_STORE_TYPE
  27. #define BOTLR_AREA (0x00000001<<5) // [0] (R/W) Boot loader area
  28. #define USEFW_AREA (0x00000001<<4) // [0] (R/W) User fw area
  29. #define CONFIG_AREA (0x00000001<<3) // [0] (R/W) Configuration area
  30. #define COMP_AREA (0x00000001<<2) // [0] (R/W) compensation area
  31. #define BASEL_AREA (0x00000001<<1) // [0] (R/W) baseline area
  32. #define INICO_AREA (0x00000001<<0) // [0] (R/W) Initial code area
  33. // ['h5000_0918], [32'h0000_0000],Flash state control register ,FLASH_STATE_REG
  34. #define BLDR_FINISH (0x00000001<<14) // [0] (R) MCU_HOLD status
  35. #define MCU_HOLD_STATUS (0x00000001<<13) // [0] (R) MCU_HOLD status
  36. #define BOOT_REGION (0x00000001<<12) // [0] (R) boot region index
  37. #define BL_CRC_CHK (0x00000001<<11) // [0] (R/W) boot-loader area CRC check
  38. #define FW_CRC_CHK (0x00000001<<10) // [0] (R/W) user FW CRC check
  39. #define PARA_CRC_CHK (0x00000001<<9) // [0] (R/W) parameter area CRC check
  40. #define COMP_CRC_CHK (0x00000001<<8) // [0] (R/W) compensation area CRC check
  41. #define BASELINE_CRC_CHK (0x00000001<<7) // [0] (R/W) baseline area CRC check
  42. #define INITIAL_CRC_CHK (0x00000001<<6) // [0] (R/W) initial code CRC check
  43. #define MCU_HOLD (0x00000001<<5) // [0] (R/W) MCU hold
  44. #define SKIP_LOAD (0x00000001<<4) // [0] (R/W) Skip all load flash action
  45. #define FW_INICO_ERR (0x00000001<<3) // [0] (R) FW_INICO_ERR
  46. #define FW_CG_ERR (0x00000001<<2) // [0] (R) cc bl CRC error
  47. #define FW_CRC_ERR (0x00000001<<1) // [0] (R) FW_CRC_ERR
  48. #define BL0_CRC_ERR (0x00000001<<0) // [0] (R) BL0_CRC_ERR
  49. // ['h5000_0934], [32'h0000_0000], FLASH Lock and Key Register (main) (FLKEY1)
  50. #define FLKEY1_LOCK (0x00000000<<0) // [7:0] (R/W) FLASH Lock and Key1 Register
  51. #define FLKEY1_KEY (0x000000A5<<0) // [7:0] (R/W) FLASH Unlock and Key1 Register:0xA5
  52. // ['h5000_0938], [32'h0000_0000], FLASH Lock and Key Register (information) (FLKEY2)
  53. #define FLKEY2_LOCK (0x00000000<<0) // [7:0] (R/W) FLASH Lock and Key3 Register
  54. #define FLKEY2_KEY (0x000000D7<<0) // [7:0] (R/W) FLASH Unlock and Key3 Register:0xD7
  55. //#define MAX_SENSING_PIN_NUM 30
  56. // ['h5000_0610], [32'h0106_0300], I2C eng Register (I2CENG)
  57. #define REG_I2CENG_ADDR 0x50000610
  58. #define I2CENG_AUTO_I2C_DGF_MODE2 (0x00000001<<26) // [26:26] (R/W) auto_i2c_dgf_mode2,, 1: switch def_en after next posedge SCL_dgf, 0: switch def_en control auto_i2c_dgf_mode (bit[24]).
  59. #define I2CENG_DGF_OSC_AUTOSEL (0x00000001<<25) // [25:25] (R/W) dgf_osc_autosel,, 0: TP OSC control, 1: TP OSC/DRIVER OSC control
  60. #define I2CENG_AUTO_I2C_DGF_MODE (0x00000001<<24) // [24:24] (R/W) dgf_en signal delay timing select 0: switch def_en after STOP signal 1: switch def_en after next posedge SCL.
  61. #define I2CENG_I2CS_DGFEN_DLY_NUM(u7x) ((u7x&0x0000007F)<<16) // [22:16] (R/W) dgf_en signal delay number (clock by system clock ).
  62. #define I2CENG_I2CS_DEGFIR_NUM(u7x) ((u7x&0x0000007F)<<8) // [14:8] (R/W) I2C Pad (SCL/SDA) deglitch filter number.
  63. #define I2CENG_RB_MANUAL_I2C_DGF (0x00000001<<7) // [7:7] (R/W) I2C Pad (SCL/SDA) deglitch filter manual mode control 1: Enable 0: Disable.
  64. #define I2CENG_RB_I2C_DGF_EN (0x00000001<<6) // [6:6] (R/W) I2C Pad (SCL/SDA) deglitch filter enable control register when rb_manual_i2c_dgf =1, 1: Enable 0: Disable.
  65. #define I2CENG_FIRST_DAT_SEL(u2x) ((u2x&0x00000003)<<0) // [1:0] (R/W) First data request select for PDA2 read. 0: at 2nd SCL; 1: at 3th SCL; 2:at 4th SCL; 3:at 5th SCL.
  66. #define REG_I2C_I2CFLASHPRO 0x50000624
  67. //['h5000_0628], [32'h0000_0000], PDA2 Control Register (PDA2CTL)
  68. #define REG_PDA2CTL_ADDR 0x50000628
  69. #define PDA2CTL_PDA2_EN (0x00000001UL<<2) // [2:2] (R/W) PDA2 enable bit. 1: enable 0: disable.
  70. #define PDA2CTL_SIE2 (0x00000001<<1) // [1:1] (R/W) SIE2 enable register . 1: enable 0: mask.
  71. #define PDA2CTL_SI2 (0x00000001<<0) // [0:0] (R/W) SI2 interrupt flag (write 1 to clear).
  72. //['h5000_0E1C], [32'h0000_0000], GPIO deglitch enable(GPIO_DEGLITCH)
  73. #define REG_GPIO_DEGLITCH_ENABLE 0x50000E1C
  74. #define GPIO_PULLH_EN(u2x) ((u2x&0x00000003)<<0) // [3:2] (R/W) 1: enable pull-high of GPIO, 0: disable pull-high of GPIO
  75. #define GPIO_DEGLITCH_EN(u2x) ((u2x&0x00000003)<<0) // [1:0] (R/W) 1: enable deglitch function of GPIO, 0: disable deglitch function of GPIO
  76. #define REG_SYSCON_BLKEN_ADDR 0x40000000
  77. #define REG_SYSCON_BLKRST_ADDR 0x40000004
  78. //#define REG_SYSCON_MISCIER_ADDR 0x40000014
  79. #define REG_T2D_CONFIG_1 0x5000145c
  80. #define REG_T2D_CONFIG_2 0x50001460
  81. #define REG_T2D_CONFIG_3 0x50001464
  82. #define REG_T2D_R_CONFIG_1 0x50001468
  83. #define REG_T2D_R_CONFIG_2 0x5000146C
  84. #define MCU_HOLD (0x00000001<<5) // [0] (R/W) MCU hold
  85. #define SKIP_LOAD (0x00000001<<4) // [0] (R/W) Skip all load flash action
  86. #define BLKRST_SW_RST (0x00000001<<0) // [0] (R/W) 1: Software reset, all digital block will be reset
  87. #define MCU_HOLD_STATUS (0x00000001<<13) // [0] (R) MCU_HOLD status
  88. #define FLH_RELEASE_PD (0x00000001<<5) // [0] (R/W) Release from deep power down mode
  89. #define BL_CRC_CHK (0x00000001<<11) // [0] (R/W) boot-loader area CRC check
  90. /* Base addresses */
  91. #define RM_PRAM_BASE (0x00000000UL) // Program, AHB
  92. #define RM_RAM_BASE (0x20000000UL) // SRAM, AHB
  93. #define RM_AHB_BASE (0x40000000UL) // Peripheral, AHB
  94. #define RM_APB_BASE (0x50000000UL) // Peripheral, APB
  95. //#define FW_SYS_CMD_ADDR 0x20000288
  96. #define FW_FT_CMD_ADDR 0x20000289
  97. #define FW_FT_ARG0_ADDR 0x2000028A
  98. #define FW_FT_ARG1_ADDR 0x2000028C
  99. //#define FW_FT_IMG_ADDR 0x2000019C
  100. //#define FW_TP_SEQ_NUM_ADDR 0x20000290
  101. #define SYS_CMD_FUNC_DIS_BS_UPDATE 0x20
  102. #define DIS_BASELINE_UPDATE 0x00010000
  103. #define SYS_CMD_DO_BL_CAL 0x5A
  104. #define SYS_CMD_READ_CAL_FLAG 0x5B
  105. #define SYS_CMD_DO_CC_CAL 0x5C
  106. #define SYS_CMD_CAL_WAIT 0x5D
  107. #define SYS_CMD_WAKEUP_GESTURE_ENABLE 0x40
  108. #define SYS_CMD_WAKEUP_GESTURE_DISABLE 0x41
  109. #define SYS_CMD_FT_GET_DSP_NS_PARAM 0x60
  110. #define SYS_CMD_FT_FUN_FLAG 0x62
  111. #define SYS_CMD_FT_DC_DISABLE 0x010000
  112. #define SYS_CMD_FT_DIG_GAIN_ENABLE 0x020000
  113. #define SYS_CMD_FT_TEST_LOG_EN 0x800000
  114. #define FW_FT_CHANNEL_X_ADDR (PRAM_PARA_START + 24)
  115. #define FW_FT_CHANNEL_Y_ADDR (PRAM_PARA_START + 25)
  116. #define FW_FT_PIN_ADDR (PRAM_PARA_START + 27)
  117. #define FW_FT_PWR_MODE_ADDR (PRAM_PARA_START + 26)
  118. #define FW_FT_FW_VERSION (PRAM_PARA_START + 4)
  119. #define FW_FT_SRAM_FW_VERSION 0x200006E0
  120. #define BOOT_SYNC_DATA_ADDR 0x20000200
  121. #define BOOT_MAIN_STATE_ADDR 0x20000204
  122. #define BOOT_NORMAL_STATE_ADDR 0x20000208
  123. #define BOOT_BURNING_STATE_ADDR 0x2000020C
  124. #define BOOT_CMD_TYPE_ADDR 0x20000210
  125. #define BOOT_RET_DATA_ADDR 0x20000214
  126. #define BOOT_TEST_MODE_ADDR 0x20000218
  127. #define FLASH_OFFSET (0x7800)
  128. #define PRAM_BASELINE_LENGTH (0x130)
  129. #define PRAM_COMP_LENGTH (0x304)
  130. #define PRAM_DIS_INIT_LENGTH (0x80)
  131. #define PRAM_PARA_LENGTH (0x174)
  132. #define PRAM_FW_LENGTH (0x7300)
  133. #define PRAM_BOOT_LENGTH (0x800)
  134. #define PRAM_BOOT_START (0x0000)
  135. #define PRAM_DIS_INIT_START (0x7F80)
  136. #define PRAM_COMP_START (0x7C78)
  137. #define PRAM_PARA_START (0x7B00)
  138. #define PRAM_FW_START (0x0800)
  139. #define PRAM_RESERVE_START (0x0800)
  140. #define PRAM_PARA_DC_THD_ADDR (PRAM_PARA_START + 136)
  141. #define PRAM_CC_TABLE_ADDR (0x7F78)
  142. #define PRAM_BASEINE_START (0x6CCC)
  143. #define PRAM_BOOT_CRC_LENGTH (PRAM_BOOT_LENGTH - HEADER_LENGTH)
  144. #define PRAM_FW_CRC_START (0x6B5C)
  145. #define PRAM_FW_CRC_LENGTH (PRAM_FW_LENGTH + PRAM_PARA_LENGTH) //0x7474
  146. #define PRAM_CB_CRC_START (0x6DFC)
  147. #define PRAM_CB_CRC_LENGTH (PRAM_COMP_LENGTH + PRAM_BASELINE_LENGTH)
  148. #define FT_RAWDATA1_SHORT_BUF_ADDR 0x200002E4 //((at(0x200002E4)));
  149. #define FT_RAWDATA2_OPEN_BUF_ADDR (FT_RAWDATA1_SHORT_BUF_ADDR+100) //((at(0x20000348)));
  150. #define FT_RAWDATA3_CC_BUF_ADDR (FT_RAWDATA2_OPEN_BUF_ADDR+100) //((at(0x200003AC)));
  151. #define FT_UC_BUF_ADDR (FT_RAWDATA3_CC_BUF_ADDR+100) //((at(0x20000410)));
  152. #define FT_OPEN_BL_BUF_ADDR (FT_UC_BUF_ADDR+100) //((at(0x20000474)));
  153. #define FT_TEST_RESULT_BUF_ADDR (FT_OPEN_BL_BUF_ADDR+100) //((at(0x200004D8)));
  154. #define FT_TEST_ITEM_RESULT (FT_TEST_RESULT_BUF_ADDR+50+2) //((at(0x2000050C)));
  155. #define FT_TEST_INFO_ADDR 0x20000674//FT_IMG2PIN_BUF_ADDR+72//((at(0x20000674)));
  156. #define FT_TEST_THD_ADDR (FT_TEST_INFO_ADDR+16) //((at(0x20000684)));
  157. #define FT_TEST_PARA_ADDR (FT_TEST_THD_ADDR+36) //((at(0x200006A8)));
  158. #define SRAM_FT_RAWDATA_3_CC_ADDR (RM_RAM_BASE + 0x0000074C) //0x2000074C
  159. #define SRAM_FT_UC_CC_ADDR (RM_RAM_BASE + 0x000006EC) //0x200006EC
  160. #define FLASH_NORMAL_FW_FW_VERSION_ADDR (FW_FT_FW_VERSION)
  161. #define FLASH_NORMAL_FW_CUST_VERSION_ADDR (PRAM_PARA_START + 10)
  162. #define FLASH_TEST_FW_FW_VERSION_ADDR (FW_FT_FW_VERSION + FLASH_OFFSET)
  163. #define FLASH_NORMAL_FW_CC_TABLE_ADDR 0x9300
  164. #define REG_FLASHCTL_FLASH_PRAM_LOCK 0X50000900
  165. #define REG_FLASHCTL_FLASH_PRAM_STORE_TYPE 0X50000904
  166. #define REG_FLASHCTL_FLASH_PRAM_ADDR 0X50000908
  167. #define REG_FLASHCTL_FLASH_PRAM_LENGTH 0X5000090C
  168. #define REG_FLASHCTL_FLASH_ADDR 0X50000910
  169. #define REG_FLASHCTL_FLASH_ISPCTL 0X50000914
  170. #define REG_FLASHCTL_FLASH_STATE_REG_ADDR 0x50000918
  171. #define REG_FLASHCTL_FLASH_FLKEY1 0x50000934
  172. #define REG_FLASHCTL_FLASH_FLKEY2 0x50000938
  173. #define REG_FLASHCTL_FLASH_DATA 0x5000093C
  174. #define REG_FLASHCTL_FLASH_ENG3 0x5000094C
  175. #define REG_FLASHCTL_FLASH_PRGCHKSUM_ADDR 0x50000974
  176. #define REG_FLASHCTL_FLASH_PRGCHKSUM_RESULT 0x50000978
  177. #define REG_FLASHCTL_DEVID_ADDR 0x500009BC
  178. #define REG_SPI_SLAVE_SPIFLASHPRO 0x50000524
  179. #define PRAM_ADDR_CC_INFO 0x00007F78
  180. #define RAM_WRITE_TEST_ADDR1 0x50000950
  181. #define RAM_WRITE_TEST_ADDR2 0x50000B10
  182. #define RAM_WRITE_TEST_ADDR3 0x50000B00
  183. #define RAM_READ_TEST_ADDR1 0x50000954
  184. #define RAM_READ_TEST_ADDR2 0x50000B04
  185. #define RAM_READ_TEST_ADDR3 0x50000B08
  186. #define FT_UPDATE 0x01
  187. #define FT_BASELINE_SF 0x02
  188. #define FT_BASELINE_PS 0x42
  189. #define FT_COMPENSATION_SF 0x04
  190. #define FT_COMPENSATION_PS 0x44
  191. #define FT_RAWDATA_W_BL_SF 0x08
  192. #define FT_RAWDATA_W_BL_PS 0x48
  193. #define FT_RAWDATA_WO_BL_SF 0x10
  194. #define FT_RAWDATA_WO_BL_PS 0x50
  195. #define FT_ALG_RAWDATA 0x20
  196. #define FT_PS_SEL 0x40
  197. #define FT_DEBUG_MESSAGE 0x80
  198. #define FT_UPDATE_CASE 0xFE
  199. #define FT_STATUS_PURE_RAW 0x01
  200. #define FT_STATUS_PURE_AF_DC 0x02
  201. typedef enum {
  202. CRC_CHECK_FAIL = 0x80,
  203. CRC_CHECK_PASS = 0x81,
  204. WAIT_TEST_MODE = 0x82,
  205. PARTITION_CRC = 0xA0,
  206. SET_ADDR_READY = 0xA1,
  207. SET_ADDR_FAIL = 0xA2,
  208. WRT_PRAM_DATA = 0xA3,
  209. WRT_PRAM_FAIL = 0xA4,
  210. WAIT_WRT_ACK = 0xA5,
  211. WAIT_ACK_FAIL = 0xA6,
  212. GET_WRT_ACK = 0xA7,
  213. GET_WRT_UNLOCK = 0xA8,
  214. GET_UNLOCK_FAIL = 0xA9,
  215. } I2C_SYNC_CMD;
  216. typedef enum {
  217. MAIN_STATE_NORMAL_MODE = 0,
  218. MAIN_STATE_BURNING_MODE,
  219. MAIN_STATE_FIRWARE_MODE,
  220. } TCH_BOOTLOADER_STATE;
  221. typedef enum {
  222. BURNING_STATE_INIT = 0,
  223. BURNING_CHECK_ADDR,
  224. BURNING_UNLOCK_PRAM,
  225. BURNING_WRT_PRAM,
  226. BURNING_WRT_FLASH_PREPARE,
  227. BURNING_WRT_FLASH_EXCUTE,
  228. BURNING_WRT_FLASH_FINISH,
  229. BURNING_STATE_HALT,
  230. } BL_BURNING_STATE;
  231. typedef enum {
  232. NORMAL_STATE_CHECK = 0,
  233. NORMAL_CRC_CALC,
  234. NORMAL_CRC_NOTIFY,
  235. NORMAL_FW_CRC,
  236. NORMAL_MODE_CHANGE,
  237. NORMAL_MODE_IDLE,
  238. } BL_NORMAL_STATE;