Skip to content

Commit 2e8c911

Browse files
XenuIsWatchingkartben
authored andcommitted
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>
1 parent 2f9faa0 commit 2e8c911

File tree

5 files changed

+52
-31
lines changed

5 files changed

+52
-31
lines changed

drivers/i3c/i3c_common.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -777,28 +777,28 @@ int i3c_device_adv_info_get(struct i3c_device_desc *target)
777777
/* GETMRL */
778778
if (i3c_ccc_do_getmrl(target, &mrl) != 0) {
779779
/* GETMRL may be optionally supported if no settable limit */
780-
LOG_DBG("No settable limit for GETMRL");
780+
LOG_DBG("%s: No settable limit for GETMRL", target->dev->name);
781781
}
782782

783783
/* GETMWL */
784784
if (i3c_ccc_do_getmwl(target, &mwl) != 0) {
785785
/* GETMWL may be optionally supported if no settable limit */
786-
LOG_DBG("No settable limit for GETMWL");
786+
LOG_DBG("%s: No settable limit for GETMWL", target->dev->name);
787787
}
788788

789789
/* GETCAPS */
790-
ret = i3c_ccc_do_getcaps_fmt1(target, &caps);
791-
/*
792-
* GETCAPS (GETHDRCAP) is required to be supported for I3C v1.0 targets that support HDR
793-
* modes and required if the Target's I3C version is v1.1 or later, but which the version it
794-
* supports it can't be known ahead of time. So if the BCR bit for Advanced capabilities is
795-
* set, then it is expected for GETCAPS to always be supported. Otherwise, then it's a I3C
796-
* v1.0 device without any HDR modes so do not treat as an error if no valid response.
797-
*/
798-
if ((ret != 0) && (target->bcr & I3C_BCR_ADV_CAPABILITIES)) {
799-
return ret;
800-
} else {
801-
ret = 0;
790+
if (((target->flags & I3C_V1P0_SUPPORT) && (target->bcr & I3C_BCR_ADV_CAPABILITIES)) ||
791+
(!(target->flags & I3C_V1P0_SUPPORT))) {
792+
/*
793+
* GETCAPS (GETHDRCAP) is required to be supported for I3C v1.0 targets that support
794+
* HDR modes and required if the Target's I3C version is v1.1 or later.
795+
* It is also possible for this function to be called on an 'unknown' device such as
796+
* from a secondary controller gathering info about a target it found about through
797+
* DEFTGTS, and it can't be known ahead of time if it is a v1.0 or v1.1 device.
798+
*/
799+
if (i3c_ccc_do_getcaps_fmt1(target, &caps) != 0) {
800+
LOG_DBG("%s: GETCAPS not received", target->dev->name);
801+
}
802802
}
803803

804804
/* CRCAPS */
@@ -873,8 +873,9 @@ static int i3c_bus_setdasa(const struct device *dev, const struct i3c_dev_list *
873873
* address as its static address if a different dynamic address
874874
* is not requested
875875
*/
876-
if ((desc->supports_setaasa) && ((desc->init_dynamic_addr == 0) ||
877-
desc->init_dynamic_addr == desc->static_addr)) {
876+
if ((desc->flags & I3C_SUPPORTS_SETAASA) &&
877+
((desc->init_dynamic_addr == 0) ||
878+
desc->init_dynamic_addr == desc->static_addr)) {
878879
*need_aasa = true;
879880
continue;
880881
}
@@ -1079,7 +1080,8 @@ int i3c_bus_init(const struct device *dev, const struct i3c_dev_list *dev_list)
10791080
* Only set for devices that support SETAASA and do not
10801081
* request a different dynamic address than its SA
10811082
*/
1082-
if ((desc->supports_setaasa) && (desc->static_addr != 0) &&
1083+
if ((desc->flags & I3C_SUPPORTS_SETAASA) &&
1084+
(desc->static_addr != 0) &&
10831085
((desc->init_dynamic_addr == 0) ||
10841086
desc->init_dynamic_addr == desc->static_addr)) {
10851087
desc->dynamic_addr = desc->static_addr;

drivers/i3c/i3c_shell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ static int cmd_i3c_ccc_setaasa(const struct shell *sh, size_t argc, char **argv)
629629

630630
/* set all devices DA to SA */
631631
I3C_BUS_FOR_EACH_I3CDEV(dev, desc) {
632-
if ((desc->supports_setaasa) && (desc->dynamic_addr == 0) &&
632+
if (((desc->flags) & I3C_SUPPORTS_SETAASA) && (desc->dynamic_addr == 0) &&
633633
(desc->static_addr != 0)) {
634634
desc->dynamic_addr = desc->static_addr;
635635
}

dts/bindings/i3c/i3c-device.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,8 @@ properties:
6767
description: |
6868
Indicates if the device supports the CCC SETAASA. If true, it will
6969
be used as an optimization for bus initialization.
70+
71+
v1p0-support:
72+
type: boolean
73+
description: |
74+
Indicates if the device compiles to I3C v1.0.

include/zephyr/drivers/i3c.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -929,12 +929,13 @@ struct i3c_device_desc {
929929
const uint8_t init_dynamic_addr;
930930

931931
/**
932-
* Device support for SETAASA
932+
* Device Flags
933933
*
934-
* This will be used as an optimization for bus initializtion if the
934+
* BIT[0]: This shall be used as an optimization for bus initializtion if the
935935
* device supports SETAASA.
936+
* BIT[1]: This shall be used to indicate if the device is a I3C v1.0 device
936937
*/
937-
const bool supports_setaasa;
938+
const uint8_t flags;
938939

939940
/**
940941
* Dynamic Address for this target device used for communication.

include/zephyr/drivers/i3c/devicetree.h

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ extern "C" {
5252
#define I3C_DEVICE_ID_DT_INST(inst) \
5353
I3C_DEVICE_ID_DT(DT_DRV_INST(inst))
5454

55+
/**
56+
* @name I3C device flags.
57+
* @anchor I3C_DEVICE_FLAGS
58+
* @{
59+
*/
60+
61+
/** Device supports SETAASA CCC */
62+
#define I3C_SUPPORTS_SETAASA BIT(0)
63+
/** Device supports I3C v1.0 */
64+
#define I3C_V1P0_SUPPORT BIT(1)
65+
66+
/** @} */
67+
5568
/**
5669
* @brief Structure initializer for i3c_device_desc from devicetree
5770
*
@@ -62,16 +75,16 @@ extern "C" {
6275
* @param node_id Devicetree node identifier for the I3C device whose
6376
* struct i3c_device_desc to create an initializer for
6477
*/
65-
#define I3C_DEVICE_DESC_DT(node_id) \
66-
{ \
67-
.bus = DEVICE_DT_GET(DT_BUS(node_id)), \
68-
.dev = DEVICE_DT_GET(node_id), \
69-
.static_addr = DT_PROP_BY_IDX(node_id, reg, 0), \
70-
.pid = ((uint64_t)DT_PROP_BY_IDX(node_id, reg, 1) << 32)\
71-
| DT_PROP_BY_IDX(node_id, reg, 2), \
72-
.init_dynamic_addr = \
73-
DT_PROP_OR(node_id, assigned_address, 0), \
74-
.supports_setaasa = DT_PROP(node_id, supports_setaasa), \
78+
#define I3C_DEVICE_DESC_DT(node_id) \
79+
{ \
80+
.bus = DEVICE_DT_GET(DT_BUS(node_id)), \
81+
.dev = DEVICE_DT_GET(node_id), \
82+
.static_addr = DT_PROP_BY_IDX(node_id, reg, 0), \
83+
.pid = ((uint64_t)DT_PROP_BY_IDX(node_id, reg, 1) << 32) | \
84+
DT_PROP_BY_IDX(node_id, reg, 2), \
85+
.init_dynamic_addr = DT_PROP_OR(node_id, assigned_address, 0), \
86+
.flags = FIELD_PREP(I3C_SUPPORTS_SETAASA, DT_PROP(node_id, supports_setaasa)) | \
87+
FIELD_PREP(I3C_V1P0_SUPPORT, DT_PROP(node_id, v1p0_support)), \
7588
},
7689

7790
/**

0 commit comments

Comments
 (0)