longhaul.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. /*
  2. * (C) 2001-2004 Dave Jones. <davej@codemonkey.org.uk>
  3. * (C) 2002 Padraig Brady. <padraig@antefacto.com>
  4. *
  5. * Licensed under the terms of the GNU GPL License version 2.
  6. * Based upon datasheets & sample CPUs kindly provided by VIA.
  7. *
  8. * VIA have currently 3 different versions of Longhaul.
  9. * Version 1 (Longhaul) uses the BCR2 MSR at 0x1147.
  10. * It is present only in Samuel 1 (C5A), Samuel 2 (C5B) stepping 0.
  11. * Version 2 of longhaul is the same as v1, but adds voltage scaling.
  12. * Present in Samuel 2 (steppings 1-7 only) (C5B), and Ezra (C5C)
  13. * voltage scaling support has currently been disabled in this driver
  14. * until we have code that gets it right.
  15. * Version 3 of longhaul got renamed to Powersaver and redesigned
  16. * to use the POWERSAVER MSR at 0x110a.
  17. * It is present in Ezra-T (C5M), Nehemiah (C5X) and above.
  18. * It's pretty much the same feature wise to longhaul v2, though
  19. * there is provision for scaling FSB too, but this doesn't work
  20. * too well in practice so we don't even try to use this.
  21. *
  22. * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous*
  23. */
  24. #include <linux/kernel.h>
  25. #include <linux/module.h>
  26. #include <linux/moduleparam.h>
  27. #include <linux/init.h>
  28. #include <linux/cpufreq.h>
  29. #include <linux/slab.h>
  30. #include <linux/string.h>
  31. #include <asm/msr.h>
  32. #include <asm/timex.h>
  33. #include <asm/io.h>
  34. #include "longhaul.h"
  35. #define PFX "longhaul: "
  36. #define TYPE_LONGHAUL_V1 1
  37. #define TYPE_LONGHAUL_V2 2
  38. #define TYPE_POWERSAVER 3
  39. #define CPU_SAMUEL 1
  40. #define CPU_SAMUEL2 2
  41. #define CPU_EZRA 3
  42. #define CPU_EZRA_T 4
  43. #define CPU_NEHEMIAH 5
  44. static int cpu_model;
  45. static unsigned int numscales=16, numvscales;
  46. static unsigned int fsb;
  47. static int minvid, maxvid;
  48. static unsigned int minmult, maxmult;
  49. static int can_scale_voltage;
  50. static int vrmrev;
  51. /* Module parameters */
  52. static int dont_scale_voltage;
  53. #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "longhaul", msg)
  54. #define __hlt() __asm__ __volatile__("hlt": : :"memory")
  55. /* Clock ratios multiplied by 10 */
  56. static int clock_ratio[32];
  57. static int eblcr_table[32];
  58. static int voltage_table[32];
  59. static unsigned int highest_speed, lowest_speed; /* kHz */
  60. static int longhaul_version;
  61. static struct cpufreq_frequency_table *longhaul_table;
  62. #ifdef CONFIG_CPU_FREQ_DEBUG
  63. static char speedbuffer[8];
  64. static char *print_speed(int speed)
  65. {
  66. if (speed > 1000) {
  67. if (speed%1000 == 0)
  68. sprintf (speedbuffer, "%dGHz", speed/1000);
  69. else
  70. sprintf (speedbuffer, "%d.%dGHz", speed/1000, (speed%1000)/100);
  71. } else
  72. sprintf (speedbuffer, "%dMHz", speed);
  73. return speedbuffer;
  74. }
  75. #endif
  76. static unsigned int calc_speed(int mult)
  77. {
  78. int khz;
  79. khz = (mult/10)*fsb;
  80. if (mult%10)
  81. khz += fsb/2;
  82. khz *= 1000;
  83. return khz;
  84. }
  85. static int longhaul_get_cpu_mult(void)
  86. {
  87. unsigned long invalue=0,lo, hi;
  88. rdmsr (MSR_IA32_EBL_CR_POWERON, lo, hi);
  89. invalue = (lo & (1<<22|1<<23|1<<24|1<<25)) >>22;
  90. if (longhaul_version==TYPE_LONGHAUL_V2 || longhaul_version==TYPE_POWERSAVER) {
  91. if (lo & (1<<27))
  92. invalue+=16;
  93. }
  94. return eblcr_table[invalue];
  95. }
  96. static void do_powersaver(union msr_longhaul *longhaul,
  97. unsigned int clock_ratio_index)
  98. {
  99. int version;
  100. switch (cpu_model) {
  101. case CPU_EZRA_T:
  102. version = 3;
  103. break;
  104. case CPU_NEHEMIAH:
  105. version = 0xf;
  106. break;
  107. default:
  108. return;
  109. }
  110. rdmsrl(MSR_VIA_LONGHAUL, longhaul->val);
  111. longhaul->bits.SoftBusRatio = clock_ratio_index & 0xf;
  112. longhaul->bits.SoftBusRatio4 = (clock_ratio_index & 0x10) >> 4;
  113. longhaul->bits.EnableSoftBusRatio = 1;
  114. longhaul->bits.RevisionKey = 0;
  115. local_irq_disable();
  116. wrmsrl(MSR_VIA_LONGHAUL, longhaul->val);
  117. local_irq_enable();
  118. __hlt();
  119. rdmsrl(MSR_VIA_LONGHAUL, longhaul->val);
  120. longhaul->bits.EnableSoftBusRatio = 0;
  121. longhaul->bits.RevisionKey = version;
  122. local_irq_disable();
  123. wrmsrl(MSR_VIA_LONGHAUL, longhaul->val);
  124. local_irq_enable();
  125. }
  126. /**
  127. * longhaul_set_cpu_frequency()
  128. * @clock_ratio_index : bitpattern of the new multiplier.
  129. *
  130. * Sets a new clock ratio.
  131. */
  132. static void longhaul_setstate(unsigned int clock_ratio_index)
  133. {
  134. int speed, mult;
  135. struct cpufreq_freqs freqs;
  136. union msr_longhaul longhaul;
  137. union msr_bcr2 bcr2;
  138. static unsigned int old_ratio=-1;
  139. if (old_ratio == clock_ratio_index)
  140. return;
  141. old_ratio = clock_ratio_index;
  142. mult = clock_ratio[clock_ratio_index];
  143. if (mult == -1)
  144. return;
  145. speed = calc_speed(mult);
  146. if ((speed > highest_speed) || (speed < lowest_speed))
  147. return;
  148. freqs.old = calc_speed(longhaul_get_cpu_mult());
  149. freqs.new = speed;
  150. freqs.cpu = 0; /* longhaul.c is UP only driver */
  151. cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
  152. dprintk ("Setting to FSB:%dMHz Mult:%d.%dx (%s)\n",
  153. fsb, mult/10, mult%10, print_speed(speed/1000));
  154. switch (longhaul_version) {
  155. /*
  156. * Longhaul v1. (Samuel[C5A] and Samuel2 stepping 0[C5B])
  157. * Software controlled multipliers only.
  158. *
  159. * *NB* Until we get voltage scaling working v1 & v2 are the same code.
  160. * Longhaul v2 appears in Samuel2 Steppings 1->7 [C5b] and Ezra [C5C]
  161. */
  162. case TYPE_LONGHAUL_V1:
  163. case TYPE_LONGHAUL_V2:
  164. rdmsrl (MSR_VIA_BCR2, bcr2.val);
  165. /* Enable software clock multiplier */
  166. bcr2.bits.ESOFTBF = 1;
  167. bcr2.bits.CLOCKMUL = clock_ratio_index;
  168. local_irq_disable();
  169. wrmsrl (MSR_VIA_BCR2, bcr2.val);
  170. local_irq_enable();
  171. __hlt();
  172. /* Disable software clock multiplier */
  173. rdmsrl (MSR_VIA_BCR2, bcr2.val);
  174. bcr2.bits.ESOFTBF = 0;
  175. local_irq_disable();
  176. wrmsrl (MSR_VIA_BCR2, bcr2.val);
  177. local_irq_enable();
  178. break;
  179. /*
  180. * Longhaul v3 (aka Powersaver). (Ezra-T [C5M] & Nehemiah [C5N])
  181. * We can scale voltage with this too, but that's currently
  182. * disabled until we come up with a decent 'match freq to voltage'
  183. * algorithm.
  184. * When we add voltage scaling, we will also need to do the
  185. * voltage/freq setting in order depending on the direction
  186. * of scaling (like we do in powernow-k7.c)
  187. * Nehemiah can do FSB scaling too, but this has never been proven
  188. * to work in practice.
  189. */
  190. case TYPE_POWERSAVER:
  191. do_powersaver(&longhaul, clock_ratio_index);
  192. break;
  193. }
  194. cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
  195. }
  196. /*
  197. * Centaur decided to make life a little more tricky.
  198. * Only longhaul v1 is allowed to read EBLCR BSEL[0:1].
  199. * Samuel2 and above have to try and guess what the FSB is.
  200. * We do this by assuming we booted at maximum multiplier, and interpolate
  201. * between that value multiplied by possible FSBs and cpu_mhz which
  202. * was calculated at boot time. Really ugly, but no other way to do this.
  203. */
  204. #define ROUNDING 0xf
  205. static int _guess(int guess)
  206. {
  207. int target;
  208. target = ((maxmult/10)*guess);
  209. if (maxmult%10 != 0)
  210. target += (guess/2);
  211. target += ROUNDING/2;
  212. target &= ~ROUNDING;
  213. return target;
  214. }
  215. static int guess_fsb(void)
  216. {
  217. int speed = (cpu_khz/1000);
  218. int i;
  219. int speeds[3] = { 66, 100, 133 };
  220. speed += ROUNDING/2;
  221. speed &= ~ROUNDING;
  222. for (i=0; i<3; i++) {
  223. if (_guess(speeds[i]) == speed)
  224. return speeds[i];
  225. }
  226. return 0;
  227. }
  228. static int __init longhaul_get_ranges(void)
  229. {
  230. unsigned long invalue;
  231. unsigned int multipliers[32]= {
  232. 50,30,40,100,55,35,45,95,90,70,80,60,120,75,85,65,
  233. -1,110,120,-1,135,115,125,105,130,150,160,140,-1,155,-1,145 };
  234. unsigned int j, k = 0;
  235. union msr_longhaul longhaul;
  236. unsigned long lo, hi;
  237. unsigned int eblcr_fsb_table_v1[] = { 66, 133, 100, -1 };
  238. unsigned int eblcr_fsb_table_v2[] = { 133, 100, -1, 66 };
  239. switch (longhaul_version) {
  240. case TYPE_LONGHAUL_V1:
  241. case TYPE_LONGHAUL_V2:
  242. /* Ugh, Longhaul v1 didn't have the min/max MSRs.
  243. Assume min=3.0x & max = whatever we booted at. */
  244. minmult = 30;
  245. maxmult = longhaul_get_cpu_mult();
  246. rdmsr (MSR_IA32_EBL_CR_POWERON, lo, hi);
  247. invalue = (lo & (1<<18|1<<19)) >>18;
  248. if (cpu_model==CPU_SAMUEL || cpu_model==CPU_SAMUEL2)
  249. fsb = eblcr_fsb_table_v1[invalue];
  250. else
  251. fsb = guess_fsb();
  252. break;
  253. case TYPE_POWERSAVER:
  254. /* Ezra-T */
  255. if (cpu_model==CPU_EZRA_T) {
  256. rdmsrl (MSR_VIA_LONGHAUL, longhaul.val);
  257. invalue = longhaul.bits.MaxMHzBR;
  258. if (longhaul.bits.MaxMHzBR4)
  259. invalue += 16;
  260. maxmult=multipliers[invalue];
  261. invalue = longhaul.bits.MinMHzBR;
  262. if (longhaul.bits.MinMHzBR4 == 1)
  263. minmult = 30;
  264. else
  265. minmult = multipliers[invalue];
  266. fsb = eblcr_fsb_table_v2[longhaul.bits.MaxMHzFSB];
  267. break;
  268. }
  269. /* Nehemiah */
  270. if (cpu_model==CPU_NEHEMIAH) {
  271. rdmsrl (MSR_VIA_LONGHAUL, longhaul.val);
  272. /*
  273. * TODO: This code works, but raises a lot of questions.
  274. * - Some Nehemiah's seem to have broken Min/MaxMHzBR's.
  275. * We get around this by using a hardcoded multiplier of 4.0x
  276. * for the minimimum speed, and the speed we booted up at for the max.
  277. * This is done in longhaul_get_cpu_mult() by reading the EBLCR register.
  278. * - According to some VIA documentation EBLCR is only
  279. * in pre-Nehemiah C3s. How this still works is a mystery.
  280. * We're possibly using something undocumented and unsupported,
  281. * But it works, so we don't grumble.
  282. */
  283. minmult=40;
  284. maxmult=longhaul_get_cpu_mult();
  285. /* Starting with the 1.2GHz parts, theres a 200MHz bus. */
  286. if ((cpu_khz/1000) > 1200)
  287. fsb = 200;
  288. else
  289. fsb = eblcr_fsb_table_v2[longhaul.bits.MaxMHzFSB];
  290. break;
  291. }
  292. }
  293. dprintk ("MinMult:%d.%dx MaxMult:%d.%dx\n",
  294. minmult/10, minmult%10, maxmult/10, maxmult%10);
  295. if (fsb == -1) {
  296. printk (KERN_INFO PFX "Invalid (reserved) FSB!\n");
  297. return -EINVAL;
  298. }
  299. highest_speed = calc_speed(maxmult);
  300. lowest_speed = calc_speed(minmult);
  301. dprintk ("FSB:%dMHz Lowest speed: %s Highest speed:%s\n", fsb,
  302. print_speed(lowest_speed/1000),
  303. print_speed(highest_speed/1000));
  304. if (lowest_speed == highest_speed) {
  305. printk (KERN_INFO PFX "highestspeed == lowest, aborting.\n");
  306. return -EINVAL;
  307. }
  308. if (lowest_speed > highest_speed) {
  309. printk (KERN_INFO PFX "nonsense! lowest (%d > %d) !\n",
  310. lowest_speed, highest_speed);
  311. return -EINVAL;
  312. }
  313. longhaul_table = kmalloc((numscales + 1) * sizeof(struct cpufreq_frequency_table), GFP_KERNEL);
  314. if(!longhaul_table)
  315. return -ENOMEM;
  316. for (j=0; j < numscales; j++) {
  317. unsigned int ratio;
  318. ratio = clock_ratio[j];
  319. if (ratio == -1)
  320. continue;
  321. if (ratio > maxmult || ratio < minmult)
  322. continue;
  323. longhaul_table[k].frequency = calc_speed(ratio);
  324. longhaul_table[k].index = j;
  325. k++;
  326. }
  327. longhaul_table[k].frequency = CPUFREQ_TABLE_END;
  328. if (!k) {
  329. kfree (longhaul_table);
  330. return -EINVAL;
  331. }
  332. return 0;
  333. }
  334. static void __init longhaul_setup_voltagescaling(void)
  335. {
  336. union msr_longhaul longhaul;
  337. rdmsrl (MSR_VIA_LONGHAUL, longhaul.val);
  338. if (!(longhaul.bits.RevisionID & 1))
  339. return;
  340. minvid = longhaul.bits.MinimumVID;
  341. maxvid = longhaul.bits.MaximumVID;
  342. vrmrev = longhaul.bits.VRMRev;
  343. if (minvid == 0 || maxvid == 0) {
  344. printk (KERN_INFO PFX "Bogus values Min:%d.%03d Max:%d.%03d. "
  345. "Voltage scaling disabled.\n",
  346. minvid/1000, minvid%1000, maxvid/1000, maxvid%1000);
  347. return;
  348. }
  349. if (minvid == maxvid) {
  350. printk (KERN_INFO PFX "Claims to support voltage scaling but min & max are "
  351. "both %d.%03d. Voltage scaling disabled\n",
  352. maxvid/1000, maxvid%1000);
  353. return;
  354. }
  355. if (vrmrev==0) {
  356. dprintk ("VRM 8.5 \n");
  357. memcpy (voltage_table, vrm85scales, sizeof(voltage_table));
  358. numvscales = (voltage_table[maxvid]-voltage_table[minvid])/25;
  359. } else {
  360. dprintk ("Mobile VRM \n");
  361. memcpy (voltage_table, mobilevrmscales, sizeof(voltage_table));
  362. numvscales = (voltage_table[maxvid]-voltage_table[minvid])/5;
  363. }
  364. /* Current voltage isn't readable at first, so we need to
  365. set it to a known value. The spec says to use maxvid */
  366. longhaul.bits.RevisionKey = longhaul.bits.RevisionID; /* FIXME: This is bad. */
  367. longhaul.bits.EnableSoftVID = 1;
  368. longhaul.bits.SoftVID = maxvid;
  369. wrmsrl (MSR_VIA_LONGHAUL, longhaul.val);
  370. minvid = voltage_table[minvid];
  371. maxvid = voltage_table[maxvid];
  372. dprintk ("Min VID=%d.%03d Max VID=%d.%03d, %d possible voltage scales\n",
  373. maxvid/1000, maxvid%1000, minvid/1000, minvid%1000, numvscales);
  374. can_scale_voltage = 1;
  375. }
  376. static int longhaul_verify(struct cpufreq_policy *policy)
  377. {
  378. return cpufreq_frequency_table_verify(policy, longhaul_table);
  379. }
  380. static int longhaul_target(struct cpufreq_policy *policy,
  381. unsigned int target_freq, unsigned int relation)
  382. {
  383. unsigned int table_index = 0;
  384. unsigned int new_clock_ratio = 0;
  385. if (cpufreq_frequency_table_target(policy, longhaul_table, target_freq, relation, &table_index))
  386. return -EINVAL;
  387. new_clock_ratio = longhaul_table[table_index].index & 0xFF;
  388. longhaul_setstate(new_clock_ratio);
  389. return 0;
  390. }
  391. static unsigned int longhaul_get(unsigned int cpu)
  392. {
  393. if (cpu)
  394. return 0;
  395. return calc_speed(longhaul_get_cpu_mult());
  396. }
  397. static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
  398. {
  399. struct cpuinfo_x86 *c = cpu_data;
  400. char *cpuname=NULL;
  401. int ret;
  402. switch (c->x86_model) {
  403. case 6:
  404. cpu_model = CPU_SAMUEL;
  405. cpuname = "C3 'Samuel' [C5A]";
  406. longhaul_version = TYPE_LONGHAUL_V1;
  407. memcpy (clock_ratio, samuel1_clock_ratio, sizeof(samuel1_clock_ratio));
  408. memcpy (eblcr_table, samuel1_eblcr, sizeof(samuel1_eblcr));
  409. break;
  410. case 7:
  411. longhaul_version = TYPE_LONGHAUL_V1;
  412. switch (c->x86_mask) {
  413. case 0:
  414. cpu_model = CPU_SAMUEL2;
  415. cpuname = "C3 'Samuel 2' [C5B]";
  416. /* Note, this is not a typo, early Samuel2's had Samuel1 ratios. */
  417. memcpy (clock_ratio, samuel1_clock_ratio, sizeof(samuel1_clock_ratio));
  418. memcpy (eblcr_table, samuel2_eblcr, sizeof(samuel2_eblcr));
  419. break;
  420. case 1 ... 15:
  421. if (c->x86_mask < 8) {
  422. cpu_model = CPU_SAMUEL2;
  423. cpuname = "C3 'Samuel 2' [C5B]";
  424. } else {
  425. cpu_model = CPU_EZRA;
  426. cpuname = "C3 'Ezra' [C5C]";
  427. }
  428. memcpy (clock_ratio, ezra_clock_ratio, sizeof(ezra_clock_ratio));
  429. memcpy (eblcr_table, ezra_eblcr, sizeof(ezra_eblcr));
  430. break;
  431. }
  432. break;
  433. case 8:
  434. cpu_model = CPU_EZRA_T;
  435. cpuname = "C3 'Ezra-T' [C5M]";
  436. longhaul_version = TYPE_POWERSAVER;
  437. numscales=32;
  438. memcpy (clock_ratio, ezrat_clock_ratio, sizeof(ezrat_clock_ratio));
  439. memcpy (eblcr_table, ezrat_eblcr, sizeof(ezrat_eblcr));
  440. break;
  441. case 9:
  442. cpu_model = CPU_NEHEMIAH;
  443. longhaul_version = TYPE_POWERSAVER;
  444. numscales=32;
  445. switch (c->x86_mask) {
  446. case 0 ... 1:
  447. cpuname = "C3 'Nehemiah A' [C5N]";
  448. memcpy (clock_ratio, nehemiah_a_clock_ratio, sizeof(nehemiah_a_clock_ratio));
  449. memcpy (eblcr_table, nehemiah_a_eblcr, sizeof(nehemiah_a_eblcr));
  450. break;
  451. case 2 ... 4:
  452. cpuname = "C3 'Nehemiah B' [C5N]";
  453. memcpy (clock_ratio, nehemiah_b_clock_ratio, sizeof(nehemiah_b_clock_ratio));
  454. memcpy (eblcr_table, nehemiah_b_eblcr, sizeof(nehemiah_b_eblcr));
  455. break;
  456. case 5 ... 15:
  457. cpuname = "C3 'Nehemiah C' [C5N]";
  458. memcpy (clock_ratio, nehemiah_c_clock_ratio, sizeof(nehemiah_c_clock_ratio));
  459. memcpy (eblcr_table, nehemiah_c_eblcr, sizeof(nehemiah_c_eblcr));
  460. break;
  461. }
  462. break;
  463. default:
  464. cpuname = "Unknown";
  465. break;
  466. }
  467. printk (KERN_INFO PFX "VIA %s CPU detected. ", cpuname);
  468. switch (longhaul_version) {
  469. case TYPE_LONGHAUL_V1:
  470. case TYPE_LONGHAUL_V2:
  471. printk ("Longhaul v%d supported.\n", longhaul_version);
  472. break;
  473. case TYPE_POWERSAVER:
  474. printk ("Powersaver supported.\n");
  475. break;
  476. };
  477. ret = longhaul_get_ranges();
  478. if (ret != 0)
  479. return ret;
  480. if ((longhaul_version==TYPE_LONGHAUL_V2 || longhaul_version==TYPE_POWERSAVER) &&
  481. (dont_scale_voltage==0))
  482. longhaul_setup_voltagescaling();
  483. policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
  484. policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
  485. policy->cur = calc_speed(longhaul_get_cpu_mult());
  486. ret = cpufreq_frequency_table_cpuinfo(policy, longhaul_table);
  487. if (ret)
  488. return ret;
  489. cpufreq_frequency_table_get_attr(longhaul_table, policy->cpu);
  490. return 0;
  491. }
  492. static int __devexit longhaul_cpu_exit(struct cpufreq_policy *policy)
  493. {
  494. cpufreq_frequency_table_put_attr(policy->cpu);
  495. return 0;
  496. }
  497. static struct freq_attr* longhaul_attr[] = {
  498. &cpufreq_freq_attr_scaling_available_freqs,
  499. NULL,
  500. };
  501. static struct cpufreq_driver longhaul_driver = {
  502. .verify = longhaul_verify,
  503. .target = longhaul_target,
  504. .get = longhaul_get,
  505. .init = longhaul_cpu_init,
  506. .exit = __devexit_p(longhaul_cpu_exit),
  507. .name = "longhaul",
  508. .owner = THIS_MODULE,
  509. .attr = longhaul_attr,
  510. };
  511. static int __init longhaul_init(void)
  512. {
  513. struct cpuinfo_x86 *c = cpu_data;
  514. if (c->x86_vendor != X86_VENDOR_CENTAUR || c->x86 != 6)
  515. return -ENODEV;
  516. switch (c->x86_model) {
  517. case 6 ... 9:
  518. return cpufreq_register_driver(&longhaul_driver);
  519. default:
  520. printk (KERN_INFO PFX "Unknown VIA CPU. Contact davej@codemonkey.org.uk\n");
  521. }
  522. return -ENODEV;
  523. }
  524. static void __exit longhaul_exit(void)
  525. {
  526. int i=0;
  527. for (i=0; i < numscales; i++) {
  528. if (clock_ratio[i] == maxmult) {
  529. longhaul_setstate(i);
  530. break;
  531. }
  532. }
  533. cpufreq_unregister_driver(&longhaul_driver);
  534. kfree(longhaul_table);
  535. }
  536. module_param (dont_scale_voltage, int, 0644);
  537. MODULE_PARM_DESC(dont_scale_voltage, "Don't scale voltage of processor");
  538. MODULE_AUTHOR ("Dave Jones <davej@codemonkey.org.uk>");
  539. MODULE_DESCRIPTION ("Longhaul driver for VIA Cyrix processors.");
  540. MODULE_LICENSE ("GPL");
  541. module_init(longhaul_init);
  542. module_exit(longhaul_exit);