forked from lowRISC/opentitan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spi_device.hjson
1593 lines (1514 loc) · 52.8 KB
/
spi_device.hjson
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
{
name: "spi_device",
human_name: "SPI Device",
one_line_desc: "Serial peripheral interface supporting different device modes, suitable for bulk-load of data into and out of the chip",
one_paragraph_desc: '''
SPI Device is a configurable, versatile hardware block that implements three modes (SPI Flash emulation mode, SPI passthrough mode, and TPM over SPI mode) to support a variety of different applications.
TPM over SPI operates in compliance with TPM PC Client Platform, unloading this protocol from a software solution.
SPI Flash emulation mode supports many JEDEC standard commands such as Read Status, Read JEDEC ID, Read SFDP, EN4B/EX4B, and multiple other read commands, allowing OpenTitan to provide, for example, verified boot firmware to other external devices.
'''
// Unique comportable IP identifier defined under KNOWN_CIP_IDS in the regtool.
cip_id: "26",
design_spec: "../doc",
dv_doc: "../doc/dv",
hw_checklist: "../doc/checklist",
sw_checklist: "/sw/device/lib/dif/dif_spi_device",
revisions: [
{
version: "0.5.0",
life_stage: "L1",
design_stage: "D1",
verification_stage: "V1",
dif_stage: "S0",
commit_id: "553ca956e0204e5b67b3bbea47f2e067f60b5510",
notes: ""
}
{ version: "1.0.0",
life_stage: "L1",
design_stage: "D2S",
verification_stage: "V2S",
dif_stage: "S2",
commit_id: "",
notes: ""
}
{ version: "2.0.0",
life_stage: "L1",
design_stage: "D2S",
verification_stage: "V2S",
dif_stage: "S1",
commit_id: "",
notes: ""
}
]
clocking: [
{clock: "clk_i", reset: "rst_ni", primary: true},
// The scan_rst_ni port isn't listed here because it's generated by the
// "scan_reset: true" below.
{clock: "scan_clk_i"}
]
bus_interfaces: [
{ protocol: "tlul", direction: "device" }
],
available_input_list: [
{ name: "sck", desc: "SPI Clock" },
{ name: "csb", desc: "Chip Select#" },
{ name: "tpm_csb", desc: "TPM Chip Select#"}
],
available_output_list: [
],
available_inout_list: [
{ name: "sd",
width: "4",
desc: "SPI IO, IO2/IO3 has multi-purpose (/WP, /HOLD)"
}
]
interrupt_list: [
{ name: "upload_cmdfifo_not_empty"
desc: "Upload Command FIFO is not empty"
}
{ name: "upload_payload_not_empty"
desc: '''Upload payload is not empty.
The event occurs after SPI transaction completed
'''
}
{ name: "upload_payload_overflow"
desc: '''Upload payload overflow event.
When a SPI Host system issues a command with payload more than 256B,
this event is reported. When it happens, SW should read the last
written payload index CSR to figure out the starting address of the
last 256B.
'''
type: "event"
}
{ name: "readbuf_watermark"
desc: '''Read Buffer Threshold event.
The host system accesses greater than or equal to the threshold of a
buffer.
'''
}
{ name: "readbuf_flip"
desc: '''Read buffer flipped event.
The host system accesses other side of buffer.
'''
type: "event"
}
{ name: "tpm_header_not_empty"
desc: "TPM Header(Command/Address) buffer available"
type: "status"
}
{ name: "tpm_rdfifo_cmd_end"
desc: '''TPM RdFIFO command ended.
The TPM Read command targeting the RdFIFO ended.
Check TPM_STATUS.rdfifo_aborted to see if the transaction completed.
'''
type: "event"
}
{ name: "tpm_rdfifo_drop"
desc: '''TPM RdFIFO data dropped.
Data was dropped from the RdFIFO.
Data was written while a read command was not active, and it was not accepted.
This can occur when the host aborts a read command.
'''
type: "event"
}
],
alert_list: [
{ name: "fatal_fault",
desc: '''
This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected.
'''
}
],
scan: "true", // Enable `scanmode_i` port
scan_reset: "true", // Enable `scan_rst_ni` port
param_list: [
{ name: "SramType"
desc: "Sram Entries. Word size is 32bit width."
type: "spi_device_pkg::sram_type_e"
default: "spi_device_pkg::DefaultSramType"
local: "false"
expose: "true"
}
{ name: "SramDepth"
desc: "Sram Entries. Word size is 32bit width."
type: "int unsigned"
default: "1024"
local: "true"
}
{ name: "SramEgressDepth"
desc: "Sram Egress Entries. Word size is 32bit width."
type: "int unsigned"
default: "848"
local: "true"
}
{ name: "SramIngressDepth"
desc: "Sram Ingress Entries. Word size is 32bit width."
type: "int unsigned"
default: "112"
local: "true"
}
{ name: "SramReadBufferOffset"
desc: "Sram eFlash read buffer offset (from egress buffer start). Word size is 32bit width."
type: "int unsigned"
default: "0"
local: "true"
}
{ name: "SramReadBufferDepth"
desc: "Sram eFlash read buffer entries. Word size is 32bit width."
type: "int unsigned"
default: "512"
local: "true"
}
{ name: "SramMailboxOffset"
desc: "Sram mailbox buffer offset (from egress buffer start). Word size is 32bit width."
type: "int unsigned"
default: "512"
local: "true"
}
{ name: "SramMailboxDepth"
desc: "Sram mailbox entries. Word size is 32bit width."
type: "int unsigned"
default: "256"
local: "true"
}
{ name: "SramSfdpOffset"
desc: "Sram SFDP buffer offset (from egress buffer start). Word size is 32bit width."
type: "int unsigned"
default: "768"
local: "true"
}
{ name: "SramSfdpDepth"
desc: "Sram SFDP entries. Word size is 32bit width."
type: "int unsigned"
default: "64"
local: "true"
}
{ name: "SramTpmRdFifoOffset"
desc: "Sram TPM RdFIFO offset (from egress buffer start). Word size is 32bit width."
type: "int unsigned"
default: "832"
local: "true"
}
{ name: "SramTpmRdFifoDepth"
desc: "Sram TPM RdFIFO entries. Word size is 32bit width."
type: "int unsigned"
default: "16"
local: "true"
}
{ name: "SramPayloadOffset"
desc: "Sram payload FIFO offset (from ingress buffer start). Word size is 32bit width."
type: "int unsigned"
default: "0"
local: "true"
}
{ name: "SramPayloadDepth"
desc: "Sram payload FIFO entries. Word size is 32bit width."
type: "int unsigned"
default: "64"
local: "true"
}
{ name: "SramCmdFifoOffset"
desc: "Sram command FIFO offset (from ingress buffer start). Word size is 32bit width."
type: "int unsigned"
default: "64"
local: "true"
}
{ name: "SramCmdFifoDepth"
desc: "Sram command FIFO entries. Word size is 32bit width."
type: "int unsigned"
default: "16"
local: "true"
}
{ name: "SramAddrFifoOffset"
desc: "Sram address FIFO offset (from ingress buffer start). Word size is 32bit width."
type: "int unsigned"
default: "80"
local: "true"
}
{ name: "SramAddrFifoDepth"
desc: "Sram address FIFO entries. Word size is 32bit width."
type: "int unsigned"
default: "16"
local: "true"
}
{ name: "SramTpmWrFifoOffset"
desc: "Sram TPM Write FIFO offset (from ingress buffer start). Word size is 32bit width."
type: "int unsigned"
default: "96"
local: "true"
}
{ name: "SramTpmWrFifoDepth"
desc: "Sram TPM Write FIFO entries. Word size is 32bit width."
type: "int unsigned"
default: "16"
local: "true"
}
{ name: "NumCmdInfo"
desc: "Define the number of Command Info slots."
type: "int unsigned"
default: "24"
local: "true"
}
{ name: "NumLocality"
desc: "The number of locality TPM module supports."
type: "int unsigned"
default: "5"
local: "true"
} // p: NumLocality
{ name: "TpmRdFifoPtrW"
desc: "TPM RdFIFO Pointer Bit Width. clog2(Depth(16+1))"
type: "int unsigned"
default: "5"
local: "true"
} // p: TpmRdFifoPtrW
{ name: "TpmRdFifoWidth"
desc: "TPM Read FIFO Data Width. (TpmRdFifoWidth/8) shall be power of two"
type: "int unsigned"
default: "32"
} // p: TpmRdFifoWidth
],
inter_signal_list: [
{ struct: "ram_2p_cfg",
package: "prim_ram_2p_pkg",
type: "uni",
name: "ram_cfg",
act: "rcv"
}
{ struct: "passthrough",
package: "spi_device_pkg"
type: "req_rsp"
name: "passthrough",
act: "req"
}
{ struct: "logic"
package: ""
type: "uni"
name: "mbist_en"
act: "rcv"
}
{ struct: "logic"
package: ""
type: "uni"
name: "sck_monitor"
act: "req"
}
],
features: [
{
name: "SPI_DEVICE.MODE.FLASH_EMULATION",
desc: '''Emulates the behaviour of a Serial Flash device when connected to an upstream SPI Host.
In this mode, the block recognizes SPI Flash commands and can respond entirely in HW.
'''
}
{
name: "SPI_DEVICE.MODE.PASSTHROUGH",
desc: '''The block acts as a proxy to a downstream external SPI Flash, with optional inline filtering and monitoring.
In this mode, an upstream SPI Host communicates with a downstream external SPI Flash.
Traffic received by this block is forwarded to a SPI_HOST instance, which then
relays the traffic onto the downstream external SPI flash.
Runtime-configurable filtering, payload interception, payload substitution and monitoring operations
on the passthrough traffic are provided by the block.
'''
}
{
name: "SPI_DEVICE.MODE.TPM",
desc: '''Acts as a device-side endpoint in compliance with TPM PC Client Platform over SPI.
'''
}
{
name: "SPI_DEVICE.HW.LANES",
desc: '''1,2 or 4 lane operation is supported by the block.
'''
}
{
name: "SPI_DEVICE.HW.SERDES_ORDERING",
desc: '''The block allows serialization ordering control for SDI/SDO that can be controlled at runtime.
CSR.CFG.rx_order : "RX bit order on SDI. 0 for MSB first, 1 for LSB first."
CSR.CFG.tx_order : "TX bit order on SDO. 0 for MSB first, 1 for LSB first.
'''
}
{
name: "SPI_DEVICE.HW.CSB_STATUS",
desc: '''CSR.STATUS fields show the current status of the two CSB signals (.csb/.tpm_csb).
'''
}
{
name: "SPI_DEVICE.MODE.FLASH_EMULATION.COMMANDS",
desc: '''Device should respond to all specified standard SPI Flash Commands.
'''
}
{
name: "SPI_DEVICE.HW.FLASH_EMULATION_BLOCKS",
desc: '''Hardware contains a number of submodules for handling certain commands.
cmdparse, READ, EN4B/EX4B, SFDP, JEDEC, status/busy
- CSR.FLASH_STATUS contains SW-writable bits that define the response to a Read Status Register command.
- Some fields in CSR.FLASH_STATUS may also be modified by HW.
- WRDI/WREN commands modify the CSR.FLASH_STATUS.status.WEL bit.
- CSR.FLASH_STATUS.status.BUSY may be modified by HW depending on command upload configuration of the
CSR.CMDINFO[x].busy field.
- CSR.JEDEC_CC and CSR.JEDEC_ID provide data for the JEDEC Read command.
- The SFDP section of DPSRAM provides data for the Read SFDP command.
'''
}
{
name: "SPI_DEVICE.MODE.FLASH_EMULATION.READ_COMMAND_PROCESSOR",
desc: '''SPI Flash Read commands are provided with data from a DPSRAM section with a ping-pong buffering scheme, or a fixed mailbox region.
- The readptr crossing the buffer boundary creates a readbuf_flip interrupt.
- The readptr crossing the offset CSR.READ_THRESHOLD within a buffer creates a readbuf_watermark interrupt.
'''
}
{
name: "SPI_DEVICE.MODE.FLASH_EMULATION.DUMMY_CYCLE",
desc: '''Insertion of dummy cycles between SPI Flash opcode and data.
'''
}
{
name: "SPI_DEVICE.MODE.FLASH_EMULATION.WRITE_ENABLE_DISABLE",
desc: '''The block supports SPI Flash WREN/WRDI commands from the external host.
'''
}
{
name: "SPI_DEVICE.HW.LAST_READ_ADDR",
desc: '''The register CSR.LAST_READ_ADDR shows the last address a SPI Flash Read command accessed before CSb de-assertion.
MODES : FLASH_EMULATION,PASSTHROUGH
'''
}
{
name: "SPI_DEVICE.HW.CMDINFOS",
desc: '''Registers that can contain custom opcode + data for responding to SPI Flash Commands.
'''
}
{
name: "SPI_DEVICE.HW.COMMAND_UPLOAD",
desc: '''HW can store the received command into the command/address FIFOs and payload buffer.
MODES:FLASH_EMULATION,PASSTHROUGH
- A received SPI Flash command can conditionally be written to the command,address and payload FIFOs.
- SW can access data about the uploaded commands via CSR.UPLOAD_STATUS and CSR.UPLOAD_STATUS2.
- SW can read CSR.UPLOAD_CMDFIFO to access the command FIFO.
- SW can read CSR.UPLOAD_ADDRFIFO to access the address FIFO.
- The payload FIFO can be read by accessing the DPSRAM window.
'''
}
{
name: "SPI_DEVICE.HW.3B4B_ADDRESSING",
desc: '''Support CSR control of 3B/4B operation, plus host control with EN4B/EX4B
'''
}
{
name: "SPI_DEVICE.MODE.PASSTHROUGH.CMD_FILTER",
desc: '''Passthrough logic filters the command based on the 256-bit value of the "CMD_FILTER_0" CSR.
'''
}
{
name: "SPI_DEVICE.MODE.PASSTHROUGH.ADDRESS_MANIPULATION",
desc: '''By configuring ADDR_SWAP_MASK and ADDR_SWAP_DATA CSRs, certain address bits of Flash Commands can be overwritten on passthrough.
'''
}
{
name: "SPI_DEVICE.MODE.PASSTHROUGH.STATUS_MANIPULATION",
desc: '''By configuring PAYLOAD_SWAP_MASK and PAYLOAD_SWAP_DATA CSRs, certain bits of the first 4 payload bytes may be overwritten on passthrough.
'''
}
{
name: "SPI_DEVICE.MODE.PASSTHROUGH.OUTPUT_ENABLE_CONTROL",
desc: '''Passthrough module can control the output enable signals on both host and downstream side.
'''
}
{
name: "SPI_DEVICE.MODE.PASSTHROUGH.INTERCEPT_EN",
desc: '''Allow the block to reply to SPI Flash commands, taking precedence over the data returned by the passthrough device.
'''
}
{
name: "SPI_DEVICE.MODE.PASSTHROUGH.MAILBOX",
desc: '''Return data from the 1kB Mailbox read/write buffer if the command address falls in the range (MAILBOX_ADDR:MAILBOX_ADDR+1kB).
'''
}
{
name: "SPI_DEVICE.MODE.TPM.RETURN-BY-HW_REGS",
desc: '''Block can auto-respond to a TPM host when the address falls within a configured range using the RETURN-BY-HW registers.
'''
}
{
name: "SPI_DEVICE.MODE.TPM.AUTO_WAIT",
desc: '''If the address of a command does not fall into a pre-configured range, the block automatically returns a WAIT on the bus.
'''
}
{
name: "SPI_DEVICE.MODE.TPM.READ_FIFO_MODE",
desc: '''If not activating the RETURN-BY-HW mode, the block responds to a Host TPM commands when the TPM_READ_FIFO has data >= requested transfer size.
'''
}
{
name: "SPI_DEVICE.MODE.TPM.CAPABILITY",
desc: '''TPM-mode can advertise the capabilities it supports to the upstream Host by setting CSR.TPM_CAP.
'''
}
],
countermeasures: [
{ name: "BUS.INTEGRITY",
desc: "End-to-end bus integrity scheme."
}
]
regwidth: "32",
registers: [
{ name: "CONTROL",
desc: "Control register",
swaccess: "rw",
hwaccess: "hro",
fields: [
{ bits: "0",
name: "FLASH_STATUS_FIFO_CLR",
swaccess: "rw1s",
hwaccess: "hrw",
desc: '''Set to clear the flash status FIFO.
When set to 1, resets the flash status FIFO used for synchronizing changes from firmware.
The reset should only be used when the upstream SPI host is known to be inactive.
This function is intended to allow restoring initial values when the upstream SPI host is reset.
This CSR automatically resets to 0.
'''
resval: "0",
tags: [// This CSR only briefly pulses to anything other than 0.
"excl:CsrNonInitTests:CsrExclWrite"]
},
{ bits: "1",
name: "FLASH_READ_BUFFER_CLR",
swaccess: "rw1s",
hwaccess: "hrw",
desc: '''Set to clear the read buffer state.
When set to 1, resets the flash read buffer state that tracks the host read address.
The reset should only be used when the upstream SPI host is known to be inactive.
This function is intended to allow restoring initial values when the upstream SPI host is reset.
This CSR automatically resets to 0.
'''
resval: "0",
tags: [// This CSR only briefly pulses to anything other than 0.
"excl:CsrNonInitTests:CsrExclWrite"]
},
{ bits: "5:4",
name: "MODE",
desc: "SPI Device flash operation mode.",
resval: "1"
enum: [
{ value: "0",
name: "disabled",
desc: '''SPI Flash operations disabled.
SPI device flash operations are disabled, and all transactions are ignored.
Note that SPI TPM operations are controlled by !!TPM_CFG
'''
},
{ value: "1"
name: "flashmode"
desc: '''SPI Flash Emulation mode.
In flash mode, SPI Device IP accepts SPI Flash commands and
processes internally, then returns data for the read commands.
HW processes the Status, JEDEC ID, SFDP commands.
The current version does not support Dual/Quad IO and QPI
commands.
'''
}
{ value: "2"
name: "passthrough"
desc: '''
In passthrough mode, SPI Device IP forwards the incoming SPI
flash traffics to the attached downstream flash device. HW may
processes commands internally and returns data.
SW may configure the device to drop inadmissable commands.
'''
}
]
tags: [// Changing modes randomly can result in unknown values being
// passed between spi_dev/host due to passthrough
"excl:CsrNonInitTests:CsrExclWrite"]
},
]
},
{ name: "CFG",
desc: "Configuration Register",
swaccess: "rw",
hwaccess: "hro",
fields: [
{ bits: "2",
name: "tx_order",
desc: "TX bit order on SDO. 0 for MSB to LSB, 1 for LSB to MSB",
resval: "0",
},
{ bits: "3",
name: "rx_order",
desc: "RX bit order on SDI. Module stores bitstream from MSB to LSB if value is 0.",
resval: "0",
},
{ bits: "24"
name: "mailbox_en"
desc: '''Mailbox enable.
If 1, in the flash and passthrough mode, the IP checks the incoming
address and return from the internal Mailbox buffer if the address
falls into the MAILBOX range
(MAILBOX_ADDR:MAILBOX_ADDR+MAILBOX_SIZE)}.
'''
} // f: mailbox_en
]
},
{ name: "STATUS",
desc: "SPI Device status register",
swaccess: "ro",
hwaccess: "hwo",
hwext: "true",
fields: [
{ bits: "5", name: "csb", desc: "Direct input of CSb signal", resval: "1" },
{ bits: "6"
name: "tpm_csb"
desc: "Direct input of TPM CSb"
resval: "1"
tags: [
// the value of tpm_csb is determined by the
// value on the pins, hence it cannot be predicted.
"excl:CsrAllTests:CsrExclCheck"
]
}
]
},
//=========================================================================
// Flash & Passthrough CSRs
{ name: "INTERCEPT_EN"
desc: '''Intercept Passthrough datapath.
'''
swaccess: "rw"
hwaccess: "hro"
fields: [
{ bits: "0"
name: "status"
desc: "If set, Read Status is processed internally."
} // f: status
{ bits: "1"
name: "jedec"
desc: "If set, Read JEDEC ID is processed internally."
} // f: jedec
{ bits: "2"
name: "sfdp"
desc: "If set, Read SFDP is processed internally."
} // f: sfdp
{ bits: "3"
name: "mbx"
desc: "If set, Read Command to Mailbox region is processed internally."
} // f: mailbox
]
} // R: INTERCEPT_EN
{ name: "ADDR_MODE"
desc: '''Flash address mode configuration
This register shows the current address mode and pending changes.
It is updated by the HW when the command phase completes.
'''
swaccess: "ro"
hwaccess: "hwo"
hwext: true
tags: [
// SW is not able to read back the ADDR_MODE register right after write.
// The pending field changes whenever the CSR is written, regardless of the value.
// So, the CSR is excluded from most automated CSR tests.
"excl:CsrNonInitTests:CsrExclWrite"
]
fields: [
{ bits: "0"
name: "addr_4b_en"
swaccess: "rw"
hwaccess: "hrw" // Updated by EN4B/EX4B
hwqe: true
desc: '''4B Address Mode enable.
This field configures the internal module to receive 32 bits of the SPI commands.
The affected commands are the SPI read commands except QPI, and program commands.
It is expected for SW to configure this field at the configuration stage and release control to HW until the next reset.
Even though Read SFDP command has address fields, the SFDP command is not affected by this field.
The command always parse 24 bits on the SPI line 0 following the SPI command as the address field.
This field has noteworthy read behavior.
If a software-initiated change is still `pending` the sync to the SPI domain, this bit will reflect the value to be sent.
Otherwise, this field will reflect the current value observed in the SPI domain.
'''
},
{ bits: "31"
name: "pending"
desc: '''SW-originated change is pending.
This bit is 1 whenever the current value of addr_4b_en has yet to sync with the SPI domain.
If an EN4B or EX4B command arrives next, the current value in `addr_4b_en` will be ignored,
and the SPI flash command will take priority, with an update to `addr_4b_en` to match the command's result.
'''
}
]
} // R: ADDR_MODE
{ name: "LAST_READ_ADDR"
desc: '''Last Read Address
This register shows the last address accessed by the host system.
It is updated by the HW when CSb is de-asserted.
'''
swaccess: "ro"
hwaccess: "hwo"
hwext: true
fields: [
{ bits: "31:0"
name: "addr"
desc: "Last address"
}
]
} // R: LAST_READ_ADDR
{ name: "FLASH_STATUS"
desc: '''SPI Flash Status register.
This register emulates the SPI Flash Status 3, 2, 1 registers.
bit [7:0] is for Status register, bit [15:8] is for Status-2 register,
and bit [23:16] is for Status-3 register. It is SW responsibility to
maintain this register value up to date.
The HW latches the value when SPI Flash transaction begins. Any updates
during the transaction will be updated after the transaction is
completed.
'''
swaccess: "rw"
hwaccess: "hrw"
hwext: true
hwqe: true
tags: [
// SW is not able to read back the STATUS register right after write.
// The read back value is the committed value, which needs at least a SPI transaction.
// So excluded from CSR automation test.
"excl:CsrNonInitTests:CsrExclWrite"
]
fields: [
{ bits: "0"
name: "busy"
desc: '''BUSY signal is cleared when CSb is high. SW should read
back the register to confirm the value is cleared.'''
swaccess: "rw0c"
hwaccess: "hrw"
} // f: busy
{ bits: "1"
name: "wel"
desc: '''WEL signal is cleared when CSb is high. SW should read
back the register to confirm the value is cleared.
Bit 1 (WEL) is a SW modifiable and HW modifiable field.
HW updates the WEL field when `WRDI` or `WREN` command is received.
'''
swaccess: "rw0c"
hwaccess: "hrw"
} // f: busy
{ bits: "23:2"
name: "status"
desc: '''Rest of the status register.
Fields other than the bit 0 (BUSY) and bit 1 (WEL) fields are
SW-maintained fields. HW just reads and returns to the host system.
- [ 2]\: BP0
- [ 3]\: BP1
- [ 4]\: BP2
- [ 5]\: TB
- [ 6]\: SEC
- [ 7]\: SRP0
- [ 8]\: SRP1
- [ 9]\: QE
- [11]\: LB1
- [12]\: LB2
- [13]\: LB3
- [14]\: CMP
- [15]\: SUS
- [18]\: WPS
- [21]\: DRV0
- [22]\: DRV1
- [23]\: HOLD /RST
'''
} // f: status
]
} // R: FLASH_STATUS
{
name: "JEDEC_CC"
desc: '''JEDEC Continuation Code configuration register.
Read JEDEC ID must return the continuation code if the manufacturer ID
is not shown in the first page of JEDEC table. This register controls
the Continuation Code.
'''
swaccess: "rw"
hwaccess: "hro"
fields: [
{ bits: "15:8"
name: "num_cc"
desc: "The number that Continuation Code repeats"
} // f: num_cc
{ bits: "7:0"
name: "cc"
desc: "Continuation Code byte"
resval: "0x7F"
} // f: cc
]
} // R: JEDEC_CC
{
name: "JEDEC_ID"
desc: '''JEDEC ID register.
'''
swaccess: "rw"
hwaccess: "hro"
fields: [
{ bits: "23:16"
name: "mf"
desc: "Manufacturer ID"
} // f: manufacturer id
{ bits: "15:0"
name: "id"
desc: "Device ID"
} // f: device id
]
} // R: JEDEC_ID
{ name: "READ_THRESHOLD"
desc: '''Read Buffer threshold register.
'''
swaccess: "rw"
hwaccess: "hro"
fields: [
{ bits: "9:0"
name: "threshold"
desc: '''If 0, disable the watermark. If non-zero, when the host
access above or equal to the threshold, it reports an interrupt.
The value is byte-granularity not SRAM index.
'''
} // f: threshold
]
} // R: READ_THRESHOLD
{ name: "MAILBOX_ADDR"
desc: '''Mailbox Base address register.
The mailbox size is fixed. In this version of IP, the size is 1kB.
Lower 10 bits of the Mailbox address is tied to 0.
'''
swaccess: "rw"
hwaccess: "hro"
fields: [
{ bits: "31:0"
name: "addr"
desc: "Mailbox Address. Lower 10 bits are ignored"
} // f: addr
]
} // R: MAILBOX_ADDR
{ name: "UPLOAD_STATUS"
desc: '''Upload module status register.
'''
swaccess: "ro"
hwaccess: "hwo"
fields: [
{ bits: "4:0"
name: "cmdfifo_depth"
desc: "Command FIFO Entry"
} // f: cmdfifo_depth
{ bits: "7"
name: "cmdfifo_notempty"
desc: "Upload Command FIFO Not Empty"
} // f: cmdfifo_notempty
{ bits: "12:8"
name: "addrfifo_depth"
desc: "Address FIFO Entry"
} // f: addrfifo_depth
{ bits: "15"
name: "addrfifo_notempty"
desc: "Upload Address FIFO Not Empty"
} // f: addrfifo_notempty
]
} // R: UPLOAD_STATUS
{ name: "UPLOAD_STATUS2"
desc: '''Upload module status 2 register.
This register contains payload related status. payload_depth indicates
the payload size (from 0 to 256 bytes).
payload_start_idx indicates the start of the 256B. This stays 0
usually. However, when the SPI host system issues more than 256B of
payload in a command, this field may not be 0. For example, if the
system issues 258B payload, the payload_depth is 256 (as the IP only
holds 256B of payload), the payload_start_idx is 2. SW should read from
2 to 255 then 0 and 1.
'''
swaccess: "ro"
hwaccess: "hwo"
fields: [
{ bits: "8:0"
name: "payload_depth"
desc: '''Payload buffer depth
'''
} // f: payload_depth
{ bits: "23:16"
name: "payload_start_idx"
desc: '''Payload Start Index'''
} // f: payload_start_idx
]
} // R: UPLOAD_STATUS2
{ name: "UPLOAD_CMDFIFO"
desc: '''Command Fifo Read Port.
'''
swaccess: "ro"
hwaccess: "hrw"
hwre: "true"
hwext: "true"
fields: [
{ bits: "7:0"
name: "data"
desc: "command opcode"
}
{ bits: "13"
name: "busy"
desc: "State of BUSY bit at command time"
}
{ bits: "14"
name: "wel"
desc: "State of WEL bit at command time"
}
{ bits: "15"
name: "addr4b_mode"
desc: "1 if address mode at command time is 4 Bytes, else 3 Bytes"
}
]
} // R: UPLOAD_CMDFIFO
{ name: "UPLOAD_ADDRFIFO"
desc: '''Address Fifo Read Port.
'''
swaccess: "ro"
hwaccess: "hrw"
hwre: "true"
hwext: "true"
fields: [
{ bits: "31:0"
name: "data"
desc: "read data"
}
]
} // R: UPLOAD_ADDRFIFO
{ multireg: {
cname: "SPI_DEVICE"
name: "CMD_FILTER"
desc: '''Command Filter
If a bit in this CSR is 1, then corresponding SPI command w.r.t the
bit position among 256 bit is dropped in SPI Passthrough mode.
'''
count: "256"
swaccess: "rw"
hwaccess: "hro"
compact: true
fields: [
{ bits: "0"
name: "filter"
resval: "0"
desc: "If 1, command will be filtered"
}
]
}
}
{ name: "ADDR_SWAP_MASK"
desc: '''Address Swap Mask register.
This register is used in the SPI passthrough mode. If any of bits in
this register is set, the corresponding address bit in the SPI Read
commands is replaced with the data from !!ADDR_SWAP_DATA.
If 3B address mode is active, upper 8bit [31:24] is ignored.
'''
swaccess: "rw"
hwaccess: "hro"
fields: [
{ bits: "31:0"
resval: "0",
name: "mask"
desc: '''When a bit is 1, the SPI read address to the downstream SPI
Flash device is swapped to !!ADDR_SWAP_DATA.
'''
}
]
}
{ name: "ADDR_SWAP_DATA"
desc: '''The address value for the address swap feature.
'''
swaccess: "rw"
hwaccess: "hro"
fields: [
{ bits: "31:0"
resval: "0"
name: "data"
desc: "Desired value to be swapped for the SPI read commands."
}
]
}
{ name: "PAYLOAD_SWAP_MASK"
desc: '''Write Data Swap in the passthrough mode.
PAYLOAD_SWAP_MASK CSR provides the SW to change certain bits in the
first 4 bytes of the write payload in the passthrough mode.
'''
swaccess: "rw"
hwaccess: "hro"
fields: [
{ bits: "31:0"
resval: "0"
name: "mask"
desc: "byte mask"
} // f: mask
]
} // R: PAYLOAD_SWAP_MASK
{ name: "PAYLOAD_SWAP_DATA"
desc: '''Write Data Swap in the passthrough mode.
PAYLOAD_SWAP_DATA combined with PAYLOAD_SWAP_MASK provides the SW to
change certain bits in the first 4 bytes of the write payload in the
passthrough mode.
The register should be written in Little-Endian order. [7:0] bits are
processed in the first received payload byte. [31:24] bits for the 4th
byte.
'''
swaccess: "rw"
hwaccess: "hro"
fields: [
{ bits: "31:0"
resval: "0"
name: "data"