From nobody Wed Nov 5 03:05:53 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=1761712710; cv=none; d=zohomail.com; s=zohoarc; b=LbhFB5m0ifhDjxqwNqlbzlRHtutCrai/T8XU+jiKY5IWwMea2nobFzBsmUweB5AmS6pnmvxJXcYxB+BV6BkhJFeH9l4Dpm4S5AUMfooASSSosr1yjjVUenELoUZYKfNFrL8QpyKoHwBldmCo+ce/pc/CU5XOhEuH1/7MrcVGpGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761712710; 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=+LzMPXWT2/ae1RBU4Kb42ArX1YmwRLPFViPp7QEyyxk=; b=BkBvirSSNTpDoZh9gv8Y7Dk2rVORKul6VLAwpVRTvSq/TJ7EuIa1ItCepsWzQ2F8Jn9aGhSSI1zDcguxfnZ4mqVwvog82z+4zoPudKh5EdJQbeRX5SVJo6E52M5a+WKE//vzZzqNbgV0fWp90W5oCPertxIAM19+lVzG9Y6oR4w= 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 1761712710446280.1646408129658; Tue, 28 Oct 2025 21:38:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vDxwZ-0007EJ-VI; Wed, 29 Oct 2025 00:37:55 -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 1vDxwY-0007Dl-A5; Wed, 29 Oct 2025 00:37:54 -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 1vDxwV-0004M3-K7; Wed, 29 Oct 2025 00:37:53 -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:12 +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:12 +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 03/17] hw/arm/aspeed: Split Palmetto machine into a separate source file for maintainability Date: Wed, 29 Oct 2025 12:36:49 +0800 Message-ID: <20251029043710.1486573-4-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: 1761712713684158500 This commit moves the OpenPOWER Palmetto BMC machine implementation out of aspeed.c into a new standalone file aspeed_ast2400_palmetto.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: - Removed PALMETTO_BMC_HW_STRAP1 macro definition from aspeed.c. - Moved palmetto_bmc_i2c_init() I=C2=B2C initialization logic into the new = file. - Moved aspeed_machine_palmetto_class_init() and type registration. - Added aspeed_ast2400_palmetto.c to the build system (meson.build). - Removed all Palmetto-specific code and macros from aspeed.c. No functional changes. Signed-off-by: Jamin Lin --- hw/arm/aspeed.c | 59 ------------------------ hw/arm/aspeed_ast2400_palmetto.c | 79 ++++++++++++++++++++++++++++++++ hw/arm/meson.build | 1 + 3 files changed, 80 insertions(+), 59 deletions(-) create mode 100644 hw/arm/aspeed_ast2400_palmetto.c diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index f6e9d5cda1..f58245456a 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -42,20 +42,6 @@ static struct arm_boot_info aspeed_board_binfo =3D { #define ASPEED_RAM_SIZE(sz) (sz) #endif =20 -/* Palmetto hardware value: 0x120CE416 */ -#define PALMETTO_BMC_HW_STRAP1 ( \ - SCU_AST2400_HW_STRAP_DRAM_SIZE(DRAM_SIZE_256MB) | \ - SCU_AST2400_HW_STRAP_DRAM_CONFIG(2 /* DDR3 with CL=3D6, CWL=3D5 */= ) | \ - SCU_AST2400_HW_STRAP_ACPI_DIS | \ - SCU_AST2400_HW_STRAP_SET_CLK_SOURCE(AST2400_CLK_48M_IN) | \ - SCU_HW_STRAP_VGA_CLASS_CODE | \ - SCU_HW_STRAP_LPC_RESET_PIN | \ - SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_M_S_EN) | \ - SCU_AST2400_HW_STRAP_SET_CPU_AHB_RATIO(AST2400_CPU_AHB_RATIO_2_1) = | \ - SCU_HW_STRAP_SPI_WIDTH | \ - SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) | \ - SCU_AST2400_HW_STRAP_BOOT_MODE(AST2400_SPI_BOOT)) - /* AST2600 evb hardware value */ #define AST2600_EVB_HW_STRAP1 0x000000C0 #define AST2600_EVB_HW_STRAP2 0x00000003 @@ -311,30 +297,6 @@ static void aspeed_machine_init(MachineState *machine) arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo); } =20 -static void palmetto_bmc_i2c_init(AspeedMachineState *bmc) -{ - AspeedSoCState *soc =3D bmc->soc; - DeviceState *dev; - uint8_t *eeprom_buf =3D g_malloc0(32 * 1024); - - /* - * The palmetto platform expects a ds3231 RTC but a ds1338 is - * enough to provide basic RTC features. Alarms will be missing - */ - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 0), "ds1338", 0x= 68); - - smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50, - eeprom_buf); - - /* add a TMP423 temperature sensor */ - dev =3D DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2= ), - "tmp423", 0x4c)); - object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abo= rt); - object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abo= rt); - object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abo= rt); - object_property_set_int(OBJECT(dev), "temperature3", 110000, &error_ab= ort); -} - static void ast2600_evb_i2c_init(AspeedMachineState *bmc) { AspeedSoCState *soc =3D bmc->soc; @@ -1041,23 +1003,6 @@ static void aspeed_machine_class_init(ObjectClass *o= c, const void *data) aspeed_machine_class_props_init(oc); } =20 -static void aspeed_machine_palmetto_class_init(ObjectClass *oc, - const void *data) -{ - MachineClass *mc =3D MACHINE_CLASS(oc); - AspeedMachineClass *amc =3D ASPEED_MACHINE_CLASS(oc); - - mc->desc =3D "OpenPOWER Palmetto BMC (ARM926EJ-S)"; - amc->soc_name =3D "ast2400-a1"; - amc->hw_strap1 =3D PALMETTO_BMC_HW_STRAP1; - amc->fmc_model =3D "n25q256a"; - amc->spi_model =3D "mx25l25635f"; - amc->num_cs =3D 1; - amc->i2c_init =3D palmetto_bmc_i2c_init; - mc->default_ram_size =3D 256 * MiB; - aspeed_machine_class_init_cpus_defaults(mc); -}; - static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, const void *data) { @@ -1404,10 +1349,6 @@ static void aspeed_machine_qcom_firework_class_init(= ObjectClass *oc, =20 static const TypeInfo aspeed_machine_types[] =3D { { - .name =3D MACHINE_TYPE_NAME("palmetto-bmc"), - .parent =3D TYPE_ASPEED_MACHINE, - .class_init =3D aspeed_machine_palmetto_class_init, - }, { .name =3D MACHINE_TYPE_NAME("ast2600-evb"), .parent =3D TYPE_ASPEED_MACHINE, .class_init =3D aspeed_machine_ast2600_evb_class_init, diff --git a/hw/arm/aspeed_ast2400_palmetto.c b/hw/arm/aspeed_ast2400_palme= tto.c new file mode 100644 index 0000000000..1c17de2088 --- /dev/null +++ b/hw/arm/aspeed_ast2400_palmetto.c @@ -0,0 +1,79 @@ +/* + * OpenPOWER Palmetto + * + * 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/i2c/smbus_eeprom.h" + +/* Palmetto hardware value: 0x120CE416 */ +#define PALMETTO_BMC_HW_STRAP1 ( \ + SCU_AST2400_HW_STRAP_DRAM_SIZE(DRAM_SIZE_256MB) | \ + SCU_AST2400_HW_STRAP_DRAM_CONFIG(2 /* DDR3 with CL=3D6, CWL=3D5 */= ) | \ + SCU_AST2400_HW_STRAP_ACPI_DIS | \ + SCU_AST2400_HW_STRAP_SET_CLK_SOURCE(AST2400_CLK_48M_IN) | \ + SCU_HW_STRAP_VGA_CLASS_CODE | \ + SCU_HW_STRAP_LPC_RESET_PIN | \ + SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_M_S_EN) | \ + SCU_AST2400_HW_STRAP_SET_CPU_AHB_RATIO(AST2400_CPU_AHB_RATIO_2_1) = | \ + SCU_HW_STRAP_SPI_WIDTH | \ + SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) | \ + SCU_AST2400_HW_STRAP_BOOT_MODE(AST2400_SPI_BOOT)) + +static void palmetto_bmc_i2c_init(AspeedMachineState *bmc) +{ + AspeedSoCState *soc =3D bmc->soc; + DeviceState *dev; + uint8_t *eeprom_buf =3D g_malloc0(32 * 1024); + + /* + * The palmetto platform expects a ds3231 RTC but a ds1338 is + * enough to provide basic RTC features. Alarms will be missing + */ + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 0), "ds1338", 0x= 68); + + smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50, + eeprom_buf); + + /* add a TMP423 temperature sensor */ + dev =3D DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2= ), + "tmp423", 0x4c)); + object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abo= rt); + object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abo= rt); + object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abo= rt); + object_property_set_int(OBJECT(dev), "temperature3", 110000, &error_ab= ort); +} + +static void aspeed_machine_palmetto_class_init(ObjectClass *oc, + const void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + AspeedMachineClass *amc =3D ASPEED_MACHINE_CLASS(oc); + + mc->desc =3D "OpenPOWER Palmetto BMC (ARM926EJ-S)"; + amc->soc_name =3D "ast2400-a1"; + amc->hw_strap1 =3D PALMETTO_BMC_HW_STRAP1; + amc->fmc_model =3D "n25q256a"; + amc->spi_model =3D "mx25l25635f"; + amc->num_cs =3D 1; + amc->i2c_init =3D palmetto_bmc_i2c_init; + mc->default_ram_size =3D 256 * MiB; + aspeed_machine_class_init_cpus_defaults(mc); +}; + +static const TypeInfo aspeed_ast2400_palmetto_types[] =3D { + { + .name =3D MACHINE_TYPE_NAME("palmetto-bmc"), + .parent =3D TYPE_ASPEED_MACHINE, + .class_init =3D aspeed_machine_palmetto_class_init, + }, +}; + +DEFINE_TYPES(aspeed_ast2400_palmetto_types) + diff --git a/hw/arm/meson.build b/hw/arm/meson.build index 9411e27d78..293dbbb53b 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -44,6 +44,7 @@ arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( 'aspeed.c', 'aspeed_soc_common.c', 'aspeed_ast2400.c', + 'aspeed_ast2400_palmetto.c', 'aspeed_ast2400_quanta-q71l.c', 'aspeed_ast2400_supermicrox11.c', 'aspeed_ast2500_evb.c', --=20 2.43.0