diff mbox series

[v3,13/20] hw/mips/fuloong2e: Set CPU frequency to 533 MHz

Message ID 20201010204319.3119239-14-f4bug@amsat.org
State Superseded
Headers show
Series hw/mips: Set CPU frequency | expand

Commit Message

Philippe Mathieu-Daudé Oct. 10, 2020, 8:43 p.m. UTC
The CPU frequency is normally provided by the firmware in the
"cpuclock" environment variable. The 2E board can handles up
to 660MHz, but be conservative and take the same value used
by the Linux kernel: 533 MHz.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/mips/fuloong2e.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Jiaxun Yang Oct. 12, 2020, 5:54 a.m. UTC | #1
在 2020/10/11 上午4:43, Philippe Mathieu-Daudé 写道:
> The CPU frequency is normally provided by the firmware in the

> "cpuclock" environment variable. The 2E board can handles up

> to 660MHz, but be conservative and take the same value used

> by the Linux kernel: 533 MHz.

>

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>


Thanks

- Jiaxun
> ---

>   hw/mips/fuloong2e.c | 8 +++++++-

>   1 file changed, 7 insertions(+), 1 deletion(-)

>

> diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c

> index b000ed1d7f7..b25c3df19d0 100644

> --- a/hw/mips/fuloong2e.c

> +++ b/hw/mips/fuloong2e.c

> @@ -28,6 +28,7 @@

>   #include "hw/isa/superio.h"

>   #include "net/net.h"

>   #include "hw/boards.h"

> +#include "hw/qdev-clock.h"

>   #include "hw/i2c/smbus_eeprom.h"

>   #include "hw/block/flash.h"

>   #include "hw/mips/mips.h"

> @@ -300,10 +301,15 @@ static void mips_fuloong2e_init(MachineState *machine)

>       I2CBus *smbus;

>       MIPSCPU *cpu;

>       CPUMIPSState *env;

> +    Clock *cpuclk;

>       DeviceState *dev;

>   

>       /* init CPUs */

> -    cpu = MIPS_CPU(cpu_create(machine->cpu_type));

> +    cpu = MIPS_CPU(object_new(machine->cpu_type));

> +    cpuclk = clock_new(OBJECT(machine), "cpu-refclk");

> +    clock_set_hz(cpuclk, 533080000); /* ~533 MHz */

> +    qdev_connect_clock_in(DEVICE(cpu), "clk-in", cpuclk);

> +    qdev_realize(DEVICE(cpu), NULL, &error_abort);

>       env = &cpu->env;

>   

>       qemu_register_reset(main_cpu_reset, cpu);
diff mbox series

Patch

diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
index b000ed1d7f7..b25c3df19d0 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -28,6 +28,7 @@ 
 #include "hw/isa/superio.h"
 #include "net/net.h"
 #include "hw/boards.h"
+#include "hw/qdev-clock.h"
 #include "hw/i2c/smbus_eeprom.h"
 #include "hw/block/flash.h"
 #include "hw/mips/mips.h"
@@ -300,10 +301,15 @@  static void mips_fuloong2e_init(MachineState *machine)
     I2CBus *smbus;
     MIPSCPU *cpu;
     CPUMIPSState *env;
+    Clock *cpuclk;
     DeviceState *dev;
 
     /* init CPUs */
-    cpu = MIPS_CPU(cpu_create(machine->cpu_type));
+    cpu = MIPS_CPU(object_new(machine->cpu_type));
+    cpuclk = clock_new(OBJECT(machine), "cpu-refclk");
+    clock_set_hz(cpuclk, 533080000); /* ~533 MHz */
+    qdev_connect_clock_in(DEVICE(cpu), "clk-in", cpuclk);
+    qdev_realize(DEVICE(cpu), NULL, &error_abort);
     env = &cpu->env;
 
     qemu_register_reset(main_cpu_reset, cpu);