@@ -386,6 +386,7 @@ module ccc
386
386
`I3C_BCAST_ENDXFER : have_defining_byte = 1'b1 ;
387
387
`I3C_BCAST_RSTACT : have_defining_byte = 1'b1 ;
388
388
`I3C_BCAST_MLANE : have_defining_byte = 1'b1 ;
389
+ `I3C_DIRECT_GETCAPS : have_defining_byte = 1'b1 ;
389
390
`I3C_DIRECT_ENDXFER : have_defining_byte = 1'b1 ;
390
391
`I3C_DIRECT_RSTACT : have_defining_byte = 1'b1 ;
391
392
default : have_defining_byte = '0 ;
@@ -397,6 +398,7 @@ module ccc
397
398
WaitCCC,
398
399
RxTbit,
399
400
RxDefByte,
401
+ RxDefByteOrBusCond,
400
402
RxDefByteTbit,
401
403
RxByte,
402
404
RxDirectDefByteTbit,
@@ -432,10 +434,17 @@ module ccc
432
434
end
433
435
434
436
logic [7 : 0 ] defining_byte;
437
+ logic valid_defining_byte;
435
438
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
438
443
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 ;
439
448
end
440
449
end
441
450
@@ -507,7 +516,8 @@ module ccc
507
516
RxTbit: begin
508
517
if (bus_rx_done_i) begin
509
518
// 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;
511
521
else begin
512
522
// ENTDAA is special
513
523
if (command_code == `I3C_BCAST_ENTDAA ) begin
@@ -553,6 +563,10 @@ module ccc
553
563
RxDefByte: begin
554
564
if (bus_rx_done_i) state_d = RxDefByteTbit;
555
565
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
556
570
RxDefByteTbit: begin
557
571
if (bus_rx_done_i) begin
558
572
// broadcast CCCs
@@ -611,7 +625,8 @@ module ccc
611
625
else if (bus_tx_done_i) state_d = TxDataTbit;
612
626
end
613
627
TxDataTbit: begin
614
- if (bus_tx_done_i)
628
+ if (bus_rstart_det_i) state_d = RxDirectAddr;
629
+ else if (bus_tx_done_i)
615
630
if (tx_data_done) state_d = WaitForBusCond;
616
631
else state_d = TxData;
617
632
end
@@ -656,6 +671,11 @@ module ccc
656
671
ccc_rx_req_bit = '0 ;
657
672
ccc_rx_req_byte = '1 ;
658
673
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
659
679
RxDefByteTbit: begin
660
680
ccc_rx_req_bit = '1 ;
661
681
ccc_rx_req_byte = '0 ;
@@ -763,6 +783,17 @@ module ccc
763
783
if (tx_data_id == 8'h01 ) tx_data = get_dcr_i;
764
784
else tx_data = '0 ;
765
785
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
766
797
// 2 Bytes
767
798
`I3C_DIRECT_GETSTATUS : begin
768
799
tx_data_id_init = 8'h02 ;
@@ -796,6 +827,15 @@ module ccc
796
827
else if (tx_data_id == 8'h01 ) tx_data = get_pid_i[7 : 0 ];
797
828
else tx_data = '0 ;
798
829
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
799
839
default : begin
800
840
tx_data_id_init = 8'h00 ;
801
841
tx_data = '0 ;
@@ -928,7 +968,7 @@ module ccc
928
968
end
929
969
// rstact (direct)
930
970
`I3C_DIRECT_RSTACT : begin
931
- if (command_valid && is_byte_our_addr) begin
971
+ if (command_valid && is_byte_our_addr && ~ command_rnw ) begin
932
972
rst_action_valid <= 1'b1 ;
933
973
end else begin
934
974
rst_action_valid <= 1'b0 ;
0 commit comments