From nobody Fri Sep 5 22:31:41 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174614175251828.648051608550304; Thu, 1 May 2025 16:22:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uAdDH-0004zn-2W; Thu, 01 May 2025 19:21:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uAdD1-0004mp-0v; Thu, 01 May 2025 19:20:52 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uAdCx-0007IV-EU; Thu, 01 May 2025 19:20:48 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id B47BA55D25F; Fri, 02 May 2025 01:20:45 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id MBTiza-hyQCr; Fri, 2 May 2025 01:20:43 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id C371A55D261; Fri, 02 May 2025 01:20:43 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-ID: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 11/13] hw/ppc/pegasos2: Add bus frequency to machine state To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin Date: Fri, 02 May 2025 01:20:43 +0200 (CEST) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1746141755182019100 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Store the bus frequency in the machine state and set it from instance init method. Signed-off-by: BALATON Zoltan --- hw/ppc/pegasos2.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index f7999520e4..ae3f01231d 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -55,8 +55,6 @@ #define H_PRIVILEGE -3 /* Caller not privileged */ #define H_PARAMETER -4 /* Parameter invalid, out-of-range or conflicting= */ =20 -#define BUS_FREQ_HZ 133333333 - #define TYPE_PEGASOS_MACHINE MACHINE_TYPE_NAME("pegasos") OBJECT_DECLARE_SIMPLE_TYPE(PegasosMachineState, PEGASOS_MACHINE) =20 @@ -66,6 +64,7 @@ struct PegasosMachineState { PowerPCCPU *cpu; DeviceState *nb; /* north bridge */ DeviceState *sb; /* south bridge */ + int bus_freq_hz; IRQState pci_irqs[PCI_NUM_PINS]; OrIRQState orirq[PCI_NUM_PINS]; qemu_irq mv_pirq[PCI_NUM_PINS]; @@ -135,7 +134,7 @@ static void pegasos2_setup_pci_irq(PegasosMachineState = *pm) qdev_get_gpio_in_named(pm->nb, "gpp", 31)); } =20 -static void pegasos2_init(MachineState *machine) +static void pegasos_init(MachineState *machine) { PegasosMachineState *pm =3D PEGASOS_MACHINE(machine); CPUPPCState *env; @@ -158,7 +157,7 @@ static void pegasos2_init(MachineState *machine) } =20 /* Set time-base frequency */ - cpu_ppc_tb_init(env, BUS_FREQ_HZ / 4); + cpu_ppc_tb_init(env, pm->bus_freq_hz / 4); qemu_register_reset(pegasos2_cpu_reset, pm->cpu); =20 /* RAM */ @@ -603,6 +602,13 @@ static bool pegasos2_setprop(MachineState *ms, const c= har *path, return true; } =20 +static void pegasos2_init(Object *obj) +{ + PegasosMachineState *pm =3D PEGASOS_MACHINE(obj); + + pm->bus_freq_hz =3D 133333333; +} + static void pegasos2_machine_class_init(ObjectClass *oc, const void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -610,7 +616,7 @@ static void pegasos2_machine_class_init(ObjectClass *oc= , const void *data) VofMachineIfClass *vmc =3D VOF_MACHINE_CLASS(oc); =20 mc->desc =3D "Genesi/bPlan Pegasos II"; - mc->init =3D pegasos2_init; + mc->init =3D pegasos_init; mc->reset =3D pegasos2_machine_reset; mc->block_default_type =3D IF_IDE; mc->default_boot_order =3D "cd"; @@ -640,6 +646,7 @@ static const TypeInfo pegasos_machine_types[] =3D { .name =3D MACHINE_TYPE_NAME("pegasos2"), .parent =3D TYPE_PEGASOS_MACHINE, .class_init =3D pegasos2_machine_class_init, + .instance_init =3D pegasos2_init, .interfaces =3D (const InterfaceInfo[]) { { TYPE_PPC_VIRTUAL_HYPERVISOR }, { TYPE_VOF_MACHINE_IF }, @@ -777,7 +784,7 @@ static void add_pci_device(PCIBus *bus, PCIDevice *d, v= oid *opaque) g_string_free(node, TRUE); } =20 -static void add_cpu_info(void *fdt, PowerPCCPU *cpu) +static void add_cpu_info(void *fdt, PowerPCCPU *cpu, int bus_freq) { uint32_t cells[2]; =20 @@ -824,8 +831,8 @@ static void add_cpu_info(void *fdt, PowerPCCPU *cpu) qemu_fdt_setprop_cell(fdt, cp, "reservation-granule-size", 4); qemu_fdt_setprop_cell(fdt, cp, "timebase-frequency", cpu->env.tb_env->tb_freq); - qemu_fdt_setprop_cell(fdt, cp, "bus-frequency", BUS_FREQ_HZ); - qemu_fdt_setprop_cell(fdt, cp, "clock-frequency", BUS_FREQ_HZ * 7.5); + qemu_fdt_setprop_cell(fdt, cp, "bus-frequency", bus_freq); + qemu_fdt_setprop_cell(fdt, cp, "clock-frequency", bus_freq * 7.5); qemu_fdt_setprop_cell(fdt, cp, "cpu-version", cpu->env.spr[SPR_PVR]); cells[0] =3D 0; cells[1] =3D 0; @@ -861,7 +868,7 @@ static void *pegasos2_build_fdt(PegasosMachineState *pm= , int *fdt_size) } qemu_fdt_setprop_string(fdt, "/", "name", "bplan,Pegasos2"); =20 - add_cpu_info(fdt, pm->cpu); + add_cpu_info(fdt, pm->cpu, pm->bus_freq_hz); =20 fi.fdt =3D fdt; fi.path =3D "/pci@c0000000"; --=20 2.41.3