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 | d591bf2 | 2012-06-29 11:20:53 -0700 | [diff] [blame] | 26 | #define LVL_NONE RPM_REGULATOR_CORNER_RETENTION |
| 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, |
| 36 | .config_offset = 0x14, |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 37 | /* TODO: Verify magic number for 8974 when available. */ |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 38 | .config_val = 0x7845C665, |
| 39 | .low_vdd_l_max = 52, |
| 40 | .vdd[HFPLL_VDD_NONE] = LVL_NONE, |
| 41 | .vdd[HFPLL_VDD_LOW] = LVL_LOW, |
| 42 | .vdd[HFPLL_VDD_NOM] = LVL_NOM, |
| 43 | }; |
| 44 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 45 | static struct scalable scalable[] __initdata = { |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 46 | [CPU0] = { |
| 47 | .hfpll_phys_base = 0xF908A000, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 48 | .l2cpmr_iaddr = 0x4501, |
Matt Wagantall | 6d9c416 | 2012-07-16 18:58:16 -0700 | [diff] [blame^] | 49 | .vreg[VREG_CORE] = { "krait0", 1050000 }, |
Matt Wagantall | 75473eb | 2012-05-31 15:23:22 -0700 | [diff] [blame] | 50 | .vreg[VREG_MEM] = { "krait0_mem", 1050000 }, |
Matt Wagantall | d591bf2 | 2012-06-29 11:20:53 -0700 | [diff] [blame] | 51 | .vreg[VREG_DIG] = { "krait0_dig", LVL_HIGH }, |
Matt Wagantall | 337cdb7 | 2012-06-29 12:07:27 -0700 | [diff] [blame] | 52 | .vreg[VREG_HFPLL_A] = { "krait0_hfpll_a", 2150000 }, |
| 53 | .vreg[VREG_HFPLL_B] = { "krait0_hfpll_b", 1800000 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 54 | }, |
| 55 | [CPU1] = { |
| 56 | .hfpll_phys_base = 0xF909A000, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 57 | .l2cpmr_iaddr = 0x5501, |
Matt Wagantall | 6d9c416 | 2012-07-16 18:58:16 -0700 | [diff] [blame^] | 58 | .vreg[VREG_CORE] = { "krait1", 1050000 }, |
Matt Wagantall | 75473eb | 2012-05-31 15:23:22 -0700 | [diff] [blame] | 59 | .vreg[VREG_MEM] = { "krait1_mem", 1050000 }, |
Matt Wagantall | d591bf2 | 2012-06-29 11:20:53 -0700 | [diff] [blame] | 60 | .vreg[VREG_DIG] = { "krait1_dig", LVL_HIGH }, |
Matt Wagantall | 337cdb7 | 2012-06-29 12:07:27 -0700 | [diff] [blame] | 61 | .vreg[VREG_HFPLL_A] = { "krait1_hfpll_a", 2150000 }, |
| 62 | .vreg[VREG_HFPLL_B] = { "krait1_hfpll_b", 1800000 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 63 | }, |
| 64 | [CPU2] = { |
| 65 | .hfpll_phys_base = 0xF90AA000, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 66 | .l2cpmr_iaddr = 0x6501, |
Matt Wagantall | 6d9c416 | 2012-07-16 18:58:16 -0700 | [diff] [blame^] | 67 | .vreg[VREG_CORE] = { "krait2", 1050000 }, |
Matt Wagantall | 75473eb | 2012-05-31 15:23:22 -0700 | [diff] [blame] | 68 | .vreg[VREG_MEM] = { "krait2_mem", 1050000 }, |
Matt Wagantall | d591bf2 | 2012-06-29 11:20:53 -0700 | [diff] [blame] | 69 | .vreg[VREG_DIG] = { "krait2_dig", LVL_HIGH }, |
Matt Wagantall | 337cdb7 | 2012-06-29 12:07:27 -0700 | [diff] [blame] | 70 | .vreg[VREG_HFPLL_A] = { "krait2_hfpll_a", 2150000 }, |
| 71 | .vreg[VREG_HFPLL_B] = { "krait2_hfpll_b", 1800000 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 72 | }, |
| 73 | [CPU3] = { |
| 74 | .hfpll_phys_base = 0xF90BA000, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 75 | .l2cpmr_iaddr = 0x7501, |
Matt Wagantall | 6d9c416 | 2012-07-16 18:58:16 -0700 | [diff] [blame^] | 76 | .vreg[VREG_CORE] = { "krait3", 1050000 }, |
Matt Wagantall | 75473eb | 2012-05-31 15:23:22 -0700 | [diff] [blame] | 77 | .vreg[VREG_MEM] = { "krait3_mem", 1050000 }, |
Matt Wagantall | d591bf2 | 2012-06-29 11:20:53 -0700 | [diff] [blame] | 78 | .vreg[VREG_DIG] = { "krait3_dig", LVL_HIGH }, |
Matt Wagantall | 337cdb7 | 2012-06-29 12:07:27 -0700 | [diff] [blame] | 79 | .vreg[VREG_HFPLL_A] = { "krait3_hfpll_a", 2150000 }, |
| 80 | .vreg[VREG_HFPLL_B] = { "krait3_hfpll_b", 1800000 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 81 | }, |
| 82 | [L2] = { |
| 83 | .hfpll_phys_base = 0xF9016000, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 84 | .l2cpmr_iaddr = 0x0500, |
Matt Wagantall | 337cdb7 | 2012-06-29 12:07:27 -0700 | [diff] [blame] | 85 | .vreg[VREG_HFPLL_A] = { "l2_hfpll_a", 2150000 }, |
| 86 | .vreg[VREG_HFPLL_B] = { "l2_hfpll_b", 1800000 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 87 | }, |
| 88 | }; |
| 89 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 90 | static struct msm_bus_paths bw_level_tbl[] __initdata = { |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 91 | [0] = BW_MBPS(400), /* At least 50 MHz on bus. */ |
| 92 | [1] = BW_MBPS(800), /* At least 100 MHz on bus. */ |
| 93 | [2] = BW_MBPS(1334), /* At least 167 MHz on bus. */ |
| 94 | [3] = BW_MBPS(2666), /* At least 200 MHz on bus. */ |
| 95 | [4] = BW_MBPS(3200), /* At least 333 MHz on bus. */ |
| 96 | }; |
| 97 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 98 | static struct msm_bus_scale_pdata bus_scale_data __initdata = { |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 99 | .usecase = bw_level_tbl, |
| 100 | .num_usecases = ARRAY_SIZE(bw_level_tbl), |
| 101 | .active_only = 1, |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 102 | .name = "acpuclk-8974", |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 103 | }; |
| 104 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 105 | static struct l2_level l2_freq_tbl[] __initdata = { |
Matt Wagantall | c216734 | 2012-07-12 17:21:43 -0700 | [diff] [blame] | 106 | [0] = { {STBY_KHZ, QSB, 0, 0, 0 }, LVL_LOW, 1050000, 0 }, |
| 107 | [1] = { { 300000, PLL_0, 0, 2, 0 }, LVL_LOW, 1050000, 2 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 108 | [2] = { { 384000, HFPLL, 2, 0, 40 }, LVL_NOM, 1050000, 2 }, |
| 109 | [3] = { { 460800, HFPLL, 2, 0, 48 }, LVL_NOM, 1050000, 2 }, |
| 110 | [4] = { { 537600, HFPLL, 1, 0, 28 }, LVL_NOM, 1050000, 2 }, |
| 111 | [5] = { { 576000, HFPLL, 1, 0, 30 }, LVL_NOM, 1050000, 3 }, |
| 112 | [6] = { { 652800, HFPLL, 1, 0, 34 }, LVL_NOM, 1050000, 3 }, |
| 113 | [7] = { { 729600, HFPLL, 1, 0, 38 }, LVL_NOM, 1050000, 3 }, |
| 114 | [8] = { { 806400, HFPLL, 1, 0, 42 }, LVL_NOM, 1050000, 3 }, |
| 115 | [9] = { { 883200, HFPLL, 1, 0, 46 }, LVL_NOM, 1050000, 4 }, |
| 116 | [10] = { { 960000, HFPLL, 1, 0, 50 }, LVL_NOM, 1050000, 4 }, |
| 117 | [11] = { { 1036800, HFPLL, 1, 0, 54 }, LVL_NOM, 1050000, 4 }, |
| 118 | }; |
| 119 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 120 | static struct acpu_level acpu_freq_tbl[] __initdata = { |
Matt Wagantall | 6d9c416 | 2012-07-16 18:58:16 -0700 | [diff] [blame^] | 121 | { 0, {STBY_KHZ, QSB, 0, 0, 0 }, L2(0), 1050000, 3200000 }, |
| 122 | { 1, { 300000, PLL_0, 0, 2, 0 }, L2(1), 1050000, 3200000 }, |
| 123 | { 1, { 384000, HFPLL, 2, 0, 40 }, L2(2), 1050000, 3200000 }, |
| 124 | { 1, { 460800, HFPLL, 2, 0, 48 }, L2(3), 1050000, 3200000 }, |
| 125 | { 1, { 537600, HFPLL, 1, 0, 28 }, L2(4), 1050000, 3200000 }, |
| 126 | { 1, { 576000, HFPLL, 1, 0, 30 }, L2(5), 1050000, 3200000 }, |
| 127 | { 1, { 652800, HFPLL, 1, 0, 34 }, L2(6), 1050000, 3200000 }, |
| 128 | { 1, { 729600, HFPLL, 1, 0, 38 }, L2(7), 1050000, 3200000 }, |
| 129 | { 1, { 806400, HFPLL, 1, 0, 42 }, L2(8), 1050000, 3200000 }, |
| 130 | { 1, { 883200, HFPLL, 1, 0, 46 }, L2(9), 1050000, 3200000 }, |
| 131 | { 1, { 960000, HFPLL, 1, 0, 50 }, L2(10), 1050000, 3200000 }, |
| 132 | { 1, { 1036800, HFPLL, 1, 0, 54 }, L2(11), 1050000, 3200000 }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 133 | { 0, { 0 } } |
| 134 | }; |
| 135 | |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 136 | static struct pvs_table pvs_tables[NUM_PVS] __initdata = { |
| 137 | [PVS_SLOW] = { acpu_freq_tbl, sizeof(acpu_freq_tbl) }, |
| 138 | [PVS_NOMINAL] = { acpu_freq_tbl, sizeof(acpu_freq_tbl) }, |
| 139 | [PVS_FAST] = { acpu_freq_tbl, sizeof(acpu_freq_tbl) }, |
| 140 | }; |
| 141 | |
| 142 | static struct acpuclk_krait_params acpuclk_8974_params __initdata = { |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 143 | .scalable = scalable, |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 144 | .scalable_size = sizeof(scalable), |
| 145 | .hfpll_data = &hfpll_data, |
| 146 | .pvs_tables = pvs_tables, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 147 | .l2_freq_tbl = l2_freq_tbl, |
Matt Wagantall | 1f3762d | 2012-06-08 19:08:48 -0700 | [diff] [blame] | 148 | .l2_freq_tbl_size = sizeof(l2_freq_tbl), |
| 149 | .bus_scale = &bus_scale_data, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 150 | .qfprom_phys_base = 0xFC4A8000, |
| 151 | }; |
| 152 | |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 153 | static int __init acpuclk_8974_probe(struct platform_device *pdev) |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 154 | { |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 155 | return acpuclk_krait_init(&pdev->dev, &acpuclk_8974_params); |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 156 | } |
| 157 | |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 158 | static struct of_device_id acpuclk_8974_match_table[] = { |
| 159 | { .compatible = "qcom,acpuclk-8974" }, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 160 | {} |
| 161 | }; |
| 162 | |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 163 | static struct platform_driver acpuclk_8974_driver = { |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 164 | .driver = { |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 165 | .name = "acpuclk-8974", |
| 166 | .of_match_table = acpuclk_8974_match_table, |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 167 | .owner = THIS_MODULE, |
| 168 | }, |
| 169 | }; |
| 170 | |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 171 | static int __init acpuclk_8974_init(void) |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 172 | { |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 173 | return platform_driver_probe(&acpuclk_8974_driver, |
| 174 | acpuclk_8974_probe); |
Matt Wagantall | e9b715a | 2012-01-04 18:16:14 -0800 | [diff] [blame] | 175 | } |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 176 | device_initcall(acpuclk_8974_init); |