Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013, The Linux Foundation. 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 | #define pr_fmt(fmt) "%s: " fmt, __func__ |
| 15 | |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/io.h> |
| 20 | #include <linux/delay.h> |
| 21 | #include <linux/mutex.h> |
| 22 | #include <linux/spinlock.h> |
| 23 | #include <linux/errno.h> |
| 24 | #include <linux/cpufreq.h> |
| 25 | #include <linux/clk.h> |
| 26 | #include <linux/platform_device.h> |
| 27 | #include <linux/iopoll.h> |
| 28 | |
| 29 | #include <mach/board.h> |
| 30 | #include <mach/msm_iomap.h> |
| 31 | #include <mach/msm_bus.h> |
| 32 | #include <mach/msm_bus_board.h> |
| 33 | #include <mach/rpm-regulator.h> |
| 34 | #include <mach/clk-provider.h> |
| 35 | #include <mach/rpm-regulator-smd.h> |
| 36 | |
| 37 | #include "acpuclock.h" |
| 38 | #include "acpuclock-cortex.h" |
| 39 | |
| 40 | #define POLL_INTERVAL_US 1 |
| 41 | #define APCS_RCG_UPDATE_TIMEOUT_US 20 |
| 42 | |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 43 | static struct acpuclk_drv_data *priv; |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 44 | static uint32_t bus_perf_client; |
| 45 | |
| 46 | /* Update the bus bandwidth request. */ |
| 47 | static void set_bus_bw(unsigned int bw) |
| 48 | { |
| 49 | int ret; |
| 50 | |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 51 | if (bw >= priv->bus_scale->num_usecases) { |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 52 | pr_err("invalid bandwidth request (%d)\n", bw); |
| 53 | return; |
| 54 | } |
| 55 | |
| 56 | /* Update bandwidth if request has changed. This may sleep. */ |
| 57 | ret = msm_bus_scale_client_update_request(bus_perf_client, bw); |
| 58 | if (ret) |
| 59 | pr_err("bandwidth request failed (%d)\n", ret); |
| 60 | |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | /* Apply any voltage increases. */ |
| 65 | static int increase_vdd(unsigned int vdd_cpu, unsigned int vdd_mem) |
| 66 | { |
| 67 | int rc = 0; |
| 68 | |
| 69 | /* Increase vdd_mem before vdd_cpu. vdd_mem should be >= vdd_cpu. */ |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 70 | rc = regulator_set_voltage(priv->vdd_mem, vdd_mem, priv->vdd_max_mem); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 71 | if (rc) { |
| 72 | pr_err("vdd_mem increase failed (%d)\n", rc); |
| 73 | return rc; |
| 74 | } |
| 75 | |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 76 | rc = regulator_set_voltage(priv->vdd_cpu, vdd_cpu, priv->vdd_max_cpu); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 77 | if (rc) |
| 78 | pr_err("vdd_cpu increase failed (%d)\n", rc); |
| 79 | |
| 80 | return rc; |
| 81 | } |
| 82 | |
| 83 | /* Apply any per-cpu voltage decreases. */ |
| 84 | static void decrease_vdd(unsigned int vdd_cpu, unsigned int vdd_mem) |
| 85 | { |
| 86 | int ret; |
| 87 | |
| 88 | /* Update CPU voltage. */ |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 89 | ret = regulator_set_voltage(priv->vdd_cpu, vdd_cpu, priv->vdd_max_cpu); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 90 | if (ret) { |
| 91 | pr_err("vdd_cpu decrease failed (%d)\n", ret); |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | /* Decrease vdd_mem after vdd_cpu. vdd_mem should be >= vdd_cpu. */ |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 96 | ret = regulator_set_voltage(priv->vdd_mem, vdd_mem, priv->vdd_max_mem); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 97 | if (ret) |
| 98 | pr_err("vdd_mem decrease failed (%d)\n", ret); |
| 99 | } |
| 100 | |
| 101 | static void select_clk_source_div(struct acpuclk_drv_data *drv_data, |
| 102 | struct clkctl_acpu_speed *s) |
| 103 | { |
| 104 | u32 regval, rc, src_div; |
| 105 | void __iomem *apcs_rcg_config = drv_data->apcs_rcg_config; |
| 106 | void __iomem *apcs_rcg_cmd = drv_data->apcs_rcg_cmd; |
| 107 | struct acpuclk_reg_data *r = &drv_data->reg_data; |
| 108 | |
| 109 | src_div = s->src_div ? ((2 * s->src_div) - 1) : s->src_div; |
| 110 | |
| 111 | regval = readl_relaxed(apcs_rcg_config); |
| 112 | regval &= ~r->cfg_src_mask; |
| 113 | regval |= s->src_sel << r->cfg_src_shift; |
| 114 | regval &= ~r->cfg_div_mask; |
| 115 | regval |= src_div << r->cfg_div_shift; |
| 116 | writel_relaxed(regval, apcs_rcg_config); |
| 117 | |
| 118 | /* Update the configuration */ |
| 119 | regval = readl_relaxed(apcs_rcg_cmd); |
| 120 | regval |= r->update_mask; |
| 121 | writel_relaxed(regval, apcs_rcg_cmd); |
| 122 | |
| 123 | /* Wait for the update to take effect */ |
Patrick Daly | 6bda591 | 2013-04-03 16:06:07 -0700 | [diff] [blame] | 124 | rc = readl_poll_timeout_noirq(apcs_rcg_cmd, regval, |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 125 | !(regval & r->poll_mask), |
| 126 | POLL_INTERVAL_US, |
| 127 | APCS_RCG_UPDATE_TIMEOUT_US); |
| 128 | if (rc) |
| 129 | pr_warn("acpu rcg didn't update its configuration\n"); |
| 130 | } |
| 131 | |
Patrick Daly | 57d87e6 | 2013-04-09 18:51:51 -0700 | [diff] [blame] | 132 | static int set_speed_atomic(struct clkctl_acpu_speed *tgt_s) |
| 133 | { |
| 134 | struct clkctl_acpu_speed *strt_s = priv->current_speed; |
| 135 | struct clk *strt = priv->src_clocks[strt_s->src].clk; |
| 136 | struct clk *tgt = priv->src_clocks[tgt_s->src].clk; |
| 137 | int rc = 0; |
| 138 | |
| 139 | WARN(strt_s->src == ACPUPLL && tgt_s->src == ACPUPLL, |
| 140 | "can't reprogram ACPUPLL during atomic context\n"); |
| 141 | rc = clk_enable(tgt); |
| 142 | if (rc) |
| 143 | return rc; |
| 144 | |
| 145 | select_clk_source_div(priv, tgt_s); |
| 146 | clk_disable(strt); |
| 147 | |
| 148 | return rc; |
| 149 | } |
| 150 | |
| 151 | static int set_speed(struct clkctl_acpu_speed *tgt_s) |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 152 | { |
| 153 | int rc = 0; |
| 154 | unsigned int tgt_freq_hz = tgt_s->khz * 1000; |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 155 | struct clkctl_acpu_speed *strt_s = priv->current_speed; |
| 156 | struct clkctl_acpu_speed *cxo_s = &priv->freq_tbl[0]; |
| 157 | struct clk *strt = priv->src_clocks[strt_s->src].clk; |
| 158 | struct clk *tgt = priv->src_clocks[tgt_s->src].clk; |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 159 | |
| 160 | if (strt_s->src == ACPUPLL && tgt_s->src == ACPUPLL) { |
| 161 | /* Switch to another always on src */ |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 162 | select_clk_source_div(priv, cxo_s); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 163 | |
| 164 | /* Re-program acpu pll */ |
Patrick Daly | 57d87e6 | 2013-04-09 18:51:51 -0700 | [diff] [blame] | 165 | clk_disable_unprepare(tgt); |
Patrick Daly | e85c6bc | 2013-01-31 14:14:28 -0800 | [diff] [blame] | 166 | |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 167 | rc = clk_set_rate(tgt, tgt_freq_hz); |
| 168 | if (rc) |
| 169 | pr_err("Failed to set ACPU PLL to %u\n", tgt_freq_hz); |
Patrick Daly | e85c6bc | 2013-01-31 14:14:28 -0800 | [diff] [blame] | 170 | |
Patrick Daly | 57d87e6 | 2013-04-09 18:51:51 -0700 | [diff] [blame] | 171 | BUG_ON(clk_prepare_enable(tgt)); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 172 | |
| 173 | /* Switch back to acpu pll */ |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 174 | select_clk_source_div(priv, tgt_s); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 175 | |
| 176 | } else if (strt_s->src != ACPUPLL && tgt_s->src == ACPUPLL) { |
| 177 | rc = clk_set_rate(tgt, tgt_freq_hz); |
| 178 | if (rc) { |
| 179 | pr_err("Failed to set ACPU PLL to %u\n", tgt_freq_hz); |
| 180 | return rc; |
| 181 | } |
| 182 | |
Patrick Daly | 57d87e6 | 2013-04-09 18:51:51 -0700 | [diff] [blame] | 183 | rc = clk_prepare_enable(tgt); |
Patrick Daly | e85c6bc | 2013-01-31 14:14:28 -0800 | [diff] [blame] | 184 | |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 185 | if (rc) { |
| 186 | pr_err("ACPU PLL enable failed\n"); |
| 187 | return rc; |
| 188 | } |
| 189 | |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 190 | select_clk_source_div(priv, tgt_s); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 191 | |
Patrick Daly | 57d87e6 | 2013-04-09 18:51:51 -0700 | [diff] [blame] | 192 | clk_disable_unprepare(strt); |
Patrick Daly | e85c6bc | 2013-01-31 14:14:28 -0800 | [diff] [blame] | 193 | |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 194 | } else { |
Patrick Daly | 57d87e6 | 2013-04-09 18:51:51 -0700 | [diff] [blame] | 195 | rc = clk_prepare_enable(tgt); |
Patrick Daly | e85c6bc | 2013-01-31 14:14:28 -0800 | [diff] [blame] | 196 | |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 197 | if (rc) { |
| 198 | pr_err("%s enable failed\n", |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 199 | priv->src_clocks[tgt_s->src].name); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 200 | return rc; |
| 201 | } |
| 202 | |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 203 | select_clk_source_div(priv, tgt_s); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 204 | |
Patrick Daly | 57d87e6 | 2013-04-09 18:51:51 -0700 | [diff] [blame] | 205 | clk_disable_unprepare(strt); |
Patrick Daly | e85c6bc | 2013-01-31 14:14:28 -0800 | [diff] [blame] | 206 | |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | return rc; |
| 210 | } |
| 211 | |
| 212 | static int acpuclk_cortex_set_rate(int cpu, unsigned long rate, |
| 213 | enum setrate_reason reason) |
| 214 | { |
| 215 | struct clkctl_acpu_speed *tgt_s, *strt_s; |
| 216 | int rc = 0; |
| 217 | |
| 218 | if (reason == SETRATE_CPUFREQ) |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 219 | mutex_lock(&priv->lock); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 220 | |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 221 | strt_s = priv->current_speed; |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 222 | |
| 223 | /* Return early if rate didn't change */ |
| 224 | if (rate == strt_s->khz) |
| 225 | goto out; |
| 226 | |
| 227 | /* Find target frequency */ |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 228 | for (tgt_s = priv->freq_tbl; tgt_s->khz != 0; tgt_s++) |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 229 | if (tgt_s->khz == rate) |
| 230 | break; |
| 231 | if (tgt_s->khz == 0) { |
| 232 | rc = -EINVAL; |
| 233 | goto out; |
| 234 | } |
| 235 | |
| 236 | /* Increase VDD levels if needed */ |
| 237 | if ((reason == SETRATE_CPUFREQ || reason == SETRATE_INIT) |
| 238 | && (tgt_s->khz > strt_s->khz)) { |
| 239 | rc = increase_vdd(tgt_s->vdd_cpu, tgt_s->vdd_mem); |
| 240 | if (rc) |
| 241 | goto out; |
| 242 | } |
| 243 | |
| 244 | pr_debug("Switching from CPU rate %u KHz -> %u KHz\n", |
| 245 | strt_s->khz, tgt_s->khz); |
| 246 | |
Patrick Daly | e85c6bc | 2013-01-31 14:14:28 -0800 | [diff] [blame] | 247 | /* Switch CPU speed. Flag indicates atomic context */ |
| 248 | if (reason == SETRATE_CPUFREQ || reason == SETRATE_INIT) |
Patrick Daly | 57d87e6 | 2013-04-09 18:51:51 -0700 | [diff] [blame] | 249 | rc = set_speed(tgt_s); |
Patrick Daly | e85c6bc | 2013-01-31 14:14:28 -0800 | [diff] [blame] | 250 | else |
Patrick Daly | 57d87e6 | 2013-04-09 18:51:51 -0700 | [diff] [blame] | 251 | rc = set_speed_atomic(tgt_s); |
Patrick Daly | e85c6bc | 2013-01-31 14:14:28 -0800 | [diff] [blame] | 252 | |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 253 | if (rc) |
| 254 | goto out; |
| 255 | |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 256 | priv->current_speed = tgt_s; |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 257 | pr_debug("CPU speed change complete\n"); |
| 258 | |
| 259 | /* Nothing else to do for SWFI or power-collapse. */ |
| 260 | if (reason == SETRATE_SWFI || reason == SETRATE_PC) |
| 261 | goto out; |
| 262 | |
| 263 | /* Update bus bandwith request */ |
| 264 | set_bus_bw(tgt_s->bw_level); |
| 265 | |
| 266 | /* Drop VDD levels if we can. */ |
| 267 | if (tgt_s->khz < strt_s->khz) |
| 268 | decrease_vdd(tgt_s->vdd_cpu, tgt_s->vdd_mem); |
| 269 | |
| 270 | out: |
| 271 | if (reason == SETRATE_CPUFREQ) |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 272 | mutex_unlock(&priv->lock); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 273 | return rc; |
| 274 | } |
| 275 | |
| 276 | static unsigned long acpuclk_cortex_get_rate(int cpu) |
| 277 | { |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 278 | return priv->current_speed->khz; |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | #ifdef CONFIG_CPU_FREQ_MSM |
| 282 | static struct cpufreq_frequency_table freq_table[30]; |
| 283 | |
| 284 | static void __init cpufreq_table_init(void) |
| 285 | { |
| 286 | int i, freq_cnt = 0; |
| 287 | |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 288 | /* Construct the freq_table tables from priv->freq_tbl. */ |
| 289 | for (i = 0; priv->freq_tbl[i].khz != 0 |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 290 | && freq_cnt < ARRAY_SIZE(freq_table); i++) { |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 291 | if (!priv->freq_tbl[i].use_for_scaling) |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 292 | continue; |
| 293 | freq_table[freq_cnt].index = freq_cnt; |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 294 | freq_table[freq_cnt].frequency = priv->freq_tbl[i].khz; |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 295 | freq_cnt++; |
| 296 | } |
| 297 | /* freq_table not big enough to store all usable freqs. */ |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 298 | BUG_ON(priv->freq_tbl[i].khz != 0); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 299 | |
| 300 | freq_table[freq_cnt].index = freq_cnt; |
| 301 | freq_table[freq_cnt].frequency = CPUFREQ_TABLE_END; |
| 302 | |
| 303 | pr_info("CPU: %d scaling frequencies supported.\n", freq_cnt); |
| 304 | |
| 305 | /* Register table with CPUFreq. */ |
| 306 | for_each_possible_cpu(i) |
| 307 | cpufreq_frequency_table_get_attr(freq_table, i); |
| 308 | } |
| 309 | #else |
| 310 | static void __init cpufreq_table_init(void) {} |
| 311 | #endif |
| 312 | |
| 313 | static struct acpuclk_data acpuclk_cortex_data = { |
| 314 | .set_rate = acpuclk_cortex_set_rate, |
| 315 | .get_rate = acpuclk_cortex_get_rate, |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 316 | }; |
| 317 | |
| 318 | int __init acpuclk_cortex_init(struct platform_device *pdev, |
| 319 | struct acpuclk_drv_data *data) |
| 320 | { |
| 321 | unsigned long max_cpu_khz = 0; |
| 322 | int i, rc; |
| 323 | |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 324 | priv = data; |
| 325 | mutex_init(&priv->lock); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 326 | |
Patrick Daly | af8808e | 2013-03-20 12:57:00 -0700 | [diff] [blame] | 327 | acpuclk_cortex_data.power_collapse_khz = priv->wait_for_irq_khz; |
| 328 | acpuclk_cortex_data.wait_for_irq_khz = priv->wait_for_irq_khz; |
| 329 | |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 330 | bus_perf_client = msm_bus_scale_register_client(priv->bus_scale); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 331 | if (!bus_perf_client) { |
| 332 | pr_err("Unable to register bus client\n"); |
| 333 | BUG(); |
| 334 | } |
| 335 | |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 336 | /* Improve boot time by ramping up CPU immediately */ |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 337 | for (i = 0; priv->freq_tbl[i].khz != 0; i++) |
| 338 | if (priv->freq_tbl[i].use_for_scaling) |
| 339 | max_cpu_khz = priv->freq_tbl[i].khz; |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 340 | |
| 341 | /* Initialize regulators */ |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 342 | rc = increase_vdd(priv->vdd_max_cpu, priv->vdd_max_mem); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 343 | if (rc) |
| 344 | goto err_vdd; |
| 345 | |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 346 | rc = regulator_enable(priv->vdd_mem); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 347 | if (rc) { |
| 348 | dev_err(&pdev->dev, "regulator_enable for mem failed\n"); |
| 349 | goto err_vdd; |
| 350 | } |
| 351 | |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 352 | rc = regulator_enable(priv->vdd_cpu); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 353 | if (rc) { |
| 354 | dev_err(&pdev->dev, "regulator_enable for cpu failed\n"); |
| 355 | goto err_vdd_cpu; |
| 356 | } |
| 357 | |
Patrick Daly | 71839d4 | 2013-02-25 13:05:05 -0800 | [diff] [blame] | 358 | /* |
| 359 | * Select a state which is always a valid transition to align SW with |
| 360 | * the HW configuration set by the bootloaders. |
| 361 | */ |
| 362 | acpuclk_cortex_set_rate(0, acpuclk_cortex_data.power_collapse_khz, |
| 363 | SETRATE_INIT); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 364 | acpuclk_cortex_set_rate(0, max_cpu_khz, SETRATE_INIT); |
| 365 | |
| 366 | acpuclk_register(&acpuclk_cortex_data); |
| 367 | cpufreq_table_init(); |
| 368 | |
| 369 | return 0; |
| 370 | |
| 371 | err_vdd_cpu: |
Patrick Daly | 9196ed4 | 2013-03-13 15:59:03 -0700 | [diff] [blame] | 372 | regulator_disable(priv->vdd_mem); |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 373 | err_vdd: |
Patrick Daly | 985c14b | 2012-12-03 17:12:37 -0800 | [diff] [blame] | 374 | return rc; |
| 375 | } |