Skip to content

Commit a9ec466

Browse files
committed
i3c_controller: Review fixes
Signed-off-by: Jorge Marques <jorge.marques@analog.com>
1 parent 0e5eb51 commit a9ec466

24 files changed

+709
-659
lines changed

docs/library/i3c_controller/i3c_controller_core.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ I3C Controller Core
66
.. hdl-component-diagram::
77

88
The I3C Controller Core peripheral forms the heart of the I3C Controller.
9-
It is responsible for handling a I3C Controller commandsand translates it into low-level I3C bus transactions.
9+
It is responsible for handling a I3C Controller commands and translates it into
10+
low-level I3C bus transactions.
1011

1112
Files
1213
-------------------------------------------------------------------------------

docs/library/i3c_controller/i3c_controller_host_interface.rst

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ access to a I3C Controller Control Interface.
1010
This is typically used in combination with a software program to dynamically
1111
generate I3C transactions.
1212

13-
The peripheral has also support for providing memory-mapped access to one or more
14-
:ref:`i3c_controller offload-control-interface` cores and change its content
15-
dynamically at runtime.
13+
The peripheral also has support for providing memory-mapped access to one or more
14+
:ref:`i3c_controller offload-interface` cores and change its content dynamically at
15+
runtime.
1616

1717
Files
1818
--------------------------------------------------------------------------------
@@ -38,6 +38,33 @@ Signal and Interface Pins
3838

3939
.. hdl-interfaces::
4040

41+
* - s_axi_aclk
42+
- All ``s_axi`` signals and ``irq`` are synchronous to this clock.
43+
* - s_axi_aresetn
44+
- Synchronous active-low reset.
45+
Resets the internal state of the peripheral.
46+
* - s_axi
47+
- AXI-Lite bus slave.
48+
Memory-mapped AXI-lite bus that provides access to modules register map.
49+
* - irq
50+
- Level-High Interrupt.
51+
Interrupt output of the module. Is asserted when at least one of the
52+
modules interrupt is pending and unmasked.
53+
* - offload_trigger
54+
- On offload operation, assert to start a burst.
55+
* - sdio
56+
- Group of byte stream interfaces (``SDI``, ``SDO``, and ``IBI``),
57+
internally connected to thei respective FIFOs.
58+
* - offload
59+
- SDI output of the :ref:`i3c_controller offload-interface`,
60+
generally consumed to a DMA.
61+
* - cmdp
62+
- Parsed :ref:`i3c_controller command_descriptors` to instruct the
63+
:ref:`i3c_controller core`.
64+
* - rmap
65+
- Interface give the :ref:`i3c_controller core` access to some register map
66+
addresses.
67+
4168
Register Map
4269
--------------------------------------------------------------------------------
4370

@@ -68,7 +95,7 @@ asserted when:
6895
* ``SDO_ALMOST_EMPTY``: the level falls bellow the almost empty level.
6996
* ``SDI_ALMOST_FULL``: the level rises above the almost full level.
7097
* ``IBI_ALMOST_FULL``: the level rises above the almost full level.
71-
* ``CMDR_PENDING``: a new synchronization event arrives.
98+
* ``CMDR_PENDING``: a new :ref:`i3c_controller cmdr` event arrives.
7299
* ``IBI_PENDING``: a new IBI event arrives.
73100
* ``DAA_PENDING``: a peripheral requested an address during the DAA.
74101

@@ -98,14 +125,9 @@ FIFO Threshold Interrupts
98125
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99126

100127
The FIFO threshold interrupts can be used by software for flow control of the
101-
streams.
102-
103-
If an application wants to send more data than what fits into the FIFO can write
104-
samples into the FIFO until it is full then suspend operation wait for the almost
105-
empty interrupt and continue writing data to the FIFO.
106-
Similarly, when the application wants to read more data than what fits into FIFO
107-
it should listen for the almost full interrupt and read data from the FIFO when
108-
it occurs.
128+
streams, for example,
129+
listen to the FIFO level interrupts during data transfer to and from the FIFOs
130+
to avoid data loss.
109131

110132
The FIFO threshold interrupt is asserted when then FIFO level rises above the
111133
watermark and is automatically de-asserted when the level drops below the
@@ -114,7 +136,7 @@ watermark.
114136
Pending Interrupts
115137
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116138

117-
The pending interrupts ``*_PENDING`` is asserted when a new sync event is received
139+
The pending interrupt ``*_PENDING`` is asserted when a new sync event is received
118140
from a stream.
119141
For information about the ``CMDR`` see :ref:`i3c_controller cmdr`, and about the
120142
``IBI`` see :ref:`i3c_controller ibi`.

docs/library/i3c_controller/index.rst

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,19 @@ I3C Controller
1010
Core Module<i3c_controller_core>
1111
Interface<interface>
1212

13-
I3C Controller is subset of the I3C specification to interface peripheral such
14-
as ADCs through I3C.
13+
I3C Controller is subset of the I3C-basic specification to interface peripherals
14+
such as ADCs through I3C.
15+
16+
It consist out of two sub-modules which communicate over well defined interfaces.
17+
The :ref:`i3c_controller core` is a lean but powerful execution module, which
18+
implements the I3C bus control logic.
19+
It is controlled by a command stream generated by the :ref:`i3c_controller host_interface`,
20+
which parses the :ref:`i3c_controller command_descriptors`.
21+
22+
The :ref:`i3c_controller offload-interface` operation mode allows to execute
23+
a pre-programmed command stream when triggered by an external event, allowing for
24+
minimal latency.
25+
1526

1627
Sub-modules
1728
--------------------------------------------------------------------------------
@@ -24,12 +35,14 @@ Sub-modules
2435
Interfaces
2536
--------------------------------------------------------------------------------
2637

27-
* :ref:`i3c_controller control-interface`: SPI Engine command stream.
28-
* :ref:`i3c_controller offload-control-interface`: Program the command stream
29-
stored in a offload module.
38+
* :ref:`i3c_controller control-interface`: Command descriptors.
39+
* :ref:`i3c_controller offload-interface`: Command descriptors for cyclic operation,
40+
with SDI data generally consumed by a DMA.
3041

3142
Software
3243
--------------------------------------------------------------------------------
3344

45+
* :git-linux:`Linux Driver <i3c:drivers/i3c/master/adi-i3c-master.c>`:
46+
Linux driver for the I3C Controller.
3447
* :ref:`i3c_controller instruction-format`: Overview of the I3C Controller
3548
instruction format.

docs/library/i3c_controller/interface.rst

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ The interface consists of five streams:
1818
Instruction Set Specification
1919
--------------------------------------------------------------------------------
2020

21-
The I3C Controller instruction set is a pair of 32-bit instruction set (command
22-
0 and command 1).
21+
The I3C Controller instruction set is a pair of 32-bit command descriptors
22+
(command 0 and command 1), with the latter present only for some command 0 values.
2323

2424
.. _i3c_controller command_descriptors:
2525

@@ -85,7 +85,7 @@ The CCC ID is defined in the *linux/i3c/ccc.h* file.
8585
the procedure.
8686

8787
Bits not presented in the tables are assumed 0.
88-
When Value is filled, it means it is is the required constant value for this
88+
When Value is filled, it means it is the required constant value for this
8989
transfer.
9090

9191
+------------------------------------------------------------------------------+
@@ -164,7 +164,7 @@ Command Receipts
164164

165165
Command receipts (cmdr) are returned descriptors for each command descriptor
166166
executed (cmd).
167-
When a new cmdr is written to the CMDR FIFO, an interruption is sent to
167+
When a new cmdr is written to the CMDR FIFO, an interrupton is sent to
168168
PS, see :ref:`i3c_controller interrupts`.
169169

170170
In the cmdr, the buffer length is updated with the number of bytes actually
@@ -232,7 +232,7 @@ In-Band Interrupts
232232
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
233233

234234
IBI\s are accepted autonomously during bus idle if the feature is enabled.
235-
The accepted IBI\s fill the IBI FIFO and generate an interruption in the
235+
The accepted IBI\s fill the IBI FIFO and generate an interrupt to the
236236
PS.
237237

238238
The structure of the received IBI is:
@@ -364,42 +364,43 @@ the possible commands, and body is a 1-byte that depends on the header.
364364
Configuration Registers
365365
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
366366

367-
.. _i3c_controller offload-control-interface:
367+
.. _i3c_controller offload-interface:
368368

369-
Offload Control Interface
369+
Offload Interface
370370
--------------------------------------------------------------------------------
371371

372372
The offload interface allows to cyclic operation with SDI output to a DMA.
373373
The offload commands are the same as in :ref:`i3c_controller command_descriptors`,
374-
however no command receipt is emitted and less complex should be preferred with
375-
this interface, specially that the I3C specification allows the peripheral to
376-
reject a transfer.
377-
378-
Instead of writing the command to a FIFO, the user shall write the commands in
379-
sequence to the OFFLOAD_CMD_* registers and update the OFFLOAD_CMD_LENGTH
380-
register subfield (one shall set the OPS_MODE to offload at the same write).
381-
The offload logic will then execute in cycles at each offload_trigger when
382-
in OPS_MODE offload ('b11).
383-
384-
In summary, are suitable of the offload interface register read transfers.
374+
however no command receipt is emitted and less complex transactions are preferred
375+
with this interface, specially that the I3C specification allows the peripheral to
376+
reject a transfer;
377+
in summary, are suitable of the offload interface register read transfers, e.g.
378+
ADC readings.
379+
380+
To use this mode,
381+
instead of writing the command to the CMD FIFO and the payloads to SDO FIFO:
382+
383+
* Write the command descriptors in sequence of execution to the OFFLOAD_CMD_*
384+
registers.
385+
* Populate the OFFLOAD_SDO_* registers with the SDO payload, preserving unused
386+
bytes slots (don't mix different commands payload in the same address).
387+
* Update the OPS_OFFLOAD_LENGTH register subfield with the number of commands
388+
descriptors.
389+
390+
The offload logic will then execute a burst for each offload_trigger
391+
(OPS_MODE must be 'b1).
392+
Also, one shall set the OPS_MODE to offload at the same write of the
393+
OPS_OFFLOAD_LENGTH.
385394

386395
The Block RAM Offload
387396
--------------------------------------------------------------------------------
388397

389-
A 16-bit wide address, 32-bit data dual access block ram is used to store the
398+
A 5-bit wide address, 32-bit data dual access block ram is used to store the
390399
offload commands and SDO.
391400

392-
The registers are mapped at [4:4] LSB:
393-
394-
.. list-table::
395-
:header-rows: 1
396-
397-
* - Value [5:5]
398-
- Description
399-
* - ``0``
400-
- Commands
401-
* - ``1``
402-
- SDO
401+
The bit 5 indicates if it's a command descriptor ('b0) or a SDO payload ('b1).
402+
The actual width of the address and data depends on the implementation, but in
403+
general the 5-bit address is placed as a 16-bit address with the 11 MSB grounded.
403404

404405
Debugging Tips
405406
--------------------------------------------------------------------------------

docs/regmap/adi_regmap_i3c_controller.txt

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ CMD_FIFO_ROOM
183183
ENDREG
184184

185185
FIELD
186-
[31:0] 0x????????
186+
[31:0]
187187
CMD_FIFO_ROOM
188188
RO
189189
Number of free entries in the CMD FIFO.
@@ -213,7 +213,7 @@ SDO_FIFO_ROOM
213213
ENDREG
214214

215215
FIELD
216-
[31:0] 0x????????
216+
[31:0]
217217
SDO_FIFO_ROOM
218218
RO
219219
Number of free entries in the SDO FIFO.
@@ -265,7 +265,7 @@ See :ref:`i3c_controller instruction-format` for the structure of the command.
265265
ENDREG
266266

267267
FIELD
268-
[31:0] 0x??
268+
[31:0]
269269
CMD_FIFO
270270
WO
271271
The command to the I3C controller to execute.
@@ -357,7 +357,7 @@ Writing to it has no effect.
357357
ENDREG
358358

359359
FIELD
360-
[31:0] 0x??
360+
[31:0] 0x????????
361361
SDI_FIFO
362362
RO
363363
ENDFIELD
@@ -426,24 +426,25 @@ ENDFIELD
426426
REG
427427
0x40
428428
OPS
429+
Configure the operation of the controller.
429430
ENDREG
430431

431432
FIELD
432-
[0] 0x??
433+
[0] 0x0
433434
OPS_MODE
434435
RW
435-
Set 0 to private transfers, 1 to offload.
436+
Set 0 to direct transfers, 1 to offload operation.
436437
ENDFIELD
437438

438439
FIELD
439-
[4:1] 0x??
440+
[4:1] 0x0
440441
OPS_OFFLOAD_LENGTH
441442
RW
442443
Offload commands length.
443444
ENDFIELD
444445

445446
FIELD
446-
[6:5] 0x??
447+
[6:5] 0x00
447448
OPS_SPEED_GRADE
448449
RW
449450
Sets the speed grade in push-pull mode.
@@ -467,10 +468,11 @@ ENDIELD
467468
REG
468469
0x50
469470
IBI_CONFIG
471+
Configure the In-Band Interrupt (IBI) feature.
470472
ENDREG
471473

472474
FIELD
473-
[0] 0x??
475+
[0] 0x0
474476
IBI_CONFIG_ENABLE
475477
WO
476478
Set this bit to accept (ACK) IBI requests.
@@ -482,7 +484,7 @@ Accepted IBIs fill the IBI_FIFO and generate an interruption in the PS.
482484
ENDFIELD
483485

484486
FIELD
485-
[1] 0x??
487+
[1] 0x0
486488
IBI_CONFIG_AUTO
487489
WO
488490
Set this bit to listen for IBI requests (when a peripheral pulls SDA Low during quiet times).
@@ -534,14 +536,14 @@ Indicates if the device sends an MDB during the IBI.
534536
ENDFIELD
535537

536538
FIELD
537-
[8:8] 0x???
539+
[8:8] 0xX
538540
DEV_CHAR_WEN
539541
W
540542
Enable write of the fields.
541543
ENDFIELD
542544

543545
FIELD
544-
[15:9] 0x???
546+
[15:9] 0x??
545547
DEV_CHAR_ADDR
546548
RW
547549
Device address to apply DEV_CHAR[3:0].
@@ -557,15 +559,52 @@ Offload command memory. Write commands in sequence to these addresses and update
557559
OFFLOAD_CMD_LENGTH register.
558560
ENDREG
559561

562+
FIELD
563+
[31:0] 0x??????
564+
OFFLOAD_CMD
565+
RW
566+
The command to the I3C controller to execute.
567+
ENDFIELD
568+
560569
############################################################################################
561570
############################################################################################
562571

563572
REG
564573
0xc0 + 0x01*n
565574
OFFLOAD_SDO_n
566575
Offload SDO memory.
567-
The length is infered by the commands and reset after each burst.
576+
Dual access memory sector used to store the SDO payload for the offload execution.
577+
The SDO is read by the parsing the OFFLOAD_CMD commands.
578+
For example, if the first command on OFFLOAD_CMD is a write with length 3 and the next with
579+
length 2, 3 bytes from OFFLOAD_SDO_0 are sent, then 2 bytes from OFFLOAD_SDO_1 are sent.
580+
If OPS_OFFLOAD_LENGTH is 2, then the burst concludes and the "pointer" resets to
581+
OFFLOAD_SDO_0, otherwise, the execution continues until all commands are resolved, always
582+
bounded by OPS_OFFLOAD_LENGTH.
568583
ENDREG
569584

585+
FIELD
586+
[31:24] 0x??
587+
OFFLOAD_SDO_BYTE_3
588+
RO
589+
ENDFIELD
590+
591+
FIELD
592+
[23:16] 0x??
593+
OFFLOAD_SDO_BYTE_2
594+
RO
595+
ENDFIELD
596+
597+
FIELD
598+
[15:8] 0x??
599+
OFFLOAD_SDO_BYTE_1
600+
RO
601+
ENDFIELD
602+
603+
FIELD
604+
[7:0] 0x??
605+
OFFLOAD_SDO_BYTE_0
606+
RO
607+
ENDFIELD
608+
570609
############################################################################################
571610
############################################################################################

0 commit comments

Comments
 (0)