blob: 45f20966449ea26f177ced0c8103b5fb3fae65fb [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
30static struct hfpll_data hfpll_data = {
31 .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,
40 .low_vdd_l_max = 40,
41 .vdd[HFPLL_VDD_NONE] = LVL_NONE,
42 .vdd[HFPLL_VDD_LOW] = LVL_LOW,
43 .vdd[HFPLL_VDD_NOM] = LVL_NOM,
44};
45
46static struct scalable scalable[] = {
47 [CPU0] = {
48 .hfpll_phys_base = 0x00903200,
49 .hfpll_data = &hfpll_data,
50 .aux_clk_sel_phys = 0x02088014,
51 .aux_clk_sel = 3,
52 .l2cpmr_iaddr = 0x4501,
53 .vreg[VREG_CORE] = { "krait0", 1300000, 1740000 },
54 .vreg[VREG_MEM] = { "krait0_mem", 1150000 },
55 .vreg[VREG_DIG] = { "krait0_dig", 1150000 },
56 .vreg[VREG_HFPLL_A] = { "krait0_hfpll", 1800000 },
57 },
58 [CPU1] = {
59 .hfpll_phys_base = 0x00903300,
60 .hfpll_data = &hfpll_data,
61 .aux_clk_sel_phys = 0x02098014,
62 .aux_clk_sel = 3,
63 .l2cpmr_iaddr = 0x5501,
64 .vreg[VREG_CORE] = { "krait1", 1300000, 1740000 },
65 .vreg[VREG_MEM] = { "krait1_mem", 1150000 },
66 .vreg[VREG_DIG] = { "krait1_dig", 1150000 },
67 .vreg[VREG_HFPLL_A] = { "krait1_hfpll", 1800000 },
68 },
69 [L2] = {
70 .hfpll_phys_base = 0x00903400,
71 .hfpll_data = &hfpll_data,
72 .aux_clk_sel_phys = 0x02011028,
73 .aux_clk_sel = 3,
74 .l2cpmr_iaddr = 0x0500,
75 .vreg[VREG_HFPLL_A] = { "l2_hfpll", 1800000 },
76 },
77};
78
79static struct msm_bus_paths bw_level_tbl[] = {
80 [0] = BW_MBPS(640), /* At least 80 MHz on bus. */
81 [1] = BW_MBPS(1064), /* At least 133 MHz on bus. */
82 [2] = BW_MBPS(1600), /* At least 200 MHz on bus. */
83 [3] = BW_MBPS(2128), /* At least 266 MHz on bus. */
84 [4] = BW_MBPS(3200), /* At least 400 MHz on bus. */
85};
86
87static struct msm_bus_scale_pdata bus_scale_data = {
88 .usecase = bw_level_tbl,
89 .num_usecases = ARRAY_SIZE(bw_level_tbl),
90 .active_only = 1,
91 .name = "acpuclk-8627",
92};
93
94/* TODO: Update vdd_dig, vdd_mem and bw when data is available. */
95#define L2(x) (&l2_freq_tbl[(x)])
96static struct l2_level l2_freq_tbl[] = {
97 [0] = { {STBY_KHZ, QSB, 0, 0, 0x00 }, LVL_NOM, 1050000, 0 },
98 [1] = { { 384000, PLL_8, 0, 2, 0x00 }, LVL_NOM, 1050000, 1 },
99 [2] = { { 432000, HFPLL, 2, 0, 0x20 }, LVL_NOM, 1050000, 1 },
100 [3] = { { 486000, HFPLL, 2, 0, 0x24 }, LVL_NOM, 1050000, 1 },
101 [4] = { { 540000, HFPLL, 2, 0, 0x28 }, LVL_NOM, 1050000, 2 },
102 [5] = { { 594000, HFPLL, 1, 0, 0x16 }, LVL_NOM, 1050000, 2 },
103 [6] = { { 648000, HFPLL, 1, 0, 0x18 }, LVL_NOM, 1050000, 2 },
104 [7] = { { 702000, HFPLL, 1, 0, 0x1A }, LVL_NOM, 1050000, 3 },
105 [8] = { { 756000, HFPLL, 1, 0, 0x1C }, LVL_HIGH, 1150000, 3 },
106 [9] = { { 810000, HFPLL, 1, 0, 0x1E }, LVL_HIGH, 1150000, 3 },
107 [10] = { { 864000, HFPLL, 1, 0, 0x20 }, LVL_HIGH, 1150000, 4 },
108 [11] = { { 918000, HFPLL, 1, 0, 0x22 }, LVL_HIGH, 1150000, 4 },
109 [12] = { { 972000, HFPLL, 1, 0, 0x24 }, LVL_HIGH, 1150000, 4 },
110};
111
112/* TODO: Update core voltages when data is available. */
113static struct acpu_level acpu_freq_tbl[] = {
114 { 0, { STBY_KHZ, QSB, 0, 0, 0x00 }, L2(0), 900000 },
115 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(1), 900000 },
116 { 1, { 432000, HFPLL, 2, 0, 0x20 }, L2(5), 925000 },
117 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(5), 925000 },
118 { 1, { 540000, HFPLL, 2, 0, 0x28 }, L2(5), 937500 },
119 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(5), 962500 },
120 { 1, { 648000, HFPLL, 1, 0, 0x18 }, L2(9), 987500 },
121 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(9), 1000000 },
122 { 1, { 756000, HFPLL, 1, 0, 0x1C }, L2(9), 1025000 },
123 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(9), 1062500 },
124 { 1, { 864000, HFPLL, 1, 0, 0x20 }, L2(12), 1062500 },
125 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(12), 1087500 },
126 { 1, { 972000, HFPLL, 1, 0, 0x24 }, L2(12), 1100000 },
127 { 0, { 0 } }
128};
129
130static struct acpuclk_krait_params acpuclk_8627_params = {
131 .scalable = scalable,
132 .pvs_acpu_freq_tbl[PVS_SLOW] = acpu_freq_tbl,
133 .pvs_acpu_freq_tbl[PVS_NOMINAL] = acpu_freq_tbl,
134 .pvs_acpu_freq_tbl[PVS_FAST] = acpu_freq_tbl,
135 .l2_freq_tbl = l2_freq_tbl,
136 .l2_freq_tbl_size = ARRAY_SIZE(l2_freq_tbl),
137 .bus_scale_data = &bus_scale_data,
138 .qfprom_phys_base = 0x00700000,
139};
140
141static int __init acpuclk_8627_probe(struct platform_device *pdev)
142{
143 return acpuclk_krait_init(&pdev->dev, &acpuclk_8627_params);
144}
145
146static struct platform_driver acpuclk_8627_driver = {
147 .driver = {
148 .name = "acpuclk-8627",
149 .owner = THIS_MODULE,
150 },
151};
152
153static int __init acpuclk_8627_init(void)
154{
155 return platform_driver_probe(&acpuclk_8627_driver,
156 acpuclk_8627_probe);
157}
158device_initcall(acpuclk_8627_init);