aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/pm.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/pm.c')
-rw-r--r--arch/arm/mach-omap2/pm.c104
1 files changed, 39 insertions, 65 deletions
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 472bf22d5e84..2ab7a9e17fe2 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -26,54 +26,21 @@
26 26
27static struct omap_device_pm_latency *pm_lats; 27static struct omap_device_pm_latency *pm_lats;
28 28
29static struct device *mpu_dev; 29static int _init_omap_device(char *name)
30static struct device *iva_dev;
31static struct device *l3_dev;
32static struct device *dsp_dev;
33
34struct device *omap2_get_mpuss_device(void)
35{
36 WARN_ON_ONCE(!mpu_dev);
37 return mpu_dev;
38}
39
40struct device *omap2_get_iva_device(void)
41{
42 WARN_ON_ONCE(!iva_dev);
43 return iva_dev;
44}
45
46struct device *omap2_get_l3_device(void)
47{
48 WARN_ON_ONCE(!l3_dev);
49 return l3_dev;
50}
51
52struct device *omap4_get_dsp_device(void)
53{
54 WARN_ON_ONCE(!dsp_dev);
55 return dsp_dev;
56}
57EXPORT_SYMBOL(omap4_get_dsp_device);
58
59/* static int _init_omap_device(struct omap_hwmod *oh, void *user) */
60static int _init_omap_device(char *name, struct device **new_dev)
61{ 30{
62 struct omap_hwmod *oh; 31 struct omap_hwmod *oh;
63 struct omap_device *od; 32 struct platform_device *pdev;
64 33
65 oh = omap_hwmod_lookup(name); 34 oh = omap_hwmod_lookup(name);
66 if (WARN(!oh, "%s: could not find omap_hwmod for %s\n", 35 if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
67 __func__, name)) 36 __func__, name))
68 return -ENODEV; 37 return -ENODEV;
69 38
70 od = omap_device_build(oh->name, 0, oh, NULL, 0, pm_lats, 0, false); 39 pdev = omap_device_build(oh->name, 0, oh, NULL, 0, pm_lats, 0, false);
71 if (WARN(IS_ERR(od), "%s: could not build omap_device for %s\n", 40 if (WARN(IS_ERR(pdev), "%s: could not build omap_device for %s\n",
72 __func__, name)) 41 __func__, name))
73 return -ENODEV; 42 return -ENODEV;
74 43
75 *new_dev = &od->pdev.dev;
76
77 return 0; 44 return 0;
78} 45}
79 46
@@ -82,16 +49,16 @@ static int _init_omap_device(char *name, struct device **new_dev)
82 */ 49 */
83static void omap2_init_processor_devices(void) 50static void omap2_init_processor_devices(void)
84{ 51{
85 _init_omap_device("mpu", &mpu_dev); 52 _init_omap_device("mpu");
86 if (omap3_has_iva()) 53 if (omap3_has_iva())
87 _init_omap_device("iva", &iva_dev); 54 _init_omap_device("iva");
88 55
89 if (cpu_is_omap44xx()) { 56 if (cpu_is_omap44xx()) {
90 _init_omap_device("l3_main_1", &l3_dev); 57 _init_omap_device("l3_main_1");
91 _init_omap_device("dsp", &dsp_dev); 58 _init_omap_device("dsp");
92 _init_omap_device("iva", &iva_dev); 59 _init_omap_device("iva");
93 } else { 60 } else {
94 _init_omap_device("l3_main", &l3_dev); 61 _init_omap_device("l3_main");
95 } 62 }
96} 63}
97 64
@@ -136,8 +103,8 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
136 103
137 ret = pwrdm_set_next_pwrst(pwrdm, state); 104 ret = pwrdm_set_next_pwrst(pwrdm, state);
138 if (ret) { 105 if (ret) {
139 printk(KERN_ERR "Unable to set state of powerdomain: %s\n", 106 pr_err("%s: unable to set state of powerdomain: %s\n",
140 pwrdm->name); 107 __func__, pwrdm->name);
141 goto err; 108 goto err;
142 } 109 }
143 110
@@ -161,37 +128,44 @@ err:
161} 128}
162 129
163/* 130/*
164 * This API is to be called during init to put the various voltage 131 * This API is to be called during init to set the various voltage
165 * domains to the voltage as per the opp table. Typically we boot up 132 * domains to the voltage as per the opp table. Typically we boot up
166 * at the nominal voltage. So this function finds out the rate of 133 * at the nominal voltage. So this function finds out the rate of
167 * the clock associated with the voltage domain, finds out the correct 134 * the clock associated with the voltage domain, finds out the correct
168 * opp entry and puts the voltage domain to the voltage specifies 135 * opp entry and sets the voltage domain to the voltage specified
169 * in the opp entry 136 * in the opp entry
170 */ 137 */
171static int __init omap2_set_init_voltage(char *vdd_name, char *clk_name, 138static int __init omap2_set_init_voltage(char *vdd_name, char *clk_name,
172 struct device *dev) 139 const char *oh_name)
173{ 140{
174 struct voltagedomain *voltdm; 141 struct voltagedomain *voltdm;
175 struct clk *clk; 142 struct clk *clk;
176 struct opp *opp; 143 struct opp *opp;
177 unsigned long freq, bootup_volt; 144 unsigned long freq, bootup_volt;
145 struct device *dev;
146
147 if (!vdd_name || !clk_name || !oh_name) {
148 pr_err("%s: invalid parameters\n", __func__);
149 goto exit;
150 }
178 151
179 if (!vdd_name || !clk_name || !dev) { 152 dev = omap_device_get_by_hwmod_name(oh_name);
180 printk(KERN_ERR "%s: Invalid parameters!\n", __func__); 153 if (IS_ERR(dev)) {
154 pr_err("%s: Unable to get dev pointer for hwmod %s\n",
155 __func__, oh_name);
181 goto exit; 156 goto exit;
182 } 157 }
183 158
184 voltdm = omap_voltage_domain_lookup(vdd_name); 159 voltdm = voltdm_lookup(vdd_name);
185 if (IS_ERR(voltdm)) { 160 if (IS_ERR(voltdm)) {
186 printk(KERN_ERR "%s: Unable to get vdd pointer for vdd_%s\n", 161 pr_err("%s: unable to get vdd pointer for vdd_%s\n",
187 __func__, vdd_name); 162 __func__, vdd_name);
188 goto exit; 163 goto exit;
189 } 164 }
190 165
191 clk = clk_get(NULL, clk_name); 166 clk = clk_get(NULL, clk_name);
192 if (IS_ERR(clk)) { 167 if (IS_ERR(clk)) {
193 printk(KERN_ERR "%s: unable to get clk %s\n", 168 pr_err("%s: unable to get clk %s\n", __func__, clk_name);
194 __func__, clk_name);
195 goto exit; 169 goto exit;
196 } 170 }
197 171
@@ -200,24 +174,23 @@ static int __init omap2_set_init_voltage(char *vdd_name, char *clk_name,
200 174
201 opp = opp_find_freq_ceil(dev, &freq); 175 opp = opp_find_freq_ceil(dev, &freq);
202 if (IS_ERR(opp)) { 176 if (IS_ERR(opp)) {
203 printk(KERN_ERR "%s: unable to find boot up OPP for vdd_%s\n", 177 pr_err("%s: unable to find boot up OPP for vdd_%s\n",
204 __func__, vdd_name); 178 __func__, vdd_name);
205 goto exit; 179 goto exit;
206 } 180 }
207 181
208 bootup_volt = opp_get_voltage(opp); 182 bootup_volt = opp_get_voltage(opp);
209 if (!bootup_volt) { 183 if (!bootup_volt) {
210 printk(KERN_ERR "%s: unable to find voltage corresponding" 184 pr_err("%s: unable to find voltage corresponding "
211 "to the bootup OPP for vdd_%s\n", __func__, vdd_name); 185 "to the bootup OPP for vdd_%s\n", __func__, vdd_name);
212 goto exit; 186 goto exit;
213 } 187 }
214 188
215 omap_voltage_scale_vdd(voltdm, bootup_volt); 189 voltdm_scale(voltdm, bootup_volt);
216 return 0; 190 return 0;
217 191
218exit: 192exit:
219 printk(KERN_ERR "%s: Unable to put vdd_%s to its init voltage\n\n", 193 pr_err("%s: unable to set vdd_%s\n", __func__, vdd_name);
220 __func__, vdd_name);
221 return -EINVAL; 194 return -EINVAL;
222} 195}
223 196
@@ -226,8 +199,8 @@ static void __init omap3_init_voltages(void)
226 if (!cpu_is_omap34xx()) 199 if (!cpu_is_omap34xx())
227 return; 200 return;
228 201
229 omap2_set_init_voltage("mpu", "dpll1_ck", mpu_dev); 202 omap2_set_init_voltage("mpu_iva", "dpll1_ck", "mpu");
230 omap2_set_init_voltage("core", "l3_ick", l3_dev); 203 omap2_set_init_voltage("core", "l3_ick", "l3_main");
231} 204}
232 205
233static void __init omap4_init_voltages(void) 206static void __init omap4_init_voltages(void)
@@ -235,14 +208,15 @@ static void __init omap4_init_voltages(void)
235 if (!cpu_is_omap44xx()) 208 if (!cpu_is_omap44xx())
236 return; 209 return;
237 210
238 omap2_set_init_voltage("mpu", "dpll_mpu_ck", mpu_dev); 211 omap2_set_init_voltage("mpu", "dpll_mpu_ck", "mpu");
239 omap2_set_init_voltage("core", "l3_div_ck", l3_dev); 212 omap2_set_init_voltage("core", "l3_div_ck", "l3_main_1");
240 omap2_set_init_voltage("iva", "dpll_iva_m5x2_ck", iva_dev); 213 omap2_set_init_voltage("iva", "dpll_iva_m5x2_ck", "iva");
241} 214}
242 215
243static int __init omap2_common_pm_init(void) 216static int __init omap2_common_pm_init(void)
244{ 217{
245 omap2_init_processor_devices(); 218 if (!of_have_populated_dt())
219 omap2_init_processor_devices();
246 omap_pm_if_init(); 220 omap_pm_if_init();
247 221
248 return 0; 222 return 0;