fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / i386 / kernel / cpu / cpufreq / powernow-k7.c
index 913f652..5438276 100644 (file)
@@ -12,7 +12,6 @@
  * - We disable half multipliers if ACPI is used on A0 stepping CPUs.
  */
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -23,6 +22,7 @@
 #include <linux/dmi.h>
 
 #include <asm/msr.h>
+#include <asm/timer.h>
 #include <asm/timex.h>
 #include <asm/io.h>
 #include <asm/system.h>
@@ -170,10 +170,9 @@ static int get_ranges (unsigned char *pst)
        unsigned int speed;
        u8 fid, vid;
 
-       powernow_table = kmalloc((sizeof(struct cpufreq_frequency_table) * (number_scales + 1)), GFP_KERNEL);
+       powernow_table = kzalloc((sizeof(struct cpufreq_frequency_table) * (number_scales + 1)), GFP_KERNEL);
        if (!powernow_table)
                return -ENOMEM;
-       memset(powernow_table, 0, (sizeof(struct cpufreq_frequency_table) * (number_scales + 1)));
 
        for (j=0 ; j < number_scales; j++) {
                fid = *pst++;
@@ -199,8 +198,8 @@ static int get_ranges (unsigned char *pst)
                powernow_table[j].index |= (vid << 8); /* upper 8 bits */
 
                dprintk ("   FID: 0x%x (%d.%dx [%dMHz])  "
-                        "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10, 
-                        fid_codes[fid] % 10, speed/1000, vid,  
+                        "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10,
+                        fid_codes[fid] % 10, speed/1000, vid,
                         mobile_vid_table[vid]/1000,
                         mobile_vid_table[vid]%1000);
        }
@@ -304,16 +303,13 @@ static int powernow_acpi_init(void)
                goto err0;
        }
 
-       acpi_processor_perf = kmalloc(sizeof(struct acpi_processor_performance),
+       acpi_processor_perf = kzalloc(sizeof(struct acpi_processor_performance),
                                      GFP_KERNEL);
-
        if (!acpi_processor_perf) {
                retval = -ENOMEM;
                goto err0;
        }
 
-       memset(acpi_processor_perf, 0, sizeof(struct acpi_processor_performance));
-
        if (acpi_processor_register_performance(acpi_processor_perf, 0)) {
                retval = -EIO;
                goto err1;
@@ -336,14 +332,12 @@ static int powernow_acpi_init(void)
                goto err2;
        }
 
-       powernow_table = kmalloc((number_scales + 1) * (sizeof(struct cpufreq_frequency_table)), GFP_KERNEL);
+       powernow_table = kzalloc((number_scales + 1) * (sizeof(struct cpufreq_frequency_table)), GFP_KERNEL);
        if (!powernow_table) {
                retval = -ENOMEM;
                goto err2;
        }
 
-       memset(powernow_table, 0, ((number_scales + 1) * sizeof(struct cpufreq_frequency_table)));
-
        pc.val = (unsigned long) acpi_processor_perf->states[0].control;
        for (i = 0; i < number_scales; i++) {
                u8 fid, vid;
@@ -373,8 +367,8 @@ static int powernow_acpi_init(void)
                }
 
                dprintk ("   FID: 0x%x (%d.%dx [%dMHz])  "
-                        "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10, 
-                        fid_codes[fid] % 10, speed/1000, vid,  
+                        "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10,
+                        fid_codes[fid] % 10, speed/1000, vid,
                         mobile_vid_table[vid]/1000,
                         mobile_vid_table[vid]%1000);
 
@@ -457,23 +451,23 @@ static int powernow_decode_bios (int maxfid, int startvid)
 
                        pst = (struct pst_s *) p;
 
-                       for (i = 0 ; i <psb->numpst; i++) {
+                       for (j=0; j<psb->numpst; j++) {
                                pst = (struct pst_s *) p;
                                number_scales = pst->numpstates;
 
                                if ((etuple == pst->cpuid) && check_fsb(pst->fsbspeed) &&
                                    (maxfid==pst->maxfid) && (startvid==pst->startvid))
                                {
-                                       dprintk ("PST:%d (@%p)\n", i, pst);
-                                       dprintk (" cpuid: 0x%x  fsb: %d  maxFID: 0x%x  startvid: 0x%x\n", 
+                                       dprintk ("PST:%d (@%p)\n", j, pst);
+                                       dprintk (" cpuid: 0x%x  fsb: %d  maxFID: 0x%x  startvid: 0x%x\n",
                                                 pst->cpuid, pst->fsbspeed, pst->maxfid, pst->startvid);
 
                                        ret = get_ranges ((char *) pst + sizeof (struct pst_s));
                                        return ret;
-
                                } else {
+                                       unsigned int k;
                                        p = (char *) pst + sizeof (struct pst_s);
-                                       for (j=0 ; j < number_scales; j++)
+                                       for (k=0; k<number_scales; k++)
                                                p+=2;
                                }
                        }
@@ -586,13 +580,14 @@ static int __init powernow_cpu_init (struct cpufreq_policy *policy)
 
        rdmsrl (MSR_K7_FID_VID_STATUS, fidvidstatus.val);
 
-       /* A K7 with powernow technology is set to max frequency by BIOS */
-       fsb = (10 * cpu_khz) / fid_codes[fidvidstatus.bits.MFID];
+       recalibrate_cpu_khz();
+
+       fsb = (10 * cpu_khz) / fid_codes[fidvidstatus.bits.CFID];
        if (!fsb) {
                printk(KERN_WARNING PFX "can not determine bus frequency\n");
                return -EINVAL;
        }
-       dprintk("FSB: %3d.%03d MHz\n", fsb/1000, fsb%1000);
+       dprintk("FSB: %3dMHz\n", fsb/1000);
 
        if (dmi_check_system(powernow_dmi_table) || acpi_force) {
                printk (KERN_INFO PFX "PSB/PST known to be broken.  Trying ACPI instead\n");
@@ -643,9 +638,7 @@ static int powernow_cpu_exit (struct cpufreq_policy *policy) {
        }
 #endif
 
-       if (powernow_table)
-               kfree(powernow_table);
-
+       kfree(powernow_table);
        return 0;
 }