Patrick Daly | 6578e0c | 2012-07-19 18:50:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011-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 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/module.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <mach/rpm-regulator.h> |
| 18 | #include <mach/msm_bus_board.h> |
| 19 | #include <mach/msm_bus.h> |
| 20 | |
| 21 | #include "acpuclock.h" |
| 22 | #include "acpuclock-krait.h" |
| 23 | |
| 24 | static struct hfpll_data hfpll_data __initdata = { |
| 25 | .mode_offset = 0x00, |
| 26 | .l_offset = 0x08, |
| 27 | .m_offset = 0x0C, |
| 28 | .n_offset = 0x10, |
| 29 | .config_offset = 0x04, |
| 30 | .config_val = 0x7845C665, |
| 31 | .has_droop_ctl = true, |
| 32 | .droop_offset = 0x14, |
| 33 | .droop_val = 0x0108C000, |
| 34 | .low_vdd_l_max = 37, |
| 35 | .nom_vdd_l_max = 74, |
| 36 | .vdd[HFPLL_VDD_NONE] = 0, |
| 37 | .vdd[HFPLL_VDD_LOW] = 945000, |
| 38 | .vdd[HFPLL_VDD_NOM] = 1050000, |
| 39 | .vdd[HFPLL_VDD_HIGH] = 1150000, |
| 40 | }; |
| 41 | |
| 42 | static struct scalable scalable[] __initdata = { |
| 43 | [CPU0] = { |
| 44 | .hfpll_phys_base = 0x00903200, |
| 45 | .aux_clk_sel_phys = 0x02088014, |
| 46 | .aux_clk_sel = 3, |
| 47 | .l2cpmr_iaddr = 0x4501, |
| 48 | .vreg[VREG_CORE] = { "krait0", 1300000 }, |
| 49 | .vreg[VREG_MEM] = { "krait0_mem", 1150000 }, |
| 50 | .vreg[VREG_DIG] = { "krait0_dig", 1150000 }, |
| 51 | .vreg[VREG_HFPLL_A] = { "krait0_s8", 2050000 }, |
| 52 | .vreg[VREG_HFPLL_B] = { "krait0_l23", 1800000 }, |
| 53 | }, |
| 54 | [CPU1] = { |
| 55 | .hfpll_phys_base = 0x00903300, |
| 56 | .aux_clk_sel_phys = 0x02098014, |
| 57 | .aux_clk_sel = 3, |
| 58 | .l2cpmr_iaddr = 0x5501, |
| 59 | .vreg[VREG_CORE] = { "krait1", 1300000 }, |
| 60 | .vreg[VREG_MEM] = { "krait1_mem", 1150000 }, |
| 61 | .vreg[VREG_DIG] = { "krait1_dig", 1150000 }, |
| 62 | .vreg[VREG_HFPLL_A] = { "krait1_s8", 2050000 }, |
| 63 | .vreg[VREG_HFPLL_B] = { "krait1_l23", 1800000 }, |
| 64 | }, |
| 65 | [L2] = { |
| 66 | .hfpll_phys_base = 0x00903400, |
| 67 | .aux_clk_sel_phys = 0x02011028, |
| 68 | .aux_clk_sel = 3, |
| 69 | .l2cpmr_iaddr = 0x0500, |
| 70 | .vreg[VREG_HFPLL_A] = { "l2_s8", 2050000 }, |
| 71 | .vreg[VREG_HFPLL_B] = { "l2_l23", 1800000 }, |
| 72 | }, |
| 73 | }; |
| 74 | |
| 75 | static struct msm_bus_paths bw_level_tbl[] __initdata = { |
| 76 | [0] = BW_MBPS(640), /* At least 80 MHz on bus. */ |
| 77 | [1] = BW_MBPS(1064), /* At least 133 MHz on bus. */ |
| 78 | [2] = BW_MBPS(1600), /* At least 200 MHz on bus. */ |
| 79 | [3] = BW_MBPS(2128), /* At least 266 MHz on bus. */ |
| 80 | [4] = BW_MBPS(3200), /* At least 400 MHz on bus. */ |
| 81 | [5] = BW_MBPS(4264), /* At least 533 MHz on bus. */ |
| 82 | }; |
| 83 | |
| 84 | static struct msm_bus_scale_pdata bus_scale_data __initdata = { |
| 85 | .usecase = bw_level_tbl, |
| 86 | .num_usecases = ARRAY_SIZE(bw_level_tbl), |
| 87 | .active_only = 1, |
| 88 | .name = "acpuclk-8960ab", |
| 89 | }; |
| 90 | |
| 91 | static struct l2_level l2_freq_tbl[] __initdata = { |
| 92 | [0] = { { 384000, PLL_8, 0, 2, 0x00 }, 1050000, 1050000, 1 }, |
| 93 | [1] = { { 486000, HFPLL, 2, 0, 0x24 }, 1050000, 1050000, 2 }, |
| 94 | [2] = { { 594000, HFPLL, 1, 0, 0x16 }, 1050000, 1050000, 2 }, |
| 95 | [3] = { { 702000, HFPLL, 1, 0, 0x1A }, 1050000, 1050000, 4 }, |
| 96 | [4] = { { 810000, HFPLL, 1, 0, 0x1E }, 1050000, 1050000, 4 }, |
| 97 | [5] = { { 918000, HFPLL, 1, 0, 0x22 }, 1150000, 1150000, 5 }, |
| 98 | [6] = { { 1026000, HFPLL, 1, 0, 0x26 }, 1150000, 1150000, 5 }, |
| 99 | [7] = { { 1134000, HFPLL, 1, 0, 0x2A }, 1150000, 1150000, 5 }, |
| 100 | [8] = { { 1242000, HFPLL, 1, 0, 0x2E }, 1150000, 1150000, 5 }, |
| 101 | [9] = { { 1350000, HFPLL, 1, 0, 0x32 }, 1150000, 1150000, 5 }, |
Stephen Boyd | 791bca9 | 2012-09-11 21:08:13 -0700 | [diff] [blame] | 102 | { } |
Patrick Daly | 6578e0c | 2012-07-19 18:50:02 -0700 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | static struct acpu_level acpu_freq_tbl_slow[] __initdata = { |
| 106 | { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(0), 950000 }, |
| 107 | { 0, { 432000, HFPLL, 2, 0, 0x20 }, L2(3), 975000 }, |
| 108 | { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(3), 975000 }, |
| 109 | { 0, { 540000, HFPLL, 2, 0, 0x28 }, L2(3), 1000000 }, |
| 110 | { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(3), 1000000 }, |
| 111 | { 0, { 648000, HFPLL, 1, 0, 0x18 }, L2(3), 1025000 }, |
| 112 | { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(3), 1025000 }, |
| 113 | { 0, { 756000, HFPLL, 1, 0, 0x1C }, L2(3), 1075000 }, |
| 114 | { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(3), 1075000 }, |
| 115 | { 0, { 864000, HFPLL, 1, 0, 0x20 }, L2(3), 1100000 }, |
| 116 | { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(3), 1100000 }, |
| 117 | { 0, { 972000, HFPLL, 1, 0, 0x24 }, L2(3), 1125000 }, |
| 118 | { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(3), 1125000 }, |
| 119 | { 0, { 1080000, HFPLL, 1, 0, 0x28 }, L2(9), 1175000 }, |
| 120 | { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(9), 1175000 }, |
| 121 | { 0, { 1188000, HFPLL, 1, 0, 0x2C }, L2(9), 1200000 }, |
| 122 | { 1, { 1242000, HFPLL, 1, 0, 0x2E }, L2(9), 1200000 }, |
| 123 | { 0, { 1296000, HFPLL, 1, 0, 0x30 }, L2(9), 1225000 }, |
| 124 | { 1, { 1350000, HFPLL, 1, 0, 0x32 }, L2(9), 1225000 }, |
| 125 | { 0, { 1404000, HFPLL, 1, 0, 0x34 }, L2(9), 1237500 }, |
| 126 | { 1, { 1458000, HFPLL, 1, 0, 0x36 }, L2(9), 1237500 }, |
| 127 | { 1, { 1512000, HFPLL, 1, 0, 0x38 }, L2(9), 1250000 }, |
Patrick Daly | c3a19da | 2012-08-20 12:29:40 -0700 | [diff] [blame] | 128 | { 1, { 1566000, HFPLL, 1, 0, 0x3A }, L2(9), 1250000 }, |
| 129 | { 1, { 1620000, HFPLL, 1, 0, 0x3C }, L2(9), 1250000 }, |
| 130 | { 1, { 1674000, HFPLL, 1, 0, 0x3E }, L2(9), 1250000 }, |
| 131 | { 1, { 1728000, HFPLL, 1, 0, 0x40 }, L2(9), 1250000 }, |
Patrick Daly | 6578e0c | 2012-07-19 18:50:02 -0700 | [diff] [blame] | 132 | { 0, { 0 } } |
| 133 | }; |
| 134 | |
| 135 | static struct pvs_table pvs_tables[NUM_PVS] __initdata = { |
| 136 | [PVS_SLOW] = { acpu_freq_tbl_slow, sizeof(acpu_freq_tbl_slow), 0 }, |
| 137 | [PVS_NOMINAL] = { acpu_freq_tbl_slow, sizeof(acpu_freq_tbl_slow), 0 }, |
| 138 | [PVS_FAST] = { acpu_freq_tbl_slow, sizeof(acpu_freq_tbl_slow), 0 }, |
| 139 | }; |
| 140 | |
| 141 | static struct acpuclk_krait_params acpuclk_8960ab_params __initdata = { |
| 142 | .scalable = scalable, |
| 143 | .scalable_size = sizeof(scalable), |
| 144 | .hfpll_data = &hfpll_data, |
| 145 | .pvs_tables = pvs_tables, |
| 146 | .l2_freq_tbl = l2_freq_tbl, |
| 147 | .l2_freq_tbl_size = sizeof(l2_freq_tbl), |
| 148 | .bus_scale = &bus_scale_data, |
Matt Wagantall | ee2b437 | 2012-09-17 17:51:06 -0700 | [diff] [blame] | 149 | .pte_efuse_phys = 0x007000C0, |
Patrick Daly | 05686c3 | 2012-08-22 14:23:28 -0700 | [diff] [blame] | 150 | .stby_khz = 384000, |
Patrick Daly | 6578e0c | 2012-07-19 18:50:02 -0700 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | static int __init acpuclk_8960ab_probe(struct platform_device *pdev) |
| 154 | { |
| 155 | return acpuclk_krait_init(&pdev->dev, &acpuclk_8960ab_params); |
| 156 | } |
| 157 | |
| 158 | static struct platform_driver acpuclk_8960ab_driver = { |
| 159 | .driver = { |
| 160 | .name = "acpuclk-8960ab", |
| 161 | .owner = THIS_MODULE, |
| 162 | }, |
| 163 | }; |
| 164 | |
| 165 | static int __init acpuclk_8960ab_init(void) |
| 166 | { |
| 167 | return platform_driver_probe(&acpuclk_8960ab_driver, |
| 168 | acpuclk_8960ab_probe); |
| 169 | } |
| 170 | device_initcall(acpuclk_8960ab_init); |