drivers/clk/clk-scmi.c
Source file repositories/reference/linux-study-clean/drivers/clk/clk-scmi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/clk-scmi.c- Extension
.c- Size
- 12896 bytes
- Lines
- 486
- Domain
- Driver Families
- Bucket
- drivers/clk
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bits.hlinux/clk-provider.hlinux/device.hlinux/err.hlinux/of.hlinux/module.hlinux/scmi_protocol.h
Detected Declarations
struct scmi_clkenum scmi_clk_featsfunction scmi_clk_recalc_ratefunction scmi_clk_determine_ratefunction scmi_clk_set_ratefunction scmi_clk_set_parentfunction scmi_clk_get_parentfunction scmi_clk_enablefunction scmi_clk_disablefunction scmi_clk_atomic_enablefunction scmi_clk_atomic_disablefunction __scmi_clk_is_enabledfunction scmi_clk_atomic_is_enabledfunction scmi_clk_is_enabledfunction scmi_clk_get_duty_cyclefunction scmi_clk_set_duty_cyclefunction scmi_clk_ops_initfunction scmi_clk_ops_allocfunction scmi_clk_ops_selectfunction scmi_clocks_probe
Annotated Snippet
struct scmi_clk {
u32 id;
struct device *dev;
struct clk_hw hw;
const struct scmi_clock_info *info;
const struct scmi_protocol_handle *ph;
struct clk_parent_data *parent_data;
};
#define to_scmi_clk(clk) container_of(clk, struct scmi_clk, hw)
static unsigned long scmi_clk_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
int ret;
u64 rate;
struct scmi_clk *clk = to_scmi_clk(hw);
ret = scmi_proto_clk_ops->rate_get(clk->ph, clk->id, &rate);
if (ret)
return 0;
return rate;
}
static int scmi_clk_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
int ret;
struct scmi_clk *clk = to_scmi_clk(hw);
/*
* If we could not get a better rate scmi_clk_recalc_rate() will be
* called after the rate is set and we'll know what rate the clock is
* running at then.
*/
ret = scmi_proto_clk_ops->determine_rate(clk->ph, clk->id, &req->rate);
if (ret)
return ret;
return 0;
}
static int scmi_clk_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct scmi_clk *clk = to_scmi_clk(hw);
return scmi_proto_clk_ops->rate_set(clk->ph, clk->id, rate);
}
static int scmi_clk_set_parent(struct clk_hw *hw, u8 parent_index)
{
struct scmi_clk *clk = to_scmi_clk(hw);
return scmi_proto_clk_ops->parent_set(clk->ph, clk->id, parent_index);
}
static u8 scmi_clk_get_parent(struct clk_hw *hw)
{
struct scmi_clk *clk = to_scmi_clk(hw);
u32 parent_id, p_idx;
int ret;
ret = scmi_proto_clk_ops->parent_get(clk->ph, clk->id, &parent_id);
if (ret)
return 0;
for (p_idx = 0; p_idx < clk->info->num_parents; p_idx++) {
if (clk->parent_data[p_idx].index == parent_id)
break;
}
if (p_idx == clk->info->num_parents)
return 0;
return p_idx;
}
static int scmi_clk_enable(struct clk_hw *hw)
{
struct scmi_clk *clk = to_scmi_clk(hw);
return scmi_proto_clk_ops->enable(clk->ph, clk->id, NOT_ATOMIC);
}
static void scmi_clk_disable(struct clk_hw *hw)
{
struct scmi_clk *clk = to_scmi_clk(hw);
scmi_proto_clk_ops->disable(clk->ph, clk->id, NOT_ATOMIC);
Annotation
- Immediate include surface: `linux/bits.h`, `linux/clk-provider.h`, `linux/device.h`, `linux/err.h`, `linux/of.h`, `linux/module.h`, `linux/scmi_protocol.h`.
- Detected declarations: `struct scmi_clk`, `enum scmi_clk_feats`, `function scmi_clk_recalc_rate`, `function scmi_clk_determine_rate`, `function scmi_clk_set_rate`, `function scmi_clk_set_parent`, `function scmi_clk_get_parent`, `function scmi_clk_enable`, `function scmi_clk_disable`, `function scmi_clk_atomic_enable`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.