/* clock control register for legacy */ #define CGU_IFCCR 0x0018 #define CGU_IFCCR_VR9 0x0024 /* system clock register for legacy */ #define CGU_SYS 0x0010 /* pci control register */ #define CGU_PCICR 0x0034 #define CGU_PCICR_VR9 0x0038 /* ephy configuration register */ #define CGU_EPHY 0x10
/* Legacy PMU register for ar9, ase, danube */ /* power control register */ #define PMU_PWDCR 0x1C /* power status register */ #define PMU_PWDSR 0x20 /* power control register */ #define PMU_PWDCR1 0x24 /* power status register */ #define PMU_PWDSR1 0x28 /* power control register */ #define PWDCR(x) ((x) ? (PMU_PWDCR1) : (PMU_PWDCR)) /* power status register */ #define PWDSR(x) ((x) ? (PMU_PWDSR1) : (PMU_PWDSR))
/* PMU register for ar10 and grx390 */
/* First register set */ #define PMU_CLK_SR 0x20 /* status */ #define PMU_CLK_CR_A 0x24 /* Enable */ #define PMU_CLK_CR_B 0x28 /* Disable */ /* Second register set */ #define PMU_CLK_SR1 0x30 /* status */ #define PMU_CLK_CR1_A 0x34 /* Enable */ #define PMU_CLK_CR1_B 0x38 /* Disable */ /* Third register set */ #define PMU_ANA_SR 0x40 /* status */ #define PMU_ANA_CR_A 0x44 /* Enable */ #define PMU_ANA_CR_B 0x48 /* Disable */
/* enable a clock gate */ staticint pmu_enable(struct clk *clk)
{ int retry = 1000000;
if (of_machine_is_compatible("lantiq,ar10")
|| of_machine_is_compatible("lantiq,grx390")) {
pmu_w32(clk->bits, PWDCR_EN_XRX(clk->module)); do {} while (--retry &&
(!(pmu_r32(PWDSR_XRX(clk->module)) & clk->bits)));
} else {
spin_lock(&g_pmu_lock);
pmu_w32(pmu_r32(PWDCR(clk->module)) & ~clk->bits,
PWDCR(clk->module)); do {} while (--retry &&
(pmu_r32(PWDSR(clk->module)) & clk->bits));
spin_unlock(&g_pmu_lock);
}
if (!retry)
panic("activating PMU module failed!");
return0;
}
/* disable a clock gate */ staticvoid pmu_disable(struct clk *clk)
{ int retry = 1000000;
if (of_machine_is_compatible("lantiq,ar10")
|| of_machine_is_compatible("lantiq,grx390")) {
pmu_w32(clk->bits, PWDCR_DIS_XRX(clk->module)); do {} while (--retry &&
(pmu_r32(PWDSR_XRX(clk->module)) & clk->bits));
} else {
spin_lock(&g_pmu_lock);
pmu_w32(pmu_r32(PWDCR(clk->module)) | clk->bits,
PWDCR(clk->module)); do {} while (--retry &&
(!(pmu_r32(PWDSR(clk->module)) & clk->bits)));
spin_unlock(&g_pmu_lock);
}
if (!retry)
pr_warn("deactivating PMU module failed!");
}
staticvoid usb_set_clock(void)
{ unsignedint val = ltq_cgu_r32(ifccr);
if (of_machine_is_compatible("lantiq,ar10") ||
of_machine_is_compatible("lantiq,grx390")) {
val &= ~0x03; /* XTAL divided by 3 */
} elseif (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 */
} elseif (of_machine_is_compatible("lantiq,ase")) {
val |= 0x20; /* from XTAL */
} elseif (of_machine_is_compatible("lantiq,danube")) {
val |= 0x30; /* 12 MHz, generated from 36 MHz */
}
ltq_cgu_w32(val, ifccr);
}
/* the pci enable helper */ staticint pci_enable(struct clk *clk)
{ unsignedint 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); return0;
}
/* enable the external clock as a source */ staticint pci_ext_enable(struct clk *clk)
{
ltq_cgu_w32(ltq_cgu_r32(ifccr) & ~(1 << 16), ifccr);
ltq_cgu_w32((1 << 30), pcicr); return0;
}
/* disable the external clock as a source */ staticvoid 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 */ staticint 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; unsignedint val = ltq_cgu_r32(ifccr);
val &= ~(3 << shift);
val |= i << shift;
val |= enable;
ltq_cgu_w32(val, ifccr); return0;
}
} return -1;
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.26Bemerkung:
(vorverarbeitet am 2026-10-01)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.