drv_i2c.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /* Copyright (c) 2023, Canaan Bright Sight Co., Ltd
  2. *
  3. * Redistribution and use in source and binary forms, with or without
  4. * modification, are permitted provided that the following conditions are met:
  5. * 1. Redistributions of source code must retain the above copyright
  6. * notice, this list of conditions and the following disclaimer.
  7. * 2. Redistributions in binary form must reproduce the above copyright
  8. * notice, this list of conditions and the following disclaimer in the
  9. * documentation and/or other materials provided with the distribution.
  10. *
  11. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  12. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  13. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  15. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  16. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  18. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  19. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  20. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  21. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  22. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. /*
  26. * Copyright (c) 2006-2025 RT-Thread Development Team
  27. *
  28. * SPDX-License-Identifier: Apache-2.0
  29. */
  30. #ifndef __DRV_I2C_H__
  31. #define __DRV_I2C_H__
  32. #include <stdint.h>
  33. #define BIT(x) (1<<(x))
  34. /* Speed Selection */
  35. #define I2C_SPEED_MODE_STANDARD 1
  36. #define I2C_SPEED_MODE_FAST 2
  37. #define I2C_SPEED_MODE_MAX 3
  38. #define I2C_MAX_SPEED_UP 3400000
  39. #define I2C_FAST_SPEED_UP 1000000
  40. #define I2C_STANDARD_SPEED_UP 100000
  41. #define I2C_DEFAULT_SPEED 400000
  42. #define I2C_DEFAULT_TIMEOUT 8 /* 8ms */
  43. /* i2c data cmd definition */
  44. #define I2C_DATA_CMD_READ BIT(8)
  45. #define I2C_DATA_CMD_STOP BIT(9)
  46. #define I2C_DATA_CMD_RESTART BIT(10)
  47. #define I2C_DATA_CMD_FIRST_DATA_BYTE BIT(11)
  48. /* i2c fifo size */
  49. #define I2C_TX_FIFO_SIZE 32 /* 32 * 32bit */
  50. #define I2C_RX_FIFO_SIZE 32 /* 64 * 8bit */
  51. /* fifo threshold register definitions */
  52. #define I2C_TL0 0x00
  53. #define I2C_TL1 0x01
  54. #define I2C_TL2 0x02
  55. #define I2C_TL3 0x03
  56. #define I2C_TL4 0x04
  57. #define I2C_TL5 0x05
  58. #define I2C_TL6 0x06
  59. #define I2C_TL7 0x07
  60. #define I2C_RX_TL I2C_TL0
  61. #define I2C_TX_TL I2C_TL0
  62. /* i2c control register(offset address 0x00) */
  63. typedef struct _i2c_ic_con
  64. {
  65. uint32_t master_mode : 1;
  66. uint32_t speed : 2;
  67. uint32_t slave_10bit_addr : 1;
  68. uint32_t master_10bit_addr : 1;
  69. uint32_t restart_en : 1;
  70. uint32_t slave_disable : 1;
  71. uint32_t stop_det_ifaddressed : 1;
  72. uint32_t tx_empty_ctrl : 1;
  73. uint32_t rx_fifo_full_hld_ctrl : 1;
  74. uint32_t stop_det_if_master_active : 1;
  75. uint32_t bus_clear_feature_ctrl : 1;
  76. uint32_t rsvd_1 : 4; /* reserved */
  77. uint32_t optional_sar_ctrl : 1;
  78. uint32_t smbus_slave_quick_en : 1;
  79. uint32_t smbus_arp_en : 1;
  80. uint32_t smbus_persisent_slv_addr_en : 1;
  81. uint32_t rsvd_2 : 12; /* reserved */
  82. } __attribute__((packed, aligned(4))) i2c_ic_con_t;
  83. /* i2c target address register(offset address 0x04) */
  84. typedef struct _i2c_ic_tar
  85. {
  86. uint32_t tar : 10;
  87. uint32_t gc_or_start : 1;
  88. uint32_t special : 1;
  89. uint32_t master_10bit_addr : 1;
  90. uint32_t device_id : 1;
  91. uint32_t rsvd_1 : 2; /* reserved */
  92. uint32_t smbus_quick_cmd : 1;
  93. uint32_t rsvd_2 : 15; /* reserved */
  94. } __attribute__((packed, aligned(4))) i2c_ic_tar_t;
  95. /* i2c slave address register(offset address 0x08) */
  96. typedef struct _i2c_ic_sar
  97. {
  98. uint32_t sar : 10;
  99. uint32_t rsvd : 22; /* reserved */
  100. } __attribute__((packed, aligned(4))) i2c_ic_sar_t;
  101. /* i2c high speed master mode code address register(offset address 0x0c) */
  102. typedef struct _i2c_ic_hs_maddr
  103. {
  104. uint32_t mar : 3;
  105. uint32_t rsvd : 29; /* reserved */
  106. } __attribute__((packed, aligned(4))) i2c_ic_hs_maddr_t;
  107. /* i2c rx/tx data buffer and command register(offset address 0x10) */
  108. typedef struct _i2c_ic_data_cmd
  109. {
  110. uint32_t dat : 8;
  111. uint32_t cmd : 1;
  112. uint32_t stop : 1;
  113. uint32_t restart : 1;
  114. uint32_t first_data_byte : 1;
  115. uint32_t rsvd : 20; /* reserved */
  116. } __attribute__((packed, aligned(4))) i2c_ic_data_cmd_t;
  117. /* i2c standard/ultra-fast speed clock scl high count register(offset address 0x14) */
  118. typedef struct _i2c_ic_ss_ufm_scl_hcnt
  119. {
  120. uint32_t cnt : 16;
  121. uint32_t rsvd : 16; /* reserved */
  122. } __attribute__((packed, aligned(4))) i2c_ic_ss_ufm_scl_hcnt_t;
  123. /* i2c standard/ultra-fast speed clock scl low count register(offset address 0x18) */
  124. typedef struct _i2c_ic_ss_ufm_scl_lcnt
  125. {
  126. uint32_t cnt : 16;
  127. uint32_t rsvd : 16; /* reserved */
  128. } __attribute__((packed, aligned(4))) i2c_ic_ss_ufm_scl_lcnt_t;
  129. /* i2c fast mode speed clock scl low count/ultra-fast mode speed tbuf idle count register(offset address 0x1c) */
  130. typedef struct _i2c_ic_fs_scl_hcnt_ufm_tbuf_cnt
  131. {
  132. uint32_t cnt : 16;
  133. uint32_t rsvd : 16; /* reserved */
  134. } __attribute__((packed, aligned(4))) i2c_ic_fs_scl_hcnt_ufm_tbuf_cnt_t;
  135. /* i2c fast mode clock scl low count register(offset address 0x20) */
  136. typedef struct _i2c_ic_fs_scl_lcnt
  137. {
  138. uint32_t cnt : 16;
  139. uint32_t rsvd : 16; /* reserved */
  140. } __attribute__((packed, aligned(4))) i2c_ic_fs_scl_lcnt_t;
  141. /* i2c high speed mode clock scl high count register(offset address 0x24) */
  142. typedef struct _i2c_ic_hs_scl_hcnt
  143. {
  144. uint32_t cnt : 16;
  145. uint32_t rsvd : 16; /* reserved */
  146. } __attribute__((packed, aligned(4))) i2c_ic_hs_scl_hcnt_t;
  147. /* i2c high speed mode clock scl low count register(offset address 0x28) */
  148. typedef struct _i2c_ic_hs_scl_lcnt
  149. {
  150. uint32_t cnt : 16;
  151. uint32_t rsvd : 16; /* reserved */
  152. } __attribute__((packed, aligned(4))) i2c_ic_hs_scl_lcnt_t;
  153. /* i2c interrupt status register(offset address 0x2c) */
  154. typedef struct _i2c_ic_intr_stat
  155. {
  156. uint32_t r_rx_under : 1;
  157. uint32_t r_rx_over : 1;
  158. uint32_t r_rx_full : 1;
  159. uint32_t r_tx_over : 1;
  160. uint32_t r_tx_empty : 1;
  161. uint32_t r_rd_req : 1;
  162. uint32_t r_tx_abrt : 1;
  163. uint32_t r_rx_done : 1;
  164. uint32_t r_activity : 1;
  165. uint32_t r_stop_det : 1;
  166. uint32_t r_start_det : 1;
  167. uint32_t r_gen_call : 1;
  168. uint32_t r_restart_det : 1;
  169. uint32_t r_master_on_hold : 1;
  170. uint32_t r_slc_stuck_at_low : 1;
  171. uint32_t rsvd : 17; /* reserved */
  172. } __attribute__((packed, aligned(4))) i2c_ic_intr_stat_t;
  173. /* i2c interrupt mask register(offset address 0x30) */
  174. typedef struct _i2c_ic_intr_mask
  175. {
  176. uint32_t m_rx_under : 1;
  177. uint32_t m_rx_over : 1;
  178. uint32_t m_rx_full : 1;
  179. uint32_t m_tx_over : 1;
  180. uint32_t m_tx_empty : 1;
  181. uint32_t m_rd_req : 1;
  182. uint32_t m_tx_abrt : 1;
  183. uint32_t m_rx_done : 1;
  184. uint32_t m_activity : 1;
  185. uint32_t m_stop_det : 1;
  186. uint32_t m_start_det : 1;
  187. uint32_t m_gen_call : 1;
  188. uint32_t m_restart_det : 1;
  189. uint32_t m_master_on_hold : 1;
  190. uint32_t m_slc_stuck_at_low : 1;
  191. uint32_t rsvd : 17; /* reserved */
  192. } __attribute__((packed, aligned(4))) i2c_ic_intr_mask_t;
  193. /* i2c raw interrupt status register(offset address 0x34) */
  194. typedef struct _i2c_ic_raw_intr_stat
  195. {
  196. uint32_t rx_under : 1;
  197. uint32_t rx_over : 1;
  198. uint32_t rx_full : 1;
  199. uint32_t tx_over : 1;
  200. uint32_t tx_empty : 1;
  201. uint32_t rd_req : 1;
  202. uint32_t tx_abrt : 1;
  203. uint32_t rx_done : 1;
  204. uint32_t activity : 1;
  205. uint32_t stop_det : 1;
  206. uint32_t start_det : 1;
  207. uint32_t gen_call : 1;
  208. uint32_t restart_det : 1;
  209. uint32_t master_on_hold : 1;
  210. uint32_t scl_stuck_at_low : 1;
  211. uint32_t rsvd : 17; /* reserved */
  212. } __attribute__((packed, aligned(4))) i2c_ic_raw_intr_stat_t;
  213. /* i2c receive FIFO threshold register(offset address 0x38) */
  214. typedef struct _i2c_ic_rx_tl
  215. {
  216. uint32_t tl : 8;
  217. uint32_t rsvd : 24; /* reserved */
  218. } __attribute__((packed, aligned(4))) i2c_ic_rx_tl_t;
  219. /* i2c transmit FIFO threshold register(offset address 0x3c) */
  220. typedef struct _i2c_ic_tx_tl
  221. {
  222. uint32_t tl : 8;
  223. uint32_t rsvd : 24; /* reserved */
  224. } __attribute__((packed, aligned(4))) i2c_ic_tx_tl_t;
  225. /* i2c clear combined and individual interrupt register(offset address 0x40) */
  226. typedef struct _i2c_ic_clr_intr
  227. {
  228. uint32_t clr : 1;
  229. uint32_t rsvd : 31; /* reserved */
  230. } __attribute__((packed, aligned(4))) i2c_ic_clr_intr_t;
  231. /* i2c clear rx under interrupt register(offset address 0x44) */
  232. typedef struct _i2c_ic_clr_rx_under
  233. {
  234. uint32_t clr : 1;
  235. uint32_t rsvd : 31; /* reserved */
  236. } __attribute__((packed, aligned(4))) i2c_ic_clr_rx_under_t;
  237. /* i2c clear rx over interrupt register(offset address 0x48) */
  238. typedef struct _i2c_ic_clr_rx_over
  239. {
  240. uint32_t clr : 1;
  241. uint32_t rsvd : 31; /* reserved */
  242. } __attribute__((packed, aligned(4))) i2c_ic_clr_rx_over_t;
  243. /* i2c clear tx over interrupt register(offset address 0x4c) */
  244. typedef struct _i2c_ic_clr_tx_over
  245. {
  246. uint32_t clr : 1;
  247. uint32_t rsvd : 31; /* reserved */
  248. } __attribute__((packed, aligned(4))) i2c_ic_clr_tx_over_t;
  249. /* i2c clear rd req interrupt register(offset address 0x50) */
  250. typedef struct _i2c_ic_clr_rd_req
  251. {
  252. uint32_t clr : 1;
  253. uint32_t rsvd : 31; /* reserved */
  254. } __attribute__((packed, aligned(4))) i2c_ic_clr_rd_req_t;
  255. /* i2c clear tx abrt interrupt register(offset address 0x54) */
  256. typedef struct _i2c_ic_clr_tx_abrt
  257. {
  258. uint32_t clr : 1;
  259. uint32_t rsvd : 31; /* reserved */
  260. } __attribute__((packed, aligned(4))) i2c_ic_clr_tx_abrt_t;
  261. /* i2c clear rx done interrupt register(offset address 0x58) */
  262. typedef struct _i2c_ic_clr_rx_done
  263. {
  264. uint32_t clr : 1;
  265. uint32_t rsvd : 31; /* reserved */
  266. } __attribute__((packed, aligned(4))) i2c_ic_clr_rx_done_t;
  267. /* i2c clear activity interrupt register(offset address 0x5c) */
  268. typedef struct _i2c_ic_clr_activity
  269. {
  270. uint32_t clr : 1;
  271. uint32_t rsvd : 31; /* reserved */
  272. } __attribute__((packed, aligned(4))) i2c_ic_clr_activity_t;
  273. /* i2c clear stop det interrupt register(offset address 0x60) */
  274. typedef struct _i2c_clr_stop_det
  275. {
  276. uint32_t clr : 1;
  277. uint32_t rsvd : 31; /* reserved */
  278. } __attribute__((packed, aligned(4))) i2c_ic_clr_stop_det_t;
  279. /* i2c clear start det interrupt register(offset address 0x64) */
  280. typedef struct _i2c_ic_clr_start_det
  281. {
  282. uint32_t clr : 1;
  283. uint32_t rsvd : 31; /* reserved */
  284. } __attribute__((packed, aligned(4))) i2c_ic_clr_start_det_t;
  285. /* i2c clear gen call interrupt register(offset address 0x68) */
  286. typedef struct _i2c_ic_clr_gen_call
  287. {
  288. uint32_t clr : 1;
  289. uint32_t rsvd : 31; /* reserved */
  290. } __attribute__((packed, aligned(4))) i2c_ic_clr_gen_call_t;
  291. /* i2c enable register(offset address 0x6c) */
  292. typedef struct _i2c_ic_enable
  293. {
  294. uint32_t enable : 1;
  295. uint32_t abort : 1;
  296. uint32_t tx_cmd_block : 1;
  297. uint32_t sda_stuck_recovery_enable : 1;
  298. uint32_t rsvd_1 : 12; /* reserved */
  299. uint32_t smbus_clk_reset : 1;
  300. uint32_t smbus_suspned_en : 1;
  301. uint32_t smbus_alert_en : 1;
  302. uint32_t rsvd_2 : 13; /* reserved */
  303. } __attribute__((packed, aligned(4))) i2c_ic_enable_t;
  304. /* i2c status register(offset address 0x70) */
  305. typedef struct _i2c_ic_status
  306. {
  307. uint32_t activity : 1;
  308. uint32_t tfnf : 1;
  309. uint32_t tfe : 1;
  310. uint32_t rfne : 1;
  311. uint32_t rff : 1;
  312. uint32_t mst_activity : 1;
  313. uint32_t slv_activity : 1;
  314. uint32_t mst_hold_tx_fifo_empty : 1;
  315. uint32_t mst_hold_rx_fifo_full : 1;
  316. uint32_t slv_hold_tx_fifo_empty : 1;
  317. uint32_t slv_hold_rx_fifo_full : 1;
  318. uint32_t sda_stuck_not_recovered : 1;
  319. uint32_t rsvd_1 : 4; /* reserved */
  320. uint32_t smbus_quick_cmd_bit : 1;
  321. uint32_t smbus_slave_addr_valid : 1;
  322. uint32_t smbus_slave_addr_resolved : 1;
  323. uint32_t smbus_suspend_status : 1;
  324. uint32_t smbus_alert : 1;
  325. uint32_t rsvd_2 : 11; /* reserved */
  326. } __attribute__((packed, aligned(4))) i2c_ic_status_t;
  327. /* i2c transmit fifo level register(offset address 0x74) */
  328. typedef struct _i2c_ic_txflr
  329. {
  330. uint32_t txflr : 5;
  331. uint32_t rsvd : 27; /* reserved */
  332. } __attribute__((packed, aligned(4))) i2c_ic_txflr_t;
  333. /* i2c receive fifo level register(offset address 0x78) */
  334. typedef struct _i2c_ic_rxflr
  335. {
  336. uint32_t rxflr : 5;
  337. uint32_t rsvd : 27; /* reserved */
  338. } __attribute__((packed, aligned(4))) i2c_ic_rxflr_t;
  339. /* i2c sda hold time length register(offset address 0x7c) */
  340. typedef struct _i2c_ic_sda_hold
  341. {
  342. uint32_t tx_hold : 16;
  343. uint32_t rx_hold : 8;
  344. uint32_t rsvd : 8; /* reserved */
  345. } __attribute__((packed, aligned(4))) i2c_ic_sda_hold_t;
  346. /* i2c transmit abort source register(offset address 0x80) */
  347. typedef struct _i2c_ic_tx_abrt_source
  348. {
  349. uint32_t abrt_7b_addr_noack : 1;
  350. uint32_t abrt_10addr1_noack : 1;
  351. uint32_t abrt_10addr2_noack : 1;
  352. uint32_t abrt_txdata_noack : 1;
  353. uint32_t abrt_gcall_noack : 1;
  354. uint32_t abrt_gcall_read : 1;
  355. uint32_t abrt_hs_ackdet : 1;
  356. uint32_t abrt_sbyte_ackdet : 1;
  357. uint32_t abrt_hs_norstrt : 1;
  358. uint32_t abrt_sbyte_norstrt : 1;
  359. uint32_t abrt_10b_rd_norstrt : 1;
  360. uint32_t abrt_master_dis : 1;
  361. uint32_t abrt_lost : 1;
  362. uint32_t abrt_slvflush_txfifo : 1;
  363. uint32_t abrt_slv_arblost : 1;
  364. uint32_t abrt_slvrd_intx : 1;
  365. uint32_t abrt_user_abrt : 1;
  366. uint32_t abrt_sda_stuck_at_low : 1;
  367. uint32_t abrt_device_noack : 1;
  368. uint32_t abrt_device_slvaddr_noack : 1;
  369. uint32_t abrt_device_write : 1;
  370. uint32_t rsvd : 2; /* reserved */
  371. uint32_t tx_flush_cnt : 9;
  372. } __attribute__((packed, aligned(4))) i2c_ic_tx_abrt_source_t;
  373. /* i2c generate slave data nack register(offset address 0x84) */
  374. typedef struct _i2c_ic_slv_data_nack_only
  375. {
  376. uint32_t nack : 1;
  377. uint32_t rsvd : 31; /* reserved */
  378. } __attribute__((packed, aligned(4))) i2c_ic_slv_data_nack_only_t;
  379. /* i2c dma control register(offset address 0x88) */
  380. typedef struct _i2c_ic_dma_cr
  381. {
  382. uint32_t rdmae : 1;
  383. uint32_t tdmae : 1;
  384. uint32_t rsvd : 30; /* reserved */
  385. } __attribute__((packed, aligned(4))) i2c_ic_dma_cr_t;
  386. /* i2c dma transmit data level register(offset address 0x8c) */
  387. typedef struct _i2c_ic_dma_tdlr
  388. {
  389. uint32_t dmatdl : 5;
  390. uint32_t rsvd : 27; /* reserved */
  391. } __attribute__((packed, aligned(4))) i2c_ic_dma_tdlr_t;
  392. /* i2c dma receive data level register(offset address 0x90) */
  393. typedef struct _i2c_ic_dma_rdlr
  394. {
  395. uint32_t dmardl : 5;
  396. uint32_t rsvd : 27; /* reserved */
  397. } __attribute__((packed, aligned(4))) i2c_ic_dma_rdlr_t;
  398. /* i2c sda setup register(offset address 0x94) */
  399. typedef struct _i2c_ic_sda_setup
  400. {
  401. uint32_t setup : 8;
  402. uint32_t rsvd : 24; /* reserved */
  403. } __attribute__((packed, aligned(4))) i2c_ic_sda_setup_t;
  404. /* i2c ack general call register(offset address 0x98) */
  405. typedef struct _i2c_ic_ack_general_call
  406. {
  407. uint32_t ask : 1;
  408. uint32_t rsvd : 31; /* reserved */
  409. } __attribute__((packed, aligned(4))) i2c_ic_ack_general_call_t;
  410. /* i2c enable status register(offset address 0x9c) */
  411. typedef struct _i2c_ic_enable_status
  412. {
  413. uint32_t en : 1;
  414. uint32_t slv_disabled_while_busy : 1;
  415. uint32_t slv_rx_data_lost : 1;
  416. uint32_t rsvd : 29; /* reserved */
  417. } __attribute__((packed, aligned(4))) i2c_ic_enable_status_t;
  418. /* i2c ss, fs, or fm+/ufm spike suppression limit register(offset address 0xa0) */
  419. typedef struct _i2c_ic_fs_ufm_spklen
  420. {
  421. uint32_t spklen : 8;
  422. uint32_t rsvd : 24; /* reserved */
  423. } __attribute__((packed, aligned(4))) i2c_ic_fs_ufm_spklen_t;
  424. /* i2c hs spike suppression limit register(offset address 0xa4) */
  425. typedef struct _i2c_ic_hs_spklen
  426. {
  427. uint32_t spklen : 8;
  428. uint32_t rsvd : 24; /* reserved */
  429. } __attribute__((packed, aligned(4))) i2c_ic_hs_spklen_t;
  430. /* i2c clear restart det interrupt register(offset address 0xa8) */
  431. typedef struct _i2c_ic_clr_restart_det
  432. {
  433. uint32_t clr : 1;
  434. uint32_t rsvd : 31; /* reserved */
  435. } __attribute__((packed, aligned(4))) i2c_ic_clr_restart_det_t;
  436. /* i2c scl stuck at low timeout register(offset address 0xac) */
  437. typedef struct _i2c_ic_scl_stuck_at_low_timeout
  438. {
  439. uint32_t timeout : 32;
  440. } __attribute__((packed, aligned(4))) i2c_ic_scl_stuck_at_low_timeout_t;
  441. /* i2c sda stuck at low timeout register(offset address 0xb0) */
  442. typedef struct _i2c_ic_sda_stuck_at_low_timeout
  443. {
  444. uint32_t timeout : 32;
  445. } __attribute__((packed, aligned(4))) i2c_ic_sda_stuck_at_low_timeout_t;
  446. /* i2c clear scl stuck at low detect interrupt register(offset address 0xb4) */
  447. typedef struct _i2c_ic_clr_slc_stuck_det
  448. {
  449. uint32_t clr : 1;
  450. uint32_t rsvd : 31; /* reserved */
  451. } __attribute__((packed, aligned(4))) i2c_ic_clr_slc_stuck_det_t;
  452. /* i2c device id register(offset address 0xb8) */
  453. typedef struct _i2c_ic_device_id
  454. {
  455. uint32_t device_id : 24;
  456. uint32_t rsvd : 8; /* reserved */
  457. } __attribute__((packed, aligned(4))) i2c_ic_device_id_t;
  458. /* i2c smbus slave clock extend timeout register(offset address 0xbc) */
  459. typedef struct _i2c_ic_smbus_clk_low_sext
  460. {
  461. uint32_t timeout : 32;
  462. } __attribute__((packed, aligned(4))) i2c_ic_smbus_clk_low_sext_t;
  463. /* i2c smbus master clock extend timeout register(offset address 0xc0) */
  464. typedef struct _i2c_ic_smbus_clk_low_mext
  465. {
  466. uint32_t timeout : 32;
  467. } __attribute__((packed, aligned(4))) i2c_ic_smbus_clk_low_mext_t;
  468. /* i2c smbus master thigh max bus-idle count register(offset address 0xc4) */
  469. typedef struct _i2c_ic_smbus_thigh_max_idle_count
  470. {
  471. uint32_t cnt : 16;
  472. uint32_t rsvd : 16; /* reserved */
  473. } __attribute__((packed, aligned(4))) i2c_ic_smbus_thigh_max_idle_count_t;
  474. /* i2c smbus interrupt status register(offset address 0xc8) */
  475. typedef struct _i2c_ic_smbus_intr_stat
  476. {
  477. uint32_t r_slv_clock_extnd_timeout : 1;
  478. uint32_t r_mst_clock_extnd_timeout : 1;
  479. uint32_t r_quick_cmd_det : 1;
  480. uint32_t r_host_notify_mst_det : 1;
  481. uint32_t r_arp_prepare_cmd_det : 1;
  482. uint32_t r_arp_rst_cmd_det : 1;
  483. uint32_t r_arp_get_udid_cmd_det : 1;
  484. uint32_t r_arp_assgn_addr_cmd_det : 1;
  485. uint32_t r_slv_rx_pec_nack : 1;
  486. uint32_t r_smbus_suspend_det : 1;
  487. uint32_t r_smbus_alert_det : 1;
  488. uint32_t rsvd : 21; /* reserved */
  489. } __attribute__((packed, aligned(4))) i2c_ic_smbus_intr_stat_t;
  490. /* i2c smbus interrupt mask register(offset address 0xcc) */
  491. typedef struct _i2c_ic_smbus_intr_mask
  492. {
  493. uint32_t m_slv_clock_extnd_timeout : 1;
  494. uint32_t m_mst_clock_extnd_timeout : 1;
  495. uint32_t m_quick_cmd_det : 1;
  496. uint32_t m_host_notify_mst_det : 1;
  497. uint32_t m_arp_prepare_cmd_det : 1;
  498. uint32_t m_arp_rst_cmd_det : 1;
  499. uint32_t m_arp_get_udid_cmd_det : 1;
  500. uint32_t m_arp_assgn_addr_cmd_det : 1;
  501. uint32_t m_slv_rx_pec_nack : 1;
  502. uint32_t m_smbus_suspend_det : 1;
  503. uint32_t m_smbus_alert_det : 1;
  504. uint32_t rsvd : 21; /* reserved */
  505. } __attribute__((packed, aligned(4))) i2c_ic_smbus_intr_mask_t;
  506. /* i2c smbus raw interrupt status register(offset address 0xd0) */
  507. typedef struct _i2c_ic_smbus_raw_intr_stat
  508. {
  509. uint32_t slv_clock_extnd_timeout : 1;
  510. uint32_t mst_clock_extnd_timeout : 1;
  511. uint32_t quick_cmd_det : 1;
  512. uint32_t host_notify_mst_det : 1;
  513. uint32_t arp_prepare_cmd_det : 1;
  514. uint32_t arp_rst_cmd_det : 1;
  515. uint32_t arp_get_udid_cmd_det : 1;
  516. uint32_t arp_assgn_addr_cmd_det : 1;
  517. uint32_t slv_rx_pec_nack : 1;
  518. uint32_t smbus_suspend_det : 1;
  519. uint32_t smbus_alert_det : 1;
  520. uint32_t rsvd : 21; /* reserved */
  521. } __attribute__((packed, aligned(4))) i2c_ic_smbus_raw_intr_stat_t;
  522. /* i2c smbus clear interrupt register(offset address 0xd4) */
  523. typedef struct _i2c_ic_clr_smbus_intr
  524. {
  525. uint32_t slv_clock_extnd_timeout : 1;
  526. uint32_t mst_clock_extnd_timeout : 1;
  527. uint32_t quick_cmd_det : 1;
  528. uint32_t host_notify_mst_det : 1;
  529. uint32_t arp_prepare_cmd_det : 1;
  530. uint32_t arp_rst_cmd_det : 1;
  531. uint32_t arp_get_udid_cmd_det : 1;
  532. uint32_t arp_assgn_addr_cmd_det : 1;
  533. uint32_t slv_rx_pec_nack : 1;
  534. uint32_t smbus_suspend_det : 1;
  535. uint32_t smbus_alert_det : 1;
  536. uint32_t rsvd : 21; /* reserved */
  537. } __attribute__((packed, aligned(4))) i2c_ic_clr_smbus_intr_t;
  538. /* i2c optional slave address register(offset address 0xd8) */
  539. typedef struct _i2c_ic_optional_sar
  540. {
  541. uint32_t sar : 7;
  542. uint32_t rsvd : 25; /* reserved */
  543. } __attribute__((packed, aligned(4))) i2c_ic_optional_sar_t;
  544. /* i2c smbus udid lsb register(offset address 0xdc) */
  545. typedef struct _i2c_ic_smbus_udid_lsb
  546. {
  547. uint32_t udid_lsb : 32;
  548. } __attribute__((packed, aligned(4))) i2c_ic_smbus_udid_lsb_t;
  549. /* i2c component parameter 1 register(offset address 0xf4) */
  550. typedef struct _i2c_ic_comp_param_1
  551. {
  552. uint32_t apb_data_width : 2;
  553. uint32_t max_speed_mode : 2;
  554. uint32_t hc_count_values : 1;
  555. uint32_t intr_io : 1;
  556. uint32_t has_dma : 1;
  557. uint32_t add_encoded_params : 1;
  558. uint32_t rx_buffer_depth : 8;
  559. uint32_t tx_buffer_depth : 8;
  560. uint32_t rsvd : 8; /* reserved */
  561. } __attribute__((packed, aligned(4))) i2c_ic_comp_param_1_t;
  562. /* i2c component version register(offset address 0xf8) */
  563. typedef struct _i2c_ic_comp_version
  564. {
  565. uint32_t version : 32;
  566. } __attribute__((packed, aligned(4))) i2c_ic_comp_version_t;
  567. /* i2c component type register(offset address 0xfc) */
  568. typedef struct _i2c_ic_comp_type
  569. {
  570. uint32_t type : 32;
  571. } __attribute__((packed, aligned(4))) i2c_ic_comp_type_t;
  572. /* i2c register */
  573. typedef struct _i2c
  574. {
  575. i2c_ic_con_t con; /* 0x00 */
  576. i2c_ic_tar_t tar; /* 0x04 */
  577. i2c_ic_sar_t sar; /* 0x08 */
  578. i2c_ic_hs_maddr_t hs_maddr; /* 0x0c */
  579. i2c_ic_data_cmd_t data_cmd; /* 0x10 */
  580. i2c_ic_ss_ufm_scl_hcnt_t ss_ufm_scl_hcnt; /* 0x14 */
  581. i2c_ic_ss_ufm_scl_lcnt_t ss_ufm_scl_lcnt; /* 0x18 */
  582. i2c_ic_fs_scl_hcnt_ufm_tbuf_cnt_t fs_scl_hcnt_ufm_tbuf_cnt; /* 0x1c */
  583. i2c_ic_fs_scl_lcnt_t fs_scl_lcnt; /* 0x20 */
  584. i2c_ic_hs_scl_hcnt_t hs_scl_hcnt; /* 0x24 */
  585. i2c_ic_hs_scl_lcnt_t hs_scl_lcnt; /* 0x28 */
  586. i2c_ic_intr_stat_t intr_stat; /* 0x2c */
  587. i2c_ic_intr_mask_t intr_mask; /* 0x30 */
  588. i2c_ic_raw_intr_stat_t raw_intr_stat; /* 0x34 */
  589. i2c_ic_rx_tl_t rx_tl; /* 0x38 */
  590. i2c_ic_tx_tl_t tx_tl; /* 0x3c */
  591. i2c_ic_clr_intr_t clr_intr; /* 0x40 */
  592. i2c_ic_clr_rx_under_t clr_rx_under; /* 0x44 */
  593. i2c_ic_clr_rx_over_t clr_rx_over; /* 0x48 */
  594. i2c_ic_clr_tx_over_t clr_tx_over; /* 0x4c */
  595. i2c_ic_clr_rd_req_t clr_rd_req; /* 0x50 */
  596. i2c_ic_clr_tx_abrt_t clr_tx_abrt; /* 0x54 */
  597. i2c_ic_clr_rx_done_t clr_rx_done; /* 0x58 */
  598. i2c_ic_clr_activity_t clr_activity; /* 0x5c */
  599. i2c_ic_clr_stop_det_t clr_stop_det; /* 0x60 */
  600. i2c_ic_clr_start_det_t clr_start_det; /* 0x64 */
  601. i2c_ic_clr_gen_call_t clr_gen_call; /* 0x68 */
  602. i2c_ic_enable_t enable; /* 0x6c */
  603. i2c_ic_status_t status; /* 0x70 */
  604. i2c_ic_txflr_t txflr; /* 0x74 */
  605. i2c_ic_rxflr_t rxflr; /* 0x78 */
  606. i2c_ic_sda_hold_t sda_hold; /* 0x7c */
  607. i2c_ic_tx_abrt_source_t tx_abrt_source; /* 0x80 */
  608. i2c_ic_slv_data_nack_only_t slv_data_nack_only; /* 0x84 */
  609. i2c_ic_dma_cr_t dma_cr; /* 0x88 */
  610. i2c_ic_dma_tdlr_t dma_tdlr; /* 0x8c */
  611. i2c_ic_dma_rdlr_t dma_rdlr; /* 0x90 */
  612. i2c_ic_sda_setup_t sda_setup; /* 0x94 */
  613. i2c_ic_ack_general_call_t ack_general_call; /* 0x98 */
  614. i2c_ic_enable_status_t enable_status; /* 0x9c */
  615. i2c_ic_fs_ufm_spklen_t fs_ufm_spklen; /* 0xa0 */
  616. i2c_ic_hs_spklen_t hs_spklen; /* 0xa4 */
  617. i2c_ic_clr_restart_det_t clr_restart_det; /* 0xa8 */
  618. i2c_ic_scl_stuck_at_low_timeout_t scl_stuck_at_low_timeout; /* 0xac */
  619. i2c_ic_sda_stuck_at_low_timeout_t sda_stuck_at_low_timeout; /* 0xb0 */
  620. i2c_ic_clr_slc_stuck_det_t clr_slc_stuck_det; /* 0xb4 */
  621. i2c_ic_device_id_t device_id; /* 0xb8 */
  622. i2c_ic_smbus_clk_low_sext_t smbus_clk_low_sext; /* 0xbc */
  623. i2c_ic_smbus_clk_low_mext_t smbus_clk_low_mext; /* 0xc0 */
  624. i2c_ic_smbus_thigh_max_idle_count_t smbus_thigh_max_idle_count; /* 0xc4 */
  625. i2c_ic_smbus_intr_stat_t smbus_intr_stat; /* 0xc8 */
  626. i2c_ic_smbus_intr_mask_t smbus_intr_mask; /* 0xcc */
  627. i2c_ic_smbus_raw_intr_stat_t smbus_raw_intr_stat; /* 0xd0 */
  628. i2c_ic_clr_smbus_intr_t clr_smbus_intr; /* 0xd4 */
  629. i2c_ic_optional_sar_t optional_sar; /* 0xd8 */
  630. i2c_ic_smbus_udid_lsb_t smbus_udid_lsb; /* 0xdc */
  631. uint32_t rsvd_1[5]; /* 0xe0-0xf0 reserved */
  632. i2c_ic_comp_param_1_t comp_param_1; /* 0xf4 */
  633. i2c_ic_comp_version_t comp_version; /* 0xf8 */
  634. i2c_ic_comp_type_t comp_type; /* 0xfc */
  635. } __attribute__((packed, aligned(4))) i2c_t;
  636. #endif /* __DRV_I2C_H__ */