Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2016 Maxime Ripard. All rights reserved. |
| 3 | * |
| 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. |
| 7 | * |
| 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. |
| 12 | */ |
| 13 | |
| 14 | #ifndef _COMMON_H_ |
| 15 | #define _COMMON_H_ |
| 16 | |
| 17 | #include <linux/compiler.h> |
| 18 | #include <linux/clk-provider.h> |
| 19 | |
| 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) |
| 27 | #define CCU_FEATURE_SIGMA_DELTA_MOD BIT(7) |
| 28 | |
| 29 | /* MMC timing mode switch bit */ |
| 30 | #define CCU_MMC_NEW_TIMING_MODE BIT(30) |
| 31 | |
| 32 | struct device_node; |
| 33 | |
| 34 | struct ccu_common { |
| 35 | void __iomem *base; |
| 36 | u16 reg; |
| 37 | u16 lock_reg; |
| 38 | u32 prediv; |
| 39 | |
| 40 | unsigned long features; |
| 41 | spinlock_t *lock; |
| 42 | struct clk_hw hw; |
| 43 | }; |
| 44 | |
| 45 | static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw) |
| 46 | { |
| 47 | return container_of(hw, struct ccu_common, hw); |
| 48 | } |
| 49 | |
| 50 | struct sunxi_ccu_desc { |
| 51 | struct ccu_common **ccu_clks; |
| 52 | unsigned long num_ccu_clks; |
| 53 | |
| 54 | struct clk_hw_onecell_data *hw_clks; |
| 55 | |
| 56 | struct ccu_reset_map *resets; |
| 57 | unsigned long num_resets; |
| 58 | }; |
| 59 | |
| 60 | void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock); |
| 61 | |
| 62 | struct ccu_pll_nb { |
| 63 | struct notifier_block clk_nb; |
| 64 | struct ccu_common *common; |
| 65 | |
| 66 | u32 enable; |
| 67 | u32 lock; |
| 68 | }; |
| 69 | |
| 70 | #define to_ccu_pll_nb(_nb) container_of(_nb, struct ccu_pll_nb, clk_nb) |
| 71 | |
| 72 | int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb); |
| 73 | |
| 74 | int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, |
| 75 | const struct sunxi_ccu_desc *desc); |
| 76 | |
| 77 | #endif /* _COMMON_H_ */ |