blob: 9836907f168215d8a325cd88a2972a0bf97af66a [file] [log] [blame]
David Collins6f032ba2011-08-31 14:08:15 -07001/*
Duy Truong790f06d2013-02-13 16:38:12 -08002 * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
David Collins6f032ba2011-08-31 14:08:15 -07003 *
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#ifndef __ARCH_ARM_MACH_MSM_RPM_REGULATOR_INT_H
15#define __ARCH_ARM_MACH_MSM_RPM_REGULATOR_INT_H
16
17#include <linux/regulator/driver.h>
18#include <mach/rpm.h>
19#include <mach/rpm-regulator.h>
20
21/* Possible RPM regulator request types */
22enum rpm_regulator_type {
23 RPM_REGULATOR_TYPE_LDO,
24 RPM_REGULATOR_TYPE_SMPS,
25 RPM_REGULATOR_TYPE_VS,
26 RPM_REGULATOR_TYPE_NCP,
David Collins0ac31fe2012-02-08 13:53:34 -080027 RPM_REGULATOR_TYPE_CORNER,
28 RPM_REGULATOR_TYPE_MAX = RPM_REGULATOR_TYPE_CORNER,
David Collins6f032ba2011-08-31 14:08:15 -070029};
30
31struct request_member {
32 int word;
33 unsigned int mask;
34 int shift;
35};
36
37/* Possible RPM regulator request members */
38struct rpm_vreg_parts {
39 struct request_member mV; /* voltage: used if voltage is in mV */
40 struct request_member uV; /* voltage: used if voltage is in uV */
41 struct request_member ip; /* peak current in mA */
42 struct request_member pd; /* pull down enable */
43 struct request_member ia; /* average current in mA */
44 struct request_member fm; /* force mode */
45 struct request_member pm; /* power mode */
46 struct request_member pc; /* pin control */
47 struct request_member pf; /* pin function */
48 struct request_member enable_state; /* NCP and switch */
49 struct request_member comp_mode; /* NCP */
50 struct request_member freq; /* frequency: NCP and SMPS */
51 struct request_member freq_clk_src; /* clock source: SMPS */
52 struct request_member hpm; /* switch: control OCP and SS */
53 int request_len;
54};
55
56struct vreg_range {
57 int min_uV;
58 int max_uV;
59 int step_uV;
60 unsigned n_voltages;
61};
62
63struct vreg_set_points {
64 struct vreg_range *range;
65 int count;
66 unsigned n_voltages;
67};
68
69struct vreg {
70 struct msm_rpm_iv_pair req[2];
71 struct msm_rpm_iv_pair prev_active_req[2];
72 struct msm_rpm_iv_pair prev_sleep_req[2];
73 struct rpm_regulator_init_data pdata;
74 struct regulator_desc rdesc;
75 struct regulator_desc rdesc_pc;
76 struct regulator_dev *rdev;
77 struct regulator_dev *rdev_pc;
78 struct vreg_set_points *set_points;
79 struct rpm_vreg_parts *part;
80 int type;
81 int id;
David Collins109a8e62012-07-31 15:21:35 -070082 bool requires_cxo;
David Collins6f032ba2011-08-31 14:08:15 -070083 struct mutex pc_lock;
84 int save_uV;
85 int mode;
86 bool is_enabled;
87 bool is_enabled_pc;
88 const int hpm_min_load;
89 int active_min_uV_vote[RPM_VREG_VOTER_COUNT];
90 int sleep_min_uV_vote[RPM_VREG_VOTER_COUNT];
91};
92
93struct vreg_config {
94 struct vreg *vregs;
95 int vregs_len;
96
97 int vreg_id_min;
98 int vreg_id_max;
99
100 int pin_func_none;
101 int pin_func_sleep_b;
102
103 unsigned int mode_lpm;
104 unsigned int mode_hpm;
105
106 struct vreg_set_points **set_points;
107 int set_points_len;
108
109 const char **label_pin_ctrl;
110 int label_pin_ctrl_len;
111 const char **label_pin_func;
112 int label_pin_func_len;
113 const char **label_force_mode;
114 int label_force_mode_len;
115 const char **label_power_mode;
116 int label_power_mode_len;
117
118 int (*is_real_id) (int vreg_id);
119 int (*pc_id_to_real_id) (int vreg_id);
120
121 /* Legacy options to be used with MSM8660 */
122 int use_legacy_optimum_mode;
123 int ia_follows_ip;
124};
125
126#define REQUEST_MEMBER(_word, _mask, _shift) \
127 { \
128 .word = _word, \
129 .mask = _mask, \
130 .shift = _shift, \
131 }
132
133#define VOLTAGE_RANGE(_min_uV, _max_uV, _step_uV) \
134 { \
135 .min_uV = _min_uV, \
136 .max_uV = _max_uV, \
137 .step_uV = _step_uV, \
138 }
139
140#define SET_POINTS(_ranges) \
141{ \
142 .range = _ranges, \
143 .count = ARRAY_SIZE(_ranges), \
144};
145
146#define MICRO_TO_MILLI(uV) ((uV) / 1000)
147#define MILLI_TO_MICRO(mV) ((mV) * 1000)
148
David Collins5779cea2012-01-05 15:09:21 -0800149#if defined(CONFIG_MSM_RPM_REGULATOR) && defined(CONFIG_ARCH_MSM8X60)
David Collins6f032ba2011-08-31 14:08:15 -0700150struct vreg_config *get_config_8660(void);
151#else
152static inline struct vreg_config *get_config_8660(void)
153{
154 return NULL;
155}
156#endif
157
David Collins5779cea2012-01-05 15:09:21 -0800158#if defined(CONFIG_MSM_RPM_REGULATOR) && \
159 (defined(CONFIG_ARCH_MSM8960) || defined(CONFIG_ARCH_APQ8064))
David Collins6f032ba2011-08-31 14:08:15 -0700160struct vreg_config *get_config_8960(void);
David Collins2ac36d52012-10-02 14:56:21 -0700161struct vreg_config *get_config_8960_pm8917(void);
David Collins6f032ba2011-08-31 14:08:15 -0700162#else
163static inline struct vreg_config *get_config_8960(void)
164{
165 return NULL;
166}
David Collins2ac36d52012-10-02 14:56:21 -0700167static inline struct vreg_config *get_config_8960_pm8917(void)
168{
169 return NULL;
170}
David Collins6f032ba2011-08-31 14:08:15 -0700171#endif
172
David Collins5779cea2012-01-05 15:09:21 -0800173#if defined(CONFIG_MSM_RPM_REGULATOR) && defined(CONFIG_ARCH_MSM9615)
David Collins6ef12bf2011-08-31 14:08:15 -0700174struct vreg_config *get_config_9615(void);
175#else
176static inline struct vreg_config *get_config_9615(void)
177{
178 return NULL;
179}
180#endif
181
David Collins5779cea2012-01-05 15:09:21 -0800182#if defined(CONFIG_MSM_RPM_REGULATOR) && defined(CONFIG_ARCH_MSM8930)
183struct vreg_config *get_config_8930(void);
David Collinsd2a4fef2012-08-13 12:31:04 -0700184struct vreg_config *get_config_8930_pm8917(void);
David Collins5779cea2012-01-05 15:09:21 -0800185#else
186static inline struct vreg_config *get_config_8930(void)
187{
188 return NULL;
189}
David Collinsd2a4fef2012-08-13 12:31:04 -0700190static inline struct vreg_config *get_config_8930_pm8917(void)
191{
192 return NULL;
193}
David Collins5779cea2012-01-05 15:09:21 -0800194#endif
195
David Collins6f032ba2011-08-31 14:08:15 -0700196#endif