drivers/clk/mediatek/clk-apmixed.c
Source file repositories/reference/linux-study-clean/drivers/clk/mediatek/clk-apmixed.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/mediatek/clk-apmixed.c- Extension
.c- Size
- 2344 bytes
- Lines
- 113
- 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.
- 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/delay.hlinux/module.hlinux/of_address.hlinux/slab.hclk-mtk.h
Detected Declarations
struct mtk_ref2usb_txfunction mtk_ref2usb_tx_is_preparedfunction mtk_ref2usb_tx_preparefunction mtk_ref2usb_tx_unpreparefunction mtk_clk_unregister_ref2usb_txexport mtk_clk_register_ref2usb_txexport mtk_clk_unregister_ref2usb_tx
Annotated Snippet
struct mtk_ref2usb_tx {
struct clk_hw hw;
void __iomem *base_addr;
};
static inline struct mtk_ref2usb_tx *to_mtk_ref2usb_tx(struct clk_hw *hw)
{
return container_of(hw, struct mtk_ref2usb_tx, hw);
}
static int mtk_ref2usb_tx_is_prepared(struct clk_hw *hw)
{
struct mtk_ref2usb_tx *tx = to_mtk_ref2usb_tx(hw);
return (readl(tx->base_addr) & REF2USB_EN_MASK) == REF2USB_EN_MASK;
}
static int mtk_ref2usb_tx_prepare(struct clk_hw *hw)
{
struct mtk_ref2usb_tx *tx = to_mtk_ref2usb_tx(hw);
u32 val;
val = readl(tx->base_addr);
val |= REF2USB_TX_EN;
writel(val, tx->base_addr);
udelay(100);
val |= REF2USB_TX_LPF_EN;
writel(val, tx->base_addr);
val |= REF2USB_TX_OUT_EN;
writel(val, tx->base_addr);
return 0;
}
static void mtk_ref2usb_tx_unprepare(struct clk_hw *hw)
{
struct mtk_ref2usb_tx *tx = to_mtk_ref2usb_tx(hw);
u32 val;
val = readl(tx->base_addr);
val &= ~REF2USB_EN_MASK;
writel(val, tx->base_addr);
}
static const struct clk_ops mtk_ref2usb_tx_ops = {
.is_prepared = mtk_ref2usb_tx_is_prepared,
.prepare = mtk_ref2usb_tx_prepare,
.unprepare = mtk_ref2usb_tx_unprepare,
};
struct clk_hw *mtk_clk_register_ref2usb_tx(const char *name,
const char *parent_name, void __iomem *reg)
{
struct mtk_ref2usb_tx *tx;
struct clk_init_data init = {};
int ret;
tx = kzalloc_obj(*tx);
if (!tx)
return ERR_PTR(-ENOMEM);
tx->base_addr = reg;
tx->hw.init = &init;
init.name = name;
init.ops = &mtk_ref2usb_tx_ops;
init.parent_names = &parent_name;
init.num_parents = 1;
ret = clk_hw_register(NULL, &tx->hw);
if (ret) {
kfree(tx);
return ERR_PTR(ret);
}
return &tx->hw;
}
EXPORT_SYMBOL_GPL(mtk_clk_register_ref2usb_tx);
void mtk_clk_unregister_ref2usb_tx(struct clk_hw *hw)
{
struct mtk_ref2usb_tx *tx = to_mtk_ref2usb_tx(hw);
clk_hw_unregister(hw);
kfree(tx);
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/module.h`, `linux/of_address.h`, `linux/slab.h`, `clk-mtk.h`.
- Detected declarations: `struct mtk_ref2usb_tx`, `function mtk_ref2usb_tx_is_prepared`, `function mtk_ref2usb_tx_prepare`, `function mtk_ref2usb_tx_unprepare`, `function mtk_clk_unregister_ref2usb_tx`, `export mtk_clk_register_ref2usb_tx`, `export mtk_clk_unregister_ref2usb_tx`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: integration 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.