Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
addresses.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DRIVERS_I3C_ADDRESSES_H_
8#define ZEPHYR_INCLUDE_DRIVERS_I3C_ADDRESSES_H_
9
17#include <zephyr/types.h>
18#include <zephyr/sys/sys_io.h>
19#include <zephyr/sys/util.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
26#define I3C_BROADCAST_ADDR 0x7E
27
29#define I3C_MAX_ADDR 0x7F
30
31struct i3c_dev_list;
32
53
58 /* 2 bits per slot */
59 unsigned long slots[((I3C_MAX_ADDR + 1) * 2) / BITS_PER_LONG];
60};
61
73int i3c_addr_slots_init(const struct device *dev);
74
83 uint8_t dev_addr,
84 enum i3c_addr_slot_status status);
85
95 uint8_t dev_addr);
96
107 uint8_t dev_addr);
108
121
128static inline void i3c_addr_slots_mark_free(struct i3c_addr_slots *addr_slots,
129 uint8_t addr)
130{
131 i3c_addr_slots_set(addr_slots, addr,
133}
134
141static inline void i3c_addr_slots_mark_rsvd(struct i3c_addr_slots *addr_slots,
142 uint8_t addr)
143{
144 i3c_addr_slots_set(addr_slots, addr,
146}
147
154static inline void i3c_addr_slots_mark_i3c(struct i3c_addr_slots *addr_slots,
155 uint8_t addr)
156{
157 i3c_addr_slots_set(addr_slots, addr,
159}
160
167static inline void i3c_addr_slots_mark_i2c(struct i3c_addr_slots *addr_slots,
168 uint8_t addr)
169{
170 i3c_addr_slots_set(addr_slots, addr,
172}
173
174#ifdef __cplusplus
175}
176#endif
177
182#endif /* ZEPHYR_INCLUDE_DRIVERS_I3C_ADDRESSES_H_ */
enum i3c_addr_slot_status i3c_addr_slots_status(struct i3c_addr_slots *slots, uint8_t dev_addr)
Get the address status of a device.
#define I3C_MAX_ADDR
Maximum value of device addresses.
Definition addresses.h:29
i3c_addr_slot_status
Enum to indicate whether an address is reserved, has I2C/I3C device attached, or no device attached.
Definition addresses.h:37
static void i3c_addr_slots_mark_rsvd(struct i3c_addr_slots *addr_slots, uint8_t addr)
Mark the address as reserved in device list.
Definition addresses.h:141
static void i3c_addr_slots_mark_i2c(struct i3c_addr_slots *addr_slots, uint8_t addr)
Mark the address as I2C device in device list.
Definition addresses.h:167
uint8_t i3c_addr_slots_next_free_find(struct i3c_addr_slots *slots, uint8_t start_addr)
Find the next free address.
bool i3c_addr_slots_is_free(struct i3c_addr_slots *slots, uint8_t dev_addr)
Check if the address is free.
static void i3c_addr_slots_mark_i3c(struct i3c_addr_slots *addr_slots, uint8_t addr)
Mark the address as I3C device in device list.
Definition addresses.h:154
void i3c_addr_slots_set(struct i3c_addr_slots *slots, uint8_t dev_addr, enum i3c_addr_slot_status status)
Set the address status of a device.
int i3c_addr_slots_init(const struct device *dev)
Initialize the I3C address slots struct.
static void i3c_addr_slots_mark_free(struct i3c_addr_slots *addr_slots, uint8_t addr)
Mark the address as free (not used) in device list.
Definition addresses.h:128
@ I3C_ADDR_SLOT_STATUS_RSVD
Address is reserved.
Definition addresses.h:42
@ I3C_ADDR_SLOT_STATUS_MASK
Bit masks used to filter status bits.
Definition addresses.h:51
@ I3C_ADDR_SLOT_STATUS_I3C_DEV
Address is associated with an I3C device.
Definition addresses.h:45
@ I3C_ADDR_SLOT_STATUS_FREE
Address has not device attached.
Definition addresses.h:39
@ I3C_ADDR_SLOT_STATUS_I2C_DEV
Address is associated with an I2C device.
Definition addresses.h:48
#define BITS_PER_LONG
Number of bits in a long int.
Definition util.h:61
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:403
Structure to keep track of addresses on I3C bus.
Definition addresses.h:57
unsigned long slots[((0x7F+1) *2)/BITS_PER_LONG]
Definition addresses.h:59
Structure for describing known devices for a controller.
Definition i3c.h:1205
Misc utilities.