1use kernel::utilities::registers::ReadWrite;
13use kernel::utilities::registers::{register_bitfields, register_structs};
14pub const I2C_PARAM_FIFO_DEPTH: u32 = 64;
16pub const I2C_PARAM_NUM_ALERTS: u32 = 1;
18pub const I2C_PARAM_REG_WIDTH: u32 = 32;
20
21register_structs! {
22 pub I2cRegisters {
23 (0x0000 => pub(crate) intr_state: ReadWrite<u32, INTR::Register>),
25 (0x0004 => pub(crate) intr_enable: ReadWrite<u32, INTR::Register>),
27 (0x0008 => pub(crate) intr_test: ReadWrite<u32, INTR::Register>),
29 (0x000c => pub(crate) alert_test: ReadWrite<u32, ALERT_TEST::Register>),
31 (0x0010 => pub(crate) ctrl: ReadWrite<u32, CTRL::Register>),
33 (0x0014 => pub(crate) status: ReadWrite<u32, STATUS::Register>),
35 (0x0018 => pub(crate) rdata: ReadWrite<u32, RDATA::Register>),
37 (0x001c => pub(crate) fdata: ReadWrite<u32, FDATA::Register>),
39 (0x0020 => pub(crate) fifo_ctrl: ReadWrite<u32, FIFO_CTRL::Register>),
41 (0x0024 => pub(crate) fifo_status: ReadWrite<u32, FIFO_STATUS::Register>),
43 (0x0028 => pub(crate) ovrd: ReadWrite<u32, OVRD::Register>),
45 (0x002c => pub(crate) val: ReadWrite<u32, VAL::Register>),
47 (0x0030 => pub(crate) timing0: ReadWrite<u32, TIMING0::Register>),
49 (0x0034 => pub(crate) timing1: ReadWrite<u32, TIMING1::Register>),
51 (0x0038 => pub(crate) timing2: ReadWrite<u32, TIMING2::Register>),
53 (0x003c => pub(crate) timing3: ReadWrite<u32, TIMING3::Register>),
55 (0x0040 => pub(crate) timing4: ReadWrite<u32, TIMING4::Register>),
57 (0x0044 => pub(crate) timeout_ctrl: ReadWrite<u32, TIMEOUT_CTRL::Register>),
59 (0x0048 => pub(crate) target_id: ReadWrite<u32, TARGET_ID::Register>),
61 (0x004c => pub(crate) acqdata: ReadWrite<u32, ACQDATA::Register>),
63 (0x0050 => pub(crate) txdata: ReadWrite<u32, TXDATA::Register>),
65 (0x0054 => pub(crate) host_timeout_ctrl: ReadWrite<u32, HOST_TIMEOUT_CTRL::Register>),
67 (0x0058 => @END),
68 }
69}
70
71register_bitfields![u32,
72 pub(crate) INTR [
74 FMT_THRESHOLD OFFSET(0) NUMBITS(1) [],
75 RX_THRESHOLD OFFSET(1) NUMBITS(1) [],
76 FMT_OVERFLOW OFFSET(2) NUMBITS(1) [],
77 RX_OVERFLOW OFFSET(3) NUMBITS(1) [],
78 NAK OFFSET(4) NUMBITS(1) [],
79 SCL_INTERFERENCE OFFSET(5) NUMBITS(1) [],
80 SDA_INTERFERENCE OFFSET(6) NUMBITS(1) [],
81 STRETCH_TIMEOUT OFFSET(7) NUMBITS(1) [],
82 SDA_UNSTABLE OFFSET(8) NUMBITS(1) [],
83 CMD_COMPLETE OFFSET(9) NUMBITS(1) [],
84 TX_STRETCH OFFSET(10) NUMBITS(1) [],
85 TX_OVERFLOW OFFSET(11) NUMBITS(1) [],
86 ACQ_FULL OFFSET(12) NUMBITS(1) [],
87 UNEXP_STOP OFFSET(13) NUMBITS(1) [],
88 HOST_TIMEOUT OFFSET(14) NUMBITS(1) [],
89 ],
90 pub(crate) ALERT_TEST [
91 FATAL_FAULT OFFSET(0) NUMBITS(1) [],
92 ],
93 pub(crate) CTRL [
94 ENABLEHOST OFFSET(0) NUMBITS(1) [],
95 ENABLETARGET OFFSET(1) NUMBITS(1) [],
96 LLPBK OFFSET(2) NUMBITS(1) [],
97 ],
98 pub(crate) STATUS [
99 FMTFULL OFFSET(0) NUMBITS(1) [],
100 RXFULL OFFSET(1) NUMBITS(1) [],
101 FMTEMPTY OFFSET(2) NUMBITS(1) [],
102 HOSTIDLE OFFSET(3) NUMBITS(1) [],
103 TARGETIDLE OFFSET(4) NUMBITS(1) [],
104 RXEMPTY OFFSET(5) NUMBITS(1) [],
105 TXFULL OFFSET(6) NUMBITS(1) [],
106 ACQFULL OFFSET(7) NUMBITS(1) [],
107 TXEMPTY OFFSET(8) NUMBITS(1) [],
108 ACQEMPTY OFFSET(9) NUMBITS(1) [],
109 ],
110 pub(crate) RDATA [
111 RDATA OFFSET(0) NUMBITS(8) [],
112 ],
113 pub(crate) FDATA [
114 FBYTE OFFSET(0) NUMBITS(8) [],
115 START OFFSET(8) NUMBITS(1) [],
116 STOP OFFSET(9) NUMBITS(1) [],
117 READ OFFSET(10) NUMBITS(1) [],
118 RCONT OFFSET(11) NUMBITS(1) [],
119 NAKOK OFFSET(12) NUMBITS(1) [],
120 ],
121 pub(crate) FIFO_CTRL [
122 RXRST OFFSET(0) NUMBITS(1) [],
123 FMTRST OFFSET(1) NUMBITS(1) [],
124 RXILVL OFFSET(2) NUMBITS(3) [
125 RXLVL1 = 0,
126 RXLVL4 = 1,
127 RXLVL8 = 2,
128 RXLVL16 = 3,
129 RXLVL30 = 4,
130 ],
131 FMTILVL OFFSET(5) NUMBITS(2) [
132 FMTLVL1 = 0,
133 FMTLVL4 = 1,
134 FMTLVL8 = 2,
135 FMTLVL16 = 3,
136 ],
137 ACQRST OFFSET(7) NUMBITS(1) [],
138 TXRST OFFSET(8) NUMBITS(1) [],
139 ],
140 pub(crate) FIFO_STATUS [
141 FMTLVL OFFSET(0) NUMBITS(7) [],
142 TXLVL OFFSET(8) NUMBITS(7) [],
143 RXLVL OFFSET(16) NUMBITS(7) [],
144 ACQLVL OFFSET(24) NUMBITS(7) [],
145 ],
146 pub(crate) OVRD [
147 TXOVRDEN OFFSET(0) NUMBITS(1) [],
148 SCLVAL OFFSET(1) NUMBITS(1) [],
149 SDAVAL OFFSET(2) NUMBITS(1) [],
150 ],
151 pub(crate) VAL [
152 SCL_RX OFFSET(0) NUMBITS(16) [],
153 SDA_RX OFFSET(16) NUMBITS(16) [],
154 ],
155 pub(crate) TIMING0 [
156 THIGH OFFSET(0) NUMBITS(16) [],
157 TLOW OFFSET(16) NUMBITS(16) [],
158 ],
159 pub(crate) TIMING1 [
160 T_R OFFSET(0) NUMBITS(16) [],
161 T_F OFFSET(16) NUMBITS(16) [],
162 ],
163 pub(crate) TIMING2 [
164 TSU_STA OFFSET(0) NUMBITS(16) [],
165 THD_STA OFFSET(16) NUMBITS(16) [],
166 ],
167 pub(crate) TIMING3 [
168 TSU_DAT OFFSET(0) NUMBITS(16) [],
169 THD_DAT OFFSET(16) NUMBITS(16) [],
170 ],
171 pub(crate) TIMING4 [
172 TSU_STO OFFSET(0) NUMBITS(16) [],
173 T_BUF OFFSET(16) NUMBITS(16) [],
174 ],
175 pub(crate) TIMEOUT_CTRL [
176 VAL OFFSET(0) NUMBITS(31) [],
177 EN OFFSET(31) NUMBITS(1) [],
178 ],
179 pub(crate) TARGET_ID [
180 ADDRESS0 OFFSET(0) NUMBITS(7) [],
181 MASK0 OFFSET(7) NUMBITS(7) [],
182 ADDRESS1 OFFSET(14) NUMBITS(7) [],
183 MASK1 OFFSET(21) NUMBITS(7) [],
184 ],
185 pub(crate) ACQDATA [
186 ABYTE OFFSET(0) NUMBITS(8) [],
187 SIGNAL OFFSET(8) NUMBITS(2) [
188 NONE = 0,
189 START = 1,
190 STOP = 2,
191 RESTART = 3,
192 ],
193 ],
194 pub(crate) TXDATA [
195 TXDATA OFFSET(0) NUMBITS(8) [],
196 ],
197 pub(crate) HOST_TIMEOUT_CTRL [
198 HOST_TIMEOUT_CTRL OFFSET(0) NUMBITS(32) [],
199 ],
200];
201
202