Commit Graph

198 Commits

Author SHA1 Message Date
Benjamin Cabé
34c4f9e6b1 drivers: i3c: cdns: fix bitwise operation in CONF_STATUS0_DEV_ROLE macro
Updated the CONF_STATUS0_DEV_ROLE macro to ensure proper bitwise
operation by adding parentheses around the bitmask operation.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-18 07:38:58 +02:00
Nghia Phung
fe2b374d00 drivers: i3c: Correct register to read IBI response
SLV_IBI_RESP is the register to read IBI response, not SLV_INTR_REQ

Signed-off-by: Nghia Phung <nghiap@amperecomputing.com>
2025-06-18 07:37:36 +02:00
Nghia Phung
caf42fbdef drivers: i3c: Check for the existence of callback before invoking
I3C callbacks are registered by upper layer. Driver layer must check if
a callback is not NULL before calling it

Signed-off-by: Nghia Phung <nghiap@amperecomputing.com>
2025-06-18 07:37:36 +02:00
Nghia Phung
90dd76bf7a drivers: i3c: Correct some I3C register name
Register at offset 0xe8 is QUEUE_SIZE_CAPABILITY
Register at offset 0xec is RELEASE_SDA_TIMING

Signed-off-by: Nghia Phung <nghiap@amperecomputing.com>
2025-06-18 07:37:36 +02:00
Nghia Phung
0d0aea18fd drivers: i3c: Handle Hotjoin completion
When Hotjoin complete and dynamic address is assigned to target,
INTR_DYN_ADDR_ASSGN_STAT interrupt will be triggered, we can use sem_hj
to notify dw_i3c_target_ibi_raise_hj() about Hotjoin completion

Signed-off-by: Nghia Phung <nghiap@amperecomputing.com>
2025-06-18 07:37:36 +02:00
Nghia Phung
f22e1018d5 drivers: i3c: init sem_hj semaphore
Add initialization for sem_hj, it is being used without initialization.

Signed-off-by: Nghia Phung <nghiap@amperecomputing.com>
2025-06-18 07:37:36 +02:00
Alvis Sun
c2f45ca588 drivers: i3c: npcx: add support for target reset request handling
This patch introduces handling for the target reset request (RSTACT)
in the I3C controller.
It enables the controller to send a broadcast RSTACT command along with
the target reset pattern in a single frame.

Signed-off-by: Alvis Sun <yfsun@nuvoton.com>
2025-06-06 08:43:32 +02:00
Ryan McClelland
8c7417a552 drivers: i3c: fix adv_info_get ret code
It's possible if a device is an i3c v1.0 spec, no hdr, no mxds,
no controller caps, and does not have a mrl nor mwl. It should
return 0 if it doesn't need to do anything.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-05-31 07:06:13 -04:00
Ryan McClelland
af1ba95ba7 drivers: i3c: cdns: add busy status
Add busy status for cadence i3c.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-05-31 07:03:19 -04:00
Ryan McClelland
d3a7b7df9a drivers: i3c: cdns: fix ibi length with no payload
If the BCR value is not set for ibi w/ payload, then it still
has a ibi length of 1 due to the MDB. Set the PL accordingly.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-05-31 06:54:59 -04:00
Daniel Leung
069cd4b861 i3c: rtio: deal with rtio_cqe_consume() returning NULL
rtio_cqe_consume() may return NULL so we need to check before
using any members of the returned struct.

Fixes #90473
Fixes #90489
Fixes #90497

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-05-29 20:18:43 -04:00
Daniel Leung
157bea57c8 i3c: set default return for i3c_device_adv_info_get()
Coverity flagged that the return variable ret may not be
initialized when returning. So give it a default value.

Fixes #90509

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-05-29 20:18:43 -04:00
Benjamin Cabé
d5e4b44696 drivers: i3c: Fix misspelling of brief in doxygen
Fixes trivial typo

Co-authored-by: Harry Martin <48959255+Harry-Martin@users.noreply.github.com>
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-05-07 11:44:33 +02:00
Ren Chen
437c16fcf9 drivers: i3c: shell: enable i3c shell support for it51xxx.
This commit introduces support for i3c shell on it51xxx.

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2025-05-06 13:01:13 +02:00
Ren Chen
9743a983f8 drivers: i3c: add it51xxx i3cm driver
Add it51xxx i3c controller driver.

Tested with: it51xxx evb board with st_lps22df sensor

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2025-05-06 13:01:13 +02:00
Ren Chen
76efd333cc drivers: i3c: add it51xxx i3cs driver
Add it51xxx i3c target driver.

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2025-05-06 13:01:13 +02:00
Hu Dou
25564f73dc drivers: i3c: stm32: fix clock init for i2c fast mode plus
The logic of clock initialization for i2c fast mode (FM) and fast
mode plus (FMP) is as follows:
 1 compute how many system clock cycles for SCL to be low
 2 compute how many system clock cycles for SCL to be high by
   subtracting the low duration computed above from the SCL period
 3 verify the high duration computed in 2 is larger than a minimum
The bug is that the step 3 for the FMP is compared with the
minimum value for FM, and causes it to fail.

The fix corrects the bug.

Signed-off-by: Hu Dou <hugh.dou@gmail.com>
2025-04-21 12:42:01 +02:00
Ryan McClelland
3932794aee drivers: i3c: shell: add direct rstdaa shell command
This adds a shell helper for a direct rstdaa for I3C v1.0 devices

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-04-17 21:16:45 +02:00
Ryan McClelland
c0503597ba drivers: i3c: add rstdaa direct helper
In I3C v1.0, there was a RSTDAA direct CCC. It is deprecated in I3C v1.1
and later. This adds a CCC helper for it.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-04-17 21:16:45 +02:00
Ryan McClelland
2e8c911fa3 drivers: i3c: add v1.0 support flag
This adds a v1.0 support dts flag for devices. This also makes it so it
doesn't try to send a GETCAPS (GETHDRCAP) ccc if this flag is set and it
doesn't support any HDR modes.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-04-17 21:16:45 +02:00
Ryan McClelland
2c66a2adc0 drivers: i3c: add i3c controller and target kconfigs
I3C can contain a lot of features that may be unused. Add Kconfigs for
enabling controller and/or target code. Choosing just one can reduce
the code size footprint.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-04-17 09:05:36 +02:00
Ren Chen
b601a357cd drivers: i3c: shell: fix the argv index for broadcast setwml ccc
For the broadcast setwml ccc, the argument vector index of the input
length is 2 instead of 3. This commit fixs this issue.

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2025-04-11 06:34:36 +02:00
Ryan McClelland
28a7ad4a57 drivers: i3c: add primary controller da property
Add a way to assign the dynamic address for a primary controller. This
is the address that is broadcasted out with the ccc DEFTGTS, and is the
address that secondary controllers use to communicate with the primary
controller.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-04-10 10:11:37 +02:00
Ryan McClelland
5eb7ae34d4 drivers: i3c: cdns: remove +1 on len for abort limit
The datasheet erroneously suggested to add a + 1 to the abort len.
This was suggested because if a controller gave a EoD, then it was
afraid that the abort would take precedence over the EoD. This was
not true. The EoD will always take precedence over a controller
abort. Remove the + 1 as this can cause issues.

For example, when talking to a part that will auto-increment a read
address, having the +1 can unknownly move this address pointer further
than anticipated.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-04-09 11:43:08 +02:00
Ryan McClelland
393da0f953 drivers: i3c: cdns: secondary controllers can do_daa
It is most certainly 'okay' for a secondary controller to do a
ENTDAA. Remove the 'block' that was preventing this.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-04-09 11:43:08 +02:00
Ryan McClelland
248f7971e4 drivers: i3c: stm32: fix ibi build issue
Use the correct 'place' for the hj_pm_lock variable

Signed-off-by: Ryan McClelland <rymcclel@gmail.com>
2025-03-26 07:08:17 +01:00
Ryan McClelland
9628d97ad9 drivers: i3c: remove group addr definition
The i3c group address support is rather very incomplete here. Remove
references to it. This could all easily come back when/if group support
comes in.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-03-26 00:47:00 +01:00
Ryan McClelland
9bce73a6e0 drivers: i3c: cleanup const
There is const used in a few places and some hacks to get around
that const. Just remove the const as well as remove the hacks.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-03-25 08:44:02 +01:00
Ryan McClelland
8bf6dac549 drivers: i3c: dw: add rtio callbacks
Add the missing api callbacks for i3c and i2c rtio.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-03-21 06:31:07 +01:00
Ryan McClelland
28676ae9be drivers: i3c: shell: fix getmxds fmt3 defbyte check
Fix the checking on the getmxds for format 3.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-03-21 06:31:03 +01:00
Ryan McClelland
30b4b1bdf8 drivers: i3c: shell: fix getcaps fmt2 defbyte check
Fix the checking on the getcaps for format 2.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-03-21 06:31:03 +01:00
Corey Wharton
6d01483b01 drivers: i3c: i3c_dw: skip I3C bus init on pure I2C buses
If the bus is only used I2C we can skip I3C bus initialization which
will send a number of unnecessary CCC transactions.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
2025-03-14 05:47:26 +01:00
Corey Wharton
a19429eb39 drivers: i3c: i3c_dw: make transfer timeout a Kconfig option
The current value of 1s is much too long, default to 100ms instead
which is enough for even a large 4kB FM I2C transfer to finish in
time let alone a typical I3C transfer. Make this configurable in
case projects want to tune this.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
2025-03-14 05:47:26 +01:00
Corey Wharton
b818a7662d drivers: i3c: i3c_dw: dynamically attach I2C devices on transfer
The maximum number of attached devices is limited by the maximum
number of entries in the device address table. For I3C devices
these have to by allocated permanently when devices are attached
but for I2C devices we can dynamically allocate an entry in the
table on a I2C transfer and free it after the transfer is completed.
This allows the maximum number of I2C + I3C devices on a bus to be
larger than the address table size as long as the number of I3C
devices is maxdevs - 1.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
2025-03-14 05:47:26 +01:00
Corey Wharton
e330a69aec drivers: i3c: i3c_dw: mark device busy during transfers
Prevent the device from being automatically suspended during transfers.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
2025-03-14 05:47:26 +01:00
Corey Wharton
6ed98bfc42 drivers: i3c: i3c_dw: add pinctrl support
Adds pinctrl support on init and on PM actions. General PM support is added
to the driver to enable the later.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
2025-03-14 05:47:26 +01:00
Ren Chen
9388349957 drivers: i3c: ccc: add missing data length for entas
This commit adds the missing data length(=0) for entas ccc.

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2025-03-07 20:24:04 +01:00
Ren Chen
20dbf4d7a0 drivers: i3c: shell: fix the judgement/argc count for getstatus/ibi tir
The errno for format 2 of the getstatus ccc always returns an error.
The check for the invalid defining byte should use the "AND" operation
instead of "OR." Additionally, the first byte of the ibi tir sending
request is ignored due to the incorrect argument count.
This commit fixes both issues.

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2025-03-07 20:24:04 +01:00
Ren Chen
373771c062 drivers: i3c: common: fix the setaasa flow
There is an incorrect dynamic address setting for setaasa. The correct
behavior is that the dynamic address should be assigned as a static
address only when the CCC request returns success. This commit fixes the
issue.

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2025-03-07 20:24:04 +01:00
Ryan McClelland
b495907ae5 drivers: i3c: cleanup target config descrition and add inline helpers
It shouldn't be possible to just 'enable' target mode of a device.
It is required by the specification to perform a handoff or request to
become a target or controller from the active controller. Not to just flip
a switch internally. Can the parameter from `enable` to `enabled` to report
if it is currently a target or a controller otherwise.

Also, add inline helpers for `i3c_config_get` and `i3c_configure` to ensure
the proper struct is passed in.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-03-07 19:50:08 +01:00
Ryan McClelland
93099e303e drivers: i3c: run clang-format on i3c_common.c
Run clang-formatt on i3c_common.c

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-03-07 19:50:08 +01:00
Benjamin Cabé
ff9fd96036 drivers: fix spelling of "transfer"
s/trasnfer/transfer/

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-21 11:41:46 +00:00
Ryan McClelland
d225d1525c drivers: i3c: cdns: fix ibi thr write
The dts define for the ibi threshold (watermark) was be written to the
ibi response threshold. Fix it to write to the correct spot.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-02-18 09:56:17 +01:00
Ryan McClelland
1b7de61977 drivers: i3c: cdns: fix up deftgts mem alloc
deftgts could be a different length the second time around. Also, be
more efficient rather than just allocaing the max_devs each time.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-02-18 09:56:17 +01:00
Ryan McClelland
534c4148a9 drivers: i3c: add snps_designware_i3c to i3c shell
add the synopsys designware i3c to the i3c shell.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-02-14 03:02:43 +01:00
Ryan McClelland
e9ea97e92d drivers: i3c: add synopsys designware i3c driver
Add synopsys designware i3c driver

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-02-14 03:02:43 +01:00
Ryan McClelland
653589c558 drivers: i3c: add controller handoff support
Add controller handoff

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-02-11 22:03:32 +01:00
Ryan McClelland
e5ac786ba8 drivers: i3c: shell: record crcaps and crhdly1 in to desc from shell
Record the crcaps and crhdly1 in to the i3c descriptor when calling from
the shell.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-02-11 22:03:32 +01:00
Ryan McClelland
3805ac189a drivers: i3c: shell: add crhdly1 and crcaps to info
Add crhdly1 and crcaps to the info shell command.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-02-11 22:03:32 +01:00
Ryan McClelland
88f5e16edc drivers: i3c: add controller handoff helper
This adds controller handoff according to section 5.1.7.1 of the
I3C specification.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-02-11 22:03:32 +01:00