If you need urgent consulting help click here
Reset Controller
Overview
Reset controllers are units that control the reset signals to multiple peripherals. The reset controller API allows peripheral drivers to request control over their reset input signals, including the ability to assert, deassert and toggle those signals. Also, the reset status of the reset input signal can be checked.
Mainly, the line_assert and line_deassert API functions are optional because in most cases we want to toggle the reset signals.
API Reference
- group reset_controller_interface
Reset Controller Interface.
Defines
-
RESET_DT_SPEC_GET_BY_IDX(node_id, idx)
Static initializer for a
reset_dt_spec
.This returns a static initializer for a
reset_dt_spec
structure given a devicetree node identifier, a property specifying a Reset Controller and an index.Example devicetree fragment:
n: node { resets = <&reset 10>; }
Example usage:
const struct reset_dt_spec spec = RESET_DT_SPEC_GET_BY_IDX(DT_NODELABEL(n), 0); // Initializes 'spec' to: // { // .dev = DEVICE_DT_GET(DT_NODELABEL(reset)), // .id = 10 // }
The ‘reset’ field must still be checked for readiness, e.g. using device_is_ready(). It is an error to use this macro unless the node exists, has the given property, and that property specifies a reset controller reset line id as shown above.
- Parameters
node_id – devicetree node identifier
idx – logical index into “resets”
- Returns
static initializer for a struct reset_dt_spec for the property
-
RESET_DT_SPEC_GET(node_id)
Equivalent to RESET_DT_SPEC_GET_BY_IDX(node_id, 0).
See also
- Parameters
node_id – devicetree node identifier
- Returns
static initializer for a struct reset_dt_spec for the property
-
RESET_DT_SPEC_INST_GET_BY_IDX(inst, idx)
Static initializer for a
reset_dt_spec
from a DT_DRV_COMPAT instance’s Reset Controller property at an index.See also
- Parameters
inst – DT_DRV_COMPAT instance number
idx – logical index into “resets”
- Returns
static initializer for a struct reset_dt_spec for the property
-
RESET_DT_SPEC_INST_GET(inst)
Equivalent to RESET_DT_SPEC_INST_GET_BY_IDX(inst, 0).
See also
- Parameters
inst – DT_DRV_COMPAT instance number
- Returns
static initializer for a struct reset_dt_spec for the property
Functions
-
int reset_status(const struct device *dev, uint32_t id, uint8_t *status)
Get the reset status.
This function returns the reset status of the device.
- Parameters
dev – Reset controller device.
id – Reset line.
status – Where to write the reset status.
- Return values
0 – On success.
-ENOSYS – If the functionality is not implemented by the driver.
-errno – Other negative errno in case of failure.
-
static inline int reset_status_dt(const struct reset_dt_spec *spec, uint8_t *status)
Get the reset status from a
reset_dt_spec
.This is equivalent to:
reset_status(spec->dev, spec->id, status);
- Parameters
spec – Reset controller specification from devicetree
status – Where to write the reset status.
- Returns
a value from reset_status()
-
int reset_line_assert(const struct device *dev, uint32_t id)
Put the device in reset state.
This function sets/clears the reset bits of the device, depending on the logic level (active-high/active-low).
- Parameters
dev – Reset controller device.
id – Reset line.
- Return values
0 – On success.
-ENOSYS – If the functionality is not implemented by the driver.
-errno – Other negative errno in case of failure.
-
static inline int reset_line_assert_dt(const struct reset_dt_spec *spec)
Assert the reset state from a
reset_dt_spec
.This is equivalent to:
reset_line_assert(spec->dev, spec->id);
- Parameters
spec – Reset controller specification from devicetree
- Returns
a value from reset_line_assert()
-
int reset_line_deassert(const struct device *dev, uint32_t id)
Take out the device from reset state.
This function sets/clears the reset bits of the device, depending on the logic level (active-low/active-high).
- Parameters
dev – Reset controller device.
id – Reset line.
- Return values
0 – On success.
-ENOSYS – If the functionality is not implemented by the driver.
-errno – Other negative errno in case of failure.
-
static inline int reset_line_deassert_dt(const struct reset_dt_spec *spec)
Deassert the reset state from a
reset_dt_spec
.This is equivalent to:
reset_line_deassert(spec->dev, spec->id)
- Parameters
spec – Reset controller specification from devicetree
- Returns
a value from reset_line_deassert()
-
int reset_line_toggle(const struct device *dev, uint32_t id)
Reset the device.
This function performs reset for a device (assert + deassert).
- Parameters
dev – Reset controller device.
id – Reset line.
- Return values
0 – On success.
-ENOSYS – If the functionality is not implemented by the driver.
-errno – Other negative errno in case of failure.
-
static inline int reset_line_toggle_dt(const struct reset_dt_spec *spec)
Reset the device from a
reset_dt_spec
.This is equivalent to:
reset_line_toggle(spec->dev, spec->id)
- Parameters
spec – Reset controller specification from devicetree
- Returns
a value from reset_line_toggle()
-
struct reset_dt_spec
- #include <reset.h>
Reset controller device configuration.
-
RESET_DT_SPEC_GET_BY_IDX(node_id, idx)