2 * Copyright (c) 2016 Maxime Ripard. All rights reserved.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
17 #include <linux/compiler.h>
18 #include <linux/clk-provider.h>
20 #define CCU_FEATURE_FRACTIONAL BIT(0)
21 #define CCU_FEATURE_VARIABLE_PREDIV BIT(1)
22 #define CCU_FEATURE_FIXED_PREDIV BIT(2)
23 #define CCU_FEATURE_FIXED_POSTDIV BIT(3)
24 #define CCU_FEATURE_ALL_PREDIV BIT(4)
25 #define CCU_FEATURE_LOCK_REG BIT(5)
26 #define CCU_FEATURE_MMC_TIMING_SWITCH BIT(6)
28 /* MMC timing mode switch bit */
29 #define CCU_MMC_NEW_TIMING_MODE BIT(30)
33 #define CLK_HW_INIT(_name, _parent, _ops, _flags) \
34 &(struct clk_init_data) { \
37 .parent_names = (const char *[]) { _parent }, \
42 #define CLK_HW_INIT_PARENTS(_name, _parents, _ops, _flags) \
43 &(struct clk_init_data) { \
46 .parent_names = _parents, \
47 .num_parents = ARRAY_SIZE(_parents), \
51 #define CLK_FIXED_FACTOR(_struct, _name, _parent, \
52 _div, _mult, _flags) \
53 struct clk_fixed_factor _struct = { \
56 .hw.init = CLK_HW_INIT(_name, \
58 &clk_fixed_factor_ops, \
68 unsigned long features;
73 static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw)
75 return container_of(hw, struct ccu_common, hw);
78 struct sunxi_ccu_desc {
79 struct ccu_common **ccu_clks;
80 unsigned long num_ccu_clks;
82 struct clk_hw_onecell_data *hw_clks;
84 struct ccu_reset_map *resets;
85 unsigned long num_resets;
88 void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock);
91 struct notifier_block clk_nb;
92 struct ccu_common *common;
98 #define to_ccu_pll_nb(_nb) container_of(_nb, struct ccu_pll_nb, clk_nb)
100 int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb);
102 int sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
103 const struct sunxi_ccu_desc *desc);
105 #endif /* _COMMON_H_ */