12#ifndef ZEPHYR_INCLUDE_DRIVERS_RESET_H_
13#define ZEPHYR_INCLUDE_DRIVERS_RESET_H_
71#define RESET_DT_SPEC_GET_BY_IDX(node_id, idx) \
73 .dev = DEVICE_DT_GET(DT_RESET_CTLR_BY_IDX(node_id, idx)), \
74 .id = DT_RESET_ID_BY_IDX(node_id, idx) \
93#define RESET_DT_SPEC_GET_BY_IDX_OR(node_id, idx, default_value) \
94 COND_CODE_1(DT_NODE_HAS_PROP(node_id, resets), \
95 (RESET_DT_SPEC_GET_BY_IDX(node_id, idx)), \
105#define RESET_DT_SPEC_GET(node_id) \
106 RESET_DT_SPEC_GET_BY_IDX(node_id, 0)
117#define RESET_DT_SPEC_GET_OR(node_id, default_value) \
118 RESET_DT_SPEC_GET_BY_IDX_OR(node_id, 0, default_value)
129#define RESET_DT_SPEC_INST_GET_BY_IDX(inst, idx) \
130 RESET_DT_SPEC_GET_BY_IDX(DT_DRV_INST(inst), idx)
142#define RESET_DT_SPEC_INST_GET_BY_IDX_OR(inst, idx, default_value) \
143 COND_CODE_1(DT_PROP_HAS_IDX(DT_DRV_INST(inst), resets, idx), \
144 (RESET_DT_SPEC_GET_BY_IDX(DT_DRV_INST(inst), idx)), \
154#define RESET_DT_SPEC_INST_GET(inst) \
155 RESET_DT_SPEC_INST_GET_BY_IDX(inst, 0)
166#define RESET_DT_SPEC_INST_GET_OR(inst, default_value) \
167 RESET_DT_SPEC_INST_GET_BY_IDX_OR(inst, 0, default_value)
183typedef int (*reset_api_line_assert)(
const struct device *dev,
uint32_t id);
190typedef int (*reset_api_line_deassert)(
const struct device *dev,
uint32_t id);
197typedef int (*reset_api_line_toggle)(
const struct device *dev,
uint32_t id);
202__subsystem
struct reset_driver_api {
203 reset_api_status status;
204 reset_api_line_assert line_assert;
205 reset_api_line_deassert line_deassert;
206 reset_api_line_toggle line_toggle;
228 const struct reset_driver_api *api = (
const struct reset_driver_api *)dev->
api;
230 if (api->status == NULL) {
234 return api->status(dev,
id, status);
269static inline int z_impl_reset_line_assert(
const struct device *dev,
uint32_t id)
271 const struct reset_driver_api *api = (
const struct reset_driver_api *)dev->
api;
273 if (api->line_assert == NULL) {
277 return api->line_assert(dev,
id);
311static inline int z_impl_reset_line_deassert(
const struct device *dev,
uint32_t id)
313 const struct reset_driver_api *api = (
const struct reset_driver_api *)dev->
api;
315 if (api->line_deassert == NULL) {
319 return api->line_deassert(dev,
id);
352static inline int z_impl_reset_line_toggle(
const struct device *dev,
uint32_t id)
354 const struct reset_driver_api *api = (
const struct reset_driver_api *)dev->
api;
356 if (api->line_toggle == NULL) {
360 return api->line_toggle(dev,
id);
387#include <zephyr/syscalls/reset.h>
int reset_line_toggle(const struct device *dev, uint32_t id)
Reset the device.
static int reset_line_deassert_dt(const struct reset_dt_spec *spec)
Deassert the reset state from a reset_dt_spec.
Definition: reset.h:333
static int reset_status_dt(const struct reset_dt_spec *spec, uint8_t *status)
Get the reset status from a reset_dt_spec.
Definition: reset.h:249
int reset_line_deassert(const struct device *dev, uint32_t id)
Take out the device from reset state.
int reset_line_assert(const struct device *dev, uint32_t id)
Put the device in reset state.
static int reset_line_assert_dt(const struct reset_dt_spec *spec)
Assert the reset state from a reset_dt_spec.
Definition: reset.h:291
int reset_status(const struct device *dev, uint32_t id, uint8_t *status)
Get the reset status.
static int reset_line_toggle_dt(const struct reset_dt_spec *spec)
Reset the device from a reset_dt_spec.
Definition: reset.h:374
#define ENOSYS
Function not implemented.
Definition: errno.h:82
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition: device.h:403
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:409
Reset controller device configuration.
Definition: reset.h:34
const struct device * dev
Reset controller device.
Definition: reset.h:36
uint32_t id
Reset line.
Definition: reset.h:38