Skip to content

Commit e0bcd9c

Browse files
committed
i3c_controller: arbitration da, bcr lookup
Better arbitration handling, check if the received DA is known, and if the IBI requester will send the MDB after the request (BCR[2] == 1). Signed-off-by: Jorge Marques <jorge.marques@analog.com>
1 parent be1096e commit e0bcd9c

File tree

9 files changed

+197
-71
lines changed

9 files changed

+197
-71
lines changed

docs/regmap/adi_regmap_i3c_controller.txt

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,21 @@ FIELD
117117
IBI_ALMOST_FULL
118118
RW
119119
If set to 0 the IBI_ALMOST_FULL interrupt is masked.
120+
ENDFIELD
120121

121122
FIELD
122123
[5] 0x00
123124
CMDR_PENDING
124125
RW
125126
If set to 0 the CMDR_PENDING interrupt is masked.
127+
ENDFIELD
126128

127129
FIELD
128130
[6] 0x00
129131
IBI_PENDING
130132
RW
131133
If set to 0 the IBI_PENDING interrupt is masked.
134+
ENDFIELD
132135

133136
############################################################################################
134137
############################################################################################
@@ -276,6 +279,27 @@ RO
276279
ENDFIELD
277280

278281

282+
FIELD
283+
[27:24] 0x??
284+
CMDR_FIFO_ERROR
285+
RO
286+
If an error occurred during the transfer.
287+
ENDFIELD
288+
289+
FIELD
290+
[19:8] 0x??
291+
CMDR_FIFO_BUFFER_LENGTH
292+
RO
293+
Unsigned 12-bits transferred payload length.
294+
ENDFIELD
295+
296+
FIELD
297+
[7:0] 0x??
298+
CMDR_FIFO_SYNC
299+
RO
300+
Command synchronization.
301+
ENDFIELD
302+
279303
############################################################################################
280304
############################################################################################
281305

@@ -337,27 +361,24 @@ IBI_FIFO
337361
ENDREG
338362

339363
FIELD
340-
[31:24] 0x??
341-
IBI_FIFO_BYTE_3
342-
RO
343-
ENDFIELD
344-
345-
FIELD
346-
[23:16] 0x??
347-
IBI_FIFO_BYTE_2
364+
[23:17] 0x??
365+
IBI_FIFO_DA
348366
RO
367+
IBI Dynamic address.
349368
ENDFIELD
350369

351370
FIELD
352371
[15:8] 0x??
353-
IBI_FIFO_BYTE_1
372+
IBI_FIFO_MDB
354373
RO
374+
IBI MDB, if the peripheral's BCR[2] is Low, the field is ignored.
355375
ENDFIELD
356376

357377
FIELD
358378
[7:0] 0x??
359-
IBI_FIFO_BYTE_0
379+
IBI_FIFO_SYNC
360380
RO
381+
Synchronization number.
361382
ENDFIELD
362383

363384
############################################################################################
@@ -571,6 +592,9 @@ The Controller, index 0, is set to HIGH when a DA is written to DEV_CHAR_0_0,
571592
while the others peripherals are set HIGH when the peripherals actually
572593
receives the DA during the DAA.
573594
The state can also be overwritten to explicit attach device (e.g. has static addr).
595+
A slot cannot be recycled, when the device is detached, it still keeps its slot in
596+
case it is attached again, effectively, only its IBIs are rejectedin the detached
597+
state.
574598
ENDFIELD
575599

576600
FIELD

library/i3c_controller/i3c_controller_core/i3c_controller_bit_mod.v

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ module i3c_controller_bit_mod (
5555
// 3: 1.56MHz
5656
input [1:0] scl_pp_sg, // SCL Push-pull speed grade
5757

58-
output reg rx,
58+
output rx,
5959
output reg rx_raw,
60-
output reg rx_valid,
60+
output rx_valid,
6161

6262

6363
// Bus drive signals
@@ -131,14 +131,12 @@ module i3c_controller_bit_mod (
131131

132132
always @(posedge clk) begin
133133
scl_high_reg <= scl_high;
134-
rx_valid <= 1'b0;
135134
sdo <= sdo_w;
136-
rx_raw <= sdi;
137-
if (~scl_high_reg & scl_high) begin
138-
rx <= sdi; // Multi-cycle-path worst-case: 4 clks (12.5MHz, half-bit ack)
139-
rx_valid <= 1'b1;
140-
end
135+
rx_raw <= sdi === 1'b0 ? 1'b0 : 1'b1;
141136
end
137+
// Multi-cycle-path worst-case: 4 clks (12.5MHz, half-bit ack)
138+
assign rx = rx_raw;
139+
assign rx_valid = ~scl_high_reg & scl_high;
142140

143141
assign sdo_w = sm == `MOD_BIT_CMD_START_ ? (scl_high ? ~count[pp_sg+1] : 1'b1) :
144142
sm == `MOD_BIT_CMD_STOP_ ? (scl_high ? count[pp_sg+1] : 1'b0) :

library/i3c_controller/i3c_controller_core/i3c_controller_core.v

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,14 @@ module i3c_controller_core #(
119119
wire cmdw_rx_valid;
120120
wire [7:0] cmdw_rx;
121121

122+
wire arbitration_valid;
123+
wire ibi_bcr_2;
122124
wire ibi_requested;
123125
wire ibi_requested_auto;
124126
wire ibi_tick;
125127
wire [6:0] ibi_da;
126128
wire [7:0] ibi_mdb;
129+
wire ibi_da_attached;
127130

128131
wire [31:0] pid_bcr_dcr;
129132
wire pid_bcr_dcr_tick;
@@ -164,8 +167,12 @@ module i3c_controller_core #(
164167
.cmdw_rx(cmdw_rx),
165168
.rx_raw(rx_raw),
166169
.cmd_nop(cmd_nop),
170+
.arbitration_valid(arbitration_valid),
171+
.ibi_bcr_2(ibi_bcr_2),
167172
.ibi_requested(ibi_requested),
168173
.ibi_requested_auto(ibi_requested_auto),
174+
.ibi_da(ibi_da),
175+
.ibi_da_attached(ibi_da_attached),
169176
.pid_bcr_dcr_tick(pid_bcr_dcr_tick),
170177
.pid_bcr_dcr(pid_bcr_dcr),
171178
.rmap_ibi_config(rmap_ibi_config),
@@ -193,10 +200,13 @@ module i3c_controller_core #(
193200
.cmd_ready(cmd_ready),
194201
.rx(rx),
195202
.rx_valid(rx_valid),
203+
.arbitration_valid(arbitration_valid),
204+
.ibi_bcr_2(ibi_bcr_2),
196205
.ibi_requested(ibi_requested),
197206
.ibi_requested_auto(ibi_requested_auto),
198207
.ibi_tick(ibi_tick),
199208
.ibi_da(ibi_da),
209+
.ibi_da_attached(ibi_da_attached),
200210
.ibi_mdb(ibi_mdb),
201211
.pid_bcr_dcr_tick(pid_bcr_dcr_tick),
202212
.pid_bcr_dcr(pid_bcr_dcr),

0 commit comments

Comments
 (0)