Lines Matching refs:cprman

333 static inline void cprman_write(struct bcm2835_cprman *cprman, u32 reg, u32 val)  in cprman_write()  argument
335 writel(CM_PASSWORD | val, cprman->regs + reg); in cprman_write()
338 static inline u32 cprman_read(struct bcm2835_cprman *cprman, u32 reg) in cprman_read() argument
340 return readl(cprman->regs + reg); in cprman_read()
346 static unsigned long bcm2835_measure_tcnt_mux(struct bcm2835_cprman *cprman, in bcm2835_measure_tcnt_mux() argument
353 spin_lock(&cprman->regs_lock); in bcm2835_measure_tcnt_mux()
355 cprman_write(cprman, CM_TCNTCTL, CM_KILL); in bcm2835_measure_tcnt_mux()
357 cprman_write(cprman, CM_TCNTCTL, in bcm2835_measure_tcnt_mux()
361 cprman_write(cprman, CM_OSCCOUNT, osccount); in bcm2835_measure_tcnt_mux()
368 while (cprman_read(cprman, CM_OSCCOUNT)) { in bcm2835_measure_tcnt_mux()
370 dev_err(cprman->dev, "timeout waiting for OSCCOUNT\n"); in bcm2835_measure_tcnt_mux()
379 while (cprman_read(cprman, CM_TCNTCTL) & CM_BUSY) { in bcm2835_measure_tcnt_mux()
381 dev_err(cprman->dev, "timeout waiting for !BUSY\n"); in bcm2835_measure_tcnt_mux()
388 count = cprman_read(cprman, CM_TCNTCNT); in bcm2835_measure_tcnt_mux()
390 cprman_write(cprman, CM_TCNTCTL, 0); in bcm2835_measure_tcnt_mux()
393 spin_unlock(&cprman->regs_lock); in bcm2835_measure_tcnt_mux()
398 static void bcm2835_debugfs_regset(struct bcm2835_cprman *cprman, u32 base, in bcm2835_debugfs_regset() argument
404 regset = devm_kzalloc(cprman->dev, sizeof(*regset), GFP_KERNEL); in bcm2835_debugfs_regset()
410 regset->base = cprman->regs + base; in bcm2835_debugfs_regset()
514 struct bcm2835_cprman *cprman; member
521 struct bcm2835_cprman *cprman = pll->cprman; in bcm2835_pll_is_on() local
524 return cprman_read(cprman, data->a2w_ctrl_reg) & in bcm2835_pll_is_on()
572 struct bcm2835_cprman *cprman = pll->cprman; in bcm2835_pll_get_rate() local
574 u32 a2wctrl = cprman_read(cprman, data->a2w_ctrl_reg); in bcm2835_pll_get_rate()
581 fdiv = cprman_read(cprman, data->frac_reg) & A2W_PLL_FRAC_MASK; in bcm2835_pll_get_rate()
584 using_prediv = cprman_read(cprman, data->ana_reg_base + 4) & in bcm2835_pll_get_rate()
598 struct bcm2835_cprman *cprman = pll->cprman; in bcm2835_pll_off() local
601 spin_lock(&cprman->regs_lock); in bcm2835_pll_off()
602 cprman_write(cprman, data->cm_ctrl_reg, CM_PLL_ANARST); in bcm2835_pll_off()
603 cprman_write(cprman, data->a2w_ctrl_reg, in bcm2835_pll_off()
604 cprman_read(cprman, data->a2w_ctrl_reg) | in bcm2835_pll_off()
606 spin_unlock(&cprman->regs_lock); in bcm2835_pll_off()
612 struct bcm2835_cprman *cprman = pll->cprman; in bcm2835_pll_on() local
616 cprman_write(cprman, data->a2w_ctrl_reg, in bcm2835_pll_on()
617 cprman_read(cprman, data->a2w_ctrl_reg) & in bcm2835_pll_on()
621 spin_lock(&cprman->regs_lock); in bcm2835_pll_on()
622 cprman_write(cprman, data->cm_ctrl_reg, in bcm2835_pll_on()
623 cprman_read(cprman, data->cm_ctrl_reg) & ~CM_PLL_ANARST); in bcm2835_pll_on()
624 spin_unlock(&cprman->regs_lock); in bcm2835_pll_on()
628 while (!(cprman_read(cprman, CM_LOCK) & data->lock_mask)) { in bcm2835_pll_on()
630 dev_err(cprman->dev, "%s: couldn't lock PLL\n", in bcm2835_pll_on()
638 cprman_write(cprman, data->a2w_ctrl_reg, in bcm2835_pll_on()
639 cprman_read(cprman, data->a2w_ctrl_reg) | in bcm2835_pll_on()
646 bcm2835_pll_write_ana(struct bcm2835_cprman *cprman, u32 ana_reg_base, u32 *ana) in bcm2835_pll_write_ana() argument
659 cprman_write(cprman, ana_reg_base + i * 4, ana[i]); in bcm2835_pll_write_ana()
666 struct bcm2835_cprman *cprman = pll->cprman; in bcm2835_pll_set_rate() local
683 ana[i] = cprman_read(cprman, data->ana_reg_base + i * 4); in bcm2835_pll_set_rate()
705 spin_lock(&cprman->regs_lock); in bcm2835_pll_set_rate()
706 cprman_write(cprman, A2W_XOSC_CTRL, in bcm2835_pll_set_rate()
707 cprman_read(cprman, A2W_XOSC_CTRL) | in bcm2835_pll_set_rate()
709 spin_unlock(&cprman->regs_lock); in bcm2835_pll_set_rate()
712 bcm2835_pll_write_ana(cprman, data->ana_reg_base, ana); in bcm2835_pll_set_rate()
715 cprman_write(cprman, data->frac_reg, fdiv); in bcm2835_pll_set_rate()
717 a2w_ctl = cprman_read(cprman, data->a2w_ctrl_reg); in bcm2835_pll_set_rate()
722 cprman_write(cprman, data->a2w_ctrl_reg, a2w_ctl); in bcm2835_pll_set_rate()
725 bcm2835_pll_write_ana(cprman, data->ana_reg_base, ana); in bcm2835_pll_set_rate()
734 struct bcm2835_cprman *cprman = pll->cprman; in bcm2835_pll_debug_init() local
738 regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL); in bcm2835_pll_debug_init()
757 bcm2835_debugfs_regset(cprman, 0, regs, 7, dentry); in bcm2835_pll_debug_init()
772 struct bcm2835_cprman *cprman; member
785 struct bcm2835_cprman *cprman = divider->cprman; in bcm2835_pll_divider_is_on() local
788 return !(cprman_read(cprman, data->a2w_reg) & A2W_PLL_CHANNEL_DISABLE); in bcm2835_pll_divider_is_on()
807 struct bcm2835_cprman *cprman = divider->cprman; in bcm2835_pll_divider_off() local
810 spin_lock(&cprman->regs_lock); in bcm2835_pll_divider_off()
811 cprman_write(cprman, data->cm_reg, in bcm2835_pll_divider_off()
812 (cprman_read(cprman, data->cm_reg) & in bcm2835_pll_divider_off()
814 cprman_write(cprman, data->a2w_reg, in bcm2835_pll_divider_off()
815 cprman_read(cprman, data->a2w_reg) | in bcm2835_pll_divider_off()
817 spin_unlock(&cprman->regs_lock); in bcm2835_pll_divider_off()
823 struct bcm2835_cprman *cprman = divider->cprman; in bcm2835_pll_divider_on() local
826 spin_lock(&cprman->regs_lock); in bcm2835_pll_divider_on()
827 cprman_write(cprman, data->a2w_reg, in bcm2835_pll_divider_on()
828 cprman_read(cprman, data->a2w_reg) & in bcm2835_pll_divider_on()
831 cprman_write(cprman, data->cm_reg, in bcm2835_pll_divider_on()
832 cprman_read(cprman, data->cm_reg) & ~data->hold_mask); in bcm2835_pll_divider_on()
833 spin_unlock(&cprman->regs_lock); in bcm2835_pll_divider_on()
843 struct bcm2835_cprman *cprman = divider->cprman; in bcm2835_pll_divider_set_rate() local
853 cprman_write(cprman, data->a2w_reg, div); in bcm2835_pll_divider_set_rate()
854 cm = cprman_read(cprman, data->cm_reg); in bcm2835_pll_divider_set_rate()
855 cprman_write(cprman, data->cm_reg, cm | data->load_mask); in bcm2835_pll_divider_set_rate()
856 cprman_write(cprman, data->cm_reg, cm & ~data->load_mask); in bcm2835_pll_divider_set_rate()
865 struct bcm2835_cprman *cprman = divider->cprman; in bcm2835_pll_divider_debug_init() local
869 regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL); in bcm2835_pll_divider_debug_init()
878 bcm2835_debugfs_regset(cprman, 0, regs, 2, dentry); in bcm2835_pll_divider_debug_init()
899 struct bcm2835_cprman *cprman; member
911 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_is_on() local
914 return (cprman_read(cprman, data->ctl_reg) & CM_ENABLE) != 0; in bcm2835_clock_is_on()
990 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_get_rate() local
997 div = cprman_read(cprman, data->div_reg); in bcm2835_clock_get_rate()
1004 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_wait_busy() local
1008 while (cprman_read(cprman, data->ctl_reg) & CM_BUSY) { in bcm2835_clock_wait_busy()
1010 dev_err(cprman->dev, "%s: couldn't lock PLL\n", in bcm2835_clock_wait_busy()
1021 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_off() local
1024 spin_lock(&cprman->regs_lock); in bcm2835_clock_off()
1025 cprman_write(cprman, data->ctl_reg, in bcm2835_clock_off()
1026 cprman_read(cprman, data->ctl_reg) & ~CM_ENABLE); in bcm2835_clock_off()
1027 spin_unlock(&cprman->regs_lock); in bcm2835_clock_off()
1036 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_on() local
1039 spin_lock(&cprman->regs_lock); in bcm2835_clock_on()
1040 cprman_write(cprman, data->ctl_reg, in bcm2835_clock_on()
1041 cprman_read(cprman, data->ctl_reg) | in bcm2835_clock_on()
1044 spin_unlock(&cprman->regs_lock); in bcm2835_clock_on()
1050 dev_info(cprman->dev, in bcm2835_clock_on()
1054 bcm2835_measure_tcnt_mux(cprman, data->tcnt_mux)); in bcm2835_clock_on()
1064 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_set_rate() local
1069 spin_lock(&cprman->regs_lock); in bcm2835_clock_set_rate()
1079 ctl = cprman_read(cprman, data->ctl_reg) & ~CM_FRAC; in bcm2835_clock_set_rate()
1081 cprman_write(cprman, data->ctl_reg, ctl); in bcm2835_clock_set_rate()
1083 cprman_write(cprman, data->div_reg, div); in bcm2835_clock_set_rate()
1085 spin_unlock(&cprman->regs_lock); in bcm2835_clock_set_rate()
1107 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_choose_div_and_prate() local
1141 dev_warn(cprman->dev, in bcm2835_clock_choose_div_and_prate()
1225 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_set_parent() local
1229 cprman_write(cprman, data->ctl_reg, src); in bcm2835_clock_set_parent()
1236 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_get_parent() local
1238 u32 src = cprman_read(cprman, data->ctl_reg); in bcm2835_clock_get_parent()
1258 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_debug_init() local
1261 bcm2835_debugfs_regset(cprman, data->ctl_reg, in bcm2835_clock_debug_init()
1298 static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman, in bcm2835_register_pll() argument
1308 init.parent_names = &cprman->real_parent_names[0]; in bcm2835_register_pll()
1318 pll->cprman = cprman; in bcm2835_register_pll()
1322 ret = devm_clk_hw_register(cprman->dev, &pll->hw); in bcm2835_register_pll()
1329 bcm2835_register_pll_divider(struct bcm2835_cprman *cprman, in bcm2835_register_pll_divider() argument
1338 divider_name = devm_kasprintf(cprman->dev, GFP_KERNEL, in bcm2835_register_pll_divider()
1354 divider = devm_kzalloc(cprman->dev, sizeof(*divider), GFP_KERNEL); in bcm2835_register_pll_divider()
1358 divider->div.reg = cprman->regs + data->a2w_reg; in bcm2835_register_pll_divider()
1362 divider->div.lock = &cprman->regs_lock; in bcm2835_register_pll_divider()
1366 divider->cprman = cprman; in bcm2835_register_pll_divider()
1369 ret = devm_clk_hw_register(cprman->dev, &divider->div.hw); in bcm2835_register_pll_divider()
1378 return clk_hw_register_fixed_factor(cprman->dev, data->name, in bcm2835_register_pll_divider()
1388 static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman, in bcm2835_register_clock() argument
1408 parents[i] = cprman->real_parent_names[ret]; in bcm2835_register_clock()
1433 if (!(cprman_read(cprman, data->ctl_reg) & CM_ENABLE)) in bcm2835_register_clock()
1437 clock = devm_kzalloc(cprman->dev, sizeof(*clock), GFP_KERNEL); in bcm2835_register_clock()
1441 clock->cprman = cprman; in bcm2835_register_clock()
1445 ret = devm_clk_hw_register(cprman->dev, &clock->hw); in bcm2835_register_clock()
1451 static struct clk *bcm2835_register_gate(struct bcm2835_cprman *cprman, in bcm2835_register_gate() argument
1454 return clk_register_gate(cprman->dev, data->name, data->parent, in bcm2835_register_gate()
1456 cprman->regs + data->ctl_reg, in bcm2835_register_gate()
1457 CM_GATE_BIT, 0, &cprman->regs_lock); in bcm2835_register_gate()
1460 typedef struct clk_hw *(*bcm2835_clk_register)(struct bcm2835_cprman *cprman,
2194 struct bcm2835_cprman *cprman; in bcm2835_clk_probe() local
2206 cprman = devm_kzalloc(dev, in bcm2835_clk_probe()
2207 struct_size(cprman, onecell.hws, asize), in bcm2835_clk_probe()
2209 if (!cprman) in bcm2835_clk_probe()
2212 spin_lock_init(&cprman->regs_lock); in bcm2835_clk_probe()
2213 cprman->dev = dev; in bcm2835_clk_probe()
2215 cprman->regs = devm_ioremap_resource(dev, res); in bcm2835_clk_probe()
2216 if (IS_ERR(cprman->regs)) in bcm2835_clk_probe()
2217 return PTR_ERR(cprman->regs); in bcm2835_clk_probe()
2219 memcpy(cprman->real_parent_names, cprman_parent_names, in bcm2835_clk_probe()
2221 of_clk_parent_fill(dev->of_node, cprman->real_parent_names, in bcm2835_clk_probe()
2231 if (!cprman->real_parent_names[0]) in bcm2835_clk_probe()
2234 platform_set_drvdata(pdev, cprman); in bcm2835_clk_probe()
2236 cprman->onecell.num = asize; in bcm2835_clk_probe()
2237 hws = cprman->onecell.hws; in bcm2835_clk_probe()
2243 hws[i] = desc->clk_register(cprman, desc->data); in bcm2835_clk_probe()
2252 &cprman->onecell); in bcm2835_clk_probe()