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. |
Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 5 | * Copyright (c) 2007-2012, The Linux Foundation. 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> |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 21 | #include <linux/module.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 22 | #include <linux/init.h> |
| 23 | #include <linux/errno.h> |
| 24 | #include <linux/string.h> |
| 25 | #include <linux/delay.h> |
| 26 | #include <linux/clk.h> |
| 27 | #include <linux/cpufreq.h> |
| 28 | #include <linux/mutex.h> |
| 29 | #include <linux/io.h> |
| 30 | #include <linux/sort.h> |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 31 | #include <linux/platform_device.h> |
| 32 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 33 | #include <mach/board.h> |
| 34 | #include <mach/msm_iomap.h> |
Matt Wagantall | 33d01f5 | 2012-02-23 23:27:44 -0800 | [diff] [blame] | 35 | #include <mach/clk-provider.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 36 | #include <mach/socinfo.h> |
Taniya Das | c43e687 | 2012-03-21 16:41:14 +0530 | [diff] [blame] | 37 | #include <asm/mach-types.h> |
| 38 | #include <asm/cpu.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 39 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 40 | #include "smd_private.h" |
| 41 | #include "acpuclock.h" |
| 42 | |
| 43 | #define A11S_CLK_CNTL_ADDR (MSM_CSR_BASE + 0x100) |
| 44 | #define A11S_CLK_SEL_ADDR (MSM_CSR_BASE + 0x104) |
| 45 | #define A11S_VDD_SVS_PLEVEL_ADDR (MSM_CSR_BASE + 0x124) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 46 | |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 47 | #define PLL4_L_VAL_ADDR (MSM_CLK_CTL_BASE + 0x378) |
| 48 | #define PLL4_M_VAL_ADDR (MSM_CLK_CTL_BASE + 0x37C) |
| 49 | #define PLL4_N_VAL_ADDR (MSM_CLK_CTL_BASE + 0x380) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 50 | |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 51 | #define POWER_COLLAPSE_KHZ 19200 |
| 52 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 53 | /* Max CPU frequency allowed by hardware while in standby waiting for an irq. */ |
| 54 | #define MAX_WAIT_FOR_IRQ_KHZ 128000 |
| 55 | |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 56 | /** |
| 57 | * enum - For acpuclock PLL IDs |
| 58 | */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 59 | enum { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 60 | ACPU_PLL_0 = 0, |
| 61 | ACPU_PLL_1, |
| 62 | ACPU_PLL_2, |
| 63 | ACPU_PLL_3, |
| 64 | ACPU_PLL_4, |
Pankaj Kumar | 0249bed | 2012-03-08 15:20:54 +0530 | [diff] [blame] | 65 | ACPU_PLL_TCXO, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 66 | ACPU_PLL_END, |
| 67 | }; |
| 68 | |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 69 | struct acpu_clk_src { |
| 70 | struct clk *clk; |
| 71 | const char *name; |
| 72 | }; |
| 73 | |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 74 | struct pll_config { |
| 75 | unsigned int l; |
| 76 | unsigned int m; |
| 77 | unsigned int n; |
| 78 | }; |
| 79 | |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 80 | static struct acpu_clk_src pll_clk[ACPU_PLL_END] = { |
| 81 | [ACPU_PLL_0] = { .name = "pll0_clk" }, |
| 82 | [ACPU_PLL_1] = { .name = "pll1_clk" }, |
| 83 | [ACPU_PLL_2] = { .name = "pll2_clk" }, |
| 84 | [ACPU_PLL_4] = { .name = "pll4_clk" }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 85 | }; |
| 86 | |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 87 | static struct pll_config pll4_cfg_tbl[] = { |
Trilok Soni | 2c2ec16 | 2012-10-15 17:54:23 +0530 | [diff] [blame] | 88 | [0] = { 36, 1, 2 }, /* 700.8 MHz */ |
| 89 | [1] = { 52, 1, 2 }, /* 1008 MHz */ |
| 90 | [2] = { 63, 0, 1 }, /* 1209.6 MHz */ |
| 91 | [3] = { 73, 0, 1 }, /* 1401.6 MHz */ |
| 92 | [4] = { 60, 0, 1 }, /* 1152 MHz */ |
Trilok Soni | 4a0be01 | 2012-10-16 16:26:24 +0530 | [diff] [blame] | 93 | [5] = { 57, 1, 2 }, /* 1104 MHz */ |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 94 | }; |
| 95 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 96 | struct clock_state { |
| 97 | struct clkctl_acpu_speed *current_speed; |
| 98 | struct mutex lock; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 99 | uint32_t max_speed_delta_khz; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 100 | struct clk *ebi1_clk; |
| 101 | }; |
| 102 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 103 | struct clkctl_acpu_speed { |
| 104 | unsigned int use_for_scaling; |
| 105 | unsigned int a11clk_khz; |
| 106 | int pll; |
| 107 | unsigned int a11clk_src_sel; |
| 108 | unsigned int a11clk_src_div; |
| 109 | unsigned int ahbclk_khz; |
| 110 | unsigned int ahbclk_div; |
| 111 | int vdd; |
| 112 | unsigned int axiclk_khz; |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 113 | struct pll_config *pll_rate; |
Taniya Das | c43e687 | 2012-03-21 16:41:14 +0530 | [diff] [blame] | 114 | unsigned long lpj; /* loops_per_jiffy */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 115 | /* Pointers in acpu_freq_tbl[] for max up/down steppings. */ |
| 116 | struct clkctl_acpu_speed *down[ACPU_PLL_END]; |
| 117 | struct clkctl_acpu_speed *up[ACPU_PLL_END]; |
| 118 | }; |
| 119 | |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 120 | static bool dynamic_reprogram; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 121 | static struct clock_state drv_state = { 0 }; |
| 122 | static struct clkctl_acpu_speed *acpu_freq_tbl; |
| 123 | |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 124 | /* Switch to this when reprogramming PLL4 */ |
| 125 | static struct clkctl_acpu_speed *backup_s; |
| 126 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 127 | /* |
| 128 | * ACPU freq tables used for different PLLs frequency combinations. The |
| 129 | * correct table is selected during init. |
| 130 | * |
| 131 | * Table stepping up/down entries are calculated during boot to choose the |
| 132 | * largest frequency jump that's less than max_speed_delta_khz on each PLL. |
| 133 | */ |
| 134 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 135 | /* 7627 with GSM capable modem */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 136 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_pll4_0[] = { |
| 137 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 30720 }, |
| 138 | { 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 61440 }, |
| 139 | { 1, 122880, ACPU_PLL_1, 1, 1, 61440, 1, 3, 61440 }, |
| 140 | { 0, 200000, ACPU_PLL_2, 2, 5, 66667, 2, 4, 61440 }, |
| 141 | { 1, 245760, ACPU_PLL_1, 1, 0, 122880, 1, 4, 61440 }, |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 142 | { 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 160000 }, |
| 143 | { 0, 400000, ACPU_PLL_2, 2, 2, 133333, 2, 5, 160000 }, |
| 144 | { 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 6, 160000 }, |
| 145 | { 1, 600000, ACPU_PLL_2, 2, 1, 200000, 2, 7, 200000 }, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 146 | { 0 } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 147 | }; |
| 148 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 149 | /* 7627 with CDMA capable modem */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 150 | static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_1200_pll4_0[] = { |
| 151 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 24576 }, |
| 152 | { 1, 98304, ACPU_PLL_1, 1, 1, 98304, 0, 3, 49152 }, |
| 153 | { 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 49152 }, |
| 154 | { 1, 196608, ACPU_PLL_1, 1, 0, 65536, 2, 4, 98304 }, |
| 155 | { 0, 200000, ACPU_PLL_2, 2, 5, 66667, 2, 4, 98304 }, |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 156 | { 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 160000 }, |
| 157 | { 0, 400000, ACPU_PLL_2, 2, 2, 133333, 2, 5, 160000 }, |
| 158 | { 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 6, 160000 }, |
| 159 | { 1, 600000, ACPU_PLL_2, 2, 1, 200000, 2, 7, 200000 }, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 160 | { 0 } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 161 | }; |
| 162 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 163 | /* 7627 with GSM capable modem - PLL2 @ 800 */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 164 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_800_pll4_0[] = { |
| 165 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 30720 }, |
| 166 | { 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 61440 }, |
| 167 | { 1, 122880, ACPU_PLL_1, 1, 1, 61440, 1, 3, 61440 }, |
| 168 | { 0, 200000, ACPU_PLL_2, 2, 3, 66667, 2, 4, 61440 }, |
| 169 | { 1, 245760, ACPU_PLL_1, 1, 0, 122880, 1, 4, 61440 }, |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 170 | { 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 160000 }, |
| 171 | { 0, 400000, ACPU_PLL_2, 2, 1, 133333, 2, 5, 160000 }, |
| 172 | { 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 6, 160000 }, |
| 173 | { 1, 800000, ACPU_PLL_2, 2, 0, 200000, 3, 7, 200000 }, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 174 | { 0 } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 175 | }; |
| 176 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 177 | /* 7627 with CDMA capable modem - PLL2 @ 800 */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 178 | static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_800_pll4_0[] = { |
| 179 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 24576 }, |
| 180 | { 1, 98304, ACPU_PLL_1, 1, 1, 98304, 0, 3, 49152 }, |
| 181 | { 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 49152 }, |
| 182 | { 1, 196608, ACPU_PLL_1, 1, 0, 65536, 2, 4, 98304 }, |
| 183 | { 0, 200000, ACPU_PLL_2, 2, 3, 66667, 2, 4, 98304 }, |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 184 | { 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 160000 }, |
| 185 | { 0, 400000, ACPU_PLL_2, 2, 1, 133333, 2, 5, 160000 }, |
| 186 | { 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 6, 160000 }, |
| 187 | { 1, 800000, ACPU_PLL_2, 2, 0, 200000, 3, 7, 200000 }, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 188 | { 0 } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 189 | }; |
| 190 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 191 | /* 7627a PLL2 @ 1200MHz with GSM capable modem */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 192 | 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] | 193 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 194 | { 0, 61440, ACPU_PLL_1, 1, 3, 7680, 3, 1, 61440 }, |
| 195 | { 1, 122880, ACPU_PLL_1, 1, 1, 15360, 3, 2, 61440 }, |
| 196 | { 1, 245760, ACPU_PLL_1, 1, 0, 30720, 3, 3, 61440 }, |
Pankaj Kumar | 2764fe7 | 2012-02-23 00:53:28 +0530 | [diff] [blame] | 197 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 122880 }, |
Trilok Soni | 7d6c865 | 2011-07-14 15:35:07 +0530 | [diff] [blame] | 198 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
| 199 | { 0, 400000, ACPU_PLL_4, 6, 1, 50000, 3, 4, 122880 }, |
| 200 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
Pankaj Kumar | 501e14e | 2012-04-10 14:51:41 +0530 | [diff] [blame] | 201 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 160000 }, |
Trilok Soni | 7d6c865 | 2011-07-14 15:35:07 +0530 | [diff] [blame] | 202 | { 1, 800000, ACPU_PLL_4, 6, 0, 100000, 3, 7, 200000 }, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 203 | { 0 } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 204 | }; |
| 205 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 206 | /* 7627a PLL2 @ 1200MHz with CDMA capable modem */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 207 | 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] | 208 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
| 209 | { 0, 65536, ACPU_PLL_1, 1, 3, 8192, 3, 1, 49152 }, |
| 210 | { 1, 98304, ACPU_PLL_1, 1, 1, 12288, 3, 2, 49152 }, |
| 211 | { 1, 196608, ACPU_PLL_1, 1, 0, 24576, 3, 3, 98304 }, |
Trilok Soni | abb750b | 2011-07-13 16:47:18 +0530 | [diff] [blame] | 212 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 120000 }, |
| 213 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 120000 }, |
| 214 | { 0, 400000, ACPU_PLL_4, 6, 1, 50000, 3, 4, 120000 }, |
| 215 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 120000 }, |
Pankaj Kumar | 501e14e | 2012-04-10 14:51:41 +0530 | [diff] [blame] | 216 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 160000 }, |
Trilok Soni | 7d6c865 | 2011-07-14 15:35:07 +0530 | [diff] [blame] | 217 | { 1, 800000, ACPU_PLL_4, 6, 0, 100000, 3, 7, 200000 }, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 218 | { 0 } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 219 | }; |
| 220 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 221 | /* 7627aa PLL4 @ 1008MHz with GSM capable modem */ |
Trilok Soni | f597e24 | 2011-06-06 12:37:16 +0530 | [diff] [blame] | 222 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_pll4_1008[] = { |
| 223 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 224 | { 0, 61440, ACPU_PLL_1, 1, 3, 7680, 3, 1, 61440 }, |
| 225 | { 1, 122880, ACPU_PLL_1, 1, 1, 15360, 3, 2, 61440 }, |
| 226 | { 1, 245760, ACPU_PLL_1, 1, 0, 30720, 3, 3, 61440 }, |
Pankaj Kumar | 2764fe7 | 2012-02-23 00:53:28 +0530 | [diff] [blame] | 227 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 122880 }, |
Trilok Soni | f597e24 | 2011-06-06 12:37:16 +0530 | [diff] [blame] | 228 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
| 229 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
Pankaj Kumar | 501e14e | 2012-04-10 14:51:41 +0530 | [diff] [blame] | 230 | { 0, 504000, ACPU_PLL_4, 6, 1, 63000, 3, 6, 160000 }, |
| 231 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 160000 }, |
Trilok Soni | f597e24 | 2011-06-06 12:37:16 +0530 | [diff] [blame] | 232 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 7, 200000}, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 233 | { 0 } |
Trilok Soni | f597e24 | 2011-06-06 12:37:16 +0530 | [diff] [blame] | 234 | }; |
| 235 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 236 | /* 7627aa PLL4 @ 1008MHz with CDMA capable modem */ |
Trilok Soni | d7b05e5 | 2011-08-17 18:09:08 +0530 | [diff] [blame] | 237 | static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_1200_pll4_1008[] = { |
| 238 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
| 239 | { 0, 65536, ACPU_PLL_1, 1, 3, 8192, 3, 1, 49152 }, |
| 240 | { 1, 98304, ACPU_PLL_1, 1, 1, 12288, 3, 2, 49152 }, |
| 241 | { 1, 196608, ACPU_PLL_1, 1, 0, 24576, 3, 3, 98304 }, |
Pankaj Kumar | 2764fe7 | 2012-02-23 00:53:28 +0530 | [diff] [blame] | 242 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 122880 }, |
Trilok Soni | d7b05e5 | 2011-08-17 18:09:08 +0530 | [diff] [blame] | 243 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
| 244 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
Pankaj Kumar | 501e14e | 2012-04-10 14:51:41 +0530 | [diff] [blame] | 245 | { 0, 504000, ACPU_PLL_4, 6, 1, 63000, 3, 6, 160000 }, |
| 246 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 160000 }, |
Trilok Soni | d7b05e5 | 2011-08-17 18:09:08 +0530 | [diff] [blame] | 247 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 7, 200000}, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 248 | { 0 } |
Trilok Soni | d7b05e5 | 2011-08-17 18:09:08 +0530 | [diff] [blame] | 249 | }; |
| 250 | |
Pankaj Kumar | 50c705c | 2012-01-10 12:02:07 +0530 | [diff] [blame] | 251 | /* 8625 PLL4 @ 1209MHz with GSM capable modem */ |
| 252 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_pll4_1209[] = { |
| 253 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
Trilok Soni | 266a150 | 2012-08-03 20:25:48 +0530 | [diff] [blame] | 254 | { 0, 61440, ACPU_PLL_1, 1, 3, 7680, 3, 0, 61440 }, |
| 255 | { 0, 122880, ACPU_PLL_1, 1, 1, 15360, 3, 1, 61440 }, |
| 256 | { 1, 245760, ACPU_PLL_1, 1, 0, 30720, 3, 1, 61440 }, |
| 257 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 2, 122880 }, |
| 258 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 2, 122880 }, |
| 259 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 3, 122880 }, |
| 260 | { 0, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 4, 160000 }, |
| 261 | { 1, 700800, ACPU_PLL_4, 6, 0, 87500, 3, 4, 160000, &pll4_cfg_tbl[0]}, |
| 262 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 5, 200000, &pll4_cfg_tbl[1]}, |
| 263 | { 1, 1209600, ACPU_PLL_4, 6, 0, 151200, 3, 6, 200000, &pll4_cfg_tbl[2]}, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 264 | { 0 } |
Pankaj Kumar | 50c705c | 2012-01-10 12:02:07 +0530 | [diff] [blame] | 265 | }; |
| 266 | |
| 267 | /* 8625 PLL4 @ 1209MHz with CDMA capable modem */ |
| 268 | static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_1200_pll4_1209[] = { |
| 269 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
| 270 | { 0, 65536, ACPU_PLL_1, 1, 3, 8192, 3, 1, 49152 }, |
Trilok Soni | 55b7af9 | 2012-10-15 18:21:51 +0530 | [diff] [blame] | 271 | { 0, 98304, ACPU_PLL_1, 1, 1, 12288, 3, 1, 49152 }, |
| 272 | { 1, 196608, ACPU_PLL_1, 1, 0, 24576, 3, 1, 98304 }, |
Trilok Soni | 266a150 | 2012-08-03 20:25:48 +0530 | [diff] [blame] | 273 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 2, 122880 }, |
| 274 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 3, 122880 }, |
| 275 | { 0, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 4, 160000 }, |
| 276 | { 1, 700800, ACPU_PLL_4, 6, 0, 87500, 3, 4, 160000, &pll4_cfg_tbl[0]}, |
| 277 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 5, 200000, &pll4_cfg_tbl[1]}, |
| 278 | { 1, 1209600, ACPU_PLL_4, 6, 0, 151200, 3, 6, 200000, &pll4_cfg_tbl[2]}, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 279 | { 0 } |
| 280 | }; |
| 281 | |
| 282 | /* 8625 PLL4 @ 1401.6MHz with GSM capable modem */ |
| 283 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_pll4_1401[] = { |
| 284 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 285 | { 0, 61440, ACPU_PLL_1, 1, 3, 7680, 3, 0, 61440 }, |
| 286 | { 0, 122880, ACPU_PLL_1, 1, 1, 15360, 3, 1, 61440 }, |
| 287 | { 1, 245760, ACPU_PLL_1, 1, 0, 30720, 3, 1, 61440 }, |
| 288 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 2, 122880 }, |
| 289 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 2, 122880 }, |
| 290 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 3, 122880 }, |
| 291 | { 0, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 4, 160000 }, |
| 292 | { 1, 700800, ACPU_PLL_4, 6, 0, 87500, 3, 4, 160000, &pll4_cfg_tbl[0]}, |
| 293 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 5, 200000, &pll4_cfg_tbl[1]}, |
| 294 | { 1, 1209600, ACPU_PLL_4, 6, 0, 151200, 3, 6, 200000, &pll4_cfg_tbl[2]}, |
| 295 | { 1, 1401600, ACPU_PLL_4, 6, 0, 175000, 3, 7, 200000, &pll4_cfg_tbl[3]}, |
| 296 | { 0 } |
| 297 | }; |
| 298 | |
| 299 | /* 8625 PLL4 @ 1401.6MHz with CDMA capable modem */ |
| 300 | static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_1200_pll4_1401[] = { |
| 301 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
| 302 | { 0, 65536, ACPU_PLL_1, 1, 3, 8192, 3, 1, 49152 }, |
Trilok Soni | 55b7af9 | 2012-10-15 18:21:51 +0530 | [diff] [blame] | 303 | { 0, 98304, ACPU_PLL_1, 1, 1, 12288, 3, 1, 49152 }, |
| 304 | { 1, 196608, ACPU_PLL_1, 1, 0, 24576, 3, 1, 98304 }, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 305 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 2, 122880 }, |
| 306 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 3, 122880 }, |
| 307 | { 0, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 4, 160000 }, |
| 308 | { 1, 700800, ACPU_PLL_4, 6, 0, 87500, 3, 4, 160000, &pll4_cfg_tbl[0]}, |
| 309 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 5, 200000, &pll4_cfg_tbl[1]}, |
| 310 | { 1, 1209600, ACPU_PLL_4, 6, 0, 151200, 3, 6, 200000, &pll4_cfg_tbl[2]}, |
| 311 | { 1, 1401600, ACPU_PLL_4, 6, 0, 175000, 3, 7, 200000, &pll4_cfg_tbl[3]}, |
| 312 | { 0 } |
Pankaj Kumar | 50c705c | 2012-01-10 12:02:07 +0530 | [diff] [blame] | 313 | }; |
| 314 | |
Trilok Soni | 72cacdb | 2012-10-15 17:58:57 +0530 | [diff] [blame] | 315 | /* 8625 PLL4 @ 1008MHz with GSM capable modem */ |
Trilok Soni | a563990 | 2012-08-05 16:49:07 +0530 | [diff] [blame] | 316 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_pll4_1008_2p0[] = { |
| 317 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 318 | { 0, 61440, ACPU_PLL_1, 1, 3, 7680, 3, 0, 61440 }, |
| 319 | { 0, 122880, ACPU_PLL_1, 1, 1, 15360, 3, 1, 61440 }, |
| 320 | { 1, 245760, ACPU_PLL_1, 1, 0, 30720, 3, 1, 61440 }, |
| 321 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 2, 122880 }, |
| 322 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 2, 122880 }, |
| 323 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 3, 122880 }, |
| 324 | { 0, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 4, 160000 }, |
| 325 | { 1, 700800, ACPU_PLL_4, 6, 0, 87500, 3, 4, 160000, &pll4_cfg_tbl[0]}, |
| 326 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 5, 200000, &pll4_cfg_tbl[1]}, |
| 327 | { 0 } |
| 328 | }; |
| 329 | |
Trilok Soni | 72cacdb | 2012-10-15 17:58:57 +0530 | [diff] [blame] | 330 | /* 8625 PLL4 @ 1008MHz with CDMA capable modem */ |
Trilok Soni | a563990 | 2012-08-05 16:49:07 +0530 | [diff] [blame] | 331 | static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_1200_pll4_1008_2p0[] = { |
| 332 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
| 333 | { 0, 65536, ACPU_PLL_1, 1, 3, 8192, 3, 1, 49152 }, |
Trilok Soni | 55b7af9 | 2012-10-15 18:21:51 +0530 | [diff] [blame] | 334 | { 0, 98304, ACPU_PLL_1, 1, 1, 12288, 3, 1, 49152 }, |
| 335 | { 1, 196608, ACPU_PLL_1, 1, 0, 24576, 3, 1, 98304 }, |
Trilok Soni | a563990 | 2012-08-05 16:49:07 +0530 | [diff] [blame] | 336 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 2, 122880 }, |
| 337 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 3, 122880 }, |
| 338 | { 0, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 4, 160000 }, |
| 339 | { 1, 700800, ACPU_PLL_4, 6, 0, 87500, 3, 4, 160000, &pll4_cfg_tbl[0]}, |
| 340 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 5, 200000, &pll4_cfg_tbl[1]}, |
| 341 | { 0 } |
| 342 | }; |
| 343 | |
Trilok Soni | 4a0be01 | 2012-10-16 16:26:24 +0530 | [diff] [blame] | 344 | /* 8625 PLL4 @ 1104MHz with GSM capable modem with v2.0 plan */ |
| 345 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_pll4_1104[] = { |
| 346 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 347 | { 1, 245760, ACPU_PLL_1, 1, 0, 30720, 3, 1, 61440 }, |
| 348 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 2, 122880 }, |
| 349 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 3, 122880 }, |
| 350 | { 0, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 4, 160000 }, |
| 351 | { 1, 700800, ACPU_PLL_4, 6, 0, 87500, 3, 4, 160000, &pll4_cfg_tbl[0]}, |
| 352 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 5, 200000, &pll4_cfg_tbl[1]}, |
| 353 | { 1, 1104000, ACPU_PLL_4, 6, 0, 151200, 3, 6, 200000, &pll4_cfg_tbl[5]}, |
| 354 | { 0 } |
| 355 | }; |
| 356 | |
| 357 | /* 8625 PLL4 @ 1104MHz with CDMA capable modem with v2.0 plan */ |
| 358 | static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_1200_pll4_1104[] = { |
| 359 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
| 360 | { 1, 196608, ACPU_PLL_1, 1, 0, 24576, 3, 1, 98304 }, |
| 361 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 2, 122880 }, |
| 362 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 3, 122880 }, |
| 363 | { 0, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 4, 160000 }, |
| 364 | { 1, 700800, ACPU_PLL_4, 6, 0, 87500, 3, 4, 160000, &pll4_cfg_tbl[0]}, |
| 365 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 5, 200000, &pll4_cfg_tbl[1]}, |
| 366 | { 1, 1104000, ACPU_PLL_4, 6, 0, 151200, 3, 6, 200000, &pll4_cfg_tbl[5]}, |
| 367 | { 0 } |
| 368 | }; |
| 369 | |
Trilok Soni | 2c2ec16 | 2012-10-15 17:54:23 +0530 | [diff] [blame] | 370 | /* 8625 PLL4 @ 1152MHz with GSM capable modem with v2.0 plan */ |
Trilok Soni | 4863172 | 2012-05-17 20:56:42 +0530 | [diff] [blame] | 371 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_pll4_1152[] = { |
| 372 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
Trilok Soni | 2c2ec16 | 2012-10-15 17:54:23 +0530 | [diff] [blame] | 373 | { 1, 245760, ACPU_PLL_1, 1, 0, 30720, 3, 1, 61440 }, |
| 374 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 2, 122880 }, |
| 375 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 3, 122880 }, |
| 376 | { 0, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 4, 160000 }, |
| 377 | { 1, 700800, ACPU_PLL_4, 6, 0, 87500, 3, 4, 160000, &pll4_cfg_tbl[0]}, |
| 378 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 5, 200000, &pll4_cfg_tbl[1]}, |
| 379 | { 1, 1152000, ACPU_PLL_4, 6, 0, 151200, 3, 6, 200000, &pll4_cfg_tbl[4]}, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 380 | { 0 } |
Trilok Soni | 4863172 | 2012-05-17 20:56:42 +0530 | [diff] [blame] | 381 | }; |
| 382 | |
Trilok Soni | 2c2ec16 | 2012-10-15 17:54:23 +0530 | [diff] [blame] | 383 | /* 8625 PLL4 @ 1115MHz with CDMA capable modem with v2.0 plan */ |
Trilok Soni | 4863172 | 2012-05-17 20:56:42 +0530 | [diff] [blame] | 384 | static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_1200_pll4_1152[] = { |
| 385 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
Trilok Soni | 2c2ec16 | 2012-10-15 17:54:23 +0530 | [diff] [blame] | 386 | { 1, 196608, ACPU_PLL_1, 1, 0, 24576, 3, 1, 98304 }, |
| 387 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 2, 122880 }, |
| 388 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 3, 122880 }, |
| 389 | { 0, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 4, 160000 }, |
| 390 | { 1, 700800, ACPU_PLL_4, 6, 0, 87500, 3, 4, 160000, &pll4_cfg_tbl[0]}, |
| 391 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 5, 200000, &pll4_cfg_tbl[1]}, |
| 392 | { 1, 1152000, ACPU_PLL_4, 6, 0, 151200, 3, 6, 200000, &pll4_cfg_tbl[4]}, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 393 | { 0 } |
Trilok Soni | 4863172 | 2012-05-17 20:56:42 +0530 | [diff] [blame] | 394 | }; |
| 395 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 396 | /* 7625a PLL2 @ 1200MHz with GSM capable modem */ |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 397 | static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_25a[] = { |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 398 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 399 | { 0, 61440, ACPU_PLL_1, 1, 3, 7680, 3, 1, 61440 }, |
| 400 | { 1, 122880, ACPU_PLL_1, 1, 1, 15360, 3, 2, 61440 }, |
| 401 | { 1, 245760, ACPU_PLL_1, 1, 0, 30720, 3, 3, 61440 }, |
Pankaj Kumar | 2764fe7 | 2012-02-23 00:53:28 +0530 | [diff] [blame] | 402 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 122880 }, |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 403 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 404 | { 0, 400000, ACPU_PLL_2, 2, 2, 50000, 3, 4, 122880 }, |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 405 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
| 406 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 }, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 407 | { 0 } |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 408 | }; |
| 409 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 410 | /* 7627a PLL2 @ 1200MHz with GSM capable modem */ |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 411 | static struct clkctl_acpu_speed pll0_960_pll1_737_pll2_1200_pll4_800[] = { |
| 412 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 413 | { 0, 61440, ACPU_PLL_1, 1, 11, 7680, 3, 1, 61440 }, |
| 414 | { 1, 122880, ACPU_PLL_1, 1, 5, 15360, 3, 2, 61440 }, |
| 415 | { 1, 245760, ACPU_PLL_1, 1, 2, 30720, 3, 3, 61440 }, |
Pankaj Kumar | 2764fe7 | 2012-02-23 00:53:28 +0530 | [diff] [blame] | 416 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 122880 }, |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 417 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
| 418 | { 0, 400000, ACPU_PLL_4, 6, 1, 50000, 3, 4, 122880 }, |
| 419 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
Pankaj Kumar | 501e14e | 2012-04-10 14:51:41 +0530 | [diff] [blame] | 420 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 160000 }, |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 421 | { 1, 800000, ACPU_PLL_4, 6, 0, 100000, 3, 7, 200000 }, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 422 | { 0 } |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 423 | }; |
| 424 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 425 | /* 7627a PLL2 @ 1200MHz with CDMA capable modem */ |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 426 | static struct clkctl_acpu_speed pll0_960_pll1_589_pll2_1200_pll4_800[] = { |
| 427 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
| 428 | { 0, 65536, ACPU_PLL_1, 1, 8, 8192, 3, 1, 49152 }, |
| 429 | { 1, 98304, ACPU_PLL_1, 1, 5, 12288, 3, 2, 49152 }, |
| 430 | { 1, 196608, ACPU_PLL_1, 1, 2, 24576, 3, 3, 98304 }, |
| 431 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 120000 }, |
| 432 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 120000 }, |
| 433 | { 0, 400000, ACPU_PLL_4, 6, 1, 50000, 3, 4, 120000 }, |
| 434 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 120000 }, |
Pankaj Kumar | 501e14e | 2012-04-10 14:51:41 +0530 | [diff] [blame] | 435 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 160000 }, |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 436 | { 1, 800000, ACPU_PLL_4, 6, 0, 100000, 3, 7, 200000 }, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 437 | { 0 } |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 438 | }; |
| 439 | |
Pankaj Kumar | 714c5cc | 2012-01-05 13:14:38 +0530 | [diff] [blame] | 440 | /* 7627aa PLL4 @ 1008MHz with GSM capable modem */ |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 441 | static struct clkctl_acpu_speed pll0_960_pll1_737_pll2_1200_pll4_1008[] = { |
| 442 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 443 | { 0, 61440, ACPU_PLL_1, 1, 11, 7680, 3, 1, 61440 }, |
| 444 | { 1, 122880, ACPU_PLL_1, 1, 5, 15360, 3, 2, 61440 }, |
| 445 | { 1, 245760, ACPU_PLL_1, 1, 2, 30720, 3, 3, 61440 }, |
Pankaj Kumar | 2764fe7 | 2012-02-23 00:53:28 +0530 | [diff] [blame] | 446 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 122880 }, |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 447 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
| 448 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
Pankaj Kumar | 501e14e | 2012-04-10 14:51:41 +0530 | [diff] [blame] | 449 | { 0, 504000, ACPU_PLL_4, 6, 1, 63000, 3, 6, 160000 }, |
| 450 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 160000 }, |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 451 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 7, 200000}, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 452 | { 0 } |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 453 | }; |
| 454 | |
Pankaj Kumar | 2764fe7 | 2012-02-23 00:53:28 +0530 | [diff] [blame] | 455 | /* 7627aa PLL4 @ 1008MHz with CDMA capable modem */ |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 456 | static struct clkctl_acpu_speed pll0_960_pll1_589_pll2_1200_pll4_1008[] = { |
| 457 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 }, |
| 458 | { 0, 65536, ACPU_PLL_1, 1, 8, 8192, 3, 1, 49152 }, |
| 459 | { 1, 98304, ACPU_PLL_1, 1, 5, 12288, 3, 2, 49152 }, |
| 460 | { 1, 196608, ACPU_PLL_1, 1, 2, 24576, 3, 3, 98304 }, |
Pankaj Kumar | 2764fe7 | 2012-02-23 00:53:28 +0530 | [diff] [blame] | 461 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 122880 }, |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 462 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
| 463 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
Pankaj Kumar | 501e14e | 2012-04-10 14:51:41 +0530 | [diff] [blame] | 464 | { 0, 504000, ACPU_PLL_4, 6, 1, 63000, 3, 6, 160000 }, |
| 465 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 160000 }, |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 466 | { 1, 1008000, ACPU_PLL_4, 6, 0, 126000, 3, 7, 200000}, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 467 | { 0 } |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 468 | }; |
| 469 | |
Pankaj Kumar | 2764fe7 | 2012-02-23 00:53:28 +0530 | [diff] [blame] | 470 | /* 7625a PLL2 @ 1200MHz with GSM capable modem */ |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 471 | static struct clkctl_acpu_speed pll0_960_pll1_737_pll2_1200_25a[] = { |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 472 | { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 }, |
| 473 | { 0, 61440, ACPU_PLL_1, 1, 11, 7680, 3, 1, 61440 }, |
| 474 | { 1, 122880, ACPU_PLL_1, 1, 5, 15360, 3, 2, 61440 }, |
| 475 | { 1, 245760, ACPU_PLL_1, 1, 2, 30720, 3, 3, 61440 }, |
Pankaj Kumar | 2764fe7 | 2012-02-23 00:53:28 +0530 | [diff] [blame] | 476 | { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 122880 }, |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 477 | { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 }, |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 478 | { 0, 400000, ACPU_PLL_2, 2, 2, 50000, 3, 4, 122880 }, |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 479 | { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 }, |
| 480 | { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 }, |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 481 | { 0 } |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 482 | }; |
| 483 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 484 | #define PLL_CONFIG(m0, m1, m2, m4) { \ |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 485 | m0, m1, m2, m4, \ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 486 | pll0_##m0##_pll1_##m1##_pll2_##m2##_pll4_##m4 \ |
| 487 | } |
| 488 | |
| 489 | struct pll_freq_tbl_map { |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 490 | unsigned int pll0_rate; |
| 491 | unsigned int pll1_rate; |
| 492 | unsigned int pll2_rate; |
| 493 | unsigned int pll4_rate; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 494 | struct clkctl_acpu_speed *tbl; |
| 495 | }; |
| 496 | |
| 497 | static struct pll_freq_tbl_map acpu_freq_tbl_list[] = { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 498 | PLL_CONFIG(960, 196, 1200, 0), |
| 499 | PLL_CONFIG(960, 245, 1200, 0), |
| 500 | PLL_CONFIG(960, 196, 800, 0), |
| 501 | PLL_CONFIG(960, 245, 800, 0), |
| 502 | PLL_CONFIG(960, 245, 1200, 800), |
| 503 | PLL_CONFIG(960, 196, 1200, 800), |
Trilok Soni | f597e24 | 2011-06-06 12:37:16 +0530 | [diff] [blame] | 504 | PLL_CONFIG(960, 245, 1200, 1008), |
Trilok Soni | d7b05e5 | 2011-08-17 18:09:08 +0530 | [diff] [blame] | 505 | PLL_CONFIG(960, 196, 1200, 1008), |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 506 | PLL_CONFIG(960, 737, 1200, 800), |
| 507 | PLL_CONFIG(960, 589, 1200, 800), |
| 508 | PLL_CONFIG(960, 737, 1200, 1008), |
| 509 | PLL_CONFIG(960, 589, 1200, 1008), |
Pankaj Kumar | 50c705c | 2012-01-10 12:02:07 +0530 | [diff] [blame] | 510 | PLL_CONFIG(960, 245, 1200, 1209), |
| 511 | PLL_CONFIG(960, 196, 1200, 1209), |
Trilok Soni | 4863172 | 2012-05-17 20:56:42 +0530 | [diff] [blame] | 512 | PLL_CONFIG(960, 245, 1200, 1152), |
| 513 | PLL_CONFIG(960, 196, 1200, 1152), |
Trilok Soni | 4a0be01 | 2012-10-16 16:26:24 +0530 | [diff] [blame] | 514 | PLL_CONFIG(960, 245, 1200, 1104), |
| 515 | PLL_CONFIG(960, 196, 1200, 1104), |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 516 | PLL_CONFIG(960, 245, 1200, 1401), |
| 517 | PLL_CONFIG(960, 196, 1200, 1401), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 518 | { 0, 0, 0, 0, 0 } |
| 519 | }; |
| 520 | |
| 521 | #ifdef CONFIG_CPU_FREQ_MSM |
Pankaj Kumar | 873bc7a | 2011-12-21 17:25:44 +0530 | [diff] [blame] | 522 | static struct cpufreq_frequency_table freq_table[NR_CPUS][20]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 523 | |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 524 | static void __devinit cpufreq_table_init(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 525 | { |
Pankaj Kumar | 873bc7a | 2011-12-21 17:25:44 +0530 | [diff] [blame] | 526 | int cpu; |
| 527 | for_each_possible_cpu(cpu) { |
| 528 | unsigned int i, freq_cnt = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 529 | |
Pankaj Kumar | 873bc7a | 2011-12-21 17:25:44 +0530 | [diff] [blame] | 530 | /* Construct the freq_table table from acpu_freq_tbl since |
| 531 | * the freq_table values need to match frequencies specified |
| 532 | * in acpu_freq_tbl and acpu_freq_tbl needs to be fixed up |
| 533 | * during init. |
| 534 | */ |
| 535 | for (i = 0; acpu_freq_tbl[i].a11clk_khz != 0 |
| 536 | && freq_cnt < ARRAY_SIZE(*freq_table)-1; i++) { |
| 537 | if (acpu_freq_tbl[i].use_for_scaling) { |
| 538 | freq_table[cpu][freq_cnt].index = freq_cnt; |
| 539 | freq_table[cpu][freq_cnt].frequency |
| 540 | = acpu_freq_tbl[i].a11clk_khz; |
| 541 | freq_cnt++; |
| 542 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 543 | } |
Pankaj Kumar | 873bc7a | 2011-12-21 17:25:44 +0530 | [diff] [blame] | 544 | |
| 545 | /* freq_table not big enough to store all usable freqs. */ |
| 546 | BUG_ON(acpu_freq_tbl[i].a11clk_khz != 0); |
| 547 | |
| 548 | freq_table[cpu][freq_cnt].index = freq_cnt; |
| 549 | freq_table[cpu][freq_cnt].frequency = CPUFREQ_TABLE_END; |
| 550 | /* Register table with CPUFreq. */ |
| 551 | cpufreq_frequency_table_get_attr(freq_table[cpu], cpu); |
| 552 | pr_info("CPU%d: %d scaling frequencies supported.\n", |
| 553 | cpu, freq_cnt); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 554 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 555 | } |
| 556 | #endif |
| 557 | |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 558 | static void update_jiffies(int cpu, unsigned long loops) |
| 559 | { |
| 560 | #ifdef CONFIG_SMP |
| 561 | for_each_possible_cpu(cpu) { |
| 562 | per_cpu(cpu_data, cpu).loops_per_jiffy = |
| 563 | loops; |
| 564 | } |
| 565 | #endif |
| 566 | /* Adjust the global one */ |
| 567 | loops_per_jiffy = loops; |
| 568 | } |
| 569 | |
| 570 | /* Assumes PLL4 is off and the acpuclock isn't sourced from PLL4 */ |
| 571 | static void acpuclk_config_pll4(struct pll_config *pll) |
| 572 | { |
| 573 | /* Make sure write to disable PLL_4 has completed |
| 574 | * before reconfiguring that PLL. */ |
| 575 | mb(); |
| 576 | writel_relaxed(pll->l, PLL4_L_VAL_ADDR); |
| 577 | writel_relaxed(pll->m, PLL4_M_VAL_ADDR); |
| 578 | writel_relaxed(pll->n, PLL4_N_VAL_ADDR); |
| 579 | /* Make sure PLL is programmed before returning. */ |
| 580 | mb(); |
| 581 | } |
| 582 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 583 | static int acpuclk_set_vdd_level(int vdd) |
| 584 | { |
| 585 | uint32_t current_vdd; |
| 586 | |
Pankaj Kumar | 9406a3b | 2011-12-23 18:07:15 +0530 | [diff] [blame] | 587 | /* |
| 588 | * NOTE: v1.0 of 7x27a/7x25a chip doesn't have working |
| 589 | * VDD switching support. |
| 590 | */ |
| 591 | if ((cpu_is_msm7x27a() || cpu_is_msm7x25a()) && |
| 592 | (SOCINFO_VERSION_MINOR(socinfo_get_version()) < 1)) |
| 593 | return 0; |
| 594 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 595 | current_vdd = readl_relaxed(A11S_VDD_SVS_PLEVEL_ADDR) & 0x07; |
| 596 | |
| 597 | pr_debug("Switching VDD from %u mV -> %d mV\n", |
| 598 | current_vdd, vdd); |
| 599 | |
| 600 | writel_relaxed((1 << 7) | (vdd << 3), A11S_VDD_SVS_PLEVEL_ADDR); |
| 601 | mb(); |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 602 | udelay(62); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 603 | if ((readl_relaxed(A11S_VDD_SVS_PLEVEL_ADDR) & 0x7) != vdd) { |
| 604 | pr_err("VDD set failed\n"); |
| 605 | return -EIO; |
| 606 | } |
| 607 | |
| 608 | pr_debug("VDD switched\n"); |
| 609 | |
| 610 | return 0; |
| 611 | } |
| 612 | |
| 613 | /* Set proper dividers for the given clock speed. */ |
| 614 | static void acpuclk_set_div(const struct clkctl_acpu_speed *hunt_s) |
| 615 | { |
| 616 | uint32_t reg_clkctl, reg_clksel, clk_div, src_sel; |
| 617 | |
| 618 | reg_clksel = readl_relaxed(A11S_CLK_SEL_ADDR); |
| 619 | |
| 620 | /* AHB_CLK_DIV */ |
| 621 | clk_div = (reg_clksel >> 1) & 0x03; |
| 622 | /* CLK_SEL_SRC1NO */ |
| 623 | src_sel = reg_clksel & 1; |
| 624 | |
| 625 | /* |
| 626 | * If the new clock divider is higher than the previous, then |
| 627 | * program the divider before switching the clock |
| 628 | */ |
| 629 | if (hunt_s->ahbclk_div > clk_div) { |
| 630 | reg_clksel &= ~(0x3 << 1); |
| 631 | reg_clksel |= (hunt_s->ahbclk_div << 1); |
| 632 | writel_relaxed(reg_clksel, A11S_CLK_SEL_ADDR); |
| 633 | } |
| 634 | |
| 635 | /* Program clock source and divider */ |
| 636 | reg_clkctl = readl_relaxed(A11S_CLK_CNTL_ADDR); |
| 637 | reg_clkctl &= ~(0xFF << (8 * src_sel)); |
| 638 | reg_clkctl |= hunt_s->a11clk_src_sel << (4 + 8 * src_sel); |
| 639 | reg_clkctl |= hunt_s->a11clk_src_div << (0 + 8 * src_sel); |
| 640 | writel_relaxed(reg_clkctl, A11S_CLK_CNTL_ADDR); |
| 641 | |
| 642 | /* Program clock source selection */ |
| 643 | reg_clksel ^= 1; |
| 644 | writel_relaxed(reg_clksel, A11S_CLK_SEL_ADDR); |
| 645 | |
Pankaj Kumar | d66a919a | 2012-04-11 19:35:38 +0530 | [diff] [blame] | 646 | /* Wait for the clock switch to complete */ |
| 647 | mb(); |
| 648 | udelay(50); |
| 649 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 650 | /* |
| 651 | * If the new clock divider is lower than the previous, then |
| 652 | * program the divider after switching the clock |
| 653 | */ |
| 654 | if (hunt_s->ahbclk_div < clk_div) { |
| 655 | reg_clksel &= ~(0x3 << 1); |
| 656 | reg_clksel |= (hunt_s->ahbclk_div << 1); |
| 657 | writel_relaxed(reg_clksel, A11S_CLK_SEL_ADDR); |
| 658 | } |
| 659 | } |
| 660 | |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 661 | static int acpuclk_7627_set_rate(int cpu, unsigned long rate, |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 662 | enum setrate_reason reason) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 663 | { |
| 664 | uint32_t reg_clkctl; |
| 665 | struct clkctl_acpu_speed *cur_s, *tgt_s, *strt_s; |
| 666 | int res, rc = 0; |
| 667 | unsigned int plls_enabled = 0, pll; |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 668 | int delta; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 669 | |
| 670 | if (reason == SETRATE_CPUFREQ) |
| 671 | mutex_lock(&drv_state.lock); |
| 672 | |
| 673 | strt_s = cur_s = drv_state.current_speed; |
| 674 | |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 675 | WARN_ONCE(cur_s == NULL, "%s: not initialized\n", __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 676 | if (cur_s == NULL) { |
| 677 | rc = -ENOENT; |
| 678 | goto out; |
| 679 | } |
| 680 | |
| 681 | if (rate == cur_s->a11clk_khz) |
| 682 | goto out; |
| 683 | |
| 684 | for (tgt_s = acpu_freq_tbl; tgt_s->a11clk_khz != 0; tgt_s++) { |
| 685 | if (tgt_s->a11clk_khz == rate) |
| 686 | break; |
| 687 | } |
| 688 | |
| 689 | if (tgt_s->a11clk_khz == 0) { |
| 690 | rc = -EINVAL; |
| 691 | goto out; |
| 692 | } |
| 693 | |
| 694 | /* Choose the highest speed at or below 'rate' with same PLL. */ |
| 695 | if (reason != SETRATE_CPUFREQ |
| 696 | && tgt_s->a11clk_khz < cur_s->a11clk_khz) { |
| 697 | while (tgt_s->pll != ACPU_PLL_TCXO && tgt_s->pll != cur_s->pll) |
| 698 | tgt_s--; |
| 699 | } |
| 700 | |
| 701 | if (strt_s->pll != ACPU_PLL_TCXO) |
| 702 | plls_enabled |= 1 << strt_s->pll; |
| 703 | |
| 704 | if (reason == SETRATE_CPUFREQ) { |
| 705 | if (strt_s->pll != tgt_s->pll && tgt_s->pll != ACPU_PLL_TCXO) { |
Trilok Soni | 57c0778 | 2012-05-07 16:52:16 +0530 | [diff] [blame] | 706 | rc = clk_enable(pll_clk[tgt_s->pll].clk); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 707 | if (rc < 0) { |
| 708 | pr_err("PLL%d enable failed (%d)\n", |
| 709 | tgt_s->pll, rc); |
| 710 | goto out; |
| 711 | } |
| 712 | plls_enabled |= 1 << tgt_s->pll; |
| 713 | } |
| 714 | } |
| 715 | /* Need to do this when coming out of power collapse since some modem |
| 716 | * firmwares reset the VDD when the application processor enters power |
| 717 | * collapse. */ |
| 718 | if (reason == SETRATE_CPUFREQ || reason == SETRATE_PC) { |
| 719 | /* Increase VDD if needed. */ |
| 720 | if (tgt_s->vdd > cur_s->vdd) { |
| 721 | rc = acpuclk_set_vdd_level(tgt_s->vdd); |
| 722 | if (rc < 0) { |
| 723 | pr_err("Unable to switch ACPU vdd (%d)\n", rc); |
| 724 | goto out; |
| 725 | } |
| 726 | } |
| 727 | } |
| 728 | |
| 729 | /* Set wait states for CPU inbetween frequency changes */ |
| 730 | reg_clkctl = readl_relaxed(A11S_CLK_CNTL_ADDR); |
| 731 | reg_clkctl |= (100 << 16); /* set WT_ST_CNT */ |
| 732 | writel_relaxed(reg_clkctl, A11S_CLK_CNTL_ADDR); |
| 733 | |
| 734 | pr_debug("Switching from ACPU rate %u KHz -> %u KHz\n", |
| 735 | strt_s->a11clk_khz, tgt_s->a11clk_khz); |
| 736 | |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 737 | delta = abs((int)(strt_s->a11clk_khz - tgt_s->a11clk_khz)); |
| 738 | |
| 739 | if (dynamic_reprogram) { |
| 740 | if (tgt_s->pll == ACPU_PLL_4) { |
| 741 | if (strt_s->pll == ACPU_PLL_4 || |
| 742 | delta > drv_state.max_speed_delta_khz) { |
| 743 | /* |
| 744 | * Enable the backup PLL if required |
| 745 | * and switch to it. |
| 746 | */ |
| 747 | clk_enable(pll_clk[backup_s->pll].clk); |
| 748 | acpuclk_set_div(backup_s); |
Trilok Soni | 613d2d8 | 2012-09-25 01:58:20 +0530 | [diff] [blame] | 749 | update_jiffies(cpu, backup_s->lpj); |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 750 | } |
| 751 | /* Make sure PLL4 is off before reprogramming */ |
| 752 | if ((plls_enabled & (1 << tgt_s->pll))) { |
| 753 | clk_disable(pll_clk[tgt_s->pll].clk); |
Trilok Soni | 8c239d7 | 2012-09-14 13:42:37 +0530 | [diff] [blame] | 754 | plls_enabled &= ~(1 << tgt_s->pll); |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 755 | } |
| 756 | acpuclk_config_pll4(tgt_s->pll_rate); |
| 757 | pll_clk[tgt_s->pll].clk->rate = tgt_s->a11clk_khz*1000; |
| 758 | |
| 759 | } else if (strt_s->pll == ACPU_PLL_4) { |
| 760 | if (delta > drv_state.max_speed_delta_khz) { |
| 761 | /* |
| 762 | * Enable the bcackup PLL if required |
| 763 | * and switch to it. |
| 764 | */ |
| 765 | clk_enable(pll_clk[backup_s->pll].clk); |
| 766 | acpuclk_set_div(backup_s); |
Trilok Soni | 613d2d8 | 2012-09-25 01:58:20 +0530 | [diff] [blame] | 767 | update_jiffies(cpu, backup_s->lpj); |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 768 | } |
| 769 | } |
| 770 | |
Trilok Soni | 1163e8c | 2012-09-17 14:31:04 +0530 | [diff] [blame] | 771 | if ((tgt_s->pll != ACPU_PLL_TCXO) && |
| 772 | !(plls_enabled & (1 << tgt_s->pll))) { |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 773 | rc = clk_enable(pll_clk[tgt_s->pll].clk); |
| 774 | if (rc < 0) { |
| 775 | pr_err("PLL%d enable failed (%d)\n", |
| 776 | tgt_s->pll, rc); |
| 777 | goto out; |
| 778 | } |
| 779 | plls_enabled |= 1 << tgt_s->pll; |
| 780 | } |
| 781 | acpuclk_set_div(tgt_s); |
| 782 | drv_state.current_speed = tgt_s; |
| 783 | /* Re-adjust lpj for the new clock speed. */ |
Trilok Soni | f113db4 | 2012-10-17 22:20:23 +0530 | [diff] [blame] | 784 | update_jiffies(cpu, tgt_s->lpj); |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 785 | |
| 786 | /* Disable the backup PLL */ |
| 787 | if ((delta > drv_state.max_speed_delta_khz) |
| 788 | || (strt_s->pll == ACPU_PLL_4 && |
| 789 | tgt_s->pll == ACPU_PLL_4)) |
Trilok Soni | eec9dd5 | 2012-08-04 14:51:28 +0530 | [diff] [blame] | 790 | clk_disable(pll_clk[backup_s->pll].clk); |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 791 | |
| 792 | goto done; |
| 793 | } |
| 794 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 795 | while (cur_s != tgt_s) { |
| 796 | /* |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 797 | * Always jump to target freq if within max_speed_delta_khz, |
| 798 | * regardless of PLL. If differnece is greater, use the |
| 799 | * predefined steppings in the table. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 800 | */ |
| 801 | int d = abs((int)(cur_s->a11clk_khz - tgt_s->a11clk_khz)); |
| 802 | if (d > drv_state.max_speed_delta_khz) { |
| 803 | |
| 804 | if (tgt_s->a11clk_khz > cur_s->a11clk_khz) { |
| 805 | /* Step up: jump to target PLL as early as |
| 806 | * possible so indexing using TCXO (up[-1]) |
| 807 | * never occurs. */ |
| 808 | if (likely(cur_s->up[tgt_s->pll])) |
| 809 | cur_s = cur_s->up[tgt_s->pll]; |
| 810 | else |
| 811 | cur_s = cur_s->up[cur_s->pll]; |
| 812 | } else { |
| 813 | /* Step down: stay on current PLL as long as |
| 814 | * possible so indexing using TCXO (down[-1]) |
| 815 | * never occurs. */ |
| 816 | if (likely(cur_s->down[cur_s->pll])) |
| 817 | cur_s = cur_s->down[cur_s->pll]; |
| 818 | else |
| 819 | cur_s = cur_s->down[tgt_s->pll]; |
| 820 | } |
| 821 | |
| 822 | if (cur_s == NULL) { /* This should not happen. */ |
| 823 | pr_err("No stepping frequencies found. " |
| 824 | "strt_s:%u tgt_s:%u\n", |
| 825 | strt_s->a11clk_khz, tgt_s->a11clk_khz); |
| 826 | rc = -EINVAL; |
| 827 | goto out; |
| 828 | } |
| 829 | |
| 830 | } else { |
| 831 | cur_s = tgt_s; |
| 832 | } |
| 833 | |
| 834 | pr_debug("STEP khz = %u, pll = %d\n", |
| 835 | cur_s->a11clk_khz, cur_s->pll); |
| 836 | |
| 837 | if (cur_s->pll != ACPU_PLL_TCXO |
| 838 | && !(plls_enabled & (1 << cur_s->pll))) { |
Trilok Soni | 57c0778 | 2012-05-07 16:52:16 +0530 | [diff] [blame] | 839 | rc = clk_enable(pll_clk[cur_s->pll].clk); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 840 | if (rc < 0) { |
| 841 | pr_err("PLL%d enable failed (%d)\n", |
| 842 | cur_s->pll, rc); |
| 843 | goto out; |
| 844 | } |
| 845 | plls_enabled |= 1 << cur_s->pll; |
| 846 | } |
| 847 | |
| 848 | acpuclk_set_div(cur_s); |
| 849 | drv_state.current_speed = cur_s; |
Taniya Das | c43e687 | 2012-03-21 16:41:14 +0530 | [diff] [blame] | 850 | /* Re-adjust lpj for the new clock speed. */ |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 851 | update_jiffies(cpu, cur_s->lpj); |
Taniya Das | c43e687 | 2012-03-21 16:41:14 +0530 | [diff] [blame] | 852 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 853 | } |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 854 | done: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 855 | /* Nothing else to do for SWFI. */ |
| 856 | if (reason == SETRATE_SWFI) |
| 857 | goto out; |
| 858 | |
| 859 | /* Change the AXI bus frequency if we can. */ |
Trilok Soni | 89ddd22 | 2012-10-11 15:06:57 +0530 | [diff] [blame] | 860 | if (strt_s->axiclk_khz != tgt_s->axiclk_khz) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 861 | res = clk_set_rate(drv_state.ebi1_clk, |
| 862 | tgt_s->axiclk_khz * 1000); |
| 863 | if (res < 0) |
| 864 | pr_warning("Setting AXI min rate failed (%d)\n", res); |
| 865 | } |
| 866 | |
| 867 | /* Disable PLLs we are not using anymore. */ |
| 868 | if (tgt_s->pll != ACPU_PLL_TCXO) |
| 869 | plls_enabled &= ~(1 << tgt_s->pll); |
| 870 | for (pll = ACPU_PLL_0; pll < ACPU_PLL_END; pll++) |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 871 | if (plls_enabled & (1 << pll)) |
Trilok Soni | 57c0778 | 2012-05-07 16:52:16 +0530 | [diff] [blame] | 872 | clk_disable(pll_clk[pll].clk); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 873 | |
| 874 | /* Nothing else to do for power collapse. */ |
| 875 | if (reason == SETRATE_PC) |
| 876 | goto out; |
| 877 | |
| 878 | /* Drop VDD level if we can. */ |
| 879 | if (tgt_s->vdd < strt_s->vdd) { |
| 880 | res = acpuclk_set_vdd_level(tgt_s->vdd); |
| 881 | if (res < 0) |
| 882 | pr_warning("Unable to drop ACPU vdd (%d)\n", res); |
| 883 | } |
| 884 | |
| 885 | pr_debug("ACPU speed change complete\n"); |
| 886 | out: |
| 887 | if (reason == SETRATE_CPUFREQ) |
| 888 | mutex_unlock(&drv_state.lock); |
| 889 | return rc; |
| 890 | } |
| 891 | |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 892 | static void __devinit acpuclk_hw_init(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 893 | { |
| 894 | struct clkctl_acpu_speed *speed; |
Trilok Soni | 7d6c865 | 2011-07-14 15:35:07 +0530 | [diff] [blame] | 895 | uint32_t div, sel, reg_clksel; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 896 | int res; |
| 897 | |
| 898 | /* |
Trilok Soni | 57c0778 | 2012-05-07 16:52:16 +0530 | [diff] [blame] | 899 | * Prepare all the PLLs because we enable/disable them |
| 900 | * from atomic context and can't always ensure they're |
| 901 | * all prepared in non-atomic context. Same goes for |
| 902 | * ebi1_acpu_clk. |
| 903 | */ |
| 904 | BUG_ON(clk_prepare(pll_clk[ACPU_PLL_0].clk)); |
| 905 | BUG_ON(clk_prepare(pll_clk[ACPU_PLL_1].clk)); |
| 906 | BUG_ON(clk_prepare(pll_clk[ACPU_PLL_2].clk)); |
| 907 | BUG_ON(clk_prepare(pll_clk[ACPU_PLL_4].clk)); |
| 908 | BUG_ON(clk_prepare(drv_state.ebi1_clk)); |
| 909 | |
| 910 | /* |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 911 | * Determine the rate of ACPU clock |
| 912 | */ |
| 913 | |
| 914 | if (!(readl_relaxed(A11S_CLK_SEL_ADDR) & 0x01)) { /* CLK_SEL_SRC1N0 */ |
| 915 | /* CLK_SRC0_SEL */ |
| 916 | sel = (readl_relaxed(A11S_CLK_CNTL_ADDR) >> 12) & 0x7; |
| 917 | /* CLK_SRC0_DIV */ |
| 918 | div = (readl_relaxed(A11S_CLK_CNTL_ADDR) >> 8) & 0x0f; |
| 919 | } else { |
| 920 | /* CLK_SRC1_SEL */ |
| 921 | sel = (readl_relaxed(A11S_CLK_CNTL_ADDR) >> 4) & 0x07; |
| 922 | /* CLK_SRC1_DIV */ |
| 923 | div = readl_relaxed(A11S_CLK_CNTL_ADDR) & 0x0f; |
| 924 | } |
| 925 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 926 | for (speed = acpu_freq_tbl; speed->a11clk_khz != 0; speed++) { |
| 927 | if (speed->a11clk_src_sel == sel |
| 928 | && (speed->a11clk_src_div == div)) |
| 929 | break; |
| 930 | } |
| 931 | if (speed->a11clk_khz == 0) { |
| 932 | pr_err("Error - ACPU clock reports invalid speed\n"); |
| 933 | return; |
| 934 | } |
| 935 | |
| 936 | drv_state.current_speed = speed; |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 937 | if (speed->pll != ACPU_PLL_TCXO) { |
Trilok Soni | 57c0778 | 2012-05-07 16:52:16 +0530 | [diff] [blame] | 938 | if (clk_enable(pll_clk[speed->pll].clk)) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 939 | pr_warning("Failed to vote for boot PLL\n"); |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 940 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 941 | |
Trilok Soni | 7d6c865 | 2011-07-14 15:35:07 +0530 | [diff] [blame] | 942 | /* Fix div2 to 2 for 7x27/5a(aa) targets */ |
| 943 | if (!cpu_is_msm7x27()) { |
| 944 | reg_clksel = readl_relaxed(A11S_CLK_SEL_ADDR); |
| 945 | reg_clksel &= ~(0x3 << 14); |
| 946 | reg_clksel |= (0x1 << 14); |
| 947 | writel_relaxed(reg_clksel, A11S_CLK_SEL_ADDR); |
| 948 | } |
| 949 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 950 | res = clk_set_rate(drv_state.ebi1_clk, speed->axiclk_khz * 1000); |
| 951 | if (res < 0) |
| 952 | pr_warning("Setting AXI min rate failed (%d)\n", res); |
Trilok Soni | 57c0778 | 2012-05-07 16:52:16 +0530 | [diff] [blame] | 953 | res = clk_enable(drv_state.ebi1_clk); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 954 | if (res < 0) |
| 955 | pr_warning("Enabling AXI clock failed (%d)\n", res); |
| 956 | |
| 957 | pr_info("ACPU running at %d KHz\n", speed->a11clk_khz); |
| 958 | } |
| 959 | |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 960 | static unsigned long acpuclk_7627_get_rate(int cpu) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 961 | { |
| 962 | WARN_ONCE(drv_state.current_speed == NULL, |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 963 | "%s: not initialized\n", __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 964 | if (drv_state.current_speed) |
| 965 | return drv_state.current_speed->a11clk_khz; |
| 966 | else |
| 967 | return 0; |
| 968 | } |
| 969 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 970 | /*---------------------------------------------------------------------------- |
| 971 | * Clock driver initialization |
| 972 | *---------------------------------------------------------------------------*/ |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 973 | #define MHZ 1000000 |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 974 | static void __devinit select_freq_plan(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 975 | { |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 976 | unsigned long pll_mhz[ACPU_PLL_END]; |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 977 | struct pll_freq_tbl_map *t = acpu_freq_tbl_list; |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 978 | int i; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 979 | |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 980 | /* Get PLL clocks */ |
| 981 | for (i = 0; i < ACPU_PLL_END; i++) { |
| 982 | if (pll_clk[i].name) { |
| 983 | pll_clk[i].clk = clk_get_sys("acpu", pll_clk[i].name); |
| 984 | if (IS_ERR(pll_clk[i].clk)) { |
| 985 | pll_mhz[i] = 0; |
| 986 | continue; |
| 987 | } |
| 988 | /* Get PLL's Rate */ |
| 989 | pll_mhz[i] = clk_get_rate(pll_clk[i].clk)/MHZ; |
| 990 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 991 | } |
| 992 | |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 993 | /* |
| 994 | * For the pll configuration used in acpuclock table e.g. |
| 995 | * pll0_960_pll1_245_pll2_1200" is same for 7627 and |
| 996 | * 7625a (as pll0,pll1,pll2) having same rates, but frequency |
| 997 | * table is different for both targets. |
| 998 | * |
| 999 | * Hence below for loop will not be able to select correct |
| 1000 | * table based on PLL rates as rates are same. Hence we need |
| 1001 | * to add this cpu check for selecting the correct acpuclock table. |
| 1002 | */ |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 1003 | if (cpu_is_msm7x25a()) { |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 1004 | if (pll_mhz[ACPU_PLL_1] == 245) { |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 1005 | acpu_freq_tbl = |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 1006 | pll0_960_pll1_245_pll2_1200_25a; |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 1007 | } else if (pll_mhz[ACPU_PLL_1] == 737) { |
Trilok Soni | 9bb022c | 2011-10-31 18:25:19 +0530 | [diff] [blame] | 1008 | acpu_freq_tbl = |
Pankaj Kumar | c9136b3 | 2012-01-02 18:46:13 +0530 | [diff] [blame] | 1009 | pll0_960_pll1_737_pll2_1200_25a; |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 1010 | } |
Trilok Soni | a563990 | 2012-08-05 16:49:07 +0530 | [diff] [blame] | 1011 | t->tbl = acpu_freq_tbl; |
| 1012 | } |
| 1013 | |
| 1014 | /* |
| 1015 | * 1008Mhz table selection based on the Lvalue of the PLL |
Trilok Soni | 72cacdb | 2012-10-15 17:58:57 +0530 | [diff] [blame] | 1016 | * is conflicting with the 7627AA 1GHz parts since 8625 chips |
| 1017 | * are using different clock plan based reprogramming method. |
Trilok Soni | a563990 | 2012-08-05 16:49:07 +0530 | [diff] [blame] | 1018 | */ |
Trilok Soni | 72cacdb | 2012-10-15 17:58:57 +0530 | [diff] [blame] | 1019 | if (cpu_is_msm8625() && pll_mhz[ACPU_PLL_4] == 1008) { |
Trilok Soni | a563990 | 2012-08-05 16:49:07 +0530 | [diff] [blame] | 1020 | if (pll_mhz[ACPU_PLL_2] == 245) |
| 1021 | acpu_freq_tbl = |
| 1022 | pll0_960_pll1_245_pll2_1200_pll4_1008_2p0; |
| 1023 | else |
| 1024 | acpu_freq_tbl = |
| 1025 | pll0_960_pll1_196_pll2_1200_pll4_1008_2p0; |
| 1026 | t->tbl = acpu_freq_tbl; |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 1027 | } else { |
| 1028 | /* Select the right table to use. */ |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 1029 | for (; t->tbl != 0; t++) { |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 1030 | if (t->pll0_rate == pll_mhz[ACPU_PLL_0] |
| 1031 | && t->pll1_rate == pll_mhz[ACPU_PLL_1] |
| 1032 | && t->pll2_rate == pll_mhz[ACPU_PLL_2] |
| 1033 | && t->pll4_rate == pll_mhz[ACPU_PLL_4]) { |
| 1034 | acpu_freq_tbl = t->tbl; |
Trilok Soni | 54d35c4 | 2011-07-14 17:47:50 +0530 | [diff] [blame] | 1035 | break; |
| 1036 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1037 | } |
| 1038 | } |
| 1039 | |
Trilok Soni | 3f33ffc | 2012-08-03 20:14:04 +0530 | [diff] [blame] | 1040 | if (acpu_freq_tbl == NULL) { |
| 1041 | pr_crit("Unknown PLL configuration!\n"); |
| 1042 | BUG(); |
| 1043 | } |
| 1044 | |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 1045 | /* |
Trilok Soni | 3f33ffc | 2012-08-03 20:14:04 +0530 | [diff] [blame] | 1046 | * Turn ON the dynamic reprogramming method |
| 1047 | * if one of the table entry has pll_rate defined. |
| 1048 | */ |
| 1049 | for ( ; t->tbl->a11clk_khz; t->tbl++) { |
| 1050 | if (t->tbl->pll_rate) { |
| 1051 | if (!dynamic_reprogram) { |
| 1052 | dynamic_reprogram = 1; |
| 1053 | pr_info("Dynamic reprogramming is ON\n"); |
| 1054 | } |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | /* |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 1059 | * Also find the backup pll used during PLL4 reprogramming. |
| 1060 | * We are using PLL2@600MHz as backup PLL, since 800MHz jump |
| 1061 | * is fine. |
| 1062 | */ |
Trilok Soni | 3f33ffc | 2012-08-03 20:14:04 +0530 | [diff] [blame] | 1063 | if (dynamic_reprogram) { |
| 1064 | for (t->tbl = acpu_freq_tbl; t->tbl->a11clk_khz; t->tbl++) { |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 1065 | if (t->tbl->pll == ACPU_PLL_2 && |
| 1066 | t->tbl->a11clk_src_div == 1) { |
| 1067 | backup_s = t->tbl; |
| 1068 | break; |
| 1069 | } |
| 1070 | } |
| 1071 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1072 | } |
| 1073 | |
| 1074 | /* |
| 1075 | * Hardware requires the CPU to be dropped to less than MAX_WAIT_FOR_IRQ_KHZ |
| 1076 | * before entering a wait for irq low-power mode. Find a suitable rate. |
| 1077 | */ |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 1078 | static unsigned long __devinit find_wait_for_irq_khz(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1079 | { |
| 1080 | unsigned long found_khz = 0; |
| 1081 | int i; |
| 1082 | |
| 1083 | for (i = 0; acpu_freq_tbl[i].a11clk_khz && |
| 1084 | acpu_freq_tbl[i].a11clk_khz <= MAX_WAIT_FOR_IRQ_KHZ; i++) |
| 1085 | found_khz = acpu_freq_tbl[i].a11clk_khz; |
| 1086 | |
| 1087 | return found_khz; |
| 1088 | } |
| 1089 | |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 1090 | static void __devinit lpj_init(void) |
Taniya Das | c43e687 | 2012-03-21 16:41:14 +0530 | [diff] [blame] | 1091 | { |
| 1092 | int i = 0, cpu; |
| 1093 | const struct clkctl_acpu_speed *base_clk = drv_state.current_speed; |
| 1094 | unsigned long loops; |
| 1095 | |
| 1096 | for_each_possible_cpu(cpu) { |
| 1097 | #ifdef CONFIG_SMP |
| 1098 | loops = per_cpu(cpu_data, cpu).loops_per_jiffy; |
| 1099 | #else |
| 1100 | loops = loops_per_jiffy; |
| 1101 | #endif |
| 1102 | for (i = 0; acpu_freq_tbl[i].a11clk_khz; i++) { |
| 1103 | acpu_freq_tbl[i].lpj = cpufreq_scale( |
| 1104 | loops, |
| 1105 | base_clk->a11clk_khz, |
| 1106 | acpu_freq_tbl[i].a11clk_khz); |
| 1107 | } |
| 1108 | } |
| 1109 | } |
| 1110 | |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 1111 | static void __devinit precompute_stepping(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1112 | { |
| 1113 | int i, step_idx; |
| 1114 | |
| 1115 | #define cur_freq acpu_freq_tbl[i].a11clk_khz |
| 1116 | #define step_freq acpu_freq_tbl[step_idx].a11clk_khz |
| 1117 | #define cur_pll acpu_freq_tbl[i].pll |
| 1118 | #define step_pll acpu_freq_tbl[step_idx].pll |
| 1119 | |
| 1120 | for (i = 0; acpu_freq_tbl[i].a11clk_khz; i++) { |
| 1121 | |
| 1122 | /* Calculate max "up" step for each destination PLL */ |
| 1123 | step_idx = i + 1; |
| 1124 | while (step_freq && (step_freq - cur_freq) |
| 1125 | <= drv_state.max_speed_delta_khz) { |
| 1126 | acpu_freq_tbl[i].up[step_pll] = |
| 1127 | &acpu_freq_tbl[step_idx]; |
| 1128 | step_idx++; |
| 1129 | } |
| 1130 | if (step_idx == (i + 1) && step_freq) { |
| 1131 | pr_crit("Delta between freqs %u KHz and %u KHz is" |
| 1132 | " too high!\n", cur_freq, step_freq); |
| 1133 | BUG(); |
| 1134 | } |
| 1135 | |
| 1136 | /* Calculate max "down" step for each destination PLL */ |
| 1137 | step_idx = i - 1; |
| 1138 | while (step_idx >= 0 && (cur_freq - step_freq) |
| 1139 | <= drv_state.max_speed_delta_khz) { |
| 1140 | acpu_freq_tbl[i].down[step_pll] = |
| 1141 | &acpu_freq_tbl[step_idx]; |
| 1142 | step_idx--; |
| 1143 | } |
| 1144 | if (step_idx == (i - 1) && i > 0) { |
| 1145 | pr_crit("Delta between freqs %u KHz and %u KHz is" |
| 1146 | " too high!\n", cur_freq, step_freq); |
| 1147 | BUG(); |
| 1148 | } |
| 1149 | } |
| 1150 | } |
| 1151 | |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 1152 | static void __devinit print_acpu_freq_tbl(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1153 | { |
| 1154 | struct clkctl_acpu_speed *t; |
| 1155 | short down_idx[ACPU_PLL_END]; |
| 1156 | short up_idx[ACPU_PLL_END]; |
| 1157 | int i, j; |
| 1158 | |
| 1159 | #define FREQ_IDX(freq_ptr) (freq_ptr - acpu_freq_tbl) |
| 1160 | pr_info("Id CPU-KHz PLL DIV AHB-KHz ADIV AXI-KHz " |
| 1161 | "D0 D1 D2 D4 U0 U1 U2 U4\n"); |
| 1162 | |
| 1163 | t = &acpu_freq_tbl[0]; |
| 1164 | for (i = 0; t->a11clk_khz != 0; i++) { |
| 1165 | |
| 1166 | for (j = 0; j < ACPU_PLL_END; j++) { |
| 1167 | down_idx[j] = t->down[j] ? FREQ_IDX(t->down[j]) : -1; |
| 1168 | up_idx[j] = t->up[j] ? FREQ_IDX(t->up[j]) : -1; |
| 1169 | } |
| 1170 | |
| 1171 | pr_info("%2d %7d %3d %3d %7d %4d %7d " |
| 1172 | "%2d %2d %2d %2d %2d %2d %2d %2d\n", |
| 1173 | i, t->a11clk_khz, t->pll, t->a11clk_src_div + 1, |
| 1174 | t->ahbclk_khz, t->ahbclk_div + 1, t->axiclk_khz, |
| 1175 | down_idx[0], down_idx[1], down_idx[2], down_idx[4], |
| 1176 | up_idx[0], up_idx[1], up_idx[2], up_idx[4]); |
| 1177 | |
| 1178 | t++; |
| 1179 | } |
| 1180 | } |
| 1181 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1182 | |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 1183 | static struct acpuclk_data acpuclk_7627_data = { |
| 1184 | .set_rate = acpuclk_7627_set_rate, |
| 1185 | .get_rate = acpuclk_7627_get_rate, |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 1186 | .power_collapse_khz = POWER_COLLAPSE_KHZ, |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 1187 | .switch_time_us = 50, |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 1188 | }; |
| 1189 | |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 1190 | static int __devinit acpuclk_7627_probe(struct platform_device *pdev) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1191 | { |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 1192 | const struct acpuclk_pdata *pdata = pdev->dev.platform_data; |
| 1193 | |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 1194 | pr_info("%s()\n", __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1195 | |
| 1196 | drv_state.ebi1_clk = clk_get(NULL, "ebi1_acpu_clk"); |
| 1197 | BUG_ON(IS_ERR(drv_state.ebi1_clk)); |
| 1198 | |
| 1199 | mutex_init(&drv_state.lock); |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 1200 | drv_state.max_speed_delta_khz = pdata->max_speed_delta_khz; |
Pankaj Kumar | 3912c98 | 2011-12-07 16:59:03 +0530 | [diff] [blame] | 1201 | select_freq_plan(); |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 1202 | acpuclk_7627_data.wait_for_irq_khz = find_wait_for_irq_khz(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1203 | precompute_stepping(); |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 1204 | acpuclk_hw_init(); |
Taniya Das | c43e687 | 2012-03-21 16:41:14 +0530 | [diff] [blame] | 1205 | lpj_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1206 | print_acpu_freq_tbl(); |
Pankaj Kumar | 6e66f37 | 2011-12-05 14:41:58 +0530 | [diff] [blame] | 1207 | acpuclk_register(&acpuclk_7627_data); |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 1208 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1209 | #ifdef CONFIG_CPU_FREQ_MSM |
| 1210 | cpufreq_table_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1211 | #endif |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 1212 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1213 | } |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 1214 | |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 1215 | static struct platform_driver acpuclk_7627_driver = { |
| 1216 | .probe = acpuclk_7627_probe, |
| 1217 | .driver = { |
| 1218 | .name = "acpuclk-7627", |
| 1219 | .owner = THIS_MODULE, |
| 1220 | }, |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 1221 | }; |
| 1222 | |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 1223 | static int __init acpuclk_7627_init(void) |
| 1224 | { |
| 1225 | return platform_driver_register(&acpuclk_7627_driver); |
| 1226 | } |
| 1227 | postcore_initcall(acpuclk_7627_init); |
Kaushal Kumar | 86473f0 | 2012-06-28 19:35:58 +0530 | [diff] [blame] | 1228 | |