drivers/clk/clk-gemini.c
Source file repositories/reference/linux-study-clean/drivers/clk/clk-gemini.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/clk-gemini.c- Extension
.c- Size
- 11987 bytes
- Lines
- 461
- 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/init.hlinux/module.hlinux/platform_device.hlinux/slab.hlinux/err.hlinux/io.hlinux/clk-provider.hlinux/of.hlinux/of_address.hlinux/mfd/syscon.hlinux/regmap.hlinux/spinlock.hlinux/reset-controller.hdt-bindings/reset/cortina,gemini-reset.hdt-bindings/clock/cortina,gemini-clock.h
Detected Declarations
struct gemini_gate_datastruct clk_gemini_pcistruct gemini_resetfunction gemini_pci_recalc_ratefunction gemini_pci_determine_ratefunction gemini_pci_set_ratefunction gemini_pci_enablefunction gemini_pci_disablefunction gemini_pci_is_enabledfunction gemini_resetfunction gemini_reset_assertfunction gemini_reset_deassertfunction gemini_reset_statusfunction gemini_clk_probefunction gemini_cc_init
Annotated Snippet
struct gemini_gate_data {
u8 bit_idx;
const char *name;
const char *parent_name;
unsigned long flags;
};
/**
* struct clk_gemini_pci - Gemini PCI clock
* @hw: corresponding clock hardware entry
* @map: regmap to access the registers
*/
struct clk_gemini_pci {
struct clk_hw hw;
struct regmap *map;
};
/**
* struct gemini_reset - gemini reset controller
* @map: regmap to access the containing system controller
* @rcdev: reset controller device
*/
struct gemini_reset {
struct regmap *map;
struct reset_controller_dev rcdev;
};
/* Keeps track of all clocks */
static struct clk_hw_onecell_data *gemini_clk_data;
static const struct gemini_gate_data gemini_gates[] = {
{ 1, "security-gate", "secdiv", 0 },
{ 2, "gmac0-gate", "ahb", 0 },
{ 3, "gmac1-gate", "ahb", 0 },
{ 4, "sata0-gate", "ahb", 0 },
{ 5, "sata1-gate", "ahb", 0 },
{ 6, "usb0-gate", "ahb", 0 },
{ 7, "usb1-gate", "ahb", 0 },
{ 8, "ide-gate", "ahb", 0 },
{ 9, "pci-gate", "ahb", 0 },
/*
* The DDR controller may never have a driver, but certainly must
* not be gated off.
*/
{ 10, "ddr-gate", "ahb", CLK_IS_CRITICAL },
/*
* The flash controller must be on to access NOR flash through the
* memory map.
*/
{ 11, "flash-gate", "ahb", CLK_IGNORE_UNUSED },
{ 12, "tvc-gate", "ahb", 0 },
{ 13, "boot-gate", "apb", 0 },
};
#define to_pciclk(_hw) container_of(_hw, struct clk_gemini_pci, hw)
#define to_gemini_reset(p) container_of((p), struct gemini_reset, rcdev)
static unsigned long gemini_pci_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct clk_gemini_pci *pciclk = to_pciclk(hw);
u32 val;
regmap_read(pciclk->map, GEMINI_GLOBAL_MISC_CONTROL, &val);
if (val & PCI_CLK_66MHZ)
return 66000000;
return 33000000;
}
static int gemini_pci_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
/* We support 33 and 66 MHz */
if (req->rate < 48000000)
req->rate = 33000000;
else
req->rate = 66000000;
return 0;
}
static int gemini_pci_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct clk_gemini_pci *pciclk = to_pciclk(hw);
if (rate == 33000000)
return regmap_update_bits(pciclk->map,
GEMINI_GLOBAL_MISC_CONTROL,
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/err.h`, `linux/io.h`, `linux/clk-provider.h`, `linux/of.h`.
- Detected declarations: `struct gemini_gate_data`, `struct clk_gemini_pci`, `struct gemini_reset`, `function gemini_pci_recalc_rate`, `function gemini_pci_determine_rate`, `function gemini_pci_set_rate`, `function gemini_pci_enable`, `function gemini_pci_disable`, `function gemini_pci_is_enabled`, `function gemini_reset`.
- 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.