Skip to content

Commit 5855ecb

Browse files
XenuIsWatchingDevansh0210
authored andcommitted
drivers: i3c: add i3c error type in payload
Add the SDR Error Code to be written in to the payload following section 5.1.10.2 of the I3C v1.1.1 specification. Signed-off-by: Ryan McClelland <[email protected]>
1 parent d9181ae commit 5855ecb

File tree

3 files changed

+124
-81
lines changed

3 files changed

+124
-81
lines changed

include/zephyr/drivers/i3c.h

Lines changed: 9 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <zephyr/device.h>
2525
#include <zephyr/drivers/i3c/addresses.h>
26+
#include <zephyr/drivers/i3c/error_types.h>
2627
#include <zephyr/drivers/i3c/ccc.h>
2728
#include <zephyr/drivers/i3c/devicetree.h>
2829
#include <zephyr/drivers/i3c/ibi.h>
@@ -292,87 +293,6 @@ enum i3c_data_rate {
292293
I3C_DATA_RATE_INVALID,
293294
};
294295

295-
/**
296-
* @brief I3C SDR Controller Error Codes
297-
*
298-
* These are error codes defined by the I3C specification.
299-
*
300-
* #I3C_ERROR_CE_UNKNOWN and #I3C_ERROR_CE_NONE are not
301-
* official error codes according to the specification.
302-
* These are there simply to aid in error handling during
303-
* interactions with the I3C drivers and subsystem.
304-
*/
305-
enum i3c_sdr_controller_error_codes {
306-
/** Transaction after sending CCC */
307-
I3C_ERROR_CE0,
308-
309-
/** Monitoring Error */
310-
I3C_ERROR_CE1,
311-
312-
/** No response to broadcast address (0x7E) */
313-
I3C_ERROR_CE2,
314-
315-
/** Failed Controller Handoff */
316-
I3C_ERROR_CE3,
317-
318-
/** Unknown error (not official error code) */
319-
I3C_ERROR_CE_UNKNOWN,
320-
321-
/** No error (not official error code) */
322-
I3C_ERROR_CE_NONE,
323-
324-
I3C_ERROR_CE_MAX = I3C_ERROR_CE_UNKNOWN,
325-
I3C_ERROR_CE_INVALID,
326-
};
327-
328-
/**
329-
* @brief I3C SDR Target Error Codes
330-
*
331-
* These are error codes defined by the I3C specification.
332-
*
333-
* #I3C_ERROR_TE_UNKNOWN and #I3C_ERROR_TE_NONE are not
334-
* official error codes according to the specification.
335-
* These are there simply to aid in error handling during
336-
* interactions with the I3C drivers and subsystem.
337-
*/
338-
enum i3c_sdr_target_error_codes {
339-
/**
340-
* Invalid Broadcast Address or
341-
* Dynamic Address after DA assignment
342-
*/
343-
I3C_ERROR_TE0,
344-
345-
/** CCC Code */
346-
I3C_ERROR_TE1,
347-
348-
/** Write Data */
349-
I3C_ERROR_TE2,
350-
351-
/** Assigned Address during Dynamic Address Arbitration */
352-
I3C_ERROR_TE3,
353-
354-
/** 0x7E/R missing after RESTART during Dynamic Address Arbitration */
355-
I3C_ERROR_TE4,
356-
357-
/** Transaction after detecting CCC */
358-
I3C_ERROR_TE5,
359-
360-
/** Monitoring Error */
361-
I3C_ERROR_TE6,
362-
363-
/** Dead Bus Recovery */
364-
I3C_ERROR_DBR,
365-
366-
/** Unknown error (not official error code) */
367-
I3C_ERROR_TE_UNKNOWN,
368-
369-
/** No error (not official error code) */
370-
I3C_ERROR_TE_NONE,
371-
372-
I3C_ERROR_TE_MAX = I3C_ERROR_TE_UNKNOWN,
373-
I3C_ERROR_TE_INVALID,
374-
};
375-
376296
/**
377297
* @brief I3C Transfer API
378298
* @defgroup i3c_transfer_api I3C Transfer API
@@ -486,6 +406,14 @@ struct i3c_msg {
486406
*/
487407
uint32_t num_xfer;
488408

409+
/**
410+
* SDR Error Type
411+
*
412+
* Error from I3C Specification v1.1.1 section 5.1.10.2. It is expected
413+
* for the driver to write to this.
414+
*/
415+
enum i3c_sdr_controller_error_types err;
416+
489417
/** Flags for this message */
490418
uint8_t flags;
491419

include/zephyr/drivers/i3c/ccc.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@ struct i3c_ccc_target_payload {
259259
* write to this after the transfer.
260260
*/
261261
size_t num_xfer;
262+
263+
/**
264+
* SDR Error Type
265+
*
266+
* Error from I3C Specification v1.1.1 section 5.1.10.2. It is expected
267+
* for the driver to write to this.
268+
*/
269+
enum i3c_sdr_controller_error_types err;
262270
};
263271

264272
/**
@@ -289,6 +297,14 @@ struct i3c_ccc_payload {
289297
* It is expected for the driver to write to this after the transfer.
290298
*/
291299
size_t num_xfer;
300+
301+
/**
302+
* SDR Error Type
303+
*
304+
* Error from I3C Specification v1.1.1 section 5.1.10.2. It is expected
305+
* for the driver to write to this.
306+
*/
307+
enum i3c_sdr_controller_error_types err;
292308
} ccc;
293309

294310
struct {
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Copyright 2024 Meta Platforms, Inc. and its affiliates
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_INCLUDE_DRIVERS_I3C_ERROR_TYPES_H_
8+
#define ZEPHYR_INCLUDE_DRIVERS_I3C_ERROR_TYPES_H_
9+
10+
#ifdef __cplusplus
11+
extern "C" {
12+
#endif
13+
14+
/**
15+
* @brief I3C SDR Controller Error Types
16+
*
17+
* These are error types defined by the I3C specification.
18+
*
19+
* #I3C_ERROR_CE_UNKNOWN and #I3C_ERROR_CE_NONE are not
20+
* official error types according to the specification.
21+
* These are there simply to aid in error handling during
22+
* interactions with the I3C drivers and subsystem.
23+
*/
24+
enum i3c_sdr_controller_error_types {
25+
/** Transaction after sending CCC */
26+
I3C_ERROR_CE0,
27+
28+
/** Monitoring Error */
29+
I3C_ERROR_CE1,
30+
31+
/** No response to broadcast address (0x7E) */
32+
I3C_ERROR_CE2,
33+
34+
/** Failed Controller Handoff */
35+
I3C_ERROR_CE3,
36+
37+
/** Unknown error (not official error type) */
38+
I3C_ERROR_CE_UNKNOWN,
39+
40+
/** No error (not official error type) */
41+
I3C_ERROR_CE_NONE,
42+
43+
I3C_ERROR_CE_MAX = I3C_ERROR_CE_UNKNOWN,
44+
I3C_ERROR_CE_INVALID,
45+
};
46+
47+
/**
48+
* @brief I3C SDR Target Error Types
49+
*
50+
* These are error types defined by the I3C specification.
51+
*
52+
* #I3C_ERROR_TE_UNKNOWN and #I3C_ERROR_TE_NONE are not
53+
* official error types according to the specification.
54+
* These are there simply to aid in error handling during
55+
* interactions with the I3C drivers and subsystem.
56+
*/
57+
enum i3c_sdr_target_error_types {
58+
/**
59+
* Invalid Broadcast Address or
60+
* Dynamic Address after DA assignment
61+
*/
62+
I3C_ERROR_TE0,
63+
64+
/** CCC type */
65+
I3C_ERROR_TE1,
66+
67+
/** Write Data */
68+
I3C_ERROR_TE2,
69+
70+
/** Assigned Address during Dynamic Address Arbitration */
71+
I3C_ERROR_TE3,
72+
73+
/** 0x7E/R missing after RESTART during Dynamic Address Arbitration */
74+
I3C_ERROR_TE4,
75+
76+
/** Transaction after detecting CCC */
77+
I3C_ERROR_TE5,
78+
79+
/** Monitoring Error */
80+
I3C_ERROR_TE6,
81+
82+
/** Dead Bus Recovery */
83+
I3C_ERROR_DBR,
84+
85+
/** Unknown error (not official error type) */
86+
I3C_ERROR_TE_UNKNOWN,
87+
88+
/** No error (not official error type) */
89+
I3C_ERROR_TE_NONE,
90+
91+
I3C_ERROR_TE_MAX = I3C_ERROR_TE_UNKNOWN,
92+
I3C_ERROR_TE_INVALID,
93+
};
94+
95+
#ifdef __cplusplus
96+
}
97+
#endif
98+
99+
#endif /* ZEPHYR_INCLUDE_DRIVERS_I3C_ERROR_TYPES_H_ */

0 commit comments

Comments
 (0)