powernow-k7.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. /*
  2. * AMD K7 Powernow driver.
  3. * (C) 2003 Dave Jones on behalf of SuSE Labs.
  4. * (C) 2003-2004 Dave Jones <davej@redhat.com>
  5. *
  6. * Licensed under the terms of the GNU GPL License version 2.
  7. * Based upon datasheets & sample CPUs kindly provided by AMD.
  8. *
  9. * Errata 5: Processor may fail to execute a FID/VID change in presence of interrupt.
  10. * - We cli/sti on stepping A0 CPUs around the FID/VID transition.
  11. * Errata 15: Processors with half frequency multipliers may hang upon wakeup from disconnect.
  12. * - We disable half multipliers if ACPI is used on A0 stepping CPUs.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/moduleparam.h>
  17. #include <linux/init.h>
  18. #include <linux/cpufreq.h>
  19. #include <linux/slab.h>
  20. #include <linux/string.h>
  21. #include <linux/dmi.h>
  22. #include <asm/msr.h>
  23. #include <asm/timer.h>
  24. #include <asm/timex.h>
  25. #include <asm/io.h>
  26. #include <asm/system.h>
  27. #ifdef CONFIG_X86_POWERNOW_K7_ACPI
  28. #include <linux/acpi.h>
  29. #include <acpi/processor.h>
  30. #endif
  31. #include "powernow-k7.h"
  32. #define PFX "powernow: "
  33. struct psb_s {
  34. u8 signature[10];
  35. u8 tableversion;
  36. u8 flags;
  37. u16 settlingtime;
  38. u8 reserved1;
  39. u8 numpst;
  40. };
  41. struct pst_s {
  42. u32 cpuid;
  43. u8 fsbspeed;
  44. u8 maxfid;
  45. u8 startvid;
  46. u8 numpstates;
  47. };
  48. #ifdef CONFIG_X86_POWERNOW_K7_ACPI
  49. union powernow_acpi_control_t {
  50. struct {
  51. unsigned long fid:5,
  52. vid:5,
  53. sgtc:20,
  54. res1:2;
  55. } bits;
  56. unsigned long val;
  57. };
  58. #endif
  59. #ifdef CONFIG_CPU_FREQ_DEBUG
  60. /* divide by 1000 to get VCore voltage in V. */
  61. static const int mobile_vid_table[32] = {
  62. 2000, 1950, 1900, 1850, 1800, 1750, 1700, 1650,
  63. 1600, 1550, 1500, 1450, 1400, 1350, 1300, 0,
  64. 1275, 1250, 1225, 1200, 1175, 1150, 1125, 1100,
  65. 1075, 1050, 1025, 1000, 975, 950, 925, 0,
  66. };
  67. #endif
  68. /* divide by 10 to get FID. */
  69. static const int fid_codes[32] = {
  70. 110, 115, 120, 125, 50, 55, 60, 65,
  71. 70, 75, 80, 85, 90, 95, 100, 105,
  72. 30, 190, 40, 200, 130, 135, 140, 210,
  73. 150, 225, 160, 165, 170, 180, -1, -1,
  74. };
  75. /* This parameter is used in order to force ACPI instead of legacy method for
  76. * configuration purpose.
  77. */
  78. static int acpi_force;
  79. static struct cpufreq_frequency_table *powernow_table;
  80. static unsigned int can_scale_bus;
  81. static unsigned int can_scale_vid;
  82. static unsigned int minimum_speed=-1;
  83. static unsigned int maximum_speed;
  84. static unsigned int number_scales;
  85. static unsigned int fsb;
  86. static unsigned int latency;
  87. static char have_a0;
  88. #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "powernow-k7", msg)
  89. static int check_fsb(unsigned int fsbspeed)
  90. {
  91. int delta;
  92. unsigned int f = fsb / 1000;
  93. delta = (fsbspeed > f) ? fsbspeed - f : f - fsbspeed;
  94. return (delta < 5);
  95. }
  96. static int check_powernow(void)
  97. {
  98. struct cpuinfo_x86 *c = &cpu_data(0);
  99. unsigned int maxei, eax, ebx, ecx, edx;
  100. if ((c->x86_vendor != X86_VENDOR_AMD) || (c->x86 !=6)) {
  101. #ifdef MODULE
  102. printk (KERN_INFO PFX "This module only works with AMD K7 CPUs\n");
  103. #endif
  104. return 0;
  105. }
  106. /* Get maximum capabilities */
  107. maxei = cpuid_eax (0x80000000);
  108. if (maxei < 0x80000007) { /* Any powernow info ? */
  109. #ifdef MODULE
  110. printk (KERN_INFO PFX "No powernow capabilities detected\n");
  111. #endif
  112. return 0;
  113. }
  114. if ((c->x86_model == 6) && (c->x86_mask == 0)) {
  115. printk (KERN_INFO PFX "K7 660[A0] core detected, enabling errata workarounds\n");
  116. have_a0 = 1;
  117. }
  118. cpuid(0x80000007, &eax, &ebx, &ecx, &edx);
  119. /* Check we can actually do something before we say anything.*/
  120. if (!(edx & (1 << 1 | 1 << 2)))
  121. return 0;
  122. printk (KERN_INFO PFX "PowerNOW! Technology present. Can scale: ");
  123. if (edx & 1 << 1) {
  124. printk ("frequency");
  125. can_scale_bus=1;
  126. }
  127. if ((edx & (1 << 1 | 1 << 2)) == 0x6)
  128. printk (" and ");
  129. if (edx & 1 << 2) {
  130. printk ("voltage");
  131. can_scale_vid=1;
  132. }
  133. printk (".\n");
  134. return 1;
  135. }
  136. static int get_ranges (unsigned char *pst)
  137. {
  138. unsigned int j;
  139. unsigned int speed;
  140. u8 fid, vid;
  141. powernow_table = kzalloc((sizeof(struct cpufreq_frequency_table) * (number_scales + 1)), GFP_KERNEL);
  142. if (!powernow_table)
  143. return -ENOMEM;
  144. for (j=0 ; j < number_scales; j++) {
  145. fid = *pst++;
  146. powernow_table[j].frequency = (fsb * fid_codes[fid]) / 10;
  147. powernow_table[j].index = fid; /* lower 8 bits */
  148. speed = powernow_table[j].frequency;
  149. if ((fid_codes[fid] % 10)==5) {
  150. #ifdef CONFIG_X86_POWERNOW_K7_ACPI
  151. if (have_a0 == 1)
  152. powernow_table[j].frequency = CPUFREQ_ENTRY_INVALID;
  153. #endif
  154. }
  155. if (speed < minimum_speed)
  156. minimum_speed = speed;
  157. if (speed > maximum_speed)
  158. maximum_speed = speed;
  159. vid = *pst++;
  160. powernow_table[j].index |= (vid << 8); /* upper 8 bits */
  161. dprintk (" FID: 0x%x (%d.%dx [%dMHz]) "
  162. "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10,
  163. fid_codes[fid] % 10, speed/1000, vid,
  164. mobile_vid_table[vid]/1000,
  165. mobile_vid_table[vid]%1000);
  166. }
  167. powernow_table[number_scales].frequency = CPUFREQ_TABLE_END;
  168. powernow_table[number_scales].index = 0;
  169. return 0;
  170. }
  171. static void change_FID(int fid)
  172. {
  173. union msr_fidvidctl fidvidctl;
  174. rdmsrl (MSR_K7_FID_VID_CTL, fidvidctl.val);
  175. if (fidvidctl.bits.FID != fid) {
  176. fidvidctl.bits.SGTC = latency;
  177. fidvidctl.bits.FID = fid;
  178. fidvidctl.bits.VIDC = 0;
  179. fidvidctl.bits.FIDC = 1;
  180. wrmsrl (MSR_K7_FID_VID_CTL, fidvidctl.val);
  181. }
  182. }
  183. static void change_VID(int vid)
  184. {
  185. union msr_fidvidctl fidvidctl;
  186. rdmsrl (MSR_K7_FID_VID_CTL, fidvidctl.val);
  187. if (fidvidctl.bits.VID != vid) {
  188. fidvidctl.bits.SGTC = latency;
  189. fidvidctl.bits.VID = vid;
  190. fidvidctl.bits.FIDC = 0;
  191. fidvidctl.bits.VIDC = 1;
  192. wrmsrl (MSR_K7_FID_VID_CTL, fidvidctl.val);
  193. }
  194. }
  195. static void change_speed (unsigned int index)
  196. {
  197. u8 fid, vid;
  198. struct cpufreq_freqs freqs;
  199. union msr_fidvidstatus fidvidstatus;
  200. int cfid;
  201. /* fid are the lower 8 bits of the index we stored into
  202. * the cpufreq frequency table in powernow_decode_bios,
  203. * vid are the upper 8 bits.
  204. */
  205. fid = powernow_table[index].index & 0xFF;
  206. vid = (powernow_table[index].index & 0xFF00) >> 8;
  207. freqs.cpu = 0;
  208. rdmsrl (MSR_K7_FID_VID_STATUS, fidvidstatus.val);
  209. cfid = fidvidstatus.bits.CFID;
  210. freqs.old = fsb * fid_codes[cfid] / 10;
  211. freqs.new = powernow_table[index].frequency;
  212. cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
  213. /* Now do the magic poking into the MSRs. */
  214. if (have_a0 == 1) /* A0 errata 5 */
  215. local_irq_disable();
  216. if (freqs.old > freqs.new) {
  217. /* Going down, so change FID first */
  218. change_FID(fid);
  219. change_VID(vid);
  220. } else {
  221. /* Going up, so change VID first */
  222. change_VID(vid);
  223. change_FID(fid);
  224. }
  225. if (have_a0 == 1)
  226. local_irq_enable();
  227. cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
  228. }
  229. #ifdef CONFIG_X86_POWERNOW_K7_ACPI
  230. static struct acpi_processor_performance *acpi_processor_perf;
  231. static int powernow_acpi_init(void)
  232. {
  233. int i;
  234. int retval = 0;
  235. union powernow_acpi_control_t pc;
  236. if (acpi_processor_perf != NULL && powernow_table != NULL) {
  237. retval = -EINVAL;
  238. goto err0;
  239. }
  240. acpi_processor_perf = kzalloc(sizeof(struct acpi_processor_performance),
  241. GFP_KERNEL);
  242. if (!acpi_processor_perf) {
  243. retval = -ENOMEM;
  244. goto err0;
  245. }
  246. if (!alloc_cpumask_var(&acpi_processor_perf->shared_cpu_map,
  247. GFP_KERNEL)) {
  248. retval = -ENOMEM;
  249. goto err05;
  250. }
  251. if (acpi_processor_register_performance(acpi_processor_perf, 0)) {
  252. retval = -EIO;
  253. goto err1;
  254. }
  255. if (acpi_processor_perf->control_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) {
  256. retval = -ENODEV;
  257. goto err2;
  258. }
  259. if (acpi_processor_perf->status_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) {
  260. retval = -ENODEV;
  261. goto err2;
  262. }
  263. number_scales = acpi_processor_perf->state_count;
  264. if (number_scales < 2) {
  265. retval = -ENODEV;
  266. goto err2;
  267. }
  268. powernow_table = kzalloc((number_scales + 1) * (sizeof(struct cpufreq_frequency_table)), GFP_KERNEL);
  269. if (!powernow_table) {
  270. retval = -ENOMEM;
  271. goto err2;
  272. }
  273. pc.val = (unsigned long) acpi_processor_perf->states[0].control;
  274. for (i = 0; i < number_scales; i++) {
  275. u8 fid, vid;
  276. struct acpi_processor_px *state =
  277. &acpi_processor_perf->states[i];
  278. unsigned int speed, speed_mhz;
  279. pc.val = (unsigned long) state->control;
  280. dprintk ("acpi: P%d: %d MHz %d mW %d uS control %08x SGTC %d\n",
  281. i,
  282. (u32) state->core_frequency,
  283. (u32) state->power,
  284. (u32) state->transition_latency,
  285. (u32) state->control,
  286. pc.bits.sgtc);
  287. vid = pc.bits.vid;
  288. fid = pc.bits.fid;
  289. powernow_table[i].frequency = fsb * fid_codes[fid] / 10;
  290. powernow_table[i].index = fid; /* lower 8 bits */
  291. powernow_table[i].index |= (vid << 8); /* upper 8 bits */
  292. speed = powernow_table[i].frequency;
  293. speed_mhz = speed / 1000;
  294. /* processor_perflib will multiply the MHz value by 1000 to
  295. * get a KHz value (e.g. 1266000). However, powernow-k7 works
  296. * with true KHz values (e.g. 1266768). To ensure that all
  297. * powernow frequencies are available, we must ensure that
  298. * ACPI doesn't restrict them, so we round up the MHz value
  299. * to ensure that perflib's computed KHz value is greater than
  300. * or equal to powernow's KHz value.
  301. */
  302. if (speed % 1000 > 0)
  303. speed_mhz++;
  304. if ((fid_codes[fid] % 10)==5) {
  305. if (have_a0 == 1)
  306. powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID;
  307. }
  308. dprintk (" FID: 0x%x (%d.%dx [%dMHz]) "
  309. "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10,
  310. fid_codes[fid] % 10, speed_mhz, vid,
  311. mobile_vid_table[vid]/1000,
  312. mobile_vid_table[vid]%1000);
  313. if (state->core_frequency != speed_mhz) {
  314. state->core_frequency = speed_mhz;
  315. dprintk(" Corrected ACPI frequency to %d\n",
  316. speed_mhz);
  317. }
  318. if (latency < pc.bits.sgtc)
  319. latency = pc.bits.sgtc;
  320. if (speed < minimum_speed)
  321. minimum_speed = speed;
  322. if (speed > maximum_speed)
  323. maximum_speed = speed;
  324. }
  325. powernow_table[i].frequency = CPUFREQ_TABLE_END;
  326. powernow_table[i].index = 0;
  327. /* notify BIOS that we exist */
  328. acpi_processor_notify_smm(THIS_MODULE);
  329. return 0;
  330. err2:
  331. acpi_processor_unregister_performance(acpi_processor_perf, 0);
  332. err1:
  333. free_cpumask_var(acpi_processor_perf->shared_cpu_map);
  334. err05:
  335. kfree(acpi_processor_perf);
  336. err0:
  337. printk(KERN_WARNING PFX "ACPI perflib can not be used in this platform\n");
  338. acpi_processor_perf = NULL;
  339. return retval;
  340. }
  341. #else
  342. static int powernow_acpi_init(void)
  343. {
  344. printk(KERN_INFO PFX "no support for ACPI processor found."
  345. " Please recompile your kernel with ACPI processor\n");
  346. return -EINVAL;
  347. }
  348. #endif
  349. static int powernow_decode_bios (int maxfid, int startvid)
  350. {
  351. struct psb_s *psb;
  352. struct pst_s *pst;
  353. unsigned int i, j;
  354. unsigned char *p;
  355. unsigned int etuple;
  356. unsigned int ret;
  357. etuple = cpuid_eax(0x80000001);
  358. for (i=0xC0000; i < 0xffff0 ; i+=16) {
  359. p = phys_to_virt(i);
  360. if (memcmp(p, "AMDK7PNOW!", 10) == 0){
  361. dprintk ("Found PSB header at %p\n", p);
  362. psb = (struct psb_s *) p;
  363. dprintk ("Table version: 0x%x\n", psb->tableversion);
  364. if (psb->tableversion != 0x12) {
  365. printk (KERN_INFO PFX "Sorry, only v1.2 tables supported right now\n");
  366. return -ENODEV;
  367. }
  368. dprintk ("Flags: 0x%x\n", psb->flags);
  369. if ((psb->flags & 1)==0) {
  370. dprintk ("Mobile voltage regulator\n");
  371. } else {
  372. dprintk ("Desktop voltage regulator\n");
  373. }
  374. latency = psb->settlingtime;
  375. if (latency < 100) {
  376. printk(KERN_INFO PFX "BIOS set settling time to %d microseconds. "
  377. "Should be at least 100. Correcting.\n", latency);
  378. latency = 100;
  379. }
  380. dprintk ("Settling Time: %d microseconds.\n", psb->settlingtime);
  381. dprintk ("Has %d PST tables. (Only dumping ones relevant to this CPU).\n", psb->numpst);
  382. p += sizeof (struct psb_s);
  383. pst = (struct pst_s *) p;
  384. for (j=0; j<psb->numpst; j++) {
  385. pst = (struct pst_s *) p;
  386. number_scales = pst->numpstates;
  387. if ((etuple == pst->cpuid) && check_fsb(pst->fsbspeed) &&
  388. (maxfid==pst->maxfid) && (startvid==pst->startvid))
  389. {
  390. dprintk ("PST:%d (@%p)\n", j, pst);
  391. dprintk (" cpuid: 0x%x fsb: %d maxFID: 0x%x startvid: 0x%x\n",
  392. pst->cpuid, pst->fsbspeed, pst->maxfid, pst->startvid);
  393. ret = get_ranges ((char *) pst + sizeof (struct pst_s));
  394. return ret;
  395. } else {
  396. unsigned int k;
  397. p = (char *) pst + sizeof (struct pst_s);
  398. for (k=0; k<number_scales; k++)
  399. p+=2;
  400. }
  401. }
  402. printk (KERN_INFO PFX "No PST tables match this cpuid (0x%x)\n", etuple);
  403. printk (KERN_INFO PFX "This is indicative of a broken BIOS.\n");
  404. return -EINVAL;
  405. }
  406. p++;
  407. }
  408. return -ENODEV;
  409. }
  410. static int powernow_target (struct cpufreq_policy *policy,
  411. unsigned int target_freq,
  412. unsigned int relation)
  413. {
  414. unsigned int newstate;
  415. if (cpufreq_frequency_table_target(policy, powernow_table, target_freq, relation, &newstate))
  416. return -EINVAL;
  417. change_speed(newstate);
  418. return 0;
  419. }
  420. static int powernow_verify (struct cpufreq_policy *policy)
  421. {
  422. return cpufreq_frequency_table_verify(policy, powernow_table);
  423. }
  424. /*
  425. * We use the fact that the bus frequency is somehow
  426. * a multiple of 100000/3 khz, then we compute sgtc according
  427. * to this multiple.
  428. * That way, we match more how AMD thinks all of that work.
  429. * We will then get the same kind of behaviour already tested under
  430. * the "well-known" other OS.
  431. */
  432. static int __init fixup_sgtc(void)
  433. {
  434. unsigned int sgtc;
  435. unsigned int m;
  436. m = fsb / 3333;
  437. if ((m % 10) >= 5)
  438. m += 5;
  439. m /= 10;
  440. sgtc = 100 * m * latency;
  441. sgtc = sgtc / 3;
  442. if (sgtc > 0xfffff) {
  443. printk(KERN_WARNING PFX "SGTC too large %d\n", sgtc);
  444. sgtc = 0xfffff;
  445. }
  446. return sgtc;
  447. }
  448. static unsigned int powernow_get(unsigned int cpu)
  449. {
  450. union msr_fidvidstatus fidvidstatus;
  451. unsigned int cfid;
  452. if (cpu)
  453. return 0;
  454. rdmsrl (MSR_K7_FID_VID_STATUS, fidvidstatus.val);
  455. cfid = fidvidstatus.bits.CFID;
  456. return (fsb * fid_codes[cfid] / 10);
  457. }
  458. static int __init acer_cpufreq_pst(const struct dmi_system_id *d)
  459. {
  460. printk(KERN_WARNING "%s laptop with broken PST tables in BIOS detected.\n", d->ident);
  461. printk(KERN_WARNING "You need to downgrade to 3A21 (09/09/2002), or try a newer BIOS than 3A71 (01/20/2003)\n");
  462. printk(KERN_WARNING "cpufreq scaling has been disabled as a result of this.\n");
  463. return 0;
  464. }
  465. /*
  466. * Some Athlon laptops have really fucked PST tables.
  467. * A BIOS update is all that can save them.
  468. * Mention this, and disable cpufreq.
  469. */
  470. static struct dmi_system_id __initdata powernow_dmi_table[] = {
  471. {
  472. .callback = acer_cpufreq_pst,
  473. .ident = "Acer Aspire",
  474. .matches = {
  475. DMI_MATCH(DMI_SYS_VENDOR, "Insyde Software"),
  476. DMI_MATCH(DMI_BIOS_VERSION, "3A71"),
  477. },
  478. },
  479. { }
  480. };
  481. static int __init powernow_cpu_init (struct cpufreq_policy *policy)
  482. {
  483. union msr_fidvidstatus fidvidstatus;
  484. int result;
  485. if (policy->cpu != 0)
  486. return -ENODEV;
  487. rdmsrl (MSR_K7_FID_VID_STATUS, fidvidstatus.val);
  488. recalibrate_cpu_khz();
  489. fsb = (10 * cpu_khz) / fid_codes[fidvidstatus.bits.CFID];
  490. if (!fsb) {
  491. printk(KERN_WARNING PFX "can not determine bus frequency\n");
  492. return -EINVAL;
  493. }
  494. dprintk("FSB: %3dMHz\n", fsb/1000);
  495. if (dmi_check_system(powernow_dmi_table) || acpi_force) {
  496. printk (KERN_INFO PFX "PSB/PST known to be broken. Trying ACPI instead\n");
  497. result = powernow_acpi_init();
  498. } else {
  499. result = powernow_decode_bios(fidvidstatus.bits.MFID, fidvidstatus.bits.SVID);
  500. if (result) {
  501. printk (KERN_INFO PFX "Trying ACPI perflib\n");
  502. maximum_speed = 0;
  503. minimum_speed = -1;
  504. latency = 0;
  505. result = powernow_acpi_init();
  506. if (result) {
  507. printk (KERN_INFO PFX "ACPI and legacy methods failed\n");
  508. printk (KERN_INFO PFX "See http://www.codemonkey.org.uk/projects/cpufreq/powernow-k7.html\n");
  509. }
  510. } else {
  511. /* SGTC use the bus clock as timer */
  512. latency = fixup_sgtc();
  513. printk(KERN_INFO PFX "SGTC: %d\n", latency);
  514. }
  515. }
  516. if (result)
  517. return result;
  518. printk (KERN_INFO PFX "Minimum speed %d MHz. Maximum speed %d MHz.\n",
  519. minimum_speed/1000, maximum_speed/1000);
  520. policy->cpuinfo.transition_latency = cpufreq_scale(2000000UL, fsb, latency);
  521. policy->cur = powernow_get(0);
  522. cpufreq_frequency_table_get_attr(powernow_table, policy->cpu);
  523. return cpufreq_frequency_table_cpuinfo(policy, powernow_table);
  524. }
  525. static int powernow_cpu_exit (struct cpufreq_policy *policy) {
  526. cpufreq_frequency_table_put_attr(policy->cpu);
  527. #ifdef CONFIG_X86_POWERNOW_K7_ACPI
  528. if (acpi_processor_perf) {
  529. acpi_processor_unregister_performance(acpi_processor_perf, 0);
  530. free_cpumask_var(acpi_processor_perf->shared_cpu_map);
  531. kfree(acpi_processor_perf);
  532. }
  533. #endif
  534. kfree(powernow_table);
  535. return 0;
  536. }
  537. static struct freq_attr* powernow_table_attr[] = {
  538. &cpufreq_freq_attr_scaling_available_freqs,
  539. NULL,
  540. };
  541. static struct cpufreq_driver powernow_driver = {
  542. .verify = powernow_verify,
  543. .target = powernow_target,
  544. .get = powernow_get,
  545. .init = powernow_cpu_init,
  546. .exit = powernow_cpu_exit,
  547. .name = "powernow-k7",
  548. .owner = THIS_MODULE,
  549. .attr = powernow_table_attr,
  550. };
  551. static int __init powernow_init (void)
  552. {
  553. if (check_powernow()==0)
  554. return -ENODEV;
  555. return cpufreq_register_driver(&powernow_driver);
  556. }
  557. static void __exit powernow_exit (void)
  558. {
  559. cpufreq_unregister_driver(&powernow_driver);
  560. }
  561. module_param(acpi_force, int, 0444);
  562. MODULE_PARM_DESC(acpi_force, "Force ACPI to be used.");
  563. MODULE_AUTHOR ("Dave Jones <davej@redhat.com>");
  564. MODULE_DESCRIPTION ("Powernow driver for AMD K7 processors.");
  565. MODULE_LICENSE ("GPL");
  566. late_initcall(powernow_init);
  567. module_exit(powernow_exit);