blob: 89a0a847b7ab854d7f4b8cfe38b03341ad9d6aef [file] [log] [blame]
Patrick Daly985c14b2012-12-03 17:12:37 -08001/*
2 * Copyright (c) 2013, The Linux Foundation. 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/* Corner type vreg VDD values */
15#define LVL_NONE RPM_REGULATOR_CORNER_NONE
16#define LVL_LOW RPM_REGULATOR_CORNER_SVS_SOC
17#define LVL_NOM RPM_REGULATOR_CORNER_NORMAL
18#define LVL_HIGH RPM_REGULATOR_CORNER_SUPER_TURBO
19
20enum clk_src {
21 CXO,
22 PLL0,
23 ACPUPLL,
24 NUM_SRC,
25};
26
27struct src_clock {
28 struct clk *clk;
29 const char *name;
30};
31
32struct clkctl_acpu_speed {
33 bool use_for_scaling;
34 unsigned int khz;
35 int src;
36 unsigned int src_sel;
37 unsigned int src_div;
38 unsigned int vdd_cpu;
39 unsigned int vdd_mem;
40 unsigned int bw_level;
41};
42
43struct acpuclk_reg_data {
44 u32 cfg_src_mask;
45 u32 cfg_src_shift;
46 u32 cfg_div_mask;
47 u32 cfg_div_shift;
48 u32 update_mask;
49 u32 poll_mask;
50};
51
52struct acpuclk_drv_data {
53 struct mutex lock;
54 struct clkctl_acpu_speed *freq_tbl;
55 struct clkctl_acpu_speed *current_speed;
56 struct msm_bus_scale_pdata *bus_scale;
57 void __iomem *apcs_rcg_config;
58 void __iomem *apcs_rcg_cmd;
59 void __iomem *apcs_cpu_pwr_ctl;
60 struct regulator *vdd_cpu;
61 unsigned long vdd_max_cpu;
62 struct regulator *vdd_mem;
63 unsigned long vdd_max_mem;
64 struct src_clock src_clocks[NUM_SRC];
65 struct acpuclk_reg_data reg_data;
Patrick Dalyaf8808e2013-03-20 12:57:00 -070066 unsigned long power_collapse_khz;
67 unsigned long wait_for_irq_khz;
Patrick Daly985c14b2012-12-03 17:12:37 -080068};
69
70/* Instantaneous bandwidth requests in MB/s. */
71#define BW_MBPS(_bw) \
72 { \
73 .vectors = &(struct msm_bus_vectors){ \
74 .src = MSM_BUS_MASTER_AMPSS_M0, \
75 .dst = MSM_BUS_SLAVE_EBI_CH0, \
76 .ib = (_bw) * 1000000ULL, \
77 .ab = 0, \
78 }, \
79 .num_paths = 1, \
80 }
81
82int __init acpuclk_cortex_init(struct platform_device *pdev,
83 struct acpuclk_drv_data *data);
84