Skip to content

Commit

Permalink
i3c_controller: arbitration da, bcr lookup
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gastmaier committed Oct 2, 2023
1 parent 66729e7 commit f384d61
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 71 deletions.
44 changes: 34 additions & 10 deletions docs/regmap/adi_regmap_i3c_controller.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,21 @@ FIELD
IBI_ALMOST_FULL
RW
If set to 0 the IBI_ALMOST_FULL interrupt is masked.
ENDFIELD

FIELD
[5] 0x00
CMDR_PENDING
RW
If set to 0 the CMDR_PENDING interrupt is masked.
ENDFIELD

FIELD
[6] 0x00
IBI_PENDING
RW
If set to 0 the IBI_PENDING interrupt is masked.
ENDFIELD

############################################################################################
############################################################################################
Expand Down Expand Up @@ -276,6 +279,27 @@ RO
ENDFIELD


FIELD
[27:24] 0x??
CMDR_FIFO_ERROR
RO
If an error occurred during the transfer.
ENDFIELD

FIELD
[19:8] 0x??
CMDR_FIFO_BUFFER_LENGTH
RO
Unsigned 12-bits transferred payload length.
ENDFIELD

FIELD
[7:0] 0x??
CMDR_FIFO_SYNC
RO
Command synchronization.
ENDFIELD

############################################################################################
############################################################################################

Expand Down Expand Up @@ -337,27 +361,24 @@ IBI_FIFO
ENDREG

FIELD
[31:24] 0x??
IBI_FIFO_BYTE_3
RO
ENDFIELD

FIELD
[23:16] 0x??
IBI_FIFO_BYTE_2
[23:17] 0x??
IBI_FIFO_DA
RO
IBI Dynamic address.
ENDFIELD

FIELD
[15:8] 0x??
IBI_FIFO_BYTE_1
IBI_FIFO_MDB
RO
IBI MDB, if the peripheral's BCR[2] is Low, the field is ignored.
ENDFIELD

FIELD
[7:0] 0x??
IBI_FIFO_BYTE_0
IBI_FIFO_SYNC
RO
Synchronization number.
ENDFIELD

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

FIELD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ module i3c_controller_bit_mod (
// 3: 1.56MHz
input [1:0] scl_pp_sg, // SCL Push-pull speed grade

output reg rx,
output rx,
output reg rx_raw,
output reg rx_valid,
output rx_valid,


// Bus drive signals
Expand Down Expand Up @@ -131,14 +131,12 @@ module i3c_controller_bit_mod (

always @(posedge clk) begin
scl_high_reg <= scl_high;
rx_valid <= 1'b0;
sdo <= sdo_w;
rx_raw <= sdi;
if (~scl_high_reg & scl_high) begin
rx <= sdi; // Multi-cycle-path worst-case: 4 clks (12.5MHz, half-bit ack)
rx_valid <= 1'b1;
end
rx_raw <= sdi === 1'b0 ? 1'b0 : 1'b1;
end
// Multi-cycle-path worst-case: 4 clks (12.5MHz, half-bit ack)
assign rx = rx_raw;
assign rx_valid = ~scl_high_reg & scl_high;

assign sdo_w = sm == `MOD_BIT_CMD_START_ ? (scl_high ? ~count[pp_sg+1] : 1'b1) :
sm == `MOD_BIT_CMD_STOP_ ? (scl_high ? count[pp_sg+1] : 1'b0) :
Expand Down
10 changes: 10 additions & 0 deletions library/i3c_controller/i3c_controller_core/i3c_controller_core.v
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ module i3c_controller_core #(
wire cmdw_rx_valid;
wire [7:0] cmdw_rx;

wire arbitration_valid;
wire ibi_bcr_2;
wire ibi_requested;
wire ibi_requested_auto;
wire ibi_tick;
wire [6:0] ibi_da;
wire [7:0] ibi_mdb;
wire ibi_da_attached;

wire [31:0] pid_bcr_dcr;
wire pid_bcr_dcr_tick;
Expand Down Expand Up @@ -164,8 +167,12 @@ module i3c_controller_core #(
.cmdw_rx(cmdw_rx),
.rx_raw(rx_raw),
.cmd_nop(cmd_nop),
.arbitration_valid(arbitration_valid),
.ibi_bcr_2(ibi_bcr_2),
.ibi_requested(ibi_requested),
.ibi_requested_auto(ibi_requested_auto),
.ibi_da(ibi_da),
.ibi_da_attached(ibi_da_attached),
.pid_bcr_dcr_tick(pid_bcr_dcr_tick),
.pid_bcr_dcr(pid_bcr_dcr),
.rmap_ibi_config(rmap_ibi_config),
Expand Down Expand Up @@ -193,10 +200,13 @@ module i3c_controller_core #(
.cmd_ready(cmd_ready),
.rx(rx),
.rx_valid(rx_valid),
.arbitration_valid(arbitration_valid),
.ibi_bcr_2(ibi_bcr_2),
.ibi_requested(ibi_requested),
.ibi_requested_auto(ibi_requested_auto),
.ibi_tick(ibi_tick),
.ibi_da(ibi_da),
.ibi_da_attached(ibi_da_attached),
.ibi_mdb(ibi_mdb),
.pid_bcr_dcr_tick(pid_bcr_dcr_tick),
.pid_bcr_dcr(pid_bcr_dcr),
Expand Down
Loading

0 comments on commit f384d61

Please sign in to comment.