drivers/clk/ralink/clk-mt7621.c
Source file repositories/reference/linux-study-clean/drivers/clk/ralink/clk-mt7621.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/ralink/clk-mt7621.c- Extension
.c- Size
- 14436 bytes
- Lines
- 584
- 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/bitfield.hlinux/bitops.hlinux/clk-provider.hlinux/clk.hlinux/mfd/syscon.hlinux/platform_device.hlinux/regmap.hlinux/reset-controller.hlinux/slab.hdt-bindings/clock/mt7621-clk.hdt-bindings/reset/mt7621-reset.h
Detected Declarations
struct mt7621_clk_privstruct mt7621_clkstruct mt7621_fixed_clkstruct mt7621_gatestruct mt7621_rstfunction mt7621_gate_enablefunction mt7621_gate_disablefunction mt7621_gate_is_enabledfunction mt7621_gate_ops_initfunction mt7621_register_gatesfunction mt7621_register_fixed_clocksfunction mt7621_xtal_recalc_ratefunction mt7621_cpu_recalc_ratefunction mt7621_bus_recalc_ratefunction mt7621_register_early_clocksfunction mt7621_clk_initfunction mt7621_assert_devicefunction mt7621_deassert_devicefunction mt7621_reset_devicefunction mt7621_rst_xlatefunction mt7621_reset_initfunction mt7621_clk_probefunction mt7621_clk_reset_init
Annotated Snippet
struct mt7621_clk_priv {
struct regmap *sysc;
struct regmap *memc;
};
struct mt7621_clk {
struct clk_hw hw;
struct mt7621_clk_priv *priv;
};
struct mt7621_fixed_clk {
u8 idx;
const char *name;
const char *parent_name;
unsigned long rate;
struct clk_hw *hw;
};
struct mt7621_gate {
u8 idx;
const char *name;
const char *parent_name;
struct mt7621_clk_priv *priv;
u32 bit_idx;
struct clk_hw hw;
};
#define GATE(_id, _name, _pname, _shift) \
{ \
.idx = _id, \
.name = _name, \
.parent_name = _pname, \
.bit_idx = _shift \
}
static struct mt7621_gate mt7621_gates[] = {
GATE(MT7621_CLK_HSDMA, "hsdma", "150m", BIT(5)),
GATE(MT7621_CLK_FE, "fe", "250m", BIT(6)),
GATE(MT7621_CLK_SP_DIVTX, "sp_divtx", "270m", BIT(7)),
GATE(MT7621_CLK_TIMER, "timer", "50m", BIT(8)),
GATE(MT7621_CLK_PCM, "pcm", "270m", BIT(11)),
GATE(MT7621_CLK_PIO, "pio", "50m", BIT(13)),
GATE(MT7621_CLK_GDMA, "gdma", "bus", BIT(14)),
GATE(MT7621_CLK_NAND, "nand", "125m", BIT(15)),
GATE(MT7621_CLK_I2C, "i2c", "50m", BIT(16)),
GATE(MT7621_CLK_I2S, "i2s", "270m", BIT(17)),
GATE(MT7621_CLK_SPI, "spi", "bus", BIT(18)),
GATE(MT7621_CLK_UART1, "uart1", "50m", BIT(19)),
GATE(MT7621_CLK_UART2, "uart2", "50m", BIT(20)),
GATE(MT7621_CLK_UART3, "uart3", "50m", BIT(21)),
GATE(MT7621_CLK_ETH, "eth", "50m", BIT(23)),
GATE(MT7621_CLK_PCIE0, "pcie0", "125m", BIT(24)),
GATE(MT7621_CLK_PCIE1, "pcie1", "125m", BIT(25)),
GATE(MT7621_CLK_PCIE2, "pcie2", "125m", BIT(26)),
GATE(MT7621_CLK_CRYPTO, "crypto", "250m", BIT(29)),
GATE(MT7621_CLK_SHXC, "shxc", "50m", BIT(30))
};
static inline struct mt7621_gate *to_mt7621_gate(struct clk_hw *hw)
{
return container_of(hw, struct mt7621_gate, hw);
}
static int mt7621_gate_enable(struct clk_hw *hw)
{
struct mt7621_gate *clk_gate = to_mt7621_gate(hw);
struct regmap *sysc = clk_gate->priv->sysc;
return regmap_update_bits(sysc, SYSC_REG_CLKCFG1,
clk_gate->bit_idx, clk_gate->bit_idx);
}
static void mt7621_gate_disable(struct clk_hw *hw)
{
struct mt7621_gate *clk_gate = to_mt7621_gate(hw);
struct regmap *sysc = clk_gate->priv->sysc;
regmap_update_bits(sysc, SYSC_REG_CLKCFG1, clk_gate->bit_idx, 0);
}
static int mt7621_gate_is_enabled(struct clk_hw *hw)
{
struct mt7621_gate *clk_gate = to_mt7621_gate(hw);
struct regmap *sysc = clk_gate->priv->sysc;
u32 val;
if (regmap_read(sysc, SYSC_REG_CLKCFG1, &val))
return 0;
return val & clk_gate->bit_idx;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/clk-provider.h`, `linux/clk.h`, `linux/mfd/syscon.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/reset-controller.h`.
- Detected declarations: `struct mt7621_clk_priv`, `struct mt7621_clk`, `struct mt7621_fixed_clk`, `struct mt7621_gate`, `struct mt7621_rst`, `function mt7621_gate_enable`, `function mt7621_gate_disable`, `function mt7621_gate_is_enabled`, `function mt7621_gate_ops_init`, `function mt7621_register_gates`.
- 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.