speedstep-centrino.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /*
  2. * cpufreq driver for Enhanced SpeedStep, as found in Intel's Pentium
  3. * M (part of the Centrino chipset).
  4. *
  5. * Since the original Pentium M, most new Intel CPUs support Enhanced
  6. * SpeedStep.
  7. *
  8. * Despite the "SpeedStep" in the name, this is almost entirely unlike
  9. * traditional SpeedStep.
  10. *
  11. * Modelled on speedstep.c
  12. *
  13. * Copyright (C) 2003 Jeremy Fitzhardinge <jeremy@goop.org>
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/module.h>
  17. #include <linux/init.h>
  18. #include <linux/cpufreq.h>
  19. #include <linux/sched.h> /* current */
  20. #include <linux/delay.h>
  21. #include <linux/compiler.h>
  22. #include <asm/msr.h>
  23. #include <asm/processor.h>
  24. #include <asm/cpufeature.h>
  25. #define PFX "speedstep-centrino: "
  26. #define MAINTAINER "cpufreq@lists.linux.org.uk"
  27. #define dprintk(msg...) \
  28. cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-centrino", msg)
  29. #define INTEL_MSR_RANGE (0xffff)
  30. struct cpu_id
  31. {
  32. __u8 x86; /* CPU family */
  33. __u8 x86_model; /* model */
  34. __u8 x86_mask; /* stepping */
  35. };
  36. enum {
  37. CPU_BANIAS,
  38. CPU_DOTHAN_A1,
  39. CPU_DOTHAN_A2,
  40. CPU_DOTHAN_B0,
  41. CPU_MP4HT_D0,
  42. CPU_MP4HT_E0,
  43. };
  44. static const struct cpu_id cpu_ids[] = {
  45. [CPU_BANIAS] = { 6, 9, 5 },
  46. [CPU_DOTHAN_A1] = { 6, 13, 1 },
  47. [CPU_DOTHAN_A2] = { 6, 13, 2 },
  48. [CPU_DOTHAN_B0] = { 6, 13, 6 },
  49. [CPU_MP4HT_D0] = {15, 3, 4 },
  50. [CPU_MP4HT_E0] = {15, 4, 1 },
  51. };
  52. #define N_IDS ARRAY_SIZE(cpu_ids)
  53. struct cpu_model
  54. {
  55. const struct cpu_id *cpu_id;
  56. const char *model_name;
  57. unsigned max_freq; /* max clock in kHz */
  58. struct cpufreq_frequency_table *op_points; /* clock/voltage pairs */
  59. };
  60. static int centrino_verify_cpu_id(const struct cpuinfo_x86 *c,
  61. const struct cpu_id *x);
  62. /* Operating points for current CPU */
  63. static DEFINE_PER_CPU(struct cpu_model *, centrino_model);
  64. static DEFINE_PER_CPU(const struct cpu_id *, centrino_cpu);
  65. static struct cpufreq_driver centrino_driver;
  66. #ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE
  67. /* Computes the correct form for IA32_PERF_CTL MSR for a particular
  68. frequency/voltage operating point; frequency in MHz, volts in mV.
  69. This is stored as "index" in the structure. */
  70. #define OP(mhz, mv) \
  71. { \
  72. .frequency = (mhz) * 1000, \
  73. .index = (((mhz)/100) << 8) | ((mv - 700) / 16) \
  74. }
  75. /*
  76. * These voltage tables were derived from the Intel Pentium M
  77. * datasheet, document 25261202.pdf, Table 5. I have verified they
  78. * are consistent with my IBM ThinkPad X31, which has a 1.3GHz Pentium
  79. * M.
  80. */
  81. /* Ultra Low Voltage Intel Pentium M processor 900MHz (Banias) */
  82. static struct cpufreq_frequency_table banias_900[] =
  83. {
  84. OP(600, 844),
  85. OP(800, 988),
  86. OP(900, 1004),
  87. { .frequency = CPUFREQ_TABLE_END }
  88. };
  89. /* Ultra Low Voltage Intel Pentium M processor 1000MHz (Banias) */
  90. static struct cpufreq_frequency_table banias_1000[] =
  91. {
  92. OP(600, 844),
  93. OP(800, 972),
  94. OP(900, 988),
  95. OP(1000, 1004),
  96. { .frequency = CPUFREQ_TABLE_END }
  97. };
  98. /* Low Voltage Intel Pentium M processor 1.10GHz (Banias) */
  99. static struct cpufreq_frequency_table banias_1100[] =
  100. {
  101. OP( 600, 956),
  102. OP( 800, 1020),
  103. OP( 900, 1100),
  104. OP(1000, 1164),
  105. OP(1100, 1180),
  106. { .frequency = CPUFREQ_TABLE_END }
  107. };
  108. /* Low Voltage Intel Pentium M processor 1.20GHz (Banias) */
  109. static struct cpufreq_frequency_table banias_1200[] =
  110. {
  111. OP( 600, 956),
  112. OP( 800, 1004),
  113. OP( 900, 1020),
  114. OP(1000, 1100),
  115. OP(1100, 1164),
  116. OP(1200, 1180),
  117. { .frequency = CPUFREQ_TABLE_END }
  118. };
  119. /* Intel Pentium M processor 1.30GHz (Banias) */
  120. static struct cpufreq_frequency_table banias_1300[] =
  121. {
  122. OP( 600, 956),
  123. OP( 800, 1260),
  124. OP(1000, 1292),
  125. OP(1200, 1356),
  126. OP(1300, 1388),
  127. { .frequency = CPUFREQ_TABLE_END }
  128. };
  129. /* Intel Pentium M processor 1.40GHz (Banias) */
  130. static struct cpufreq_frequency_table banias_1400[] =
  131. {
  132. OP( 600, 956),
  133. OP( 800, 1180),
  134. OP(1000, 1308),
  135. OP(1200, 1436),
  136. OP(1400, 1484),
  137. { .frequency = CPUFREQ_TABLE_END }
  138. };
  139. /* Intel Pentium M processor 1.50GHz (Banias) */
  140. static struct cpufreq_frequency_table banias_1500[] =
  141. {
  142. OP( 600, 956),
  143. OP( 800, 1116),
  144. OP(1000, 1228),
  145. OP(1200, 1356),
  146. OP(1400, 1452),
  147. OP(1500, 1484),
  148. { .frequency = CPUFREQ_TABLE_END }
  149. };
  150. /* Intel Pentium M processor 1.60GHz (Banias) */
  151. static struct cpufreq_frequency_table banias_1600[] =
  152. {
  153. OP( 600, 956),
  154. OP( 800, 1036),
  155. OP(1000, 1164),
  156. OP(1200, 1276),
  157. OP(1400, 1420),
  158. OP(1600, 1484),
  159. { .frequency = CPUFREQ_TABLE_END }
  160. };
  161. /* Intel Pentium M processor 1.70GHz (Banias) */
  162. static struct cpufreq_frequency_table banias_1700[] =
  163. {
  164. OP( 600, 956),
  165. OP( 800, 1004),
  166. OP(1000, 1116),
  167. OP(1200, 1228),
  168. OP(1400, 1308),
  169. OP(1700, 1484),
  170. { .frequency = CPUFREQ_TABLE_END }
  171. };
  172. #undef OP
  173. #define _BANIAS(cpuid, max, name) \
  174. { .cpu_id = cpuid, \
  175. .model_name = "Intel(R) Pentium(R) M processor " name "MHz", \
  176. .max_freq = (max)*1000, \
  177. .op_points = banias_##max, \
  178. }
  179. #define BANIAS(max) _BANIAS(&cpu_ids[CPU_BANIAS], max, #max)
  180. /* CPU models, their operating frequency range, and freq/voltage
  181. operating points */
  182. static struct cpu_model models[] =
  183. {
  184. _BANIAS(&cpu_ids[CPU_BANIAS], 900, " 900"),
  185. BANIAS(1000),
  186. BANIAS(1100),
  187. BANIAS(1200),
  188. BANIAS(1300),
  189. BANIAS(1400),
  190. BANIAS(1500),
  191. BANIAS(1600),
  192. BANIAS(1700),
  193. /* NULL model_name is a wildcard */
  194. { &cpu_ids[CPU_DOTHAN_A1], NULL, 0, NULL },
  195. { &cpu_ids[CPU_DOTHAN_A2], NULL, 0, NULL },
  196. { &cpu_ids[CPU_DOTHAN_B0], NULL, 0, NULL },
  197. { &cpu_ids[CPU_MP4HT_D0], NULL, 0, NULL },
  198. { &cpu_ids[CPU_MP4HT_E0], NULL, 0, NULL },
  199. { NULL, }
  200. };
  201. #undef _BANIAS
  202. #undef BANIAS
  203. static int centrino_cpu_init_table(struct cpufreq_policy *policy)
  204. {
  205. struct cpuinfo_x86 *cpu = &cpu_data(policy->cpu);
  206. struct cpu_model *model;
  207. for(model = models; model->cpu_id != NULL; model++)
  208. if (centrino_verify_cpu_id(cpu, model->cpu_id) &&
  209. (model->model_name == NULL ||
  210. strcmp(cpu->x86_model_id, model->model_name) == 0))
  211. break;
  212. if (model->cpu_id == NULL) {
  213. /* No match at all */
  214. dprintk("no support for CPU model \"%s\": "
  215. "send /proc/cpuinfo to " MAINTAINER "\n",
  216. cpu->x86_model_id);
  217. return -ENOENT;
  218. }
  219. if (model->op_points == NULL) {
  220. /* Matched a non-match */
  221. dprintk("no table support for CPU model \"%s\"\n",
  222. cpu->x86_model_id);
  223. dprintk("try using the acpi-cpufreq driver\n");
  224. return -ENOENT;
  225. }
  226. per_cpu(centrino_model, policy->cpu) = model;
  227. dprintk("found \"%s\": max frequency: %dkHz\n",
  228. model->model_name, model->max_freq);
  229. return 0;
  230. }
  231. #else
  232. static inline int centrino_cpu_init_table(struct cpufreq_policy *policy)
  233. {
  234. return -ENODEV;
  235. }
  236. #endif /* CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE */
  237. static int centrino_verify_cpu_id(const struct cpuinfo_x86 *c,
  238. const struct cpu_id *x)
  239. {
  240. if ((c->x86 == x->x86) &&
  241. (c->x86_model == x->x86_model) &&
  242. (c->x86_mask == x->x86_mask))
  243. return 1;
  244. return 0;
  245. }
  246. /* To be called only after centrino_model is initialized */
  247. static unsigned extract_clock(unsigned msr, unsigned int cpu, int failsafe)
  248. {
  249. int i;
  250. /*
  251. * Extract clock in kHz from PERF_CTL value
  252. * for centrino, as some DSDTs are buggy.
  253. * Ideally, this can be done using the acpi_data structure.
  254. */
  255. if ((per_cpu(centrino_cpu, cpu) == &cpu_ids[CPU_BANIAS]) ||
  256. (per_cpu(centrino_cpu, cpu) == &cpu_ids[CPU_DOTHAN_A1]) ||
  257. (per_cpu(centrino_cpu, cpu) == &cpu_ids[CPU_DOTHAN_B0])) {
  258. msr = (msr >> 8) & 0xff;
  259. return msr * 100000;
  260. }
  261. if ((!per_cpu(centrino_model, cpu)) ||
  262. (!per_cpu(centrino_model, cpu)->op_points))
  263. return 0;
  264. msr &= 0xffff;
  265. for (i = 0;
  266. per_cpu(centrino_model, cpu)->op_points[i].frequency
  267. != CPUFREQ_TABLE_END;
  268. i++) {
  269. if (msr == per_cpu(centrino_model, cpu)->op_points[i].index)
  270. return per_cpu(centrino_model, cpu)->
  271. op_points[i].frequency;
  272. }
  273. if (failsafe)
  274. return per_cpu(centrino_model, cpu)->op_points[i-1].frequency;
  275. else
  276. return 0;
  277. }
  278. /* Return the current CPU frequency in kHz */
  279. static unsigned int get_cur_freq(unsigned int cpu)
  280. {
  281. unsigned l, h;
  282. unsigned clock_freq;
  283. cpumask_t saved_mask;
  284. cpumask_of_cpu_ptr(new_mask, cpu);
  285. saved_mask = current->cpus_allowed;
  286. set_cpus_allowed_ptr(current, new_mask);
  287. if (smp_processor_id() != cpu)
  288. return 0;
  289. rdmsr(MSR_IA32_PERF_STATUS, l, h);
  290. clock_freq = extract_clock(l, cpu, 0);
  291. if (unlikely(clock_freq == 0)) {
  292. /*
  293. * On some CPUs, we can see transient MSR values (which are
  294. * not present in _PSS), while CPU is doing some automatic
  295. * P-state transition (like TM2). Get the last freq set
  296. * in PERF_CTL.
  297. */
  298. rdmsr(MSR_IA32_PERF_CTL, l, h);
  299. clock_freq = extract_clock(l, cpu, 1);
  300. }
  301. set_cpus_allowed_ptr(current, &saved_mask);
  302. return clock_freq;
  303. }
  304. static int centrino_cpu_init(struct cpufreq_policy *policy)
  305. {
  306. struct cpuinfo_x86 *cpu = &cpu_data(policy->cpu);
  307. unsigned freq;
  308. unsigned l, h;
  309. int ret;
  310. int i;
  311. /* Only Intel makes Enhanced Speedstep-capable CPUs */
  312. if (cpu->x86_vendor != X86_VENDOR_INTEL ||
  313. !cpu_has(cpu, X86_FEATURE_EST))
  314. return -ENODEV;
  315. if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
  316. centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
  317. if (policy->cpu != 0)
  318. return -ENODEV;
  319. for (i = 0; i < N_IDS; i++)
  320. if (centrino_verify_cpu_id(cpu, &cpu_ids[i]))
  321. break;
  322. if (i != N_IDS)
  323. per_cpu(centrino_cpu, policy->cpu) = &cpu_ids[i];
  324. if (!per_cpu(centrino_cpu, policy->cpu)) {
  325. dprintk("found unsupported CPU with "
  326. "Enhanced SpeedStep: send /proc/cpuinfo to "
  327. MAINTAINER "\n");
  328. return -ENODEV;
  329. }
  330. if (centrino_cpu_init_table(policy)) {
  331. return -ENODEV;
  332. }
  333. /* Check to see if Enhanced SpeedStep is enabled, and try to
  334. enable it if not. */
  335. rdmsr(MSR_IA32_MISC_ENABLE, l, h);
  336. if (!(l & (1<<16))) {
  337. l |= (1<<16);
  338. dprintk("trying to enable Enhanced SpeedStep (%x)\n", l);
  339. wrmsr(MSR_IA32_MISC_ENABLE, l, h);
  340. /* check to see if it stuck */
  341. rdmsr(MSR_IA32_MISC_ENABLE, l, h);
  342. if (!(l & (1<<16))) {
  343. printk(KERN_INFO PFX
  344. "couldn't enable Enhanced SpeedStep\n");
  345. return -ENODEV;
  346. }
  347. }
  348. freq = get_cur_freq(policy->cpu);
  349. policy->cpuinfo.transition_latency = 10000;
  350. /* 10uS transition latency */
  351. policy->cur = freq;
  352. dprintk("centrino_cpu_init: cur=%dkHz\n", policy->cur);
  353. ret = cpufreq_frequency_table_cpuinfo(policy,
  354. per_cpu(centrino_model, policy->cpu)->op_points);
  355. if (ret)
  356. return (ret);
  357. cpufreq_frequency_table_get_attr(
  358. per_cpu(centrino_model, policy->cpu)->op_points, policy->cpu);
  359. return 0;
  360. }
  361. static int centrino_cpu_exit(struct cpufreq_policy *policy)
  362. {
  363. unsigned int cpu = policy->cpu;
  364. if (!per_cpu(centrino_model, cpu))
  365. return -ENODEV;
  366. cpufreq_frequency_table_put_attr(cpu);
  367. per_cpu(centrino_model, cpu) = NULL;
  368. return 0;
  369. }
  370. /**
  371. * centrino_verify - verifies a new CPUFreq policy
  372. * @policy: new policy
  373. *
  374. * Limit must be within this model's frequency range at least one
  375. * border included.
  376. */
  377. static int centrino_verify (struct cpufreq_policy *policy)
  378. {
  379. return cpufreq_frequency_table_verify(policy,
  380. per_cpu(centrino_model, policy->cpu)->op_points);
  381. }
  382. /**
  383. * centrino_setpolicy - set a new CPUFreq policy
  384. * @policy: new policy
  385. * @target_freq: the target frequency
  386. * @relation: how that frequency relates to achieved frequency
  387. * (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
  388. *
  389. * Sets a new CPUFreq policy.
  390. */
  391. struct allmasks {
  392. cpumask_t online_policy_cpus;
  393. cpumask_t saved_mask;
  394. cpumask_t set_mask;
  395. cpumask_t covered_cpus;
  396. };
  397. static int centrino_target (struct cpufreq_policy *policy,
  398. unsigned int target_freq,
  399. unsigned int relation)
  400. {
  401. unsigned int newstate = 0;
  402. unsigned int msr, oldmsr = 0, h = 0, cpu = policy->cpu;
  403. struct cpufreq_freqs freqs;
  404. int retval = 0;
  405. unsigned int j, k, first_cpu, tmp;
  406. CPUMASK_ALLOC(allmasks);
  407. CPUMASK_PTR(online_policy_cpus, allmasks);
  408. CPUMASK_PTR(saved_mask, allmasks);
  409. CPUMASK_PTR(set_mask, allmasks);
  410. CPUMASK_PTR(covered_cpus, allmasks);
  411. if (unlikely(allmasks == NULL))
  412. return -ENOMEM;
  413. if (unlikely(per_cpu(centrino_model, cpu) == NULL)) {
  414. retval = -ENODEV;
  415. goto out;
  416. }
  417. if (unlikely(cpufreq_frequency_table_target(policy,
  418. per_cpu(centrino_model, cpu)->op_points,
  419. target_freq,
  420. relation,
  421. &newstate))) {
  422. retval = -EINVAL;
  423. goto out;
  424. }
  425. #ifdef CONFIG_HOTPLUG_CPU
  426. /* cpufreq holds the hotplug lock, so we are safe from here on */
  427. cpus_and(*online_policy_cpus, cpu_online_map, policy->cpus);
  428. #else
  429. *online_policy_cpus = policy->cpus;
  430. #endif
  431. *saved_mask = current->cpus_allowed;
  432. first_cpu = 1;
  433. cpus_clear(*covered_cpus);
  434. for_each_cpu_mask_nr(j, *online_policy_cpus) {
  435. /*
  436. * Support for SMP systems.
  437. * Make sure we are running on CPU that wants to change freq
  438. */
  439. cpus_clear(*set_mask);
  440. if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
  441. cpus_or(*set_mask, *set_mask, *online_policy_cpus);
  442. else
  443. cpu_set(j, *set_mask);
  444. set_cpus_allowed_ptr(current, set_mask);
  445. preempt_disable();
  446. if (unlikely(!cpu_isset(smp_processor_id(), *set_mask))) {
  447. dprintk("couldn't limit to CPUs in this domain\n");
  448. retval = -EAGAIN;
  449. if (first_cpu) {
  450. /* We haven't started the transition yet. */
  451. goto migrate_end;
  452. }
  453. preempt_enable();
  454. break;
  455. }
  456. msr = per_cpu(centrino_model, cpu)->op_points[newstate].index;
  457. if (first_cpu) {
  458. rdmsr(MSR_IA32_PERF_CTL, oldmsr, h);
  459. if (msr == (oldmsr & 0xffff)) {
  460. dprintk("no change needed - msr was and needs "
  461. "to be %x\n", oldmsr);
  462. retval = 0;
  463. goto migrate_end;
  464. }
  465. freqs.old = extract_clock(oldmsr, cpu, 0);
  466. freqs.new = extract_clock(msr, cpu, 0);
  467. dprintk("target=%dkHz old=%d new=%d msr=%04x\n",
  468. target_freq, freqs.old, freqs.new, msr);
  469. for_each_cpu_mask_nr(k, *online_policy_cpus) {
  470. freqs.cpu = k;
  471. cpufreq_notify_transition(&freqs,
  472. CPUFREQ_PRECHANGE);
  473. }
  474. first_cpu = 0;
  475. /* all but 16 LSB are reserved, treat them with care */
  476. oldmsr &= ~0xffff;
  477. msr &= 0xffff;
  478. oldmsr |= msr;
  479. }
  480. wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
  481. if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) {
  482. preempt_enable();
  483. break;
  484. }
  485. cpu_set(j, *covered_cpus);
  486. preempt_enable();
  487. }
  488. for_each_cpu_mask_nr(k, *online_policy_cpus) {
  489. freqs.cpu = k;
  490. cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
  491. }
  492. if (unlikely(retval)) {
  493. /*
  494. * We have failed halfway through the frequency change.
  495. * We have sent callbacks to policy->cpus and
  496. * MSRs have already been written on coverd_cpus.
  497. * Best effort undo..
  498. */
  499. if (!cpus_empty(*covered_cpus)) {
  500. cpumask_of_cpu_ptr_declare(new_mask);
  501. for_each_cpu_mask_nr(j, *covered_cpus) {
  502. cpumask_of_cpu_ptr_next(new_mask, j);
  503. set_cpus_allowed_ptr(current, new_mask);
  504. wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
  505. }
  506. }
  507. tmp = freqs.new;
  508. freqs.new = freqs.old;
  509. freqs.old = tmp;
  510. for_each_cpu_mask_nr(j, *online_policy_cpus) {
  511. freqs.cpu = j;
  512. cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
  513. cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
  514. }
  515. }
  516. set_cpus_allowed_ptr(current, saved_mask);
  517. retval = 0;
  518. goto out;
  519. migrate_end:
  520. preempt_enable();
  521. set_cpus_allowed_ptr(current, saved_mask);
  522. out:
  523. CPUMASK_FREE(allmasks);
  524. return retval;
  525. }
  526. static struct freq_attr* centrino_attr[] = {
  527. &cpufreq_freq_attr_scaling_available_freqs,
  528. NULL,
  529. };
  530. static struct cpufreq_driver centrino_driver = {
  531. .name = "centrino", /* should be speedstep-centrino,
  532. but there's a 16 char limit */
  533. .init = centrino_cpu_init,
  534. .exit = centrino_cpu_exit,
  535. .verify = centrino_verify,
  536. .target = centrino_target,
  537. .get = get_cur_freq,
  538. .attr = centrino_attr,
  539. .owner = THIS_MODULE,
  540. };
  541. /**
  542. * centrino_init - initializes the Enhanced SpeedStep CPUFreq driver
  543. *
  544. * Initializes the Enhanced SpeedStep support. Returns -ENODEV on
  545. * unsupported devices, -ENOENT if there's no voltage table for this
  546. * particular CPU model, -EINVAL on problems during initiatization,
  547. * and zero on success.
  548. *
  549. * This is quite picky. Not only does the CPU have to advertise the
  550. * "est" flag in the cpuid capability flags, we look for a specific
  551. * CPU model and stepping, and we need to have the exact model name in
  552. * our voltage tables. That is, be paranoid about not releasing
  553. * someone's valuable magic smoke.
  554. */
  555. static int __init centrino_init(void)
  556. {
  557. struct cpuinfo_x86 *cpu = &cpu_data(0);
  558. if (!cpu_has(cpu, X86_FEATURE_EST))
  559. return -ENODEV;
  560. return cpufreq_register_driver(&centrino_driver);
  561. }
  562. static void __exit centrino_exit(void)
  563. {
  564. cpufreq_unregister_driver(&centrino_driver);
  565. }
  566. MODULE_AUTHOR ("Jeremy Fitzhardinge <jeremy@goop.org>");
  567. MODULE_DESCRIPTION ("Enhanced SpeedStep driver for Intel Pentium M processors.");
  568. MODULE_LICENSE ("GPL");
  569. late_initcall(centrino_init);
  570. module_exit(centrino_exit);