The bus helpers for SETDASA and SETNEWDA could have the same
dynamic address assigned as it's static addr for SETDASA or
as it's dynamic addr for SETNEWDA. (Althrough, only a clown
would set the new dynamic address to the same old dynamic
address, it is still a valid address to set to).
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Create bus helpers that will send ccc commands as well as update
items within the i3c descriptor. These are different than the
direct ccc functions as these can give a bit of convience to also
updating the descriptor.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
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>
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>
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>
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>
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>
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>
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>
Add the parameters crcaps and crhdly1 in to the i3c device descriptor.
Also, retrieve the values if they are available.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
For ENTDAA, BCR and DCR is always transmitted back up to the controller.
When `i3c_bus_init` is done, it does the ENTDAA then it would get the
basic info would get the BCR and DCR again. This was rather reduntant.
This now splits it up so there is a function called
`i3c_device_adv_info_get` which gets the mrl, mwl, getcaps, and the
mxds. `i3c_device_basic_info_get` now only just gets the bcr and dcr.
There is also an inline function called `i3c_device_info_get` which
will get everything.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
The ENTDAA does not have a way to assign DA that are with a PID. It will
assign DAs that were in it's RRs in the order that they win arbitration.
Assign only available addresses in to it's RRs before ENTDAA.
Cleanup the attach api to no longer require a addr argument and remove
the helper function `i3c_determine_default_addr`. This now looks at if
it has a static address or if it already has a dynamic address (such as
from DEFTGTS) and will register the address if either exist with
precidence of dynamic addr over static addr.
This also fixes up the look up for if a device already has a dynamic
addr to find which pos of the RRs is it is in.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
struct i3c_ccc_address is intended to match the output where the address
is left shifted by 1 for SETDASA and SETNEWDA. Require the operations
calling it to shift the data.
add an additional parameter for the setdasa function which will allow for
the da to be configured rather than being hard coded.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Add i3c_bus_for_each_i3cdev and i3c_bus_for_each_i2cdev to more easily
iterate through each i3c or i2c device on the bus.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Add the function, i3c_device_is_controller_capable, to determine if
a target is controller capable.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
The Active Controller data struct for static addr is to always be
0x7E. This is so the active controller can be identified according
to section 5.1.9.3.7 of the I3C v1.1.1 Specification.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Add support the ccc deftgts. This also includes a function to check if
there is a secondary controller on the bus, and will transmit deftgts
after initialization or a hotjoin event.
This also adds dynamic_addr to the config_target in order to retrieve
the currently configured dynamic address to be used with deftgts.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Adds a new DTS prop for i3c devices as support for the CCC SETAASA
requires prior knowledge of the target if it supports it according
to i3c spec v1.1.1 section 5.19.3.23.
This will be used as an optimization for bus initialization.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
If it's a I3C v1.0 device without any HDR modes do not treat as an error
if GETCAPS gives no valid response.
Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
Sometimes, performing a rstact which will reset all devices during init
on the bus may not be ideal. Add a KConfig to easily turn off.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Perform the modulo operation on `bitpos` before using it. This should
make code slightly more clear.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
During DAA, the responding device might not be in the device list.
This CL adds target device descriptor's pointer checking to prevent
getting unexpected results.
Signed-off-by: Alvis Sun <yfsun@nuvoton.com>
For example, if a driver needed to reserve address before it does a
ENTDAA, it would need to get free address in a loop, but the get
free address func would return the same address everytime. It needs
the start address, which would be the last free address it go, to
be passed in to get the next free address.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
There are some needs to attach and reattach i3c/i2c devices at runtime
Some I2C devices can have special registers where the address can be
changed at runtime. Also some I3C devices can be powered off at runtime
freeing up the address space they take up. These new APIs allow for these
to be changed at runtime. This also moves some config/data in to a common
i3c config/data structure which would allow the api to operate on to be
common for all I3C drivers.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Some I3C controllers have retaining registers which are used to contain
the DA of the i3c device. This needs to be updated every time the DA is
updated with SETNEWDA or SETDASA
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
According to section 5.1.9.3.5 and 5.1.9.3.6 of the I3C Specification
v1.1.1. This CCC is may be optionally supported if the target device
has no settable limit.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
This introduces the I3C API for I3C controllers. Currently,
this supports one controller per bus under Zephyr.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>