drivers/clk/imx/clk-gate-93.c
Source file repositories/reference/linux-study-clean/drivers/clk/imx/clk-gate-93.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/imx/clk-gate-93.c- Extension
.c- Size
- 4485 bytes
- Lines
- 200
- Domain
- Driver Families
- Bucket
- drivers/clk
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/clk-provider.hlinux/errno.hlinux/export.hlinux/io.hlinux/iopoll.hlinux/slab.hclk.h
Detected Declarations
struct imx93_clk_gatefunction imx93_clk_gate_do_hardwarefunction imx93_clk_gate_enablefunction imx93_clk_gate_disablefunction imx93_clk_gate_reg_is_enabledfunction imx93_clk_gate_is_enabledfunction imx93_clk_gate_disable_unusedexport imx93_clk_gate
Annotated Snippet
struct imx93_clk_gate {
struct clk_hw hw;
void __iomem *reg;
u32 bit_idx;
u32 val;
u32 mask;
spinlock_t *lock;
unsigned int *share_count;
};
#define to_imx93_clk_gate(_hw) container_of(_hw, struct imx93_clk_gate, hw)
static void imx93_clk_gate_do_hardware(struct clk_hw *hw, bool enable)
{
struct imx93_clk_gate *gate = to_imx93_clk_gate(hw);
u32 val;
val = readl(gate->reg + AUTHEN_OFFSET);
if (val & CPULPM_EN) {
val = enable ? LPM_SETTING_ON : LPM_SETTING_OFF;
writel(val, gate->reg + LPM_CUR_OFFSET);
} else {
val = readl(gate->reg + DIRECT_OFFSET);
val &= ~(gate->mask << gate->bit_idx);
if (enable)
val |= (gate->val & gate->mask) << gate->bit_idx;
writel(val, gate->reg + DIRECT_OFFSET);
}
}
static int imx93_clk_gate_enable(struct clk_hw *hw)
{
struct imx93_clk_gate *gate = to_imx93_clk_gate(hw);
unsigned long flags;
spin_lock_irqsave(gate->lock, flags);
if (gate->share_count && (*gate->share_count)++ > 0)
goto out;
imx93_clk_gate_do_hardware(hw, true);
out:
spin_unlock_irqrestore(gate->lock, flags);
return 0;
}
static void imx93_clk_gate_disable(struct clk_hw *hw)
{
struct imx93_clk_gate *gate = to_imx93_clk_gate(hw);
unsigned long flags;
spin_lock_irqsave(gate->lock, flags);
if (gate->share_count) {
if (WARN_ON(*gate->share_count == 0))
goto out;
else if (--(*gate->share_count) > 0)
goto out;
}
imx93_clk_gate_do_hardware(hw, false);
out:
spin_unlock_irqrestore(gate->lock, flags);
}
static int imx93_clk_gate_reg_is_enabled(struct imx93_clk_gate *gate)
{
u32 val = readl(gate->reg + AUTHEN_OFFSET);
if (val & CPULPM_EN) {
val = readl(gate->reg + LPM_CUR_OFFSET);
if (val == LPM_SETTING_ON)
return 1;
} else {
val = readl(gate->reg);
if (((val >> gate->bit_idx) & gate->mask) == gate->val)
return 1;
}
return 0;
}
static int imx93_clk_gate_is_enabled(struct clk_hw *hw)
{
struct imx93_clk_gate *gate = to_imx93_clk_gate(hw);
unsigned long flags;
int ret;
spin_lock_irqsave(gate->lock, flags);
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/errno.h`, `linux/export.h`, `linux/io.h`, `linux/iopoll.h`, `linux/slab.h`, `clk.h`.
- Detected declarations: `struct imx93_clk_gate`, `function imx93_clk_gate_do_hardware`, `function imx93_clk_gate_enable`, `function imx93_clk_gate_disable`, `function imx93_clk_gate_reg_is_enabled`, `function imx93_clk_gate_is_enabled`, `function imx93_clk_gate_disable_unused`, `export imx93_clk_gate`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: integration 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.