Commit f087515c authored by Jordan Crouse's avatar Jordan Crouse Committed by Thomas Gleixner

x86: GEODE: MFGPT: Use "just-in-time" detection for the MFGPT timers

There isn't much value to always detecting the MFGPT timers on
Geode platforms; detection is only needed when something wants
to use the timers.  Move the detection code so that it gets
called the first time a timer is allocated.
Signed-off-by: default avatarJordan Crouse <jordan.crouse@amd.com>
Signed-off-by: default avatarAndres Salomon <dilinger@debian.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent b0e6bf25
...@@ -163,14 +163,11 @@ EXPORT_SYMBOL_GPL(geode_gpio_setup_event); ...@@ -163,14 +163,11 @@ EXPORT_SYMBOL_GPL(geode_gpio_setup_event);
static int __init geode_southbridge_init(void) static int __init geode_southbridge_init(void)
{ {
int timers;
if (!is_geode()) if (!is_geode())
return -ENODEV; return -ENODEV;
init_lbars(); init_lbars();
timers = geode_mfgpt_detect(); (void) mfgpt_timer_setup();
printk(KERN_INFO "geode: %d MFGPT timers available.\n", timers);
return 0; return 0;
} }
......
...@@ -74,28 +74,37 @@ __setup("mfgptfix", mfgpt_fix); ...@@ -74,28 +74,37 @@ __setup("mfgptfix", mfgpt_fix);
* In other cases (such as with VSAless OpenFirmware), the system firmware * In other cases (such as with VSAless OpenFirmware), the system firmware
* leaves timers available for us to use. * leaves timers available for us to use.
*/ */
int __init geode_mfgpt_detect(void)
static int timers = -1;
static void geode_mfgpt_detect(void)
{ {
int count = 0, i; int i;
u16 val; u16 val;
timers = 0;
if (disable) { if (disable) {
printk(KERN_INFO "geode-mfgpt: Skipping MFGPT setup\n"); printk(KERN_INFO "geode-mfgpt: MFGPT support is disabled\n");
return 0; goto done;
}
if (!geode_get_dev_base(GEODE_DEV_MFGPT)) {
printk(KERN_INFO "geode-mfgpt: MFGPT LBAR is not set up\n");
goto done;
} }
for (i = 0; i < MFGPT_MAX_TIMERS; i++) { for (i = 0; i < MFGPT_MAX_TIMERS; i++) {
val = geode_mfgpt_read(i, MFGPT_REG_SETUP); val = geode_mfgpt_read(i, MFGPT_REG_SETUP);
if (!(val & MFGPT_SETUP_SETUP)) { if (!(val & MFGPT_SETUP_SETUP)) {
mfgpt_timers[i].avail = 1; mfgpt_timers[i].avail = 1;
count++; timers++;
} }
} }
/* set up clock event device, if desired */ done:
i = mfgpt_timer_setup(); printk(KERN_INFO "geode-mfgpt: %d MFGPT timers available.\n", timers);
return count;
} }
int geode_mfgpt_toggle_event(int timer, int cmp, int event, int enable) int geode_mfgpt_toggle_event(int timer, int cmp, int event, int enable)
...@@ -183,10 +192,16 @@ int geode_mfgpt_alloc_timer(int timer, int domain) ...@@ -183,10 +192,16 @@ int geode_mfgpt_alloc_timer(int timer, int domain)
{ {
int i; int i;
if (!geode_get_dev_base(GEODE_DEV_MFGPT)) if (timers == -1) {
return -ENODEV; /* timers haven't been detected yet */
geode_mfgpt_detect();
}
if (!timers)
return -1;
if (timer >= MFGPT_MAX_TIMERS) if (timer >= MFGPT_MAX_TIMERS)
return -EIO; return -1;
if (timer < 0) { if (timer < 0) {
/* Try to find an available timer */ /* Try to find an available timer */
......
...@@ -206,7 +206,6 @@ static inline u16 geode_mfgpt_read(int timer, u16 reg) ...@@ -206,7 +206,6 @@ static inline u16 geode_mfgpt_read(int timer, u16 reg)
return inw(base + reg + (timer * 8)); return inw(base + reg + (timer * 8));
} }
extern int __init geode_mfgpt_detect(void);
extern int geode_mfgpt_toggle_event(int timer, int cmp, int event, int enable); extern int geode_mfgpt_toggle_event(int timer, int cmp, int event, int enable);
extern int geode_mfgpt_set_irq(int timer, int cmp, int irq, int enable); extern int geode_mfgpt_set_irq(int timer, int cmp, int irq, int enable);
extern int geode_mfgpt_alloc_timer(int timer, int domain); extern int geode_mfgpt_alloc_timer(int timer, int domain);
......
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