Commit 7cc3ef9a authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://linux-dj.bkbits.net/cpufreq

into penguin.transmeta.com:/home/penguin/torvalds/repositories/kernel/linux
parents 26a97bb1 ce2d3f00
...@@ -242,6 +242,8 @@ static int __init elanfreq_init(void) ...@@ -242,6 +242,8 @@ static int __init elanfreq_init(void)
NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL); NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
if (!driver) if (!driver)
return -ENOMEM; return -ENOMEM;
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
...@@ -260,8 +262,6 @@ static int __init elanfreq_init(void) ...@@ -260,8 +262,6 @@ static int __init elanfreq_init(void)
driver->verify = &elanfreq_verify; driver->verify = &elanfreq_verify;
driver->setpolicy = &elanfreq_setpolicy; driver->setpolicy = &elanfreq_setpolicy;
driver->init = NULL;
driver->exit = NULL;
strncpy(driver->name, "elanfreq", CPUFREQ_NAME_LEN); strncpy(driver->name, "elanfreq", CPUFREQ_NAME_LEN);
driver->policy[0].cpu = 0; driver->policy[0].cpu = 0;
......
...@@ -431,11 +431,15 @@ static int __init cpufreq_gx_init(void) ...@@ -431,11 +431,15 @@ static int __init cpufreq_gx_init(void)
driver = kmalloc(sizeof(struct cpufreq_driver) + NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL); driver = kmalloc(sizeof(struct cpufreq_driver) + NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
if (driver == NULL) if (driver == NULL)
return -ENOMEM; return -ENOMEM;
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
params = kmalloc(sizeof(struct gxfreq_params), GFP_KERNEL); params = kmalloc(sizeof(struct gxfreq_params), GFP_KERNEL);
if (params == NULL) { if (params == NULL) {
kfree(driver); kfree(driver);
return -ENOMEM; return -ENOMEM;
} }
memset(params, 0, sizeof(struct gxfreq_params));
driver->policy = (struct cpufreq_policy *)(driver + 1); driver->policy = (struct cpufreq_policy *)(driver + 1);
params->cs55x0 = gx_pci; params->cs55x0 = gx_pci;
......
...@@ -762,6 +762,8 @@ static int __init longhaul_init (void) ...@@ -762,6 +762,8 @@ static int __init longhaul_init (void)
NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL); NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
if (!driver) if (!driver)
return -ENOMEM; return -ENOMEM;
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
...@@ -771,8 +773,7 @@ static int __init longhaul_init (void) ...@@ -771,8 +773,7 @@ static int __init longhaul_init (void)
driver->verify = &longhaul_verify; driver->verify = &longhaul_verify;
driver->setpolicy = &longhaul_setpolicy; driver->setpolicy = &longhaul_setpolicy;
driver->init = NULL;
driver->exit = NULL;
strncpy(driver->name, "longhaul", CPUFREQ_NAME_LEN); strncpy(driver->name, "longhaul", CPUFREQ_NAME_LEN);
driver->policy[0].cpu = 0; driver->policy[0].cpu = 0;
......
...@@ -54,7 +54,7 @@ static void longrun_get_policy(struct cpufreq_policy *policy) ...@@ -54,7 +54,7 @@ static void longrun_get_policy(struct cpufreq_policy *policy)
policy->min = longrun_low_freq + msr_lo * policy->min = longrun_low_freq + msr_lo *
((longrun_high_freq - longrun_low_freq) / 100); ((longrun_high_freq - longrun_low_freq) / 100);
policy->min = longrun_low_freq + msr_hi * policy->max = longrun_low_freq + msr_hi *
((longrun_high_freq - longrun_low_freq) / 100); ((longrun_high_freq - longrun_low_freq) / 100);
policy->cpu = 0; policy->cpu = 0;
} }
...@@ -241,6 +241,8 @@ static int __init longrun_init(void) ...@@ -241,6 +241,8 @@ static int __init longrun_init(void)
NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL); NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
if (!driver) if (!driver)
return -ENOMEM; return -ENOMEM;
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
...@@ -251,8 +253,7 @@ static int __init longrun_init(void) ...@@ -251,8 +253,7 @@ static int __init longrun_init(void)
driver->policy[0].cpuinfo.min_freq = longrun_low_freq; driver->policy[0].cpuinfo.min_freq = longrun_low_freq;
driver->policy[0].cpuinfo.max_freq = longrun_high_freq; driver->policy[0].cpuinfo.max_freq = longrun_high_freq;
driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL; driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL;
driver->init = NULL;
driver->exit = NULL;
strncpy(driver->name, "longrun", CPUFREQ_NAME_LEN); strncpy(driver->name, "longrun", CPUFREQ_NAME_LEN);
longrun_get_policy(&driver->policy[0]); longrun_get_policy(&driver->policy[0]);
......
...@@ -220,6 +220,8 @@ static int __init cpufreq_p4_init(void) ...@@ -220,6 +220,8 @@ static int __init cpufreq_p4_init(void)
NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL); NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
if (!driver) if (!driver)
return -ENOMEM; return -ENOMEM;
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
...@@ -240,8 +242,6 @@ static int __init cpufreq_p4_init(void) ...@@ -240,8 +242,6 @@ static int __init cpufreq_p4_init(void)
driver->verify = &cpufreq_p4_verify; driver->verify = &cpufreq_p4_verify;
driver->setpolicy = &cpufreq_p4_setpolicy; driver->setpolicy = &cpufreq_p4_setpolicy;
driver->init = NULL;
driver->exit = NULL;
strncpy(driver->name, "p4-clockmod", CPUFREQ_NAME_LEN); strncpy(driver->name, "p4-clockmod", CPUFREQ_NAME_LEN);
for (i=0;i<NR_CPUS;i++) { for (i=0;i<NR_CPUS;i++) {
......
...@@ -172,6 +172,8 @@ static int __init powernow_k6_init(void) ...@@ -172,6 +172,8 @@ static int __init powernow_k6_init(void)
release_region (POWERNOW_IOPORT, 16); release_region (POWERNOW_IOPORT, 16);
return -ENOMEM; return -ENOMEM;
} }
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
/* table init */ /* table init */
...@@ -184,8 +186,6 @@ static int __init powernow_k6_init(void) ...@@ -184,8 +186,6 @@ static int __init powernow_k6_init(void)
driver->verify = &powernow_k6_verify; driver->verify = &powernow_k6_verify;
driver->setpolicy = &powernow_k6_setpolicy; driver->setpolicy = &powernow_k6_setpolicy;
driver->init = NULL;
driver->exit = NULL;
strncpy(driver->name, "powernow-k6", CPUFREQ_NAME_LEN); strncpy(driver->name, "powernow-k6", CPUFREQ_NAME_LEN);
/* cpuinfo and default policy values */ /* cpuinfo and default policy values */
......
...@@ -674,6 +674,8 @@ static int __init speedstep_init(void) ...@@ -674,6 +674,8 @@ static int __init speedstep_init(void)
NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL); NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
if (!driver) if (!driver)
return -ENOMEM; return -ENOMEM;
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
...@@ -690,8 +692,6 @@ static int __init speedstep_init(void) ...@@ -690,8 +692,6 @@ static int __init speedstep_init(void)
driver->verify = &speedstep_verify; driver->verify = &speedstep_verify;
driver->setpolicy = &speedstep_setpolicy; driver->setpolicy = &speedstep_setpolicy;
driver->init = NULL;
driver->exit = NULL;
strncpy(driver->name, "speedstep", CPUFREQ_NAME_LEN); strncpy(driver->name, "speedstep", CPUFREQ_NAME_LEN);
driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL; driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
* linux/include/linux/cpufreq.h * linux/include/linux/cpufreq.h
* *
* Copyright (C) 2001 Russell King * Copyright (C) 2001 Russell King
* (C) 2002 Dominik Brodowski <linux@brodo.de> * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
* *
* *
* $Id: cpufreq.h,v 1.29 2002/11/11 15:35:47 db Exp $ * $Id: cpufreq.h,v 1.36 2003/01/20 17:31:48 db Exp $
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
#include <linux/device.h> #include <linux/device.h>
#define CPUFREQ_NAME_LEN 16
/********************************************************************* /*********************************************************************
* CPUFREQ NOTIFIER INTERFACE * * CPUFREQ NOTIFIER INTERFACE *
*********************************************************************/ *********************************************************************/
...@@ -37,14 +40,17 @@ int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list); ...@@ -37,14 +40,17 @@ int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list);
#define CPUFREQ_POLICY_POWERSAVE (1) #define CPUFREQ_POLICY_POWERSAVE (1)
#define CPUFREQ_POLICY_PERFORMANCE (2) #define CPUFREQ_POLICY_PERFORMANCE (2)
#define CPUFREQ_POLICY_GOVERNOR (3)
/* Frequency values here are CPU kHz so that hardware which doesn't run /* Frequency values here are CPU kHz so that hardware which doesn't run
* with some frequencies can complain without having to guess what per * with some frequencies can complain without having to guess what per
* cent / per mille means. * cent / per mille means.
* Maximum transition latency is in nanoseconds - if it's unknown, * Maximum transition latency is in microseconds - if it's unknown,
* CPUFREQ_ETERNAL shall be used. * CPUFREQ_ETERNAL shall be used.
*/ */
struct cpufreq_governor;
#define CPUFREQ_ETERNAL (-1) #define CPUFREQ_ETERNAL (-1)
struct cpufreq_cpuinfo { struct cpufreq_cpuinfo {
unsigned int max_freq; unsigned int max_freq;
...@@ -57,6 +63,7 @@ struct cpufreq_policy { ...@@ -57,6 +63,7 @@ struct cpufreq_policy {
unsigned int min; /* in kHz */ unsigned int min; /* in kHz */
unsigned int max; /* in kHz */ unsigned int max; /* in kHz */
unsigned int policy; /* see above */ unsigned int policy; /* see above */
struct cpufreq_governor *governor; /* see below */
struct cpufreq_cpuinfo cpuinfo; /* see above */ struct cpufreq_cpuinfo cpuinfo; /* see above */
struct intf_data intf; /* interface data */ struct intf_data intf; /* interface data */
}; };
...@@ -104,25 +111,62 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mu ...@@ -104,25 +111,62 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mu
return carry + val; return carry + val;
}; };
/*********************************************************************
* CPUFREQ GOVERNORS *
*********************************************************************/
#define CPUFREQ_GOV_START 1
#define CPUFREQ_GOV_STOP 2
#define CPUFREQ_GOV_LIMITS 3
struct cpufreq_governor {
char name[CPUFREQ_NAME_LEN];
int (*governor) (struct cpufreq_policy *policy,
unsigned int event);
struct list_head governor_list;
struct module *owner;
};
/* pass a target to the cpufreq driver
* _l : (cpufreq_driver_sem is not held)
*/
inline int cpufreq_driver_target(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation);
inline int cpufreq_driver_target_l(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation);
/* pass an event to the cpufreq governor */
int cpufreq_governor_l(unsigned int cpu, unsigned int event);
int cpufreq_register_governor(struct cpufreq_governor *governor);
void cpufreq_unregister_governor(struct cpufreq_governor *governor);
/********************************************************************* /*********************************************************************
* CPUFREQ DRIVER INTERFACE * * CPUFREQ DRIVER INTERFACE *
*********************************************************************/ *********************************************************************/
#define CPUFREQ_NAME_LEN 16 #define CPUFREQ_RELATION_L 0 /* lowest frequency at or above target */
#define CPUFREQ_RELATION_H 1 /* highest frequency below or at target */
struct cpufreq_driver { struct cpufreq_driver {
/* needed by all drivers */ /* needed by all drivers */
int (*verify) (struct cpufreq_policy *policy); int (*verify) (struct cpufreq_policy *policy);
int (*setpolicy) (struct cpufreq_policy *policy); struct cpufreq_policy *policy;
struct cpufreq_policy *policy; char name[CPUFREQ_NAME_LEN];
char name[CPUFREQ_NAME_LEN]; /* define one out of two */
int (*setpolicy) (struct cpufreq_policy *policy);
int (*target) (struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation);
/* optional, for the moment */ /* optional, for the moment */
int (*init) (struct cpufreq_policy *policy); int (*init) (struct cpufreq_policy *policy);
int (*exit) (struct cpufreq_policy *policy); int (*exit) (struct cpufreq_policy *policy);
/* 2.4. compatible API */ /* 2.4. compatible API */
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
unsigned int cpu_cur_freq[NR_CPUS]; unsigned int cpu_cur_freq[NR_CPUS];
#endif #endif
}; };
...@@ -276,4 +320,10 @@ int cpufreq_frequency_table_setpolicy(struct cpufreq_policy *policy, ...@@ -276,4 +320,10 @@ int cpufreq_frequency_table_setpolicy(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table, struct cpufreq_frequency_table *table,
unsigned int *index); unsigned int *index);
int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table,
unsigned int target_freq,
unsigned int relation,
unsigned int *index);
#endif /* _LINUX_CPUFREQ_H */ #endif /* _LINUX_CPUFREQ_H */
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment