Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sf32lb.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Core Devices LLC
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
11
12#ifndef _INCLUDE_ZEPHYR_DRIVERS_CLOCK_CONTROL_SF32LB_H_
13#define _INCLUDE_ZEPHYR_DRIVERS_CLOCK_CONTROL_SF32LB_H_
14
15#include <stdint.h>
16
17#include <zephyr/device.h>
18#include <zephyr/devicetree.h>
21
27
31 const struct device *dev;
34};
35
41#define SF32LB_CLOCK_DT_SPEC_GET(node_id) \
42 { \
43 .dev = DEVICE_DT_GET(DT_CLOCKS_CTLR(node_id)), \
44 .id = DT_CLOCKS_CELL(node_id, id), \
45 }
46
53#define SF32LB_CLOCK_DT_SPEC_GET_OR(node_id, default_spec) \
54 COND_CODE_1(DT_CLOCKS_HAS_IDX(node_id, 0), \
55 (SF32LB_CLOCK_DT_SPEC_GET(node_id)), (default_spec))
56
62#define SF32LB_CLOCK_DT_INST_SPEC_GET(index) SF32LB_CLOCK_DT_SPEC_GET(DT_DRV_INST(index))
63
69#define SF32LB_CLOCK_DT_INST_PARENT_SPEC_GET(index) \
70 { \
71 .dev = DEVICE_DT_GET(DT_CLOCKS_CTLR(DT_INST_PARENT(index))), \
72 .id = DT_CLOCKS_CELL(DT_INST_PARENT(index), id), \
73 }
74
81#define SF32LB_CLOCK_DT_INST_SPEC_GET_OR(index, default_spec) \
82 SF32LB_CLOCK_DT_SPEC_GET_OR(DT_DRV_INST(index), default_spec)
83
91static inline bool sf32lb_clock_is_ready_dt(const struct sf32lb_clock_dt_spec *spec)
92{
93 return device_is_ready(spec->dev);
94}
95
102static inline int sf32lb_clock_control_on_dt(const struct sf32lb_clock_dt_spec *spec)
103{
104 return clock_control_on(spec->dev, (clock_control_subsys_t)&spec->id);
105}
106
113static inline int sf32lb_clock_control_off_dt(const struct sf32lb_clock_dt_spec *spec)
114{
115 return clock_control_off(spec->dev, (clock_control_subsys_t)&spec->id);
116}
117
125 const struct sf32lb_clock_dt_spec *spec)
126{
128}
129
139 uint32_t *rate)
140{
141 return clock_control_get_rate(spec->dev, (clock_control_subsys_t)&spec->id, rate);
142}
143
145
146#endif /* _INCLUDE_ZEPHYR_DRIVERS_CLOCK_CONTROL_SF32LB_H_ */
Main header file for clock control driver API.
Clocks Devicetree macro public API header file.
Devicetree main header.
static int clock_control_get_rate(const struct device *dev, clock_control_subsys_t sys, uint32_t *rate)
Obtain the clock rate of given sub-system.
Definition clock_control.h:276
static enum clock_control_status clock_control_get_status(const struct device *dev, clock_control_subsys_t sys)
Get clock status.
Definition clock_control.h:252
void * clock_control_subsys_t
Opaque handle identifying a clock controller subsystem.
Definition clock_control.h:65
clock_control_status
Current clock status.
Definition clock_control.h:52
static int clock_control_off(const struct device *dev, clock_control_subsys_t sys)
Disable a clock controlled by the device.
Definition clock_control.h:201
static int clock_control_on(const struct device *dev, clock_control_subsys_t sys)
Enable a clock controlled by the device.
Definition clock_control.h:179
static int sf32lb_clock_control_off_dt(const struct sf32lb_clock_dt_spec *spec)
Turn off a clock using a sf32lb_clock_dt_spec structure.
Definition sf32lb.h:113
static int sf32lb_clock_control_on_dt(const struct sf32lb_clock_dt_spec *spec)
Turn on a clock using a sf32lb_clock_dt_spec structure.
Definition sf32lb.h:102
static enum clock_control_status sf32lb_clock_control_get_status_dt(const struct sf32lb_clock_dt_spec *spec)
Get the status of a clock using a sf32lb_clock_dt_spec structure.
Definition sf32lb.h:124
static uint32_t sf32lb_clock_control_get_rate_dt(const struct sf32lb_clock_dt_spec *spec, uint32_t *rate)
Get the clock rate using a sf32lb_clock_dt_spec structure.
Definition sf32lb.h:138
static bool sf32lb_clock_is_ready_dt(const struct sf32lb_clock_dt_spec *spec)
Check if the clock device is ready.
Definition sf32lb.h:91
bool device_is_ready(const struct device *dev)
Verify that a device is ready for use.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
SF32LB Clock DT spec.
Definition sf32lb.h:29
uint16_t id
Clock ID.
Definition sf32lb.h:33
const struct device * dev
Clock controller (RCC).
Definition sf32lb.h:31