ccu                26 drivers/clk/bcm/clk-kona-setup.c static bool ccu_data_offsets_valid(struct ccu_data *ccu)
ccu                28 drivers/clk/bcm/clk-kona-setup.c 	struct ccu_policy *ccu_policy = &ccu->policy;
ccu                31 drivers/clk/bcm/clk-kona-setup.c 	limit = ccu->range - sizeof(u32);
ccu                37 drivers/clk/bcm/clk-kona-setup.c 				ccu->name, ccu_policy->enable.offset, limit);
ccu                43 drivers/clk/bcm/clk-kona-setup.c 				ccu->name, ccu_policy->control.offset, limit);
ccu                93 drivers/clk/bcm/clk-kona-setup.c 	range = bcm_clk->ccu->range;
ccu               747 drivers/clk/bcm/clk-kona-setup.c static void ccu_clks_teardown(struct ccu_data *ccu)
ccu               751 drivers/clk/bcm/clk-kona-setup.c 	for (i = 0; i < ccu->clk_num; i++)
ccu               752 drivers/clk/bcm/clk-kona-setup.c 		kona_clk_teardown(&ccu->kona_clks[i].hw);
ccu               755 drivers/clk/bcm/clk-kona-setup.c static void kona_ccu_teardown(struct ccu_data *ccu)
ccu               757 drivers/clk/bcm/clk-kona-setup.c 	if (!ccu->base)
ccu               760 drivers/clk/bcm/clk-kona-setup.c 	of_clk_del_provider(ccu->node);	/* safe if never added */
ccu               761 drivers/clk/bcm/clk-kona-setup.c 	ccu_clks_teardown(ccu);
ccu               762 drivers/clk/bcm/clk-kona-setup.c 	of_node_put(ccu->node);
ccu               763 drivers/clk/bcm/clk-kona-setup.c 	ccu->node = NULL;
ccu               764 drivers/clk/bcm/clk-kona-setup.c 	iounmap(ccu->base);
ccu               765 drivers/clk/bcm/clk-kona-setup.c 	ccu->base = NULL;
ccu               768 drivers/clk/bcm/clk-kona-setup.c static bool ccu_data_valid(struct ccu_data *ccu)
ccu               772 drivers/clk/bcm/clk-kona-setup.c 	if (!ccu_data_offsets_valid(ccu))
ccu               775 drivers/clk/bcm/clk-kona-setup.c 	ccu_policy = &ccu->policy;
ccu               777 drivers/clk/bcm/clk-kona-setup.c 		if (!ccu_policy_valid(ccu_policy, ccu->name))
ccu               786 drivers/clk/bcm/clk-kona-setup.c 	struct ccu_data *ccu = data;
ccu               789 drivers/clk/bcm/clk-kona-setup.c 	if (idx >= ccu->clk_num) {
ccu               794 drivers/clk/bcm/clk-kona-setup.c 	return &ccu->kona_clks[idx].hw;
ccu               801 drivers/clk/bcm/clk-kona-setup.c void __init kona_dt_ccu_setup(struct ccu_data *ccu,
ccu               823 drivers/clk/bcm/clk-kona-setup.c 	ccu->range = (u32)range;
ccu               825 drivers/clk/bcm/clk-kona-setup.c 	if (!ccu_data_valid(ccu)) {
ccu               830 drivers/clk/bcm/clk-kona-setup.c 	ccu->base = ioremap(res.start, ccu->range);
ccu               831 drivers/clk/bcm/clk-kona-setup.c 	if (!ccu->base) {
ccu               836 drivers/clk/bcm/clk-kona-setup.c 	ccu->node = of_node_get(node);
ccu               843 drivers/clk/bcm/clk-kona-setup.c 	for (i = 0; i < ccu->clk_num; i++) {
ccu               844 drivers/clk/bcm/clk-kona-setup.c 		if (!ccu->kona_clks[i].ccu)
ccu               846 drivers/clk/bcm/clk-kona-setup.c 		kona_clk_setup(&ccu->kona_clks[i]);
ccu               849 drivers/clk/bcm/clk-kona-setup.c 	ret = of_clk_add_hw_provider(node, of_clk_kona_onecell_get, ccu);
ccu               856 drivers/clk/bcm/clk-kona-setup.c 	if (!kona_ccu_init(ccu))
ccu               861 drivers/clk/bcm/clk-kona-setup.c 	kona_ccu_teardown(ccu);
ccu               130 drivers/clk/bcm/clk-kona.c static inline u32 __ccu_read(struct ccu_data *ccu, u32 reg_offset)
ccu               132 drivers/clk/bcm/clk-kona.c 	return readl(ccu->base + reg_offset);
ccu               137 drivers/clk/bcm/clk-kona.c __ccu_write(struct ccu_data *ccu, u32 reg_offset, u32 reg_val)
ccu               139 drivers/clk/bcm/clk-kona.c 	writel(reg_val, ccu->base + reg_offset);
ccu               142 drivers/clk/bcm/clk-kona.c static inline unsigned long ccu_lock(struct ccu_data *ccu)
ccu               146 drivers/clk/bcm/clk-kona.c 	spin_lock_irqsave(&ccu->lock, flags);
ccu               150 drivers/clk/bcm/clk-kona.c static inline void ccu_unlock(struct ccu_data *ccu, unsigned long flags)
ccu               152 drivers/clk/bcm/clk-kona.c 	spin_unlock_irqrestore(&ccu->lock, flags);
ccu               159 drivers/clk/bcm/clk-kona.c static inline void __ccu_write_enable(struct ccu_data *ccu)
ccu               161 drivers/clk/bcm/clk-kona.c 	if (ccu->write_enabled) {
ccu               163 drivers/clk/bcm/clk-kona.c 			ccu->name);
ccu               166 drivers/clk/bcm/clk-kona.c 	ccu->write_enabled = true;
ccu               167 drivers/clk/bcm/clk-kona.c 	__ccu_write(ccu, 0, CCU_ACCESS_PASSWORD | 1);
ccu               170 drivers/clk/bcm/clk-kona.c static inline void __ccu_write_disable(struct ccu_data *ccu)
ccu               172 drivers/clk/bcm/clk-kona.c 	if (!ccu->write_enabled) {
ccu               174 drivers/clk/bcm/clk-kona.c 			ccu->name);
ccu               178 drivers/clk/bcm/clk-kona.c 	__ccu_write(ccu, 0, CCU_ACCESS_PASSWORD);
ccu               179 drivers/clk/bcm/clk-kona.c 	ccu->write_enabled = false;
ccu               191 drivers/clk/bcm/clk-kona.c __ccu_wait_bit(struct ccu_data *ccu, u32 reg_offset, u32 bit, bool want)
ccu               200 drivers/clk/bcm/clk-kona.c 		val = __ccu_read(ccu, reg_offset);
ccu               207 drivers/clk/bcm/clk-kona.c 		ccu->name, reg_offset, bit, want ? "set" : "clear");
ccu               214 drivers/clk/bcm/clk-kona.c static bool __ccu_policy_engine_start(struct ccu_data *ccu, bool sync)
ccu               216 drivers/clk/bcm/clk-kona.c 	struct bcm_policy_ctl *control = &ccu->policy.control;
ccu               230 drivers/clk/bcm/clk-kona.c 	ret = __ccu_wait_bit(ccu, offset, go_bit, false);
ccu               233 drivers/clk/bcm/clk-kona.c 			__func__, ccu->name);
ccu               257 drivers/clk/bcm/clk-kona.c 	__ccu_write(ccu, offset, mask);
ccu               260 drivers/clk/bcm/clk-kona.c 	ret = __ccu_wait_bit(ccu, offset, go_bit, false);
ccu               263 drivers/clk/bcm/clk-kona.c 			__func__, ccu->name);
ccu               268 drivers/clk/bcm/clk-kona.c static bool __ccu_policy_engine_stop(struct ccu_data *ccu)
ccu               270 drivers/clk/bcm/clk-kona.c 	struct bcm_lvm_en *enable = &ccu->policy.enable;
ccu               282 drivers/clk/bcm/clk-kona.c 	ret = __ccu_wait_bit(ccu, offset, enable_bit, false);
ccu               285 drivers/clk/bcm/clk-kona.c 			__func__, ccu->name);
ccu               290 drivers/clk/bcm/clk-kona.c 	__ccu_write(ccu, offset, (u32)1 << enable_bit);
ccu               293 drivers/clk/bcm/clk-kona.c 	ret = __ccu_wait_bit(ccu, offset, enable_bit, false);
ccu               296 drivers/clk/bcm/clk-kona.c 			__func__, ccu->name);
ccu               310 drivers/clk/bcm/clk-kona.c static bool policy_init(struct ccu_data *ccu, struct bcm_clk_policy *policy)
ccu               324 drivers/clk/bcm/clk-kona.c 	if (!__ccu_policy_engine_stop(ccu)) {
ccu               326 drivers/clk/bcm/clk-kona.c 			__func__, ccu->name);
ccu               339 drivers/clk/bcm/clk-kona.c 		reg_val = __ccu_read(ccu, offset);
ccu               341 drivers/clk/bcm/clk-kona.c 		__ccu_write(ccu, offset, reg_val);
ccu               346 drivers/clk/bcm/clk-kona.c 	ret = __ccu_policy_engine_start(ccu, true);
ccu               349 drivers/clk/bcm/clk-kona.c 			__func__, ccu->name);
ccu               358 drivers/clk/bcm/clk-kona.c __is_clk_gate_enabled(struct ccu_data *ccu, struct bcm_clk_gate *gate)
ccu               368 drivers/clk/bcm/clk-kona.c 	reg_val = __ccu_read(ccu, gate->offset);
ccu               375 drivers/clk/bcm/clk-kona.c is_clk_gate_enabled(struct ccu_data *ccu, struct bcm_clk_gate *gate)
ccu               384 drivers/clk/bcm/clk-kona.c 	flags = ccu_lock(ccu);
ccu               385 drivers/clk/bcm/clk-kona.c 	ret = __is_clk_gate_enabled(ccu, gate);
ccu               386 drivers/clk/bcm/clk-kona.c 	ccu_unlock(ccu, flags);
ccu               396 drivers/clk/bcm/clk-kona.c __gate_commit(struct ccu_data *ccu, struct bcm_clk_gate *gate)
ccu               406 drivers/clk/bcm/clk-kona.c 	reg_val = __ccu_read(ccu, gate->offset);
ccu               431 drivers/clk/bcm/clk-kona.c 	__ccu_write(ccu, gate->offset, reg_val);
ccu               438 drivers/clk/bcm/clk-kona.c 	return __ccu_wait_bit(ccu, gate->offset, gate->status_bit, enabled);
ccu               447 drivers/clk/bcm/clk-kona.c static bool gate_init(struct ccu_data *ccu, struct bcm_clk_gate *gate)
ccu               451 drivers/clk/bcm/clk-kona.c 	return __gate_commit(ccu, gate);
ccu               461 drivers/clk/bcm/clk-kona.c __clk_gate(struct ccu_data *ccu, struct bcm_clk_gate *gate, bool enable)
ccu               478 drivers/clk/bcm/clk-kona.c 	ret = __gate_commit(ccu, gate);
ccu               486 drivers/clk/bcm/clk-kona.c static int clk_gate(struct ccu_data *ccu, const char *name,
ccu               501 drivers/clk/bcm/clk-kona.c 	flags = ccu_lock(ccu);
ccu               502 drivers/clk/bcm/clk-kona.c 	__ccu_write_enable(ccu);
ccu               504 drivers/clk/bcm/clk-kona.c 	success = __clk_gate(ccu, gate, enable);
ccu               506 drivers/clk/bcm/clk-kona.c 	__ccu_write_disable(ccu);
ccu               507 drivers/clk/bcm/clk-kona.c 	ccu_unlock(ccu, flags);
ccu               527 drivers/clk/bcm/clk-kona.c static bool hyst_init(struct ccu_data *ccu, struct bcm_clk_hyst *hyst)
ccu               540 drivers/clk/bcm/clk-kona.c 	reg_val = __ccu_read(ccu, offset);
ccu               542 drivers/clk/bcm/clk-kona.c 	__ccu_write(ccu, offset, reg_val);
ccu               553 drivers/clk/bcm/clk-kona.c static bool __clk_trigger(struct ccu_data *ccu, struct bcm_clk_trig *trig)
ccu               556 drivers/clk/bcm/clk-kona.c 	__ccu_write(ccu, trig->offset, 1 << trig->bit);
ccu               558 drivers/clk/bcm/clk-kona.c 	return __ccu_wait_bit(ccu, trig->offset, trig->bit, false);
ccu               564 drivers/clk/bcm/clk-kona.c static u64 divider_read_scaled(struct ccu_data *ccu, struct bcm_clk_div *div)
ccu               573 drivers/clk/bcm/clk-kona.c 	flags = ccu_lock(ccu);
ccu               574 drivers/clk/bcm/clk-kona.c 	reg_val = __ccu_read(ccu, div->u.s.offset);
ccu               575 drivers/clk/bcm/clk-kona.c 	ccu_unlock(ccu, flags);
ccu               591 drivers/clk/bcm/clk-kona.c static int __div_commit(struct ccu_data *ccu, struct bcm_clk_gate *gate,
ccu               607 drivers/clk/bcm/clk-kona.c 		reg_val = __ccu_read(ccu, div->u.s.offset);
ccu               619 drivers/clk/bcm/clk-kona.c 	enabled = __is_clk_gate_enabled(ccu, gate);
ccu               620 drivers/clk/bcm/clk-kona.c 	if (!enabled && !__clk_gate(ccu, gate, true)) {
ccu               626 drivers/clk/bcm/clk-kona.c 	reg_val = __ccu_read(ccu, div->u.s.offset);
ccu               629 drivers/clk/bcm/clk-kona.c 	__ccu_write(ccu, div->u.s.offset, reg_val);
ccu               632 drivers/clk/bcm/clk-kona.c 	if (!__clk_trigger(ccu, trig))
ccu               636 drivers/clk/bcm/clk-kona.c 	if (!enabled && !__clk_gate(ccu, gate, false))
ccu               647 drivers/clk/bcm/clk-kona.c static bool div_init(struct ccu_data *ccu, struct bcm_clk_gate *gate,
ccu               652 drivers/clk/bcm/clk-kona.c 	return !__div_commit(ccu, gate, div, trig);
ccu               655 drivers/clk/bcm/clk-kona.c static int divider_write(struct ccu_data *ccu, struct bcm_clk_gate *gate,
ccu               671 drivers/clk/bcm/clk-kona.c 	flags = ccu_lock(ccu);
ccu               672 drivers/clk/bcm/clk-kona.c 	__ccu_write_enable(ccu);
ccu               674 drivers/clk/bcm/clk-kona.c 	ret = __div_commit(ccu, gate, div, trig);
ccu               676 drivers/clk/bcm/clk-kona.c 	__ccu_write_disable(ccu);
ccu               677 drivers/clk/bcm/clk-kona.c 	ccu_unlock(ccu, flags);
ccu               693 drivers/clk/bcm/clk-kona.c static unsigned long clk_recalc_rate(struct ccu_data *ccu,
ccu               721 drivers/clk/bcm/clk-kona.c 		scaled_div = divider_read_scaled(ccu, pre_div);
ccu               733 drivers/clk/bcm/clk-kona.c 	scaled_div = divider_read_scaled(ccu, div);
ccu               748 drivers/clk/bcm/clk-kona.c static long round_rate(struct ccu_data *ccu, struct bcm_clk_div *div,
ccu               780 drivers/clk/bcm/clk-kona.c 		scaled_pre_div = divider_read_scaled(ccu, pre_div);
ccu               802 drivers/clk/bcm/clk-kona.c 		best_scaled_div = divider_read_scaled(ccu, div);
ccu               840 drivers/clk/bcm/clk-kona.c static u8 selector_read_index(struct ccu_data *ccu, struct bcm_clk_sel *sel)
ccu               852 drivers/clk/bcm/clk-kona.c 	flags = ccu_lock(ccu);
ccu               853 drivers/clk/bcm/clk-kona.c 	reg_val = __ccu_read(ccu, sel->offset);
ccu               854 drivers/clk/bcm/clk-kona.c 	ccu_unlock(ccu, flags);
ccu               862 drivers/clk/bcm/clk-kona.c 			__func__, parent_sel, ccu->name, sel->offset);
ccu               874 drivers/clk/bcm/clk-kona.c __sel_commit(struct ccu_data *ccu, struct bcm_clk_gate *gate,
ccu               892 drivers/clk/bcm/clk-kona.c 		reg_val = __ccu_read(ccu, sel->offset);
ccu               906 drivers/clk/bcm/clk-kona.c 	enabled = __is_clk_gate_enabled(ccu, gate);
ccu               907 drivers/clk/bcm/clk-kona.c 	if (!enabled && !__clk_gate(ccu, gate, true))
ccu               911 drivers/clk/bcm/clk-kona.c 	reg_val = __ccu_read(ccu, sel->offset);
ccu               913 drivers/clk/bcm/clk-kona.c 	__ccu_write(ccu, sel->offset, reg_val);
ccu               916 drivers/clk/bcm/clk-kona.c 	if (!__clk_trigger(ccu, trig))
ccu               920 drivers/clk/bcm/clk-kona.c 	if (!enabled && !__clk_gate(ccu, gate, false))
ccu               931 drivers/clk/bcm/clk-kona.c static bool sel_init(struct ccu_data *ccu, struct bcm_clk_gate *gate,
ccu               936 drivers/clk/bcm/clk-kona.c 	return !__sel_commit(ccu, gate, sel, trig);
ccu               944 drivers/clk/bcm/clk-kona.c static int selector_write(struct ccu_data *ccu, struct bcm_clk_gate *gate,
ccu               958 drivers/clk/bcm/clk-kona.c 	flags = ccu_lock(ccu);
ccu               959 drivers/clk/bcm/clk-kona.c 	__ccu_write_enable(ccu);
ccu               961 drivers/clk/bcm/clk-kona.c 	ret = __sel_commit(ccu, gate, sel, trig);
ccu               963 drivers/clk/bcm/clk-kona.c 	__ccu_write_disable(ccu);
ccu               964 drivers/clk/bcm/clk-kona.c 	ccu_unlock(ccu, flags);
ccu               979 drivers/clk/bcm/clk-kona.c 	return clk_gate(bcm_clk->ccu, bcm_clk->init_data.name, gate, true);
ccu               987 drivers/clk/bcm/clk-kona.c 	(void)clk_gate(bcm_clk->ccu, bcm_clk->init_data.name, gate, false);
ccu               995 drivers/clk/bcm/clk-kona.c 	return is_clk_gate_enabled(bcm_clk->ccu, gate) ? 1 : 0;
ccu              1004 drivers/clk/bcm/clk-kona.c 	return clk_recalc_rate(bcm_clk->ccu, &data->div, &data->pre_div,
ccu              1018 drivers/clk/bcm/clk-kona.c 	return round_rate(bcm_clk->ccu, div, &bcm_clk->u.peri->pre_div,
ccu              1104 drivers/clk/bcm/clk-kona.c 	ret = selector_write(bcm_clk->ccu, &data->gate, sel, trig, index);
ccu              1124 drivers/clk/bcm/clk-kona.c 	index = selector_read_index(bcm_clk->ccu, &data->sel);
ccu              1161 drivers/clk/bcm/clk-kona.c 	(void)round_rate(bcm_clk->ccu, div, &data->pre_div,
ccu              1168 drivers/clk/bcm/clk-kona.c 	ret = divider_write(bcm_clk->ccu, &data->gate, &data->div,
ccu              1196 drivers/clk/bcm/clk-kona.c 	struct ccu_data *ccu = bcm_clk->ccu;
ccu              1203 drivers/clk/bcm/clk-kona.c 	if (!policy_init(ccu, &peri->policy)) {
ccu              1208 drivers/clk/bcm/clk-kona.c 	if (!gate_init(ccu, &peri->gate)) {
ccu              1212 drivers/clk/bcm/clk-kona.c 	if (!hyst_init(ccu, &peri->hyst)) {
ccu              1216 drivers/clk/bcm/clk-kona.c 	if (!div_init(ccu, &peri->gate, &peri->div, &peri->trig)) {
ccu              1229 drivers/clk/bcm/clk-kona.c 	if (!div_init(ccu, &peri->gate, &peri->pre_div, trig)) {
ccu              1235 drivers/clk/bcm/clk-kona.c 	if (!sel_init(ccu, &peri->gate, &peri->sel, trig)) {
ccu              1256 drivers/clk/bcm/clk-kona.c bool __init kona_ccu_init(struct ccu_data *ccu)
ccu              1260 drivers/clk/bcm/clk-kona.c 	struct kona_clk *kona_clks = ccu->kona_clks;
ccu              1263 drivers/clk/bcm/clk-kona.c 	flags = ccu_lock(ccu);
ccu              1264 drivers/clk/bcm/clk-kona.c 	__ccu_write_enable(ccu);
ccu              1266 drivers/clk/bcm/clk-kona.c 	for (which = 0; which < ccu->clk_num; which++) {
ccu              1269 drivers/clk/bcm/clk-kona.c 		if (!bcm_clk->ccu)
ccu              1275 drivers/clk/bcm/clk-kona.c 	__ccu_write_disable(ccu);
ccu              1276 drivers/clk/bcm/clk-kona.c 	ccu_unlock(ccu, flags);
ccu               407 drivers/clk/bcm/clk-kona.h 	struct ccu_data *ccu;	/* ccu this clock is associated with */
ccu               424 drivers/clk/bcm/clk-kona.h 		.ccu		= &_ccu_name ## _ccu_data,		\
ccu               506 drivers/clk/bcm/clk-kona.h extern void __init kona_dt_ccu_setup(struct ccu_data *ccu,
ccu               508 drivers/clk/bcm/clk-kona.h extern bool __init kona_ccu_init(struct ccu_data *ccu);
ccu                16 drivers/clk/sunxi-ng/ccu_reset.c 	struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
ccu                17 drivers/clk/sunxi-ng/ccu_reset.c 	const struct ccu_reset_map *map = &ccu->reset_map[id];
ccu                21 drivers/clk/sunxi-ng/ccu_reset.c 	spin_lock_irqsave(ccu->lock, flags);
ccu                23 drivers/clk/sunxi-ng/ccu_reset.c 	reg = readl(ccu->base + map->reg);
ccu                24 drivers/clk/sunxi-ng/ccu_reset.c 	writel(reg & ~map->bit, ccu->base + map->reg);
ccu                26 drivers/clk/sunxi-ng/ccu_reset.c 	spin_unlock_irqrestore(ccu->lock, flags);
ccu                34 drivers/clk/sunxi-ng/ccu_reset.c 	struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
ccu                35 drivers/clk/sunxi-ng/ccu_reset.c 	const struct ccu_reset_map *map = &ccu->reset_map[id];
ccu                39 drivers/clk/sunxi-ng/ccu_reset.c 	spin_lock_irqsave(ccu->lock, flags);
ccu                41 drivers/clk/sunxi-ng/ccu_reset.c 	reg = readl(ccu->base + map->reg);
ccu                42 drivers/clk/sunxi-ng/ccu_reset.c 	writel(reg | map->bit, ccu->base + map->reg);
ccu                44 drivers/clk/sunxi-ng/ccu_reset.c 	spin_unlock_irqrestore(ccu->lock, flags);
ccu                62 drivers/clk/sunxi-ng/ccu_reset.c 	struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
ccu                63 drivers/clk/sunxi-ng/ccu_reset.c 	const struct ccu_reset_map *map = &ccu->reset_map[id];
ccu                69 drivers/clk/sunxi-ng/ccu_reset.c 	return !(map->bit & readl(ccu->base + map->reg));