Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2016 Maxime Ripard. All rights reserved.
0004  */
0005 
0006 #ifndef _COMMON_H_
0007 #define _COMMON_H_
0008 
0009 #include <linux/compiler.h>
0010 #include <linux/clk-provider.h>
0011 
0012 #define CCU_FEATURE_FRACTIONAL      BIT(0)
0013 #define CCU_FEATURE_VARIABLE_PREDIV BIT(1)
0014 #define CCU_FEATURE_FIXED_PREDIV    BIT(2)
0015 #define CCU_FEATURE_FIXED_POSTDIV   BIT(3)
0016 #define CCU_FEATURE_ALL_PREDIV      BIT(4)
0017 #define CCU_FEATURE_LOCK_REG        BIT(5)
0018 #define CCU_FEATURE_MMC_TIMING_SWITCH   BIT(6)
0019 #define CCU_FEATURE_SIGMA_DELTA_MOD BIT(7)
0020 #define CCU_FEATURE_KEY_FIELD       BIT(8)
0021 
0022 /* MMC timing mode switch bit */
0023 #define CCU_MMC_NEW_TIMING_MODE     BIT(30)
0024 
0025 struct device_node;
0026 
0027 struct ccu_common {
0028     void __iomem    *base;
0029     u16     reg;
0030     u16     lock_reg;
0031     u32     prediv;
0032 
0033     unsigned long   features;
0034     spinlock_t  *lock;
0035     struct clk_hw   hw;
0036 };
0037 
0038 static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw)
0039 {
0040     return container_of(hw, struct ccu_common, hw);
0041 }
0042 
0043 struct sunxi_ccu_desc {
0044     struct ccu_common       **ccu_clks;
0045     unsigned long           num_ccu_clks;
0046 
0047     struct clk_hw_onecell_data  *hw_clks;
0048 
0049     struct ccu_reset_map        *resets;
0050     unsigned long           num_resets;
0051 };
0052 
0053 void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock);
0054 
0055 struct ccu_pll_nb {
0056     struct notifier_block   clk_nb;
0057     struct ccu_common   *common;
0058 
0059     u32 enable;
0060     u32 lock;
0061 };
0062 
0063 #define to_ccu_pll_nb(_nb) container_of(_nb, struct ccu_pll_nb, clk_nb)
0064 
0065 int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb);
0066 
0067 int devm_sunxi_ccu_probe(struct device *dev, void __iomem *reg,
0068              const struct sunxi_ccu_desc *desc);
0069 void of_sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
0070             const struct sunxi_ccu_desc *desc);
0071 
0072 #endif /* _COMMON_H_ */