18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2016 Maxime Ripard. All rights reserved.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef _CCU_FRAC_H_
78c2ecf20Sopenharmony_ci#define _CCU_FRAC_H_
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "ccu_common.h"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_cistruct ccu_frac_internal {
148c2ecf20Sopenharmony_ci	u32		enable;
158c2ecf20Sopenharmony_ci	u32		select;
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci	unsigned long	rates[2];
188c2ecf20Sopenharmony_ci};
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define _SUNXI_CCU_FRAC(_enable, _select, _rate1, _rate2)		\
218c2ecf20Sopenharmony_ci	{								\
228c2ecf20Sopenharmony_ci		.enable	= _enable,					\
238c2ecf20Sopenharmony_ci		.select	= _select,					\
248c2ecf20Sopenharmony_ci		.rates = { _rate1, _rate2 },				\
258c2ecf20Sopenharmony_ci	}
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_cibool ccu_frac_helper_is_enabled(struct ccu_common *common,
288c2ecf20Sopenharmony_ci				struct ccu_frac_internal *cf);
298c2ecf20Sopenharmony_civoid ccu_frac_helper_enable(struct ccu_common *common,
308c2ecf20Sopenharmony_ci			    struct ccu_frac_internal *cf);
318c2ecf20Sopenharmony_civoid ccu_frac_helper_disable(struct ccu_common *common,
328c2ecf20Sopenharmony_ci			     struct ccu_frac_internal *cf);
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cibool ccu_frac_helper_has_rate(struct ccu_common *common,
358c2ecf20Sopenharmony_ci			      struct ccu_frac_internal *cf,
368c2ecf20Sopenharmony_ci			      unsigned long rate);
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciunsigned long ccu_frac_helper_read_rate(struct ccu_common *common,
398c2ecf20Sopenharmony_ci					struct ccu_frac_internal *cf);
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciint ccu_frac_helper_set_rate(struct ccu_common *common,
428c2ecf20Sopenharmony_ci			     struct ccu_frac_internal *cf,
438c2ecf20Sopenharmony_ci			     unsigned long rate, u32 lock);
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#endif /* _CCU_FRAC_H_ */
46