12#ifndef ZEPHYR_INCLUDE_DRIVERS_MUX_H_
13#define ZEPHYR_INCLUDE_DRIVERS_MUX_H_
75#define Z_MUX_CTRL_DEFINE_BY_IDX(node_id, idx) \
76 static const uint32_t Z_MUX_CTRL_CELLS_NAME(node_id, idx)[] = { \
77 COND_CODE_1(IS_EQ(Z_MUX_PHA_NUM_CELLS(node_id, mux_controls, idx), 0), \
79 (DT_FOREACH_PHA_CELL_BY_IDX_SEP(node_id, mux_controls, idx, \
80 Z_MUX_CELL_VAL, (,)))) \
82 static const struct mux_control Z_MUX_CTRL_OBJ_NAME(node_id, idx) = { \
83 .cells = Z_MUX_CTRL_CELLS_NAME(node_id, idx), \
84 .len = Z_MUX_PHA_NUM_CELLS(node_id, mux_controls, idx), \
87#define Z_MUX_STATE_DEFINE_BY_IDX(node_id, idx) \
88 static const uint32_t Z_MUX_STATE_CELLS_NAME(node_id, idx)[] = { \
89 COND_CODE_1(IS_EQ(Z_MUX_PHA_NUM_CELLS(node_id, mux_states, idx), 1), \
91 (Z_MUX_STATE_ADDRESSING_CELLS(node_id, idx))) \
93 static const struct mux_control Z_MUX_STATE_CTRL_NAME(node_id, idx) = { \
94 .cells = Z_MUX_STATE_CELLS_NAME(node_id, idx), \
95 .len = Z_MUX_PHA_NUM_CELLS(node_id, mux_states, idx) - 1, \
97 static const struct mux_state Z_MUX_STATE_OBJ_NAME(node_id, idx) = { \
98 .control = &Z_MUX_STATE_CTRL_NAME(node_id, idx), \
99 .state = Z_MUX_STATE_LAST_CELL(node_id, idx), \
139#define MUX_CONTROL_DT_SPEC_DEFINE_BY_IDX(node_id, idx) Z_MUX_CTRL_DEFINE_BY_IDX(node_id, idx)
158#define MUX_CONTROL_DT_SPEC_DEFINE(node_id) MUX_CONTROL_DT_SPEC_DEFINE_BY_IDX(node_id, 0)
185#define MUX_CONTROL_DT_SPEC_DEFINE_BY_NAME(node_id, name) \
186 MUX_CONTROL_DT_SPEC_DEFINE_BY_IDX(node_id, \
187 DT_PHA_ELEM_IDX_BY_NAME(node_id, mux_controls, name))
226#define MUX_STATE_DT_SPEC_DEFINE_BY_IDX(node_id, idx) Z_MUX_STATE_DEFINE_BY_IDX(node_id, idx)
245#define MUX_STATE_DT_SPEC_DEFINE(node_id) MUX_STATE_DT_SPEC_DEFINE_BY_IDX(node_id, 0)
271#define MUX_STATE_DT_SPEC_DEFINE_BY_NAME(node_id, name) \
272 MUX_STATE_DT_SPEC_DEFINE_BY_IDX(node_id, \
273 DT_PHA_ELEM_IDX_BY_NAME(node_id, mux_states, name))
277typedef int (*mux_control_set_fn)(
const struct device *dev,
281typedef int (*mux_state_get_fn)(
const struct device *dev,
285typedef int (*mux_control_disconnect_fn)(
const struct device *dev,
318static inline int z_impl_mux_control_set(
const struct device *dev,
324 return api->
set(dev, control,
state);
342static inline int z_impl_mux_state_apply(
const struct device *dev,
369static inline int z_impl_mux_state_get(
const struct device *dev,
415static inline int z_impl_mux_control_disconnect(
const struct device *dev,
433#include <zephyr/syscalls/mux.h>
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1425
MUX Devicetree macro public API header file.
int mux_control_disconnect(const struct device *dev, const struct mux_control *control)
Physically disconnect a MUX control line.
int mux_state_get(const struct device *dev, const struct mux_control *control, uint32_t *state)
Read back the current state of a MUX control line.
int mux_control_set(const struct device *dev, const struct mux_control *control, uint32_t state)
Drive a MUX control line to the given state.
int mux_state_apply(const struct device *dev, const struct mux_state *mstate)
Apply a devicetree-defined default state to a MUX control line.
#define ENOSYS
Function not implemented.
Definition errno.h:83
#define NULL
Definition iar_missing_defs.h:20
state
Definition parser_state.h:29
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
MUX controller driver API.
Definition mux.h:293
mux_state_get_fn get_state
@driver_ops_optional Read back the current state of a MUX control line.
Definition mux.h:297
mux_control_set_fn set
@driver_ops_mandatory Drive a MUX control line to the given state.
Definition mux.h:295
mux_control_disconnect_fn disconnect
@driver_ops_optional Physically disconnect a MUX control line.
Definition mux.h:299
Addressing-only specifier for a single MUX control line.
Definition mux.h:52
const uint32_t * cells
Pointer to the addressing cells from the devicetree specifier.
Definition mux.h:54
size_t len
Number of addressing cells (matches #mux-control-cells).
Definition mux.h:56
Addressing + default state pair for a MUX control line.
Definition mux.h:66
const struct mux_control * control
Addressing portion (points to a statically-defined mux_control).
Definition mux.h:68
uint32_t state
Default state value taken from the trailing cell of the specifier.
Definition mux.h:70