OpenBIC
OpenSource Bridge-IC
hal_i3c.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef HAL_I3C_H
18#define HAL_I3C_H
19
20#include <zephyr.h>
21#include <drivers/i3c/i3c.h>
22
23#if DT_NODE_HAS_STATUS(DT_NODELABEL(i3c0), okay)
24#define DEV_I3C_0
25#endif
26
27#if DT_NODE_HAS_STATUS(DT_NODELABEL(i3c1), okay)
28#define DEV_I3C_1
29#endif
30
31#if DT_NODE_HAS_STATUS(DT_NODELABEL(i3c2), okay)
32#define DEV_I3C_2
33#endif
34
35#if DT_NODE_HAS_STATUS(DT_NODELABEL(i3c3), okay)
36#define DEV_I3C_3
37#endif
38
39#if DT_NODE_HAS_STATUS(DT_NODELABEL(i3c4), okay)
40#define DEV_I3C_4
41#endif
42
43#if DT_NODE_HAS_STATUS(DT_NODELABEL(i3c5), okay)
44#define DEV_I3C_5
45#endif
46
47#if DT_NODE_HAS_STATUS(DT_NODELABEL(i3c6), okay)
48#define DEV_I3C_6
49#endif
50
51#if DT_NODE_HAS_STATUS(DT_NODELABEL(i3c7), okay)
52#define DEV_I3C_7
53#endif
54
55#if DT_NODE_EXISTS(DT_NODELABEL(i3c0_smq))
56#define DEV_I3CSMQ_0
57#endif
58
59#if DT_NODE_EXISTS(DT_NODELABEL(i3c1_smq))
60#define DEV_I3CSMQ_1
61#endif
62
63#if DT_NODE_EXISTS(DT_NODELABEL(i3c2_smq))
64#define DEV_I3CSMQ_2
65#endif
66
67#if DT_NODE_EXISTS(DT_NODELABEL(i3c3_smq))
68#define DEV_I3CSMQ_3
69#endif
70
71#if DT_NODE_EXISTS(DT_NODELABEL(i3c4_smq))
72#define DEV_I3CSMQ_4
73#endif
74
75#if DT_NODE_EXISTS(DT_NODELABEL(i3c5_smq))
76#define DEV_I3CSMQ_5
77#endif
78
79#if DT_NODE_EXISTS(DT_NODELABEL(i3c6_smq))
80#define DEV_I3CSMQ_6
81#endif
82
83#if DT_NODE_EXISTS(DT_NODELABEL(i3c7_smq))
84#define DEV_I3CSMQ_7
85#endif
86
87#define DEV_I3C(n) DEV_I3C_##n
88#define DEV_I3CSMQ(n) DEV_I3CSMQ_##n
89
90#define I3C_MAX_NUM 8
91#define I3C_MAX_DATA_SIZE 256
92#define I3C_DEBUG 0
93#define I3C_SMQ_SUCCESS 0
94#define I3C_MAX_BUFFER_COUNT 2
95#define IBI_PAYLOAD_SIZE 128
96
97#define I3C_DEV_STR_LEN 8
98#define I3C_BUS_STR_LEN 4
99
103};
104
105typedef struct _I3C_MSG_ {
106 uint8_t bus;
107 uint8_t target_addr;
108 uint8_t tx_len;
112
113typedef struct _i3c_ibi_dev {
115 struct i3c_ibi_payload i3c_payload;
116 struct k_sem ibi_complete;
118
119void util_init_i3c(void);
120int i3c_mutex_lock(int bus);
121int i3c_mutex_unlock(int bus);
122int i3c_smq_read(I3C_MSG *msg);
123int i3c_smq_write(I3C_MSG *msg);
124int i3c_slave_mqueue_read(const struct device *dev, uint8_t *dest, int budget);
125int i3c_slave_mqueue_write(const struct device *dev, uint8_t *src, int size);
126
127int i3c_attach(I3C_MSG *msg);
128int i3c_detach(I3C_MSG *msg);
129int i3c_transfer(I3C_MSG *msg);
130int i3c_brocast_ccc(I3C_MSG *msg, uint8_t ccc_id, uint8_t ccc_addr);
131int i3c_spd_reg_read(I3C_MSG *msg, bool is_nvm);
132int i3c_set_pid(I3C_MSG *msg, uint16_t slot_pid);
133
139int i3c_target_get_dynamic_address(I3C_MSG *msg, uint8_t *dynamic_addr);
140
141__weak bool pal_get_slot_pid(uint16_t *pid);
142
143#endif
int i3c_brocast_ccc(I3C_MSG *msg, uint8_t ccc_id, uint8_t ccc_addr)
Definition: hal_i3c.c:215
int i3c_mutex_lock(int bus)
Definition: hal_i3c.c:741
struct _i3c_ibi_dev i3c_ibi_dev
int i3c_target_get_dynamic_address(I3C_MSG *msg, uint8_t *dynamic_addr)
Definition: hal_i3c.c:710
int i3c_smq_write(I3C_MSG *msg)
api to write i3c message to target message queue
Definition: hal_i3c.c:97
int i3c_controller_write(I3C_MSG *msg)
Definition: hal_i3c.c:343
void util_init_i3c(void)
Definition: hal_i3c.c:421
int i3c_detach(I3C_MSG *msg)
Definition: hal_i3c.c:173
__weak bool pal_get_slot_pid(uint16_t *pid)
Definition: hal_i3c.c:736
int i3c_target_set_address(I3C_MSG *msg)
Definition: hal_i3c.c:685
#define I3C_MAX_DATA_SIZE
Definition: hal_i3c.h:91
int i3c_controller_ibi_read(I3C_MSG *msg)
Definition: hal_i3c.c:630
I3C_WRITE_READ_CMD
Definition: hal_i3c.h:100
@ I3C_READ_CMD
Definition: hal_i3c.h:102
@ I3C_WRITE_CMD
Definition: hal_i3c.h:101
int i3c_set_pid(I3C_MSG *msg, uint16_t slot_pid)
Definition: hal_i3c.c:381
int i3c_spd_reg_read(I3C_MSG *msg, bool is_nvm)
Definition: hal_i3c.c:296
int i3c_mutex_unlock(int bus)
Definition: hal_i3c.c:756
int i3c_slave_mqueue_write(const struct device *dev, uint8_t *src, int size)
struct _I3C_MSG_ I3C_MSG
int i3c_smq_read(I3C_MSG *msg)
api to read i3c message from target message queue
Definition: hal_i3c.c:66
int i3c_controller_ibi_init(I3C_MSG *msg)
Definition: hal_i3c.c:556
int i3c_transfer(I3C_MSG *msg)
Definition: hal_i3c.c:251
int i3c_attach(I3C_MSG *msg)
Definition: hal_i3c.c:131
int i3c_slave_mqueue_read(const struct device *dev, uint8_t *dest, int budget)
const struct device * dev
Definition: hal_peci.c:28
uint16_t size
Definition: pldm_oem.h:0
Definition: hal_i3c.h:105
uint8_t target_addr
Definition: hal_i3c.h:107
uint8_t tx_len
Definition: hal_i3c.h:108
uint8_t data[I3C_MAX_DATA_SIZE]
Definition: hal_i3c.h:110
int rx_len
Definition: hal_i3c.h:109
uint8_t bus
Definition: hal_i3c.h:106
Definition: hal_i3c.h:113
struct i3c_ibi_payload i3c_payload
Definition: hal_i3c.h:115
struct k_sem ibi_complete
Definition: hal_i3c.h:116
uint8_t data_rx[I3C_MAX_DATA_SIZE]
Definition: hal_i3c.h:114
uint16_t slot_pid
Definition: plat_class.c:69