lowrisc/registers/
i2c_regs.rs

1// Licensed under the Apache License, Version 2.0 or the MIT License.
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3// Copyright lowRISC contributors 2023.
4
5// Generated register constants for i2c.
6// Built for Earlgrey-M2.5.1-RC1-493-gedf5e35f5d
7// https://github.com/lowRISC/opentitan/tree/edf5e35f5d50a5377641c90a315109a351de7635
8// Tree status: clean
9// Build date: 2023-10-18T10:11:37
10
11// Original reference file: hw/ip/i2c/data/i2c.hjson
12use kernel::utilities::registers::ReadWrite;
13use kernel::utilities::registers::{register_bitfields, register_structs};
14/// Depth of FMT, RX, TX, and ACQ FIFOs
15pub const I2C_PARAM_FIFO_DEPTH: u32 = 64;
16/// Number of alerts
17pub const I2C_PARAM_NUM_ALERTS: u32 = 1;
18/// Register width
19pub const I2C_PARAM_REG_WIDTH: u32 = 32;
20
21register_structs! {
22    pub I2cRegisters {
23        /// Interrupt State Register
24        (0x0000 => pub(crate) intr_state: ReadWrite<u32, INTR::Register>),
25        /// Interrupt Enable Register
26        (0x0004 => pub(crate) intr_enable: ReadWrite<u32, INTR::Register>),
27        /// Interrupt Test Register
28        (0x0008 => pub(crate) intr_test: ReadWrite<u32, INTR::Register>),
29        /// Alert Test Register
30        (0x000c => pub(crate) alert_test: ReadWrite<u32, ALERT_TEST::Register>),
31        /// I2C Control Register
32        (0x0010 => pub(crate) ctrl: ReadWrite<u32, CTRL::Register>),
33        /// I2C Live Status Register
34        (0x0014 => pub(crate) status: ReadWrite<u32, STATUS::Register>),
35        /// I2C Read Data
36        (0x0018 => pub(crate) rdata: ReadWrite<u32, RDATA::Register>),
37        /// I2C Format Data
38        (0x001c => pub(crate) fdata: ReadWrite<u32, FDATA::Register>),
39        /// I2C FIFO control register
40        (0x0020 => pub(crate) fifo_ctrl: ReadWrite<u32, FIFO_CTRL::Register>),
41        /// I2C FIFO status register
42        (0x0024 => pub(crate) fifo_status: ReadWrite<u32, FIFO_STATUS::Register>),
43        /// I2C Override Control Register
44        (0x0028 => pub(crate) ovrd: ReadWrite<u32, OVRD::Register>),
45        /// Oversampled RX values
46        (0x002c => pub(crate) val: ReadWrite<u32, VAL::Register>),
47        /// Detailed I2C Timings (directly corresponding to table 10 in the I2C Specification).
48        (0x0030 => pub(crate) timing0: ReadWrite<u32, TIMING0::Register>),
49        /// Detailed I2C Timings (directly corresponding to table 10 in the I2C Specification).
50        (0x0034 => pub(crate) timing1: ReadWrite<u32, TIMING1::Register>),
51        /// Detailed I2C Timings (directly corresponding to table 10 in the I2C Specification).
52        (0x0038 => pub(crate) timing2: ReadWrite<u32, TIMING2::Register>),
53        /// Detailed I2C Timings (directly corresponding to table 10, in the I2C Specification).
54        (0x003c => pub(crate) timing3: ReadWrite<u32, TIMING3::Register>),
55        /// Detailed I2C Timings (directly corresponding to table 10, in the I2C Specification).
56        (0x0040 => pub(crate) timing4: ReadWrite<u32, TIMING4::Register>),
57        /// I2C clock stretching timeout control
58        (0x0044 => pub(crate) timeout_ctrl: ReadWrite<u32, TIMEOUT_CTRL::Register>),
59        /// I2C target address and mask pairs
60        (0x0048 => pub(crate) target_id: ReadWrite<u32, TARGET_ID::Register>),
61        /// I2C target acquired data
62        (0x004c => pub(crate) acqdata: ReadWrite<u32, ACQDATA::Register>),
63        /// I2C target transmit data
64        (0x0050 => pub(crate) txdata: ReadWrite<u32, TXDATA::Register>),
65        /// I2C host clock generation timeout value (in units of input clock frequency)
66        (0x0054 => pub(crate) host_timeout_ctrl: ReadWrite<u32, HOST_TIMEOUT_CTRL::Register>),
67        (0x0058 => @END),
68    }
69}
70
71register_bitfields![u32,
72    /// Common Interrupt Offsets
73    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// End generated register constants for i2c