arch/mips/lantiq/xway/sysctrl.c
Source file repositories/reference/linux-study-clean/arch/mips/lantiq/xway/sysctrl.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/lantiq/xway/sysctrl.c- Extension
.c- Size
- 18716 bytes
- Lines
- 612
- Domain
- Architecture Layer
- Bucket
- arch/mips
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/ioport.hlinux/export.hlinux/clkdev.hlinux/spinlock.hlinux/of.hlinux/of_address.hlantiq_soc.h../clk.h../prom.h
Detected Declarations
function ltq_pmu_enablefunction ltq_pmu_disablefunction cgu_enablefunction cgu_disablefunction pmu_enablefunction pmu_disablefunction usb_set_clockfunction of_machine_is_compatiblefunction pci_enablefunction of_machine_is_compatiblefunction pci_ext_enablefunction pci_ext_disablefunction clkout_enablefunction clkdev_add_pmufunction clkdev_add_cgufunction clkdev_add_pcifunction clkdev_add_clkoutfunction ltq_soc_initexport ltq_pmu_enableexport ltq_pmu_disable
Annotated Snippet
of_machine_is_compatible("lantiq,grx390")) {
val &= ~0x03; /* XTAL divided by 3 */
} else if (of_machine_is_compatible("lantiq,ar9") ||
of_machine_is_compatible("lantiq,vr9")) {
/* TODO: this depends on the XTAL frequency */
val |= 0x03; /* XTAL divided by 3 */
} else if (of_machine_is_compatible("lantiq,ase")) {
val |= 0x20; /* from XTAL */
} else if (of_machine_is_compatible("lantiq,danube")) {
val |= 0x30; /* 12 MHz, generated from 36 MHz */
}
ltq_cgu_w32(val, ifccr);
}
/* the pci enable helper */
static int pci_enable(struct clk *clk)
{
unsigned int val = ltq_cgu_r32(ifccr);
/* set bus clock speed */
if (of_machine_is_compatible("lantiq,ar9") ||
of_machine_is_compatible("lantiq,vr9")) {
val &= ~0x1f00000;
if (clk->rate == CLOCK_33M)
val |= 0xe00000;
else
val |= 0x700000; /* 62.5M */
} else {
val &= ~0xf00000;
if (clk->rate == CLOCK_33M)
val |= 0x800000;
else
val |= 0x400000; /* 62.5M */
}
ltq_cgu_w32(val, ifccr);
pmu_enable(clk);
return 0;
}
/* enable the external clock as a source */
static int pci_ext_enable(struct clk *clk)
{
ltq_cgu_w32(ltq_cgu_r32(ifccr) & ~(1 << 16), ifccr);
ltq_cgu_w32((1 << 30), pcicr);
return 0;
}
/* disable the external clock as a source */
static void pci_ext_disable(struct clk *clk)
{
ltq_cgu_w32(ltq_cgu_r32(ifccr) | (1 << 16), ifccr);
ltq_cgu_w32((1 << 31) | (1 << 30), pcicr);
}
/* enable a clockout source */
static int clkout_enable(struct clk *clk)
{
int i;
/* get the correct rate */
for (i = 0; i < 4; i++) {
if (clk->rates[i] == clk->rate) {
int shift = 14 - (2 * clk->module);
int enable = 7 - clk->module;
unsigned int val = ltq_cgu_r32(ifccr);
val &= ~(3 << shift);
val |= i << shift;
val |= enable;
ltq_cgu_w32(val, ifccr);
return 0;
}
}
return -1;
}
/* manage the clock gates via PMU */
static void clkdev_add_pmu(const char *dev, const char *con, bool deactivate,
unsigned int module, unsigned int bits)
{
struct clk *clk = kzalloc_obj(struct clk);
if (!clk)
return;
clk->cl.dev_id = dev;
clk->cl.con_id = con;
clk->cl.clk = clk;
clk->enable = pmu_enable;
clk->disable = pmu_disable;
clk->module = module;
clk->bits = bits;
Annotation
- Immediate include surface: `linux/ioport.h`, `linux/export.h`, `linux/clkdev.h`, `linux/spinlock.h`, `linux/of.h`, `linux/of_address.h`, `lantiq_soc.h`, `../clk.h`.
- Detected declarations: `function ltq_pmu_enable`, `function ltq_pmu_disable`, `function cgu_enable`, `function cgu_disable`, `function pmu_enable`, `function pmu_disable`, `function usb_set_clock`, `function of_machine_is_compatible`, `function pci_enable`, `function of_machine_is_compatible`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.