blob: 2ad7d22f7212448092d58f3923afd17391f02e9c [file] [log] [blame]
Abhijeet Dharmapurikar0db555f2012-08-23 15:51:58 -07001/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13#ifndef _ARCH_ARM_MACH_MSM_MSM_DCVS_H
14#define _ARCH_ARM_MACH_MSM_MSM_DCVS_H
15
16#include <mach/msm_dcvs_scm.h>
17
18#define CORE_NAME_MAX (32)
19#define CORES_MAX (10)
20
Abhijeet Dharmapurikar0db555f2012-08-23 15:51:58 -070021#define CPU_OFFSET 1 /* used to notify TZ the core number */
Abhijeet Dharmapurikar1bbc0322012-09-12 16:40:20 -070022#define GPU_OFFSET (CORES_MAX * 2/3) /* there will be more cpus than gpus,
23 * let the GPU be assigned fewer core
24 * elements and start later
25 */
Abhijeet Dharmapurikar0db555f2012-08-23 15:51:58 -070026
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -070027enum msm_core_idle_state {
28 MSM_DCVS_IDLE_ENTER,
29 MSM_DCVS_IDLE_EXIT,
30};
31
32enum msm_core_control_event {
33 MSM_DCVS_ENABLE_IDLE_PULSE,
34 MSM_DCVS_DISABLE_IDLE_PULSE,
35 MSM_DCVS_ENABLE_HIGH_LATENCY_MODES,
36 MSM_DCVS_DISABLE_HIGH_LATENCY_MODES,
37};
38
Steve Mucklef9a87492012-11-02 15:41:00 -070039struct msm_dcvs_sync_rule {
40 unsigned long cpu_khz;
41 unsigned long gpu_floor_khz;
42};
43
44struct msm_dcvs_platform_data {
45 struct msm_dcvs_sync_rule *sync_rules;
46 unsigned num_sync_rules;
Steve Muckle749f3012012-11-21 10:12:39 -080047 unsigned long gpu_max_nom_khz;
Steve Mucklef9a87492012-11-02 15:41:00 -070048};
49
Abhijeet Dharmapurikarc1ed66c2012-09-10 16:03:39 -070050struct msm_gov_platform_data {
51 struct msm_dcvs_core_info *info;
52 int latency;
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -070053};
54
55/**
Steve Mucklef9a87492012-11-02 15:41:00 -070056 * msm_dcvs_register_cpu_freq
57 * @freq: the frequency value to register
58 * @voltage: the operating voltage (in mV) associated with the above frequency
59 *
60 * Register a cpu frequency and its operating voltage with dcvs.
61 */
62#ifdef CONFIG_MSM_DCVS
63void msm_dcvs_register_cpu_freq(uint32_t freq, uint32_t voltage);
64#else
65static inline void msm_dcvs_register_cpu_freq(uint32_t freq, uint32_t voltage)
66{}
67#endif
68
69/**
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -070070 * msm_dcvs_idle
Abhijeet Dharmapurikar1bbc0322012-09-12 16:40:20 -070071 * @dcvs_core_id: The id returned by msm_dcvs_register_core
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -070072 * @state: The enter/exit idle state the core is in
73 * @iowaited: iowait in us
74 * on iMSM_DCVS_IDLE_EXIT.
75 * @return:
76 * 0 on success,
77 * -ENOSYS,
78 * -EINVAL,
79 * SCM return values
80 *
81 * Send idle state notifications to the msm_dcvs driver
82 */
Abhijeet Dharmapurikar1bbc0322012-09-12 16:40:20 -070083int msm_dcvs_idle(int dcvs_core_id, enum msm_core_idle_state state,
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -070084 uint32_t iowaited);
85
86/**
87 * struct msm_dcvs_core_info
88 *
89 * Core specific information used by algorithm. Need to provide this
90 * before the sink driver can be registered.
91 */
92struct msm_dcvs_core_info {
Abhijeet Dharmapurikarfc7dca42012-08-26 18:27:53 -070093 int num_cores;
94 int *sensors;
Abhijeet Dharmapurikar80add422012-09-13 11:11:54 -070095 int thermal_poll_ms;
Abhijeet Dharmapurikar44451662012-08-23 18:58:44 -070096 struct msm_dcvs_freq_entry *freq_tbl;
97 struct msm_dcvs_core_param core_param;
98 struct msm_dcvs_algo_param algo_param;
99 struct msm_dcvs_energy_curve_coeffs energy_coeffs;
100 struct msm_dcvs_power_params power_param;
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -0700101};
102
103/**
104 * msm_dcvs_register_core
Abhijeet Dharmapurikar1bbc0322012-09-12 16:40:20 -0700105 * @type: whether this is a CPU or a GPU
106 * @type_core_num: The number of the core for a type
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -0700107 * @info: The core specific algorithm parameters.
Abhijeet Dharmapurikarfc7dca42012-08-26 18:27:53 -0700108 * @sensor: The thermal sensor number of the core in question
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -0700109 * @return :
110 * 0 on success,
111 * -ENOSYS,
112 * -ENOMEM
113 *
114 * Register the core with msm_dcvs driver. Done once at init before calling
115 * msm_dcvs_freq_sink_register
116 * Cores that need to run synchronously must share the same group id.
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -0700117 */
Abhijeet Dharmapurikar69134112012-08-31 22:10:41 -0700118extern int msm_dcvs_register_core(
Abhijeet Dharmapurikar1bbc0322012-09-12 16:40:20 -0700119 enum msm_dcvs_core_type type,
120 int type_core_num,
Abhijeet Dharmapurikar69134112012-08-31 22:10:41 -0700121 struct msm_dcvs_core_info *info,
Abhijeet Dharmapurikar1bbc0322012-09-12 16:40:20 -0700122 int (*set_frequency)(int type_core_num, unsigned int freq),
123 unsigned int (*get_frequency)(int type_core_num),
124 int (*idle_enable)(int type_core_num,
125 enum msm_core_control_event event),
Steve Muckle682c7a02012-11-12 14:20:39 -0800126 int (*set_floor_frequency)(int type_core_num, unsigned int freq),
Abhijeet Dharmapurikar69134112012-08-31 22:10:41 -0700127 int sensor);
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -0700128
129/**
Abhijeet Dharmapurikar69134112012-08-31 22:10:41 -0700130 * msm_dcvs_freq_sink_start
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -0700131 * @drv: The sink driver
132 * @return: Handle unique to the core.
133 *
134 * Register the clock driver code with the msm_dvs driver to get notified about
135 * frequency change requests.
136 */
Abhijeet Dharmapurikar1bbc0322012-09-12 16:40:20 -0700137extern int msm_dcvs_freq_sink_start(int dcvs_core_id);
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -0700138
139/**
Abhijeet Dharmapurikar69134112012-08-31 22:10:41 -0700140 * msm_dcvs_freq_sink_stop
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -0700141 * @drv: The sink driver
142 * @return:
143 * 0 on success,
144 * -EINVAL
145 *
146 * Unregister the sink driver for the core. This will cause the source driver
147 * for the core to stop sending idle pulses.
148 */
Abhijeet Dharmapurikar1bbc0322012-09-12 16:40:20 -0700149extern int msm_dcvs_freq_sink_stop(int dcvs_core_id);
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -0700150
Abhijeet Dharmapurikar68c970e2012-08-31 20:42:53 -0700151/**
152 * msm_dcvs_update_limits
153 * @drv: The sink driver
154 *
155 * Update the frequency known to dcvs when the limits are changed.
156 */
Abhijeet Dharmapurikar1bbc0322012-09-12 16:40:20 -0700157extern void msm_dcvs_update_limits(int dcvs_core_id);
Steve Muckle749f3012012-11-21 10:12:39 -0800158
159/**
160 * msm_dcvs_apply_gpu_floor
161 * @cpu_freq: CPU frequency to compare to GPU sync rules
162 *
163 * Apply a GPU floor frequency if the corresponding CPU frequency,
164 * or the number of CPUs online, requires it.
165 */
166extern void msm_dcvs_apply_gpu_floor(unsigned long cpu_freq);
Steve Mucklec48381e2012-11-21 15:47:15 -0800167
168/**
169 * msm_dcvs_update_algo_params
170 * @return:
171 * 0 on success, < 0 on error
172 *
173 * Updates the DCVS algorithm with parameters depending on the
174 * number of CPUs online.
175 */
176extern int msm_dcvs_update_algo_params(void);
Praveen Chidambaramf53ef1b2011-12-06 08:27:49 -0700177#endif