Zephyr API Documentation 3.7.99
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 <stdint.h>
18
19#include <zephyr/device.h>
20#include <zephyr/sys/util.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
27#define I3C_BROADCAST_ADDR 0x7E
28
30#define I3C_MAX_ADDR 0x7F
31
32struct i3c_dev_list;
33
54
59 /* 2 bits per slot */
60 unsigned long slots[((I3C_MAX_ADDR + 1) * 2) / BITS_PER_LONG];
61};
62
74int i3c_addr_slots_init(const struct device *dev);
75
84 uint8_t dev_addr,
85 enum i3c_addr_slot_status status);
86
96 uint8_t dev_addr);
97
108 uint8_t dev_addr);
109
122
129static inline void i3c_addr_slots_mark_free(struct i3c_addr_slots *addr_slots,
130 uint8_t addr)
131{
132 i3c_addr_slots_set(addr_slots, addr,
134}
135
142static inline void i3c_addr_slots_mark_rsvd(struct i3c_addr_slots *addr_slots,
143 uint8_t addr)
144{
145 i3c_addr_slots_set(addr_slots, addr,
147}
148
155static inline void i3c_addr_slots_mark_i3c(struct i3c_addr_slots *addr_slots,
156 uint8_t addr)
157{
158 i3c_addr_slots_set(addr_slots, addr,
160}
161
168static inline void i3c_addr_slots_mark_i2c(struct i3c_addr_slots *addr_slots,
169 uint8_t addr)
170{
171 i3c_addr_slots_set(addr_slots, addr,
173}
174
175#ifdef __cplusplus
176}
177#endif
178
183#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:30
i3c_addr_slot_status
Enum to indicate whether an address is reserved, has I2C/I3C device attached, or no device attached.
Definition addresses.h:38
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:142
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:168
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:155
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:129
@ I3C_ADDR_SLOT_STATUS_RSVD
Address is reserved.
Definition addresses.h:43
@ I3C_ADDR_SLOT_STATUS_MASK
Bit masks used to filter status bits.
Definition addresses.h:52
@ I3C_ADDR_SLOT_STATUS_I3C_DEV
Address is associated with an I3C device.
Definition addresses.h:46
@ I3C_ADDR_SLOT_STATUS_FREE
Address has not device attached.
Definition addresses.h:40
@ I3C_ADDR_SLOT_STATUS_I2C_DEV
Address is associated with an I2C device.
Definition addresses.h:49
#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:412
Structure to keep track of addresses on I3C bus.
Definition addresses.h:58
unsigned long slots[((0x7F+1) *2)/BITS_PER_LONG]
Definition addresses.h:60
Structure for describing known devices for a controller.
Definition i3c.h:1165
Misc utilities.