Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 //
0003 // OWL mux clock driver
0004 //
0005 // Copyright (c) 2014 Actions Semi Inc.
0006 // Author: David Liu <liuwei@actions-semi.com>
0007 //
0008 // Copyright (c) 2018 Linaro Ltd.
0009 // Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
0010 
0011 #ifndef _OWL_MUX_H_
0012 #define _OWL_MUX_H_
0013 
0014 #include "owl-common.h"
0015 
0016 struct owl_mux_hw {
0017     u32         reg;
0018     u8          shift;
0019     u8          width;
0020 };
0021 
0022 struct owl_mux {
0023     struct owl_mux_hw   mux_hw;
0024     struct owl_clk_common   common;
0025 };
0026 
0027 #define OWL_MUX_HW(_reg, _shift, _width)        \
0028     {                       \
0029         .reg    = _reg,             \
0030         .shift  = _shift,           \
0031         .width  = _width,           \
0032     }
0033 
0034 #define OWL_MUX(_struct, _name, _parents, _reg,             \
0035         _shift, _width, _flags)                 \
0036     struct owl_mux _struct = {                  \
0037         .mux_hw = OWL_MUX_HW(_reg, _shift, _width),     \
0038         .common = {                     \
0039             .regmap = NULL,                 \
0040             .hw.init = CLK_HW_INIT_PARENTS(_name,       \
0041                                _parents,    \
0042                                &owl_mux_ops,    \
0043                                _flags),     \
0044         },                          \
0045     }
0046 
0047 static inline struct owl_mux *hw_to_owl_mux(const struct clk_hw *hw)
0048 {
0049     struct owl_clk_common *common = hw_to_owl_clk_common(hw);
0050 
0051     return container_of(common, struct owl_mux, common);
0052 }
0053 
0054 u8 owl_mux_helper_get_parent(const struct owl_clk_common *common,
0055                  const struct owl_mux_hw *mux_hw);
0056 int owl_mux_helper_set_parent(const struct owl_clk_common *common,
0057                   struct owl_mux_hw *mux_hw, u8 index);
0058 
0059 extern const struct clk_ops owl_mux_ops;
0060 
0061 #endif /* _OWL_MUX_H_ */