From nobody Wed Nov 5 02:39:02 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=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1761712779; cv=none; d=zohomail.com; s=zohoarc; b=RWcpzAKxMfKaHGPso1S9tQl0SBE6PcXPPy2OGOPN3XvIbQXc1VCg+LwW6z6mB1D+6xsvow3fwtcRwqZNgTkl5FFmx3M3VfgAj9G+sKoGr04ql4VCOFPM0tAjUZ3iMCxtlGSZL9N73Rd2qiV8DEu7NXTjGlnrmZCsFqOn3QFJaoI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761712779; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=U2/J/lFRLphKAj30BJrBmMX2vqqjXOnhew0WH2vToHY=; b=IqJjFM8YdUFmpFh/iUN9Ch5U6suQqdDoKkkUE9ggS7bdleRylUcr4tgGMNKiKMX9H8xLb1plp3Z4eVdIGsPow2WHIu0EhIB+WS4ETVpJ/gN7jMOy4T1t8+Arx2Kg2VWUo12mysj0vsqBkpQvpOlCzqBNGT/yZH7JZrh/CX5VUYE= ARC-Authentication-Results: i=1; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761712779219957.6032297367283; Tue, 28 Oct 2025 21:39:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vDxwm-0007Kv-0h; Wed, 29 Oct 2025 00:38:08 -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 1vDxwk-0007Jl-Bl; Wed, 29 Oct 2025 00:38:06 -0400 Received: from mail.aspeedtech.com ([211.20.114.72] helo=TWMBX01.aspeed.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vDxwg-0004M3-JR; Wed, 29 Oct 2025 00:38:06 -0400 Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Wed, 29 Oct 2025 12:37:13 +0800 Received: from mail.aspeedtech.com (192.168.10.10) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Wed, 29 Oct 2025 12:37:13 +0800 To: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , Steven Lee , Troy Lee , Andrew Jeffery , "Joel Stanley" , "open list:All patches CC here" , "open list:ASPEED BMCs" CC: , , Subject: [PATCH v2 05/17] hw/arm/aspeed: Split Bletchley machine into a separate source file for maintainability Date: Wed, 29 Oct 2025 12:36:51 +0800 Message-ID: <20251029043710.1486573-6-jamin_lin@aspeedtech.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251029043710.1486573-1-jamin_lin@aspeedtech.com> References: <20251029043710.1486573-1-jamin_lin@aspeedtech.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=211.20.114.72; envelope-from=jamin_lin@aspeedtech.com; helo=TWMBX01.aspeed.com 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_FAIL=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: , Reply-to: Jamin Lin From: Jamin Lin via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761712781463154100 This commit moves the Facebook Bletchley BMC machine implementation out of aspeed.c into a new standalone file aspeed_ast2600_bletchley.c. This refactor continues the modularization effort for Aspeed platform suppo= rt, placing each board=E2=80=99s logic in its own dedicated source file. It improves maintainability, readability, and simplifies future development= for new platforms without cluttering aspeed.c. Key updates include: - Moved BLETCHLEY_BMC_HW_STRAP1 and BLETCHLEY_BMC_HW_STRAP2 macro definitio= ns into the new file. - Moved bletchley_bmc_i2c_init() I=C2=B2C initialization logic into the new= file. - Moved aspeed_machine_bletchley_class_init() and type registration. - Added aspeed_ast2600_bletchley.c to the build system (meson.build). - Removed all Bletchley-specific code and macros from aspeed.c. No functional changes. Signed-off-by: Jamin Lin --- hw/arm/aspeed.c | 76 ------------------------ hw/arm/aspeed_ast2600_bletchley.c | 96 +++++++++++++++++++++++++++++++ hw/arm/meson.build | 1 + 3 files changed, 97 insertions(+), 76 deletions(-) create mode 100644 hw/arm/aspeed_ast2600_bletchley.c diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 690ad0be87..6458798c2c 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -55,10 +55,6 @@ static struct arm_boot_info aspeed_board_binfo =3D { #define FUJI_BMC_HW_STRAP1 0x00000000 #define FUJI_BMC_HW_STRAP2 0x00000000 =20 -/* Bletchley hardware value */ -#define BLETCHLEY_BMC_HW_STRAP1 0x00002000 -#define BLETCHLEY_BMC_HW_STRAP2 0x00000801 - /* GB200NVL hardware value */ #define GB200NVL_BMC_HW_STRAP1 AST2600_EVB_HW_STRAP1 #define GB200NVL_BMC_HW_STRAP2 AST2600_EVB_HW_STRAP2 @@ -684,53 +680,6 @@ static void catalina_bmc_i2c_init(AspeedMachineState *= bmc) at24c_eeprom_init(i2c[15], 0x52, 8 * KiB); } =20 -static void bletchley_bmc_i2c_init(AspeedMachineState *bmc) -{ - AspeedSoCState *soc =3D bmc->soc; - I2CBus *i2c[13] =3D {}; - for (int i =3D 0; i < 13; i++) { - if ((i =3D=3D 8) || (i =3D=3D 11)) { - continue; - } - i2c[i] =3D aspeed_i2c_get_bus(&soc->i2c, i); - } - - /* Bus 0 - 5 all have the same config. */ - for (int i =3D 0; i < 6; i++) { - /* Missing model: ti,ina230 @ 0x45 */ - /* Missing model: mps,mp5023 @ 0x40 */ - i2c_slave_create_simple(i2c[i], TYPE_TMP421, 0x4f); - /* Missing model: nxp,pca9539 @ 0x76, but PCA9552 works enough */ - i2c_slave_create_simple(i2c[i], TYPE_PCA9552, 0x76); - i2c_slave_create_simple(i2c[i], TYPE_PCA9552, 0x67); - /* Missing model: fsc,fusb302 @ 0x22 */ - } - - /* Bus 6 */ - at24c_eeprom_init(i2c[6], 0x56, 65536); - /* Missing model: nxp,pcf85263 @ 0x51 , but ds1338 works enough */ - i2c_slave_create_simple(i2c[6], "ds1338", 0x51); - - - /* Bus 7 */ - at24c_eeprom_init(i2c[7], 0x54, 65536); - - /* Bus 9 */ - i2c_slave_create_simple(i2c[9], TYPE_TMP421, 0x4f); - - /* Bus 10 */ - i2c_slave_create_simple(i2c[10], TYPE_TMP421, 0x4f); - /* Missing model: ti,hdc1080 @ 0x40 */ - i2c_slave_create_simple(i2c[10], TYPE_PCA9552, 0x67); - - /* Bus 12 */ - /* Missing model: adi,adm1278 @ 0x11 */ - i2c_slave_create_simple(i2c[12], TYPE_TMP421, 0x4c); - i2c_slave_create_simple(i2c[12], TYPE_TMP421, 0x4d); - i2c_slave_create_simple(i2c[12], TYPE_PCA9552, 0x67); -} - - static void gb200nvl_bmc_i2c_init(AspeedMachineState *bmc) { AspeedSoCState *soc =3D bmc->soc; @@ -1058,27 +1007,6 @@ static void aspeed_machine_fuji_class_init(ObjectCla= ss *oc, const void *data) aspeed_machine_class_init_cpus_defaults(mc); }; =20 -#define BLETCHLEY_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB) - -static void aspeed_machine_bletchley_class_init(ObjectClass *oc, - const void *data) -{ - MachineClass *mc =3D MACHINE_CLASS(oc); - AspeedMachineClass *amc =3D ASPEED_MACHINE_CLASS(oc); - - mc->desc =3D "Facebook Bletchley BMC (Cortex-A7)"; - amc->soc_name =3D "ast2600-a3"; - amc->hw_strap1 =3D BLETCHLEY_BMC_HW_STRAP1; - amc->hw_strap2 =3D BLETCHLEY_BMC_HW_STRAP2; - amc->fmc_model =3D "w25q01jvq"; - amc->spi_model =3D NULL; - amc->num_cs =3D 2; - amc->macs_mask =3D ASPEED_MAC2_ON; - amc->i2c_init =3D bletchley_bmc_i2c_init; - mc->default_ram_size =3D BLETCHLEY_BMC_RAM_SIZE; - aspeed_machine_class_init_cpus_defaults(mc); -} - static void aspeed_machine_catalina_class_init(ObjectClass *oc, const void *data) { @@ -1361,10 +1289,6 @@ static const TypeInfo aspeed_machine_types[] =3D { .name =3D MACHINE_TYPE_NAME("fuji-bmc"), .parent =3D TYPE_ASPEED_MACHINE, .class_init =3D aspeed_machine_fuji_class_init, - }, { - .name =3D MACHINE_TYPE_NAME("bletchley-bmc"), - .parent =3D TYPE_ASPEED_MACHINE, - .class_init =3D aspeed_machine_bletchley_class_init, }, { .name =3D MACHINE_TYPE_NAME("gb200nvl-bmc"), .parent =3D TYPE_ASPEED_MACHINE, diff --git a/hw/arm/aspeed_ast2600_bletchley.c b/hw/arm/aspeed_ast2600_blet= chley.c new file mode 100644 index 0000000000..bb13970894 --- /dev/null +++ b/hw/arm/aspeed_ast2600_bletchley.c @@ -0,0 +1,96 @@ +/* + * Facebook Bletchley + * + * Copyright (C) 2025 ASPEED Technology Inc. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/arm/aspeed.h" +#include "hw/arm/aspeed_soc.h" +#include "hw/gpio/pca9552.h" +#include "hw/nvram/eeprom_at24c.h" + +#define TYPE_TMP421 "tmp421" +/* Bletchley hardware value */ +#define BLETCHLEY_BMC_HW_STRAP1 0x00002000 +#define BLETCHLEY_BMC_HW_STRAP2 0x00000801 +#define BLETCHLEY_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB) + +static void bletchley_bmc_i2c_init(AspeedMachineState *bmc) +{ + AspeedSoCState *soc =3D bmc->soc; + I2CBus *i2c[13] =3D {}; + for (int i =3D 0; i < 13; i++) { + if ((i =3D=3D 8) || (i =3D=3D 11)) { + continue; + } + i2c[i] =3D aspeed_i2c_get_bus(&soc->i2c, i); + } + + /* Bus 0 - 5 all have the same config. */ + for (int i =3D 0; i < 6; i++) { + /* Missing model: ti,ina230 @ 0x45 */ + /* Missing model: mps,mp5023 @ 0x40 */ + i2c_slave_create_simple(i2c[i], TYPE_TMP421, 0x4f); + /* Missing model: nxp,pca9539 @ 0x76, but PCA9552 works enough */ + i2c_slave_create_simple(i2c[i], TYPE_PCA9552, 0x76); + i2c_slave_create_simple(i2c[i], TYPE_PCA9552, 0x67); + /* Missing model: fsc,fusb302 @ 0x22 */ + } + + /* Bus 6 */ + at24c_eeprom_init(i2c[6], 0x56, 65536); + /* Missing model: nxp,pcf85263 @ 0x51 , but ds1338 works enough */ + i2c_slave_create_simple(i2c[6], "ds1338", 0x51); + + + /* Bus 7 */ + at24c_eeprom_init(i2c[7], 0x54, 65536); + + /* Bus 9 */ + i2c_slave_create_simple(i2c[9], TYPE_TMP421, 0x4f); + + /* Bus 10 */ + i2c_slave_create_simple(i2c[10], TYPE_TMP421, 0x4f); + /* Missing model: ti,hdc1080 @ 0x40 */ + i2c_slave_create_simple(i2c[10], TYPE_PCA9552, 0x67); + + /* Bus 12 */ + /* Missing model: adi,adm1278 @ 0x11 */ + i2c_slave_create_simple(i2c[12], TYPE_TMP421, 0x4c); + i2c_slave_create_simple(i2c[12], TYPE_TMP421, 0x4d); + i2c_slave_create_simple(i2c[12], TYPE_PCA9552, 0x67); +} + +static void aspeed_machine_bletchley_class_init(ObjectClass *oc, + const void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + AspeedMachineClass *amc =3D ASPEED_MACHINE_CLASS(oc); + + mc->desc =3D "Facebook Bletchley BMC (Cortex-A7)"; + amc->soc_name =3D "ast2600-a3"; + amc->hw_strap1 =3D BLETCHLEY_BMC_HW_STRAP1; + amc->hw_strap2 =3D BLETCHLEY_BMC_HW_STRAP2; + amc->fmc_model =3D "w25q01jvq"; + amc->spi_model =3D NULL; + amc->num_cs =3D 2; + amc->macs_mask =3D ASPEED_MAC2_ON; + amc->i2c_init =3D bletchley_bmc_i2c_init; + mc->default_ram_size =3D BLETCHLEY_BMC_RAM_SIZE; + aspeed_machine_class_init_cpus_defaults(mc); +} + +static const TypeInfo aspeed_ast2600_bletchley_types[] =3D { + { + .name =3D MACHINE_TYPE_NAME("bletchley-bmc"), + .parent =3D TYPE_ASPEED_MACHINE, + .class_init =3D aspeed_machine_bletchley_class_init, + }, +}; + +DEFINE_TYPES(aspeed_ast2600_bletchley_types) + diff --git a/hw/arm/meson.build b/hw/arm/meson.build index 293dbbb53b..06e27d94b9 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -57,6 +57,7 @@ arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( 'aspeed_ast2500_witherspoon.c', 'aspeed_ast2500_yosemitev2.c', 'aspeed_ast2600.c', + 'aspeed_ast2600_bletchley.c', 'aspeed_ast10x0.c', 'aspeed_eeprom.c', 'fby35.c')) --=20 2.43.0