mac_newworld: change timebase frequency from 100MHz to 25MHz for mac99 machine
commit78abf93cc7e2254401ccdb4df53e608927d81feb
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Mon, 4 Mar 2024 07:35:48 +0000 (4 07:35 +0000)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Sat, 9 Mar 2024 18:17:01 +0000 (9 19:17 +0100)
tree08100a4591d2c9038e3462f2e8cc81b496fd7d25
parent46e23b2e424f60e5efd404901b4bcd1410bb8091
mac_newworld: change timebase frequency from 100MHz to 25MHz for mac99 machine

MacOS X uses multiple techniques for calibrating timers depending upon the detected
hardware. One of these calibration routines compares the change in the timebase
against the KeyLargo timer and uses this to recalculate the clock frequency,
timebase frequency and bus frequency if the calibration exceeds certain limits.
This recalibration occurs despite the correct values being passed via the device
tree, and is likely due to buggy firmware on some hardware.

The timebase frequency of 100MHz was set way back in 2005 by commit fa296b0fb4
("PIC fix - changed back TB frequency to 100 MHz") and with this value on a
mac99,via=pmu machine the OSX 10.2 timer calibration incorrectly calculates the
bus frequency as 400MHz instead of 100MHz. The most noticeable side-effect is
the UI appears sluggish and not very responsive for normal use.

Change the timebase frequency from 100MHz to 25MHz which matches that of a real
G4 AGP machine (the closest match to QEMU's mac99 machine) and allows OSX 10.2
to correctly detect all of the clock frequency, timebase frequency and bus
frequency.

Tested on various MacOS images from OS 9.2 through to OSX 10.4, along with Linux
and NetBSD and I was unable to find any regressions from this change.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240304073548.2098806-1-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
hw/ppc/mac_newworld.c