···13431343 help
13441344 I2C support.
1345134513461346+config CMD_I3C
13471347+ bool "i3c"
13481348+ depends on I3C
13491349+ help
13501350+ Enable command to list i3c devices connected to the i3c controller
13511351+ and perform read and write on the connected i3c devices.
13521352+13461353config CMD_W1
13471354 depends on W1
13481355 default y if W1
···11+.. SPDX-License-Identifier: GPL-2.0
22+33+.. index::
44+ single: i3c (command)
55+66+i3c command
77+===========
88+99+Synopsis
1010+--------
1111+1212+::
1313+1414+ i3c <host_controller>
1515+ i3c current
1616+ i3c list
1717+ i3c device_list
1818+ i3c write <mem_addr> <length> <device_number>
1919+ i3c read <mem_addr> <length> <device_number>
2020+2121+Description
2222+-----------
2323+2424+The ``i3c`` command is used to probe the i3c host controller and perform
2525+read and write operations on the connected i3c devices.
2626+2727+i3c current
2828+------------
2929+3030+Display the currently selected i3c host controller.
3131+3232+i3c list
3333+---------
3434+3535+List all the i3c hosts defined in the device-tree.
3636+3737+i3c device_list
3838+----------------
3939+4040+List all the i3c devices' device number, static address, dynamic address,
4141+PID, BCR, DCR, Max Write Speed, and Max Read Speed of the probed i3c host
4242+controller.
4343+4444+i3c write
4545+----------
4646+4747+Perform a write operation from memory to the connected i3c device. The data
4848+is read from a specified memory address and written to the selected i3c
4949+device, which is identified by its device number.
5050+5151+You need to provide the memory address (``mem_addr``), the length of data
5252+to be written (``length``), and the device number (``device_number``). The
5353+data in memory will be transferred to the device in the specified order.
5454+5555+i3c read
5656+---------
5757+5858+Perform a read operation from the connected i3c device to memory. The data
5959+is read from the selected i3c device and stored at the specified memory
6060+address. You need to provide the memory address (``mem_addr``), the length
6161+of data to be read (``length``), and the device number (``device_number``).
6262+6363+The device will send the requested data, which is then written to the memory
6464+location you specified. This operation allows you to retrieve information
6565+from the device and use it in your application. The data is read in the
6666+order specified and can be multiple bytes.
6767+6868+host_controller
6969+ The name of the i3c host controller defined in the device-tree.
7070+7171+length
7272+ The size of the data to be read or written.
7373+7474+device_number
7575+ The device number in the driver model of the device connected to the i3c
7676+ host controller.
7777+7878+mem_addr
7979+ The start address in memory from which to read or write the data.
8080+8181+Examples
8282+--------
8383+8484+Probe the ``i3c0`` controller::
8585+8686+ => i3c i3c0
8787+8888+Display the current i3c host controller::
8989+9090+ => i3c current
9191+9292+Check the device number and PID of the connected devices::
9393+9494+ => i3c device_list
9595+9696+Perform write operations on the connected i3c device (device 0) from memory::
9797+9898+ => i3c write 0x1000 4 0
9999+100100+ This command reads 4 bytes of data from memory starting at address
101101+ ``0x1000`` and writes them to device 0, which is identified by its device
102102+ number in the driver model. Example data from memory could look like this:
103103+104104+ ```
105105+ Data at 0x1000: 0xAA 0xBB 0xCC 0xDD
106106+ ```
107107+108108+ The bytes `0xAA`, `0xBB`, `0xCC`, and `0xDD` will be written to device 0.
109109+110110+Perform a read operation from device 0 to memory (multiple bytes)::
111111+112112+ => i3c read 0x1000 4 0
113113+114114+ This command reads 4 bytes of data from device 0 and writes them to
115115+ memory starting at address ``0x1000``.
116116+117117+ Example output after reading 4 bytes from device 0:
118118+119119+ ```
120120+ i3c Read:
121121+ 00000000 AA BB CC DD
122122+ ```
123123+124124+ The bytes `0xAA`, `0xBB`, `0xCC`, and `0xDD` are read from device 0
125125+ and written to memory at address `0x1000`.
126126+127127+Configuration
128128+-------------
129129+130130+The ``i3c`` command is only available if CONFIG_CMD_I3C=y.
131131+132132+Return value
133133+------------
134134+135135+If the command succeeds, the return value ``$?`` is set to 0. If an error
136136+occurs, the return value ``$?`` is set to 1.
137137+138138+Note
139139+----
140140+141141+When specifying the data to be written to the i3c device (for example, with
142142+the ``i3c write`` command), the data can be provided in either uppercase
143143+or lowercase hexadecimal format. Both are valid and will be processed
144144+correctly. Similarly, when reading data with ``i3c read``, the data will be
145145+retrieved in the specified length and can include multiple bytes, all
146146+formatted in the same way.