18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */
28c2ecf20Sopenharmony_ci//
38c2ecf20Sopenharmony_ci// OWL mux clock driver
48c2ecf20Sopenharmony_ci//
58c2ecf20Sopenharmony_ci// Copyright (c) 2014 Actions Semi Inc.
68c2ecf20Sopenharmony_ci// Author: David Liu <liuwei@actions-semi.com>
78c2ecf20Sopenharmony_ci//
88c2ecf20Sopenharmony_ci// Copyright (c) 2018 Linaro Ltd.
98c2ecf20Sopenharmony_ci// Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifndef _OWL_MUX_H_
128c2ecf20Sopenharmony_ci#define _OWL_MUX_H_
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include "owl-common.h"
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_cistruct owl_mux_hw {
178c2ecf20Sopenharmony_ci	u32			reg;
188c2ecf20Sopenharmony_ci	u8			shift;
198c2ecf20Sopenharmony_ci	u8			width;
208c2ecf20Sopenharmony_ci};
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cistruct owl_mux {
238c2ecf20Sopenharmony_ci	struct owl_mux_hw	mux_hw;
248c2ecf20Sopenharmony_ci	struct owl_clk_common	common;
258c2ecf20Sopenharmony_ci};
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define OWL_MUX_HW(_reg, _shift, _width)		\
288c2ecf20Sopenharmony_ci	{						\
298c2ecf20Sopenharmony_ci		.reg	= _reg,				\
308c2ecf20Sopenharmony_ci		.shift	= _shift,			\
318c2ecf20Sopenharmony_ci		.width	= _width,			\
328c2ecf20Sopenharmony_ci	}
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define OWL_MUX(_struct, _name, _parents, _reg,				\
358c2ecf20Sopenharmony_ci		_shift, _width, _flags)					\
368c2ecf20Sopenharmony_ci	struct owl_mux _struct = {					\
378c2ecf20Sopenharmony_ci		.mux_hw	= OWL_MUX_HW(_reg, _shift, _width),		\
388c2ecf20Sopenharmony_ci		.common = {						\
398c2ecf20Sopenharmony_ci			.regmap = NULL,					\
408c2ecf20Sopenharmony_ci			.hw.init = CLK_HW_INIT_PARENTS(_name,		\
418c2ecf20Sopenharmony_ci						       _parents,	\
428c2ecf20Sopenharmony_ci						       &owl_mux_ops,	\
438c2ecf20Sopenharmony_ci						       _flags),		\
448c2ecf20Sopenharmony_ci		},							\
458c2ecf20Sopenharmony_ci	}
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cistatic inline struct owl_mux *hw_to_owl_mux(const struct clk_hw *hw)
488c2ecf20Sopenharmony_ci{
498c2ecf20Sopenharmony_ci	struct owl_clk_common *common = hw_to_owl_clk_common(hw);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	return container_of(common, struct owl_mux, common);
528c2ecf20Sopenharmony_ci}
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciu8 owl_mux_helper_get_parent(const struct owl_clk_common *common,
558c2ecf20Sopenharmony_ci			     const struct owl_mux_hw *mux_hw);
568c2ecf20Sopenharmony_ciint owl_mux_helper_set_parent(const struct owl_clk_common *common,
578c2ecf20Sopenharmony_ci			      struct owl_mux_hw *mux_hw, u8 index);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ciextern const struct clk_ops owl_mux_ops;
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#endif /* _OWL_MUX_H_ */
62