Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
40
43
46
49
52};
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
120
127static inline void i3c_addr_slots_mark_free(struct i3c_addr_slots *addr_slots,
128 uint8_t addr)
129{
130 i3c_addr_slots_set(addr_slots, addr,
132}
133
140static inline void i3c_addr_slots_mark_rsvd(struct i3c_addr_slots *addr_slots,
141 uint8_t addr)
142{
143 i3c_addr_slots_set(addr_slots, addr,
145}
146
153static inline void i3c_addr_slots_mark_i3c(struct i3c_addr_slots *addr_slots,
154 uint8_t addr)
155{
156 i3c_addr_slots_set(addr_slots, addr,
158}
159
166static inline void i3c_addr_slots_mark_i2c(struct i3c_addr_slots *addr_slots,
167 uint8_t addr)
168{
169 i3c_addr_slots_set(addr_slots, addr,
171}
172
173#ifdef __cplusplus
174}
175#endif
176
181#endif /* ZEPHYR_INCLUDE_DRIVERS_I3C_ADDRESSES_H_ */
uint8_t i3c_addr_slots_next_free_find(struct i3c_addr_slots *slots)
Find the next free address.
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:140
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:166
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:153
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:127
@ 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:58
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition: device.h:381
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:1131
Misc utilities.