All the MIPS cores emulated by QEMU provides the Coproc#0
'Count' register which can be used as a free running timer.
Since it's introduction in 2005 this timer uses a fixed
frequency of 100 MHz (for a CPU freq of 200 MHz).
While this is not an issue with Linux guests, it makes
some firmwares behave incorrectly.
The Clock API allow propagating clocks. It is particularly
useful when hardware dynamicly changes clock frequencies.
To be able to model such MIPS hardware, we need to refactor
the MIPS hardware code to handle clocks.
This series is organized as follow:
1/ qdev/clock patches already reviewed but not merged
2/ refactor the CP0 timer period to allow dynamic changes
3/ MIPS CPU get an optional input clock
4/ set correct CPU frequencies to all boards
I used a MIPSsim test suggested by Thomas.
The test is available on the list:
https://mid.mail-archive.com/20200928171539.788309-17-f4bug@amsat.org
Possible follow up:
- QOM'ify the GIC
- let the GIC handle dynamic clock changes
Missing review: patches 6-20
Regards,
Phil.
Luc Michel (1):
hw/core/clock: add the clock_new helper function
Philippe Mathieu-Daudé (19):
util/cutils: Introduce freq_to_str() to display Hertz units
qdev-monitor: Display frequencies scaled to SI unit
hw/qdev-clock: Display error hint when clock is missing from device
target/mips: Move cpu_mips_get_random() with CP0 helpers
target/mips/cp0_timer: Explicit unit in variable name
target/mips/cp0_timer: Document TIMER_PERIOD origin
target/mips: Move cp0_count_ns to CPUMIPSState
target/mips/cpu: Calculate the CP0 timer period using the CPU
frequency
target/mips/cpu: Make cp0_count_rate a property
target/mips/cpu: Allow the CPU to use dynamic frequencies
hw/mips/r4k: Explicit CPU frequency is 200 MHz
hw/mips/fuloong2e: Set CPU frequency to 533 MHz
hw/mips/mipssim: Correct CPU frequency
hw/mips/jazz: Correct CPU frequencies
hw/mips/cps: Expose input clock and connect it to CPU cores
hw/mips/boston: Set CPU frequency to 1 GHz
hw/mips/malta: Set CPU frequency to 320 MHz
hw/mips/cps: Do not allow use without input clock
target/mips/cpu: Display warning when CPU is used without input clock
include/hw/clock.h | 13 ++++++++++
include/hw/mips/cps.h | 2 ++
include/qemu/cutils.h | 12 ++++++++++
target/mips/cpu.h | 14 +++++++++++
target/mips/internal.h | 2 +-
hw/core/clock.c | 15 ++++++++++++
hw/core/qdev-clock.c | 11 +++++++++
hw/mips/boston.c | 13 ++++++++++
hw/mips/cps.c | 8 +++++++
hw/mips/fuloong2e.c | 8 ++++++-
hw/mips/jazz.c | 16 ++++++++++++-
hw/mips/malta.c | 20 +++++++++++++---
hw/mips/mipssim.c | 12 +++++++++-
hw/mips/r4k.c | 8 ++++++-
qdev-monitor.c | 8 ++++---
target/mips/cp0_helper.c | 25 ++++++++++++++++++++
target/mips/cp0_timer.c | 51 ++++++++++------------------------------
target/mips/cpu.c | 40 ++++++++++++++++++++++++++++++-
util/cutils.c | 14 +++++++++++
19 files changed, 242 insertions(+), 50 deletions(-)
--
2.26.2