18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright (c) 2013, The Linux Foundation. All rights reserved. */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef __QCOM_CLK_BRANCH_H__
58c2ecf20Sopenharmony_ci#define __QCOM_CLK_BRANCH_H__
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include "clk-regmap.h"
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/**
128c2ecf20Sopenharmony_ci * struct clk_branch - gating clock with status bit and dynamic hardware gating
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * @hwcg_reg: dynamic hardware clock gating register
158c2ecf20Sopenharmony_ci * @hwcg_bit: ORed with @hwcg_reg to enable dynamic hardware clock gating
168c2ecf20Sopenharmony_ci * @halt_reg: halt register
178c2ecf20Sopenharmony_ci * @halt_bit: ANDed with @halt_reg to test for clock halted
188c2ecf20Sopenharmony_ci * @halt_check: type of halt checking to perform
198c2ecf20Sopenharmony_ci * @clkr: handle between common and hardware-specific interfaces
208c2ecf20Sopenharmony_ci *
218c2ecf20Sopenharmony_ci * Clock which can gate its output.
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_cistruct clk_branch {
248c2ecf20Sopenharmony_ci	u32	hwcg_reg;
258c2ecf20Sopenharmony_ci	u32	halt_reg;
268c2ecf20Sopenharmony_ci	u8	hwcg_bit;
278c2ecf20Sopenharmony_ci	u8	halt_bit;
288c2ecf20Sopenharmony_ci	u8	halt_check;
298c2ecf20Sopenharmony_ci#define BRANCH_VOTED			BIT(7) /* Delay on disable */
308c2ecf20Sopenharmony_ci#define BRANCH_HALT			0 /* pol: 1 = halt */
318c2ecf20Sopenharmony_ci#define BRANCH_HALT_VOTED		(BRANCH_HALT | BRANCH_VOTED)
328c2ecf20Sopenharmony_ci#define BRANCH_HALT_ENABLE		1 /* pol: 0 = halt */
338c2ecf20Sopenharmony_ci#define BRANCH_HALT_ENABLE_VOTED	(BRANCH_HALT_ENABLE | BRANCH_VOTED)
348c2ecf20Sopenharmony_ci#define BRANCH_HALT_DELAY		2 /* No bit to check; just delay */
358c2ecf20Sopenharmony_ci#define BRANCH_HALT_SKIP		3 /* Don't check halt bit */
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	struct clk_regmap clkr;
388c2ecf20Sopenharmony_ci};
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciextern const struct clk_ops clk_branch_ops;
418c2ecf20Sopenharmony_ciextern const struct clk_ops clk_branch2_ops;
428c2ecf20Sopenharmony_ciextern const struct clk_ops clk_branch_simple_ops;
438c2ecf20Sopenharmony_ciextern const struct clk_ops clk_branch2_aon_ops;
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define to_clk_branch(_hw) \
468c2ecf20Sopenharmony_ci	container_of(to_clk_regmap(_hw), struct clk_branch, clkr)
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#endif
49