Skip to content

Commit df1fbd4

Browse files
committed
Handle RSTACT and GETCAPS direct commands
This commit adds logic to handle some of the RSTACT direct defining bytes and GETCAPS without defining byte. It also fixes situation when RSTACT GET would result in rst_action being changed. Signed-off-by: Maciej Dudek <[email protected]>
1 parent 48cbce5 commit df1fbd4

File tree

1 file changed

+45
-5
lines changed

1 file changed

+45
-5
lines changed

src/ctrl/ccc.sv

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ module ccc
386386
`I3C_BCAST_ENDXFER: have_defining_byte = 1'b1;
387387
`I3C_BCAST_RSTACT: have_defining_byte = 1'b1;
388388
`I3C_BCAST_MLANE: have_defining_byte = 1'b1;
389+
`I3C_DIRECT_GETCAPS: have_defining_byte = 1'b1;
389390
`I3C_DIRECT_ENDXFER: have_defining_byte = 1'b1;
390391
`I3C_DIRECT_RSTACT: have_defining_byte = 1'b1;
391392
default: have_defining_byte = '0;
@@ -397,6 +398,7 @@ module ccc
397398
WaitCCC,
398399
RxTbit,
399400
RxDefByte,
401+
RxDefByteOrBusCond,
400402
RxDefByteTbit,
401403
RxByte,
402404
RxDirectDefByteTbit,
@@ -432,10 +434,17 @@ module ccc
432434
end
433435

434436
logic [7:0] defining_byte;
437+
logic valid_defining_byte;
435438
always_ff @(posedge clk_i or negedge rst_ni) begin : register_defining_byte
436-
if (~rst_ni) defining_byte <= '0;
437-
else if (state_q == RxDefByte && bus_rx_done_i) begin
439+
if (~rst_ni) begin
440+
defining_byte <= '0;
441+
valid_defining_byte <= '0;
442+
end else if ((state_q == RxDefByte || state_q == RxDefByteOrBusCond) && bus_rx_done_i) begin
438443
defining_byte <= bus_rx_data_i;
444+
valid_defining_byte <= '1;
445+
end else if (state_q == RxDefByteOrBusCond && bus_rstart_det_i) begin
446+
defining_byte <= '0;
447+
valid_defining_byte <= '0;
439448
end
440449
end
441450

@@ -507,7 +516,8 @@ module ccc
507516
RxTbit: begin
508517
if (bus_rx_done_i) begin
509518
// have defining byte
510-
if (have_defining_byte) state_d = RxDefByte;
519+
if (have_defining_byte && command_code == `I3C_DIRECT_GETCAPS) state_d = RxDefByteOrBusCond;
520+
else if (have_defining_byte) state_d = RxDefByte;
511521
else begin
512522
// ENTDAA is special
513523
if (command_code == `I3C_BCAST_ENTDAA) begin
@@ -553,6 +563,10 @@ module ccc
553563
RxDefByte: begin
554564
if (bus_rx_done_i) state_d = RxDefByteTbit;
555565
end
566+
RxDefByteOrBusCond: begin
567+
if (bus_rstart_det_i) state_d = RxDirectAddr;
568+
else if (bus_rx_done_i) state_d = RxDefByteTbit;
569+
end
556570
RxDefByteTbit: begin
557571
if (bus_rx_done_i) begin
558572
// broadcast CCCs
@@ -611,7 +625,8 @@ module ccc
611625
else if (bus_tx_done_i) state_d = TxDataTbit;
612626
end
613627
TxDataTbit: begin
614-
if (bus_tx_done_i)
628+
if (bus_rstart_det_i) state_d = RxDirectAddr;
629+
else if (bus_tx_done_i)
615630
if (tx_data_done) state_d = WaitForBusCond;
616631
else state_d = TxData;
617632
end
@@ -656,6 +671,11 @@ module ccc
656671
ccc_rx_req_bit = '0;
657672
ccc_rx_req_byte = '1;
658673
end
674+
RxDefByteOrBusCond: begin
675+
ccc_rx_req_bit = '0;
676+
ccc_rx_req_byte = '1;
677+
if (bus_rstart_det_i) ccc_rx_req_byte = '0;
678+
end
659679
RxDefByteTbit: begin
660680
ccc_rx_req_bit = '1;
661681
ccc_rx_req_byte = '0;
@@ -763,6 +783,17 @@ module ccc
763783
if (tx_data_id == 8'h01) tx_data = get_dcr_i;
764784
else tx_data = '0;
765785
end
786+
`I3C_DIRECT_RSTACT: begin
787+
tx_data_id_init = 8'h01;
788+
if (defining_byte == 8'h81 || defining_byte == 8'h82) begin
789+
if (tx_data_id == 8'h01 && defining_byte == 8'h81) tx_data = 8'hFF; // Use worst case value for now
790+
else if (tx_data_id == 8'h01 && defining_byte == 8'h82) tx_data = 8'hFF; // Use worst case value for now
791+
else tx_data = '0;
792+
end else if (defining_byte == 8'h00 || defining_byte == 8'h01 || defining_byte == 8'h02) begin
793+
if (tx_data_id == 8'h01) tx_data = rst_action;
794+
else tx_data = '0;
795+
end else tx_data = '0;
796+
end
766797
// 2 Bytes
767798
`I3C_DIRECT_GETSTATUS: begin
768799
tx_data_id_init = 8'h02;
@@ -796,6 +827,15 @@ module ccc
796827
else if (tx_data_id == 8'h01) tx_data = get_pid_i[7:0];
797828
else tx_data = '0;
798829
end
830+
// n Bytes
831+
`I3C_DIRECT_GETCAPS: begin
832+
tx_data_id_init = 8'h03;
833+
// FIXME: Check that this configuration is correct
834+
if (tx_data_id == 8'h03) tx_data = 8'h00; // We don't support HDR Modes
835+
else if (tx_data_id == 8'h02) tx_data = 8'h01; // We support I3C Basic v1.1.1
836+
else if (tx_data_id == 8'h01) tx_data = 8'h40; // We send IBI MDB
837+
else tx_data = '0;
838+
end
799839
default: begin
800840
tx_data_id_init = 8'h00;
801841
tx_data = '0;
@@ -928,7 +968,7 @@ module ccc
928968
end
929969
// rstact (direct)
930970
`I3C_DIRECT_RSTACT: begin
931-
if (command_valid && is_byte_our_addr) begin
971+
if (command_valid && is_byte_our_addr && ~command_rnw) begin
932972
rst_action_valid <= 1'b1;
933973
end else begin
934974
rst_action_valid <= 1'b0;

0 commit comments

Comments
 (0)