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.

Configuration Options

Related configuration options:

API Reference

group reset_controller_interface

Reset Controller Interface.

Since

3.1

Version

0.2.0

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_BY_IDX_OR(node_id, idx, default_value)

Like RESET_DT_SPEC_GET_BY_IDX(), with a fallback to a default value.

If the devicetree node identifier ‘node_id’ refers to a node with a ‘resets’ property, this expands to RESET_DT_SPEC_GET_BY_IDX(node_id, idx). The default_value parameter is not expanded in this case.

Otherwise, this expands to default_value.

Parameters:
  • node_id – devicetree node identifier

  • idx – logical index into the ‘resets’ property

  • default_value – fallback value to expand to

Returns:

static initializer for a struct reset_dt_spec for the property, or default_value if the node or property do not exist

RESET_DT_SPEC_GET(node_id)

Equivalent to RESET_DT_SPEC_GET_BY_IDX(node_id, 0).

Parameters:
  • node_id – devicetree node identifier

Returns:

static initializer for a struct reset_dt_spec for the property

RESET_DT_SPEC_GET_OR(node_id, default_value)

Equivalent to RESET_DT_SPEC_GET_BY_IDX_OR(node_id, 0, default_value).

Parameters:
  • node_id – devicetree node identifier

  • default_value – fallback value to expand to

Returns:

static initializer for a struct reset_dt_spec for the property, or default_value if the node or property do not exist

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.

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_BY_IDX_OR(inst, idx, default_value)

Static initializer for a reset_dt_spec from a DT_DRV_COMPAT instance’s ‘resets’ property at an index, with fallback.

Parameters:
  • inst – DT_DRV_COMPAT instance number

  • idx – logical index into the ‘resets’ property

  • default_value – fallback value to expand to

Returns:

static initializer for a struct reset_dt_spec for the property, or default_value if the node or property do not exist

RESET_DT_SPEC_INST_GET(inst)

Equivalent to RESET_DT_SPEC_INST_GET_BY_IDX(inst, 0).

Parameters:
  • inst – DT_DRV_COMPAT instance number

Returns:

static initializer for a struct reset_dt_spec for the property

RESET_DT_SPEC_INST_GET_OR(inst, default_value)

Equivalent to RESET_DT_SPEC_INST_GET_BY_IDX_OR(node_id, 0, default_value).

Parameters:
  • inst – DT_DRV_COMPAT instance number

  • default_value – fallback value to expand to

Returns:

static initializer for a struct reset_dt_spec for the property, or default_value if the node or property do not exist

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.

Public Members

const struct device *dev

Reset controller device.

uint32_t id

Reset line.