Commit fef3278f authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://bk.arm.linux.org.uk/linux-2.6-pcmcia

into ppc970.osdl.org:/home/torvalds/v2.6/linux
parents 5ab27ef0 25cc28bf
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <linux/cpufreq.h> #include <linux/cpufreq.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/notifier.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/hardware.h> #include <asm/hardware.h>
...@@ -133,6 +132,39 @@ static int pxa2xx_pcmcia_set_timing(struct soc_pcmcia_socket *skt) ...@@ -133,6 +132,39 @@ static int pxa2xx_pcmcia_set_timing(struct soc_pcmcia_socket *skt)
return pxa2xx_pcmcia_set_mcxx(skt, clk); return pxa2xx_pcmcia_set_mcxx(skt, clk);
} }
#ifdef CONFIG_CPU_FREQ
static int
pxa2xx_pcmcia_frequency_change(struct soc_pcmcia_socket *skt,
unsigned long val,
struct cpufreq_freqs *freqs)
{
#warning "it's not clear if this is right since the core CPU (N) clock has no effect on the memory (L) clock"
switch (val) {
case CPUFREQ_PRECHANGE:
if (freqs->new > freqs->old) {
debug(skt, 2, "new frequency %u.%uMHz > %u.%uMHz, "
"pre-updating\n",
freqs->new / 1000, (freqs->new / 100) % 10,
freqs->old / 1000, (freqs->old / 100) % 10);
pxa2xx_pcmcia_set_mcxx(skt, freqs->new);
}
break;
case CPUFREQ_POSTCHANGE:
if (freqs->new < freqs->old) {
debug(skt, 2, "new frequency %u.%uMHz < %u.%uMHz, "
"post-updating\n",
freqs->new / 1000, (freqs->new / 100) % 10,
freqs->old / 1000, (freqs->old / 100) % 10);
pxa2xx_pcmcia_set_mcxx(skt, freqs->new);
}
break;
}
return 0;
}
#endif
int pxa2xx_drv_pcmcia_probe(struct device *dev) int pxa2xx_drv_pcmcia_probe(struct device *dev)
{ {
int ret; int ret;
...@@ -181,6 +213,9 @@ int pxa2xx_drv_pcmcia_probe(struct device *dev) ...@@ -181,6 +213,9 @@ int pxa2xx_drv_pcmcia_probe(struct device *dev)
/* Provide our PXA2xx specific timing routines. */ /* Provide our PXA2xx specific timing routines. */
ops->set_timing = pxa2xx_pcmcia_set_timing; ops->set_timing = pxa2xx_pcmcia_set_timing;
#ifdef CONFIG_CPU_FREQ
ops->frequency_change = pxa2xx_pcmcia_frequency_change;
#endif
ret = soc_common_drv_pcmcia_probe(dev, ops, first, nr); ret = soc_common_drv_pcmcia_probe(dev, ops, first, nr);
...@@ -227,101 +262,13 @@ static struct device_driver pxa2xx_pcmcia_driver = { ...@@ -227,101 +262,13 @@ static struct device_driver pxa2xx_pcmcia_driver = {
.bus = &platform_bus_type, .bus = &platform_bus_type,
}; };
#ifdef CONFIG_CPU_FREQ
/*
* When pxa2xx_pcmcia_notifier() decides that a MC{IO,MEM,ATT} adjustment (due
* to a core clock frequency change) is needed, this routine establishes
* new values consistent with the clock speed `clock'.
*/
static void pxa2xx_pcmcia_update_mcxx(unsigned int clock)
{
struct soc_pcmcia_socket *skt;
down(&soc_sockets_lock);
list_for_each_entry(skt, &soc_sockets, node) {
pxa2xx_pcmcia_set_mcxx(skt, clock);
}
up(&soc_sockets_lock);
}
/*
* When changing the processor L clock frequency, it is necessary
* to adjust the MCXX timings accordingly. We've recorded the timings
* requested by Card Services, so this is just a matter of finding
* out what our current speed is, and then recomputing the new MCXX
* values.
*
* Returns: 0 on success, -1 on error
*/
static int
pxa2xx_pcmcia_notifier(struct notifier_block *nb, unsigned long val, void *data)
{
struct cpufreq_freqs *freqs = data;
#warning "it's not clear if this is right since the core CPU (N) clock has no effect on the memory (L) clock"
switch (val) {
case CPUFREQ_PRECHANGE:
if (freqs->new > freqs->old) {
debug( 2, "new frequency %u.%uMHz > %u.%uMHz, "
"pre-updating\n",
freqs->new / 1000, (freqs->new / 100) % 10,
freqs->old / 1000, (freqs->old / 100) % 10);
pxa2xx_pcmcia_update_mcxx(freqs->new);
}
break;
case CPUFREQ_POSTCHANGE:
if (freqs->new < freqs->old) {
debug( 2, "new frequency %u.%uMHz < %u.%uMHz, "
"post-updating\n",
freqs->new / 1000, (freqs->new / 100) % 10,
freqs->old / 1000, (freqs->old / 100) % 10);
pxa2xx_pcmcia_update_mcxx(freqs->new);
}
break;
}
return 0;
}
static struct notifier_block pxa2xx_pcmcia_notifier_block = {
.notifier_call = pxa2xx_pcmcia_notifier
};
static int __init pxa2xx_pcmcia_cpufreq_init(void)
{
int ret;
ret = cpufreq_register_notifier(&pxa2xx_pcmcia_notifier_block,
CPUFREQ_TRANSITION_NOTIFIER);
if (ret < 0)
printk(KERN_ERR "Unable to register CPU frequency change "
"notifier for PCMCIA (%d)\n", ret);
return ret;
}
static void __exit pxa2xx_pcmcia_cpufreq_exit(void)
{
cpufreq_unregister_notifier(&pxa2xx_pcmcia_notifier_block, CPUFREQ_TRANSITION_NOTIFIER);
}
#else
#define pxa2xx_pcmcia_cpufreq_init()
#define pxa2xx_pcmcia_cpufreq_exit()
#endif
static int __init pxa2xx_pcmcia_init(void) static int __init pxa2xx_pcmcia_init(void)
{ {
int ret = driver_register(&pxa2xx_pcmcia_driver); return driver_register(&pxa2xx_pcmcia_driver);
if (ret == 0)
pxa2xx_pcmcia_cpufreq_init();
return ret;
} }
static void __exit pxa2xx_pcmcia_exit(void) static void __exit pxa2xx_pcmcia_exit(void)
{ {
pxa2xx_pcmcia_cpufreq_exit();
driver_unregister(&pxa2xx_pcmcia_driver); driver_unregister(&pxa2xx_pcmcia_driver);
} }
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <linux/cpufreq.h> #include <linux/cpufreq.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/notifier.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/hardware.h> #include <asm/hardware.h>
...@@ -111,6 +110,32 @@ sa1100_pcmcia_set_mecr(struct soc_pcmcia_socket *skt, unsigned int cpu_clock) ...@@ -111,6 +110,32 @@ sa1100_pcmcia_set_mecr(struct soc_pcmcia_socket *skt, unsigned int cpu_clock)
return 0; return 0;
} }
#ifdef CONFIG_CPU_FREQ
static int
sa1100_pcmcia_frequency_change(struct soc_pcmcia_socket *skt,
unsigned long val,
struct cpufreq_freqs *freqs)
{
switch (val) {
case CPUFREQ_PRECHANGE:
if (freqs->new > freqs->old)
sa1100_pcmcia_set_mecr(skt, freqs->new);
break;
case CPUFREQ_POSTCHANGE:
if (freqs->new < freqs->old)
sa1100_pcmcia_set_mecr(skt, freqs->new);
break;
case CPUFREQ_RESUMECHANGE:
sa1100_pcmcia_set_mecr(skt, freqs->new);
break;
}
return 0;
}
#endif
static int static int
sa1100_pcmcia_set_timing(struct soc_pcmcia_socket *skt) sa1100_pcmcia_set_timing(struct soc_pcmcia_socket *skt)
{ {
...@@ -152,90 +177,23 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, ...@@ -152,90 +177,23 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
/* Provide our SA11x0 specific timing routines. */ /* Provide our SA11x0 specific timing routines. */
ops->set_timing = sa1100_pcmcia_set_timing; ops->set_timing = sa1100_pcmcia_set_timing;
ops->show_timing = sa1100_pcmcia_show_timing; ops->show_timing = sa1100_pcmcia_show_timing;
#ifdef CONFIG_CPU_FREQ
ops->frequency_change = sa1100_pcmcia_frequency_change;
#endif
return soc_common_drv_pcmcia_probe(dev, ops, first, nr); return soc_common_drv_pcmcia_probe(dev, ops, first, nr);
} }
EXPORT_SYMBOL(sa11xx_drv_pcmcia_probe); EXPORT_SYMBOL(sa11xx_drv_pcmcia_probe);
#ifdef CONFIG_CPU_FREQ
/* sa1100_pcmcia_update_mecr()
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^
* When sa1100_pcmcia_notifier() decides that a MECR adjustment (due
* to a core clock frequency change) is needed, this routine establishes
* new BS_xx values consistent with the clock speed `clock'.
*/
static void sa1100_pcmcia_update_mecr(unsigned int clock)
{
struct soc_pcmcia_socket *skt;
down(&soc_pcmcia_sockets_lock);
list_for_each_entry(skt, &soc_pcmcia_sockets, node)
sa1100_pcmcia_set_mecr(skt, clock);
up(&soc_pcmcia_sockets_lock);
}
/* sa1100_pcmcia_notifier()
* ^^^^^^^^^^^^^^^^^^^^^^^^
* When changing the processor core clock frequency, it is necessary
* to adjust the MECR timings accordingly. We've recorded the timings
* requested by Card Services, so this is just a matter of finding
* out what our current speed is, and then recomputing the new MECR
* values.
*
* Returns: 0 on success, -1 on error
*/
static int
sa1100_pcmcia_notifier(struct notifier_block *nb, unsigned long val,
void *data)
{
struct cpufreq_freqs *freqs = data;
switch (val) {
case CPUFREQ_PRECHANGE:
if (freqs->new > freqs->old)
sa1100_pcmcia_update_mecr(freqs->new);
break;
case CPUFREQ_POSTCHANGE:
if (freqs->new < freqs->old)
sa1100_pcmcia_update_mecr(freqs->new);
break;
case CPUFREQ_RESUMECHANGE:
sa1100_pcmcia_update_mecr(freqs->new);
break;
}
return 0;
}
static struct notifier_block sa1100_pcmcia_notifier_block = {
.notifier_call = sa1100_pcmcia_notifier
};
static int __init sa11xx_pcmcia_init(void) static int __init sa11xx_pcmcia_init(void)
{ {
int ret; return 0;
printk(KERN_INFO "SA11xx PCMCIA\n");
ret = cpufreq_register_notifier(&sa1100_pcmcia_notifier_block,
CPUFREQ_TRANSITION_NOTIFIER);
if (ret < 0)
printk(KERN_ERR "Unable to register CPU frequency change "
"notifier (%d)\n", ret);
return ret;
} }
module_init(sa11xx_pcmcia_init); module_init(sa11xx_pcmcia_init);
static void __exit sa11xx_pcmcia_exit(void) static void __exit sa11xx_pcmcia_exit(void) {}
{
cpufreq_unregister_notifier(&sa1100_pcmcia_notifier_block, CPUFREQ_TRANSITION_NOTIFIER);
}
module_exit(sa11xx_pcmcia_exit); module_exit(sa11xx_pcmcia_exit);
#endif
MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>"); MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>");
MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11xx core socket driver"); MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11xx core socket driver");
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
======================================================================*/ ======================================================================*/
#include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -39,6 +40,7 @@ ...@@ -39,6 +40,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/cpufreq.h>
#include <asm/hardware.h> #include <asm/hardware.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -614,6 +616,49 @@ struct skt_dev_info { ...@@ -614,6 +616,49 @@ struct skt_dev_info {
#define SKT_DEV_INFO_SIZE(n) \ #define SKT_DEV_INFO_SIZE(n) \
(sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket)) (sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket))
#ifdef CONFIG_CPU_FREQ
static int
soc_pcmcia_notifier(struct notifier_block *nb, unsigned long val, void *data)
{
struct soc_pcmcia_socket *skt;
struct cpufreq_freqs *freqs = data;
int ret = 0;
down(&soc_pcmcia_sockets_lock);
list_for_each_entry(skt, &soc_pcmcia_sockets, node)
if ( skt->ops->frequency_change )
ret += skt->ops->frequency_change(skt, val, freqs);
up(&soc_pcmcia_sockets_lock);
return ret;
}
static struct notifier_block soc_pcmcia_notifier_block = {
.notifier_call = soc_pcmcia_notifier
};
static int soc_pcmcia_cpufreq_register(void)
{
int ret;
ret = cpufreq_register_notifier(&soc_pcmcia_notifier_block,
CPUFREQ_TRANSITION_NOTIFIER);
if (ret < 0)
printk(KERN_ERR "Unable to register CPU frequency change "
"notifier for PCMCIA (%d)\n", ret);
return ret;
}
static void soc_pcmcia_cpufreq_unregister(void)
{
cpufreq_unregister_notifier(&soc_pcmcia_notifier_block, CPUFREQ_TRANSITION_NOTIFIER);
}
#else
#define soc_pcmcia_cpufreq_register()
#define soc_pcmcia_cpufreq_unregister()
#endif
int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr) int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr)
{ {
struct skt_dev_info *sinfo; struct skt_dev_info *sinfo;
...@@ -692,6 +737,9 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops ...@@ -692,6 +737,9 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops
goto out_err_5; goto out_err_5;
} }
if ( list_empty(&soc_pcmcia_sockets) )
soc_pcmcia_cpufreq_register();
list_add(&skt->node, &soc_pcmcia_sockets); list_add(&skt->node, &soc_pcmcia_sockets);
/* /*
...@@ -789,6 +837,9 @@ int soc_common_drv_pcmcia_remove(struct device *dev) ...@@ -789,6 +837,9 @@ int soc_common_drv_pcmcia_remove(struct device *dev)
release_resource(&skt->res_io); release_resource(&skt->res_io);
release_resource(&skt->res_skt); release_resource(&skt->res_skt);
} }
if ( list_empty(&soc_pcmcia_sockets) )
soc_pcmcia_cpufreq_unregister();
up(&soc_pcmcia_sockets_lock); up(&soc_pcmcia_sockets_lock);
kfree(sinfo); kfree(sinfo);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#define _ASM_ARCH_PCMCIA #define _ASM_ARCH_PCMCIA
/* include the world */ /* include the world */
#include <linux/cpufreq.h>
#include <pcmcia/version.h> #include <pcmcia/version.h>
#include <pcmcia/cs_types.h> #include <pcmcia/cs_types.h>
#include <pcmcia/cs.h> #include <pcmcia/cs.h>
...@@ -103,6 +104,13 @@ struct pcmcia_low_level { ...@@ -103,6 +104,13 @@ struct pcmcia_low_level {
unsigned int (*get_timing)(struct soc_pcmcia_socket *, unsigned int, unsigned int); unsigned int (*get_timing)(struct soc_pcmcia_socket *, unsigned int, unsigned int);
int (*set_timing)(struct soc_pcmcia_socket *); int (*set_timing)(struct soc_pcmcia_socket *);
int (*show_timing)(struct soc_pcmcia_socket *, char *); int (*show_timing)(struct soc_pcmcia_socket *, char *);
#ifdef CONFIG_CPU_FREQ
/*
* CPUFREQ support.
*/
int (*frequency_change)(struct soc_pcmcia_socket *, unsigned long, struct cpufreq_freqs *);
#endif
}; };
......
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