blob: ac29caca834bef604333169dccfbb848a995b0ca [file] [log] [blame]
Matt Wagantallab730bd2012-06-07 20:13:51 -07001/*
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/* Corner type vreg VDD values */
25#define LVL_NONE RPM_VREG_CORNER_NONE
26#define LVL_LOW RPM_VREG_CORNER_LOW
27#define LVL_NOM RPM_VREG_CORNER_NOMINAL
28#define LVL_HIGH RPM_VREG_CORNER_HIGH
29
Matt Wagantall1f3762d2012-06-08 19:08:48 -070030static struct hfpll_data hfpll_data __initdata = {
Matt Wagantallab730bd2012-06-07 20:13:51 -070031 .mode_offset = 0x00,
32 .l_offset = 0x08,
33 .m_offset = 0x0C,
34 .n_offset = 0x10,
35 .config_offset = 0x04,
36 .config_val = 0x7845C665,
37 .has_droop_ctl = true,
38 .droop_offset = 0x14,
39 .droop_val = 0x0108C000,
Matt Wagantall87465f52012-07-23 22:03:06 -070040 .low_vdd_l_max = 22,
41 .nom_vdd_l_max = 42,
Matt Wagantallab730bd2012-06-07 20:13:51 -070042 .vdd[HFPLL_VDD_NONE] = LVL_NONE,
43 .vdd[HFPLL_VDD_LOW] = LVL_LOW,
44 .vdd[HFPLL_VDD_NOM] = LVL_NOM,
Matt Wagantall87465f52012-07-23 22:03:06 -070045 .vdd[HFPLL_VDD_HIGH] = LVL_HIGH,
Matt Wagantallab730bd2012-06-07 20:13:51 -070046};
47
Matt Wagantall1f3762d2012-06-08 19:08:48 -070048static struct scalable scalable[] __initdata = {
Matt Wagantallab730bd2012-06-07 20:13:51 -070049 [CPU0] = {
50 .hfpll_phys_base = 0x00903200,
Matt Wagantallab730bd2012-06-07 20:13:51 -070051 .aux_clk_sel_phys = 0x02088014,
52 .aux_clk_sel = 3,
Matt Wagantall6cd5d752012-09-27 19:56:57 -070053 .sec_clk_sel = 2,
Matt Wagantallab730bd2012-06-07 20:13:51 -070054 .l2cpmr_iaddr = 0x4501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070055 .vreg[VREG_CORE] = { "krait0", 1300000 },
Matt Wagantallab730bd2012-06-07 20:13:51 -070056 .vreg[VREG_MEM] = { "krait0_mem", 1150000 },
57 .vreg[VREG_DIG] = { "krait0_dig", 1150000 },
58 .vreg[VREG_HFPLL_A] = { "krait0_hfpll", 1800000 },
59 },
60 [CPU1] = {
61 .hfpll_phys_base = 0x00903300,
Matt Wagantallab730bd2012-06-07 20:13:51 -070062 .aux_clk_sel_phys = 0x02098014,
63 .aux_clk_sel = 3,
Matt Wagantall6cd5d752012-09-27 19:56:57 -070064 .sec_clk_sel = 2,
Matt Wagantallab730bd2012-06-07 20:13:51 -070065 .l2cpmr_iaddr = 0x5501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070066 .vreg[VREG_CORE] = { "krait1", 1300000 },
Matt Wagantallab730bd2012-06-07 20:13:51 -070067 .vreg[VREG_MEM] = { "krait1_mem", 1150000 },
68 .vreg[VREG_DIG] = { "krait1_dig", 1150000 },
69 .vreg[VREG_HFPLL_A] = { "krait1_hfpll", 1800000 },
70 },
71 [L2] = {
72 .hfpll_phys_base = 0x00903400,
Matt Wagantallab730bd2012-06-07 20:13:51 -070073 .aux_clk_sel_phys = 0x02011028,
74 .aux_clk_sel = 3,
Matt Wagantall6cd5d752012-09-27 19:56:57 -070075 .sec_clk_sel = 2,
Matt Wagantallab730bd2012-06-07 20:13:51 -070076 .l2cpmr_iaddr = 0x0500,
77 .vreg[VREG_HFPLL_A] = { "l2_hfpll", 1800000 },
78 },
79};
80
Matt Wagantall1f3762d2012-06-08 19:08:48 -070081static struct msm_bus_paths bw_level_tbl[] __initdata = {
Matt Wagantallab730bd2012-06-07 20:13:51 -070082 [0] = BW_MBPS(640), /* At least 80 MHz on bus. */
83 [1] = BW_MBPS(1064), /* At least 133 MHz on bus. */
84 [2] = BW_MBPS(1600), /* At least 200 MHz on bus. */
85 [3] = BW_MBPS(2128), /* At least 266 MHz on bus. */
86 [4] = BW_MBPS(3200), /* At least 400 MHz on bus. */
87};
88
Matt Wagantall1f3762d2012-06-08 19:08:48 -070089static struct msm_bus_scale_pdata bus_scale_data __initdata = {
Matt Wagantallab730bd2012-06-07 20:13:51 -070090 .usecase = bw_level_tbl,
91 .num_usecases = ARRAY_SIZE(bw_level_tbl),
92 .active_only = 1,
93 .name = "acpuclk-8627",
94};
95
96/* TODO: Update vdd_dig, vdd_mem and bw when data is available. */
Matt Wagantall1f3762d2012-06-08 19:08:48 -070097static struct l2_level l2_freq_tbl[] __initdata = {
Matt Wagantall6cd5d752012-09-27 19:56:57 -070098 [0] = { { 384000, PLL_8, 0, 0x00 }, LVL_NOM, 1050000, 1 },
99 [1] = { { 432000, HFPLL, 2, 0x20 }, LVL_NOM, 1050000, 1 },
100 [2] = { { 486000, HFPLL, 2, 0x24 }, LVL_NOM, 1050000, 1 },
101 [3] = { { 540000, HFPLL, 2, 0x28 }, LVL_NOM, 1050000, 2 },
102 [4] = { { 594000, HFPLL, 1, 0x16 }, LVL_NOM, 1050000, 2 },
103 [5] = { { 648000, HFPLL, 1, 0x18 }, LVL_NOM, 1050000, 2 },
104 [6] = { { 702000, HFPLL, 1, 0x1A }, LVL_NOM, 1050000, 3 },
105 [7] = { { 756000, HFPLL, 1, 0x1C }, LVL_HIGH, 1150000, 3 },
106 [8] = { { 810000, HFPLL, 1, 0x1E }, LVL_HIGH, 1150000, 3 },
107 [9] = { { 864000, HFPLL, 1, 0x20 }, LVL_HIGH, 1150000, 4 },
108 [10] = { { 918000, HFPLL, 1, 0x22 }, LVL_HIGH, 1150000, 4 },
109 [11] = { { 972000, HFPLL, 1, 0x24 }, LVL_HIGH, 1150000, 4 },
Stephen Boyd791bca92012-09-11 21:08:13 -0700110 { }
Matt Wagantallab730bd2012-06-07 20:13:51 -0700111};
112
113/* TODO: Update core voltages when data is available. */
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700114static struct acpu_level acpu_freq_tbl[] __initdata = {
Matt Wagantall6cd5d752012-09-27 19:56:57 -0700115 { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 900000 },
116 { 1, { 432000, HFPLL, 2, 0x20 }, L2(4), 925000 },
117 { 1, { 486000, HFPLL, 2, 0x24 }, L2(4), 925000 },
118 { 1, { 540000, HFPLL, 2, 0x28 }, L2(4), 937500 },
119 { 1, { 594000, HFPLL, 1, 0x16 }, L2(4), 962500 },
120 { 1, { 648000, HFPLL, 1, 0x18 }, L2(8), 987500 },
121 { 1, { 702000, HFPLL, 1, 0x1A }, L2(8), 1000000 },
122 { 1, { 756000, HFPLL, 1, 0x1C }, L2(8), 1025000 },
123 { 1, { 810000, HFPLL, 1, 0x1E }, L2(8), 1062500 },
124 { 1, { 864000, HFPLL, 1, 0x20 }, L2(11), 1062500 },
125 { 1, { 918000, HFPLL, 1, 0x22 }, L2(11), 1087500 },
126 { 1, { 972000, HFPLL, 1, 0x24 }, L2(11), 1100000 },
Matt Wagantallab730bd2012-06-07 20:13:51 -0700127 { 0, { 0 } }
128};
129
Patrick Daly18d2d482012-08-24 14:22:06 -0700130static struct pvs_table pvs_tables[NUM_SPEED_BINS][NUM_PVS] __initdata = {
131 [0][PVS_SLOW] = { acpu_freq_tbl, sizeof(acpu_freq_tbl), 0 },
132 [0][PVS_NOMINAL] = { acpu_freq_tbl, sizeof(acpu_freq_tbl), 25000 },
133 [0][PVS_FAST] = { acpu_freq_tbl, sizeof(acpu_freq_tbl), 25000 },
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700134};
135
136static struct acpuclk_krait_params acpuclk_8627_params __initdata = {
Matt Wagantallab730bd2012-06-07 20:13:51 -0700137 .scalable = scalable,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700138 .scalable_size = sizeof(scalable),
139 .hfpll_data = &hfpll_data,
140 .pvs_tables = pvs_tables,
Matt Wagantallab730bd2012-06-07 20:13:51 -0700141 .l2_freq_tbl = l2_freq_tbl,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700142 .l2_freq_tbl_size = sizeof(l2_freq_tbl),
143 .bus_scale = &bus_scale_data,
Matt Wagantallee2b4372012-09-17 17:51:06 -0700144 .pte_efuse_phys = 0x007000C0,
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700145 .stby_khz = 384000,
Matt Wagantallab730bd2012-06-07 20:13:51 -0700146};
147
148static int __init acpuclk_8627_probe(struct platform_device *pdev)
149{
150 return acpuclk_krait_init(&pdev->dev, &acpuclk_8627_params);
151}
152
153static struct platform_driver acpuclk_8627_driver = {
154 .driver = {
155 .name = "acpuclk-8627",
156 .owner = THIS_MODULE,
157 },
158};
159
160static int __init acpuclk_8627_init(void)
161{
162 return platform_driver_probe(&acpuclk_8627_driver,
163 acpuclk_8627_probe);
164}
165device_initcall(acpuclk_8627_init);