drivers/clk/imx/clk-imx8ulp-sim-lpav.c
Source file repositories/reference/linux-study-clean/drivers/clk/imx/clk-imx8ulp-sim-lpav.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/imx/clk-imx8ulp-sim-lpav.c- Extension
.c- Size
- 4359 bytes
- Lines
- 157
- 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
dt-bindings/clock/imx8ulp-clock.hlinux/auxiliary_bus.hlinux/clk-provider.hlinux/module.hlinux/of.hlinux/of_platform.hlinux/platform_device.hlinux/regmap.hlinux/slab.h
Detected Declarations
struct clk_imx8ulp_sim_lpav_datastruct clk_imx8ulp_sim_lpav_gatefunction clk_imx8ulp_sim_lpav_lockfunction clk_imx8ulp_sim_lpav_unlockfunction clk_imx8ulp_sim_lpav_probe
Annotated Snippet
struct clk_imx8ulp_sim_lpav_data {
spinlock_t lock; /* shared by MUX, clock gate and reset */
unsigned long flags; /* for spinlock usage */
struct clk_hw_onecell_data clk_data; /* keep last */
};
struct clk_imx8ulp_sim_lpav_gate {
const char *name;
int id;
const struct clk_parent_data parent;
u8 bit;
};
static struct clk_imx8ulp_sim_lpav_gate gates[] = {
IMX8ULP_HIFI_CLK_GATE("hifi_core", CORE, "core", 17),
IMX8ULP_HIFI_CLK_GATE("hifi_pbclk", PBCLK, "bus", 18),
IMX8ULP_HIFI_CLK_GATE("hifi_plat", PLAT, "plat", 19)
};
static void clk_imx8ulp_sim_lpav_lock(void *arg) __acquires(&data->lock)
{
struct clk_imx8ulp_sim_lpav_data *data = dev_get_drvdata(arg);
spin_lock_irqsave(&data->lock, data->flags);
}
static void clk_imx8ulp_sim_lpav_unlock(void *arg) __releases(&data->lock)
{
struct clk_imx8ulp_sim_lpav_data *data = dev_get_drvdata(arg);
spin_unlock_irqrestore(&data->lock, data->flags);
}
static int clk_imx8ulp_sim_lpav_probe(struct platform_device *pdev)
{
const struct regmap_config regmap_config = {
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
.lock = clk_imx8ulp_sim_lpav_lock,
.unlock = clk_imx8ulp_sim_lpav_unlock,
.lock_arg = &pdev->dev,
};
struct clk_imx8ulp_sim_lpav_data *data;
struct auxiliary_device *adev;
struct regmap *regmap;
void __iomem *base;
struct clk_hw *hw;
int i, ret;
data = devm_kzalloc(&pdev->dev,
struct_size(data, clk_data.hws, ARRAY_SIZE(gates)),
GFP_KERNEL);
if (!data)
return -ENOMEM;
dev_set_drvdata(&pdev->dev, data);
/*
* this lock is used directly by the clock gate and indirectly
* by the reset and mux controller via the regmap API
*/
spin_lock_init(&data->lock);
base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base))
return dev_err_probe(&pdev->dev, PTR_ERR(base),
"failed to ioremap base\n");
/*
* although the clock gate doesn't use the regmap API to modify the
* registers, we still need the regmap because of the reset auxiliary
* driver and the MUX drivers, which use the parent device's regmap
*/
regmap = devm_regmap_init_mmio(&pdev->dev, base, ®map_config);
if (IS_ERR(regmap))
return dev_err_probe(&pdev->dev, PTR_ERR(regmap),
"failed to initialize regmap\n");
data->clk_data.num = ARRAY_SIZE(gates);
for (i = 0; i < ARRAY_SIZE(gates); i++) {
hw = devm_clk_hw_register_gate_parent_data(&pdev->dev,
gates[i].name,
&gates[i].parent,
CLK_SET_RATE_PARENT,
base + SYSCTRL0,
gates[i].bit,
0x0, &data->lock);
if (IS_ERR(hw))
return dev_err_probe(&pdev->dev, PTR_ERR(hw),
Annotation
- Immediate include surface: `dt-bindings/clock/imx8ulp-clock.h`, `linux/auxiliary_bus.h`, `linux/clk-provider.h`, `linux/module.h`, `linux/of.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct clk_imx8ulp_sim_lpav_data`, `struct clk_imx8ulp_sim_lpav_gate`, `function clk_imx8ulp_sim_lpav_lock`, `function clk_imx8ulp_sim_lpav_unlock`, `function clk_imx8ulp_sim_lpav_probe`.
- 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.