Lines Matching refs:cg
79 void (*init_periph)(struct clockgen *cg);
99 static void cg_out(struct clockgen *cg, u32 val, u32 __iomem *reg) in cg_out() argument
101 if (cg->info.flags & CG_LITTLE_ENDIAN) in cg_out()
107 static u32 cg_in(struct clockgen *cg, u32 __iomem *reg) in cg_in() argument
111 if (cg->info.flags & CG_LITTLE_ENDIAN) in cg_in()
432 static void __init p2041_init_periph(struct clockgen *cg) in p2041_init_periph() argument
436 reg = ioread32be(&cg->guts->rcwsr[7]); in p2041_init_periph()
439 cg->fman[0] = cg->pll[CGA_PLL2].div[PLL_DIV2].clk; in p2041_init_periph()
441 cg->fman[0] = cg->pll[PLATFORM_PLL].div[PLL_DIV2].clk; in p2041_init_periph()
444 static void __init p4080_init_periph(struct clockgen *cg) in p4080_init_periph() argument
448 reg = ioread32be(&cg->guts->rcwsr[7]); in p4080_init_periph()
451 cg->fman[0] = cg->pll[CGA_PLL3].div[PLL_DIV2].clk; in p4080_init_periph()
453 cg->fman[0] = cg->pll[PLATFORM_PLL].div[PLL_DIV2].clk; in p4080_init_periph()
456 cg->fman[1] = cg->pll[CGA_PLL3].div[PLL_DIV2].clk; in p4080_init_periph()
458 cg->fman[1] = cg->pll[PLATFORM_PLL].div[PLL_DIV2].clk; in p4080_init_periph()
461 static void __init p5020_init_periph(struct clockgen *cg) in p5020_init_periph() argument
466 reg = ioread32be(&cg->guts->rcwsr[7]); in p5020_init_periph()
471 cg->fman[0] = cg->pll[CGA_PLL2].div[div].clk; in p5020_init_periph()
473 cg->fman[0] = cg->pll[PLATFORM_PLL].div[PLL_DIV2].clk; in p5020_init_periph()
476 static void __init p5040_init_periph(struct clockgen *cg) in p5040_init_periph() argument
481 reg = ioread32be(&cg->guts->rcwsr[7]); in p5040_init_periph()
486 cg->fman[0] = cg->pll[CGA_PLL3].div[div].clk; in p5040_init_periph()
488 cg->fman[0] = cg->pll[PLATFORM_PLL].div[PLL_DIV2].clk; in p5040_init_periph()
491 cg->fman[1] = cg->pll[CGA_PLL3].div[div].clk; in p5040_init_periph()
493 cg->fman[1] = cg->pll[PLATFORM_PLL].div[PLL_DIV2].clk; in p5040_init_periph()
496 static void __init t1023_init_periph(struct clockgen *cg) in t1023_init_periph() argument
498 cg->fman[0] = cg->hwaccel[1]; in t1023_init_periph()
501 static void __init t1040_init_periph(struct clockgen *cg) in t1040_init_periph() argument
503 cg->fman[0] = cg->pll[PLATFORM_PLL].div[PLL_DIV1].clk; in t1040_init_periph()
506 static void __init t2080_init_periph(struct clockgen *cg) in t2080_init_periph() argument
508 cg->fman[0] = cg->hwaccel[0]; in t2080_init_periph()
511 static void __init t4240_init_periph(struct clockgen *cg) in t4240_init_periph() argument
513 cg->fman[0] = cg->hwaccel[3]; in t4240_init_periph()
514 cg->fman[1] = cg->hwaccel[4]; in t4240_init_periph()
774 struct clockgen *cg; member
795 cg_out(hwc->cg, (clksel << CLKSEL_SHIFT) & CLKSEL_MASK, hwc->reg); in mux_set_parent()
806 clksel = (cg_in(hwc->cg, hwc->reg) & CLKSEL_MASK) >> CLKSEL_SHIFT; in mux_get_parent()
830 static const struct clockgen_pll_div *get_pll_div(struct clockgen *cg, in get_pll_div() argument
842 return &cg->pll[pll].div[div]; in get_pll_div()
845 static struct clk * __init create_mux_common(struct clockgen *cg, in create_mux_common() argument
867 div = get_pll_div(cg, hwc, i); in create_mux_common()
893 hwc->cg = cg; in create_mux_common()
906 static struct clk * __init create_one_cmux(struct clockgen *cg, int idx) in create_one_cmux() argument
918 if (cg->info.flags & CG_VER3) in create_one_cmux()
919 hwc->reg = cg->regs + 0x70000 + 0x20 * idx; in create_one_cmux()
921 hwc->reg = cg->regs + 0x20 * idx; in create_one_cmux()
923 hwc->info = cg->info.cmux_groups[cg->info.cmux_to_group[idx]]; in create_one_cmux()
932 clksel = (cg_in(cg, hwc->reg) & CLKSEL_MASK) >> CLKSEL_SHIFT; in create_one_cmux()
933 div = get_pll_div(cg, hwc, clksel); in create_one_cmux()
943 plat_rate = clk_get_rate(cg->pll[PLATFORM_PLL].div[PLL_DIV1].clk); in create_one_cmux()
945 if (cg->info.flags & CG_CMUX_GE_PLAT) in create_one_cmux()
950 return create_mux_common(cg, hwc, &cmux_ops, min_rate, max_rate, in create_one_cmux()
954 static struct clk * __init create_one_hwaccel(struct clockgen *cg, int idx) in create_one_hwaccel() argument
962 hwc->reg = cg->regs + 0x20 * idx + 0x10; in create_one_hwaccel()
963 hwc->info = cg->info.hwaccel[idx]; in create_one_hwaccel()
965 return create_mux_common(cg, hwc, &hwaccel_ops, 0, ULONG_MAX, 0, in create_one_hwaccel()
969 static void __init create_muxes(struct clockgen *cg) in create_muxes() argument
973 for (i = 0; i < ARRAY_SIZE(cg->cmux); i++) { in create_muxes()
974 if (cg->info.cmux_to_group[i] < 0) in create_muxes()
976 if (cg->info.cmux_to_group[i] >= in create_muxes()
977 ARRAY_SIZE(cg->info.cmux_groups)) { in create_muxes()
982 cg->cmux[i] = create_one_cmux(cg, i); in create_muxes()
985 for (i = 0; i < ARRAY_SIZE(cg->hwaccel); i++) { in create_muxes()
986 if (!cg->info.hwaccel[i]) in create_muxes()
989 cg->hwaccel[i] = create_one_hwaccel(cg, i); in create_muxes()
1141 static void __init create_one_pll(struct clockgen *cg, int idx) in create_one_pll() argument
1145 struct clockgen_pll *pll = &cg->pll[idx]; in create_one_pll()
1149 if (!(cg->info.pll_mask & (1 << idx))) in create_one_pll()
1152 if (cg->coreclk && idx != PLATFORM_PLL) { in create_one_pll()
1153 if (IS_ERR(cg->coreclk)) in create_one_pll()
1159 if (cg->info.flags & CG_VER3) { in create_one_pll()
1162 reg = cg->regs + 0x60080; in create_one_pll()
1165 reg = cg->regs + 0x80; in create_one_pll()
1168 reg = cg->regs + 0xa0; in create_one_pll()
1171 reg = cg->regs + 0x10080; in create_one_pll()
1174 reg = cg->regs + 0x100a0; in create_one_pll()
1182 reg = cg->regs + 0xc00; in create_one_pll()
1184 reg = cg->regs + 0x800 + 0x20 * (idx - 1); in create_one_pll()
1188 mult = cg_in(cg, reg); in create_one_pll()
1196 if ((cg->info.flags & CG_VER3) || in create_one_pll()
1197 ((cg->info.flags & CG_PLL_8BIT) && idx != PLATFORM_PLL)) in create_one_pll()
1233 static void __init create_plls(struct clockgen *cg) in create_plls() argument
1237 for (i = 0; i < ARRAY_SIZE(cg->pll); i++) in create_plls()
1238 create_one_pll(cg, i); in create_plls()
1319 struct clockgen *cg = data; in clockgen_clk_get() local
1336 clk = cg->sysclk; in clockgen_clk_get()
1339 if (idx >= ARRAY_SIZE(cg->cmux)) in clockgen_clk_get()
1341 clk = cg->cmux[idx]; in clockgen_clk_get()
1344 if (idx >= ARRAY_SIZE(cg->hwaccel)) in clockgen_clk_get()
1346 clk = cg->hwaccel[idx]; in clockgen_clk_get()
1349 if (idx >= ARRAY_SIZE(cg->fman)) in clockgen_clk_get()
1351 clk = cg->fman[idx]; in clockgen_clk_get()
1354 pll = &cg->pll[PLATFORM_PLL]; in clockgen_clk_get()
1362 clk = cg->coreclk; in clockgen_clk_get()