xref: /openbmc/linux/drivers/clk/sunxi-ng/ccu_phase.h (revision 6f9f7f87)
16f9f7f87SMaxime Ripard /*
26f9f7f87SMaxime Ripard  * Copyright (c) 2016 Maxime Ripard. All rights reserved.
36f9f7f87SMaxime Ripard  *
46f9f7f87SMaxime Ripard  * This software is licensed under the terms of the GNU General Public
56f9f7f87SMaxime Ripard  * License version 2, as published by the Free Software Foundation, and
66f9f7f87SMaxime Ripard  * may be copied, distributed, and modified under those terms.
76f9f7f87SMaxime Ripard  *
86f9f7f87SMaxime Ripard  * This program is distributed in the hope that it will be useful,
96f9f7f87SMaxime Ripard  * but WITHOUT ANY WARRANTY; without even the implied warranty of
106f9f7f87SMaxime Ripard  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
116f9f7f87SMaxime Ripard  * GNU General Public License for more details.
126f9f7f87SMaxime Ripard  */
136f9f7f87SMaxime Ripard 
146f9f7f87SMaxime Ripard #ifndef _CCU_PHASE_H_
156f9f7f87SMaxime Ripard #define _CCU_PHASE_H_
166f9f7f87SMaxime Ripard 
176f9f7f87SMaxime Ripard #include <linux/clk-provider.h>
186f9f7f87SMaxime Ripard 
196f9f7f87SMaxime Ripard #include "ccu_common.h"
206f9f7f87SMaxime Ripard 
216f9f7f87SMaxime Ripard struct ccu_phase {
226f9f7f87SMaxime Ripard 	u8			shift;
236f9f7f87SMaxime Ripard 	u8			width;
246f9f7f87SMaxime Ripard 
256f9f7f87SMaxime Ripard 	struct ccu_common	common;
266f9f7f87SMaxime Ripard };
276f9f7f87SMaxime Ripard 
286f9f7f87SMaxime Ripard #define SUNXI_CCU_PHASE(_struct, _name, _parent, _reg, _shift, _width, _flags) \
296f9f7f87SMaxime Ripard 	struct ccu_phase _struct = {					\
306f9f7f87SMaxime Ripard 		.shift	= _shift,					\
316f9f7f87SMaxime Ripard 		.width	= _width,					\
326f9f7f87SMaxime Ripard 		.common	= {						\
336f9f7f87SMaxime Ripard 			.reg		= _reg,				\
346f9f7f87SMaxime Ripard 			.hw.init	= CLK_HW_INIT(_name,		\
356f9f7f87SMaxime Ripard 						      _parent,		\
366f9f7f87SMaxime Ripard 						      &ccu_phase_ops,	\
376f9f7f87SMaxime Ripard 						      _flags),		\
386f9f7f87SMaxime Ripard 		}							\
396f9f7f87SMaxime Ripard 	}
406f9f7f87SMaxime Ripard 
416f9f7f87SMaxime Ripard static inline struct ccu_phase *hw_to_ccu_phase(struct clk_hw *hw)
426f9f7f87SMaxime Ripard {
436f9f7f87SMaxime Ripard 	struct ccu_common *common = hw_to_ccu_common(hw);
446f9f7f87SMaxime Ripard 
456f9f7f87SMaxime Ripard 	return container_of(common, struct ccu_phase, common);
466f9f7f87SMaxime Ripard }
476f9f7f87SMaxime Ripard 
486f9f7f87SMaxime Ripard extern const struct clk_ops ccu_phase_ops;
496f9f7f87SMaxime Ripard 
506f9f7f87SMaxime Ripard #endif /* _CCU_PHASE_H_ */
51