Skip to content

Commit 4350147

Browse files
ozbenhpaulusmack
authored andcommitted
[PATCH] ppc64: SMU based macs cpufreq support
CPU freq support using 970FX powertune facility for iMac G5 and SMU based single CPU desktop. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent a82765b commit 4350147

11 files changed

Lines changed: 572 additions & 25 deletions

File tree

‎arch/powerpc/Kconfig‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,14 @@ config CPU_FREQ_PMAC
404404
this currently includes some models of iBook & Titanium
405405
PowerBook.
406406

407+
config CPU_FREQ_PMAC64
408+
bool "Support for some Apple G5s"
409+
depends on CPU_FREQ && PMAC_SMU && PPC64
410+
select CPU_FREQ_TABLE
411+
help
412+
This adds support for frequency switching on Apple iMac G5,
413+
and some of the more recent desktop G5 machines as well.
414+
407415
config PPC601_SYNC_FIX
408416
bool "Workarounds for PPC601 bugs"
409417
depends on 6xx && (PPC_PREP || PPC_PMAC)

‎arch/powerpc/kernel/misc_64.S‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,76 @@ _GLOBAL(real_writeb)
603603
blr
604604
#endif /* defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) */
605605

606+
/*
607+
* SCOM access functions for 970 (FX only for now)
608+
*
609+
* unsigned long scom970_read(unsigned int address);
610+
* void scom970_write(unsigned int address, unsigned long value);
611+
*
612+
* The address passed in is the 24 bits register address. This code
613+
* is 970 specific and will not check the status bits, so you should
614+
* know what you are doing.
615+
*/
616+
_GLOBAL(scom970_read)
617+
/* interrupts off */
618+
mfmsr r4
619+
ori r0,r4,MSR_EE
620+
xori r0,r0,MSR_EE
621+
mtmsrd r0,1
622+
623+
/* rotate 24 bits SCOM address 8 bits left and mask out it's low 8 bits
624+
* (including parity). On current CPUs they must be 0'd,
625+
* and finally or in RW bit
626+
*/
627+
rlwinm r3,r3,8,0,15
628+
ori r3,r3,0x8000
629+
630+
/* do the actual scom read */
631+
sync
632+
mtspr SPRN_SCOMC,r3
633+
isync
634+
mfspr r3,SPRN_SCOMD
635+
isync
636+
mfspr r0,SPRN_SCOMC
637+
isync
638+
639+
/* XXX: fixup result on some buggy 970's (ouch ! we lost a bit, bah
640+
* that's the best we can do). Not implemented yet as we don't use
641+
* the scom on any of the bogus CPUs yet, but may have to be done
642+
* ultimately
643+
*/
644+
645+
/* restore interrupts */
646+
mtmsrd r4,1
647+
blr
648+
649+
650+
_GLOBAL(scom970_write)
651+
/* interrupts off */
652+
mfmsr r5
653+
ori r0,r5,MSR_EE
654+
xori r0,r0,MSR_EE
655+
mtmsrd r0,1
656+
657+
/* rotate 24 bits SCOM address 8 bits left and mask out it's low 8 bits
658+
* (including parity). On current CPUs they must be 0'd.
659+
*/
660+
661+
rlwinm r3,r3,8,0,15
662+
663+
sync
664+
mtspr SPRN_SCOMD,r4 /* write data */
665+
isync
666+
mtspr SPRN_SCOMC,r3 /* write command */
667+
isync
668+
mfspr 3,SPRN_SCOMC
669+
isync
670+
671+
/* restore interrupts */
672+
mtmsrd r5,1
673+
blr
674+
675+
606676
/*
607677
* Create a kernel thread
608678
* kernel_thread(fn, arg, flags)

‎arch/powerpc/platforms/powermac/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
obj-y += pic.o setup.o time.o feature.o pci.o \
22
sleep.o low_i2c.o cache.o
33
obj-$(CONFIG_PMAC_BACKLIGHT) += backlight.o
4-
obj-$(CONFIG_CPU_FREQ_PMAC) += cpufreq.o
4+
obj-$(CONFIG_CPU_FREQ_PMAC) += cpufreq_32.o
5+
obj-$(CONFIG_CPU_FREQ_PMAC64) += cpufreq_64.o
56
obj-$(CONFIG_NVRAM) += nvram.o
67
# ppc64 pmac doesn't define CONFIG_NVRAM but needs nvram stuff
78
obj-$(CONFIG_PPC64) += nvram.o

arch/powerpc/platforms/powermac/cpufreq.c renamed to arch/powerpc/platforms/powermac/cpufreq_32.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,18 +397,16 @@ static int pmac_cpufreq_target( struct cpufreq_policy *policy,
397397
unsigned int relation)
398398
{
399399
unsigned int newstate = 0;
400+
int rc;
400401

401402
if (cpufreq_frequency_table_target(policy, pmac_cpu_freqs,
402403
target_freq, relation, &newstate))
403404
return -EINVAL;
404405

405-
return do_set_cpu_speed(newstate, 1);
406-
}
406+
rc = do_set_cpu_speed(newstate, 1);
407407

408-
unsigned int pmac_get_one_cpufreq(int i)
409-
{
410-
/* Supports only one CPU for now */
411-
return (i == 0) ? cur_freq : 0;
408+
ppc_proc_freq = cur_freq * 1000ul;
409+
return rc;
412410
}
413411

414412
static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy)
@@ -464,7 +462,7 @@ static int pmac_cpufreq_resume(struct cpufreq_policy *policy)
464462
/* If we resume, first check if we have a get() function */
465463
if (get_speed_proc)
466464
cur_freq = get_speed_proc();
467-
else
465+
else)
468466
cur_freq = 0;
469467

470468
/* We don't, hrm... we don't really know our speed here, best
@@ -474,6 +472,8 @@ static int pmac_cpufreq_resume(struct cpufreq_policy *policy)
474472
do_set_cpu_speed(sleep_freq == low_freq ?
475473
CPUFREQ_LOW : CPUFREQ_HIGH, 0);
476474

475+
ppc_proc_freq = cur_freq * 1000ul;
476+
477477
no_schedule = 0;
478478
return 0;
479479
}
@@ -547,7 +547,7 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode)
547547
*/
548548
if (low_freq < 98000000)
549549
low_freq = 101000000;
550-
550+
551551
/* Convert those to CPU core clocks */
552552
low_freq = (low_freq * (*ratio)) / 2000;
553553
hi_freq = (hi_freq * (*ratio)) / 2000;
@@ -714,6 +714,7 @@ static int __init pmac_cpufreq_setup(void)
714714

715715
pmac_cpu_freqs[CPUFREQ_LOW].frequency = low_freq;
716716
pmac_cpu_freqs[CPUFREQ_HIGH].frequency = hi_freq;
717+
ppc_proc_freq = cur_freq * 1000ul;
717718

718719
printk(KERN_INFO "Registering PowerMac CPU frequency driver\n");
719720
printk(KERN_INFO "Low: %d Mhz, High: %d Mhz, Boot: %d Mhz\n",

0 commit comments

Comments
 (0)