Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
|
Interfaces for hardware spinlocks. More...
Files | |
file | hwspinlock.h |
Main header file for hardware spinlock driver API. |
Data Structures | |
struct | hwspinlock_context |
HW spinlock controller runtime context. More... | |
struct | hwspinlock_dt_spec |
Complete hardware spinlock DT information. More... |
Macros | |
#define | HWSPINLOCK_CTX_INITIALIZER |
Initializer for a hwspinlock_ctx_t. | |
#define | HWSPINLOCK_DT_SPEC_GET_BY_IDX(node_id, idx) |
Structure initializer for struct hwspinlock_dt_spec from devicetree by index. | |
#define | HWSPINLOCK_DT_SPEC_GET_BY_NAME(node_id, name) |
Structure initializer for struct hwspinlock_dt_spec from devicetree by name. | |
#define | HWSPINLOCK_DT_SPEC_GET(node_id) |
Structure initializer for struct hwspinlock_dt_spec from devicetree. | |
#define | HWSPINLOCK_DT_SPEC_INST_GET_BY_IDX(inst, idx) |
Instance version of HWSPINLOCK_DT_SPEC_GET_BY_IDX() | |
#define | HWSPINLOCK_DT_SPEC_INST_GET_BY_NAME(inst, name) |
Instance version of HWSPINLOCK_DT_SPEC_GET_BY_NAME() | |
#define | HWSPINLOCK_DT_SPEC_INST_GET(inst) |
Instance version of HWSPINLOCK_DT_SPEC_GET() |
Typedefs | |
typedef struct hwspinlock_context | hwspinlock_ctx_t |
Opaque type to represent a hwspinlock runtime context. |
Functions | |
static int | hw_spin_trylock (const struct device *dev, hwspinlock_ctx_t *ctx, uint32_t id, k_spinlock_key_t *key) |
Try to lock HW spinlock. | |
static k_spinlock_key_t | hw_spin_lock (const struct device *dev, hwspinlock_ctx_t *ctx, uint32_t id) |
Lock HW spinlock. | |
static void | hw_spin_unlock (const struct device *dev, hwspinlock_ctx_t *ctx, uint32_t id, k_spinlock_key_t key) |
Unlock HW spinlock. | |
static uint32_t | hw_spinlock_get_max_id (const struct device *dev) |
Get HW spinlock max ID. | |
static int | hw_spin_trylock_dt (struct hwspinlock_dt_spec *spec, k_spinlock_key_t *key) |
Try to lock HW spinlock from a struct hwspinlock_dt_spec. | |
static k_spinlock_key_t | hw_spin_lock_dt (struct hwspinlock_dt_spec *spec) |
Lock HW spinlock from a struct hwspinlock_dt_spec. | |
static void | hw_spin_unlock_dt (struct hwspinlock_dt_spec *spec, k_spinlock_key_t key) |
Unlock HW spinlock from a struct hwspinlock_dt_spec. | |
static uint32_t | hw_spinlock_get_max_id_dt (struct hwspinlock_dt_spec *spec) |
Get HW spinlock max ID from a struct hwspinlock_dt_spec. |
Interfaces for hardware spinlocks.
#define HWSPINLOCK_CTX_INITIALIZER |
#include <zephyr/drivers/hwspinlock.h>
Initializer for a hwspinlock_ctx_t.
#define HWSPINLOCK_DT_SPEC_GET | ( | node_id | ) |
#include <zephyr/drivers/hwspinlock.h>
Structure initializer for struct hwspinlock_dt_spec from devicetree.
This is equivalent to HWSPINLOCK_DT_SPEC_GET_BY_IDX(node_id, 0)
node_id | Devicetree node identifier for the HWSPINLOCK device |
#define HWSPINLOCK_DT_SPEC_GET_BY_IDX | ( | node_id, | |
idx ) |
#include <zephyr/drivers/hwspinlock.h>
Structure initializer for struct hwspinlock_dt_spec from devicetree by index.
This helper macro expands to a static initializer for a struct hwspinlock_dt_spec by reading the relevant device controller and id number from the devicetree.
Example devicetree fragment:
Example usage:
node_id | Devicetree node identifier for the HWSPINLOCK device |
idx | Index of hwlocks element |
#define HWSPINLOCK_DT_SPEC_GET_BY_NAME | ( | node_id, | |
name ) |
#include <zephyr/drivers/hwspinlock.h>
Structure initializer for struct hwspinlock_dt_spec from devicetree by name.
This helper macro expands to a static initializer for a struct hwspinlock_dt_spec by reading the relevant device controller and id number from the devicetree.
Example devicetree fragment:
Example usage:
node_id | Devicetree node identifier for the HWSPINLOCK device |
name | lowercase-and-underscores name of the hwlocks element |
#define HWSPINLOCK_DT_SPEC_INST_GET | ( | inst | ) |
#include <zephyr/drivers/hwspinlock.h>
Instance version of HWSPINLOCK_DT_SPEC_GET()
inst | DT_DRV_COMPAT instance number |
#define HWSPINLOCK_DT_SPEC_INST_GET_BY_IDX | ( | inst, | |
idx ) |
#include <zephyr/drivers/hwspinlock.h>
Instance version of HWSPINLOCK_DT_SPEC_GET_BY_IDX()
inst | DT_DRV_COMPAT instance number |
idx | Index of the hwlocks element |
#define HWSPINLOCK_DT_SPEC_INST_GET_BY_NAME | ( | inst, | |
name ) |
#include <zephyr/drivers/hwspinlock.h>
Instance version of HWSPINLOCK_DT_SPEC_GET_BY_NAME()
inst | DT_DRV_COMPAT instance number |
name | lowercase-and-underscores name of the hwlocks element |
typedef struct hwspinlock_context hwspinlock_ctx_t |
#include <zephyr/drivers/hwspinlock.h>
Opaque type to represent a hwspinlock runtime context.
This type is not meant to be inspected by application code.
|
inlinestatic |
#include <zephyr/drivers/hwspinlock.h>
Lock HW spinlock.
This function is used when locking an HW spinlock. If the spinlock is already locked by another party, waits for it to be released. This is useful when protecting a resource which is shared between multiple clusters.
Because this uses a regular zephyr spinlock in conjunction with a hwspinlock, the same rules applies. Separate hwspinlock may be nested. It is legal to lock another (unlocked) hwspinlock while holding a lock. However, an attempt to acquire a hwspinlock that the CPU already holds will deadlock.
dev | HW spinlock device instance. |
ctx | HW spinlock runtime context. |
id | Spinlock identifier. |
|
inlinestatic |
#include <zephyr/drivers/hwspinlock.h>
Lock HW spinlock from a struct hwspinlock_dt_spec.
This is the dt_spec equivalent of hw_spin_lock()
spec | HWSPINLOCK specification from devicetree |
|
inlinestatic |
#include <zephyr/drivers/hwspinlock.h>
Try to lock HW spinlock.
This function is used when trying to lock an HW spinlock. If the spinlock is already locked by another cluster, exits with -EBUSY.
dev | HW spinlock device instance. | |
ctx | HW spinlock runtime context. | |
id | Spinlock identifier. | |
[out] | key | A pointer to the spinlock key. |
0 | On success. |
-ENOSYS | If the operation is not implemented. |
-EINVAL | If HW spinlock id is invalid. |
-EBUSY | If HW spinlock is already locked by someone else. |
|
inlinestatic |
#include <zephyr/drivers/hwspinlock.h>
Try to lock HW spinlock from a struct hwspinlock_dt_spec.
This is the dt_spec equivalent of hw_spin_trylock()
spec | HWSPINLOCK specification from devicetree | |
[out] | key | A pointer to the spinlock key. |
|
inlinestatic |
#include <zephyr/drivers/hwspinlock.h>
Unlock HW spinlock.
This function to unlock an HW spinlock
dev | HW spinlock device instance. |
ctx | HW spinlock runtime context. |
id | Spinlock identifier. |
key | The value returned from hw_spin_lock() when this lock was acquired |
|
inlinestatic |
#include <zephyr/drivers/hwspinlock.h>
Unlock HW spinlock from a struct hwspinlock_dt_spec.
This is the dt_spec equivalent of hw_spin_unlock()
spec | HWSPINLOCK specification from devicetree |
key | The value returned from hw_spin_lock() when this lock was acquired |
#include <zephyr/drivers/hwspinlock.h>
Get HW spinlock max ID.
This function is used to get the HW spinlock maximum ID. It should be called before attempting to lock/unlock a specific HW spinlock.
dev | HW spinlock device instance. |
HW | spinlock max ID. |
|
inlinestatic |
#include <zephyr/drivers/hwspinlock.h>
Get HW spinlock max ID from a struct hwspinlock_dt_spec.
This is the dt_spec equivalent of hw_spinlock_get_max_id()
spec | HWSPINLOCK specification from devicetree |