Zephyr API Documentation 4.3.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
6#ifndef _INCLUDE_ZEPHYR_DRIVERS_CLOCK_CONTROL_SF32LB_H_
7#define _INCLUDE_ZEPHYR_DRIVERS_CLOCK_CONTROL_SF32LB_H_
8
9#include <stdint.h>
10
11#include <zephyr/device.h>
12#include <zephyr/devicetree.h>
15
22
26 const struct device *dev;
29};
30
36#define SF32LB_CLOCK_DT_SPEC_GET(node_id) \
37 { \
38 .dev = DEVICE_DT_GET(DT_CLOCKS_CTLR(node_id)), \
39 .id = DT_CLOCKS_CELL(node_id, id), \
40 }
41
48#define SF32LB_CLOCK_DT_SPEC_GET_OR(node_id, default_spec) \
49 COND_CODE_1(DT_CLOCKS_HAS_IDX(node_id, 0), \
50 (SF32LB_CLOCK_DT_SPEC_GET(node_id)), (default_spec))
51
57#define SF32LB_CLOCK_DT_INST_SPEC_GET(index) SF32LB_CLOCK_DT_SPEC_GET(DT_DRV_INST(index))
58
65#define SF32LB_CLOCK_DT_INST_SPEC_GET_OR(index, default_spec) \
66 SF32LB_CLOCK_DT_SPEC_GET_OR(DT_DRV_INST(index), default_spec)
67
75static inline bool sf32lb_clock_is_ready_dt(const struct sf32lb_clock_dt_spec *spec)
76{
77 return device_is_ready(spec->dev);
78}
79
86static inline int sf32lb_clock_control_on_dt(const struct sf32lb_clock_dt_spec *spec)
87{
88 return clock_control_on(spec->dev, (clock_control_subsys_t)&spec->id);
89}
90
97static inline int sf32lb_clock_control_off_dt(const struct sf32lb_clock_dt_spec *spec)
98{
99 return clock_control_off(spec->dev, (clock_control_subsys_t)&spec->id);
100}
101
109 const struct sf32lb_clock_dt_spec *spec)
110{
112}
113
123 uint32_t *rate)
124{
125 return clock_control_get_rate(spec->dev, (clock_control_subsys_t)&spec->id, rate);
126}
127
129
130#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:227
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:202
void * clock_control_subsys_t
clock_control_subsys_t is a type to identify a clock controller sub-system.
Definition clock_control.h:59
clock_control_status
Current clock status.
Definition clock_control.h:47
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:149
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:126
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:97
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:86
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:108
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:122
static bool sf32lb_clock_is_ready_dt(const struct sf32lb_clock_dt_spec *spec)
Check if the clock device is ready.
Definition sf32lb.h:75
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:24
uint16_t id
Clock ID.
Definition sf32lb.h:28
const struct device * dev
Clock controller (RCC)
Definition sf32lb.h:26