blob: 90f8a95e1399c56193007405797e5bbff0a31ef3 [file] [log] [blame]
Pankaj Kumar3912c982011-12-07 16:59:03 +05301/*
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 Mulukutla681d8682012-03-09 23:56:20 -080015#ifndef __ARCH_ARM_MACH_MSM_CLOCK_PLL_H
16#define __ARCH_ARM_MACH_MSM_CLOCK_PLL_H
17
Pankaj Kumar3912c982011-12-07 16:59:03 +053018/**
19 * enum - For PLL IDs
20 */
21enum {
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 Wagantallf82f2942012-01-27 13:56:13 -080037 * @c: clock
Pankaj Kumar3912c982011-12-07 16:59:03 +053038 */
39struct pll_shared_clk {
40 unsigned int id;
41 void __iomem *const mode_reg;
42 struct clk c;
Vikram Mulukutla4d6caa82012-04-10 18:04:55 -070043 void *const __iomem *base;
Pankaj Kumar3912c982011-12-07 16:59:03 +053044};
45
Matt Wagantallae053222012-05-14 19:42:07 -070046extern struct clk_ops clk_ops_pll;
Pankaj Kumar3912c982011-12-07 16:59:03 +053047
Matt Wagantallf82f2942012-01-27 13:56:13 -080048static inline struct pll_shared_clk *to_pll_shared_clk(struct clk *c)
Pankaj Kumar3912c982011-12-07 16:59:03 +053049{
Matt Wagantallf82f2942012-01-27 13:56:13 -080050 return container_of(c, struct pll_shared_clk, c);
Pankaj Kumar3912c982011-12-07 16:59:03 +053051}
52
53/**
54 * msm_shared_pll_control_init() - Initialize shared pll control structure
55 */
56void msm_shared_pll_control_init(void);
Vikram Mulukutla681d8682012-03-09 23:56:20 -080057
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 Wagantallf82f2942012-01-27 13:56:13 -080067 * @c: clock
Vikram Mulukutla681d8682012-03-09 23:56:20 -080068 */
69struct 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 Mulukutla4d6caa82012-04-10 18:04:55 -070079 void *const __iomem *base;
Vikram Mulukutla681d8682012-03-09 23:56:20 -080080};
81
82extern struct clk_ops clk_ops_pll_vote;
83
Matt Wagantallf82f2942012-01-27 13:56:13 -080084static inline struct pll_vote_clk *to_pll_vote_clk(struct clk *c)
Vikram Mulukutla681d8682012-03-09 23:56:20 -080085{
Matt Wagantallf82f2942012-01-27 13:56:13 -080086 return container_of(c, struct pll_vote_clk, c);
Vikram Mulukutla681d8682012-03-09 23:56:20 -080087}
88
89/**
90 * struct pll_clk - phase locked loop
91 * @mode_reg: enable register
Vikram Mulukutlaaa3e0112012-04-23 14:40:51 -070092 * @status_reg: status register, contains the lock detection bit
Vikram Mulukutla681d8682012-03-09 23:56:20 -080093 * @parent: clock source
94 * @c: clk
Vikram Mulukutlaaa3e0112012-04-23 14:40:51 -070095 * @base: pointer to base address of ioremapped registers.
Vikram Mulukutla681d8682012-03-09 23:56:20 -080096 */
97struct pll_clk {
98 void __iomem *const mode_reg;
Vikram Mulukutlaaa3e0112012-04-23 14:40:51 -070099 void __iomem *const status_reg;
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800100
101 struct clk *parent;
102 struct clk c;
Vikram Mulukutla4d6caa82012-04-10 18:04:55 -0700103 void *const __iomem *base;
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800104};
105
106extern struct clk_ops clk_ops_local_pll;
107
Matt Wagantallf82f2942012-01-27 13:56:13 -0800108static inline struct pll_clk *to_pll_clk(struct clk *c)
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800109{
Matt Wagantallf82f2942012-01-27 13:56:13 -0800110 return container_of(c, struct pll_clk, c);
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800111}
112
Matt Wagantallf82f2942012-01-27 13:56:13 -0800113int sr_pll_clk_enable(struct clk *c);
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700114int msm8974_pll_clk_enable(struct clk *c);
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800115
116/*
117 * PLL vote clock APIs
118 */
Matt Wagantallf82f2942012-01-27 13:56:13 -0800119int pll_vote_clk_enable(struct clk *c);
120void pll_vote_clk_disable(struct clk *c);
121struct clk *pll_vote_clk_get_parent(struct clk *c);
122int pll_vote_clk_is_enabled(struct clk *c);
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800123
Vikram Mulukutla5b146722012-04-23 18:17:50 -0700124struct 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
140struct 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
149void __init configure_pll(struct pll_config *, struct pll_config_regs *, u32);
150
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800151#endif