From: Ducrot Bruno Subject: cpufreq/linux/arch/i386/kernel/cpufreq longhaul.c, 1.93.2.4, 1.93.2.5 Date: Mon, 01 Mar 2004 15:11:28 +0000 Sender: cpufreq-bounces@www.linux.org.uk Message-ID: Return-path: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: cpufreq-bounces+glkc-cpufreq=gmane.org@www.linux.org.uk MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: cpufreq@www.linux.org.uk Update of /mnt/src/cvsroot/cpufreq/linux/arch/i386/kernel/cpufreq In directory flint:/tmp/cvs-serv30352 Modified Files: Tag: LINUX_2_4 longhaul.c Log Message: update to latest longhaul driver from cpufreq bk tree. Index: longhaul.c =================================================================== RCS file: /mnt/src/cvsroot/cpufreq/linux/arch/i386/kernel/cpufreq/longhaul.c,v retrieving revision 1.93.2.4 retrieving revision 1.93.2.5 diff -u -r1.93.2.4 -r1.93.2.5 --- longhaul.c 9 Dec 2003 09:07:30 -0000 1.93.2.4 +++ longhaul.c 1 Mar 2004 15:11:25 -0000 1.93.2.5 @@ -1,5 +1,5 @@ /* - * (C) 2001-2003 Dave Jones. + * (C) 2001-2004 Dave Jones. * (C) 2002 Padraig Brady. * * Licensed under the terms of the GNU GPL License version 2. @@ -63,11 +63,12 @@ static unsigned int calc_speed (int mult, int fsb) { - int mhz; - mhz = (mult/10)*fsb; + int khz; + khz = (mult/10)*fsb; if (mult%10) - mhz += fsb/2; - return mhz; + khz += fsb/2; + khz *= 1000; + return khz; } @@ -185,6 +186,7 @@ return target; } + static int guess_fsb(int maxmult) { int speed = (cpu_khz/1000); @@ -202,7 +204,6 @@ } - static int __init longhaul_get_ranges (void) { struct cpuinfo_x86 *c = cpu_data; @@ -233,6 +234,8 @@ case 2: rdmsrl (MSR_VIA_LONGHAUL, longhaul.val); + //TODO: Nehemiah may have borken MaxMHzBR. + // need to extrapolate from FSB. invalue = longhaul.bits.MaxMHzBR; if (longhaul.bits.MaxMHzBR4) invalue += 16; @@ -244,7 +247,16 @@ else minmult = multipliers[invalue]; - fsb = guess_fsb(maxmult); + switch (longhaul.bits.MaxMHzFSB) { + case 0x0: fsb=133; + break; + case 0x1: fsb=100; + break; + case 0x2: printk (KERN_INFO PFX "Invalid (reserved) FSB!\n"); + return -EINVAL; + case 0x3: fsb=66; + break; + } break; } @@ -253,7 +265,17 @@ highest_speed = calc_speed (maxmult, fsb); lowest_speed = calc_speed (minmult,fsb); dprintk (KERN_INFO PFX "FSB: %dMHz Lowestspeed=%dMHz Highestspeed=%dMHz\n", - fsb, lowest_speed, highest_speed); + fsb, lowest_speed/1000, highest_speed/1000); + + if (lowest_speed == highest_speed) { + printk (KERN_INFO PFX "highestspeed == lowest, aborting.\n"); + return -EINVAL; + } + if (lowest_speed > highest_speed) { + printk (KERN_INFO PFX "nonsense! lowest (%d > %d) !\n", + lowest_speed, highest_speed); + return -EINVAL; + } longhaul_table = kmalloc((numscales + 1) * sizeof(struct cpufreq_frequency_table), GFP_KERNEL); if(!longhaul_table) @@ -267,7 +289,7 @@ if (ratio > maxmult || ratio < minmult) continue; longhaul_table[k].frequency = calc_speed (ratio, fsb); - longhaul_table[k].index = (j << 8); + longhaul_table[k].index = j; k++; } @@ -416,12 +438,12 @@ printk (KERN_INFO PFX "VIA %s CPU detected. Longhaul v%d supported.\n", cpuname, longhaul_version); - if ((longhaul_version==2) && (dont_scale_voltage==0)) - longhaul_setup_voltagescaling(); - ret = longhaul_get_ranges(); if (ret != 0) return ret; + + if ((longhaul_version==2) && (dont_scale_voltage==0)) + longhaul_setup_voltagescaling(); policy->policy = CPUFREQ_POLICY_PERFORMANCE; policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;