pmac32-cpufreq.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2002 - 2005 Benjamin Herrenschmidt <[email protected]>
  4. * Copyright (C) 2004 John Steele Scott <[email protected]>
  5. *
  6. * TODO: Need a big cleanup here. Basically, we need to have different
  7. * cpufreq_driver structures for the different type of HW instead of the
  8. * current mess. We also need to better deal with the detection of the
  9. * type of machine.
  10. */
  11. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  12. #include <linux/module.h>
  13. #include <linux/types.h>
  14. #include <linux/errno.h>
  15. #include <linux/kernel.h>
  16. #include <linux/delay.h>
  17. #include <linux/sched.h>
  18. #include <linux/adb.h>
  19. #include <linux/pmu.h>
  20. #include <linux/cpufreq.h>
  21. #include <linux/init.h>
  22. #include <linux/device.h>
  23. #include <linux/hardirq.h>
  24. #include <linux/of_device.h>
  25. #include <asm/machdep.h>
  26. #include <asm/irq.h>
  27. #include <asm/pmac_feature.h>
  28. #include <asm/mmu_context.h>
  29. #include <asm/sections.h>
  30. #include <asm/cputable.h>
  31. #include <asm/time.h>
  32. #include <asm/mpic.h>
  33. #include <asm/keylargo.h>
  34. #include <asm/switch_to.h>
  35. /* WARNING !!! This will cause calibrate_delay() to be called,
  36. * but this is an __init function ! So you MUST go edit
  37. * init/main.c to make it non-init before enabling DEBUG_FREQ
  38. */
  39. #undef DEBUG_FREQ
  40. extern void low_choose_7447a_dfs(int dfs);
  41. extern void low_choose_750fx_pll(int pll);
  42. extern void low_sleep_handler(void);
  43. /*
  44. * Currently, PowerMac cpufreq supports only high & low frequencies
  45. * that are set by the firmware
  46. */
  47. static unsigned int low_freq;
  48. static unsigned int hi_freq;
  49. static unsigned int cur_freq;
  50. static unsigned int sleep_freq;
  51. static unsigned long transition_latency;
  52. /*
  53. * Different models uses different mechanisms to switch the frequency
  54. */
  55. static int (*set_speed_proc)(int low_speed);
  56. static unsigned int (*get_speed_proc)(void);
  57. /*
  58. * Some definitions used by the various speedprocs
  59. */
  60. static u32 voltage_gpio;
  61. static u32 frequency_gpio;
  62. static u32 slew_done_gpio;
  63. static int no_schedule;
  64. static int has_cpu_l2lve;
  65. static int is_pmu_based;
  66. /* There are only two frequency states for each processor. Values
  67. * are in kHz for the time being.
  68. */
  69. #define CPUFREQ_HIGH 0
  70. #define CPUFREQ_LOW 1
  71. static struct cpufreq_frequency_table pmac_cpu_freqs[] = {
  72. {0, CPUFREQ_HIGH, 0},
  73. {0, CPUFREQ_LOW, 0},
  74. {0, 0, CPUFREQ_TABLE_END},
  75. };
  76. static inline void local_delay(unsigned long ms)
  77. {
  78. if (no_schedule)
  79. mdelay(ms);
  80. else
  81. msleep(ms);
  82. }
  83. #ifdef DEBUG_FREQ
  84. static inline void debug_calc_bogomips(void)
  85. {
  86. /* This will cause a recalc of bogomips and display the
  87. * result. We backup/restore the value to avoid affecting the
  88. * core cpufreq framework's own calculation.
  89. */
  90. unsigned long save_lpj = loops_per_jiffy;
  91. calibrate_delay();
  92. loops_per_jiffy = save_lpj;
  93. }
  94. #endif /* DEBUG_FREQ */
  95. /* Switch CPU speed under 750FX CPU control
  96. */
  97. static int cpu_750fx_cpu_speed(int low_speed)
  98. {
  99. u32 hid2;
  100. if (low_speed == 0) {
  101. /* ramping up, set voltage first */
  102. pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, voltage_gpio, 0x05);
  103. /* Make sure we sleep for at least 1ms */
  104. local_delay(10);
  105. /* tweak L2 for high voltage */
  106. if (has_cpu_l2lve) {
  107. hid2 = mfspr(SPRN_HID2);
  108. hid2 &= ~0x2000;
  109. mtspr(SPRN_HID2, hid2);
  110. }
  111. }
  112. #ifdef CONFIG_PPC_BOOK3S_32
  113. low_choose_750fx_pll(low_speed);
  114. #endif
  115. if (low_speed == 1) {
  116. /* tweak L2 for low voltage */
  117. if (has_cpu_l2lve) {
  118. hid2 = mfspr(SPRN_HID2);
  119. hid2 |= 0x2000;
  120. mtspr(SPRN_HID2, hid2);
  121. }
  122. /* ramping down, set voltage last */
  123. pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, voltage_gpio, 0x04);
  124. local_delay(10);
  125. }
  126. return 0;
  127. }
  128. static unsigned int cpu_750fx_get_cpu_speed(void)
  129. {
  130. if (mfspr(SPRN_HID1) & HID1_PS)
  131. return low_freq;
  132. else
  133. return hi_freq;
  134. }
  135. /* Switch CPU speed using DFS */
  136. static int dfs_set_cpu_speed(int low_speed)
  137. {
  138. if (low_speed == 0) {
  139. /* ramping up, set voltage first */
  140. pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, voltage_gpio, 0x05);
  141. /* Make sure we sleep for at least 1ms */
  142. local_delay(1);
  143. }
  144. /* set frequency */
  145. #ifdef CONFIG_PPC_BOOK3S_32
  146. low_choose_7447a_dfs(low_speed);
  147. #endif
  148. udelay(100);
  149. if (low_speed == 1) {
  150. /* ramping down, set voltage last */
  151. pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, voltage_gpio, 0x04);
  152. local_delay(1);
  153. }
  154. return 0;
  155. }
  156. static unsigned int dfs_get_cpu_speed(void)
  157. {
  158. if (mfspr(SPRN_HID1) & HID1_DFS)
  159. return low_freq;
  160. else
  161. return hi_freq;
  162. }
  163. /* Switch CPU speed using slewing GPIOs
  164. */
  165. static int gpios_set_cpu_speed(int low_speed)
  166. {
  167. int gpio, timeout = 0;
  168. /* If ramping up, set voltage first */
  169. if (low_speed == 0) {
  170. pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, voltage_gpio, 0x05);
  171. /* Delay is way too big but it's ok, we schedule */
  172. local_delay(10);
  173. }
  174. /* Set frequency */
  175. gpio = pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, frequency_gpio, 0);
  176. if (low_speed == ((gpio & 0x01) == 0))
  177. goto skip;
  178. pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, frequency_gpio,
  179. low_speed ? 0x04 : 0x05);
  180. udelay(200);
  181. do {
  182. if (++timeout > 100)
  183. break;
  184. local_delay(1);
  185. gpio = pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, slew_done_gpio, 0);
  186. } while((gpio & 0x02) == 0);
  187. skip:
  188. /* If ramping down, set voltage last */
  189. if (low_speed == 1) {
  190. pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, voltage_gpio, 0x04);
  191. /* Delay is way too big but it's ok, we schedule */
  192. local_delay(10);
  193. }
  194. #ifdef DEBUG_FREQ
  195. debug_calc_bogomips();
  196. #endif
  197. return 0;
  198. }
  199. /* Switch CPU speed under PMU control
  200. */
  201. static int pmu_set_cpu_speed(int low_speed)
  202. {
  203. struct adb_request req;
  204. unsigned long save_l2cr;
  205. unsigned long save_l3cr;
  206. unsigned int pic_prio;
  207. unsigned long flags;
  208. preempt_disable();
  209. #ifdef DEBUG_FREQ
  210. printk(KERN_DEBUG "HID1, before: %x\n", mfspr(SPRN_HID1));
  211. #endif
  212. pmu_suspend();
  213. /* Disable all interrupt sources on openpic */
  214. pic_prio = mpic_cpu_get_priority();
  215. mpic_cpu_set_priority(0xf);
  216. /* Make sure the decrementer won't interrupt us */
  217. asm volatile("mtdec %0" : : "r" (0x7fffffff));
  218. /* Make sure any pending DEC interrupt occurring while we did
  219. * the above didn't re-enable the DEC */
  220. mb();
  221. asm volatile("mtdec %0" : : "r" (0x7fffffff));
  222. /* We can now disable MSR_EE */
  223. local_irq_save(flags);
  224. /* Giveup the FPU & vec */
  225. enable_kernel_fp();
  226. #ifdef CONFIG_ALTIVEC
  227. if (cpu_has_feature(CPU_FTR_ALTIVEC))
  228. enable_kernel_altivec();
  229. #endif /* CONFIG_ALTIVEC */
  230. /* Save & disable L2 and L3 caches */
  231. save_l3cr = _get_L3CR(); /* (returns -1 if not available) */
  232. save_l2cr = _get_L2CR(); /* (returns -1 if not available) */
  233. /* Send the new speed command. My assumption is that this command
  234. * will cause PLL_CFG[0..3] to be changed next time CPU goes to sleep
  235. */
  236. pmu_request(&req, NULL, 6, PMU_CPU_SPEED, 'W', 'O', 'O', 'F', low_speed);
  237. while (!req.complete)
  238. pmu_poll();
  239. /* Prepare the northbridge for the speed transition */
  240. pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,1);
  241. /* Call low level code to backup CPU state and recover from
  242. * hardware reset
  243. */
  244. low_sleep_handler();
  245. /* Restore the northbridge */
  246. pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,0);
  247. /* Restore L2 cache */
  248. if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
  249. _set_L2CR(save_l2cr);
  250. /* Restore L3 cache */
  251. if (save_l3cr != 0xffffffff && (save_l3cr & L3CR_L3E) != 0)
  252. _set_L3CR(save_l3cr);
  253. /* Restore userland MMU context */
  254. switch_mmu_context(NULL, current->active_mm, NULL);
  255. #ifdef DEBUG_FREQ
  256. printk(KERN_DEBUG "HID1, after: %x\n", mfspr(SPRN_HID1));
  257. #endif
  258. /* Restore low level PMU operations */
  259. pmu_unlock();
  260. /*
  261. * Restore decrementer; we'll take a decrementer interrupt
  262. * as soon as interrupts are re-enabled and the generic
  263. * clockevents code will reprogram it with the right value.
  264. */
  265. set_dec(1);
  266. /* Restore interrupts */
  267. mpic_cpu_set_priority(pic_prio);
  268. /* Let interrupts flow again ... */
  269. local_irq_restore(flags);
  270. #ifdef DEBUG_FREQ
  271. debug_calc_bogomips();
  272. #endif
  273. pmu_resume();
  274. preempt_enable();
  275. return 0;
  276. }
  277. static int do_set_cpu_speed(struct cpufreq_policy *policy, int speed_mode)
  278. {
  279. unsigned long l3cr;
  280. static unsigned long prev_l3cr;
  281. if (speed_mode == CPUFREQ_LOW &&
  282. cpu_has_feature(CPU_FTR_L3CR)) {
  283. l3cr = _get_L3CR();
  284. if (l3cr & L3CR_L3E) {
  285. prev_l3cr = l3cr;
  286. _set_L3CR(0);
  287. }
  288. }
  289. set_speed_proc(speed_mode == CPUFREQ_LOW);
  290. if (speed_mode == CPUFREQ_HIGH &&
  291. cpu_has_feature(CPU_FTR_L3CR)) {
  292. l3cr = _get_L3CR();
  293. if ((prev_l3cr & L3CR_L3E) && l3cr != prev_l3cr)
  294. _set_L3CR(prev_l3cr);
  295. }
  296. cur_freq = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq;
  297. return 0;
  298. }
  299. static unsigned int pmac_cpufreq_get_speed(unsigned int cpu)
  300. {
  301. return cur_freq;
  302. }
  303. static int pmac_cpufreq_target( struct cpufreq_policy *policy,
  304. unsigned int index)
  305. {
  306. int rc;
  307. rc = do_set_cpu_speed(policy, index);
  308. ppc_proc_freq = cur_freq * 1000ul;
  309. return rc;
  310. }
  311. static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy)
  312. {
  313. cpufreq_generic_init(policy, pmac_cpu_freqs, transition_latency);
  314. return 0;
  315. }
  316. static u32 read_gpio(struct device_node *np)
  317. {
  318. const u32 *reg = of_get_property(np, "reg", NULL);
  319. u32 offset;
  320. if (reg == NULL)
  321. return 0;
  322. /* That works for all keylargos but shall be fixed properly
  323. * some day... The problem is that it seems we can't rely
  324. * on the "reg" property of the GPIO nodes, they are either
  325. * relative to the base of KeyLargo or to the base of the
  326. * GPIO space, and the device-tree doesn't help.
  327. */
  328. offset = *reg;
  329. if (offset < KEYLARGO_GPIO_LEVELS0)
  330. offset += KEYLARGO_GPIO_LEVELS0;
  331. return offset;
  332. }
  333. static int pmac_cpufreq_suspend(struct cpufreq_policy *policy)
  334. {
  335. /* Ok, this could be made a bit smarter, but let's be robust for now. We
  336. * always force a speed change to high speed before sleep, to make sure
  337. * we have appropriate voltage and/or bus speed for the wakeup process,
  338. * and to make sure our loops_per_jiffies are "good enough", that is will
  339. * not cause too short delays if we sleep in low speed and wake in high
  340. * speed..
  341. */
  342. no_schedule = 1;
  343. sleep_freq = cur_freq;
  344. if (cur_freq == low_freq && !is_pmu_based)
  345. do_set_cpu_speed(policy, CPUFREQ_HIGH);
  346. return 0;
  347. }
  348. static int pmac_cpufreq_resume(struct cpufreq_policy *policy)
  349. {
  350. /* If we resume, first check if we have a get() function */
  351. if (get_speed_proc)
  352. cur_freq = get_speed_proc();
  353. else
  354. cur_freq = 0;
  355. /* We don't, hrm... we don't really know our speed here, best
  356. * is that we force a switch to whatever it was, which is
  357. * probably high speed due to our suspend() routine
  358. */
  359. do_set_cpu_speed(policy, sleep_freq == low_freq ?
  360. CPUFREQ_LOW : CPUFREQ_HIGH);
  361. ppc_proc_freq = cur_freq * 1000ul;
  362. no_schedule = 0;
  363. return 0;
  364. }
  365. static struct cpufreq_driver pmac_cpufreq_driver = {
  366. .verify = cpufreq_generic_frequency_table_verify,
  367. .target_index = pmac_cpufreq_target,
  368. .get = pmac_cpufreq_get_speed,
  369. .init = pmac_cpufreq_cpu_init,
  370. .suspend = pmac_cpufreq_suspend,
  371. .resume = pmac_cpufreq_resume,
  372. .flags = CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
  373. .attr = cpufreq_generic_attr,
  374. .name = "powermac",
  375. };
  376. static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode)
  377. {
  378. struct device_node *volt_gpio_np = of_find_node_by_name(NULL,
  379. "voltage-gpio");
  380. struct device_node *freq_gpio_np = of_find_node_by_name(NULL,
  381. "frequency-gpio");
  382. struct device_node *slew_done_gpio_np = of_find_node_by_name(NULL,
  383. "slewing-done");
  384. const u32 *value;
  385. /*
  386. * Check to see if it's GPIO driven or PMU only
  387. *
  388. * The way we extract the GPIO address is slightly hackish, but it
  389. * works well enough for now. We need to abstract the whole GPIO
  390. * stuff sooner or later anyway
  391. */
  392. if (volt_gpio_np)
  393. voltage_gpio = read_gpio(volt_gpio_np);
  394. if (freq_gpio_np)
  395. frequency_gpio = read_gpio(freq_gpio_np);
  396. if (slew_done_gpio_np)
  397. slew_done_gpio = read_gpio(slew_done_gpio_np);
  398. of_node_put(volt_gpio_np);
  399. of_node_put(freq_gpio_np);
  400. of_node_put(slew_done_gpio_np);
  401. /* If we use the frequency GPIOs, calculate the min/max speeds based
  402. * on the bus frequencies
  403. */
  404. if (frequency_gpio && slew_done_gpio) {
  405. int lenp, rc;
  406. const u32 *freqs, *ratio;
  407. freqs = of_get_property(cpunode, "bus-frequencies", &lenp);
  408. lenp /= sizeof(u32);
  409. if (freqs == NULL || lenp != 2) {
  410. pr_err("bus-frequencies incorrect or missing\n");
  411. return 1;
  412. }
  413. ratio = of_get_property(cpunode, "processor-to-bus-ratio*2",
  414. NULL);
  415. if (ratio == NULL) {
  416. pr_err("processor-to-bus-ratio*2 missing\n");
  417. return 1;
  418. }
  419. /* Get the min/max bus frequencies */
  420. low_freq = min(freqs[0], freqs[1]);
  421. hi_freq = max(freqs[0], freqs[1]);
  422. /* Grrrr.. It _seems_ that the device-tree is lying on the low bus
  423. * frequency, it claims it to be around 84Mhz on some models while
  424. * it appears to be approx. 101Mhz on all. Let's hack around here...
  425. * fortunately, we don't need to be too precise
  426. */
  427. if (low_freq < 98000000)
  428. low_freq = 101000000;
  429. /* Convert those to CPU core clocks */
  430. low_freq = (low_freq * (*ratio)) / 2000;
  431. hi_freq = (hi_freq * (*ratio)) / 2000;
  432. /* Now we get the frequencies, we read the GPIO to see what is out current
  433. * speed
  434. */
  435. rc = pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, frequency_gpio, 0);
  436. cur_freq = (rc & 0x01) ? hi_freq : low_freq;
  437. set_speed_proc = gpios_set_cpu_speed;
  438. return 1;
  439. }
  440. /* If we use the PMU, look for the min & max frequencies in the
  441. * device-tree
  442. */
  443. value = of_get_property(cpunode, "min-clock-frequency", NULL);
  444. if (!value)
  445. return 1;
  446. low_freq = (*value) / 1000;
  447. /* The PowerBook G4 12" (PowerBook6,1) has an error in the device-tree
  448. * here */
  449. if (low_freq < 100000)
  450. low_freq *= 10;
  451. value = of_get_property(cpunode, "max-clock-frequency", NULL);
  452. if (!value)
  453. return 1;
  454. hi_freq = (*value) / 1000;
  455. set_speed_proc = pmu_set_cpu_speed;
  456. is_pmu_based = 1;
  457. return 0;
  458. }
  459. static int pmac_cpufreq_init_7447A(struct device_node *cpunode)
  460. {
  461. struct device_node *volt_gpio_np;
  462. if (of_get_property(cpunode, "dynamic-power-step", NULL) == NULL)
  463. return 1;
  464. volt_gpio_np = of_find_node_by_name(NULL, "cpu-vcore-select");
  465. if (volt_gpio_np)
  466. voltage_gpio = read_gpio(volt_gpio_np);
  467. of_node_put(volt_gpio_np);
  468. if (!voltage_gpio){
  469. pr_err("missing cpu-vcore-select gpio\n");
  470. return 1;
  471. }
  472. /* OF only reports the high frequency */
  473. hi_freq = cur_freq;
  474. low_freq = cur_freq/2;
  475. /* Read actual frequency from CPU */
  476. cur_freq = dfs_get_cpu_speed();
  477. set_speed_proc = dfs_set_cpu_speed;
  478. get_speed_proc = dfs_get_cpu_speed;
  479. return 0;
  480. }
  481. static int pmac_cpufreq_init_750FX(struct device_node *cpunode)
  482. {
  483. struct device_node *volt_gpio_np;
  484. u32 pvr;
  485. const u32 *value;
  486. if (of_get_property(cpunode, "dynamic-power-step", NULL) == NULL)
  487. return 1;
  488. hi_freq = cur_freq;
  489. value = of_get_property(cpunode, "reduced-clock-frequency", NULL);
  490. if (!value)
  491. return 1;
  492. low_freq = (*value) / 1000;
  493. volt_gpio_np = of_find_node_by_name(NULL, "cpu-vcore-select");
  494. if (volt_gpio_np)
  495. voltage_gpio = read_gpio(volt_gpio_np);
  496. of_node_put(volt_gpio_np);
  497. pvr = mfspr(SPRN_PVR);
  498. has_cpu_l2lve = !((pvr & 0xf00) == 0x100);
  499. set_speed_proc = cpu_750fx_cpu_speed;
  500. get_speed_proc = cpu_750fx_get_cpu_speed;
  501. cur_freq = cpu_750fx_get_cpu_speed();
  502. return 0;
  503. }
  504. /* Currently, we support the following machines:
  505. *
  506. * - Titanium PowerBook 1Ghz (PMU based, 667Mhz & 1Ghz)
  507. * - Titanium PowerBook 800 (PMU based, 667Mhz & 800Mhz)
  508. * - Titanium PowerBook 400 (PMU based, 300Mhz & 400Mhz)
  509. * - Titanium PowerBook 500 (PMU based, 300Mhz & 500Mhz)
  510. * - iBook2 500/600 (PMU based, 400Mhz & 500/600Mhz)
  511. * - iBook2 700 (CPU based, 400Mhz & 700Mhz, support low voltage)
  512. * - Recent MacRISC3 laptops
  513. * - All new machines with 7447A CPUs
  514. */
  515. static int __init pmac_cpufreq_setup(void)
  516. {
  517. struct device_node *cpunode;
  518. const u32 *value;
  519. if (strstr(boot_command_line, "nocpufreq"))
  520. return 0;
  521. /* Get first CPU node */
  522. cpunode = of_cpu_device_node_get(0);
  523. if (!cpunode)
  524. goto out;
  525. /* Get current cpu clock freq */
  526. value = of_get_property(cpunode, "clock-frequency", NULL);
  527. if (!value)
  528. goto out;
  529. cur_freq = (*value) / 1000;
  530. /* Check for 7447A based MacRISC3 */
  531. if (of_machine_is_compatible("MacRISC3") &&
  532. of_get_property(cpunode, "dynamic-power-step", NULL) &&
  533. PVR_VER(mfspr(SPRN_PVR)) == 0x8003) {
  534. pmac_cpufreq_init_7447A(cpunode);
  535. /* Allow dynamic switching */
  536. transition_latency = 8000000;
  537. pmac_cpufreq_driver.flags &= ~CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING;
  538. /* Check for other MacRISC3 machines */
  539. } else if (of_machine_is_compatible("PowerBook3,4") ||
  540. of_machine_is_compatible("PowerBook3,5") ||
  541. of_machine_is_compatible("MacRISC3")) {
  542. pmac_cpufreq_init_MacRISC3(cpunode);
  543. /* Else check for iBook2 500/600 */
  544. } else if (of_machine_is_compatible("PowerBook4,1")) {
  545. hi_freq = cur_freq;
  546. low_freq = 400000;
  547. set_speed_proc = pmu_set_cpu_speed;
  548. is_pmu_based = 1;
  549. }
  550. /* Else check for TiPb 550 */
  551. else if (of_machine_is_compatible("PowerBook3,3") && cur_freq == 550000) {
  552. hi_freq = cur_freq;
  553. low_freq = 500000;
  554. set_speed_proc = pmu_set_cpu_speed;
  555. is_pmu_based = 1;
  556. }
  557. /* Else check for TiPb 400 & 500 */
  558. else if (of_machine_is_compatible("PowerBook3,2")) {
  559. /* We only know about the 400 MHz and the 500Mhz model
  560. * they both have 300 MHz as low frequency
  561. */
  562. if (cur_freq < 350000 || cur_freq > 550000)
  563. goto out;
  564. hi_freq = cur_freq;
  565. low_freq = 300000;
  566. set_speed_proc = pmu_set_cpu_speed;
  567. is_pmu_based = 1;
  568. }
  569. /* Else check for 750FX */
  570. else if (PVR_VER(mfspr(SPRN_PVR)) == 0x7000)
  571. pmac_cpufreq_init_750FX(cpunode);
  572. out:
  573. of_node_put(cpunode);
  574. if (set_speed_proc == NULL)
  575. return -ENODEV;
  576. pmac_cpu_freqs[CPUFREQ_LOW].frequency = low_freq;
  577. pmac_cpu_freqs[CPUFREQ_HIGH].frequency = hi_freq;
  578. ppc_proc_freq = cur_freq * 1000ul;
  579. pr_info("Registering PowerMac CPU frequency driver\n");
  580. pr_info("Low: %d Mhz, High: %d Mhz, Boot: %d Mhz\n",
  581. low_freq/1000, hi_freq/1000, cur_freq/1000);
  582. return cpufreq_register_driver(&pmac_cpufreq_driver);
  583. }
  584. module_init(pmac_cpufreq_setup);