drivers/clk/ingenic/tcu.c
Source file repositories/reference/linux-study-clean/drivers/clk/ingenic/tcu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/ingenic/tcu.c- Extension
.c- Size
- 13115 bytes
- Lines
- 500
- 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.hlinux/clk-provider.hlinux/clockchips.hlinux/mfd/ingenic-tcu.hlinux/mfd/syscon.hlinux/regmap.hlinux/slab.hlinux/syscore_ops.hdt-bindings/clock/ingenic,tcu.h
Detected Declarations
struct ingenic_soc_infostruct ingenic_tcu_clk_infostruct ingenic_tcu_clkstruct ingenic_tcuenum tcu_clk_parentfunction ingenic_tcu_enablefunction ingenic_tcu_disablefunction ingenic_tcu_is_enabledfunction ingenic_tcu_enable_regsfunction ingenic_tcu_disable_regsfunction ingenic_tcu_get_parentfunction ingenic_tcu_set_parentfunction ingenic_tcu_recalc_ratefunction ingenic_tcu_get_prescalefunction ingenic_tcu_determine_ratefunction ingenic_tcu_set_ratefunction ingenic_tcu_register_clockfunction ingenic_tcu_probefunction driverfunction tcu_pm_suspendfunction tcu_pm_resumefunction ingenic_tcu_init
Annotated Snippet
struct ingenic_soc_info {
unsigned int num_channels;
bool has_ost;
bool has_tcu_clk;
bool allow_missing_tcu_clk;
};
struct ingenic_tcu_clk_info {
struct clk_init_data init_data;
u8 gate_bit;
u8 tcsr_reg;
};
struct ingenic_tcu_clk {
struct clk_hw hw;
unsigned int idx;
struct ingenic_tcu *tcu;
const struct ingenic_tcu_clk_info *info;
};
struct ingenic_tcu {
const struct ingenic_soc_info *soc_info;
struct regmap *map;
struct clk *clk;
struct clk_hw_onecell_data *clocks;
};
static struct ingenic_tcu *ingenic_tcu;
static inline struct ingenic_tcu_clk *to_tcu_clk(struct clk_hw *hw)
{
return container_of(hw, struct ingenic_tcu_clk, hw);
}
static int ingenic_tcu_enable(struct clk_hw *hw)
{
struct ingenic_tcu_clk *tcu_clk = to_tcu_clk(hw);
const struct ingenic_tcu_clk_info *info = tcu_clk->info;
struct ingenic_tcu *tcu = tcu_clk->tcu;
regmap_write(tcu->map, TCU_REG_TSCR, BIT(info->gate_bit));
return 0;
}
static void ingenic_tcu_disable(struct clk_hw *hw)
{
struct ingenic_tcu_clk *tcu_clk = to_tcu_clk(hw);
const struct ingenic_tcu_clk_info *info = tcu_clk->info;
struct ingenic_tcu *tcu = tcu_clk->tcu;
regmap_write(tcu->map, TCU_REG_TSSR, BIT(info->gate_bit));
}
static int ingenic_tcu_is_enabled(struct clk_hw *hw)
{
struct ingenic_tcu_clk *tcu_clk = to_tcu_clk(hw);
const struct ingenic_tcu_clk_info *info = tcu_clk->info;
unsigned int value;
regmap_read(tcu_clk->tcu->map, TCU_REG_TSR, &value);
return !(value & BIT(info->gate_bit));
}
static bool ingenic_tcu_enable_regs(struct clk_hw *hw)
{
struct ingenic_tcu_clk *tcu_clk = to_tcu_clk(hw);
const struct ingenic_tcu_clk_info *info = tcu_clk->info;
struct ingenic_tcu *tcu = tcu_clk->tcu;
bool enabled = false;
/*
* According to the programming manual, a timer channel's registers can
* only be accessed when the channel's stop bit is clear.
*/
enabled = !!ingenic_tcu_is_enabled(hw);
regmap_write(tcu->map, TCU_REG_TSCR, BIT(info->gate_bit));
return enabled;
}
static void ingenic_tcu_disable_regs(struct clk_hw *hw)
{
struct ingenic_tcu_clk *tcu_clk = to_tcu_clk(hw);
const struct ingenic_tcu_clk_info *info = tcu_clk->info;
struct ingenic_tcu *tcu = tcu_clk->tcu;
regmap_write(tcu->map, TCU_REG_TSSR, BIT(info->gate_bit));
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk-provider.h`, `linux/clockchips.h`, `linux/mfd/ingenic-tcu.h`, `linux/mfd/syscon.h`, `linux/regmap.h`, `linux/slab.h`, `linux/syscore_ops.h`.
- Detected declarations: `struct ingenic_soc_info`, `struct ingenic_tcu_clk_info`, `struct ingenic_tcu_clk`, `struct ingenic_tcu`, `enum tcu_clk_parent`, `function ingenic_tcu_enable`, `function ingenic_tcu_disable`, `function ingenic_tcu_is_enabled`, `function ingenic_tcu_enable_regs`, `function ingenic_tcu_disable_regs`.
- 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.