From nobody Sun Feb 8 22:01:11 2026 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=1768207073; cv=none; d=zohomail.com; s=zohoarc; b=SwCf/Ho9c47Y8xaI0Ie34lWdFHR1fSx78GKqFTmuTnAMVFSQEI7IeS/0Z7reBJyyV2wkJPZ70n5bI8OkFMEFUju7std3bfoLhyquuur2J0e+8Y44DeUTMwUF/ILxgfF2/en3zWaBmzItstzz9NaZ7vJ+2DIq5yUO55sIYHCyG+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768207073; 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=vKka25cf38ReavEsjWZFEgE4zGsbswV/bfYR+EXMG1g=; b=aLZFs/sJ4leGOq4frwdwdlbz6LhC71KfBHi7TmceZjWu1Mko/QTGROQcgiCUN+uF8U4lWKgm1H5oDxCtuoIkwUxQ+cv3AZ+0xvzXZjjJzns/lo6vLvtFWBip4zuw3yYnQb4g38gI5mY/RdG8E7IomJNoz7bOiab7PgjmvFu6eGI= 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 17682070737218.093111088168826; Mon, 12 Jan 2026 00:37:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vfDKa-0005Cp-HG; Mon, 12 Jan 2026 03:31:20 -0500 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 1vfDKN-00055H-I6; Mon, 12 Jan 2026 03:31:12 -0500 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 1vfDKL-0008QA-Tj; Mon, 12 Jan 2026 03:31:07 -0500 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; Mon, 12 Jan 2026 16:30:55 +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; Mon, 12 Jan 2026 16:30:55 +0800 To: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Andrew Jeffery , Joel Stanley , "open list:ASPEED BMCs" , "open list:All patches CC here" CC: , Kane-Chen-AS Subject: [PATCH v1 1/1] hw/i2c/aspeed: Introduce 'bus-label' to customize bus naming Date: Mon, 12 Jan 2026 16:30:53 +0800 Message-ID: <20260112083054.4151945-2-kane_chen@aspeedtech.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260112083054.4151945-1-kane_chen@aspeedtech.com> References: <20260112083054.4151945-1-kane_chen@aspeedtech.com> MIME-Version: 1.0 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 (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=kane_chen@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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Kane Chen From: Kane Chen via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1768207076638158500 Content-Type: text/plain; charset="utf-8" From: Kane-Chen-AS On some Aspeed-based machines, multiple I2C controllers may exist across different components, such as the primary SoC and an external IO expander or co-processor (e.g., AST1700). Using the current static naming convention results in object name conflicts when multiple controllers attempt to instantiate buses with the same ID. This patch introduces a 'bus-label' property for the Aspeed I2C controller. This allows higher-level layers, such as the SoC realize function, to provide a unique identifier for the buses. The I2C bus object name is then constructed using this label (e.g., "ioexp0.0" instead of the default "aspeed.i2c.bus.0"). This enhancement ensures unique bus identifiers across the system and resolves naming conflicts in multi-controller configurations. Signed-off-by: Kane-Chen-AS Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Nabih Estefan Tested-by: Nabih Estefan --- include/hw/i2c/aspeed_i2c.h | 2 ++ hw/i2c/aspeed_i2c.c | 27 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h index ffcff2580f..68bd138026 100644 --- a/include/hw/i2c/aspeed_i2c.h +++ b/include/hw/i2c/aspeed_i2c.h @@ -252,6 +252,7 @@ struct AspeedI2CBus { MemoryRegion mr_pool; =20 I2CBus *bus; + char *name; uint8_t id; qemu_irq irq; =20 @@ -269,6 +270,7 @@ struct AspeedI2CState { uint32_t intr_status; uint32_t ctrl_global; uint32_t new_clk_divider; + char *bus_label; MemoryRegion pool_iomem; uint8_t share_pool[ASPEED_I2C_SHARE_POOL_SIZE]; =20 diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c index 1b8ac561c3..7cf92423c7 100644 --- a/hw/i2c/aspeed_i2c.c +++ b/hw/i2c/aspeed_i2c.c @@ -1215,9 +1215,16 @@ static void aspeed_i2c_realize(DeviceState *dev, Err= or **errp) "aspeed.i2c", aic->mem_size); sysbus_init_mmio(sbd, &s->iomem); =20 + /* default value */ + if (!s->bus_label) { + s->bus_label =3D g_strdup(TYPE_ASPEED_I2C_BUS); + } + for (i =3D 0; i < aic->num_busses; i++) { Object *bus =3D OBJECT(&s->busses[i]); int offset =3D i < aic->gap ? 1 : 5; + g_autofree char *name =3D g_strdup_printf("%s.%d", + s->bus_label, i); =20 if (!object_property_set_link(bus, "controller", OBJECT(s), errp))= { return; @@ -1227,6 +1234,10 @@ static void aspeed_i2c_realize(DeviceState *dev, Err= or **errp) return; } =20 + if (!object_property_set_str(bus, "bus-name", name, errp)) { + return; + } + if (!sysbus_realize(SYS_BUS_DEVICE(bus), errp)) { return; } @@ -1263,6 +1274,7 @@ static void aspeed_i2c_realize(DeviceState *dev, Erro= r **errp) static const Property aspeed_i2c_properties[] =3D { DEFINE_PROP_LINK("dram", AspeedI2CState, dram_mr, TYPE_MEMORY_REGION, MemoryRegion *), + DEFINE_PROP_STRING("bus-label", AspeedI2CState, bus_label), }; =20 static void aspeed_i2c_class_init(ObjectClass *klass, const void *data) @@ -1423,24 +1435,26 @@ static void aspeed_i2c_bus_realize(DeviceState *dev= , Error **errp) { AspeedI2CBus *s =3D ASPEED_I2C_BUS(dev); AspeedI2CClass *aic; - g_autofree char *name =3D g_strdup_printf(TYPE_ASPEED_I2C_BUS ".%d", s= ->id); - g_autofree char *pool_name =3D g_strdup_printf("%s.pool", name); + g_autofree char *pool_name =3D NULL; =20 - if (!s->controller) { - error_setg(errp, TYPE_ASPEED_I2C_BUS ": 'controller' link not set"= ); + if (!s->controller || !s->name) { + error_setg(errp, TYPE_ASPEED_I2C_BUS + ": 'controller' or 'bus-name' not set"); return; } =20 + pool_name =3D g_strdup_printf("%s.pool", s->name); + aic =3D ASPEED_I2C_GET_CLASS(s->controller); =20 sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); =20 - s->bus =3D i2c_init_bus(dev, name); + s->bus =3D i2c_init_bus(dev, s->name); s->slave =3D i2c_slave_create_simple(s->bus, TYPE_ASPEED_I2C_BUS_SLAVE, 0xff); =20 memory_region_init_io(&s->mr, OBJECT(s), &aspeed_i2c_bus_ops, - s, name, aic->reg_size); + s, s->name, aic->reg_size); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mr); =20 memory_region_init_io(&s->mr_pool, OBJECT(s), &aspeed_i2c_bus_pool_ops, @@ -1452,6 +1466,7 @@ static const Property aspeed_i2c_bus_properties[] =3D= { DEFINE_PROP_UINT8("bus-id", AspeedI2CBus, id, 0), DEFINE_PROP_LINK("controller", AspeedI2CBus, controller, TYPE_ASPEED_I= 2C, AspeedI2CState *), + DEFINE_PROP_STRING("bus-name", AspeedI2CBus, name), }; =20 static void aspeed_i2c_bus_class_init(ObjectClass *klass, const void *data) --=20 2.43.0