drivers/clk/keystone/sci-clk.c
Source file repositories/reference/linux-study-clean/drivers/clk/keystone/sci-clk.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/keystone/sci-clk.c- Extension
.c- Size
- 18637 bytes
- Lines
- 748
- 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.
- 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/clk-provider.hlinux/err.hlinux/io.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/slab.hlinux/soc/ti/ti_sci_protocol.hlinux/bsearch.hlinux/list_sort.h
Detected Declarations
struct sci_clk_providerstruct sci_clkfunction sci_clk_preparefunction sci_clk_unpreparefunction preparedfunction sci_clk_recalc_ratefunction sci_clk_determine_ratefunction sci_clk_set_ratefunction sci_clk_get_parentfunction sci_clk_set_parentfunction sci_clk_restore_contextfunction _sci_clk_buildfunction _cmp_sci_clkfunction ti_sci_init_clocksfunction ti_sci_scan_clocks_from_fwfunction _cmp_sci_clk_listfunction ti_sci_scan_clocks_from_dtfunction list_for_each_entryfunction ti_sci_clk_probefunction ti_sci_clk_remove
Annotated Snippet
struct sci_clk_provider {
const struct ti_sci_handle *sci;
const struct ti_sci_clk_ops *ops;
struct device *dev;
struct sci_clk **clocks;
int num_clocks;
};
/**
* struct sci_clk - TI SCI clock representation
* @hw: Hardware clock cookie for common clock framework
* @dev_id: Device index
* @clk_id: Clock index
* @num_parents: Number of parents for this clock
* @provider: Master clock provider
* @flags: Flags for the clock
* @node: Link for handling clocks probed via DT
* @cached_req: Cached requested freq for determine rate calls
* @cached_res: Cached result freq for determine rate calls
* @parent_id: Parent index for this clock
* @rate: Clock rate
*/
struct sci_clk {
struct clk_hw hw;
u16 dev_id;
u32 clk_id;
u32 num_parents;
struct sci_clk_provider *provider;
u8 flags;
struct list_head node;
unsigned long cached_req;
unsigned long cached_res;
int parent_id;
unsigned long rate;
};
#define to_sci_clk(_hw) container_of(_hw, struct sci_clk, hw)
/**
* sci_clk_prepare - Prepare (enable) a TI SCI clock
* @hw: clock to prepare
*
* Prepares a clock to be actively used. Returns the SCI protocol status.
*/
static int sci_clk_prepare(struct clk_hw *hw)
{
struct sci_clk *clk = to_sci_clk(hw);
bool enable_ssc = clk->flags & SCI_CLK_SSC_ENABLE;
bool allow_freq_change = clk->flags & SCI_CLK_ALLOW_FREQ_CHANGE;
bool input_termination = clk->flags & SCI_CLK_INPUT_TERMINATION;
return clk->provider->ops->get_clock(clk->provider->sci, clk->dev_id,
clk->clk_id, enable_ssc,
allow_freq_change,
input_termination);
}
/**
* sci_clk_unprepare - Un-prepares (disables) a TI SCI clock
* @hw: clock to unprepare
*
* Un-prepares a clock from active state.
*/
static void sci_clk_unprepare(struct clk_hw *hw)
{
struct sci_clk *clk = to_sci_clk(hw);
int ret;
ret = clk->provider->ops->put_clock(clk->provider->sci, clk->dev_id,
clk->clk_id);
if (ret)
dev_err(clk->provider->dev,
"unprepare failed for dev=%d, clk=%d, ret=%d\n",
clk->dev_id, clk->clk_id, ret);
}
/**
* sci_clk_is_prepared - Check if a TI SCI clock is prepared or not
* @hw: clock to check status for
*
* Checks if a clock is prepared (enabled) in hardware. Returns non-zero
* value if clock is enabled, zero otherwise.
*/
static int sci_clk_is_prepared(struct clk_hw *hw)
{
struct sci_clk *clk = to_sci_clk(hw);
bool req_state, current_state;
int ret;
ret = clk->provider->ops->is_on(clk->provider->sci, clk->dev_id,
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/err.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/soc/ti/ti_sci_protocol.h`.
- Detected declarations: `struct sci_clk_provider`, `struct sci_clk`, `function sci_clk_prepare`, `function sci_clk_unprepare`, `function prepared`, `function sci_clk_recalc_rate`, `function sci_clk_determine_rate`, `function sci_clk_set_rate`, `function sci_clk_get_parent`, `function sci_clk_set_parent`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: source implementation candidate.
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.