Matt Wagantall | d1af38e | 2011-08-06 01:38:02 -0700 | [diff] [blame] | 1 | /* |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * MSM architecture clock driver |
| 3 | * |
| 4 | * Copyright (C) 2007 Google, Inc. |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 5 | * Copyright (c) 2007-2012, Code Aurora Forum. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6 | * Author: San Mehat <san@android.com> |
| 7 | * |
| 8 | * This software is licensed under the terms of the GNU General Public |
| 9 | * License version 2, as published by the Free Software Foundation, and |
| 10 | * may be copied, distributed, and modified under those terms. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | */ |
| 18 | |
| 19 | #include <linux/version.h> |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/errno.h> |
| 23 | #include <linux/string.h> |
| 24 | #include <linux/delay.h> |
| 25 | #include <linux/clk.h> |
| 26 | #include <linux/cpufreq.h> |
| 27 | #include <linux/mutex.h> |
| 28 | #include <linux/io.h> |
| 29 | #include <linux/sort.h> |
| 30 | #include <linux/remote_spinlock.h> |
| 31 | #include <mach/board.h> |
| 32 | #include <mach/msm_iomap.h> |
| 33 | #include <asm/mach-types.h> |
| 34 | #include <mach/socinfo.h> |
| 35 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 36 | #include "smd_private.h" |
| 37 | #include "acpuclock.h" |
| 38 | |
| 39 | #define A11S_CLK_CNTL_ADDR (MSM_CSR_BASE + 0x100) |
| 40 | #define A11S_CLK_SEL_ADDR (MSM_CSR_BASE + 0x104) |
| 41 | #define A11S_VDD_SVS_PLEVEL_ADDR (MSM_CSR_BASE + 0x124) |
| 42 | #define PLLn_MODE(n) (MSM_CLK_CTL_BASE + 0x300 + 28 * (n)) |
| 43 | #define PLLn_L_VAL(n) (MSM_CLK_CTL_BASE + 0x304 + 28 * (n)) |
| 44 | |
| 45 | #define PLL4_MODE (MSM_CLK_CTL_BASE + 0x374) |
| 46 | #define PLL4_L_VAL (MSM_CLK_CTL_BASE + 0x378) |
| 47 | |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 48 | #define POWER_COLLAPSE_KHZ 19200 |
| 49 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 50 | /* Max CPU frequency allowed by hardware while in standby waiting for an irq. */ |
| 51 | #define MAX_WAIT_FOR_IRQ_KHZ 128000 |
| 52 | |
| 53 | enum { |
| 54 | ACPU_PLL_TCXO = -1, |
| 55 | ACPU_PLL_0 = 0, |
| 56 | ACPU_PLL_1, |
| 57 | ACPU_PLL_2, |
| 58 | ACPU_PLL_3, |
| 59 | ACPU_PLL_4, |
| 60 | ACPU_PLL_END, |
| 61 | }; |
| 62 | |
| 63 | static const struct pll { |
| 64 | void __iomem *mod_reg; |
| 65 | const uint32_t l_val_mask; |
| 66 | } soc_pll[ACPU_PLL_END] = { |
| 67 | [ACPU_PLL_0] = {PLLn_MODE(ACPU_PLL_0), 0x3f}, |
| 68 | [ACPU_PLL_1] = {PLLn_MODE(ACPU_PLL_1), 0x3f}, |
| 69 | [ACPU_PLL_2] = {PLLn_MODE(ACPU_PLL_2), 0x3f}, |
| 70 | [ACPU_PLL_3] = {PLLn_MODE(ACPU_PLL_3), 0x3f}, |
| 71 | [ACPU_PLL_4] = {PLL4_MODE, 0x3ff}, |
| 72 | }; |
| 73 | |
| 74 | struct clock_state { |
| 75 | struct clkctl_acpu_speed *current_speed; |
| 76 | struct mutex lock; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 77 | uint32_t max_speed_delta_khz; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 78 | struct clk *ebi1_clk; |
| 79 | }; |
| 80 | |
| 81 | #define PLL_BASE 7 |
| 82 | |
| 83 | struct shared_pll_control { |
| 84 | uint32_t version; |
| 85 | struct { |
| 86 | /* Denotes if the PLL is ON. Technically, this can be read |
| 87 | * directly from the PLL registers, but this feild is here, |
| 88 | * so let's use it. |
| 89 | */ |
| 90 | uint32_t on; |
| 91 | /* One bit for each processor core. The application processor |
| 92 | * is allocated bit position 1. All other bits should be |
| 93 | * considered as votes from other processors. |
| 94 | */ |
| 95 | uint32_t votes; |
| 96 | } pll[PLL_BASE + ACPU_PLL_END]; |
| 97 | }; |
| 98 | |
| 99 | struct clkctl_acpu_speed { |
| 100 | unsigned int use_for_scaling; |
| 101 | unsigned int a11clk_khz; |
| 102 | int pll; |
| 103 | unsigned int a11clk_src_sel; |
| 104 | unsigned int a11clk_src_div; |
| 105 | unsigned int ahbclk_khz; |
| 106 | unsigned int ahbclk_div; |
| 107 | int vdd; |
| 108 | unsigned int axiclk_khz; |
| 109 | unsigned long lpj; /* loops_per_jiffy */ |
| 110 | /* Pointers in acpu_freq_tbl[] for max up/down steppings. */ |
| 111 | struct clkctl_acpu_speed *down[ACPU_PLL_END]; |
| 112 | struct clkctl_acpu_speed *up[ACPU_PLL_END]; |
| 113 | }; |
| 114 | |
| 115 | static remote_spinlock_t pll_lock; |
| 116 | static struct shared_pll_control *pll_control; |
| 117 | static struct clock_state drv_state = { 0 }; |
| 118 | static struct clkctl_acpu_speed *acpu_freq_tbl; |
| 119 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 120 | /* |
| 121 | * ACPU freq tables used for different PLLs frequency combinations. The |
| 122 | * correct table is selected during init. |
| 123 | * |
| 124 | * Table stepping up/down entries are calculated during boot to choose the |
| 125 | * largest frequency jump that's less than max_speed_delta_khz on each PLL. |
| 126 | */ |
| 127 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 128 | /* 7627 with GSM capable modem */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 129 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_pll4_0[] = { |
| 130 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 30720 }, |
| 131 | { 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 61440 }, |
| 132 | { 1, 122880, ACPU_PLL_1, 1, 1, 61440, 1, 3, 61440 }, |
| 133 | { 0, 200000, ACPU_PLL_2, 2, 5, 66667, 2, 4, 61440 }, |
| 134 | { 1, 245760, ACPU_PLL_1, 1, 0, 122880, 1, 4, 61440 }, |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 135 | { 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 160000 }, |
| 136 | { 0, 400000, ACPU_PLL_2, 2, 2, 133333, 2, 5, 160000 }, |
| 137 | { 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 6, 160000 }, |
| 138 | { 1, 600000, ACPU_PLL_2, 2, 1, 200000, 2, 7, 200000 }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 139 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 140 | }; |
| 141 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 142 | /* 7627 with CDMA capable modem */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 143 | static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_1200_pll4_0[] = { |
| 144 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 24576 }, |
| 145 | { 1, 98304, ACPU_PLL_1, 1, 1, 98304, 0, 3, 49152 }, |
| 146 | { 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 49152 }, |
| 147 | { 1, 196608, ACPU_PLL_1, 1, 0, 65536, 2, 4, 98304 }, |
| 148 | { 0, 200000, ACPU_PLL_2, 2, 5, 66667, 2, 4, 98304 }, |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 149 | { 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 160000 }, |
| 150 | { 0, 400000, ACPU_PLL_2, 2, 2, 133333, 2, 5, 160000 }, |
| 151 | { 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 6, 160000 }, |
| 152 | { 1, 600000, ACPU_PLL_2, 2, 1, 200000, 2, 7, 200000 }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 153 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 154 | }; |
| 155 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 156 | /* 7627 with GSM capable modem - PLL2 @ 800 */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 157 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_800_pll4_0[] = { |
| 158 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 30720 }, |
| 159 | { 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 61440 }, |
| 160 | { 1, 122880, ACPU_PLL_1, 1, 1, 61440, 1, 3, 61440 }, |
| 161 | { 0, 200000, ACPU_PLL_2, 2, 3, 66667, 2, 4, 61440 }, |
| 162 | { 1, 245760, ACPU_PLL_1, 1, 0, 122880, 1, 4, 61440 }, |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 163 | { 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 160000 }, |
| 164 | { 0, 400000, ACPU_PLL_2, 2, 1, 133333, 2, 5, 160000 }, |
| 165 | { 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 6, 160000 }, |
| 166 | { 1, 800000, ACPU_PLL_2, 2, 0, 200000, 3, 7, 200000 }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 167 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 168 | }; |
| 169 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 170 | /* 7627 with CDMA capable modem - PLL2 @ 800 */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 171 | static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_800_pll4_0[] = { |
| 172 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 24576 }, |
| 173 | { 1, 98304, ACPU_PLL_1, 1, 1, 98304, 0, 3, 49152 }, |
| 174 | { 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 49152 }, |
| 175 | { 1, 196608, ACPU_PLL_1, 1, 0, 65536, 2, 4, 98304 }, |
| 176 | { 0, 200000, ACPU_PLL_2, 2, 3, 66667, 2, 4, 98304 }, |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 177 | { 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 160000 }, |
| 178 | { 0, 400000, ACPU_PLL_2, 2, 1, 133333, 2, 5, 160000 }, |
| 179 | { 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 6, 160000 }, |
| 180 | { 1, 800000, ACPU_PLL_2, 2, 0, 200000, 3, 7, 200000 }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 181 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 182 | }; |
| 183 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 184 | /* 7627a PLL2 @ 1200MHz with GSM capable modem */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 185 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_pll4_800[] = { |
Trilok Soni | 7d6c865 | 2011-07-14 15:35:07 +0530 | [diff] [blame] | 186 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 187 | { 0, 61440, ACPU_PLL_1, 1, 3, 7680, 3, 1, 61440 }, |
| 188 | { 1, 122880, ACPU_PLL_1, 1, 1, 15360, 3, 2, 61440 }, |
| 189 | { 1, 245760, ACPU_PLL_1, 1, 0, 30720, 3, 3, 61440 }, |
| 190 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 150000 }, |
| 191 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
| 192 | { 0, 400000, ACPU_PLL_4, 6, 1, 50000, 3, 4, 122880 }, |
| 193 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
| 194 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 }, |
| 195 | { 1, 800000, ACPU_PLL_4, 6, 0, 100000, 3, 7, 200000 }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 196 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 197 | }; |
| 198 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 199 | /* 7627a PLL2 @ 1200MHz with CDMA capable modem */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 200 | static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_1200_pll4_800[] = { |
Trilok Soni | 7d6c865 | 2011-07-14 15:35:07 +0530 | [diff] [blame] | 201 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
| 202 | { 0, 65536, ACPU_PLL_1, 1, 3, 8192, 3, 1, 49152 }, |
| 203 | { 1, 98304, ACPU_PLL_1, 1, 1, 12288, 3, 2, 49152 }, |
| 204 | { 1, 196608, ACPU_PLL_1, 1, 0, 24576, 3, 3, 98304 }, |
Trilok Soni | abb750b | 2011-07-13 16:47:18 +0530 | [diff] [blame] | 205 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 120000 }, |
| 206 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 120000 }, |
| 207 | { 0, 400000, ACPU_PLL_4, 6, 1, 50000, 3, 4, 120000 }, |
| 208 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 120000 }, |
Trilok Soni | 7d6c865 | 2011-07-14 15:35:07 +0530 | [diff] [blame] | 209 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 }, |
| 210 | { 1, 800000, ACPU_PLL_4, 6, 0, 100000, 3, 7, 200000 }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 211 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 212 | }; |
| 213 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 214 | /* 7627aa PLL4 @ 1008MHz with GSM capable modem */ |
Trilok Soni | f597e24 | 2011-06-06 12:37:16 +0530 | [diff] [blame] | 215 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_pll4_1008[] = { |
| 216 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 217 | { 0, 61440, ACPU_PLL_1, 1, 3, 7680, 3, 1, 61440 }, |
| 218 | { 1, 122880, ACPU_PLL_1, 1, 1, 15360, 3, 2, 61440 }, |
| 219 | { 1, 245760, ACPU_PLL_1, 1, 0, 30720, 3, 3, 61440 }, |
| 220 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 150000 }, |
| 221 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
| 222 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
| 223 | { 0, 504000, ACPU_PLL_4, 6, 1, 63000, 3, 6, 200000 }, |
| 224 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 }, |
| 225 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 7, 200000}, |
| 226 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 227 | }; |
| 228 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 229 | /* 7627aa PLL4 @ 1008MHz with CDMA capable modem */ |
Trilok Soni | d7b05e5 | 2011-08-17 18:09:08 +0530 | [diff] [blame] | 230 | static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_1200_pll4_1008[] = { |
| 231 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
| 232 | { 0, 65536, ACPU_PLL_1, 1, 3, 8192, 3, 1, 49152 }, |
| 233 | { 1, 98304, ACPU_PLL_1, 1, 1, 12288, 3, 2, 49152 }, |
| 234 | { 1, 196608, ACPU_PLL_1, 1, 0, 24576, 3, 3, 98304 }, |
| 235 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 150000 }, |
| 236 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
| 237 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
| 238 | { 0, 504000, ACPU_PLL_4, 6, 1, 63000, 3, 6, 200000 }, |
| 239 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 }, |
| 240 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 7, 200000}, |
| 241 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 242 | }; |
| 243 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 244 | /* 7625a PLL2 @ 1200MHz with GSM capable modem */ |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 245 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_25a[] = { |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 246 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 247 | { 0, 61440, ACPU_PLL_1, 1, 3, 7680, 3, 1, 61440 }, |
| 248 | { 1, 122880, ACPU_PLL_1, 1, 1, 15360, 3, 2, 61440 }, |
| 249 | { 1, 245760, ACPU_PLL_1, 1, 0, 30720, 3, 3, 61440 }, |
| 250 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 150000 }, |
| 251 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 252 | { 0, 400000, ACPU_PLL_2, 2, 2, 50000, 3, 4, 122880 }, |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 253 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
| 254 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 }, |
| 255 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 256 | }; |
| 257 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 258 | /* 7627a PLL2 @ 1200MHz with GSM capable modem */ |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 259 | static struct clkctl_acpu_speed pll0_960_pll1_737_pll2_1200_pll4_800[] = { |
| 260 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 261 | { 0, 61440, ACPU_PLL_1, 1, 11, 7680, 3, 1, 61440 }, |
| 262 | { 1, 122880, ACPU_PLL_1, 1, 5, 15360, 3, 2, 61440 }, |
| 263 | { 1, 245760, ACPU_PLL_1, 1, 2, 30720, 3, 3, 61440 }, |
| 264 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 150000 }, |
| 265 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
| 266 | { 0, 400000, ACPU_PLL_4, 6, 1, 50000, 3, 4, 122880 }, |
| 267 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
| 268 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 }, |
| 269 | { 1, 800000, ACPU_PLL_4, 6, 0, 100000, 3, 7, 200000 }, |
| 270 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 271 | }; |
| 272 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 273 | /* 7627a PLL2 @ 1200MHz with CDMA capable modem */ |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 274 | static struct clkctl_acpu_speed pll0_960_pll1_589_pll2_1200_pll4_800[] = { |
| 275 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
| 276 | { 0, 65536, ACPU_PLL_1, 1, 8, 8192, 3, 1, 49152 }, |
| 277 | { 1, 98304, ACPU_PLL_1, 1, 5, 12288, 3, 2, 49152 }, |
| 278 | { 1, 196608, ACPU_PLL_1, 1, 2, 24576, 3, 3, 98304 }, |
| 279 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 120000 }, |
| 280 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 120000 }, |
| 281 | { 0, 400000, ACPU_PLL_4, 6, 1, 50000, 3, 4, 120000 }, |
| 282 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 120000 }, |
| 283 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 }, |
| 284 | { 1, 800000, ACPU_PLL_4, 6, 0, 100000, 3, 7, 200000 }, |
| 285 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 286 | }; |
| 287 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 288 | /* 7627aa PLL4 @ 1008MHz with GSM capable modem */ |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 289 | static struct clkctl_acpu_speed pll0_960_pll1_737_pll2_1200_pll4_1008[] = { |
| 290 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 291 | { 0, 61440, ACPU_PLL_1, 1, 11, 7680, 3, 1, 61440 }, |
| 292 | { 1, 122880, ACPU_PLL_1, 1, 5, 15360, 3, 2, 61440 }, |
| 293 | { 1, 245760, ACPU_PLL_1, 1, 2, 30720, 3, 3, 61440 }, |
| 294 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 150000 }, |
| 295 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
| 296 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
| 297 | { 0, 504000, ACPU_PLL_4, 6, 1, 63000, 3, 6, 200000 }, |
| 298 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 }, |
| 299 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 7, 200000}, |
| 300 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 301 | }; |
| 302 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 303 | /* 7x27aa PLL4 @ 1008MHz with CDMA capable modem */ |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 304 | static struct clkctl_acpu_speed pll0_960_pll1_589_pll2_1200_pll4_1008[] = { |
| 305 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
| 306 | { 0, 65536, ACPU_PLL_1, 1, 8, 8192, 3, 1, 49152 }, |
| 307 | { 1, 98304, ACPU_PLL_1, 1, 5, 12288, 3, 2, 49152 }, |
| 308 | { 1, 196608, ACPU_PLL_1, 1, 2, 24576, 3, 3, 98304 }, |
| 309 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 150000 }, |
| 310 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
| 311 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
| 312 | { 0, 504000, ACPU_PLL_4, 6, 1, 63000, 3, 6, 200000 }, |
| 313 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 }, |
| 314 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 7, 200000}, |
| 315 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 316 | }; |
| 317 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 318 | /* 7x25a PLL2 @ 1200MHz with GSM capable modem */ |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 319 | static struct clkctl_acpu_speed pll0_960_pll1_737_pll2_1200_25a[] = { |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 320 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 321 | { 0, 61440, ACPU_PLL_1, 1, 11, 7680, 3, 1, 61440 }, |
| 322 | { 1, 122880, ACPU_PLL_1, 1, 5, 15360, 3, 2, 61440 }, |
| 323 | { 1, 245760, ACPU_PLL_1, 1, 2, 30720, 3, 3, 61440 }, |
| 324 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 150000 }, |
| 325 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 326 | { 0, 400000, ACPU_PLL_2, 2, 2, 50000, 3, 4, 122880 }, |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 327 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
| 328 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 }, |
| 329 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} } |
| 330 | }; |
| 331 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 332 | #define PLL_0_MHZ 0 |
| 333 | #define PLL_196_MHZ 10 |
| 334 | #define PLL_245_MHZ 12 |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 335 | #define PLL_589_MHZ 30 |
| 336 | #define PLL_737_MHZ 38 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 337 | #define PLL_800_MHZ 41 |
| 338 | #define PLL_960_MHZ 50 |
Trilok Soni | f597e24 | 2011-06-06 12:37:16 +0530 | [diff] [blame] | 339 | #define PLL_1008_MHZ 52 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 340 | #define PLL_1200_MHZ 62 |
| 341 | |
| 342 | #define PLL_CONFIG(m0, m1, m2, m4) { \ |
| 343 | PLL_##m0##_MHZ, PLL_##m1##_MHZ, PLL_##m2##_MHZ, PLL_##m4##_MHZ, \ |
| 344 | pll0_##m0##_pll1_##m1##_pll2_##m2##_pll4_##m4 \ |
| 345 | } |
| 346 | |
| 347 | struct pll_freq_tbl_map { |
| 348 | unsigned int pll0_l; |
| 349 | unsigned int pll1_l; |
| 350 | unsigned int pll2_l; |
| 351 | unsigned int pll4_l; |
| 352 | struct clkctl_acpu_speed *tbl; |
| 353 | }; |
| 354 | |
| 355 | static struct pll_freq_tbl_map acpu_freq_tbl_list[] = { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 356 | PLL_CONFIG(960, 196, 1200, 0), |
| 357 | PLL_CONFIG(960, 245, 1200, 0), |
| 358 | PLL_CONFIG(960, 196, 800, 0), |
| 359 | PLL_CONFIG(960, 245, 800, 0), |
| 360 | PLL_CONFIG(960, 245, 1200, 800), |
| 361 | PLL_CONFIG(960, 196, 1200, 800), |
Trilok Soni | f597e24 | 2011-06-06 12:37:16 +0530 | [diff] [blame] | 362 | PLL_CONFIG(960, 245, 1200, 1008), |
Trilok Soni | d7b05e5 | 2011-08-17 18:09:08 +0530 | [diff] [blame] | 363 | PLL_CONFIG(960, 196, 1200, 1008), |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 364 | PLL_CONFIG(960, 737, 1200, 800), |
| 365 | PLL_CONFIG(960, 589, 1200, 800), |
| 366 | PLL_CONFIG(960, 737, 1200, 1008), |
| 367 | PLL_CONFIG(960, 589, 1200, 1008), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 368 | { 0, 0, 0, 0, 0 } |
| 369 | }; |
| 370 | |
| 371 | #ifdef CONFIG_CPU_FREQ_MSM |
Pankaj Kumar | 873bc7a | 2011-12-21 17:25:44 +0530 | [diff] [blame] | 372 | static struct cpufreq_frequency_table freq_table[NR_CPUS][20]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 373 | |
| 374 | static void __init cpufreq_table_init(void) |
| 375 | { |
Pankaj Kumar | 873bc7a | 2011-12-21 17:25:44 +0530 | [diff] [blame] | 376 | int cpu; |
| 377 | for_each_possible_cpu(cpu) { |
| 378 | unsigned int i, freq_cnt = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 379 | |
Pankaj Kumar | 873bc7a | 2011-12-21 17:25:44 +0530 | [diff] [blame] | 380 | /* Construct the freq_table table from acpu_freq_tbl since |
| 381 | * the freq_table values need to match frequencies specified |
| 382 | * in acpu_freq_tbl and acpu_freq_tbl needs to be fixed up |
| 383 | * during init. |
| 384 | */ |
| 385 | for (i = 0; acpu_freq_tbl[i].a11clk_khz != 0 |
| 386 | && freq_cnt < ARRAY_SIZE(*freq_table)-1; i++) { |
| 387 | if (acpu_freq_tbl[i].use_for_scaling) { |
| 388 | freq_table[cpu][freq_cnt].index = freq_cnt; |
| 389 | freq_table[cpu][freq_cnt].frequency |
| 390 | = acpu_freq_tbl[i].a11clk_khz; |
| 391 | freq_cnt++; |
| 392 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 393 | } |
Pankaj Kumar | 873bc7a | 2011-12-21 17:25:44 +0530 | [diff] [blame] | 394 | |
| 395 | /* freq_table not big enough to store all usable freqs. */ |
| 396 | BUG_ON(acpu_freq_tbl[i].a11clk_khz != 0); |
| 397 | |
| 398 | freq_table[cpu][freq_cnt].index = freq_cnt; |
| 399 | freq_table[cpu][freq_cnt].frequency = CPUFREQ_TABLE_END; |
| 400 | /* Register table with CPUFreq. */ |
| 401 | cpufreq_frequency_table_get_attr(freq_table[cpu], cpu); |
| 402 | pr_info("CPU%d: %d scaling frequencies supported.\n", |
| 403 | cpu, freq_cnt); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 404 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 405 | } |
| 406 | #endif |
| 407 | |
| 408 | static void pll_enable(void __iomem *addr, unsigned on) |
| 409 | { |
| 410 | if (on) { |
| 411 | writel_relaxed(2, addr); |
| 412 | mb(); |
| 413 | udelay(5); |
| 414 | writel_relaxed(6, addr); |
| 415 | mb(); |
| 416 | udelay(50); |
| 417 | writel_relaxed(7, addr); |
| 418 | } else { |
| 419 | writel_relaxed(0, addr); |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | static int pc_pll_request(unsigned id, unsigned on) |
| 424 | { |
| 425 | int res = 0; |
| 426 | on = !!on; |
| 427 | |
| 428 | if (on) |
| 429 | pr_debug("Enabling PLL %d\n", id); |
| 430 | else |
| 431 | pr_debug("Disabling PLL %d\n", id); |
| 432 | |
| 433 | if (id >= ACPU_PLL_END) |
| 434 | return -EINVAL; |
| 435 | |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 436 | remote_spin_lock(&pll_lock); |
| 437 | if (on) { |
| 438 | pll_control->pll[PLL_BASE + id].votes |= 2; |
| 439 | if (!pll_control->pll[PLL_BASE + id].on) { |
| 440 | pll_enable(soc_pll[id].mod_reg, 1); |
| 441 | pll_control->pll[PLL_BASE + id].on = 1; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 442 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 443 | } else { |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 444 | pll_control->pll[PLL_BASE + id].votes &= ~2; |
| 445 | if (pll_control->pll[PLL_BASE + id].on |
| 446 | && !pll_control->pll[PLL_BASE + id].votes) { |
| 447 | pll_enable(soc_pll[id].mod_reg, 0); |
| 448 | pll_control->pll[PLL_BASE + id].on = 0; |
| 449 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 450 | } |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 451 | remote_spin_unlock(&pll_lock); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 452 | |
| 453 | if (on) |
| 454 | pr_debug("PLL enabled\n"); |
| 455 | else |
| 456 | pr_debug("PLL disabled\n"); |
| 457 | |
| 458 | return res; |
| 459 | } |
| 460 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 461 | static int acpuclk_set_vdd_level(int vdd) |
| 462 | { |
| 463 | uint32_t current_vdd; |
| 464 | |
Pankaj Kumar | 9406a3b | 2011-12-23 18:07:15 +0530 | [diff] [blame] | 465 | /* |
| 466 | * NOTE: v1.0 of 7x27a/7x25a chip doesn't have working |
| 467 | * VDD switching support. |
| 468 | */ |
| 469 | if ((cpu_is_msm7x27a() || cpu_is_msm7x25a()) && |
| 470 | (SOCINFO_VERSION_MINOR(socinfo_get_version()) < 1)) |
| 471 | return 0; |
| 472 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 473 | current_vdd = readl_relaxed(A11S_VDD_SVS_PLEVEL_ADDR) & 0x07; |
| 474 | |
| 475 | pr_debug("Switching VDD from %u mV -> %d mV\n", |
| 476 | current_vdd, vdd); |
| 477 | |
| 478 | writel_relaxed((1 << 7) | (vdd << 3), A11S_VDD_SVS_PLEVEL_ADDR); |
| 479 | mb(); |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 480 | udelay(62); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 481 | if ((readl_relaxed(A11S_VDD_SVS_PLEVEL_ADDR) & 0x7) != vdd) { |
| 482 | pr_err("VDD set failed\n"); |
| 483 | return -EIO; |
| 484 | } |
| 485 | |
| 486 | pr_debug("VDD switched\n"); |
| 487 | |
| 488 | return 0; |
| 489 | } |
| 490 | |
| 491 | /* Set proper dividers for the given clock speed. */ |
| 492 | static void acpuclk_set_div(const struct clkctl_acpu_speed *hunt_s) |
| 493 | { |
| 494 | uint32_t reg_clkctl, reg_clksel, clk_div, src_sel; |
| 495 | |
| 496 | reg_clksel = readl_relaxed(A11S_CLK_SEL_ADDR); |
| 497 | |
| 498 | /* AHB_CLK_DIV */ |
| 499 | clk_div = (reg_clksel >> 1) & 0x03; |
| 500 | /* CLK_SEL_SRC1NO */ |
| 501 | src_sel = reg_clksel & 1; |
| 502 | |
| 503 | /* |
| 504 | * If the new clock divider is higher than the previous, then |
| 505 | * program the divider before switching the clock |
| 506 | */ |
| 507 | if (hunt_s->ahbclk_div > clk_div) { |
| 508 | reg_clksel &= ~(0x3 << 1); |
| 509 | reg_clksel |= (hunt_s->ahbclk_div << 1); |
| 510 | writel_relaxed(reg_clksel, A11S_CLK_SEL_ADDR); |
| 511 | } |
| 512 | |
| 513 | /* Program clock source and divider */ |
| 514 | reg_clkctl = readl_relaxed(A11S_CLK_CNTL_ADDR); |
| 515 | reg_clkctl &= ~(0xFF << (8 * src_sel)); |
| 516 | reg_clkctl |= hunt_s->a11clk_src_sel << (4 + 8 * src_sel); |
| 517 | reg_clkctl |= hunt_s->a11clk_src_div << (0 + 8 * src_sel); |
| 518 | writel_relaxed(reg_clkctl, A11S_CLK_CNTL_ADDR); |
| 519 | |
| 520 | /* Program clock source selection */ |
| 521 | reg_clksel ^= 1; |
| 522 | writel_relaxed(reg_clksel, A11S_CLK_SEL_ADDR); |
| 523 | |
| 524 | /* |
| 525 | * If the new clock divider is lower than the previous, then |
| 526 | * program the divider after switching the clock |
| 527 | */ |
| 528 | if (hunt_s->ahbclk_div < clk_div) { |
| 529 | reg_clksel &= ~(0x3 << 1); |
| 530 | reg_clksel |= (hunt_s->ahbclk_div << 1); |
| 531 | writel_relaxed(reg_clksel, A11S_CLK_SEL_ADDR); |
| 532 | } |
| 533 | } |
| 534 | |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 535 | static int acpuclk_7627_set_rate(int cpu, unsigned long rate, |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 536 | enum setrate_reason reason) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 537 | { |
| 538 | uint32_t reg_clkctl; |
| 539 | struct clkctl_acpu_speed *cur_s, *tgt_s, *strt_s; |
| 540 | int res, rc = 0; |
| 541 | unsigned int plls_enabled = 0, pll; |
| 542 | |
| 543 | if (reason == SETRATE_CPUFREQ) |
| 544 | mutex_lock(&drv_state.lock); |
| 545 | |
| 546 | strt_s = cur_s = drv_state.current_speed; |
| 547 | |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 548 | WARN_ONCE(cur_s == NULL, "%s: not initialized\n", __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 549 | if (cur_s == NULL) { |
| 550 | rc = -ENOENT; |
| 551 | goto out; |
| 552 | } |
| 553 | |
| 554 | if (rate == cur_s->a11clk_khz) |
| 555 | goto out; |
| 556 | |
| 557 | for (tgt_s = acpu_freq_tbl; tgt_s->a11clk_khz != 0; tgt_s++) { |
| 558 | if (tgt_s->a11clk_khz == rate) |
| 559 | break; |
| 560 | } |
| 561 | |
| 562 | if (tgt_s->a11clk_khz == 0) { |
| 563 | rc = -EINVAL; |
| 564 | goto out; |
| 565 | } |
| 566 | |
| 567 | /* Choose the highest speed at or below 'rate' with same PLL. */ |
| 568 | if (reason != SETRATE_CPUFREQ |
| 569 | && tgt_s->a11clk_khz < cur_s->a11clk_khz) { |
| 570 | while (tgt_s->pll != ACPU_PLL_TCXO && tgt_s->pll != cur_s->pll) |
| 571 | tgt_s--; |
| 572 | } |
| 573 | |
| 574 | if (strt_s->pll != ACPU_PLL_TCXO) |
| 575 | plls_enabled |= 1 << strt_s->pll; |
| 576 | |
| 577 | if (reason == SETRATE_CPUFREQ) { |
| 578 | if (strt_s->pll != tgt_s->pll && tgt_s->pll != ACPU_PLL_TCXO) { |
| 579 | rc = pc_pll_request(tgt_s->pll, 1); |
| 580 | if (rc < 0) { |
| 581 | pr_err("PLL%d enable failed (%d)\n", |
| 582 | tgt_s->pll, rc); |
| 583 | goto out; |
| 584 | } |
| 585 | plls_enabled |= 1 << tgt_s->pll; |
| 586 | } |
| 587 | } |
| 588 | /* Need to do this when coming out of power collapse since some modem |
| 589 | * firmwares reset the VDD when the application processor enters power |
| 590 | * collapse. */ |
| 591 | if (reason == SETRATE_CPUFREQ || reason == SETRATE_PC) { |
| 592 | /* Increase VDD if needed. */ |
| 593 | if (tgt_s->vdd > cur_s->vdd) { |
| 594 | rc = acpuclk_set_vdd_level(tgt_s->vdd); |
| 595 | if (rc < 0) { |
| 596 | pr_err("Unable to switch ACPU vdd (%d)\n", rc); |
| 597 | goto out; |
| 598 | } |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | /* Set wait states for CPU inbetween frequency changes */ |
| 603 | reg_clkctl = readl_relaxed(A11S_CLK_CNTL_ADDR); |
| 604 | reg_clkctl |= (100 << 16); /* set WT_ST_CNT */ |
| 605 | writel_relaxed(reg_clkctl, A11S_CLK_CNTL_ADDR); |
| 606 | |
| 607 | pr_debug("Switching from ACPU rate %u KHz -> %u KHz\n", |
| 608 | strt_s->a11clk_khz, tgt_s->a11clk_khz); |
| 609 | |
| 610 | while (cur_s != tgt_s) { |
| 611 | /* |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 612 | * Always jump to target freq if within max_speed_delta_khz, |
| 613 | * regardless of PLL. If differnece is greater, use the |
| 614 | * predefined steppings in the table. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 615 | */ |
| 616 | int d = abs((int)(cur_s->a11clk_khz - tgt_s->a11clk_khz)); |
| 617 | if (d > drv_state.max_speed_delta_khz) { |
| 618 | |
| 619 | if (tgt_s->a11clk_khz > cur_s->a11clk_khz) { |
| 620 | /* Step up: jump to target PLL as early as |
| 621 | * possible so indexing using TCXO (up[-1]) |
| 622 | * never occurs. */ |
| 623 | if (likely(cur_s->up[tgt_s->pll])) |
| 624 | cur_s = cur_s->up[tgt_s->pll]; |
| 625 | else |
| 626 | cur_s = cur_s->up[cur_s->pll]; |
| 627 | } else { |
| 628 | /* Step down: stay on current PLL as long as |
| 629 | * possible so indexing using TCXO (down[-1]) |
| 630 | * never occurs. */ |
| 631 | if (likely(cur_s->down[cur_s->pll])) |
| 632 | cur_s = cur_s->down[cur_s->pll]; |
| 633 | else |
| 634 | cur_s = cur_s->down[tgt_s->pll]; |
| 635 | } |
| 636 | |
| 637 | if (cur_s == NULL) { /* This should not happen. */ |
| 638 | pr_err("No stepping frequencies found. " |
| 639 | "strt_s:%u tgt_s:%u\n", |
| 640 | strt_s->a11clk_khz, tgt_s->a11clk_khz); |
| 641 | rc = -EINVAL; |
| 642 | goto out; |
| 643 | } |
| 644 | |
| 645 | } else { |
| 646 | cur_s = tgt_s; |
| 647 | } |
| 648 | |
| 649 | pr_debug("STEP khz = %u, pll = %d\n", |
| 650 | cur_s->a11clk_khz, cur_s->pll); |
| 651 | |
| 652 | if (cur_s->pll != ACPU_PLL_TCXO |
| 653 | && !(plls_enabled & (1 << cur_s->pll))) { |
| 654 | rc = pc_pll_request(cur_s->pll, 1); |
| 655 | if (rc < 0) { |
| 656 | pr_err("PLL%d enable failed (%d)\n", |
| 657 | cur_s->pll, rc); |
| 658 | goto out; |
| 659 | } |
| 660 | plls_enabled |= 1 << cur_s->pll; |
| 661 | } |
| 662 | |
| 663 | acpuclk_set_div(cur_s); |
| 664 | drv_state.current_speed = cur_s; |
| 665 | /* Re-adjust lpj for the new clock speed. */ |
| 666 | loops_per_jiffy = cur_s->lpj; |
| 667 | mb(); |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 668 | udelay(50); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | /* Nothing else to do for SWFI. */ |
| 672 | if (reason == SETRATE_SWFI) |
| 673 | goto out; |
| 674 | |
| 675 | /* Change the AXI bus frequency if we can. */ |
| 676 | if (strt_s->axiclk_khz != tgt_s->axiclk_khz) { |
| 677 | res = clk_set_rate(drv_state.ebi1_clk, |
| 678 | tgt_s->axiclk_khz * 1000); |
| 679 | if (res < 0) |
| 680 | pr_warning("Setting AXI min rate failed (%d)\n", res); |
| 681 | } |
| 682 | |
| 683 | /* Disable PLLs we are not using anymore. */ |
| 684 | if (tgt_s->pll != ACPU_PLL_TCXO) |
| 685 | plls_enabled &= ~(1 << tgt_s->pll); |
| 686 | for (pll = ACPU_PLL_0; pll < ACPU_PLL_END; pll++) |
| 687 | if (plls_enabled & (1 << pll)) { |
| 688 | res = pc_pll_request(pll, 0); |
| 689 | if (res < 0) |
| 690 | pr_warning("PLL%d disable failed (%d)\n", |
| 691 | pll, res); |
| 692 | } |
| 693 | |
| 694 | /* Nothing else to do for power collapse. */ |
| 695 | if (reason == SETRATE_PC) |
| 696 | goto out; |
| 697 | |
| 698 | /* Drop VDD level if we can. */ |
| 699 | if (tgt_s->vdd < strt_s->vdd) { |
| 700 | res = acpuclk_set_vdd_level(tgt_s->vdd); |
| 701 | if (res < 0) |
| 702 | pr_warning("Unable to drop ACPU vdd (%d)\n", res); |
| 703 | } |
| 704 | |
| 705 | pr_debug("ACPU speed change complete\n"); |
| 706 | out: |
| 707 | if (reason == SETRATE_CPUFREQ) |
| 708 | mutex_unlock(&drv_state.lock); |
| 709 | return rc; |
| 710 | } |
| 711 | |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 712 | static void __init acpuclk_hw_init(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 713 | { |
| 714 | struct clkctl_acpu_speed *speed; |
Trilok Soni | 7d6c865 | 2011-07-14 15:35:07 +0530 | [diff] [blame] | 715 | uint32_t div, sel, reg_clksel; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 716 | int res; |
| 717 | |
| 718 | /* |
| 719 | * Determine the rate of ACPU clock |
| 720 | */ |
| 721 | |
| 722 | if (!(readl_relaxed(A11S_CLK_SEL_ADDR) & 0x01)) { /* CLK_SEL_SRC1N0 */ |
| 723 | /* CLK_SRC0_SEL */ |
| 724 | sel = (readl_relaxed(A11S_CLK_CNTL_ADDR) >> 12) & 0x7; |
| 725 | /* CLK_SRC0_DIV */ |
| 726 | div = (readl_relaxed(A11S_CLK_CNTL_ADDR) >> 8) & 0x0f; |
| 727 | } else { |
| 728 | /* CLK_SRC1_SEL */ |
| 729 | sel = (readl_relaxed(A11S_CLK_CNTL_ADDR) >> 4) & 0x07; |
| 730 | /* CLK_SRC1_DIV */ |
| 731 | div = readl_relaxed(A11S_CLK_CNTL_ADDR) & 0x0f; |
| 732 | } |
| 733 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 734 | for (speed = acpu_freq_tbl; speed->a11clk_khz != 0; speed++) { |
| 735 | if (speed->a11clk_src_sel == sel |
| 736 | && (speed->a11clk_src_div == div)) |
| 737 | break; |
| 738 | } |
| 739 | if (speed->a11clk_khz == 0) { |
| 740 | pr_err("Error - ACPU clock reports invalid speed\n"); |
| 741 | return; |
| 742 | } |
| 743 | |
| 744 | drv_state.current_speed = speed; |
| 745 | if (speed->pll != ACPU_PLL_TCXO) |
| 746 | if (pc_pll_request(speed->pll, 1)) |
| 747 | pr_warning("Failed to vote for boot PLL\n"); |
| 748 | |
Trilok Soni | 7d6c865 | 2011-07-14 15:35:07 +0530 | [diff] [blame] | 749 | /* Fix div2 to 2 for 7x27/5a(aa) targets */ |
| 750 | if (!cpu_is_msm7x27()) { |
| 751 | reg_clksel = readl_relaxed(A11S_CLK_SEL_ADDR); |
| 752 | reg_clksel &= ~(0x3 << 14); |
| 753 | reg_clksel |= (0x1 << 14); |
| 754 | writel_relaxed(reg_clksel, A11S_CLK_SEL_ADDR); |
| 755 | } |
| 756 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 757 | res = clk_set_rate(drv_state.ebi1_clk, speed->axiclk_khz * 1000); |
| 758 | if (res < 0) |
| 759 | pr_warning("Setting AXI min rate failed (%d)\n", res); |
Pankaj Kumar | 1909591 | 2012-01-11 18:09:13 +0530 | [diff] [blame^] | 760 | res = clk_prepare_enable(drv_state.ebi1_clk); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 761 | if (res < 0) |
| 762 | pr_warning("Enabling AXI clock failed (%d)\n", res); |
| 763 | |
| 764 | pr_info("ACPU running at %d KHz\n", speed->a11clk_khz); |
| 765 | } |
| 766 | |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 767 | static unsigned long acpuclk_7627_get_rate(int cpu) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 768 | { |
| 769 | WARN_ONCE(drv_state.current_speed == NULL, |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 770 | "%s: not initialized\n", __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 771 | if (drv_state.current_speed) |
| 772 | return drv_state.current_speed->a11clk_khz; |
| 773 | else |
| 774 | return 0; |
| 775 | } |
| 776 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 777 | /*---------------------------------------------------------------------------- |
| 778 | * Clock driver initialization |
| 779 | *---------------------------------------------------------------------------*/ |
| 780 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 781 | static void __init acpu_freq_tbl_fixup(void) |
| 782 | { |
| 783 | unsigned long pll0_l, pll1_l, pll2_l, pll4_l; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 784 | struct pll_freq_tbl_map *lst; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 785 | |
| 786 | /* Wait for the PLLs to be initialized and then read their frequency. |
| 787 | */ |
| 788 | do { |
| 789 | pll0_l = readl_relaxed(PLLn_L_VAL(0)) & |
| 790 | soc_pll[ACPU_PLL_0].l_val_mask; |
| 791 | cpu_relax(); |
| 792 | udelay(50); |
| 793 | } while (pll0_l == 0); |
| 794 | do { |
| 795 | pll1_l = readl_relaxed(PLLn_L_VAL(1)) & |
| 796 | soc_pll[ACPU_PLL_1].l_val_mask; |
| 797 | cpu_relax(); |
| 798 | udelay(50); |
| 799 | } while (pll1_l == 0); |
| 800 | do { |
| 801 | pll2_l = readl_relaxed(PLLn_L_VAL(2)) & |
| 802 | soc_pll[ACPU_PLL_2].l_val_mask; |
| 803 | cpu_relax(); |
| 804 | udelay(50); |
| 805 | } while (pll2_l == 0); |
| 806 | |
| 807 | pr_info("L val: PLL0: %d, PLL1: %d, PLL2: %d\n", |
| 808 | (int)pll0_l, (int)pll1_l, (int)pll2_l); |
| 809 | |
| 810 | if (!cpu_is_msm7x27() && !cpu_is_msm7x25a()) { |
| 811 | do { |
| 812 | pll4_l = readl_relaxed(PLL4_L_VAL) & |
| 813 | soc_pll[ACPU_PLL_4].l_val_mask; |
| 814 | cpu_relax(); |
| 815 | udelay(50); |
| 816 | } while (pll4_l == 0); |
| 817 | pr_info("L val: PLL4: %d\n", (int)pll4_l); |
| 818 | } else { |
| 819 | pll4_l = 0; |
| 820 | } |
| 821 | |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 822 | /* Fix the tables for 7x25a variant to not conflict with 7x27 ones */ |
| 823 | if (cpu_is_msm7x25a()) { |
| 824 | if (pll1_l == PLL_245_MHZ) { |
| 825 | acpu_freq_tbl = |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 826 | pll0_960_pll1_245_pll2_1200_25a; |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 827 | } else if (pll1_l == PLL_737_MHZ) { |
| 828 | acpu_freq_tbl = |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 829 | pll0_960_pll1_737_pll2_1200_25a; |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 830 | } |
| 831 | } else { |
| 832 | /* Select the right table to use. */ |
| 833 | for (lst = acpu_freq_tbl_list; lst->tbl != 0; lst++) { |
| 834 | if (lst->pll0_l == pll0_l && lst->pll1_l == pll1_l |
| 835 | && lst->pll2_l == pll2_l |
| 836 | && lst->pll4_l == pll4_l) { |
| 837 | acpu_freq_tbl = lst->tbl; |
| 838 | break; |
| 839 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 840 | } |
| 841 | } |
| 842 | |
| 843 | if (acpu_freq_tbl == NULL) { |
| 844 | pr_crit("Unknown PLL configuration!\n"); |
| 845 | BUG(); |
| 846 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | /* |
| 850 | * Hardware requires the CPU to be dropped to less than MAX_WAIT_FOR_IRQ_KHZ |
| 851 | * before entering a wait for irq low-power mode. Find a suitable rate. |
| 852 | */ |
| 853 | static unsigned long __init find_wait_for_irq_khz(void) |
| 854 | { |
| 855 | unsigned long found_khz = 0; |
| 856 | int i; |
| 857 | |
| 858 | for (i = 0; acpu_freq_tbl[i].a11clk_khz && |
| 859 | acpu_freq_tbl[i].a11clk_khz <= MAX_WAIT_FOR_IRQ_KHZ; i++) |
| 860 | found_khz = acpu_freq_tbl[i].a11clk_khz; |
| 861 | |
| 862 | return found_khz; |
| 863 | } |
| 864 | |
| 865 | /* Initalize the lpj field in the acpu_freq_tbl. */ |
| 866 | static void __init lpj_init(void) |
| 867 | { |
| 868 | int i; |
| 869 | const struct clkctl_acpu_speed *base_clk = drv_state.current_speed; |
| 870 | for (i = 0; acpu_freq_tbl[i].a11clk_khz; i++) { |
| 871 | acpu_freq_tbl[i].lpj = cpufreq_scale(loops_per_jiffy, |
| 872 | base_clk->a11clk_khz, |
| 873 | acpu_freq_tbl[i].a11clk_khz); |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | static void __init precompute_stepping(void) |
| 878 | { |
| 879 | int i, step_idx; |
| 880 | |
| 881 | #define cur_freq acpu_freq_tbl[i].a11clk_khz |
| 882 | #define step_freq acpu_freq_tbl[step_idx].a11clk_khz |
| 883 | #define cur_pll acpu_freq_tbl[i].pll |
| 884 | #define step_pll acpu_freq_tbl[step_idx].pll |
| 885 | |
| 886 | for (i = 0; acpu_freq_tbl[i].a11clk_khz; i++) { |
| 887 | |
| 888 | /* Calculate max "up" step for each destination PLL */ |
| 889 | step_idx = i + 1; |
| 890 | while (step_freq && (step_freq - cur_freq) |
| 891 | <= drv_state.max_speed_delta_khz) { |
| 892 | acpu_freq_tbl[i].up[step_pll] = |
| 893 | &acpu_freq_tbl[step_idx]; |
| 894 | step_idx++; |
| 895 | } |
| 896 | if (step_idx == (i + 1) && step_freq) { |
| 897 | pr_crit("Delta between freqs %u KHz and %u KHz is" |
| 898 | " too high!\n", cur_freq, step_freq); |
| 899 | BUG(); |
| 900 | } |
| 901 | |
| 902 | /* Calculate max "down" step for each destination PLL */ |
| 903 | step_idx = i - 1; |
| 904 | while (step_idx >= 0 && (cur_freq - step_freq) |
| 905 | <= drv_state.max_speed_delta_khz) { |
| 906 | acpu_freq_tbl[i].down[step_pll] = |
| 907 | &acpu_freq_tbl[step_idx]; |
| 908 | step_idx--; |
| 909 | } |
| 910 | if (step_idx == (i - 1) && i > 0) { |
| 911 | pr_crit("Delta between freqs %u KHz and %u KHz is" |
| 912 | " too high!\n", cur_freq, step_freq); |
| 913 | BUG(); |
| 914 | } |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | static void __init print_acpu_freq_tbl(void) |
| 919 | { |
| 920 | struct clkctl_acpu_speed *t; |
| 921 | short down_idx[ACPU_PLL_END]; |
| 922 | short up_idx[ACPU_PLL_END]; |
| 923 | int i, j; |
| 924 | |
| 925 | #define FREQ_IDX(freq_ptr) (freq_ptr - acpu_freq_tbl) |
| 926 | pr_info("Id CPU-KHz PLL DIV AHB-KHz ADIV AXI-KHz " |
| 927 | "D0 D1 D2 D4 U0 U1 U2 U4\n"); |
| 928 | |
| 929 | t = &acpu_freq_tbl[0]; |
| 930 | for (i = 0; t->a11clk_khz != 0; i++) { |
| 931 | |
| 932 | for (j = 0; j < ACPU_PLL_END; j++) { |
| 933 | down_idx[j] = t->down[j] ? FREQ_IDX(t->down[j]) : -1; |
| 934 | up_idx[j] = t->up[j] ? FREQ_IDX(t->up[j]) : -1; |
| 935 | } |
| 936 | |
| 937 | pr_info("%2d %7d %3d %3d %7d %4d %7d " |
| 938 | "%2d %2d %2d %2d %2d %2d %2d %2d\n", |
| 939 | i, t->a11clk_khz, t->pll, t->a11clk_src_div + 1, |
| 940 | t->ahbclk_khz, t->ahbclk_div + 1, t->axiclk_khz, |
| 941 | down_idx[0], down_idx[1], down_idx[2], down_idx[4], |
| 942 | up_idx[0], up_idx[1], up_idx[2], up_idx[4]); |
| 943 | |
| 944 | t++; |
| 945 | } |
| 946 | } |
| 947 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 948 | static void shared_pll_control_init(void) |
| 949 | { |
| 950 | #define PLL_REMOTE_SPINLOCK_ID "S:7" |
| 951 | unsigned smem_size; |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 952 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 953 | remote_spin_lock_init(&pll_lock, PLL_REMOTE_SPINLOCK_ID); |
| 954 | pll_control = smem_get_entry(SMEM_CLKREGIM_SOURCES, &smem_size); |
| 955 | |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 956 | if (!pll_control) { |
| 957 | pr_err("Can't find shared PLL control data structure!\n"); |
| 958 | BUG(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 959 | /* There might be more PLLs than what the application processor knows |
| 960 | * about. But the index used for each PLL is guaranteed to remain the |
| 961 | * same. */ |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 962 | } else if (smem_size < sizeof(struct shared_pll_control)) { |
| 963 | pr_err("Shared PLL control data" |
| 964 | "structure too small!\n"); |
| 965 | BUG(); |
| 966 | } else if (pll_control->version != 0xCCEE0001) { |
| 967 | pr_err("Shared PLL control version mismatch!\n"); |
| 968 | BUG(); |
| 969 | } else { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 970 | pr_info("Shared PLL control available.\n"); |
| 971 | return; |
| 972 | } |
| 973 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 974 | } |
| 975 | |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 976 | static struct acpuclk_data acpuclk_7627_data = { |
| 977 | .set_rate = acpuclk_7627_set_rate, |
| 978 | .get_rate = acpuclk_7627_get_rate, |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 979 | .power_collapse_khz = POWER_COLLAPSE_KHZ, |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 980 | .switch_time_us = 50, |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 981 | }; |
| 982 | |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 983 | static int __init acpuclk_7627_init(struct acpuclk_soc_data *soc_data) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 984 | { |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 985 | pr_info("%s()\n", __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 986 | |
| 987 | drv_state.ebi1_clk = clk_get(NULL, "ebi1_acpu_clk"); |
| 988 | BUG_ON(IS_ERR(drv_state.ebi1_clk)); |
| 989 | |
| 990 | mutex_init(&drv_state.lock); |
| 991 | shared_pll_control_init(); |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 992 | drv_state.max_speed_delta_khz = soc_data->max_speed_delta_khz; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 993 | acpu_freq_tbl_fixup(); |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 994 | acpuclk_7627_data.wait_for_irq_khz = find_wait_for_irq_khz(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 995 | precompute_stepping(); |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 996 | acpuclk_hw_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 997 | lpj_init(); |
| 998 | print_acpu_freq_tbl(); |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 999 | acpuclk_register(&acpuclk_7627_data); |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 1000 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1001 | #ifdef CONFIG_CPU_FREQ_MSM |
| 1002 | cpufreq_table_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1003 | #endif |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 1004 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1005 | } |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 1006 | |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 1007 | struct acpuclk_soc_data acpuclk_7x27_soc_data __initdata = { |
| 1008 | .max_speed_delta_khz = 400000, |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 1009 | .init = acpuclk_7627_init, |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 1010 | }; |
| 1011 | |
| 1012 | struct acpuclk_soc_data acpuclk_7x27a_soc_data __initdata = { |
| 1013 | .max_speed_delta_khz = 400000, |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 1014 | .init = acpuclk_7627_init, |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 1015 | }; |
| 1016 | |
| 1017 | struct acpuclk_soc_data acpuclk_7x27aa_soc_data __initdata = { |
| 1018 | .max_speed_delta_khz = 504000, |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 1019 | .init = acpuclk_7627_init, |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 1020 | }; |