Subject: iBook G4 CPU speed control
To: netbsd-macppc <port-macppc@NetBSD.ORG>
From: Michael <macallan18@earthlink.net>
List: port-macppc
Date: 09/25/2005 21:52:58
--Signature_Sun__25_Sep_2005_21_52_58_-0400_nFjB7ZwntpIVZwCh
Content-Type: multipart/mixed;
boundary="Multipart_Sun__25_Sep_2005_21_52_58_-0400_8e/tt1DxkLwDVe0K"
--Multipart_Sun__25_Sep_2005_21_52_58_-0400_8e/tt1DxkLwDVe0K
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hello,
I've finally found out how to switch CPU speed on G4 Macs with Intrepid
chipset ( like iBook G4, some PowerMacs and PowerBooks and probably
others )
The problem:
cpu0 at mainbus0: 7455 (Revision 3.3), ID 0 (primary)
cpu0: HID0 8450c0bc<EMCP,TBEN,NAP,DPM,ICE,DCE,SGE,BTIC,LRSTK,FOLD,BHT>,
PS=3D1=20
cpu0: 614.39 MHz, 256KB L2 cache
It's supposed to run at 800 MHz but that's what the firmware sets up.
With the attached patch you'll get:
obio0 at pci1 dev 23 function 0: addr 0x80000000
enabling Intrepid CPU speed control
CPU speed is low
and this:
~# sysctl machdep
...
machdep.cpu_speed =3D 0
~# envstat -r
case temperature: 49.000 degC
CPU temperature: 54.000 degC
GPU temperature: 51.000 degC
voltage0: 1.589 V
fan0: 0 RPM
Now we can do
~# sysctl -w machdep.cpu_speed=3D1
machdep.cpu_speed: 0 -> 1
That's it, now the CPU runs at full speed.
We can check core voltage to see that something changed:
~# envstat -r
case temperature: 49.000 degC
CPU temperature: 54.000 degC
GPU temperature: 51.000 degC
voltage0: 1.810 V
fan0: 0 RPM
~# flops
FLOPS C Program (Double Precision), V2.0 18 Dec 1992
Module Error RunTime MFLOPS
(usec)
1 -7.6739e-13 0.0816 171.6341
with speed back to low we get:
~# flops
FLOPS C Program (Double Precision), V2.0 18 Dec 1992
Module Error RunTime MFLOPS
(usec)
1 -7.6739e-13 0.0966 144.9620
So far this in only known to work on my iBook. It may or may not work on
different hardware.
have fun
Michael
--Multipart_Sun__25_Sep_2005_21_52_58_-0400_8e/tt1DxkLwDVe0K
Content-Type: application/octet-stream; name=cpuspeed.patch
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=cpuspeed.patch
SW5kZXg6IG9iaW8uYwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09ClJDUyBmaWxlOiAvY3Zzcm9vdC9zcmMvc3lzL2FyY2gv
bWFjcHBjL2Rldi9vYmlvLmMsdgpyZXRyaWV2aW5nIHJldmlzaW9uIDEuMjIKZGlmZiAtdSAtdyAt
cjEuMjIgb2Jpby5jCi0tLSBvYmlvLmMJNSBKdW4gMjAwNSAyMDowMjowMSAtMDAwMAkxLjIyCisr
KyBvYmlvLmMJMjYgU2VwIDIwMDUgMDE6NTA6MzEgLTAwMDAKQEAgLTQ2LDYgKzQ2LDggQEAKIAog
I2luY2x1ZGUgPG1hY2hpbmUvYXV0b2NvbmYuaD4KIAorI2luY2x1ZGUgPHN5cy9zeXNjdGwuaD4K
Kwogc3RhdGljIHZvaWQgb2Jpb19hdHRhY2ggX19QKChzdHJ1Y3QgZGV2aWNlICosIHN0cnVjdCBk
ZXZpY2UgKiwgdm9pZCAqKSk7CiBzdGF0aWMgaW50IG9iaW9fbWF0Y2ggX19QKChzdHJ1Y3QgZGV2
aWNlICosIHN0cnVjdCBjZmRhdGEgKiwgdm9pZCAqKSk7CiBzdGF0aWMgaW50IG9iaW9fcHJpbnQg
X19QKCh2b2lkICosIGNvbnN0IGNoYXIgKikpOwpAQCAtNTUsNiArNTcsOSBAQAogCWludCBzY19u
b2RlOwogfTsKIAorc3RhdGljIGludCBvYmlvX2dldF9jcHVfc3BlZWQocGFkZHJfdCk7CitzdGF0
aWMgdm9pZCBvYmlvX3NldF9jcHVfc3BlZWQocGFkZHJfdCwgaW50KTsKK3N0YXRpYyB2b2lkIHNl
dHVwX3N5c2N0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Cit9Cg==
--Multipart_Sun__25_Sep_2005_21_52_58_-0400_8e/tt1DxkLwDVe0K--
--Signature_Sun__25_Sep_2005_21_52_58_-0400_nFjB7ZwntpIVZwCh
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (NetBSD)
iQEVAwUBQzdUfspnzkX8Yg2nAQK1rQgAiSzQhntaSyQazpfA36AWQ2LP7ZiK0hGL
U/4IIsmCTMdDZAz+EbsY2+B4QZ4woGu3znjvt8bH8dKFjdbd7gmmNfkr9zNfKLjm
+cp3rVGeTNQYMJSaNqarSKr219hQ6TvlMz0AmRbrCqtVGY8vwiexK+w8xWIR7W/K
fGvatvSSHDmvIgjqRFiRSpcqu6mrAJhJw5tOGpus02prCmllkiQS4UmGxh61edRk
tjcDiu8ZY8d2SXjrMcXetiNWWJZxzGi0+JNFBEYTEH5cpa4Bd08fFcApCIpIMnq2
Jcl7vZuyUPpECIcZ7ef+abnvupobHHsLs4Vj/3o9YAwlQqsep90ZqA==
=V04f
-----END PGP SIGNATURE-----
--Signature_Sun__25_Sep_2005_21_52_58_-0400_nFjB7ZwntpIVZwCh--