Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 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 | |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 15 | #ifndef __ARCH_ARM_MACH_MSM_CLOCK_PLL_H |
| 16 | #define __ARCH_ARM_MACH_MSM_CLOCK_PLL_H |
| 17 | |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 18 | /** |
| 19 | * enum - For PLL IDs |
| 20 | */ |
| 21 | enum { |
| 22 | PLL_TCXO = -1, |
| 23 | PLL_0 = 0, |
| 24 | PLL_1, |
| 25 | PLL_2, |
| 26 | PLL_3, |
| 27 | PLL_4, |
| 28 | PLL_END, |
| 29 | }; |
| 30 | |
| 31 | /** |
| 32 | * struct pll_shared_clk - PLL shared with other processors without |
| 33 | * any HW voting |
| 34 | * @id: PLL ID |
| 35 | * @mode_reg: enable register |
| 36 | * @parent: clock source |
Matt Wagantall | f82f294 | 2012-01-27 13:56:13 -0800 | [diff] [blame] | 37 | * @c: clock |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 38 | */ |
| 39 | struct pll_shared_clk { |
| 40 | unsigned int id; |
| 41 | void __iomem *const mode_reg; |
| 42 | struct clk c; |
Vikram Mulukutla | 4d6caa8 | 2012-04-10 18:04:55 -0700 | [diff] [blame] | 43 | void *const __iomem *base; |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 44 | }; |
| 45 | |
Matt Wagantall | ae05322 | 2012-05-14 19:42:07 -0700 | [diff] [blame] | 46 | extern struct clk_ops clk_ops_pll; |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 47 | |
Matt Wagantall | f82f294 | 2012-01-27 13:56:13 -0800 | [diff] [blame] | 48 | static inline struct pll_shared_clk *to_pll_shared_clk(struct clk *c) |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 49 | { |
Matt Wagantall | f82f294 | 2012-01-27 13:56:13 -0800 | [diff] [blame] | 50 | return container_of(c, struct pll_shared_clk, c); |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /** |
| 54 | * msm_shared_pll_control_init() - Initialize shared pll control structure |
| 55 | */ |
| 56 | void msm_shared_pll_control_init(void); |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * struct pll_vote_clk - phase locked loop (HW voteable) |
| 60 | * @soft_vote: soft voting variable for multiple PLL software instances |
| 61 | * @soft_vote_mask: soft voting mask for multiple PLL software instances |
| 62 | * @en_reg: enable register |
| 63 | * @en_mask: ORed with @en_reg to enable the clock |
| 64 | * @status_mask: ANDed with @status_reg to determine if PLL is active. |
| 65 | * @status_reg: status register |
| 66 | * @parent: clock source |
Matt Wagantall | f82f294 | 2012-01-27 13:56:13 -0800 | [diff] [blame] | 67 | * @c: clock |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 68 | */ |
| 69 | struct pll_vote_clk { |
| 70 | u32 *soft_vote; |
| 71 | const u32 soft_vote_mask; |
| 72 | void __iomem *const en_reg; |
| 73 | const u32 en_mask; |
| 74 | void __iomem *const status_reg; |
| 75 | const u32 status_mask; |
| 76 | |
| 77 | struct clk *parent; |
| 78 | struct clk c; |
Vikram Mulukutla | 4d6caa8 | 2012-04-10 18:04:55 -0700 | [diff] [blame] | 79 | void *const __iomem *base; |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | extern struct clk_ops clk_ops_pll_vote; |
| 83 | |
Matt Wagantall | f82f294 | 2012-01-27 13:56:13 -0800 | [diff] [blame] | 84 | static inline struct pll_vote_clk *to_pll_vote_clk(struct clk *c) |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 85 | { |
Matt Wagantall | f82f294 | 2012-01-27 13:56:13 -0800 | [diff] [blame] | 86 | return container_of(c, struct pll_vote_clk, c); |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | /** |
| 90 | * struct pll_clk - phase locked loop |
| 91 | * @mode_reg: enable register |
Vikram Mulukutla | aa3e011 | 2012-04-23 14:40:51 -0700 | [diff] [blame] | 92 | * @status_reg: status register, contains the lock detection bit |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 93 | * @parent: clock source |
| 94 | * @c: clk |
Vikram Mulukutla | aa3e011 | 2012-04-23 14:40:51 -0700 | [diff] [blame] | 95 | * @base: pointer to base address of ioremapped registers. |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 96 | */ |
| 97 | struct pll_clk { |
| 98 | void __iomem *const mode_reg; |
Vikram Mulukutla | aa3e011 | 2012-04-23 14:40:51 -0700 | [diff] [blame] | 99 | void __iomem *const status_reg; |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 100 | |
| 101 | struct clk *parent; |
| 102 | struct clk c; |
Vikram Mulukutla | 4d6caa8 | 2012-04-10 18:04:55 -0700 | [diff] [blame] | 103 | void *const __iomem *base; |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | extern struct clk_ops clk_ops_local_pll; |
| 107 | |
Matt Wagantall | f82f294 | 2012-01-27 13:56:13 -0800 | [diff] [blame] | 108 | static inline struct pll_clk *to_pll_clk(struct clk *c) |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 109 | { |
Matt Wagantall | f82f294 | 2012-01-27 13:56:13 -0800 | [diff] [blame] | 110 | return container_of(c, struct pll_clk, c); |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 111 | } |
| 112 | |
Matt Wagantall | f82f294 | 2012-01-27 13:56:13 -0800 | [diff] [blame] | 113 | int sr_pll_clk_enable(struct clk *c); |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 114 | int msm8974_pll_clk_enable(struct clk *c); |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 115 | |
| 116 | /* |
| 117 | * PLL vote clock APIs |
| 118 | */ |
Matt Wagantall | f82f294 | 2012-01-27 13:56:13 -0800 | [diff] [blame] | 119 | int pll_vote_clk_enable(struct clk *c); |
| 120 | void pll_vote_clk_disable(struct clk *c); |
| 121 | struct clk *pll_vote_clk_get_parent(struct clk *c); |
| 122 | int pll_vote_clk_is_enabled(struct clk *c); |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 123 | |
Vikram Mulukutla | 5b14672 | 2012-04-23 18:17:50 -0700 | [diff] [blame] | 124 | struct pll_config { |
| 125 | u32 l; |
| 126 | u32 m; |
| 127 | u32 n; |
| 128 | u32 vco_val; |
| 129 | u32 vco_mask; |
| 130 | u32 pre_div_val; |
| 131 | u32 pre_div_mask; |
| 132 | u32 post_div_val; |
| 133 | u32 post_div_mask; |
| 134 | u32 mn_ena_val; |
| 135 | u32 mn_ena_mask; |
| 136 | u32 main_output_val; |
| 137 | u32 main_output_mask; |
| 138 | }; |
| 139 | |
| 140 | struct pll_config_regs { |
| 141 | void __iomem *l_reg; |
| 142 | void __iomem *m_reg; |
| 143 | void __iomem *n_reg; |
| 144 | void __iomem *config_reg; |
| 145 | void __iomem *mode_reg; |
| 146 | void *const __iomem *base; |
| 147 | }; |
| 148 | |
| 149 | void __init configure_pll(struct pll_config *, struct pll_config_regs *, u32); |
| 150 | |
Vikram Mulukutla | 681d868 | 2012-03-09 23:56:20 -0800 | [diff] [blame] | 151 | #endif |