blob: c7800fcb8a2b94fa86d5dd6feaed083cbafea37f [file] [log] [blame]
Matt Wagantalle9b715a2012-01-04 18:16:14 -08001/*
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 Mucklef132c6c2012-06-06 18:30:57 -070014#include <linux/module.h>
Matt Wagantalle9b715a2012-01-04 18:16:14 -080015#include <linux/platform_device.h>
16#include <linux/of.h>
Matt Wagantalld591bf22012-06-29 11:20:53 -070017#include <mach/rpm-regulator-smd.h>
Matt Wagantalle9b715a2012-01-04 18:16:14 -080018#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 Wagantalld591bf22012-06-29 11:20:53 -070026#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 Wagantalle9b715a2012-01-04 18:16:14 -080030
Matt Wagantall1f3762d2012-06-08 19:08:48 -070031static struct hfpll_data hfpll_data __initdata = {
Matt Wagantalle9b715a2012-01-04 18:16:14 -080032 .mode_offset = 0x00,
33 .l_offset = 0x04,
34 .m_offset = 0x08,
35 .n_offset = 0x0C,
Matt Wagantalla77b7f32012-07-18 16:32:01 -070036 .has_user_reg = true,
37 .user_offset = 0x10,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080038 .config_offset = 0x14,
Matt Wagantalla77b7f32012-07-18 16:32:01 -070039 /* TODO: Verify magic numbers when final values are available. */
40 .user_val = 0x8,
41 .config_val = 0x04D0405D,
42 .low_vco_l_max = 65,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080043 .low_vdd_l_max = 52,
Matt Wagantall87465f52012-07-23 22:03:06 -070044 .nom_vdd_l_max = 104,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080045 .vdd[HFPLL_VDD_NONE] = LVL_NONE,
46 .vdd[HFPLL_VDD_LOW] = LVL_LOW,
47 .vdd[HFPLL_VDD_NOM] = LVL_NOM,
Matt Wagantall87465f52012-07-23 22:03:06 -070048 .vdd[HFPLL_VDD_HIGH] = LVL_HIGH,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080049};
50
Matt Wagantall1f3762d2012-06-08 19:08:48 -070051static struct scalable scalable[] __initdata = {
Matt Wagantalle9b715a2012-01-04 18:16:14 -080052 [CPU0] = {
53 .hfpll_phys_base = 0xF908A000,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080054 .l2cpmr_iaddr = 0x4501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070055 .vreg[VREG_CORE] = { "krait0", 1050000 },
Matt Wagantall75473eb2012-05-31 15:23:22 -070056 .vreg[VREG_MEM] = { "krait0_mem", 1050000 },
Matt Wagantalld591bf22012-06-29 11:20:53 -070057 .vreg[VREG_DIG] = { "krait0_dig", LVL_HIGH },
Matt Wagantall337cdb72012-06-29 12:07:27 -070058 .vreg[VREG_HFPLL_A] = { "krait0_hfpll_a", 2150000 },
59 .vreg[VREG_HFPLL_B] = { "krait0_hfpll_b", 1800000 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -080060 },
61 [CPU1] = {
62 .hfpll_phys_base = 0xF909A000,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080063 .l2cpmr_iaddr = 0x5501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070064 .vreg[VREG_CORE] = { "krait1", 1050000 },
Matt Wagantall75473eb2012-05-31 15:23:22 -070065 .vreg[VREG_MEM] = { "krait1_mem", 1050000 },
Matt Wagantalld591bf22012-06-29 11:20:53 -070066 .vreg[VREG_DIG] = { "krait1_dig", LVL_HIGH },
Matt Wagantall337cdb72012-06-29 12:07:27 -070067 .vreg[VREG_HFPLL_A] = { "krait1_hfpll_a", 2150000 },
68 .vreg[VREG_HFPLL_B] = { "krait1_hfpll_b", 1800000 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -080069 },
70 [CPU2] = {
71 .hfpll_phys_base = 0xF90AA000,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080072 .l2cpmr_iaddr = 0x6501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070073 .vreg[VREG_CORE] = { "krait2", 1050000 },
Matt Wagantall75473eb2012-05-31 15:23:22 -070074 .vreg[VREG_MEM] = { "krait2_mem", 1050000 },
Matt Wagantalld591bf22012-06-29 11:20:53 -070075 .vreg[VREG_DIG] = { "krait2_dig", LVL_HIGH },
Matt Wagantall337cdb72012-06-29 12:07:27 -070076 .vreg[VREG_HFPLL_A] = { "krait2_hfpll_a", 2150000 },
77 .vreg[VREG_HFPLL_B] = { "krait2_hfpll_b", 1800000 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -080078 },
79 [CPU3] = {
80 .hfpll_phys_base = 0xF90BA000,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080081 .l2cpmr_iaddr = 0x7501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070082 .vreg[VREG_CORE] = { "krait3", 1050000 },
Matt Wagantall75473eb2012-05-31 15:23:22 -070083 .vreg[VREG_MEM] = { "krait3_mem", 1050000 },
Matt Wagantalld591bf22012-06-29 11:20:53 -070084 .vreg[VREG_DIG] = { "krait3_dig", LVL_HIGH },
Matt Wagantall337cdb72012-06-29 12:07:27 -070085 .vreg[VREG_HFPLL_A] = { "krait3_hfpll_a", 2150000 },
86 .vreg[VREG_HFPLL_B] = { "krait3_hfpll_b", 1800000 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -080087 },
88 [L2] = {
89 .hfpll_phys_base = 0xF9016000,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080090 .l2cpmr_iaddr = 0x0500,
Matt Wagantall337cdb72012-06-29 12:07:27 -070091 .vreg[VREG_HFPLL_A] = { "l2_hfpll_a", 2150000 },
92 .vreg[VREG_HFPLL_B] = { "l2_hfpll_b", 1800000 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -080093 },
94};
95
Matt Wagantall1f3762d2012-06-08 19:08:48 -070096static struct msm_bus_paths bw_level_tbl[] __initdata = {
Matt Wagantalle9b715a2012-01-04 18:16:14 -080097 [0] = BW_MBPS(400), /* At least 50 MHz on bus. */
98 [1] = BW_MBPS(800), /* At least 100 MHz on bus. */
99 [2] = BW_MBPS(1334), /* At least 167 MHz on bus. */
100 [3] = BW_MBPS(2666), /* At least 200 MHz on bus. */
101 [4] = BW_MBPS(3200), /* At least 333 MHz on bus. */
102};
103
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700104static struct msm_bus_scale_pdata bus_scale_data __initdata = {
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800105 .usecase = bw_level_tbl,
106 .num_usecases = ARRAY_SIZE(bw_level_tbl),
107 .active_only = 1,
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700108 .name = "acpuclk-8974",
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800109};
110
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700111static struct l2_level l2_freq_tbl[] __initdata = {
Matt Wagantallc2167342012-07-12 17:21:43 -0700112 [0] = { {STBY_KHZ, QSB, 0, 0, 0 }, LVL_LOW, 1050000, 0 },
113 [1] = { { 300000, PLL_0, 0, 2, 0 }, LVL_LOW, 1050000, 2 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800114 [2] = { { 384000, HFPLL, 2, 0, 40 }, LVL_NOM, 1050000, 2 },
115 [3] = { { 460800, HFPLL, 2, 0, 48 }, LVL_NOM, 1050000, 2 },
116 [4] = { { 537600, HFPLL, 1, 0, 28 }, LVL_NOM, 1050000, 2 },
117 [5] = { { 576000, HFPLL, 1, 0, 30 }, LVL_NOM, 1050000, 3 },
118 [6] = { { 652800, HFPLL, 1, 0, 34 }, LVL_NOM, 1050000, 3 },
119 [7] = { { 729600, HFPLL, 1, 0, 38 }, LVL_NOM, 1050000, 3 },
120 [8] = { { 806400, HFPLL, 1, 0, 42 }, LVL_NOM, 1050000, 3 },
121 [9] = { { 883200, HFPLL, 1, 0, 46 }, LVL_NOM, 1050000, 4 },
122 [10] = { { 960000, HFPLL, 1, 0, 50 }, LVL_NOM, 1050000, 4 },
123 [11] = { { 1036800, HFPLL, 1, 0, 54 }, LVL_NOM, 1050000, 4 },
124};
125
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700126static struct acpu_level acpu_freq_tbl[] __initdata = {
Matt Wagantall6d9c4162012-07-16 18:58:16 -0700127 { 0, {STBY_KHZ, QSB, 0, 0, 0 }, L2(0), 1050000, 3200000 },
128 { 1, { 300000, PLL_0, 0, 2, 0 }, L2(1), 1050000, 3200000 },
129 { 1, { 384000, HFPLL, 2, 0, 40 }, L2(2), 1050000, 3200000 },
130 { 1, { 460800, HFPLL, 2, 0, 48 }, L2(3), 1050000, 3200000 },
131 { 1, { 537600, HFPLL, 1, 0, 28 }, L2(4), 1050000, 3200000 },
132 { 1, { 576000, HFPLL, 1, 0, 30 }, L2(5), 1050000, 3200000 },
133 { 1, { 652800, HFPLL, 1, 0, 34 }, L2(6), 1050000, 3200000 },
134 { 1, { 729600, HFPLL, 1, 0, 38 }, L2(7), 1050000, 3200000 },
135 { 1, { 806400, HFPLL, 1, 0, 42 }, L2(8), 1050000, 3200000 },
136 { 1, { 883200, HFPLL, 1, 0, 46 }, L2(9), 1050000, 3200000 },
137 { 1, { 960000, HFPLL, 1, 0, 50 }, L2(10), 1050000, 3200000 },
138 { 1, { 1036800, HFPLL, 1, 0, 54 }, L2(11), 1050000, 3200000 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800139 { 0, { 0 } }
140};
141
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700142static struct pvs_table pvs_tables[NUM_PVS] __initdata = {
143 [PVS_SLOW] = { acpu_freq_tbl, sizeof(acpu_freq_tbl) },
144 [PVS_NOMINAL] = { acpu_freq_tbl, sizeof(acpu_freq_tbl) },
145 [PVS_FAST] = { acpu_freq_tbl, sizeof(acpu_freq_tbl) },
146};
147
148static struct acpuclk_krait_params acpuclk_8974_params __initdata = {
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800149 .scalable = scalable,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700150 .scalable_size = sizeof(scalable),
151 .hfpll_data = &hfpll_data,
152 .pvs_tables = pvs_tables,
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800153 .l2_freq_tbl = l2_freq_tbl,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700154 .l2_freq_tbl_size = sizeof(l2_freq_tbl),
155 .bus_scale = &bus_scale_data,
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800156 .qfprom_phys_base = 0xFC4A8000,
157};
158
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700159static int __init acpuclk_8974_probe(struct platform_device *pdev)
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800160{
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700161 return acpuclk_krait_init(&pdev->dev, &acpuclk_8974_params);
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800162}
163
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700164static struct of_device_id acpuclk_8974_match_table[] = {
165 { .compatible = "qcom,acpuclk-8974" },
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800166 {}
167};
168
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700169static struct platform_driver acpuclk_8974_driver = {
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800170 .driver = {
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700171 .name = "acpuclk-8974",
172 .of_match_table = acpuclk_8974_match_table,
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800173 .owner = THIS_MODULE,
174 },
175};
176
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700177static int __init acpuclk_8974_init(void)
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800178{
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700179 return platform_driver_probe(&acpuclk_8974_driver,
180 acpuclk_8974_probe);
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800181}
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700182device_initcall(acpuclk_8974_init);