Skip to content

Commit c050359

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

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

drivers/i3c/i3c_ccc.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,26 @@ int i3c_ccc_do_rstact(const struct i3c_device_desc *target,
137137
return i3c_do_ccc(target->bus, &ccc_payload);
138138
}
139139

140+
int i3c_ccc_do_rstdaa(struct i3c_device_desc *target)
141+
{
142+
struct i3c_ccc_payload ccc_payload;
143+
struct i3c_ccc_target_payload ccc_tgt_payload;
144+
145+
__ASSERT_NO_MSG(target != NULL);
146+
__ASSERT_NO_MSG(target->bus != NULL);
147+
148+
ccc_tgt_payload.addr = target->dynamic_addr;
149+
ccc_tgt_payload.rnw = 1;
150+
ccc_tgt_payload.data_len = 0;
151+
152+
memset(&ccc_payload, 0, sizeof(ccc_payload));
153+
ccc_payload.ccc.id = I3C_CCC_RSTDAA_DC;
154+
ccc_payload.targets.payloads = &ccc_tgt_payload;
155+
ccc_payload.targets.num_targets = 1;
156+
157+
return i3c_do_ccc(target->bus, &ccc_payload);
158+
}
159+
140160
int i3c_ccc_do_rstdaa_all(const struct device *controller)
141161
{
142162
struct i3c_ccc_payload ccc_payload;

include/zephyr/drivers/i3c/ccc.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ extern "C" {
179179
*/
180180
#define I3C_CCC_VENDOR(broadcast, id) ((id) + ((broadcast) ? 0x61U : 0xE0U))
181181

182+
/**
183+
* Reset Dynamic Address (Direct)
184+
*
185+
* @note This should not be used by devices that support I3C v1.0 and this
186+
* shall not be used for devices that support I3C v1.1 or later.
187+
*/
188+
#define I3C_CCC_RSTDAA_DC 0x86U
189+
182190
/** Set Dynamic Address from Static Address (Direct) */
183191
#define I3C_CCC_SETDASA 0x87U
184192

@@ -1502,6 +1510,21 @@ static inline int i3c_ccc_do_rstact_fmt3(const struct i3c_device_desc *target,
15021510
return i3c_ccc_do_rstact(target, action, true, data);
15031511
}
15041512

1513+
/**
1514+
* @brief Reset dynamic addresses for a targets.
1515+
*
1516+
* Helper function to reset a dynamic addresses of a targets.
1517+
*
1518+
* @note This should not be used by devices that support I3C v1.0 and this
1519+
* shall not be used for devices that support I3C v1.1 or later.
1520+
*
1521+
* @param[in] target Pointer to the target device descriptor where
1522+
* the device is configured with a dynamic address.
1523+
*
1524+
* @return @see i3c_do_ccc
1525+
*/
1526+
int i3c_ccc_do_rstdaa(struct i3c_device_desc *target);
1527+
15051528
/**
15061529
* @brief Broadcast RSTDAA to reset dynamic addresses for all targets.
15071530
*
@@ -1538,7 +1561,7 @@ int i3c_ccc_do_setdasa(const struct i3c_device_desc *target,
15381561
* Note this does not update @p target with the new dynamic address.
15391562
*
15401563
* @param[in] target Pointer to the target device descriptor where
1541-
* the device is configured with a static address.
1564+
* the device is configured with a dynamic address.
15421565
* @param[in] new_da Struct of the Dynamic address
15431566
*
15441567
* @return @see i3c_do_ccc

0 commit comments

Comments
 (0)