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