static void __init create_one_pll(struct clockgen *cg, int idx) { u32 __iomem *reg; u32 mult; struct clockgen_pll *pll = &cg->pll[idx]; const char *input = "cg-sysclk"; int i; if (!(cg->info.pll_mask & (1 << idx))) return; if (cg->coreclk && idx != PLATFORM_PLL) { if (IS_ERR(cg->coreclk)) return; input = "cg-coreclk"; } if (cg->info.flags & CG_VER3) { switch (idx) { case PLATFORM_PLL: reg = cg->regs + 0x60080; break; case CGA_PLL1: reg = cg->regs + 0x80; break; case CGA_PLL2: reg = cg->regs + 0xa0; break; case CGB_PLL1: reg = cg->regs + 0x10080; break; case CGB_PLL2: reg = cg->regs + 0x100a0; break; default: WARN_ONCE(1, "index %d\n", idx); return; } } else { if (idx == PLATFORM_PLL) reg = cg->regs + 0xc00; else reg = cg->regs + 0x800 + 0x20 * (idx - 1); } /* Get the multiple of PLL */ mult = cg_in(cg, reg); /* Check if this PLL is disabled */ if (mult & PLL_KILL) { pr_debug("%s(): pll %p disabled\n", __func__, reg); return; } if ((cg->info.flags & CG_VER3) || ((cg->info.flags & CG_PLL_8BIT) && idx != PLATFORM_PLL)) mult = (mult & GENMASK(8, 1)) >> 1; else
static u8 mux_get_parent(struct clk_hw *hw) { struct mux_hwclock *hwc = to_mux_hwclock(hw); u32 clksel; s8 ret; clksel = (cg_in(hwc->cg, hwc->reg) & CLKSEL_MASK) >> CLKSEL_SHIFT; ret = hwc->clksel_to_parent[clksel]; if (ret < 0) { pr_err("%s: mux at %p has bad clksel\n", __func__, hwc->reg); return 0; } return ret; }
static struct clk * __init create_one_cmux(struct clockgen *cg, int idx) { struct mux_hwclock *hwc; const struct clockgen_pll_div *div; unsigned long plat_rate, min_rate; u64 pct80_rate; u32 clksel; hwc = kzalloc(sizeof(*hwc), GFP_KERNEL); if (!hwc) return NULL; if (cg->info.flags & CG_VER3) hwc->reg = cg->regs + 0x70000 + 0x20 * idx; else hwc->reg = cg->regs + 0x20 * idx; hwc->info = cg->info.cmux_groups[cg->info.cmux_to_group[idx]]; /* * Find the rate for the default clksel, and treat it as the * maximum rated core frequency. If this is an incorrect * assumption, certain clock options (possibly including the * default clksel) may be inappropriately excluded on certain * chips. */ clksel = (cg_in(cg, hwc->reg) & CLKSEL_MASK) >> CLKSEL_SHIFT; div = get_pll_div(cg, hwc, clksel); if (!div) { kfree(hwc); return NULL; } pct80_rate = clk_get_rate(div->clk); pct80_rate *= 8; do_div(pct80_rate, 10); plat_rate = clk_get_rate(cg->pll[PLATFORM_PLL].div[PLL_DIV1].clk); if (cg->info.flags & CG_CMUX_GE_PLAT) min_rate = plat_rate; else min_rate = plat_rate / 2; return create_mux_common(cg, hwc, &cmux_ops, min_rate, pct80_rate, "cg-cmux%d", idx); }