~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to xen/include/acpi/cpufreq/cpufreq.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  xen/include/acpi/cpufreq/cpufreq.h
 
3
 *
 
4
 *  Copyright (C) 2001 Russell King
 
5
 *            (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
 
6
 *
 
7
 * $Id: cpufreq.h,v 1.36 2003/01/20 17:31:48 db Exp $
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License version 2 as
 
11
 * published by the Free Software Foundation.
 
12
 */
 
13
 
 
14
#ifndef __XEN_CPUFREQ_PM_H__
 
15
#define __XEN_CPUFREQ_PM_H__
 
16
 
 
17
#include <xen/types.h>
 
18
#include <xen/list.h>
 
19
#include <xen/cpumask.h>
 
20
 
 
21
#include "processor_perf.h"
 
22
 
 
23
DECLARE_PER_CPU(spinlock_t, cpufreq_statistic_lock);
 
24
 
 
25
extern bool_t __read_mostly cpufreq_verbose;
 
26
 
 
27
struct cpufreq_governor;
 
28
 
 
29
struct acpi_cpufreq_data {
 
30
    struct processor_performance *acpi_data;
 
31
    struct cpufreq_frequency_table *freq_table;
 
32
    unsigned int max_freq;
 
33
    unsigned int cpu_feature;
 
34
};
 
35
 
 
36
struct cpufreq_cpuinfo {
 
37
    unsigned int        max_freq;
 
38
    unsigned int        second_max_freq;    /* P1 if Turbo Mode is on */
 
39
    unsigned int        min_freq;
 
40
    unsigned int        transition_latency; /* in 10^(-9) s = nanoseconds */
 
41
};
 
42
 
 
43
struct cpufreq_policy {
 
44
    cpumask_t           cpus;          /* affected CPUs */
 
45
    unsigned int        shared_type;   /* ANY or ALL affected CPUs
 
46
                                          should set cpufreq */
 
47
    unsigned int        cpu;           /* cpu nr of registered CPU */
 
48
    struct cpufreq_cpuinfo    cpuinfo;
 
49
 
 
50
    unsigned int        min;    /* in kHz */
 
51
    unsigned int        max;    /* in kHz */
 
52
    unsigned int        cur;    /* in kHz, only needed if cpufreq
 
53
                                 * governors are used */
 
54
    struct cpufreq_governor     *governor;
 
55
 
 
56
    unsigned int        resume; /* flag for cpufreq 1st run
 
57
                                 * S3 wakeup, hotplug cpu, etc */
 
58
};
 
59
extern struct cpufreq_policy *cpufreq_cpu_policy[NR_CPUS];
 
60
 
 
61
extern int __cpufreq_set_policy(struct cpufreq_policy *data,
 
62
                                struct cpufreq_policy *policy);
 
63
 
 
64
void cpufreq_cmdline_parse(char *);
 
65
 
 
66
#define CPUFREQ_SHARED_TYPE_NONE (0) /* None */
 
67
#define CPUFREQ_SHARED_TYPE_HW   (1) /* HW does needed coordination */
 
68
#define CPUFREQ_SHARED_TYPE_ALL  (2) /* All dependent CPUs should set freq */
 
69
#define CPUFREQ_SHARED_TYPE_ANY  (3) /* Freq can be set from any dependent CPU*/
 
70
 
 
71
/******************** cpufreq transition notifiers *******************/
 
72
 
 
73
struct cpufreq_freqs {
 
74
    unsigned int cpu;    /* cpu nr */
 
75
    unsigned int old;
 
76
    unsigned int new;
 
77
    u8 flags;            /* flags of cpufreq_driver, see below. */
 
78
};
 
79
 
 
80
 
 
81
/*********************************************************************
 
82
 *                          CPUFREQ GOVERNORS                        *
 
83
 *********************************************************************/
 
84
 
 
85
#define CPUFREQ_GOV_START  1
 
86
#define CPUFREQ_GOV_STOP   2
 
87
#define CPUFREQ_GOV_LIMITS 3
 
88
 
 
89
struct cpufreq_governor {
 
90
    char    name[CPUFREQ_NAME_LEN];
 
91
    int     (*governor)(struct cpufreq_policy *policy,
 
92
                        unsigned int event);
 
93
    void    (*handle_option)(const char *name, const char *value);
 
94
    struct list_head governor_list;
 
95
};
 
96
 
 
97
extern struct cpufreq_governor *cpufreq_opt_governor;
 
98
extern struct cpufreq_governor cpufreq_gov_dbs;
 
99
extern struct cpufreq_governor cpufreq_gov_userspace;
 
100
extern struct cpufreq_governor cpufreq_gov_performance;
 
101
extern struct cpufreq_governor cpufreq_gov_powersave;
 
102
 
 
103
extern int cpufreq_register_governor(struct cpufreq_governor *governor);
 
104
extern int cpufreq_unregister_governor(struct cpufreq_governor *governor);
 
105
extern struct cpufreq_governor *__find_governor(const char *governor);
 
106
#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_dbs
 
107
 
 
108
/* pass a target to the cpufreq driver */
 
109
extern int __cpufreq_driver_target(struct cpufreq_policy *policy,
 
110
                                   unsigned int target_freq,
 
111
                                   unsigned int relation);
 
112
 
 
113
#define GOV_GETAVG     1
 
114
#define USR_GETAVG     2
 
115
extern int cpufreq_driver_getavg(unsigned int cpu, unsigned int flag);
 
116
 
 
117
static __inline__ int 
 
118
__cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)
 
119
{
 
120
    return policy->governor->governor(policy, event);
 
121
}
 
122
 
 
123
 
 
124
/*********************************************************************
 
125
 *                      CPUFREQ DRIVER INTERFACE                     *
 
126
 *********************************************************************/
 
127
 
 
128
#define CPUFREQ_RELATION_L 0  /* lowest frequency at or above target */
 
129
#define CPUFREQ_RELATION_H 1  /* highest frequency below or at target */
 
130
 
 
131
struct cpufreq_driver {
 
132
    char   name[CPUFREQ_NAME_LEN];
 
133
    int    (*init)(struct cpufreq_policy *policy);
 
134
    int    (*verify)(struct cpufreq_policy *policy);
 
135
    int    (*target)(struct cpufreq_policy *policy,
 
136
                     unsigned int target_freq,
 
137
                     unsigned int relation);
 
138
    unsigned int    (*get)(unsigned int cpu);
 
139
    unsigned int    (*getavg)(unsigned int cpu, unsigned int flag);
 
140
    int    (*exit)(struct cpufreq_policy *policy);
 
141
};
 
142
 
 
143
extern struct cpufreq_driver *cpufreq_driver;
 
144
 
 
145
static __inline__ 
 
146
int cpufreq_register_driver(struct cpufreq_driver *driver_data)
 
147
{
 
148
    if (!driver_data         || 
 
149
        !driver_data->init   || 
 
150
        !driver_data->exit   || 
 
151
        !driver_data->verify || 
 
152
        !driver_data->target)
 
153
        return -EINVAL;
 
154
 
 
155
    if (cpufreq_driver)
 
156
        return -EBUSY;
 
157
 
 
158
    cpufreq_driver = driver_data;
 
159
    return 0;
 
160
}
 
161
 
 
162
static __inline__ 
 
163
int cpufreq_unregister_driver(struct cpufreq_driver *driver)
 
164
{
 
165
    if (!cpufreq_driver || (driver != cpufreq_driver))
 
166
        return -EINVAL;
 
167
 
 
168
    cpufreq_driver = NULL;
 
169
    return 0;
 
170
}
 
171
 
 
172
static __inline__
 
173
void cpufreq_verify_within_limits(struct cpufreq_policy *policy,
 
174
                                  unsigned int min, unsigned int max)
 
175
{
 
176
    if (policy->min < min)
 
177
        policy->min = min;
 
178
    if (policy->max < min)
 
179
        policy->max = min;
 
180
    if (policy->min > max)
 
181
        policy->min = max;
 
182
    if (policy->max > max)
 
183
        policy->max = max;
 
184
    if (policy->min > policy->max)
 
185
        policy->min = policy->max;
 
186
    return;
 
187
}
 
188
 
 
189
 
 
190
/*********************************************************************
 
191
 *                     FREQUENCY TABLE HELPERS                       *
 
192
 *********************************************************************/
 
193
 
 
194
#define CPUFREQ_ENTRY_INVALID ~0
 
195
#define CPUFREQ_TABLE_END     ~1
 
196
 
 
197
struct cpufreq_frequency_table {
 
198
    unsigned int    index;     /* any */
 
199
    unsigned int    frequency; /* kHz - doesn't need to be in ascending
 
200
                                * order */
 
201
};
 
202
 
 
203
int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
 
204
                   struct cpufreq_frequency_table *table);
 
205
 
 
206
int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
 
207
                   struct cpufreq_frequency_table *table);
 
208
 
 
209
int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
 
210
                   struct cpufreq_frequency_table *table,
 
211
                   unsigned int target_freq,
 
212
                   unsigned int relation,
 
213
                   unsigned int *index);
 
214
 
 
215
 
 
216
/*********************************************************************
 
217
 *                     UNIFIED DEBUG HELPERS                         *
 
218
 *********************************************************************/
 
219
 
 
220
struct cpu_dbs_info_s {
 
221
    uint64_t prev_cpu_idle;
 
222
    uint64_t prev_cpu_wall;
 
223
    struct cpufreq_policy *cur_policy;
 
224
    struct cpufreq_frequency_table *freq_table;
 
225
    int cpu;
 
226
    unsigned int enable:1;
 
227
    unsigned int stoppable:1;
 
228
    unsigned int turbo_enabled:1;
 
229
};
 
230
 
 
231
int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event);
 
232
int get_cpufreq_ondemand_para(uint32_t *sampling_rate_max,
 
233
                              uint32_t *sampling_rate_min,
 
234
                              uint32_t *sampling_rate,
 
235
                              uint32_t *up_threshold);
 
236
int write_ondemand_sampling_rate(unsigned int sampling_rate);
 
237
int write_ondemand_up_threshold(unsigned int up_threshold);
 
238
 
 
239
int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq);
 
240
 
 
241
void cpufreq_dbs_timer_suspend(void);
 
242
void cpufreq_dbs_timer_resume(void);
 
243
 
 
244
void cpufreq_dbs_enable_turbo(int cpuid);
 
245
void cpufreq_dbs_disable_turbo(int cpuid);
 
246
unsigned int cpufreq_dbs_get_turbo_status(int cpuid);
 
247
#endif /* __XEN_CPUFREQ_PM_H__ */