Lines Matching refs:cru
85 static int rkclk_set_pll(struct rk3188_cru *cru, enum rk_clk_id clk_id, in rkclk_set_pll() argument
89 struct rk3188_pll *pll = &cru->pll[pll_id]; in rkclk_set_pll()
119 static int rkclk_configure_ddr(struct rk3188_cru *cru, struct rk3188_grf *grf, in rkclk_configure_ddr() argument
149 rk_clrsetreg(&cru->cru_mode_con, DPLL_MODE_MASK << DPLL_MODE_SHIFT, in rkclk_configure_ddr()
152 rkclk_set_pll(cru, CLK_DDR, &dpll_cfg[cfg], has_bwadj); in rkclk_configure_ddr()
159 rk_clrsetreg(&cru->cru_mode_con, DPLL_MODE_MASK << DPLL_MODE_SHIFT, in rkclk_configure_ddr()
165 static int rkclk_configure_cpu(struct rk3188_cru *cru, struct rk3188_grf *grf, in rkclk_configure_cpu() argument
198 rk_clrsetreg(&cru->cru_mode_con, APLL_MODE_MASK << APLL_MODE_SHIFT, in rkclk_configure_cpu()
201 rkclk_set_pll(cru, CLK_ARM, &apll_cfg[cfg], has_bwadj); in rkclk_configure_cpu()
208 rk_clrsetreg(&cru->cru_clksel_con[0], in rkclk_configure_cpu()
213 rk_clrsetreg(&cru->cru_clksel_con[1], in rkclk_configure_cpu()
218 rk_clrsetreg(&cru->cru_mode_con, APLL_MODE_MASK << APLL_MODE_SHIFT, in rkclk_configure_cpu()
225 static uint32_t rkclk_pll_get_rate(struct rk3188_cru *cru, in rkclk_pll_get_rate() argument
231 struct rk3188_pll *pll = &cru->pll[pll_id]; in rkclk_pll_get_rate()
238 con = readl(&cru->cru_mode_con); in rkclk_pll_get_rate()
258 static ulong rockchip_mmc_get_clk(struct rk3188_cru *cru, uint gclk_rate, in rockchip_mmc_get_clk() argument
267 con = readl(&cru->cru_clksel_con[12]); in rockchip_mmc_get_clk()
272 con = readl(&cru->cru_clksel_con[11]); in rockchip_mmc_get_clk()
277 con = readl(&cru->cru_clksel_con[12]); in rockchip_mmc_get_clk()
287 static ulong rockchip_mmc_set_clk(struct rk3188_cru *cru, uint gclk_rate, in rockchip_mmc_set_clk() argument
300 rk_clrsetreg(&cru->cru_clksel_con[12], in rockchip_mmc_set_clk()
306 rk_clrsetreg(&cru->cru_clksel_con[11], in rockchip_mmc_set_clk()
312 rk_clrsetreg(&cru->cru_clksel_con[12], in rockchip_mmc_set_clk()
320 return rockchip_mmc_get_clk(cru, gclk_rate, periph); in rockchip_mmc_set_clk()
323 static ulong rockchip_spi_get_clk(struct rk3188_cru *cru, uint gclk_rate, in rockchip_spi_get_clk() argument
331 con = readl(&cru->cru_clksel_con[25]); in rockchip_spi_get_clk()
335 con = readl(&cru->cru_clksel_con[25]); in rockchip_spi_get_clk()
345 static ulong rockchip_spi_set_clk(struct rk3188_cru *cru, uint gclk_rate, in rockchip_spi_set_clk() argument
354 rk_clrsetreg(&cru->cru_clksel_con[25], in rockchip_spi_set_clk()
360 rk_clrsetreg(&cru->cru_clksel_con[25], in rockchip_spi_set_clk()
368 return rockchip_spi_get_clk(cru, gclk_rate, periph); in rockchip_spi_set_clk()
372 static void rkclk_init(struct rk3188_cru *cru, struct rk3188_grf *grf, in rkclk_init() argument
378 rk_clrsetreg(&cru->cru_mode_con, in rkclk_init()
385 rkclk_set_pll(cru, CLK_GENERAL, &gpll_init_cfg, has_bwadj); in rkclk_init()
386 rkclk_set_pll(cru, CLK_CODEC, &cpll_init_cfg, has_bwadj); in rkclk_init()
402 rk_clrsetreg(&cru->cru_clksel_con[0], in rkclk_init()
415 rk_clrsetreg(&cru->cru_clksel_con[1], in rkclk_init()
438 rk_clrsetreg(&cru->cru_clksel_con[10], in rkclk_init()
448 rk_clrsetreg(&cru->cru_mode_con, in rkclk_init()
454 rockchip_mmc_set_clk(cru, PERI_HCLK_HZ, HCLK_SDMMC, 16000000); in rkclk_init()
463 gclk_rate = rkclk_pll_get_rate(priv->cru, CLK_GENERAL); in rk3188_clk_get_rate()
466 new_rate = rkclk_pll_get_rate(priv->cru, clk->id); in rk3188_clk_get_rate()
474 new_rate = rockchip_mmc_get_clk(priv->cru, PERI_HCLK_HZ, in rk3188_clk_get_rate()
479 new_rate = rockchip_spi_get_clk(priv->cru, PERI_PCLK_HZ, in rk3188_clk_get_rate()
498 struct rk3188_cru *cru = priv->cru; in rk3188_clk_set_rate() local
503 new_rate = rkclk_configure_cpu(priv->cru, priv->grf, rate, in rk3188_clk_set_rate()
507 new_rate = rkclk_configure_ddr(priv->cru, priv->grf, rate, in rk3188_clk_set_rate()
516 new_rate = rockchip_mmc_set_clk(cru, PERI_HCLK_HZ, in rk3188_clk_set_rate()
521 new_rate = rockchip_spi_set_clk(cru, PERI_PCLK_HZ, in rk3188_clk_set_rate()
541 priv->cru = dev_read_addr_ptr(dev); in rk3188_clk_ofdata_to_platdata()
561 priv->cru = map_sysmem(plat->dtd.reg[0], plat->dtd.reg[1]); in rk3188_clk_probe()
564 rkclk_init(priv->cru, priv->grf, priv->has_bwadj); in rk3188_clk_probe()