diff -urNp x-ref/Documentation/Configure.help x/Documentation/Configure.help --- x-ref/Documentation/Configure.help Mon Sep 30 03:47:30 2002 +++ x/Documentation/Configure.help Mon Sep 30 03:47:32 2002 @@ -252,6 +252,14 @@ CONFIG_X86_NUMAQ You will need a new lynxer.elf file to flash your firmware with - send email to Martin.Bligh@us.ibm.com +IBM x440 Summit support +CONFIG_X86_CYCLONE + This option enables support for the IBM x440 and related multi-CEC + systems based on the Summit chipset. This options allows you to pass + "cyclone" as a boot option to make use of a performance counter on + the Cyclone chipset for calculating do_gettimeofday, greatly + improving performance when compared to the PIT based method. + IO-APIC support on uniprocessors CONFIG_X86_UP_IOAPIC An IO-APIC (I/O Advanced Programmable Interrupt Controller) is an diff -urNp x-ref/arch/i386/config.in x/arch/i386/config.in --- x-ref/arch/i386/config.in Mon Sep 30 03:47:31 2002 +++ x/arch/i386/config.in Mon Sep 30 03:47:32 2002 @@ -241,8 +241,9 @@ else fi fi +bool 'IBM x440 Gettimeofday Cyclone Timer support' CONFIG_X86_CYCLONE bool 'Unsynced TSC support' CONFIG_X86_TSC_DISABLE -if [ "$CONFIG_X86_TSC_DISABLE" != "y" -a "$CONFIG_X86_HAS_TSC" = "y" ]; then +if [ "$CONFIG_X86_TSC_DISABLE" != "y" -a "$CONFIG_X86_HAS_TSC" = "y" -a "$CONFIG_X86_CYCLONE" != "y" ]; then define_bool CONFIG_X86_TSC y fi diff -urNp x-ref/arch/i386/kernel/setup.c x/arch/i386/kernel/setup.c --- x-ref/arch/i386/kernel/setup.c Mon Sep 30 03:47:30 2002 +++ x/arch/i386/kernel/setup.c Mon Sep 30 03:47:32 2002 @@ -1173,7 +1173,7 @@ __setup("cachesize=", cachesize_setup); #ifndef CONFIG_X86_TSC -static int tsc_disable __initdata = 0; +int tsc_disable __initdata = 0; static int __init notsc_setup(char *str) { diff -urNp x-ref/arch/i386/kernel/time.c x/arch/i386/kernel/time.c --- x-ref/arch/i386/kernel/time.c Thu Sep 26 04:13:59 2002 +++ x/arch/i386/kernel/time.c Mon Sep 30 03:47:45 2002 @@ -121,6 +121,138 @@ EXPORT_SYMBOL(i8253_lock); extern spinlock_t i8259A_lock; +#ifdef CONFIG_X86_CYCLONE + +#define CYCLONE_CBAR_ADDR 0xFEB00CD0 +#define CYCLONE_PMCC_OFFSET 0x51A0 +#define CYCLONE_MPMC_OFFSET 0x51D0 +#define CYCLONE_MPCS_OFFSET 0x51A8 +#define CYCLONE_TIMER_FREQ 100000000 + +static int use_cyclone __initdata = 0; +extern int tsc_disable; +/*XXX - should autodetect*/ +static int __init cyclone_setup(char *str) +{ + tsc_disable = 1; + use_cyclone = 1; + return 1; +} +__setup("cyclone", cyclone_setup); + + +static u32* cyclone_timer; /*Cyclone MPMC0 register*/ +static u32 last_cyclone_timer; + +static inline void mark_timeoffset_cyclone(void) +{ + int count; + + /*quickly read the cyclone timer*/ + if(cyclone_timer) + last_cyclone_timer = cyclone_timer[0]; + + /*calculate delay_at_last_interrupt*/ + spin_lock(&i8253_lock); + outb_p(0x00, 0x43); /* latch the count ASAP */ + + count = inb_p(0x40); /* read the latched count */ + count |= inb(0x40) << 8; + spin_unlock(&i8253_lock); + + count = ((LATCH-1) - count) * TICK_SIZE; + delay_at_last_interrupt = (count + LATCH/2) / LATCH; +} + +static unsigned long do_gettimeoffset_cyclone(void) +{ + u32 offset; + + if(!cyclone_timer) + return delay_at_last_interrupt; + + /* Read the cyclone timer */ + offset = cyclone_timer[0]; + + /* .. relative to previous jiffy*/ + offset = offset - last_cyclone_timer; + + /*convert cyclone ticks to microseconds*/ + offset = offset/100; /*XXX slow, can we speed this up?*/ + + /* our adjusted time offset in microseconds */ + return delay_at_last_interrupt + offset; +} + +static void init_cyclone_clock(void) +{ + u32* reg; + u32 base; /*saved cyclone base address*/ + u32 pageaddr; /*page that contains cyclone_timer register*/ + u32 offset; /*offset from pageaddr to cyclone_timer register*/ + + printk(KERN_INFO "Summit chipset: Starting Cyclone Clock.\n"); + + /*find base address*/ + pageaddr = (CYCLONE_CBAR_ADDR)&PAGE_MASK; + offset = (CYCLONE_CBAR_ADDR)&(~PAGE_MASK); + set_fixmap_nocache(FIX_CYCLONE_TIMER, pageaddr); + reg = (u32*)(fix_to_virt(FIX_CYCLONE_TIMER) + offset); + if(!reg){ + printk(KERN_ERR "Summit chipset: Could not find valid CBAR register.\n"); + return; + } + base = *reg; + if(!base){ + printk(KERN_ERR "Summit chipset: Could not find valid CBAR value.\n"); + return; + } + + /*setup PMCC*/ + pageaddr = (base + CYCLONE_PMCC_OFFSET)&PAGE_MASK; + offset = (base + CYCLONE_PMCC_OFFSET)&(~PAGE_MASK); + set_fixmap_nocache(FIX_CYCLONE_TIMER, pageaddr); + reg = (u32*)(fix_to_virt(FIX_CYCLONE_TIMER) + offset); + if(!reg){ + printk(KERN_ERR "Summit chipset: Could not find valid PMCC register.\n"); + return; + } + reg[0] = 0x00000001; + + /*setup MPCS*/ + pageaddr = (base + CYCLONE_MPCS_OFFSET)&PAGE_MASK; + offset = (base + CYCLONE_MPCS_OFFSET)&(~PAGE_MASK); + set_fixmap_nocache(FIX_CYCLONE_TIMER, pageaddr); + reg = (u32*)(fix_to_virt(FIX_CYCLONE_TIMER) + offset); + if(!reg){ + printk(KERN_ERR "Summit chipset: Could not find valid MPCS register.\n"); + return; + } + reg[0] = 0x00000001; + + /*map in cyclone_timer*/ + pageaddr = (base + CYCLONE_MPMC_OFFSET)&PAGE_MASK; + offset = (base + CYCLONE_MPMC_OFFSET)&(~PAGE_MASK); + set_fixmap_nocache(FIX_CYCLONE_TIMER, pageaddr); + cyclone_timer = (u32*)(fix_to_virt(FIX_CYCLONE_TIMER) + offset); + if(!cyclone_timer){ + printk(KERN_ERR "Summit chipset: Could not find valid MPMC register.\n"); + return; + } + + /* Everything looks good, so set do_gettimeoffset*/ + do_gettimeoffset = do_gettimeoffset_cyclone; +} + +#else /*CONFIG_X86_CYCLONE*/ + +#define use_cyclone 0 +static void mark_timeoffset_cyclone(void) {} +static unsigned long do_gettimeoffset_cyclone(void) {return 0;} +static void init_cyclone_clock(void) {} + +#endif /*CONFIG_X86_CYCLONE*/ + #ifndef CONFIG_X86_TSC /* This function must be called with interrupts disabled @@ -508,7 +640,8 @@ static void timer_interrupt(int irq, voi count = ((LATCH-1) - count) * TICK_SIZE; delay_at_last_interrupt = (count + LATCH/2) / LATCH; - } + } else if (use_cyclone) + mark_timeoffset_cyclone(); do_timer_interrupt(irq, NULL, regs); @@ -699,6 +832,9 @@ void __init time_init(void) } } + if((!use_tsc) && use_cyclone) + init_cyclone_clock(); + #ifdef CONFIG_VISWS printk("Starting Cobalt Timer system clock\n"); diff -urNp x-ref/include/asm-i386/fixmap.h x/include/asm-i386/fixmap.h --- x-ref/include/asm-i386/fixmap.h Mon Sep 30 03:47:21 2002 +++ x/include/asm-i386/fixmap.h Mon Sep 30 03:47:32 2002 @@ -64,6 +64,9 @@ enum fixed_addresses { #ifndef CONFIG_X86_F00F_WORKS_OK FIX_F00F, #endif +#ifdef CONFIG_X86_CYCLONE + FIX_CYCLONE_TIMER, /*cyclone timer register*/ +#endif #ifdef CONFIG_HIGHMEM FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,