Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 14 | #include <linux/module.h> |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/of.h> |
Matt Wagantall | d591bf2 | 2012-06-29 11:20:53 -0700 | [diff] [blame] | 17 | #include <mach/rpm-regulator-smd.h> |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 18 | #include <mach/msm_bus_board.h> |
| 19 | #include <mach/msm_bus.h> |
| 20 | #include <mach/socinfo.h> |
| 21 | |
| 22 | #include "acpuclock.h" |
| 23 | #include "acpuclock-krait.h" |
| 24 | |
| 25 | /* Corner type vreg VDD values */ |
Matt Wagantall | f06e357 | 2012-07-27 12:45:24 -0700 | [diff] [blame] | 26 | #define LVL_NONE RPM_REGULATOR_CORNER_NONE |
Matt Wagantall | d591bf2 | 2012-06-29 11:20:53 -0700 | [diff] [blame] | 27 | #define LVL_LOW RPM_REGULATOR_CORNER_SVS_SOC |
| 28 | #define LVL_NOM RPM_REGULATOR_CORNER_NORMAL |
| 29 | #define LVL_HIGH RPM_REGULATOR_CORNER_SUPER_TURBO |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 30 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 31 | static struct hfpll_data hfpll_data __initdata = { |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 32 | .mode_offset = 0x00, |
| 33 | .l_offset = 0x04, |
| 34 | .m_offset = 0x08, |
| 35 | .n_offset = 0x0C, |
Matt Wagantall | a77b7f3 | 2012-07-18 16:32:01 -0700 | [diff] [blame] | 36 | .has_user_reg = true, |
| 37 | .user_offset = 0x10, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 38 | .config_offset = 0x14, |
Matt Wagantall | a77b7f3 | 2012-07-18 16:32:01 -0700 | [diff] [blame] | 39 | /* TODO: Verify magic numbers when final values are available. */ |
| 40 | .user_val = 0x8, |
| 41 | .config_val = 0x04D0405D, |
| 42 | .low_vco_l_max = 65, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 43 | .low_vdd_l_max = 52, |
Matt Wagantall | 87465f5 | 2012-07-23 22:03:06 -0700 | [diff] [blame] | 44 | .nom_vdd_l_max = 104, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 45 | .vdd[HFPLL_VDD_NONE] = LVL_NONE, |
| 46 | .vdd[HFPLL_VDD_LOW] = LVL_LOW, |
| 47 | .vdd[HFPLL_VDD_NOM] = LVL_NOM, |
Matt Wagantall | 87465f5 | 2012-07-23 22:03:06 -0700 | [diff] [blame] | 48 | .vdd[HFPLL_VDD_HIGH] = LVL_HIGH, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 49 | }; |
| 50 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 51 | static struct scalable scalable[] __initdata = { |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 52 | [CPU0] = { |
| 53 | .hfpll_phys_base = 0xF908A000, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 54 | .l2cpmr_iaddr = 0x4501, |
Matt Wagantall | 6d9c416 | 2012-07-16 18:58:16 -0700 | [diff] [blame] | 55 | .vreg[VREG_CORE] = { "krait0", 1050000 }, |
Matt Wagantall | 75473eb | 2012-05-31 15:23:22 -0700 | [diff] [blame] | 56 | .vreg[VREG_MEM] = { "krait0_mem", 1050000 }, |
Matt Wagantall | d591bf2 | 2012-06-29 11:20:53 -0700 | [diff] [blame] | 57 | .vreg[VREG_DIG] = { "krait0_dig", LVL_HIGH }, |
Matt Wagantall | 337cdb7 | 2012-06-29 12:07:27 -0700 | [diff] [blame] | 58 | .vreg[VREG_HFPLL_A] = { "krait0_hfpll_a", 2150000 }, |
| 59 | .vreg[VREG_HFPLL_B] = { "krait0_hfpll_b", 1800000 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 60 | }, |
| 61 | [CPU1] = { |
| 62 | .hfpll_phys_base = 0xF909A000, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 63 | .l2cpmr_iaddr = 0x5501, |
Matt Wagantall | 6d9c416 | 2012-07-16 18:58:16 -0700 | [diff] [blame] | 64 | .vreg[VREG_CORE] = { "krait1", 1050000 }, |
Matt Wagantall | 75473eb | 2012-05-31 15:23:22 -0700 | [diff] [blame] | 65 | .vreg[VREG_MEM] = { "krait1_mem", 1050000 }, |
Matt Wagantall | d591bf2 | 2012-06-29 11:20:53 -0700 | [diff] [blame] | 66 | .vreg[VREG_DIG] = { "krait1_dig", LVL_HIGH }, |
Matt Wagantall | 337cdb7 | 2012-06-29 12:07:27 -0700 | [diff] [blame] | 67 | .vreg[VREG_HFPLL_A] = { "krait1_hfpll_a", 2150000 }, |
| 68 | .vreg[VREG_HFPLL_B] = { "krait1_hfpll_b", 1800000 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 69 | }, |
| 70 | [CPU2] = { |
| 71 | .hfpll_phys_base = 0xF90AA000, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 72 | .l2cpmr_iaddr = 0x6501, |
Matt Wagantall | 6d9c416 | 2012-07-16 18:58:16 -0700 | [diff] [blame] | 73 | .vreg[VREG_CORE] = { "krait2", 1050000 }, |
Matt Wagantall | 75473eb | 2012-05-31 15:23:22 -0700 | [diff] [blame] | 74 | .vreg[VREG_MEM] = { "krait2_mem", 1050000 }, |
Matt Wagantall | d591bf2 | 2012-06-29 11:20:53 -0700 | [diff] [blame] | 75 | .vreg[VREG_DIG] = { "krait2_dig", LVL_HIGH }, |
Matt Wagantall | 337cdb7 | 2012-06-29 12:07:27 -0700 | [diff] [blame] | 76 | .vreg[VREG_HFPLL_A] = { "krait2_hfpll_a", 2150000 }, |
| 77 | .vreg[VREG_HFPLL_B] = { "krait2_hfpll_b", 1800000 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 78 | }, |
| 79 | [CPU3] = { |
| 80 | .hfpll_phys_base = 0xF90BA000, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 81 | .l2cpmr_iaddr = 0x7501, |
Matt Wagantall | 6d9c416 | 2012-07-16 18:58:16 -0700 | [diff] [blame] | 82 | .vreg[VREG_CORE] = { "krait3", 1050000 }, |
Matt Wagantall | 75473eb | 2012-05-31 15:23:22 -0700 | [diff] [blame] | 83 | .vreg[VREG_MEM] = { "krait3_mem", 1050000 }, |
Matt Wagantall | d591bf2 | 2012-06-29 11:20:53 -0700 | [diff] [blame] | 84 | .vreg[VREG_DIG] = { "krait3_dig", LVL_HIGH }, |
Matt Wagantall | 337cdb7 | 2012-06-29 12:07:27 -0700 | [diff] [blame] | 85 | .vreg[VREG_HFPLL_A] = { "krait3_hfpll_a", 2150000 }, |
| 86 | .vreg[VREG_HFPLL_B] = { "krait3_hfpll_b", 1800000 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 87 | }, |
| 88 | [L2] = { |
| 89 | .hfpll_phys_base = 0xF9016000, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 90 | .l2cpmr_iaddr = 0x0500, |
Matt Wagantall | 337cdb7 | 2012-06-29 12:07:27 -0700 | [diff] [blame] | 91 | .vreg[VREG_HFPLL_A] = { "l2_hfpll_a", 2150000 }, |
| 92 | .vreg[VREG_HFPLL_B] = { "l2_hfpll_b", 1800000 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 93 | }, |
| 94 | }; |
| 95 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 96 | static struct msm_bus_paths bw_level_tbl[] __initdata = { |
Matt Wagantall | f06e357 | 2012-07-27 12:45:24 -0700 | [diff] [blame] | 97 | [0] = BW_MBPS(552), /* At least 69 MHz on bus. */ |
| 98 | [1] = BW_MBPS(1112), /* At least 139 MHz on bus. */ |
| 99 | [2] = BW_MBPS(2224), /* At least 278 MHz on bus. */ |
| 100 | [3] = BW_MBPS(4448), /* At least 556 MHz on bus. */ |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 101 | }; |
| 102 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 103 | static struct msm_bus_scale_pdata bus_scale_data __initdata = { |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 104 | .usecase = bw_level_tbl, |
| 105 | .num_usecases = ARRAY_SIZE(bw_level_tbl), |
| 106 | .active_only = 1, |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 107 | .name = "acpuclk-8974", |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 108 | }; |
| 109 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 110 | static struct l2_level l2_freq_tbl[] __initdata = { |
Matt Wagantall | f06e357 | 2012-07-27 12:45:24 -0700 | [diff] [blame] | 111 | [0] = { { 300000, PLL_0, 0, 2, 0 }, LVL_LOW, 950000, 0 }, |
| 112 | [1] = { { 384000, HFPLL, 2, 0, 40 }, LVL_NOM, 950000, 1 }, |
| 113 | [2] = { { 460800, HFPLL, 2, 0, 48 }, LVL_NOM, 950000, 1 }, |
| 114 | [3] = { { 537600, HFPLL, 1, 0, 28 }, LVL_NOM, 950000, 2 }, |
| 115 | [4] = { { 576000, HFPLL, 1, 0, 30 }, LVL_NOM, 950000, 2 }, |
| 116 | [5] = { { 652800, HFPLL, 1, 0, 34 }, LVL_NOM, 950000, 2 }, |
| 117 | [6] = { { 729600, HFPLL, 1, 0, 38 }, LVL_NOM, 950000, 2 }, |
| 118 | [7] = { { 806400, HFPLL, 1, 0, 42 }, LVL_NOM, 950000, 2 }, |
| 119 | [8] = { { 883200, HFPLL, 1, 0, 46 }, LVL_HIGH, 1050000, 2 }, |
| 120 | [9] = { { 960000, HFPLL, 1, 0, 50 }, LVL_HIGH, 1050000, 2 }, |
| 121 | [10] = { { 1036800, HFPLL, 1, 0, 54 }, LVL_HIGH, 1050000, 3 }, |
| 122 | [11] = { { 1113600, HFPLL, 1, 0, 58 }, LVL_HIGH, 1050000, 3 }, |
| 123 | [12] = { { 1190400, HFPLL, 1, 0, 62 }, LVL_HIGH, 1050000, 3 }, |
| 124 | [13] = { { 1267200, HFPLL, 1, 0, 66 }, LVL_HIGH, 1050000, 3 }, |
| 125 | [14] = { { 1344000, HFPLL, 1, 0, 70 }, LVL_HIGH, 1050000, 3 }, |
| 126 | [15] = { { 1420800, HFPLL, 1, 0, 74 }, LVL_HIGH, 1050000, 3 }, |
| 127 | [16] = { { 1497600, HFPLL, 1, 0, 78 }, LVL_HIGH, 1050000, 3 }, |
| 128 | [17] = { { 1574400, HFPLL, 1, 0, 82 }, LVL_HIGH, 1050000, 3 }, |
| 129 | [18] = { { 1651200, HFPLL, 1, 0, 86 }, LVL_HIGH, 1050000, 3 }, |
| 130 | [19] = { { 1728000, HFPLL, 1, 0, 90 }, LVL_HIGH, 1050000, 3 }, |
| 131 | [20] = { { 1804800, HFPLL, 1, 0, 94 }, LVL_HIGH, 1050000, 3 }, |
| 132 | [21] = { { 1881600, HFPLL, 1, 0, 98 }, LVL_HIGH, 1050000, 3 }, |
| 133 | [22] = { { 1958400, HFPLL, 1, 0, 102 }, LVL_HIGH, 1050000, 3 }, |
| 134 | [23] = { { 2035200, HFPLL, 1, 0, 106 }, LVL_HIGH, 1050000, 3 }, |
| 135 | [24] = { { 2112000, HFPLL, 1, 0, 110 }, LVL_HIGH, 1050000, 3 }, |
| 136 | [25] = { { 2188800, HFPLL, 1, 0, 114 }, LVL_HIGH, 1050000, 3 }, |
Stephen Boyd | 791bca9 | 2012-09-11 21:08:13 -0700 | [diff] [blame] | 137 | { } |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 138 | }; |
| 139 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 140 | static struct acpu_level acpu_freq_tbl[] __initdata = { |
Matt Wagantall | f06e357 | 2012-07-27 12:45:24 -0700 | [diff] [blame] | 141 | { 1, { 300000, PLL_0, 0, 2, 0 }, L2(0), 950000, 3200000 }, |
| 142 | { 1, { 384000, HFPLL, 2, 0, 40 }, L2(3), 950000, 3200000 }, |
| 143 | { 1, { 460800, HFPLL, 2, 0, 48 }, L2(3), 950000, 3200000 }, |
| 144 | { 1, { 537600, HFPLL, 1, 0, 28 }, L2(5), 950000, 3200000 }, |
| 145 | { 1, { 576000, HFPLL, 1, 0, 30 }, L2(5), 950000, 3200000 }, |
| 146 | { 1, { 652800, HFPLL, 1, 0, 34 }, L2(5), 950000, 3200000 }, |
| 147 | { 1, { 729600, HFPLL, 1, 0, 38 }, L2(5), 950000, 3200000 }, |
| 148 | { 1, { 806400, HFPLL, 1, 0, 42 }, L2(7), 950000, 3200000 }, |
| 149 | { 1, { 883200, HFPLL, 1, 0, 46 }, L2(7), 950000, 3200000 }, |
| 150 | { 1, { 960000, HFPLL, 1, 0, 50 }, L2(7), 950000, 3200000 }, |
| 151 | { 1, { 1036800, HFPLL, 1, 0, 54 }, L2(7), 950000, 3200000 }, |
Matt Wagantall | 2badbdc | 2012-08-20 21:57:28 -0700 | [diff] [blame] | 152 | { 1, { 1113600, HFPLL, 1, 0, 58 }, L2(12), 1050000, 3200000 }, |
| 153 | { 1, { 1190400, HFPLL, 1, 0, 62 }, L2(12), 1050000, 3200000 }, |
| 154 | { 1, { 1267200, HFPLL, 1, 0, 66 }, L2(12), 1050000, 3200000 }, |
| 155 | { 1, { 1344000, HFPLL, 1, 0, 70 }, L2(15), 1050000, 3200000 }, |
| 156 | { 1, { 1420800, HFPLL, 1, 0, 74 }, L2(15), 1050000, 3200000 }, |
| 157 | { 1, { 1497600, HFPLL, 1, 0, 78 }, L2(16), 1050000, 3200000 }, |
Matt Wagantall | f06e357 | 2012-07-27 12:45:24 -0700 | [diff] [blame] | 158 | { 0, { 1574400, HFPLL, 1, 0, 82 }, L2(20), 1050000, 3200000 }, |
| 159 | { 0, { 1651200, HFPLL, 1, 0, 86 }, L2(20), 1050000, 3200000 }, |
| 160 | { 0, { 1728000, HFPLL, 1, 0, 90 }, L2(20), 1050000, 3200000 }, |
| 161 | { 0, { 1804800, HFPLL, 1, 0, 94 }, L2(25), 1050000, 3200000 }, |
| 162 | { 0, { 1881600, HFPLL, 1, 0, 98 }, L2(25), 1050000, 3200000 }, |
| 163 | { 0, { 1958400, HFPLL, 1, 0, 102 }, L2(25), 1050000, 3200000 }, |
| 164 | { 0, { 1996800, HFPLL, 1, 0, 104 }, L2(25), 1050000, 3200000 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 165 | { 0, { 0 } } |
| 166 | }; |
| 167 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 168 | static struct pvs_table pvs_tables[NUM_PVS] __initdata = { |
| 169 | [PVS_SLOW] = { acpu_freq_tbl, sizeof(acpu_freq_tbl) }, |
| 170 | [PVS_NOMINAL] = { acpu_freq_tbl, sizeof(acpu_freq_tbl) }, |
| 171 | [PVS_FAST] = { acpu_freq_tbl, sizeof(acpu_freq_tbl) }, |
| 172 | }; |
| 173 | |
| 174 | static struct acpuclk_krait_params acpuclk_8974_params __initdata = { |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 175 | .scalable = scalable, |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 176 | .scalable_size = sizeof(scalable), |
| 177 | .hfpll_data = &hfpll_data, |
| 178 | .pvs_tables = pvs_tables, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 179 | .l2_freq_tbl = l2_freq_tbl, |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 180 | .l2_freq_tbl_size = sizeof(l2_freq_tbl), |
| 181 | .bus_scale = &bus_scale_data, |
Matt Wagantall | ee2b437 | 2012-09-17 17:51:06 -0700 | [diff] [blame] | 182 | .pte_efuse_phys = 0xFC4B80B0, |
Matt Wagantall | b7c231b | 2012-07-24 18:40:17 -0700 | [diff] [blame] | 183 | .stby_khz = 300000, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 184 | }; |
| 185 | |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 186 | static int __init acpuclk_8974_probe(struct platform_device *pdev) |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 187 | { |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 188 | return acpuclk_krait_init(&pdev->dev, &acpuclk_8974_params); |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 189 | } |
| 190 | |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 191 | static struct of_device_id acpuclk_8974_match_table[] = { |
| 192 | { .compatible = "qcom,acpuclk-8974" }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 193 | {} |
| 194 | }; |
| 195 | |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 196 | static struct platform_driver acpuclk_8974_driver = { |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 197 | .driver = { |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 198 | .name = "acpuclk-8974", |
| 199 | .of_match_table = acpuclk_8974_match_table, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 200 | .owner = THIS_MODULE, |
| 201 | }, |
| 202 | }; |
| 203 | |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 204 | static int __init acpuclk_8974_init(void) |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 205 | { |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 206 | return platform_driver_probe(&acpuclk_8974_driver, |
| 207 | acpuclk_8974_probe); |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 208 | } |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 209 | device_initcall(acpuclk_8974_init); |