Lines Matching refs:cprman
335 static inline void cprman_write(struct bcm2835_cprman *cprman, u32 reg, u32 val) in cprman_write() argument
337 writel(CM_PASSWORD | val, cprman->regs + reg); in cprman_write()
340 static inline u32 cprman_read(struct bcm2835_cprman *cprman, u32 reg) in cprman_read() argument
342 return readl(cprman->regs + reg); in cprman_read()
348 static unsigned long bcm2835_measure_tcnt_mux(struct bcm2835_cprman *cprman, in bcm2835_measure_tcnt_mux() argument
355 spin_lock(&cprman->regs_lock); in bcm2835_measure_tcnt_mux()
357 cprman_write(cprman, CM_TCNTCTL, CM_KILL); in bcm2835_measure_tcnt_mux()
359 cprman_write(cprman, CM_TCNTCTL, in bcm2835_measure_tcnt_mux()
363 cprman_write(cprman, CM_OSCCOUNT, osccount); in bcm2835_measure_tcnt_mux()
370 while (cprman_read(cprman, CM_OSCCOUNT)) { in bcm2835_measure_tcnt_mux()
372 dev_err(cprman->dev, "timeout waiting for OSCCOUNT\n"); in bcm2835_measure_tcnt_mux()
381 while (cprman_read(cprman, CM_TCNTCTL) & CM_BUSY) { in bcm2835_measure_tcnt_mux()
383 dev_err(cprman->dev, "timeout waiting for !BUSY\n"); in bcm2835_measure_tcnt_mux()
390 count = cprman_read(cprman, CM_TCNTCNT); in bcm2835_measure_tcnt_mux()
392 cprman_write(cprman, CM_TCNTCTL, 0); in bcm2835_measure_tcnt_mux()
395 spin_unlock(&cprman->regs_lock); in bcm2835_measure_tcnt_mux()
400 static void bcm2835_debugfs_regset(struct bcm2835_cprman *cprman, u32 base, in bcm2835_debugfs_regset() argument
406 regset = devm_kzalloc(cprman->dev, sizeof(*regset), GFP_KERNEL); in bcm2835_debugfs_regset()
412 regset->base = cprman->regs + base; in bcm2835_debugfs_regset()
519 struct bcm2835_cprman *cprman; member
526 struct bcm2835_cprman *cprman = pll->cprman; in bcm2835_pll_is_on() local
529 return cprman_read(cprman, data->a2w_ctrl_reg) & in bcm2835_pll_is_on()
533 static u32 bcm2835_pll_get_prediv_mask(struct bcm2835_cprman *cprman, in bcm2835_pll_get_prediv_mask() argument
541 if (cprman->soc & SOC_BCM2711) in bcm2835_pll_get_prediv_mask()
591 struct bcm2835_cprman *cprman = pll->cprman; in bcm2835_pll_get_rate() local
593 u32 a2wctrl = cprman_read(cprman, data->a2w_ctrl_reg); in bcm2835_pll_get_rate()
600 fdiv = cprman_read(cprman, data->frac_reg) & A2W_PLL_FRAC_MASK; in bcm2835_pll_get_rate()
603 using_prediv = cprman_read(cprman, data->ana_reg_base + 4) & in bcm2835_pll_get_rate()
604 bcm2835_pll_get_prediv_mask(cprman, data); in bcm2835_pll_get_rate()
617 struct bcm2835_cprman *cprman = pll->cprman; in bcm2835_pll_off() local
620 spin_lock(&cprman->regs_lock); in bcm2835_pll_off()
621 cprman_write(cprman, data->cm_ctrl_reg, CM_PLL_ANARST); in bcm2835_pll_off()
622 cprman_write(cprman, data->a2w_ctrl_reg, in bcm2835_pll_off()
623 cprman_read(cprman, data->a2w_ctrl_reg) | in bcm2835_pll_off()
625 spin_unlock(&cprman->regs_lock); in bcm2835_pll_off()
631 struct bcm2835_cprman *cprman = pll->cprman; in bcm2835_pll_on() local
635 cprman_write(cprman, data->a2w_ctrl_reg, in bcm2835_pll_on()
636 cprman_read(cprman, data->a2w_ctrl_reg) & in bcm2835_pll_on()
640 spin_lock(&cprman->regs_lock); in bcm2835_pll_on()
641 cprman_write(cprman, data->cm_ctrl_reg, in bcm2835_pll_on()
642 cprman_read(cprman, data->cm_ctrl_reg) & ~CM_PLL_ANARST); in bcm2835_pll_on()
643 spin_unlock(&cprman->regs_lock); in bcm2835_pll_on()
647 while (!(cprman_read(cprman, CM_LOCK) & data->lock_mask)) { in bcm2835_pll_on()
649 dev_err(cprman->dev, "%s: couldn't lock PLL\n", in bcm2835_pll_on()
657 cprman_write(cprman, data->a2w_ctrl_reg, in bcm2835_pll_on()
658 cprman_read(cprman, data->a2w_ctrl_reg) | in bcm2835_pll_on()
665 bcm2835_pll_write_ana(struct bcm2835_cprman *cprman, u32 ana_reg_base, u32 *ana) in bcm2835_pll_write_ana() argument
678 cprman_write(cprman, ana_reg_base + i * 4, ana[i]); in bcm2835_pll_write_ana()
685 struct bcm2835_cprman *cprman = pll->cprman; in bcm2835_pll_set_rate() local
687 u32 prediv_mask = bcm2835_pll_get_prediv_mask(cprman, data); in bcm2835_pll_set_rate()
703 ana[i] = cprman_read(cprman, data->ana_reg_base + i * 4); in bcm2835_pll_set_rate()
725 spin_lock(&cprman->regs_lock); in bcm2835_pll_set_rate()
726 cprman_write(cprman, A2W_XOSC_CTRL, in bcm2835_pll_set_rate()
727 cprman_read(cprman, A2W_XOSC_CTRL) | in bcm2835_pll_set_rate()
729 spin_unlock(&cprman->regs_lock); in bcm2835_pll_set_rate()
732 bcm2835_pll_write_ana(cprman, data->ana_reg_base, ana); in bcm2835_pll_set_rate()
735 cprman_write(cprman, data->frac_reg, fdiv); in bcm2835_pll_set_rate()
737 a2w_ctl = cprman_read(cprman, data->a2w_ctrl_reg); in bcm2835_pll_set_rate()
742 cprman_write(cprman, data->a2w_ctrl_reg, a2w_ctl); in bcm2835_pll_set_rate()
745 bcm2835_pll_write_ana(cprman, data->ana_reg_base, ana); in bcm2835_pll_set_rate()
754 struct bcm2835_cprman *cprman = pll->cprman; in bcm2835_pll_debug_init() local
758 regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL); in bcm2835_pll_debug_init()
777 bcm2835_debugfs_regset(cprman, 0, regs, 7, dentry); in bcm2835_pll_debug_init()
792 struct bcm2835_cprman *cprman; member
805 struct bcm2835_cprman *cprman = divider->cprman; in bcm2835_pll_divider_is_on() local
808 return !(cprman_read(cprman, data->a2w_reg) & A2W_PLL_CHANNEL_DISABLE); in bcm2835_pll_divider_is_on()
826 struct bcm2835_cprman *cprman = divider->cprman; in bcm2835_pll_divider_off() local
829 spin_lock(&cprman->regs_lock); in bcm2835_pll_divider_off()
830 cprman_write(cprman, data->cm_reg, in bcm2835_pll_divider_off()
831 (cprman_read(cprman, data->cm_reg) & in bcm2835_pll_divider_off()
833 cprman_write(cprman, data->a2w_reg, in bcm2835_pll_divider_off()
834 cprman_read(cprman, data->a2w_reg) | in bcm2835_pll_divider_off()
836 spin_unlock(&cprman->regs_lock); in bcm2835_pll_divider_off()
842 struct bcm2835_cprman *cprman = divider->cprman; in bcm2835_pll_divider_on() local
845 spin_lock(&cprman->regs_lock); in bcm2835_pll_divider_on()
846 cprman_write(cprman, data->a2w_reg, in bcm2835_pll_divider_on()
847 cprman_read(cprman, data->a2w_reg) & in bcm2835_pll_divider_on()
850 cprman_write(cprman, data->cm_reg, in bcm2835_pll_divider_on()
851 cprman_read(cprman, data->cm_reg) & ~data->hold_mask); in bcm2835_pll_divider_on()
852 spin_unlock(&cprman->regs_lock); in bcm2835_pll_divider_on()
862 struct bcm2835_cprman *cprman = divider->cprman; in bcm2835_pll_divider_set_rate() local
872 cprman_write(cprman, data->a2w_reg, div); in bcm2835_pll_divider_set_rate()
873 cm = cprman_read(cprman, data->cm_reg); in bcm2835_pll_divider_set_rate()
874 cprman_write(cprman, data->cm_reg, cm | data->load_mask); in bcm2835_pll_divider_set_rate()
875 cprman_write(cprman, data->cm_reg, cm & ~data->load_mask); in bcm2835_pll_divider_set_rate()
884 struct bcm2835_cprman *cprman = divider->cprman; in bcm2835_pll_divider_debug_init() local
888 regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL); in bcm2835_pll_divider_debug_init()
897 bcm2835_debugfs_regset(cprman, 0, regs, 2, dentry); in bcm2835_pll_divider_debug_init()
918 struct bcm2835_cprman *cprman; member
930 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_is_on() local
933 return (cprman_read(cprman, data->ctl_reg) & CM_ENABLE) != 0; in bcm2835_clock_is_on()
1024 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_get_rate() local
1032 div = cprman_read(cprman, data->div_reg); in bcm2835_clock_get_rate()
1044 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_wait_busy() local
1048 while (cprman_read(cprman, data->ctl_reg) & CM_BUSY) { in bcm2835_clock_wait_busy()
1050 dev_err(cprman->dev, "%s: couldn't lock PLL\n", in bcm2835_clock_wait_busy()
1061 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_off() local
1064 spin_lock(&cprman->regs_lock); in bcm2835_clock_off()
1065 cprman_write(cprman, data->ctl_reg, in bcm2835_clock_off()
1066 cprman_read(cprman, data->ctl_reg) & ~CM_ENABLE); in bcm2835_clock_off()
1067 spin_unlock(&cprman->regs_lock); in bcm2835_clock_off()
1076 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_on() local
1079 spin_lock(&cprman->regs_lock); in bcm2835_clock_on()
1080 cprman_write(cprman, data->ctl_reg, in bcm2835_clock_on()
1081 cprman_read(cprman, data->ctl_reg) | in bcm2835_clock_on()
1084 spin_unlock(&cprman->regs_lock); in bcm2835_clock_on()
1090 dev_info(cprman->dev, in bcm2835_clock_on()
1094 bcm2835_measure_tcnt_mux(cprman, data->tcnt_mux)); in bcm2835_clock_on()
1104 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_set_rate() local
1109 spin_lock(&cprman->regs_lock); in bcm2835_clock_set_rate()
1119 ctl = cprman_read(cprman, data->ctl_reg) & ~CM_FRAC; in bcm2835_clock_set_rate()
1121 cprman_write(cprman, data->ctl_reg, ctl); in bcm2835_clock_set_rate()
1123 cprman_write(cprman, data->div_reg, div); in bcm2835_clock_set_rate()
1125 spin_unlock(&cprman->regs_lock); in bcm2835_clock_set_rate()
1147 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_choose_div_and_prate() local
1181 dev_warn(cprman->dev, in bcm2835_clock_choose_div_and_prate()
1265 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_set_parent() local
1269 cprman_write(cprman, data->ctl_reg, src); in bcm2835_clock_set_parent()
1276 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_get_parent() local
1278 u32 src = cprman_read(cprman, data->ctl_reg); in bcm2835_clock_get_parent()
1298 struct bcm2835_cprman *cprman = clock->cprman; in bcm2835_clock_debug_init() local
1301 bcm2835_debugfs_regset(cprman, data->ctl_reg, in bcm2835_clock_debug_init()
1338 static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman, in bcm2835_register_pll() argument
1349 init.parent_names = &cprman->real_parent_names[0]; in bcm2835_register_pll()
1359 pll->cprman = cprman; in bcm2835_register_pll()
1363 ret = devm_clk_hw_register(cprman->dev, &pll->hw); in bcm2835_register_pll()
1372 bcm2835_register_pll_divider(struct bcm2835_cprman *cprman, in bcm2835_register_pll_divider() argument
1382 divider_name = devm_kasprintf(cprman->dev, GFP_KERNEL, in bcm2835_register_pll_divider()
1398 divider = devm_kzalloc(cprman->dev, sizeof(*divider), GFP_KERNEL); in bcm2835_register_pll_divider()
1402 divider->div.reg = cprman->regs + divider_data->a2w_reg; in bcm2835_register_pll_divider()
1406 divider->div.lock = &cprman->regs_lock; in bcm2835_register_pll_divider()
1410 divider->cprman = cprman; in bcm2835_register_pll_divider()
1413 ret = devm_clk_hw_register(cprman->dev, ÷r->div.hw); in bcm2835_register_pll_divider()
1422 return clk_hw_register_fixed_factor(cprman->dev, in bcm2835_register_pll_divider()
1433 static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman, in bcm2835_register_clock() argument
1454 parents[i] = cprman->real_parent_names[ret]; in bcm2835_register_clock()
1479 if (!(cprman_read(cprman, clock_data->ctl_reg) & CM_ENABLE)) in bcm2835_register_clock()
1483 clock = devm_kzalloc(cprman->dev, sizeof(*clock), GFP_KERNEL); in bcm2835_register_clock()
1487 clock->cprman = cprman; in bcm2835_register_clock()
1491 ret = devm_clk_hw_register(cprman->dev, &clock->hw); in bcm2835_register_clock()
1497 static struct clk_hw *bcm2835_register_gate(struct bcm2835_cprman *cprman, in bcm2835_register_gate() argument
1502 return clk_hw_register_gate(cprman->dev, gate_data->name, in bcm2835_register_gate()
1505 cprman->regs + gate_data->ctl_reg, in bcm2835_register_gate()
1506 CM_GATE_BIT, 0, &cprman->regs_lock); in bcm2835_register_gate()
1510 struct clk_hw *(*clk_register)(struct bcm2835_cprman *cprman,
2266 struct bcm2835_cprman *cprman; in bcm2835_clk_probe() local
2277 cprman = devm_kzalloc(dev, in bcm2835_clk_probe()
2278 struct_size(cprman, onecell.hws, asize), in bcm2835_clk_probe()
2280 if (!cprman) in bcm2835_clk_probe()
2283 spin_lock_init(&cprman->regs_lock); in bcm2835_clk_probe()
2284 cprman->dev = dev; in bcm2835_clk_probe()
2285 cprman->regs = devm_platform_ioremap_resource(pdev, 0); in bcm2835_clk_probe()
2286 if (IS_ERR(cprman->regs)) in bcm2835_clk_probe()
2287 return PTR_ERR(cprman->regs); in bcm2835_clk_probe()
2289 memcpy(cprman->real_parent_names, cprman_parent_names, in bcm2835_clk_probe()
2291 of_clk_parent_fill(dev->of_node, cprman->real_parent_names, in bcm2835_clk_probe()
2301 if (!cprman->real_parent_names[0]) in bcm2835_clk_probe()
2304 platform_set_drvdata(pdev, cprman); in bcm2835_clk_probe()
2306 cprman->onecell.num = asize; in bcm2835_clk_probe()
2307 cprman->soc = pdata->soc; in bcm2835_clk_probe()
2308 hws = cprman->onecell.hws; in bcm2835_clk_probe()
2314 hws[i] = desc->clk_register(cprman, desc->data); in bcm2835_clk_probe()
2323 &cprman->onecell); in bcm2835_clk_probe()