From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791816860; cv=none; d=zohomail.com; s=zohoarc; b=mas8pbZosjpZkb7EvQXv3j2tJUISSEdQV9sPQPexgD+Zm3ZS2jYbWfPXdRO8NH14zJdcSMNUqB+nWmgQWqGMBrfq+cx9lOcp69uPnmUFohxJudLGq3mSOoFa4LoKRvqg/3V6AJVBxcZSOyljvC8/XaAiDxDBh+fRknsz70L4uRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791816860; 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:Sender:Subject:Subject:To:To:Message-Id; bh=yXN++fw5zgOO6Nzdt5aDXW+w27r6GydROb+GJyYC31Y=; b=JHvFYUammrAEH3MPtE98SNrUJDnpJWdehPxlFEwGquC1oZmTSt7mMdxU1H2GfT9vHKGtkU7FVw6YbtE25Z1PQ7D/bQoQm8/1AzaRbwO1RtAkk0Bdq4Znys/7IKiT7s85XXsxq/d619lbyPq7igE7qcuEW+ysK25J0bX4cFejDTU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791816860650539.15699678361; Mon, 12 Oct 2026 07:54:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHPi-0005ma-En; Mon, 12 Oct 2026 10:54:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHP6-0005g2-H7 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:53:32 -0400 Received: from mail-wm1-f43.google.com ([209.85.128.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHP3-0004jk-N0 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:53:28 -0400 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4a16c1608faso26290405e9.0 for ; Mon, 12 Oct 2026 07:53:25 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48db9abd3aasm19296117f8f.32.2026.10.12.07.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 07:53:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791816804; x=1792421604; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yXN++fw5zgOO6Nzdt5aDXW+w27r6GydROb+GJyYC31Y=; b=Cr84FKFqAWkP0OHD98LiJ42QuUqo/57LBs2RwNU6UwRHYLH6WeQnBNBs16wXHQ2gqu S0xr+dNbaV8OZ7SQr8l0ajgG8iqVXG1Qou1dfQ3T97mFREfke2tK7dakauWO/aMmEmvG CpxxvOYJzF6Ewj8HWKGfu0GDNZsp/XmHQhTYq+52dVYTBDAaVqrrhd/nPsb6aKq7lsDK iw85gX3I0WI0HbO9NXtDuZmGSXND7HUoDh0j9bdNs6WDOf3LXcpujieo47YXbiyXUjyR ATddV3x9+h+vd6X6kPG4r1Ye9Y1Cv4JJZnNVbvXK2hwDfVNl3YXgUkXQykqnPOQnXzM9 GTeQ== X-Gm-Message-State: AFq9FYIledLXf/2VOgJR8+e1tOn/yng7iSW5vyMgXYNO+y/Y8kP7kqcQ x+NDyrm0/O5UcMlUYNP8QG+pfj58KtVUU/rOBgdTp152lM8EPlQlfhgBmMUpeNTQ X-Gm-Gg: AYBFou1YDBNfHCUDw+ROMtAX8xWHsPt24jIZNSbnIS6iIeC7u83Zr9ltl7O74nibbDT U4FvLwwQRr/w24Jmz3A9ba/GEmrl+1IToTQkSScW8wae478z5VrXM8Auvd1IIE/R6aA0PKgVYVc ZbtbeQ5Mr4u2vW11FZuCLZJmvNceAayKVJ2oBtmvUB2fmmf5fgls7ScNUQ9pjwa8kpbZ3UfLSbG FG3bhlPob5cmVejzM05gkdn8IBIfkz493bhZ4OkNQP1SHTIGQ+Aj8Nf5n+Lutsdj6sv2Tinl+C6 CLRpEjHX/FEzBQdAb/kT1xIBMvRLDlt5uuvUzr91yawIdHGoy1vzaC1+8LzMGfWzVUbY0C0Bwwx J6KjPzgx0lDTwPPHpgJ4v0kyWSzgGH/Ogd4GY+dQlj6dtPlDWu2g3UoftT7ZppeTuWVGwg+Sloq UYsMUg0ZxTEDMIGFyv8DY3WoBLqAROyfLu7gPQah2lyNwWuc42XV87sizodz7c+CbK1Dr/7NQGU KNXSBNZ4dnvXUGdxRmSIrllyXVSRwrTEC2s6AQ5HYPxcGYMYMi3NFUB X-Received: by 2002:a05:600c:c3db:10b0:49f:fe89:efca with SMTP id 5b1f17b1804b1-4a18dcde66amr145444135e9.19.1791816803828; Mon, 12 Oct 2026 07:53:23 -0700 (PDT) Date: Mon, 12 Oct 2026 16:31:54 +0200 Subject: [PATCH v2 01/50] docs/system/arm/aspeed: add the catalina-bmc machine MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-1-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815519; l=1992; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=jOGxphM6i2yuU0VVdWKJiaxsh0O18wnvUcN3/3+xhQk=; b=BndPsP7EPmKREvNz3huXhMaogYdbZ2XWQyFcgAHmOv4OvtApr069o6KfEFX904R/m1h50qU0X sIuOVxop7ATBZznxmEHi1kwyMIHTNHjSxsT2wMUHJo2W82YNuTRofrS X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.43; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f43.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791816862881158500 The Facebook Catalina BMC machine is supported by hw/arm but has never been listed in the Aspeed documentation. Add it to the AST2600 machine table. While at it, shorten the document title. Listing every machine name in the title duplicates the tables right below it, and made the title (and its underline) grow past 350 columns. The machine list stays available where it is readable, in the per-SoC tables. Signed-off-by: Emmanuel Blot Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Jamin Lin --- docs/system/arm/aspeed.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst index 2d51ceeb84..933df41f96 100644 --- a/docs/system/arm/aspeed.rst +++ b/docs/system/arm/aspeed.rst @@ -1,5 +1,5 @@ -Aspeed family boards (``anacapa-bmc``, ``ast2500-evb``, ``ast2600-evb``, `= `bletchley-bmc``, ``fuji-bmc``, ``gb200nvl-bmc``, ``fby35-bmc``, ``g220a-bm= c``, ``palmetto-bmc``, ``quanta-q71l-bmc``, ``rainier-bmc``, ``romulus-bmc`= `, ``supermicrox11-bmc``, ``supermicrox11spi-bmc``, ``tiogapass-bmc``, ``wi= therspoon-bmc``, ``yosemitev2-bmc``) -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Aspeed family boards +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 The QEMU Aspeed machines model BMCs of various OpenPOWER systems and Aspeed evaluation boards. They are based on different releases of the @@ -33,6 +33,7 @@ AST2600 SoC based machines : - ``fuji-bmc`` Facebook Fuji BMC - ``bletchley-bmc`` Facebook Bletchley BMC - ``fby35-bmc`` Facebook fby35 BMC +- ``catalina-bmc`` Facebook Catalina BMC - ``anacapa-bmc`` Facebook Anacapa BMC - ``gb200nvl-bmc`` Nvidia GB200nvl BMC =20 --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791816910; cv=none; d=zohomail.com; s=zohoarc; b=d+Fwp8dgKhbEPe9btwvZ+2VA8PlxagHlSF8r0zZHHUsg2KM1m7Ahb/ZQYL3547AlqT2q9iJIIAUKOVtPfiOeL+c4I0ds2gUtorIPFBWkhUmfTc1Dev5oO/OQ1rZZ57fz0QYLurZEOYNmZguEp+WgQa+mlGyj+duF1l1q7UXFEmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791816910; 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:Sender:Subject:Subject:To:To:Message-Id; bh=pWk7MV0WjBOJc/s9RX0ZBDFXEdiiCKZ4mANozxUHjQs=; b=OMn6b/06X6+3EUtr2Aeih0usBEbjb1Sjks4auTJ1QEO39OgZchmUo5/kKhYAlzGVHZwv5jfla5CHUzrgwCBFOYf5kdPWoka74xaWUl1pVsm2BKNRdP5ig36297ILqIxmK4Xof3no9a6a2LvVlpLZWvOUT/J1/G3evLd/38eCQZs= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791816910467527.1199956111644; Mon, 12 Oct 2026 07:55:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHQU-0006Td-8Q; Mon, 12 Oct 2026 10:54:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHQ6-00063v-O3 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:54:32 -0400 Received: from mail-wm1-f54.google.com ([209.85.128.54]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHQ3-0004pZ-93 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:54:29 -0400 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4a161d9b8c7so13596915e9.3 for ; Mon, 12 Oct 2026 07:54:26 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18bf2343asm545123275e9.9.2026.10.12.07.54.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 07:54:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791816866; x=1792421666; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pWk7MV0WjBOJc/s9RX0ZBDFXEdiiCKZ4mANozxUHjQs=; b=pjF7UKcoQiyLaWkmbh9jqEeLTkmPa2r261DXi9YKcHKz3QTTj7dcDLczdzrF6AJ76P ud8YiRX/bKz2nPTX3/8iYjGyQwbQr/wfUTo/72UTaDETHz4cuqgeH19jeAr+YI4iNMBR qsNMan7L0OQgjo11tDfknZSb5o53cfoSJzilnJdsQ3DN+ZaSRmVzy5Go4rXvr+5kaBzi Umaw8jU4+v8B5UP6zghJmEDn8sfSL3l/Z2QycpDrqTcWGA9QMGlwQM3m19nUhNvnF5Uf gqJjxEQOl9/9FOijk8qdhE+XwnAURp315iSksmNByMf7s8VXe/i8UAsaK4dwCRRV34ff 4cdA== X-Gm-Message-State: AFq9FYIZit03N4pOftdGvWUJAKM8RPxb7SkPMhLliCqVuVmhAXyF/WnD v1qKQKUCaiOpHpbw+riPV+Xi2pNtxY0Btv8J1UpDEYX5pQ3r8FfzDDYQR9++puig X-Gm-Gg: AYBFou0oc0W/WjXi+gJMLSCWGDPY2I+HpH84SeTG7zwQHe1RpUC/QmzV7HuGUP8wl0+ baAVoNNMzvHBl8i9zlfC98ZDCw7xSKIEFSniemW6D9InhGvGgr6XQbPtaol9SVYILl5whtmCIMs NIvHhy1IBmDeO0BpfqZGvDVi1nqNPO3IoMU1MmSP4ljaHScgRdzmB2WsTuSbROQTkZPMIjb4xyb gRA1EZ01d+bPvtdvs0FYhlMzfp5K8Z3qBST1EqMnigtZ38tOh/3XF9n4d/3D0imkNSnG0Z+0jv2 +vR3XCJHWmoTG0IulPKa72hnNj1GUJIvgKjw8BdtKwa7J71EsKw4MctpR/Dxsi36XgBMyQe6mPR e3KrLjtj5kdjdmbIKZQ6jynSfWfEOCz0q/yfZRlqV1urArwu1aR516yiGM0yt6OqGI2IgsYir1/ Oxqn4blOHqDoE5RbMCOCBNtVEN+hqLYVkVavmFv7HHXxKss86Wi2J5nqesmSB//lqTdXYH7p5nr ESu6v/J8+3fUuCzrcybxT5FwZnWZmzo1LVbGFz9RUEcFw== X-Received: by 2002:a05:600c:3f06:b0:49f:bc43:9e96 with SMTP id 5b1f17b1804b1-4a18e4a3bfbmr201172005e9.8.1791816865607; Mon, 12 Oct 2026 07:54:25 -0700 (PDT) Date: Mon, 12 Oct 2026 16:31:55 +0200 Subject: [PATCH v2 02/50] docs/system/arm/aspeed: add the sanmiguel-bmc machine MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-2-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815519; l=827; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=OuuDyLAyQiERaSazvNIfVs0crUzUw8PgfLhgJ7loAvM=; b=pDhb/aaq1Q7JVtjkYsscfH2BbmpFFdn+Egv5r4iRD6RKiUf10/g2BFeWayUp/whjJkXOprlY5 a39annO85fdDkYxQr2IuDSUGmQGNCpjHT+fptASOKc6s7NsU5ok6MKe X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.54; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f54.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791816913759158500 The Facebook SanMiguel BMC machine is supported by hw/arm but has never been listed in the Aspeed documentation. Add it to the AST2600 machine table. Signed-off-by: Emmanuel Blot Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Jamin Lin --- docs/system/arm/aspeed.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst index 933df41f96..f38f33cbe1 100644 --- a/docs/system/arm/aspeed.rst +++ b/docs/system/arm/aspeed.rst @@ -34,6 +34,7 @@ AST2600 SoC based machines : - ``bletchley-bmc`` Facebook Bletchley BMC - ``fby35-bmc`` Facebook fby35 BMC - ``catalina-bmc`` Facebook Catalina BMC +- ``sanmiguel-bmc`` Facebook SanMiguel BMC - ``anacapa-bmc`` Facebook Anacapa BMC - ``gb200nvl-bmc`` Nvidia GB200nvl BMC =20 --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791816947; cv=none; d=zohomail.com; s=zohoarc; b=dS1jyOzxLWdHn4RhPICTDd4CZjdM80+teon663aXIw3+ruuHVJoPS54R07rypiv6F1HrQ0Zk/f3278WsF2kKgX9dUORvfGYKQcCBGBzwe1Cx6snf59/U4fW5WMWfm8XR2hvgG39aFHrE2l7mZnGtHHxPc0oern9jaNAmTtxizU8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791816947; 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:Sender:Subject:Subject:To:To:Message-Id; bh=ImldGJ+S970Bf5OYd6GaXlG8v143fN7qBqQiDylCmP4=; b=FMXX/qW98M2TaggwZm+camgnNS0Se7k5IPgYy488zih6kShZLuLij6uxEuOP2NfqPzIT9A6qCBSSmxdcpJpc2tbnHZFj7iBHI1CMtVtjsHXLFPG4XNzpjt/1CDDum+Be+Y4f1NrhMj0+6vIoWyyAZNuHxYasH1qUZ48/opFyzKY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791816946852686.8431413434739; Mon, 12 Oct 2026 07:55:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHRF-00086y-AB; Mon, 12 Oct 2026 10:55:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHR6-0007yM-DB for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:55:33 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHR3-0005Ie-Ob for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:55:32 -0400 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4a166199820so12643295e9.1 for ; Mon, 12 Oct 2026 07:55:28 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18bf2e0dbsm312212015e9.11.2026.10.12.07.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 07:55:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791816927; x=1792421727; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ImldGJ+S970Bf5OYd6GaXlG8v143fN7qBqQiDylCmP4=; b=iB8EL5kfgkl34Zs4qZ7WAHSPHjhndA5YP9HePBDtpAu/Ik0qcf1xVhSrpBP7XyMota 34G9s9QbkW+l0Ofh/M6dzeEmA3mbtLdWOWC7WwM0WBpYNNZCFNezKcCDw6S9agk3ayxU B+1BSMbXUC0v1e15HKvNnJx3ZEEPvFdp7avzBIaLxzlydFn0+UouqheSE6DdKRDU2m1C EMhl6S4T7S4Yh7H8P7BjOZiWU9pXS22IczyX2tIxA5rrSrpTKIPRpvuyYv7ovn/Z7leY vof55youon5GKZNTa83vunXg1A9qyNW9EzmoXGdfPCtndCeMUonwrBOCe70BIfrO5Zjj fFYg== X-Gm-Message-State: AFq9FYJ3EWsJmVQBvYFVHtzdx150PsBcQYjE7FMj3c+cupXKRZixv22h IdUKNS4Pr3OsnocyYGVLD+eTHV+1x6UMHUyB9jfstdUKridSY6cG+WEFQS2khUlh X-Gm-Gg: AYBFou2MSlcga6sLf/vLQ8gmFvLCyiCwLWFC2Kj3lmcC2AygjfB4C3V4JL2eZT3I7P3 Tr/uXTFETTvmrKK3u766LvdT3RaULTdjJHfxgQMssvI4bLExSMu2pYive+Pt+8cbzuHr57T/xUG BJZTcdqR8WHVlWSrahGYzGeAjAe66NrslcdIFnTf+Ztb+b8bbu2qy0968tGj8yhCaDDP68bVO77 II9RxDqT4eOtbm8NrWZM0EUgCtKa0uGfczu4WBQUXj44a4vetg0qJLFoD73sS4FN25VSQhi/yVv Wb6FcPUx+djvvHoCDidVu04oH4du0eYn09fbJkHuNpEa21vMEObfpWCrqjoNkOAJZ9UaOyPVk1c gYYCvgUett9JyEKt83Z1r/Yick/XfuZDCp+ht0q3TFtaLkOHqhMMd5ohuqeSBkv5cmg2z6Pr22B bNWko+J1MPpddo4VL4aU71temgXIWwaFbmqrw3Sb1Nj3l7PtUGdJBQ0KgARUViKPCYDreHQvwN2 CXYHYZ3ERHHdmDBRPySDM4mjqEfxEiN/KJ4HFp7zjs+nUi7d5yt09vW X-Received: by 2002:a05:600c:8b78:b0:49e:65f2:db64 with SMTP id 5b1f17b1804b1-4a18e4837f2mr176377965e9.5.1791816926905; Mon, 12 Oct 2026 07:55:26 -0700 (PDT) Date: Mon, 12 Oct 2026 16:31:56 +0200 Subject: [PATCH v2 03/50] hw/arm: sanmiguel: remove the second SPI flash controller MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-3-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815519; l=1273; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=d5avXaQSHf6bIfiDvZv67RY5xgd1U3dm0wZh/dvYVAk=; b=M4EuneDWmdSo+VtSiaypHuk5+OfyPHsRFymuYjEK1qqATk/7ayeW0LBEEEiBPYzFJmbzIduyd R3YCUJRus7NCKQNRfHveC+Klhxdd6mCFzXBTgwRcm6g7weRdqcb+h2e X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.42; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f42.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791816949999158500 The board only populates the flash device attached to the FMC controller; the SoC SPI controllers are left unused. Advertising a part there presents the guest with a flash device the hardware does not have. While here, add the missing year to the copyright line. Signed-off-by: Emmanuel Blot Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Jamin Lin --- hw/arm/aspeed_ast2600_sanmiguel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/arm/aspeed_ast2600_sanmiguel.c b/hw/arm/aspeed_ast2600_sanm= iguel.c index 345a9c9416..ac2aef740a 100644 --- a/hw/arm/aspeed_ast2600_sanmiguel.c +++ b/hw/arm/aspeed_ast2600_sanmiguel.c @@ -1,7 +1,7 @@ /* * Facebook SanMiguel BMC * - * Copyright (c) Meta Platforms, Inc. and affiliates. + * Copyright (c) 2026 Meta Platforms, Inc. and affiliates. * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -384,7 +384,7 @@ static void aspeed_machine_sanmiguel_class_init(ObjectC= lass *oc, amc->hw_strap1 =3D SANMIGUEL_BMC_HW_STRAP1; amc->hw_strap2 =3D SANMIGUEL_BMC_HW_STRAP2; amc->fmc_model =3D "mx66l1g45g"; - amc->spi_model =3D "mx66l1g45g"; + amc->spi_model =3D NULL; amc->num_cs =3D 2; amc->macs_mask =3D ASPEED_MAC0_ON; amc->i2c_init =3D sanmiguel_bmc_i2c_init; --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817016; cv=none; d=zohomail.com; s=zohoarc; b=WdTk3pBKXLdgvd1tYJaEcun6lmwRPrG/8g/q5JN7uz3qjpGs08trnB9zNavJ/Pe1h4+xL9BobhMuTWaW6rkOTs6rqKNSP6qOKqXe1YuukYB00xDOu7PfcFHLCEo1yRJLeq1QXAQ8mWNKwy7JHKsj5t55ay8xN8PvBtW6lxaAUrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817016; 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:Sender:Subject:Subject:To:To:Message-Id; bh=MVSG8EzaWLj+Z754/87jnXfWdb4zSMi3q66mrxn3Q8s=; b=QsP1Yt8/lSuv3yocqO3Izc6p0+IQDjbTZkgDwd5JnPDPLE0YbVedrtEOs9H9vBPZsMXon0aqjPcpoZ+yem0Ij7H+1nyh1P3zQFZP9Y5lcYM2igl3D0GvFS31nTHP57ENf6/jazeH/zP6E7QAVtAOt9U6tQ2/QBBNAXYZCZugNf4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179181701682798.0252238415161; Mon, 12 Oct 2026 07:56:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHS7-0000Mq-U0; Mon, 12 Oct 2026 10:56:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHS4-0000Jn-1q for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:56:32 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHS2-0005S0-0s for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:56:31 -0400 Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-48af4d4e61fso1387525f8f.2 for ; Mon, 12 Oct 2026 07:56:29 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48db9abd57fsm19265393f8f.37.2026.10.12.07.56.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 07:56:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791816988; x=1792421788; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MVSG8EzaWLj+Z754/87jnXfWdb4zSMi3q66mrxn3Q8s=; b=dRU0/BS764kaOHD7XWfmUUk/l5NhilFwATAZaTj8IZGI8zK/vVlyhs9nVbEX4MT/hi vcpwDJOplhMG9gWpZiTDnZUdZluzuv3Bb83VEP+Z9D3qGvO2NFJaSrPu2oeBrTPu+m8z MubkhhZyUiaelRjw5C4mwMmku86u++WwodqbOGyRBX9IW7n9ppJWAvFVOLR2Vp3Ve4Cq 8nD8y4Uu3Etb8nGnU1QyY52YxPM2XzsNuWLOpSX9GpFENES1AJaS348uKRSbGGWTmHCz +1EHOysdxxsbfIbU8WK+Wd66qTPjtbw8oDwb/CwqI4aPunZSaahy0eDjwUTGjuBrUSJ7 2+EQ== X-Gm-Message-State: AFq9FYLZXhXaqEyOwwgJfBItcbok1vtkYBbqhzB2PF9i4ueTiQ5Vt6vn NuXDz68/Ds+ByPWiBYqkJ0GeV9vut602sq91JBAjPwWPyvALsuheQgomWvQpJZK3 X-Gm-Gg: AYBFou0U68tSaMBpkEAl2p1kGyG548BrbsVScx9IyqC706gRGitjnD6QnCxJjX27RN2 PaeU313F82po8t57xiLPA3vNOdiVI8NhImLqEFWun+pLi0uGI6uGH9iAxCOqsmsptLf+FxQQtIj faIXFwaRdw+RSEQTQYokRbnPEcSSbiF1bqgI8uAkkJ6bIUDhKuCrBOnrRrHeYAqUVI80kOKH5PU At7kIA7q/kPOr1TgV4yp+CO5Ulz3De44pqpMcEOcR96/i7oK6SaCPKbdzGbY0gaCr6KloM0GYYK IOZf6If1uji+NhdkgBBPQAYNrwlk89HbwtE+aVUEWFpnuDb35sEtt6k3cV94ON1ktaaPZzXUIaw cJpLd56e8MzDGYVFhwt65AfZrsAHcdHhBFDvya/t56R2Waj8j6tf+x8eZ1Z1T7I1Fmg/AfXfwxN mJ6/JCp4RWgHdXThmf1k1Iz7eIQrlsPTidMAYnZtDYK7OUzU3GK9H/4+tRW7dILdBwBL/EIJV9q SAM69Jycl/CW0BGN/RWPMU5KewRacY/jZ9Hj/ZLa6bpwQ== X-Received: by 2002:a05:6000:3102:b0:48d:ca32:e90f with SMTP id ffacd0b85a97d-48dca32e9b5mr11121631f8f.55.1791816988226; Mon, 12 Oct 2026 07:56:28 -0700 (PDT) Date: Mon, 12 Oct 2026 16:31:57 +0200 Subject: [PATCH v2 04/50] hw/i2c: pca954x: drop unused header inclusions MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-4-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815519; l=838; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=b9K700bDZsWgDrz5nZ97CmrXARWhU1wSPXweUqGmEJM=; b=Tl71FE+9JTd2lCFH9MHeRy9QCAflu+bF7+oW1C+qsX1R2DLonL4r/bn1gjB2xxkmFQeDlxpZc +kpBqMhNRD0C6okC3kOgx6cDYO2/aPSPQiSICheFlZcE4sPWrBhIhBS X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.42; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f42.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817019209158500 The qapi/error.h, hw/core/sysbus.h and qemu/module.h headers are included but not used by i2c_mux_pca954x.c. Remove them. Signed-off-by: Emmanuel Blot Reviewed-by: C=C3=A9dric Le Goater --- hw/i2c/i2c_mux_pca954x.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c index c603446028..c8e75da8b2 100644 --- a/hw/i2c/i2c_mux_pca954x.c +++ b/hw/i2c/i2c_mux_pca954x.c @@ -15,15 +15,12 @@ */ =20 #include "qemu/osdep.h" -#include "qapi/error.h" #include "hw/i2c/i2c.h" #include "hw/i2c/i2c_mux_pca954x.h" #include "hw/i2c/smbus_slave.h" #include "hw/core/qdev.h" #include "hw/core/qdev-properties.h" -#include "hw/core/sysbus.h" #include "qemu/log.h" -#include "qemu/module.h" #include "qemu/queue.h" #include "qom/object.h" #include "trace.h" --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817061; cv=none; d=zohomail.com; s=zohoarc; b=gpzrJwxLcabj2+hbnRDaD6PnPrew9zy6InK3UuV+oOvSKdlSIKDJpomxdH3ASQ3ZUj63qJ+785cHOI06RXE19to2sjKRT/9CjF90tvTOQeFt1egjdM4SiQZiR6zkL/RJSEk59tKZxid3+hVu4/7w+bDYpKG54d8Ve7gqwHXxZUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817061; 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:Sender:Subject:Subject:To:To:Message-Id; bh=ck3CEQnd+90nZi0PVMSkxvUrGGVcHfbcdge1sB9r9S4=; b=PAdgfhv7ddp3ckK4N2pHCczZ0W41rtiYSXlwUnWyY88CIodfqL56bKSrudrkyXDz7lUXAnv4aQawiOdKlQZ6v9OlR/DblqD7KsCbCSKl9TLtIyDY28eSj51gOTPyCOEVIWjyac8thQxX9jwpsVgCoWUP0783jIyv5Qg65fYrPfU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817061838838.1409822061697; Mon, 12 Oct 2026 07:57:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHT7-0000xH-5Q; Mon, 12 Oct 2026 10:57:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHT3-0000wV-Az for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:57:33 -0400 Received: from mail-wr1-f45.google.com ([209.85.221.45]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHT1-0005ZP-Cw for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:57:33 -0400 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-48c4649b3aaso1168798f8f.2 for ; Mon, 12 Oct 2026 07:57:30 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48db9ac02cfsm18873073f8f.39.2026.10.12.07.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 07:57:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817049; x=1792421849; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ck3CEQnd+90nZi0PVMSkxvUrGGVcHfbcdge1sB9r9S4=; b=oV8DoJtUocCWPlLndmK2Ww9QS0n1QYd6nuZNdVBjtafPTujgEWb4ki2izt8UwdZy1U JaluRiQjZKl0WAKXZ/oXRiIjJgsCiQHPRf5/B8JpRdXwXJFn6haKaESet9lZ6CHQFoIf 2GHLEN6mq//yq6aVXUKUlmJAtRncitufZcVK1vdT5aRNvx+nl7LSboNrbD9s79O8N6AX TkP/ohvevi49iPKgpcOv240p7ohtegVRUO8RRJcCyvXXXgDL/wTtuj65/iKYKor6LXGF rE3FbYTA7niG80PCLRJZZiFY+DCPxAhSzoSyrueaksPyf6FhsoekbPq/DqWQlt8FOo/m Uwjw== X-Gm-Message-State: AFq9FYKspjmdIlPRwMllNPBjcdnwf7g8ESyBfcpZCS0oCsUd5byfr4cg SDY350UPzGr2RKcf1lAd3cZO8LeI2ox15qqrO4CKYAu5UE2liDgWS4PCBTYY8ATv X-Gm-Gg: AYBFou0SlYlCW7tjiZl+XSpiTnNM2cGDwBchZDxBPv+FSCcjiKVAdlD0QmS3/5zTfCM I5PnQRDLSr78l/BXFhIztlWpy1grgEx6FdFnPykFw/uYKY6QfDErmiMWw9cB3H141JUN78cn206 ALHYAps77zZ9bm96DT36AFAaQ37of1R6GpevXpOA5r2Xgl3aD9MxFpoXSCFstc84a83x1dedYj/ n9KxtA7RlG2IKQi+DmwKezuKNZ4v5P1QsH9BJzGcYQejQLsaARU3Pgu0tg9akzYdglkQCze6sk7 +wAVrIkbGvrl2aiG4UuTjBs7EjUJJlFM7Od+KFnglTKNA/yd9zIjfgKzg7mxrsN/ZEXSGCjdlUY 3N0e438/VQ474VaOowdFdlnVcrcQooVEFS3XEx31041+xsbDA0IBbbdHSpz8ITd5TgFR/Imdbyj oc71iVi5RV6N9QBpgkgHrkmmxJ1hdvcwluErwwwyfcmi0VWMaLYtkn3eurYN3UAp1ji4/QPnUQM FCOGVRGa4JuuoDqNUXKRJKrWP7XJknO/XMI3c+mUC8z3g== X-Received: by 2002:adf:ed90:0:b0:487:1646:8740 with SMTP id ffacd0b85a97d-48dbaaeab93mr13395801f8f.29.1791817049381; Mon, 12 Oct 2026 07:57:29 -0700 (PDT) Date: Mon, 12 Oct 2026 16:31:58 +0200 Subject: [PATCH v2 05/50] hw/i2c: pca954x: add PCA9545 4-channel mux model MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-5-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815519; l=6615; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=guhP+3BLl/RYjFmMgEVS/5ykcSVJY8JOeua1R3YAv18=; b=Gqpg+agYb3dqrWFh9kXFsNENYITjwNhxpDiAUIvkQIdB/6zIbqhRnQiZldzXd/V6nto3PbNhc 5xzjyPjfqibDI/kfQgQ+nud/EDzI5ibD8fbDmhsWSWEAui9fEPEUzel X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.45; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f45.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817064009158500 The PCA9545 is a 4-channel I2C mux/switch. What sets it apart from the plain PCA9546 is its interrupt logic: one INTn input per channel and a shared INT output, both active low, asserted whenever any channel interrupt is active. Model this behind a new has_irq class flag. The PCA9545 gains four named "interrupt" GPIO inputs and an "interrupt-out" output, and its control read-back merges the latched status nibble; the plain PCA9546/PCA9548 switches keep their previous behaviour. Signed-off-by: Emmanuel Blot Reviewed-by: C=C3=A9dric Le Goater --- hw/i2c/i2c_mux_pca954x.c | 71 ++++++++++++++++++++++++++++++++++++= ++-- include/hw/i2c/i2c_mux_pca954x.h | 1 + 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c index c8e75da8b2..4bb078a03c 100644 --- a/hw/i2c/i2c_mux_pca954x.c +++ b/hw/i2c/i2c_mux_pca954x.c @@ -12,12 +12,20 @@ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. + * + * Limitations: + * - A control write longer than one byte is rejected rather than retainin= g the + * last received byte as the datasheet specifies. + * - On reset the cached per-channel interrupt state is cleared; a downstr= eam + * INT input that stays asserted across the reset is not re-sampled unti= l it + * next toggles. */ =20 #include "qemu/osdep.h" #include "hw/i2c/i2c.h" #include "hw/i2c/i2c_mux_pca954x.h" #include "hw/i2c/smbus_slave.h" +#include "hw/core/irq.h" #include "hw/core/qdev.h" #include "hw/core/qdev-properties.h" #include "qemu/log.h" @@ -26,11 +34,15 @@ #include "trace.h" =20 #define PCA9548_CHANNEL_COUNT 8 +#define PCA9545_CHANNEL_COUNT 4 #define PCA9546_CHANNEL_COUNT 4 =20 /* * struct Pca954xState - The pca954x state object. * @control: The value written to the mux control. + * @int_status: Per-channel interrupt status, for parts with interrupt log= ic. + * @int_out: The mux INT output, driven low while any channel interrupt is + * active. * @channel: The set of i2c channel buses that act as channels which own t= he * i2c children. */ @@ -38,6 +50,8 @@ typedef struct Pca954xState { SMBusDevice parent; =20 uint8_t control; + uint8_t int_status; + qemu_irq int_out; =20 bool enabled[PCA9548_CHANNEL_COUNT]; I2CBus *bus[PCA9548_CHANNEL_COUNT]; @@ -48,11 +62,13 @@ typedef struct Pca954xState { /* * struct Pca954xClass - The pca954x class object. * @nchans: The number of i2c channels this device has. + * @has_irq: Whether the part implements interrupt logic. */ typedef struct Pca954xClass { SMBusDeviceClass parent; =20 uint8_t nchans; + bool has_irq; } Pca954xClass; =20 #define TYPE_PCA954X "pca954x" @@ -116,8 +132,10 @@ static void pca954x_enable_channel(Pca954xState *s, ui= nt8_t enable_mask) =20 static void pca954x_write(Pca954xState *s, uint8_t data) { - s->control =3D data; - pca954x_enable_channel(s, data); + Pca954xClass *c =3D PCA954X_GET_CLASS(s); + + s->control =3D c->has_irq ? data & ((1 << c->nchans) - 1) : data; + pca954x_enable_channel(s, s->control); =20 trace_pca954x_write_bytes(data); } @@ -148,16 +166,45 @@ static int pca954x_write_data(SMBusDevice *d, uint8_t= *buf, uint8_t len) static uint8_t pca954x_read_byte(SMBusDevice *d) { Pca954xState *s =3D PCA954X(d); + Pca954xClass *c =3D PCA954X_GET_CLASS(s); uint8_t data =3D s->control; + + /* + * On parts with interrupt logic the read-back byte carries the per-ch= annel + * interrupt status in the upper nibble. + */ + if (c->has_irq) { + data =3D (s->int_status << 4) | (s->control & 0x0f); + } + trace_pca954x_read_data(data); return data; } =20 +/* + * A downstream device drives one of the INTn inputs. INTn and INT are act= ive + * low, and both carry the physical level: 0 is asserted, 1 is idle. + */ +static void pca954x_irq_handler(void *opaque, int n, int level) +{ + Pca954xState *s =3D PCA954X(opaque); + + if (level) { + s->int_status &=3D ~(1 << n); + } else { + s->int_status |=3D (1 << n); + } + + qemu_set_irq(s->int_out, s->int_status =3D=3D 0); +} + static void pca954x_enter_reset(Object *obj, ResetType type) { Pca954xState *s =3D PCA954X(obj); /* Reset will disable all channels. */ pca954x_write(s, 0); + s->int_status =3D 0; + qemu_set_irq(s->int_out, 1); /* INT released */ } =20 I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t channel) @@ -169,6 +216,13 @@ I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t cha= nnel) return pca954x->bus[channel]; } =20 +static void pca9545_class_init(ObjectClass *klass, const void *data) +{ + Pca954xClass *s =3D PCA954X_CLASS(klass); + s->nchans =3D PCA9545_CHANNEL_COUNT; + s->has_irq =3D true; +} + static void pca9546_class_init(ObjectClass *klass, const void *data) { Pca954xClass *s =3D PCA954X_CLASS(klass); @@ -184,12 +238,20 @@ static void pca9548_class_init(ObjectClass *klass, co= nst void *data) static void pca954x_realize(DeviceState *dev, Error **errp) { Pca954xState *s =3D PCA954X(dev); + Pca954xClass *c =3D PCA954X_GET_CLASS(dev); DeviceState *d =3D DEVICE(s); if (s->name) { d->id =3D g_strdup(s->name); } else { d->id =3D g_strdup_printf("pca954x[%x]", s->parent.i2c.address); } + + if (c->has_irq) { + /* One INTn input per channel, plus the shared INT output. */ + qdev_init_gpio_in_named(dev, pca954x_irq_handler, "interrupt", + c->nchans); + qdev_init_gpio_out_named(dev, &s->int_out, "interrupt-out", 1); + } } =20 static void pca954x_init(Object *obj) @@ -242,6 +304,11 @@ static const TypeInfo pca954x_info[] =3D { .class_init =3D pca954x_class_init, .abstract =3D true, }, + { + .name =3D TYPE_PCA9545, + .parent =3D TYPE_PCA954X, + .class_init =3D pca9545_class_init, + }, { .name =3D TYPE_PCA9546, .parent =3D TYPE_PCA954X, diff --git a/include/hw/i2c/i2c_mux_pca954x.h b/include/hw/i2c/i2c_mux_pca9= 54x.h index 3dd25ec983..19a1050505 100644 --- a/include/hw/i2c/i2c_mux_pca954x.h +++ b/include/hw/i2c/i2c_mux_pca954x.h @@ -3,6 +3,7 @@ =20 #include "hw/i2c/i2c.h" =20 +#define TYPE_PCA9545 "pca9545" #define TYPE_PCA9546 "pca9546" #define TYPE_PCA9548 "pca9548" =20 --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817164; cv=none; d=zohomail.com; s=zohoarc; b=hzXKnyZLTByR6tzuqycP641RouCinsyLUQ0qwhMTnAg7aClr57dejWKSm6kpLCfeyHFs8MNwWECT/cKCel4yOfrHQd8P07DdpwQLkVe2VUbcSjU0v2bDPFJMqHC4FHmLEYyTHxhc0pqq8lf+EX8ggpkNPwEhJbMDxVtXM5BkzYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817164; 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:Sender:Subject:Subject:To:To:Message-Id; bh=cBS24KyVkFdx9K1mrb9mnaPLSyXbJlcPXKfV6TpuYbc=; b=ef3/kEwhzUUZGhuj9+5WMDFcFXLrHhzAOdXOhNAziBGURzVoyShw0/wkp2xdJ611O13HNDM9mUWd/zvF0oDUTz9+qCQOAt60t0T0wPGlmkO3Rt3xJ/cf6Urt5tIeUkqavIuXGofXsh7VxQGghiU+oM2shFm1yrqhR/iYgSRSL3c= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817164376800.1753889438199; Mon, 12 Oct 2026 07:59:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHUU-0001YB-1u; Mon, 12 Oct 2026 10:59:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHUB-0001Ui-Mt for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:58:48 -0400 Received: from mail-wr1-f52.google.com ([209.85.221.52]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHU0-0005fD-6X for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:58:33 -0400 Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-48afcd7ba9bso1115910f8f.3 for ; Mon, 12 Oct 2026 07:58:31 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48db9acfa28sm20117000f8f.51.2026.10.12.07.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 07:58:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817111; x=1792421911; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cBS24KyVkFdx9K1mrb9mnaPLSyXbJlcPXKfV6TpuYbc=; b=rrV7bYLJ89IOUjtkRC5saFigl9+O4TuT+dcX8W0rhnhxxydtx5CYH8q8Mpqm/0XxYe okt5wCSfW+007U6ZZiHV4CcbReAIYC4yKIXU/YBLWLvCSr4tLCHAggs9nCthjaZWduag GUGh0Y7NbAkj8NWD5MKRmhvC/nK4L9U8Am9KsTOi2LIkh+tldZ0hVXu8NzTOnlpw7pmQ KVkN3GdEZoDCEHdj4T504ek33iYI0Icx2mwMbo89SGEZK3iNyL+Rgp0650/Lv9jmqKuf Bh1x/2EVwIYupICIM48EHMfVkeOUVNTOsgTO6f41pIUtJpHUzVXh7LC0+FTdH75EiLbJ ZQNw== X-Gm-Message-State: AFq9FYICFPZBKzwzwZ4pFTegU/rx/1WKlWEb6C90yP5ylOY7qwgDJScB 3GTo6WP3k7MUapbhfbTjSPPZBY74KreWT04AYXAWOpejZinZEmHgEXz/hCbOr6Bc X-Gm-Gg: AYBFou0RkR+lImygEMIVO9ufQwuvH2EGxWwg5Y+dDXy9XjYXdlK6e4nspijhj0CL7LE 3bQe0h7urK0MiKOwuQNi3N4TUEIPivI2gAdF1MRfOfGoIbvcxR6s+c/lDtnzZv60Rbk+QptKC5t aLcZMm/ECqcxGMG9sHbGSTRaGwBbu6y2ws3s5kXrcufRVJNuu4aqzyD5YWRbP2E6rFEBtVD1KXH ZCdf8pJeQiLqmdwh61oClLsMsW6YEGyaciC+AXFeE7uNPDDX64zURZ5DfGA+pNM3mWg1mPCsttl jz+Nf0ygfCYAVe0CyJp75Q5nLvPwKALtkTs8gqXUerbuVNQY0iHHOifOjdRS8QoLFBDnkNP64rk nXD+/7mxbxz5DqBcbfE08RKAoG+LTjsThtIxA1YENEeGAVIUzbkot1XxBddqMruKJUJBC9BDT3R k3dcGXHHrhaaiGDyJ5ZR7JqjQqEHdzaukJppBUFoy43vZAQK/oLAEX5WBKxweBFy3wARtM1uz8s y6xtnH5h3Y2YsZfYa8M/Q1pnVI7rpdPg4uYsAhNUQXs7w== X-Received: by 2002:a5d:5e01:0:b0:487:35d:cb0f with SMTP id ffacd0b85a97d-48dbaadde6dmr19172721f8f.14.1791817110618; Mon, 12 Oct 2026 07:58:30 -0700 (PDT) Date: Mon, 12 Oct 2026 16:31:59 +0200 Subject: [PATCH v2 06/50] hw/i2c: pca954x: migrate mux state MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-6-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815519; l=1912; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=6X3qtF5y9bDFv2QNu2TGa306El/FnP4ElGjKxh8N7cM=; b=a/5no+gY9vkPrY0vzsK8im6C2uagcbkgarXXe3eLjxbo6dEPrkuWZVv3+pquCSlmGHutp1fVZ M4UyIV9d2W9BZCOIO8chhhFYJQro60j5KZq24p4nRLpQIdLv5ilwr2h X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.52; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f52.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817166023158500 The pca954x model had no VMStateDescription, so neither the channel selection nor the PCA9545 interrupt status survived a migration. This changes the migration stream of the pre-existing PCA9546 and PCA9548, which an older QEMU rejects. Signed-off-by: Emmanuel Blot Reviewed-by: C=C3=A9dric Le Goater --- hw/i2c/i2c_mux_pca954x.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c index 4bb078a03c..597e57d99a 100644 --- a/hw/i2c/i2c_mux_pca954x.c +++ b/hw/i2c/i2c_mux_pca954x.c @@ -28,6 +28,7 @@ #include "hw/core/irq.h" #include "hw/core/qdev.h" #include "hw/core/qdev-properties.h" +#include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/queue.h" #include "qom/object.h" @@ -270,6 +271,28 @@ static void pca954x_init(Object *obj) } } =20 +static int pca954x_post_load(void *opaque, int version_id) +{ + Pca954xState *s =3D PCA954X(opaque); + + pca954x_enable_channel(s, s->control); + qemu_set_irq(s->int_out, s->int_status =3D=3D 0); + return 0; +} + +static const VMStateDescription vmstate_pca954x =3D { + .name =3D "pca954x", + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load =3D pca954x_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_SMBUS_DEVICE(parent, Pca954xState), + VMSTATE_UINT8(control, Pca954xState), + VMSTATE_UINT8(int_status, Pca954xState), + VMSTATE_END_OF_LIST() + }, +}; + static const Property pca954x_props[] =3D { DEFINE_PROP_STRING("name", Pca954xState, name), }; @@ -287,6 +310,7 @@ static void pca954x_class_init(ObjectClass *klass, cons= t void *data) =20 dc->desc =3D "Pca954x i2c-mux"; dc->realize =3D pca954x_realize; + dc->vmsd =3D &vmstate_pca954x; =20 k->write_data =3D pca954x_write_data; k->receive_byte =3D pca954x_read_byte; --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817191; cv=none; d=zohomail.com; s=zohoarc; b=adWrS7MmGFZGofXwEHbkGdseOKgYKNgJhbId+Z9s8Qk4DOy7gUowImtE3NxVCzYomJKwSqMsN55T7nqOBqePWT1L7cEq9/Cl9kV8fe/WQVMqoFFXkPBlsRSSSuMiHzzUh3E9Ub4FEbD+l73LjYjHVKHISvF/wStkhL1x0WAJhMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817191; 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:Sender:Subject:Subject:To:To:Message-Id; bh=9Rfer8hh0Vvf5IwVCuxWXlCGZN/4Nsa/aOUTquN+KzI=; b=eVqGWFHbixEqwG87/UscuVbcCPbTD4hbwdl6YwnxkHSMkLKrHYRe1axtgHWMG4aLx2xUj9dzJwpfIUmC89Z15IljRsZohqXEmY8IWmsLs4eqKdcpbNM4e48MRKWo7J9DsbujYkclAPlN7hDmAjjKkcIPscC6QodmFecYgdFvIHE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817190979886.9835263397501; Mon, 12 Oct 2026 07:59:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHV7-0001xj-9u; Mon, 12 Oct 2026 10:59:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHV3-0001qH-Cj for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:59:37 -0400 Received: from mail-wm1-f52.google.com ([209.85.128.52]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHUz-0005kc-F8 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 10:59:36 -0400 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-49fbb2acc90so15646755e9.2 for ; Mon, 12 Oct 2026 07:59:33 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18bf2e0dbsm312446465e9.11.2026.10.12.07.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 07:59:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817172; x=1792421972; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9Rfer8hh0Vvf5IwVCuxWXlCGZN/4Nsa/aOUTquN+KzI=; b=Bay1Ved2n2sR2KBMzeYF0Bcs/RO9/Lcdmvj5WPX/CbGOaN/ts7wLsFDTHDLS9GX9AK /QzRaR/Gpieymjt6qEt8H3qoztMCgxtjp6j7FWGYBRJCmJqW09sT3sO+t3FMURMGE3IO FNPZNHl+5VfdjZK7YrtdT76tVW8+bMm7pwEkNY4o7KBaqtz88wwNzCZ8tPdL20DvDEKI m4gskbSbbvaLscNInt8w4fbJZXbxt8jvouHnMywTrrkOwY4zFgW21M9ZCk54VmiC0TnG y2abnvdLHu3neZQyDKsYfSTFyHDcLl/4fdwrW2kPHGIQ7TFk1Iqqub63b3qx+G2VzXxx bfMA== X-Gm-Message-State: AFq9FYIkXQpu5h9SObmI/+o12+BIKG6JCrsZwpooXMoYZ+x7tHsVEWMR kw0A1TP8b2OqhSpwQNjKXn3JVmC2EWVvlbiK36bFmF4ETde8N20QAPkdGIASA36k X-Gm-Gg: AYBFou3Ik9YFuY4gSmaTXA3KnRkeO32QBfXvT1/klayNhBnlG43XpvWzevuCrKuVn1Z L+yyKhM4Q8g4b3xp3vq6bpBG2O3VN/JPaOaX8oV7fDgSrkKztEUBKpYq7GJ5ZnTQGikvCCxPtwz nUJjixcvFzs62mh3SWs4VnCC14Wa30HrQMoLS4o1fAZ47Np4gL2LY9gOFe37SLb40W180j1oCN4 hNmskeRZz8uEz1CsNaIy1zc2YUFlpfG+yU5QxH+iOjTaJsO2DtYYwOdPiGZaVRUnvE1k/a5E2MF vk964O13102KxxIGVbSETp5gviB4msfT0+Ot85HTJVuhp4iCKjlTBqpZLi9O/uMRxeVvRXZzBmJ tqpePDzgeEJlV+97SBmA5IwRH7K0/Hw4f5es7oPf0ugBv1/X+QlRdOx/uHD2Tdd2EglH+vjTZW1 dV8lbbAsp/eel0JsoJAA3p760g3KgAW7jc8JlLVzUpJBSx+zSwgeD+HEYeYDFDmf3OtgtKbCGCm 8XNg50Ml8hz43uIAEZqwAHY2vIrpoJxEVUcVaGpVqxvbg== X-Received: by 2002:a05:600c:8b74:b0:4a0:2847:b6ee with SMTP id 5b1f17b1804b1-4a18e4fb8c1mr183422435e9.35.1791817171791; Mon, 12 Oct 2026 07:59:31 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:00 +0200 Subject: [PATCH v2 07/50] tests/qtest: pca9545: add mux test MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-7-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815519; l=4644; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=72voOzSuCaCvtExlGMvR/ZyC+1zQC+N/iYCSHIdJEEY=; b=hO1AVeCoe5RAYmDOO8pUyHooRQL7tTrdKKZQeOgRAl1Th9ITISdPnVn/93Hehj7eU2IwO3M2G GIclfDYxaB0AKAbZ1w+Cvvi/MeJPbsmacKlhwN4ijSOcWIxcJpi07fJ X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.52; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f52.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817192313158500 Exercise the PCA9545 4-channel I2C mux: channel selection through the control byte, upper-nibble read-back, and interrupt logic. Signed-off-by: Emmanuel Blot Reviewed-by: C=C3=A9dric Le Goater --- tests/qtest/meson.build | 1 + tests/qtest/pca9545-test.c | 116 +++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 117 insertions(+) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 200abf6f36..e05d8a07b9 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -336,6 +336,7 @@ qos_test_ss.add( 'ne2000-test.c', 'tulip-test.c', 'nvme-test.c', + 'pca9545-test.c', 'pca9552-test.c', 'pca9554-test.c', 'pca9555-test.c', diff --git a/tests/qtest/pca9545-test.c b/tests/qtest/pca9545-test.c new file mode 100644 index 0000000000..91f56db92f --- /dev/null +++ b/tests/qtest/pca9545-test.c @@ -0,0 +1,116 @@ +/* + * QTest testcase for the PCA9545 4-channel I2C switch with interrupt logic + * + * Copyright (c) 2026 Meta Platforms, Inc. and affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "libqtest-single.h" +#include "libqos/qgraph.h" +#include "libqos/i2c.h" + +#define PCA9545_TEST_ID "pca9545-test" +#define PCA9545_TEST_ADDR 0x70 +#define PCA9545_TEST_PATH "/machine/peripheral/" PCA9545_TEST_ID + +/* INTn and INT are active low: level 0 is asserted. */ +#define INT_ASSERTED 0 +#define INT_RELEASED 1 + +/* The mux has no register pointer: a read/write moves a single control by= te. */ +static uint8_t pca9545_get(QI2CDevice *dev) +{ + uint8_t val; + + qi2c_recv(dev, &val, 1); + return val; +} + +static void pca9545_set(QI2CDevice *dev, uint8_t val) +{ + qi2c_send(dev, &val, 1); +} + +static void pca9545_set_int(unsigned chan, int level) +{ + qtest_set_irq_in(global_qtest, PCA9545_TEST_PATH, "interrupt", chan, l= evel); +} + +/* Channel selection is the lower nibble; the upper nibble reads back 0. */ +static void test_channel_select(void *obj, void *data, QGuestAllocator *al= loc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + g_assert_cmphex(pca9545_get(dev), =3D=3D, 0x00); + + pca9545_set(dev, 0x05); /* channels 0 and 2 */ + g_assert_cmphex(pca9545_get(dev), =3D=3D, 0x05); + + pca9545_set(dev, 0x0f); /* all channels */ + g_assert_cmphex(pca9545_get(dev), =3D=3D, 0x0f); + + pca9545_set(dev, 0x00); + g_assert_cmphex(pca9545_get(dev), =3D=3D, 0x00); +} + +/* + * The interrupt status is reported in the upper nibble (INT3..INT0) and is + * latched regardless of which channels are selected (PCA9545A Table 5). + */ +static void test_interrupt_status(void *obj, void *data, QGuestAllocator *= alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + pca9545_set_int(1, INT_ASSERTED); + g_assert_cmphex(pca9545_get(dev), =3D=3D, 0x20); + + pca9545_set(dev, 0x01); + pca9545_set_int(3, INT_ASSERTED); + g_assert_cmphex(pca9545_get(dev), =3D=3D, 0xa1); /* INT3 | INT1 | chan= nel 0 */ + + pca9545_set_int(1, INT_RELEASED); + g_assert_cmphex(pca9545_get(dev), =3D=3D, 0x81); /* INT3 | channel 0 */ +} + +/* The INT output is pulled low while any channel interrupt is active. */ +static void test_interrupt_output(void *obj, void *data, QGuestAllocator *= alloc) +{ + qtest_irq_intercept_out_named(global_qtest, PCA9545_TEST_PATH, + "interrupt-out"); + + /* + * Interception starts with no recorded level, so drive an idle input + * first to make the mux publish the released state of its output. + */ + pca9545_set_int(0, INT_RELEASED); + g_assert_true(get_irq(0)); + + pca9545_set_int(0, INT_ASSERTED); + g_assert_false(get_irq(0)); + + pca9545_set_int(2, INT_ASSERTED); + g_assert_false(get_irq(0)); + + pca9545_set_int(0, INT_RELEASED); + g_assert_false(get_irq(0)); + pca9545_set_int(2, INT_RELEASED); + g_assert_true(get_irq(0)); +} + +static void pca9545_register_nodes(void) +{ + QOSGraphEdgeOptions opts =3D { + .extra_device_opts =3D "id=3D" PCA9545_TEST_ID ",address=3D0x70" + }; + add_qi2c_address(&opts, &(QI2CAddress) { PCA9545_TEST_ADDR }); + + qos_node_create_driver("pca9545", i2c_device_create); + qos_node_consumes("pca9545", "i2c-bus", &opts); + + qos_add_test("channel-select", "pca9545", test_channel_select, NULL); + qos_add_test("interrupt-status", "pca9545", test_interrupt_status, NUL= L); + qos_add_test("interrupt-output", "pca9545", test_interrupt_output, NUL= L); +} +libqos_init(pca9545_register_nodes); --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817272; cv=none; d=zohomail.com; s=zohoarc; b=Ob7Ywy4YUsMR8PFPeEyCzIiOHSPP3AZtYhYBeY3Rrndtr+TNnt8AH5oCWojUA6+9vnCsCLipaFXmGz0jFwMLocmTiBls4AoFgxlHV3o69V93oDoiyBgiIoDds+Ak0H9abmlX4yn0TbzMxUlqWNN0AZaNsrD16tGyWt0HRXcOI68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817272; 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:Sender:Subject:Subject:To:To:Message-Id; bh=wDP5WL+nHMCrP+FkWkhyy3PeP+6u4U2NxCql/xvInIk=; b=BF4aNftRjePSZwik/RyIiXhMzkCzG31VwdGMfBw++BdNdwQKoH4AB7uym/maQOVCd2Ml3pa3eesG47VNecPslsO9XU36kYGbfJco6qft1kxDOjcHkpboVt70FKOEV4DV+6EW+a9/31eVRQ8aFh32zUeK93MDnwuszI1Ax47mP+U= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817272639448.3127243652882; Mon, 12 Oct 2026 08:01:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHW8-0002pZ-9J; Mon, 12 Oct 2026 11:00:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHW4-0002oX-Jf for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:00:40 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHW1-00064q-Qu for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:00:40 -0400 Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-48b02a2359aso1868320f8f.0 for ; Mon, 12 Oct 2026 08:00:37 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48db94e33c7sm21497260f8f.10.2026.10.12.08.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:00:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817236; x=1792422036; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=wDP5WL+nHMCrP+FkWkhyy3PeP+6u4U2NxCql/xvInIk=; b=2ug1uxW0X95R8I+I6rwYVRtCob1PAlJtN62vNTqzB8BxAl4nvcVjvBb8GUOSEwh2CT yWNtuJmEXFfsQTjvm9KncFUNm4QAbHzIOu7f7Sj24QO6er+6VmXoiRuCSsickrz4iimI tXrONiAT3MxDjokPSoBG7vE0xigdpE95BbS6Sqcyv+j1M//0OaHSSshSOkHWSCZDlxyu gzpkc5B0RWI9LupmFL+sxn2rTGJFnzlu4S4EaLMXPabEBwnGg3gSKX4tiOjebwQZvFAF uDLzobfeZiIm6glK01WKgXunySZGiY+CY77n/Nan3jUmv5TI4hqu19LhSAWh2WSsEXb0 FVLg== X-Gm-Message-State: AFq9FYJDGs8UN8BCy4rm+oGIT5JhFLt/eFLdXLbh/z0AzbxqxnGvJEhT fIeZmOzrTYAcAvZmjEN8ha/xo1RyoEzmq8L+n2DOc6SZL6LJ1RJiMx+92T7DBs7g X-Gm-Gg: AYBFou3v7VB4IiNRwjogMxCcPQYXcq/LZ+tqzRN7euBY0MIDi6POKUuLSN1yL7SAscK OBiUZViAL7hginL7JK0tlx1OE3bTox4AkFciTF7krd4PE80MaQ5lOtn+kfJbEsGM1iOHjnJCVBU 5C1AL0gH1H6J47Grl68NjKIcoepkMMyxfIrmwfOwd9pvIABtf81MCii7+zmK+gM7zFI4qTlKt6f DS8uOpxTJITl8TdVfhjE9/3WtEtYzrj1noC8U4QJ084nQ9XUTFpMz8NTNGIaYxBpsnHZcpWzIge sqPwH7Ovwx8JrRWHLLF8erxfSjz06h56xYrnxc6Q5wC5giQ2kOTld/0FlcI2UUtyNAS6Gtc4Jz0 3dgzTYj1AtLlyUInQwGuXJnZW1UD5nDPBQU1vF3fMx1rx5+c0KFZ9yh1WrWI5gkOmD/Gj7JGhaX AhHfn2qODWGfe0p391FvvTaNjJPs+b4SrYUULo9PCPN65+u1dw/4jVrOnSlsu7LGqKJjbLZlof6 x8/nG6d3tmmIi7Wy/qj1FOBkyQ5h+Fbb0t2mPf3v1W7ng== X-Received: by 2002:a05:6000:2dc5:b0:48a:f4d4:e1f3 with SMTP id ffacd0b85a97d-48dbaaecd68mr16588887f8f.13.1791817235263; Mon, 12 Oct 2026 08:00:35 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:01 +0200 Subject: [PATCH v2 08/50] hw/rtc: ds1338: move TYPE_DS1338 to a public header MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-8-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815519; l=1551; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=CHjHyVACEubRQ9qO4x11bxK9mverbnzeYmmxFnXvHD0=; b=yapktyvu/svjNL2CFX5Cpg6XHqC/ipce2Avu9bNxnA+14JfTypvk6lSLDsaLyy9OrJjH7QXfS qpkRvmEu7ULC40cJaIK3TCBUkHmftyYUc/s3lfaxWzcUgwE3XqQHnAs X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.53; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f53.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817273725158500 Move the TYPE_DS1338 type name definition from ds1338.c into a new include/hw/rtc/ds1338.h header so that boards instantiating the device no longer need to redefine the type name string locally. Signed-off-by: Emmanuel Blot Reviewed-by: C=C3=A9dric Le Goater --- hw/rtc/ds1338.c | 2 +- include/hw/rtc/ds1338.h | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/hw/rtc/ds1338.c b/hw/rtc/ds1338.c index 5f1ee2e410..f8b3340bf0 100644 --- a/hw/rtc/ds1338.c +++ b/hw/rtc/ds1338.c @@ -12,6 +12,7 @@ =20 #include "qemu/osdep.h" #include "hw/i2c/i2c.h" +#include "hw/rtc/ds1338.h" #include "migration/vmstate.h" #include "qemu/bcd.h" #include "qom/object.h" @@ -29,7 +30,6 @@ #define HOURS_PM 0x20 #define CTRL_OSF 0x20 =20 -#define TYPE_DS1338 "ds1338" OBJECT_DECLARE_SIMPLE_TYPE(DS1338State, DS1338) =20 struct DS1338State { diff --git a/include/hw/rtc/ds1338.h b/include/hw/rtc/ds1338.h new file mode 100644 index 0000000000..f4cfe6a8e7 --- /dev/null +++ b/include/hw/rtc/ds1338.h @@ -0,0 +1,20 @@ +/* + * MAXIM DS1338 I2C RTC+NVRAM + * + * Copyright (c) 2009 CodeSourcery. + * Written by Paul Brook + * + * This code is licensed under the GNU GPL v2. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_RTC_DS1338_H +#define HW_RTC_DS1338_H + +#define TYPE_DS1338 "ds1338" + +#endif --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817308; cv=none; d=zohomail.com; s=zohoarc; b=TDs/pIC5gPedWKqy2m08r4GqeNWzMV1Pfo574XuilvnurMCBam4ihijtwH2yJh+V3CImN7qGzLoFeJ/AGlFa20RTWhmVcz5kENc5KzQfujgKh1SndfnzVPzC5pyOKZjXl7ruUDq2twDcrGi1CsVou8EPPM+icRpmjOZCwW7XtHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817308; 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:Sender:Subject:Subject:To:To:Message-Id; bh=Iynoh3aT8safdUE3BTc0b1k07T2hDRDq8XUc5yS3tkk=; b=GWk4Oug9L1JbfIEF7qOSIeJUtXImMQrAqQn5spIx3Ys33q9s7YSEMc+fJ4PUK+Jz91bZDOQFTWNDbSUJNKCuD+9iutm3tzE3PM88kSDXPw7tb1g0Uy/o5WgmI6kyMiirng8jfxF8RxcYvsyMJRu/Iggqf777bX3AcLgoRnMIKOw= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817307819619.1265699383716; Mon, 12 Oct 2026 08:01:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHX6-0003Ok-CE; Mon, 12 Oct 2026 11:01:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHX3-0003N7-KI for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:01:41 -0400 Received: from mail-wm1-f41.google.com ([209.85.128.41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHX1-0006BS-CY for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:01:41 -0400 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4a1635f7c89so20348995e9.2 for ; Mon, 12 Oct 2026 08:01:39 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48db9acf092sm19901459f8f.45.2026.10.12.08.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:01:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817298; x=1792422098; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Iynoh3aT8safdUE3BTc0b1k07T2hDRDq8XUc5yS3tkk=; b=FxHnLk+et8TmUbNkBTpxlU+PKjezMAmsl0u8qzKgtNCz+nUZEnkG2bVeaN2fyzj/Tk rLHX8uDqn24BViRQFWQYN/82RZ9FtV0A6zRuQImyhNKYXjI6+VhGfbEGQU57yKJziCSi lxaem6KGrEgGtaMiyevdLr5ksCkm15htTScFT872bxvhsuVmRA/GeKHsLcey+srjtPOD 5/HKdNuLoEyT5Hkit74mmyWNRG9Mph5y0bmy4Uu3sFVtfetU+98ayHb+FY9hDl2w8vSi GyRLklzI49vdqVBEhFqSAMJun3xiL7/F4rYEp5yNNZGr/raNRvJ2ro97XkIqLK8mfjMW 5HtQ== X-Gm-Message-State: AFq9FYLIFOsz2bEbPRtLwmBim1fqodJBCRhCrJzG04stiGzcvAUAH5j3 LRS6tfNPFCmEz9i121cZT6uwhPrh9zwkEGJW0if+NjPxZvQlLQ4F+ZTpbefd3hWc X-Gm-Gg: AYBFou0+rfRB9M8La+letBIjl1ffQk7/1RdwklpEj0wrBnZTk8vLqi8qt0wcrC3zTzJ 31x2pi2YvXI753XURRKKAh+d9OHO8d1nvZlGE2t0GKU8DNOlgfo4c0u9IzT6QK7jRfgZ6KosXK2 UhNomuYRV4Wzw3eQVn3XkhU87sYMJgky3cNb2yVHOYuWQPkNQlQB7lM9wQZ0Vt1Dycr2wWAeGLD hv3l8BWMjYl7rw3A2O5TB8YtIiE0E9+oi1qAY9rlPMutd97g5rxdNpYRsgXtCksUyVIYboZoVMA SNN5eOB5vQAH1Nt0lGjU6f+cVlXOVMZr3d5KJ+AU7MoizQ7M4a5m9J9NOQphGMt6L195y0akUMi Aic5KH+RWs4QO+tPcUwg56/sog8aOain+mzuDYzM9T7jtjcT+yjqmjnlK+iIwzv0IcwEzrbdZIO +f6usJPaNNOcd/3mbfrCg4sB+UNhUrviiKaAsDr7xt8hwsLVh4Mcz5CtG7BNrccFZrufxolgR+3 FzMx8GhInpKyAJGD2oKADB8n0MrnYuBveAwAybhDGyXaQ== X-Received: by 2002:a05:600c:8214:b0:4a1:6425:be69 with SMTP id 5b1f17b1804b1-4a18e4b4db8mr183059115e9.17.1791817297761; Mon, 12 Oct 2026 08:01:37 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:02 +0200 Subject: [PATCH v2 09/50] hw: ds1338: use the TYPE_DS1338 constant instead of the "ds1338" string MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-9-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=11014; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=nCUROmiWn21T4uywY6NVMgmTsZ/FiAbd7U88DkRkIr8=; b=riaJWxAq4E2O+Ib7K64FaFNAvMaA4yQ1xBNocaLbRt9w55A9ljl3/bEp75lWJAA03DaDSvYo/ EHNGcK1Q+6WA4M4TyBps59A+R6M6ehyNmzVfOsFI1gKIxjS4rHsgD2/ X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.41; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f41.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817310847158500 Now that TYPE_DS1338 is exposed by include/hw/rtc/ds1338.h, use it in the machines that instantiate the RTC by its raw type name string. No functional change. Signed-off-by: Emmanuel Blot Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Jamin Lin --- hw/arm/aspeed_ast2400_palmetto.c | 4 +++- hw/arm/aspeed_ast2400_supermicrox11.c | 4 +++- hw/arm/aspeed_ast2500_romulus.c | 4 +++- hw/arm/aspeed_ast2500_supermicro-x11spi.c | 4 +++- hw/arm/aspeed_ast2500_witherspoon.c | 4 +++- hw/arm/aspeed_ast2600_bletchley.c | 3 ++- hw/arm/aspeed_ast2600_catalina.c | 2 +- hw/arm/aspeed_ast2600_sanmiguel.c | 3 +-- hw/arm/realview.c | 3 ++- hw/arm/versatilepb.c | 3 ++- hw/ppc/e500.c | 3 ++- hw/riscv/tt_atlantis.c | 3 ++- 12 files changed, 27 insertions(+), 13 deletions(-) diff --git a/hw/arm/aspeed_ast2400_palmetto.c b/hw/arm/aspeed_ast2400_palme= tto.c index e2350e5b6c..185185f0bb 100644 --- a/hw/arm/aspeed_ast2400_palmetto.c +++ b/hw/arm/aspeed_ast2400_palmetto.c @@ -11,6 +11,7 @@ #include "hw/arm/aspeed.h" #include "hw/arm/aspeed_soc.h" #include "hw/i2c/smbus_eeprom.h" +#include "hw/rtc/ds1338.h" =20 /* Palmetto hardware value: 0x120CE416 */ #define PALMETTO_BMC_HW_STRAP1 ( \ @@ -36,7 +37,8 @@ static void palmetto_bmc_i2c_init(AspeedMachineState *bmc) * 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); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 0), TYPE_DS1338, + 0x68); =20 smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50, eeprom_buf); diff --git a/hw/arm/aspeed_ast2400_supermicrox11.c b/hw/arm/aspeed_ast2400_= supermicrox11.c index c75898cc6d..051e072c5a 100644 --- a/hw/arm/aspeed_ast2400_supermicrox11.c +++ b/hw/arm/aspeed_ast2400_supermicrox11.c @@ -11,6 +11,7 @@ #include "hw/arm/aspeed.h" #include "hw/arm/aspeed_soc.h" #include "hw/i2c/smbus_eeprom.h" +#include "hw/rtc/ds1338.h" =20 /* TODO: Find the actual hardware value */ #define SUPERMICROX11_BMC_HW_STRAP1 ( \ @@ -36,7 +37,8 @@ static void supermicrox11_bmc_i2c_init(AspeedMachineState= *bmc) * 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); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 0), TYPE_DS1338, + 0x68); =20 smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50, eeprom_buf); diff --git a/hw/arm/aspeed_ast2500_romulus.c b/hw/arm/aspeed_ast2500_romulu= s.c index 340a74408b..87f90ed361 100644 --- a/hw/arm/aspeed_ast2500_romulus.c +++ b/hw/arm/aspeed_ast2500_romulus.c @@ -10,6 +10,7 @@ #include "qapi/error.h" #include "hw/arm/aspeed.h" #include "hw/arm/aspeed_soc.h" +#include "hw/rtc/ds1338.h" =20 /* Romulus hardware value: 0xF10AD206 */ #define ROMULUS_BMC_HW_STRAP1 ( \ @@ -29,7 +30,8 @@ static void romulus_bmc_i2c_init(AspeedMachineState *bmc) * The romulus board expects Epson RX8900 I2C RTC but a ds1338 is * good enough */ - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0= x32); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), TYPE_DS1338, + 0x32); } =20 static void aspeed_machine_romulus_class_init(ObjectClass *oc, diff --git a/hw/arm/aspeed_ast2500_supermicro-x11spi.c b/hw/arm/aspeed_ast2= 500_supermicro-x11spi.c index 5a7e49d6cc..dc0248422d 100644 --- a/hw/arm/aspeed_ast2500_supermicro-x11spi.c +++ b/hw/arm/aspeed_ast2500_supermicro-x11spi.c @@ -11,6 +11,7 @@ #include "hw/arm/aspeed.h" #include "hw/arm/aspeed_soc.h" #include "hw/i2c/smbus_eeprom.h" +#include "hw/rtc/ds1338.h" =20 /* TODO: Find the actual hardware value */ #define SUPERMICRO_X11SPI_BMC_HW_STRAP1 ( \ @@ -32,7 +33,8 @@ static void supermicro_x11spi_bmc_i2c_init(AspeedMachineS= tate *bmc) * 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); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 0), TYPE_DS1338, + 0x68); =20 smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50, eeprom_buf); diff --git a/hw/arm/aspeed_ast2500_witherspoon.c b/hw/arm/aspeed_ast2500_wi= therspoon.c index 26ddb67347..c69065846c 100644 --- a/hw/arm/aspeed_ast2500_witherspoon.c +++ b/hw/arm/aspeed_ast2500_witherspoon.c @@ -14,6 +14,7 @@ #include "hw/sensor/tmp105.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/gpio/pca9552.h" +#include "hw/rtc/ds1338.h" =20 /* Witherspoon hardware value: 0xF10AD216 */ #define WITHERSPOON_BMC_HW_STRAP1 ( \ @@ -70,7 +71,8 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *= bmc) * The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is * good enough */ - i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0= x32); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), TYPE_DS1338, + 0x32); =20 smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 11), 0x51, eeprom_buf); diff --git a/hw/arm/aspeed_ast2600_bletchley.c b/hw/arm/aspeed_ast2600_blet= chley.c index 6fa606c047..0e746055a2 100644 --- a/hw/arm/aspeed_ast2600_bletchley.c +++ b/hw/arm/aspeed_ast2600_bletchley.c @@ -12,6 +12,7 @@ #include "hw/arm/aspeed_soc.h" #include "hw/gpio/pca9552.h" #include "hw/nvram/eeprom_at24c.h" +#include "hw/rtc/ds1338.h" =20 #define TYPE_TMP421 "tmp421" /* Bletchley hardware value */ @@ -44,7 +45,7 @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bm= c) /* 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); + i2c_slave_create_simple(i2c[6], TYPE_DS1338, 0x51); =20 =20 /* Bus 7 */ diff --git a/hw/arm/aspeed_ast2600_catalina.c b/hw/arm/aspeed_ast2600_catal= ina.c index 4f2b396f6f..b15d932086 100644 --- a/hw/arm/aspeed_ast2600_catalina.c +++ b/hw/arm/aspeed_ast2600_catalina.c @@ -14,6 +14,7 @@ #include "hw/gpio/pca9552.h" #include "hw/gpio/pca9554.h" #include "hw/nvram/eeprom_at24c.h" +#include "hw/rtc/ds1338.h" #include "hw/sensor/tmp105.h" =20 /* Catalina hardware value */ @@ -22,7 +23,6 @@ #define CATALINA_BMC_RAM_SIZE (2 * GiB) =20 #define TYPE_TMP421 "tmp421" -#define TYPE_DS1338 "ds1338" =20 /* * "BMC Storage Module" FRU data. Generated with frugen. diff --git a/hw/arm/aspeed_ast2600_sanmiguel.c b/hw/arm/aspeed_ast2600_sanm= iguel.c index ac2aef740a..b0935683e2 100644 --- a/hw/arm/aspeed_ast2600_sanmiguel.c +++ b/hw/arm/aspeed_ast2600_sanmiguel.c @@ -13,6 +13,7 @@ #include "hw/gpio/pca9552.h" #include "hw/gpio/pca9554.h" #include "hw/nvram/eeprom_at24c.h" +#include "hw/rtc/ds1338.h" #include "hw/sensor/tmp105.h" =20 /* SanMiguel hardware values */ @@ -20,8 +21,6 @@ #define SANMIGUEL_BMC_HW_STRAP2 0x00000000 #define SANMIGUEL_BMC_RAM_SIZE (2 * GiB) =20 -#define TYPE_DS1338 "ds1338" - /* * "Front IO" FRU data. Generated with frugen. * diff --git a/hw/arm/realview.c b/hw/arm/realview.c index ceba0331b0..4cdf939511 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -28,6 +28,7 @@ #include "hw/intc/realview_gic.h" #include "hw/core/irq.h" #include "hw/i2c/arm_sbcon_i2c.h" +#include "hw/rtc/ds1338.h" #include "hw/sd/sd.h" #include "target/arm/cpu-qom.h" =20 @@ -323,7 +324,7 @@ static void realview_init(MachineState *machine, =20 dev =3D sysbus_create_simple(TYPE_ARM_SBCON_I2C, 0x10002000, NULL); i2c =3D (I2CBus *)qdev_get_child_bus(dev, "i2c"); - i2c_slave_create_simple(i2c, "ds1338", 0x68); + i2c_slave_create_simple(i2c, TYPE_DS1338, 0x68); =20 /* Memory map for RealView Emulation Baseboard: */ /* 0x10000000 System registers. */ diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index f94bf96599..737cd21c27 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -18,6 +18,7 @@ #include "hw/pci/pci.h" #include "hw/i2c/i2c.h" #include "hw/i2c/arm_sbcon_i2c.h" +#include "hw/rtc/ds1338.h" #include "hw/core/irq.h" #include "hw/core/boards.h" #include "hw/block/flash.h" @@ -346,7 +347,7 @@ static void versatile_init(MachineState *machine, int b= oard_id) =20 dev =3D sysbus_create_simple(TYPE_ARM_SBCON_I2C, 0x10002000, NULL); i2c =3D (I2CBus *)qdev_get_child_bus(dev, "i2c"); - i2c_slave_create_simple(i2c, "ds1338", 0x68); + i2c_slave_create_simple(i2c, TYPE_DS1338, 0x68); =20 /* Add PL041 AACI Interface to the LM4549 codec */ pl041 =3D qdev_new("pl041"); diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 1876882a04..469cef9d2f 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -50,6 +50,7 @@ #include "hw/core/platform-bus.h" #include "hw/net/fsl_etsec/etsec.h" #include "hw/i2c/i2c.h" +#include "hw/rtc/ds1338.h" #include "hw/core/irq.h" #include "hw/sd/sdhci.h" #include "hw/misc/unimp.h" @@ -1025,7 +1026,7 @@ void ppce500_init(MachineState *machine) memory_region_add_subregion(ccsr_addr_space, MPC8544_I2C_REGS_OFFSET, sysbus_mmio_get_region(s, 0)); i2c =3D I2C_BUS(qdev_get_child_bus(dev, "i2c")); - i2c_slave_create_simple(i2c, "ds1338", RTC_REGS_OFFSET); + i2c_slave_create_simple(i2c, TYPE_DS1338, RTC_REGS_OFFSET); =20 /* eSDHC */ if (pmc->has_esdhc) { diff --git a/hw/riscv/tt_atlantis.c b/hw/riscv/tt_atlantis.c index 8a219afef7..910713c6bb 100644 --- a/hw/riscv/tt_atlantis.c +++ b/hw/riscv/tt_atlantis.c @@ -27,6 +27,7 @@ #include "hw/char/serial-mm.h" #include "hw/intc/riscv_aclint.h" #include "hw/misc/unimp.h" +#include "hw/rtc/ds1338.h" =20 #include "system/system.h" #include "system/device_tree.h" @@ -657,7 +658,7 @@ static void tt_atlantis_machine_init(MachineState *mach= ine) qdev_realize(DEVICE(&ams->soc), NULL, &error_fatal); =20 /* I2C peripherals: qemu specific */ - i2c_slave_create_simple(i2c_get_bus(s, 0), "ds1338", 0x6f); + i2c_slave_create_simple(i2c_get_bus(s, 0), TYPE_DS1338, 0x6f); i2c_slave_create_simple(i2c_get_bus(s, 4), "tmp105", 0x48); =20 /* Load or create device tree */ --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817443; cv=none; d=zohomail.com; s=zohoarc; b=jhzCzuvHWhqaXqy4CQ9a4mS3SWNaEpHaKNBRLgkQilH1ZFKF9S+A2aQdCQun4YQM194lilXZINDyYndVV6mzKW1StMIzugSrLJOlZD9oLbuUGjYv5GjgVqLcKdZAtOuYc5eFYnBpeuMXSed3z9xpmwSHCyksD2MjbqiZL7mhI8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817443; 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:Sender:Subject:Subject:To:To:Message-Id; bh=uBN2fajLUkSLR6UGUjgMftgFKf7I37iwakER3PeDYqk=; b=Q95ngEYBcRDhchBvQZSgPaLeLwa/6br3sBVIHnHTccN+phwq3IcJ3039r/6l4wkFZJu0NRb/ThvkLnbO0gDQgXy6y8dw20adCnYnsWgXcLovgI36Dzmjqrx6wY1eur1bHtz4iJAC8qnoEHlE7h1V36GWHxZ8xx2PwYkeO4eJyHg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817443678738.9518257114426; Mon, 12 Oct 2026 08:04:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHYp-00041i-Hr; Mon, 12 Oct 2026 11:03:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHY2-0003w4-N5 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:02:45 -0400 Received: from mail-wm1-f47.google.com ([209.85.128.47]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHY0-0006MI-KJ for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:02:42 -0400 Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-49ff680331aso15795695e9.3 for ; Mon, 12 Oct 2026 08:02:40 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48db9ade914sm18383206f8f.54.2026.10.12.08.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:02:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817359; x=1792422159; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=uBN2fajLUkSLR6UGUjgMftgFKf7I37iwakER3PeDYqk=; b=yWozq4H2RUsVHojGTW030Vh2qgvGRelQ9wIHOVubud9l9tBeL/t9vwBNh8Vu1Q0Coi Q5WGqCSWXyzTg2utefL6YYhrHPOG7tZf1HPow+ZSGpasSFowT+wD9m4cq//jczHDqQMP P0vRUHN2rtTVduazMXRSa00Kh9XGLSkWjDes9+fzz8dJvFVmmrcNzQPmVD4TYAD2BKwe ivMKH4hKRiMEU1BYXIjm0v8lkZHPlGtOBsZJEn9UtTvZ2cKA1kYmuMEIqWNPa/3478N5 UcGAVNSiAFn6UIyoCZAR+HEdZe49nomJA3hftaz/dwQa0PP6lVRRPJxDQuAKFnNIMQ66 78Gg== X-Gm-Message-State: AFq9FYJr58wls+uJkRV1AZMfklx1eyW0R3b5X3Q9JWtcA9mBomyw/F8y 5oxdW/XRVb9ccROdkXLQf7/FnqgQYDlqQ/x4bkFfn0xHRFyz5VqeQIYNdkStCnbz X-Gm-Gg: AYBFou2UlY8eh1kn4HsalJqAQcif0ikSqW6imXdyLJRe28uSaZXhVNZfExZ/KddlwWx rtisoHU7GcCo0Nm/o8ZZgk6/ctg3Do8s/ZuftoXUA7z4nvf6OU2jVyCaK+4usqdrdSPfkiwqhpa dgmDyF4CEepAEsi/vCAZN+TWY0h6IQgInpRB9AvK9tgkmkdnpZBQHpeE93B0bFqBs8dD5duJzjt nt9Vq0n+fZvtjnNiM8QpQrcIpKHpc2QUmfSxtj6WKmNW5zvXdZsq/dsL0YH85tux3088yEvlWNQ zTDPGdl1Cwf1cbHiVNn3Gi2XOzzrGGjvXiTB6prki/HSrieGK/ElwAr8keYI6doH1jD/yZuiJn0 p8/RyJ8xxUNmqqCF7bxDelo/1wH+ItXUFk1oxdtum2guV+ruPfgBcgwzy2Iezpx3aug8QNzdB0D 9LVL//FiA7rJEpVNGYMAZnqkPu4SrCb5RJs5hThsGdp0HMQpt+CPkoz4qlHAvhDPxejooMci00g CvSYdQ8JJgDL0Vo5eUX8gYF4Uyq4dQn2HQn0F9MhMdw2A== X-Received: by 2002:a05:600c:4fd5:b0:4a0:5b:7bc0 with SMTP id 5b1f17b1804b1-4a18e49a7e3mr194637505e9.21.1791817358991; Mon, 12 Oct 2026 08:02:38 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:03 +0200 Subject: [PATCH v2 10/50] hw/rtc: ds1338: implement Resettable reset MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-10-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=1334; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=dw30TFJwCbFZiHnP+oufY0O0rlo9ULUgYxm9lxU/N6I=; b=gCj4ACC5dNO3AG53vFPudYQeLeg3WDZQQKwWNjs6v/cZ3h3uPGFGDM6JuLIwVPG18NEYST65k roUdGP4FuHQDD2mdnsTdMIHoe4q50k256ps4gb1YjL9Bhdbb5OBf1qA X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.47; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f47.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817445710158500 The device relied on device_class_set_legacy_reset(), a compatibility shim around the legacy DeviceState reset hook. Convert ds1338_reset() into a proper Resettable hold phase, dropping the legacy shim. Signed-off-by: Emmanuel Blot Reviewed-by: C=C3=A9dric Le Goater --- hw/rtc/ds1338.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/rtc/ds1338.c b/hw/rtc/ds1338.c index f8b3340bf0..74aee6c746 100644 --- a/hw/rtc/ds1338.c +++ b/hw/rtc/ds1338.c @@ -208,9 +208,9 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) return 0; } =20 -static void ds1338_reset(DeviceState *dev) +static void ds1338_reset_hold(Object *obj, ResetType type) { - DS1338State *s =3D DS1338(dev); + DS1338State *s =3D DS1338(obj); =20 /* The clock is running and synchronized with the host */ s->offset =3D 0; @@ -224,11 +224,12 @@ static void ds1338_class_init(ObjectClass *klass, con= st void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); I2CSlaveClass *k =3D I2C_SLAVE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); =20 k->event =3D ds1338_event; k->recv =3D ds1338_recv; k->send =3D ds1338_send; - device_class_set_legacy_reset(dc, ds1338_reset); + rc->phases.hold =3D ds1338_reset_hold; dc->vmsd =3D &vmstate_ds1338; } =20 --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817513; cv=none; d=zohomail.com; s=zohoarc; b=Jn1sohe3wSP+xcz3YL2VaYQdFrE3u7cUNK7JM0Gyy0Z8j/k8FRLTTYbNyy3z+YNOz4XSKr6e+QhZljYbVtQF4+BF/+tZOEHdGHnd5jtcve3dP5ai6HtG+tiN7FxxDpxUGOpTf0zwT87BCHiMUOAY6goh15GCLkfHRSaJLV0ysVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817513; 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:Sender:Subject:Subject:To:To:Message-Id; bh=vPB5f/PPZ/fTGUrJWi/0AwBmdqaHERhdZDqmO3v6YS0=; b=hWxqDw0MDlt/q9z8LGUl90vngIX6Lyw6LH1mkpSsBXLNvOc7jyii715qudgP/6xG/uF9ugaC+JUZwRM16gWbOc1rRASXHepPS3WT1VCRQ/m+jv8udiMZUEbFZFAUS1+zDVfAq6OqwSB0lzJDl7Li0VX7Tea+HgpN3eLZNZLy/GU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817513892884.9745676444753; Mon, 12 Oct 2026 08:05:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHZi-0004P0-Vt; Mon, 12 Oct 2026 11:04:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHZ2-000494-7E for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:03:54 -0400 Received: from mail-wm1-f54.google.com ([209.85.128.54]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHZ0-0006SA-Id for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:03:43 -0400 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4a0213948d3so12400605e9.2 for ; Mon, 12 Oct 2026 08:03:41 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1a1feb78csm87213025e9.0.2026.10.12.08.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:03:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817421; x=1792422221; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=vPB5f/PPZ/fTGUrJWi/0AwBmdqaHERhdZDqmO3v6YS0=; b=EUeB+YS+E5E1+53HLJX7JsHYGC6BWnH+NrkGZWwddA13TjXIPAIhPo9PgkWuubuq8l fj4bYwjNoYPZpofAiPW6qv4jXuQbLam69cxUXEHVVMbH5HuB9rcjXlS9ludHQAt4t1NM Ya333XgS7aRIEKHRwH7n8OOae2dkHXJOjrxuNqk3x78lM7+7RYFaPERB0TX0cbAA/WRz WXgLm+2isge6f+7zDnAHHKQezWYqdZqFitmVzD1aSpd9hpcP3b9Lphxo8dc3pCDtpsHL zj3MmVuwR7wfMGGK+VAdb/QsV9YKajUCqu+tAiXpLgMWAvBQURdkZjxwaoiLUP+CL1M0 HtlA== X-Gm-Message-State: AFq9FYLdMXT08dfppP9FK0lCR+L8LTIDfs9E+3OJ9I+kPw/001qA0DZ2 mgKhPQZF1i2QGt/nEEphjdBYQaHKfkb1YHJAtq+hCH8aeH/DcGsiTtwQOrpzCQpM X-Gm-Gg: AYBFou2caZsaOn6xxnbC/3qeBSszo9m3WWLPuHMz1rO5LWHgRkQT8lgq5hIvP+F5IuN 7xGmDVlCSLt/ZDFLAYUTRU9o3/EkjV+ep2m8v/1nH5b4h47K/MhbLcKmj7RYCqbbey+6u0V/NQ+ 3IxB28glU1/+eYgxOMR8euM6afEfMsXR/H/7fJQDoWEnfJdN8uQjXO8DmpLKjjdVi6JKRb4SyD1 +DozX55LfJPF2jkKo21kPBO6pv+XYZS7JhqVEm/XqHF3MnqdYbWLxfen82j3kr35+8vuhvpSQfR AO6DjCuoXe4AfGj4CXGuApsJQ4vCh6yPSU08EnCdN9d3NrAz/Sxm9myqkZ14FwIcBOFM/n6fS2K w4QoRqHXUj6GTO6y+QRqPnnRzb6CZ2J8kOpBHngixnxWHm0P3qC5YVFV91uOd4PGxRTTAvlepx4 mIIC9Amq+aQ/j4vsSX5kEsz8gco8CwalkprcMbwi/piDJax8yH1qhu0tg3Eb783+32VIM1q2N/x ZSljDOQj9fF94LTqTgZIV7zX5+BSF1hogftc4a9EnhaNQ== X-Received: by 2002:a05:600c:3554:b0:4a0:1b14:e283 with SMTP id 5b1f17b1804b1-4a18e43a1cemr187370475e9.1.1791817420622; Mon, 12 Oct 2026 08:03:40 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:04 +0200 Subject: [PATCH v2 11/50] hw/rtc: ds1338: prefix the file-local helpers with ds1338_ MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-11-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=2049; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=4sMpXciwY1X59HescikiS3PryefwPgkY5TQZ1q6pfqQ=; b=HZAMH3EH9Mhlg4TMlDcCgbSk796PNWu8xS95fvrSTWKaIU2aFTYUDy/d7lzBqdmKvM23CQWd0 NmK9iB+ZkFIBCkxnYuJg0LygW1TYHoB+dgtho+6v6apz7MWyUgpti1C X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.54; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f54.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817514959158501 Two static helpers predate the rest of the file and carry no device prefix. Signed-off-by: Emmanuel Blot Reviewed-by: C=C3=A9dric Le Goater --- hw/rtc/ds1338.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/rtc/ds1338.c b/hw/rtc/ds1338.c index 74aee6c746..1755a3a37c 100644 --- a/hw/rtc/ds1338.c +++ b/hw/rtc/ds1338.c @@ -57,7 +57,7 @@ static const VMStateDescription vmstate_ds1338 =3D { } }; =20 -static void capture_current_time(DS1338State *s) +static void ds1338_capture_current_time(DS1338State *s) { /* Capture the current time into the secondary registers * which will be actually read by the data transfer operation. @@ -85,7 +85,7 @@ static void capture_current_time(DS1338State *s) s->nvram[6] =3D to_bcd(now.tm_year - 100); } =20 -static void inc_regptr(DS1338State *s) +static void ds1338_inc_regptr(DS1338State *s) { /* The register pointer wraps around after 0x3F; wraparound * causes the current time/date to be retransferred into @@ -93,7 +93,7 @@ static void inc_regptr(DS1338State *s) */ s->ptr =3D (s->ptr + 1) & (NVRAM_SIZE - 1); if (!s->ptr) { - capture_current_time(s); + ds1338_capture_current_time(s); } } =20 @@ -108,7 +108,7 @@ static int ds1338_event(I2CSlave *i2c, enum i2c_event e= vent) * START_SEND, because the guest can't get at that data * without going through a START_RECV which would overwrite it. */ - capture_current_time(s); + ds1338_capture_current_time(s); break; case I2C_START_SEND: s->addr_byte =3D true; @@ -129,7 +129,7 @@ static uint8_t ds1338_recv(I2CSlave *i2c) =20 trace_ds1338_recv(s->ptr, res); =20 - inc_regptr(s); + ds1338_inc_regptr(s); return res; } =20 @@ -204,7 +204,7 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) } else { s->nvram[s->ptr] =3D data; } - inc_regptr(s); + ds1338_inc_regptr(s); return 0; } =20 --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817532; cv=none; d=zohomail.com; s=zohoarc; b=RWD9ko6jfB9PaL3rdmHiexZEat1G+ykB9wIhktPZUngi/uWem9cQBArbQCaGgdcsSS3v1ApckIrfFS9WMw4lHXs8wnPGpYlm3lp6YU4fGYD82m1Ld9geY/UZRIpxB5PMtF29GPM+eWwBc6xTlEYBQL4049aOzTPsN68gjc/UvsQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817532; 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:Sender:Subject:Subject:To:To:Message-Id; bh=um44cl8FTErmKq2v7teNfkRsHWMpEkMy+vm/KZ2VsJY=; b=CqRrTWIBSZd9lxmtbuWYLEkUPMAwDrRD2kzZi0ViSS8Si4oIR6hyLUwE+s8ItI0l38N5WelYHrI2Af1rMSA6sv0xEtPojHKYEJVnEq9G4dM5ldFWt3gNFf0QWTkTdKXqOCXyzcicwPU4FbaE9LfUNuNQyvq7jO6pN9Z3vUvvfTQ= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817532906939.0730942841407; Mon, 12 Oct 2026 08:05:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHaA-0004z7-5d; Mon, 12 Oct 2026 11:04:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHa3-0004it-Ee for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:04:49 -0400 Received: from mail-wr1-f48.google.com ([209.85.221.48]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHa0-0006Yh-BM for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:04:47 -0400 Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-48c45111bebso1132991f8f.0 for ; Mon, 12 Oct 2026 08:04:43 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48db9aadf9bsm19445445f8f.29.2026.10.12.08.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:04:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817483; x=1792422283; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=um44cl8FTErmKq2v7teNfkRsHWMpEkMy+vm/KZ2VsJY=; b=tZ7v56FlqJA9QtlvDFQiOy/0Ji8K2AUlwAN0BcXVRhcZ/HS76hr+e5NhXr2B3fHMsy fsTuqTLeSjQzxQqfQzH4OOa+AiSgUK5DkU2D259xsNmtQRU+lyZwDXnZvwSjXExEg8Jm iZCADbEyu1rW2rc5encfd1QDNlcJetfzkg+v215OL1tsmHm9niJIQnQYupO9adekOwzQ pIZg3L0czXuZo72qzJJ5+tWq4N8wJZASSbLVE+CgVvXGEpYsj0u8yI3mMY6jSCa6IZPP R0SxRfiA1zNbX8p887HaiFf4tD7Uqy39t7/LAYBvkP595tvX9MZHMAjPWlU1MEaUlKVe Hhtg== X-Gm-Message-State: AFq9FYKp3X+r438dTUnOCPRMoc5r2slxxY6W/fbs/BKW6PEICp2yQQFT BIHEkLl1bSYMCnogspuFiwNEy+97ODpyj8TnSfzDAWIKephuzg6J6yvUxIpzmKvt X-Gm-Gg: AYBFou3ezskKeMXDWb7z8E+8pZ1nKjIY0joDvL3+XsSZ9D5Od3OokGghqa/0trRPgR3 2ujDSVrdUK6KRmMv1trmE8BQsro37SLMFaNtLdB5K/nZzLWQzVC1VqAmwPak3v2r8mHAPkfNLtJ Harrj/NB82Pxj4Uk3YHJ6XGVlZM/OYMhDY+eB8IWBvzBBUmq7y8fe4kSvPcqsnyNiRHvvmvL5Ap G0gmo9zVyH8zoWasm8Fc1aCda1jf3dQLGu56BkOmZwTQgvou/k/2NL8yFItdn2XOW5woGbyW+9G I87L0fkl7wfZv63RRKG2bIh0Mbwz79gqLTSxkLflotWHLdp2Jj50JeNA8PryUYMeNQ5QQml/3la ou+HlBNbcH2IglStJWmoEx6bPOjSuzRtx8go0H2PIHb4rJXS6IJIwvSrlKmqfaIH4/fIg+/eXyr 85LaNvLX3X5WajJP7t3oamHEpfm97jtbkDoL1aVJ1jLjcJzI0ljl9+D2e/AwRwk27QyJV5YPX7S SJ/EGmbgto0G2fjA+bcekE3UurWfEdTBL8hYpcGYmpOzpkVAMTB3UOm X-Received: by 2002:a05:6000:4683:b0:48c:455a:1c81 with SMTP id ffacd0b85a97d-48dbaadc0e1mr12992051f8f.17.1791817482449; Mon, 12 Oct 2026 08:04:42 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:05 +0200 Subject: [PATCH v2 12/50] hw/rtc: ds1338: parameterise the register map via a device class MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-12-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=6098; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=3HDBdw1nikFPpNJwTwE1d2HiJ1KBQ/Q3c9Vz2uyln2k=; b=QzFseEm5TnHFFxeeeA5qFJKz7nJFLk8KOYtmu3ZGJqqC9z1sswm9mJoVShNusWXgJrTJcqTid p5Cv2DLId2ICLdVjd5JD9jEK+XMb41EjgWkSdZd/lnM1zl5ehWksKlT X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.48; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f48.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817535302158500 In preparation for a register-compatible variant, refactor DS1338 register map. Introduce DS1338Class, carrying the register-pointer wrap boundary and the control/OSF register location and masks, and drive inc_regptr() and the control-register handling. The control-register power-on value is parameterised along with them, so the part comes up holding the contents its datasheet specifies rather than zero, and its oscillator-stop flag now reads set at power-on. Encode the year register modulo 100 (tm_year % 100) instead of tm_year - 100. Signed-off-by: Emmanuel Blot Reviewed-by: C=C3=A9dric Le Goater --- hw/rtc/ds1338.c | 71 ++++++++++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/hw/rtc/ds1338.c b/hw/rtc/ds1338.c index 1755a3a37c..7eaa663113 100644 --- a/hw/rtc/ds1338.c +++ b/hw/rtc/ds1338.c @@ -30,7 +30,14 @@ #define HOURS_PM 0x20 #define CTRL_OSF 0x20 =20 -OBJECT_DECLARE_SIMPLE_TYPE(DS1338State, DS1338) +/* DS1338 register map */ +#define DS1338_NUM_REGS NVRAM_SIZE /* 0x00..0x3f, then wraps */ +#define DS1338_CONTROL 0x07 +#define DS1338_CTRL_MASK 0xb3 /* bits 2, 3 and 6 read back as ze= ro */ +/* POR: OUT, OSF, SQWE and both rate-select bits come up set. */ +#define DS1338_CTRL_RESET 0xb3 + +OBJECT_DECLARE_TYPE(DS1338State, DS1338Class, DS1338) =20 struct DS1338State { I2CSlave parent_obj; @@ -42,6 +49,17 @@ struct DS1338State { bool addr_byte; }; =20 +struct DS1338Class { + I2CSlaveClass parent_class; + + uint8_t num_regs; /* register-pointer wrap boundary */ + uint8_t ctrl_addr; /* control register address */ + uint8_t ctrl_mask; /* writable/read-back bits of the control reg = */ + uint8_t osf_addr; /* register holding the OSF flag */ + uint8_t osf_mask; /* OSF bit within osf_addr */ + uint8_t ctrl_reset; /* control-register power-on value */ +}; + static const VMStateDescription vmstate_ds1338 =3D { .name =3D "ds1338", .version_id =3D 2, @@ -82,16 +100,19 @@ static void ds1338_capture_current_time(DS1338State *s) s->nvram[3] =3D (now.tm_wday + s->wday_offset) % 7 + 1; s->nvram[4] =3D to_bcd(now.tm_mday); s->nvram[5] =3D to_bcd(now.tm_mon + 1); - s->nvram[6] =3D to_bcd(now.tm_year - 100); + s->nvram[6] =3D to_bcd(now.tm_year % 100); } =20 static void ds1338_inc_regptr(DS1338State *s) { - /* The register pointer wraps around after 0x3F; wraparound - * causes the current time/date to be retransferred into - * the secondary registers. + DS1338Class *k =3D DS1338_GET_CLASS(s); + + /* + * The register pointer wraps around after the last register; wraparou= nd + * causes the current time/date to be retransferred into the secondary + * registers. */ - s->ptr =3D (s->ptr + 1) & (NVRAM_SIZE - 1); + s->ptr =3D (s->ptr + 1) % k->num_regs; if (!s->ptr) { ds1338_capture_current_time(s); } @@ -136,11 +157,12 @@ static uint8_t ds1338_recv(I2CSlave *i2c) static int ds1338_send(I2CSlave *i2c, uint8_t data) { DS1338State *s =3D DS1338(i2c); + DS1338Class *k =3D DS1338_GET_CLASS(i2c); =20 trace_ds1338_send(s->ptr, data); =20 if (s->addr_byte) { - s->ptr =3D data & (NVRAM_SIZE - 1); + s->ptr =3D data % k->num_regs; s->addr_byte =3D false; return 0; } @@ -190,18 +212,19 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) break; } s->offset =3D qemu_timedate_diff(&now); - } else if (s->ptr =3D=3D 7) { - /* Control register. */ - - /* Ensure bits 2, 3 and 6 will read back as zero. */ - data &=3D 0xB3; - - /* Attempting to write the OSF flag to logic 1 leaves the - value unchanged. */ - data =3D (data & ~CTRL_OSF) | (data & s->nvram[s->ptr] & CTRL_OSF); - - s->nvram[s->ptr] =3D data; } else { + if (s->ptr =3D=3D k->ctrl_addr) { + /* Control register: reserved bits read back as zero. */ + data &=3D k->ctrl_mask; + } + if (s->ptr =3D=3D k->osf_addr) { + /* + * Attempting to write the OSF flag to logic 1 leaves the + * value unchanged. + */ + data =3D (data & ~k->osf_mask) | + (data & s->nvram[s->ptr] & k->osf_mask); + } s->nvram[s->ptr] =3D data; } ds1338_inc_regptr(s); @@ -211,11 +234,13 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) static void ds1338_reset_hold(Object *obj, ResetType type) { DS1338State *s =3D DS1338(obj); + DS1338Class *k =3D DS1338_GET_CLASS(s); =20 /* The clock is running and synchronized with the host */ s->offset =3D 0; s->wday_offset =3D 0; memset(s->nvram, 0, NVRAM_SIZE); + s->nvram[k->ctrl_addr] =3D k->ctrl_reset; s->ptr =3D 0; s->addr_byte =3D false; } @@ -225,12 +250,21 @@ static void ds1338_class_init(ObjectClass *klass, con= st void *data) DeviceClass *dc =3D DEVICE_CLASS(klass); I2CSlaveClass *k =3D I2C_SLAVE_CLASS(klass); ResettableClass *rc =3D RESETTABLE_CLASS(klass); + DS1338Class *dsc =3D DS1338_CLASS(klass); =20 k->event =3D ds1338_event; k->recv =3D ds1338_recv; k->send =3D ds1338_send; rc->phases.hold =3D ds1338_reset_hold; + dc->desc =3D "DS1338 I2C RTC with 56-byte NV RAM"; dc->vmsd =3D &vmstate_ds1338; + + dsc->num_regs =3D DS1338_NUM_REGS; + dsc->ctrl_addr =3D DS1338_CONTROL; + dsc->ctrl_mask =3D DS1338_CTRL_MASK; + dsc->osf_addr =3D DS1338_CONTROL; + dsc->osf_mask =3D CTRL_OSF; + dsc->ctrl_reset =3D DS1338_CTRL_RESET; } =20 static const TypeInfo ds1338_types[] =3D { @@ -238,6 +272,7 @@ static const TypeInfo ds1338_types[] =3D { .name =3D TYPE_DS1338, .parent =3D TYPE_I2C_SLAVE, .instance_size =3D sizeof(DS1338State), + .class_size =3D sizeof(DS1338Class), .class_init =3D ds1338_class_init, }, }; --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817577; cv=none; d=zohomail.com; s=zohoarc; b=Q7pJ8rmMdThvOvHJh91W1cWTjYaqd+uqLtdD+GOprqeWjcsq5jVEg0VT/Qn+6w8ciLwzgBeR4fKt0JMtRLhEXtsO6pU9O4Sk4UWmvuRvZgZbYKIHeKQGjyf7JQyz/jTo8GQL/MHDxBuUENpdb20xUs9WxN9KtGTo3+oSZMEMMig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817577; 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:Sender:Subject:Subject:To:To:Message-Id; bh=yBWuUC9nCHI6TiTYFhtomTYUcrNr6zcNAyZPSG6aMfs=; b=iN0spYZjSG8EDUnNVWP+tXLNZxAec+rO9isL9RnrNH6Cs5fEpob9yqEa3GyiLjt5Ac823xNsrz0VkREERuIvU9rrEtnB5qVouEiS5KTJ5cXiAS42C27gKTsgo7wgGzDpUtB+GuS+3t4+6fTmosVy8Eik9LI3RxvS+HX5epq5Dws= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817577037688.7829511176423; Mon, 12 Oct 2026 08:06:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHb3-0006Lm-Hp; Mon, 12 Oct 2026 11:05:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHb2-0006Kp-4f for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:05:48 -0400 Received: from mail-wm1-f52.google.com ([209.85.128.52]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHaz-0006sd-PB for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:05:47 -0400 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4a140e7405dso23466425e9.3 for ; Mon, 12 Oct 2026 08:05:45 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48db9adeacdsm19780958f8f.55.2026.10.12.08.05.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:05:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817544; x=1792422344; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yBWuUC9nCHI6TiTYFhtomTYUcrNr6zcNAyZPSG6aMfs=; b=WN6MOVIcqb6HMa0DZgfFovuPc3OWBaUfLx5dvupOadPL3xIrLgpTVKbEaFI5EHmbM9 9y8woGRpUzbIr6ww64Omk2cnR2v+h0QQcVM9rNWINAkt9MLH+zhmDpJC2W6RUibTLhnX Ni84oj3mXBcN9MIRdOySanN5k4Hyg27iNubDQsdqXk75XQgxWIMv0IlqricC/i65KbfK ZPDAxJRIc/rcwgpx3yQC6GbPFksFEmZUMjTMvhVdPMRLCqrAShyYxXKXJUPH0rouU2AD k17i8zekUIelcR7va+B95Zu+xsT/sOld1hg25B3s9eKbh4woLSmt1z79PVCSLPVkS/lb apYg== X-Gm-Message-State: AFq9FYKAtqMqPyZCaxTLLXZOgG5nacDucUzYsLp2pSkJ+5hsLAJkd1v1 DoL9s1RiIK1QONd9Y+fyKJ2Fz6lvDb8ClYLgfKinTjlLxAaEN1BmIpX3Jl9wFkZL X-Gm-Gg: AYBFou2GutWnhcUzDDcUIJGDokVo5Ji+eT5tIz1fsJ4muwn6Elg2KFOr+XLLEoeivuh ws5FlBGHlW3VuCxIG0x0f7gXQjLtO5FjtY+bYfHjl67VdqYPyrCblOsu4YwpJcD3ndjcARD/lo5 fgTSCrJGkf+49tVozRbExyvFak6LgX+tHybiWdpFT+5gVc0AkrH1fFsd9Wr11IUvQ0Re/bSn2XD Lg8YONvYlLWTof8e7mZF9T3ZlkEQgSepZmCRtfLexYzFBxRoGP8UU9ZOr8gxYeJdkoacGNpP+Vi WtOHxVWtkHNvPo/4kFr2SCkFis5PYT3ZNNd3DEp71T6PMefPzYUZ0b/saL9BI/wiGkbClSCfxMc 4/T5XCPjrbHVPonG5rQc0nPzobxJKenrhPchtzGPWH2ghs6dqkIy4bnVsJlUjohznkJwvlEF/Y5 PsjED1R0X7B3HQH+SObMHoXqkRWj7jbEvGmM6fjWxWJAy1lp4K92EPuW53SKRBrhM3+3W5bSgTZ SWRULeDaEcJ2ldaSJ01g6HXwj+a1U7oajC24nOPKJm9jpc= X-Received: by 2002:a05:600c:8216:b0:49d:34:420d with SMTP id 5b1f17b1804b1-4a18e4b0465mr189633135e9.20.1791817544008; Mon, 12 Oct 2026 08:05:44 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:06 +0200 Subject: [PATCH v2 13/50] hw/rtc: ds1338: program the clock from the time registers MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-13-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=6063; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=94bqjrDMcc1+WPuTzltyln162tXTYcpioUu3J7GfTG8=; b=Ab8IyJ+26HOnO/VQvMmxjXe8L1DGO1Wfug/tXwVZZ70AYbgAuUGxzSBGPKyQ6W6DALFdKz66P 12uQXxQ9mWFC/kUqvuSo445HrqvidWeiC3ua4fwJ6Gxs0F9heSsXhcx X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.52; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f52.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817577806158500 A write to a time register rebuilt a struct tm from the current date, substituted the field being written and folded the result back into the offset. Every byte of a multi-byte transfer was therefore normalised against the fields the guest had not written yet: a date of 31 programmed while the month register still held a 30-day month moved the clock into the following month. Keep the written value in the register file and derive the offset from the file as a whole. This needs the registers refreshed on a START_SEND, as the hardware does on any START. Signed-off-by: Emmanuel Blot --- hw/rtc/ds1338.c | 116 ++++++++++++++++++++++++++++++----------------------= ---- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/hw/rtc/ds1338.c b/hw/rtc/ds1338.c index 7eaa663113..862e03bd32 100644 --- a/hw/rtc/ds1338.c +++ b/hw/rtc/ds1338.c @@ -8,6 +8,12 @@ * * Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. + * + * Limitations: + * - Writing the seconds register does not reset the internal countdown ch= ain, + * so the sub-second phase of the clock is not modelled. + * - Leap years follow the Gregorian rule, where the parts stop at 2100: t= hey + * derive the leap year from the two-digit year alone. */ =20 #include "qemu/osdep.h" @@ -75,6 +81,41 @@ static const VMStateDescription vmstate_ds1338 =3D { } }; =20 +/* Reconstruct a struct tm from the BCD time registers in nvram. */ +static void ds1338_time_from_regs(DS1338State *s, struct tm *now) +{ + qemu_get_timedate(now, s->offset); + now->tm_sec =3D from_bcd(s->nvram[0] & 0x7f); + now->tm_min =3D from_bcd(s->nvram[1] & 0x7f); + if (s->nvram[2] & HOURS_12) { + int tmp =3D from_bcd(s->nvram[2] & (HOURS_PM - 1)); + if (s->nvram[2] & HOURS_PM) { + tmp +=3D 12; + } + if (tmp % 12 =3D=3D 0) { + tmp -=3D 12; + } + now->tm_hour =3D tmp; + } else { + now->tm_hour =3D from_bcd(s->nvram[2] & (HOURS_12 - 1)); + } + now->tm_mday =3D from_bcd(s->nvram[4] & 0x3f); + now->tm_mon =3D from_bcd(s->nvram[5] & 0x1f) - 1; + now->tm_year =3D from_bcd(s->nvram[6]) + 100; +} + +static void ds1338_resync_from_regs(DS1338State *s) +{ + struct tm now; + int user_wday; + + ds1338_time_from_regs(s, &now); + s->offset =3D qemu_timedate_diff(&now); + qemu_get_timedate(&now, s->offset); + user_wday =3D (s->nvram[3] & 7) - 1; + s->wday_offset =3D (user_wday - now.tm_wday + 7) % 7; +} + static void ds1338_capture_current_time(DS1338State *s) { /* Capture the current time into the secondary registers @@ -123,16 +164,16 @@ static int ds1338_event(I2CSlave *i2c, enum i2c_event= event) DS1338State *s =3D DS1338(i2c); =20 switch (event) { - case I2C_START_RECV: - /* In h/w, capture happens on any START condition, not just a - * START_RECV, but there is no need to actually capture on - * START_SEND, because the guest can't get at that data - * without going through a START_RECV which would overwrite it. - */ - ds1338_capture_current_time(s); - break; case I2C_START_SEND: s->addr_byte =3D true; + /* fall through */ + case I2C_START_RECV: + /* + * In h/w the time is transferred to the user registers on any STA= RT + * condition, so a write modifies the running time rather than + * whatever the last read left behind. + */ + ds1338_capture_current_time(s); break; default: break; @@ -167,51 +208,20 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) return 0; } if (s->ptr < 7) { - /* Time register. */ - struct tm now; - qemu_get_timedate(&now, s->offset); - switch(s->ptr) { - case 0: - /* TODO: Implement CH (stop) bit. */ - now.tm_sec =3D from_bcd(data & 0x7f); - break; - case 1: - now.tm_min =3D from_bcd(data & 0x7f); - break; - case 2: - if (data & HOURS_12) { - int tmp =3D from_bcd(data & (HOURS_PM - 1)); - if (data & HOURS_PM) { - tmp +=3D 12; - } - if (tmp % 12 =3D=3D 0) { - tmp -=3D 12; - } - now.tm_hour =3D tmp; - } else { - now.tm_hour =3D from_bcd(data & (HOURS_12 - 1)); - } - break; - case 3: - { - /* The day field is supposed to contain a value in - the range 1-7. Otherwise behavior is undefined. - */ - int user_wday =3D (data & 7) - 1; - s->wday_offset =3D (user_wday - now.tm_wday + 7) % 7; - } - break; - case 4: - now.tm_mday =3D from_bcd(data & 0x3f); - break; - case 5: - now.tm_mon =3D from_bcd(data & 0x1f) - 1; - break; - case 6: - now.tm_year =3D from_bcd(data) + 100; - break; - } - s->offset =3D qemu_timedate_diff(&now); + /* + * Time register. The write lands in the register file and the clo= ck + * is then rebuilt from it as a whole: a transfer that programs the + * date before the month it belongs to must not be normalised away + * against the month still held from the previous date. + * + * TODO: Implement CH (stop) bit. + */ + static const uint8_t valid[7] =3D { + 0x7f, 0x7f, 0x7f, 0x07, 0x3f, 0x1f, 0xff + }; + + s->nvram[s->ptr] =3D data & valid[s->ptr]; + ds1338_resync_from_regs(s); } else { if (s->ptr =3D=3D k->ctrl_addr) { /* Control register: reserved bits read back as zero. */ --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817650; cv=none; d=zohomail.com; s=zohoarc; b=Jjczk5lGL9lw5wE6ZzDz4DQJSnkkHyFjeoWpZ3uO0222zo/YZmR5W7PACjFtrjhE6WAO1AoJmv3OG2/I7sTX1TfFwAotgAXhrsTSUcLdub5j2WHZY6JaitM17jrXpDoUMgahQ37LcLhmzP0DN+nF8FqMJ7GVv2nxWB4fs0h+tZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817650; 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:Sender:Subject:Subject:To:To:Message-Id; bh=G/mKfLQNBKAXK5zANjKJNAiRPm31akVLZZtUavo8HIg=; b=IxoHaZ6bFwxO6cvN41OOqlJF3c+f8Cx+dsKth05m/rLNRnHkg2WcaP85CnUoUcbM173K5HBFhvL6hu+tQ7hS8Q/QWF0QkYHXQrny6kxgJKMdqHvi1OuzrPim1/AWfRP6aSSgU+N0Va94DOBSznBoaMUmRcJtJF4EhHsX/kCYhWc= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817650075555.6879245486173; Mon, 12 Oct 2026 08:07:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHcG-0006v5-0t; Mon, 12 Oct 2026 11:07:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHc2-0006t7-Ic for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:06:50 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHbz-00070Z-2v for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:06:49 -0400 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4a1635f7c89so20413155e9.2 for ; Mon, 12 Oct 2026 08:06:46 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a19c8244edsm126166345e9.2.2026.10.12.08.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:06:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817605; x=1792422405; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=G/mKfLQNBKAXK5zANjKJNAiRPm31akVLZZtUavo8HIg=; b=DQv5wokGjDi0n3i7sxKbKZ7a3OtQhIsrH8P7Vxkk0+74ZCb32/Vg/djdV7cLaMQwn8 MFtvBYDBiqFdrTMBtChx9gQdZGMLDLUxngWluQl1MkTMureTV6bryHlzkn8mi68rWMQg c+HE8OVBcmpUZ5ZwwS+vJIhTAKhMKhKS4JCcRDQt7b+iW8vWuSs8t6/xnm3Pc4fHv4vL 9q9+NBn6n7AGeaqwexen9/a5pa+Rbsp3SV6VxFSMELP/60JspaH1h2WrWxHGNnyBxiy2 R3BrBAWLf8cpL1IvvsZ+sIcEvEEk/gMK8F9B1x/RIKusTvOP4AsXapU/koHhIhqs/jL3 jOkw== X-Gm-Message-State: AFq9FYKzUnzELjhVL9gfNL1g+ZhARK52TpgAa8n1BufChFzHgWmZehQY K17NZCgcJ+ULiGjPjlfkk5AnNZHofjgptNYH7139rjQPQMZqM83pBpjXeI1euVsD X-Gm-Gg: AYBFou235sxZBWJyO0KD4Jzb4M6j6Lltf0OVR5hLII6HnRdmLCxe1HbGC30TSCdChnY S7VzVVTXMsMQs7JbTQCCWMiAqCN3ir/GMAY7EegmQUo8G7IeOcuVHRMdYJ6m/IYeTRscmpLYiAS mcMZTUVP6lF41TuoXsJN5QtxagKhQ7XZlSKRl4aeQMRES8KCOkjbDXBGSayxunY7yYCpausPBjm Yhs/qqyjhn3GKuUQayZ13Fa7z7RSEHF5fgVxlVAHYeahFTECGhtUe94aukeyKby+u93J4oDixJ/ AwfaZrYUW7Ii4P5mJdQjtDXZSa+nHywDj33DWEdGWBXKml2JSPtjY46fw9f2IXttbnA9GWPyGdP KDuJa70tFqts23MoI34Ei+yVMRaXcOh/t1CMpSKZEar2HLjLgiLEhPS5X3fG26FUgtJpN/Firpo bbi9ObBoafbn5NIFHl7Nu5Kq489itmge1/QP1SzBoQkdxG3Z0j3S6wddhBuJLHaN6umr/VvicfH Z4hFgBEAg+K5FXrXREUjRIIqZy95SoXVylfinj4SH+Eqg== X-Received: by 2002:a05:600c:19ca:b0:49d:10d6:fd55 with SMTP id 5b1f17b1804b1-4a18e4487b5mr192263745e9.1.1791817605215; Mon, 12 Oct 2026 08:06:45 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:07 +0200 Subject: [PATCH v2 14/50] hw/rtc: ds1338: implement the DS1338 clock-halt bit MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-14-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=4393; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=a6K3mP3V1bOItKsHSSEEMqE6FAeOlFgY8HlKMCgf6ls=; b=g12HGd3oM/Ybh5DhnXSjpJX9/p34oNb4XcUDEkWVTTChjmU8AVXRSJHupzhnGyeF1RoQa0sxE ptmpzuuAGO2C/JysAnKkWmlZbTB67gj2vozOOy26D0LqW2VBdqVZnEX X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.42; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f42.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817650950158500 Bit 7 of the seconds register disables the oscillator, and the guest is expected to clear it before trusting the time. The bit was masked away on every write, so it always read back zero and the clock never stopped. The reset value stays clear rather than set as on real hardware, keeping the model's convention that the clock comes up running and synchronised with the host. Signed-off-by: Emmanuel Blot --- hw/rtc/ds1338.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/hw/rtc/ds1338.c b/hw/rtc/ds1338.c index 862e03bd32..79bcff4599 100644 --- a/hw/rtc/ds1338.c +++ b/hw/rtc/ds1338.c @@ -14,6 +14,7 @@ * so the sub-second phase of the clock is not modelled. * - Leap years follow the Gregorian rule, where the parts stop at 2100: t= hey * derive the leap year from the two-digit year alone. + * - The model comes up with the clock running; real hardware comes up hal= ted. */ =20 #include "qemu/osdep.h" @@ -53,6 +54,7 @@ struct DS1338State { uint8_t nvram[NVRAM_SIZE]; int32_t ptr; bool addr_byte; + bool osc_stopped; /* oscillator halted: time is frozen */ }; =20 struct DS1338Class { @@ -64,11 +66,12 @@ struct DS1338Class { uint8_t osf_addr; /* register holding the OSF flag */ uint8_t osf_mask; /* OSF bit within osf_addr */ uint8_t ctrl_reset; /* control-register power-on value */ + uint8_t ch_mask; /* Clock-halt bit in the seconds reg */ }; =20 static const VMStateDescription vmstate_ds1338 =3D { .name =3D "ds1338", - .version_id =3D 2, + .version_id =3D 3, .minimum_version_id =3D 1, .fields =3D (const VMStateField[]) { VMSTATE_I2C_SLAVE(parent_obj, DS1338State), @@ -77,6 +80,7 @@ static const VMStateDescription vmstate_ds1338 =3D { VMSTATE_UINT8_ARRAY(nvram, DS1338State, NVRAM_SIZE), VMSTATE_INT32(ptr, DS1338State), VMSTATE_BOOL(addr_byte, DS1338State), + VMSTATE_BOOL_V(osc_stopped, DS1338State, 3), VMSTATE_END_OF_LIST() } }; @@ -122,6 +126,11 @@ static void ds1338_capture_current_time(DS1338State *s) * which will be actually read by the data transfer operation. */ struct tm now; + + if (s->osc_stopped) { + return; + } + qemu_get_timedate(&now, s->offset); s->nvram[0] =3D to_bcd(now.tm_sec); s->nvram[1] =3D to_bcd(now.tm_min); @@ -213,15 +222,30 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) * is then rebuilt from it as a whole: a transfer that programs the * date before the month it belongs to must not be normalised away * against the month still held from the previous date. - * - * TODO: Implement CH (stop) bit. */ static const uint8_t valid[7] =3D { 0x7f, 0x7f, 0x7f, 0x07, 0x3f, 0x1f, 0xff }; + uint8_t mask =3D valid[s->ptr]; + bool halt =3D s->osc_stopped; =20 - s->nvram[s->ptr] =3D data & valid[s->ptr]; - ds1338_resync_from_regs(s); + if (s->ptr =3D=3D 0) { + mask |=3D k->ch_mask; + if (k->ch_mask) { + halt =3D data & k->ch_mask; + } + } + + if (halt && !s->osc_stopped) { + /* CH set: freeze the counters before the register is stored. = */ + ds1338_capture_current_time(s); + s->nvram[k->osf_addr] |=3D k->osf_mask; + } + s->nvram[s->ptr] =3D data & mask; + s->osc_stopped =3D halt; + if (!halt) { + ds1338_resync_from_regs(s); + } } else { if (s->ptr =3D=3D k->ctrl_addr) { /* Control register: reserved bits read back as zero. */ @@ -253,6 +277,7 @@ static void ds1338_reset_hold(Object *obj, ResetType ty= pe) s->nvram[k->ctrl_addr] =3D k->ctrl_reset; s->ptr =3D 0; s->addr_byte =3D false; + s->osc_stopped =3D false; } =20 static void ds1338_class_init(ObjectClass *klass, const void *data) @@ -275,6 +300,7 @@ static void ds1338_class_init(ObjectClass *klass, const= void *data) dsc->osf_addr =3D DS1338_CONTROL; dsc->osf_mask =3D CTRL_OSF; dsc->ctrl_reset =3D DS1338_CTRL_RESET; + dsc->ch_mask =3D SECONDS_CH; } =20 static const TypeInfo ds1338_types[] =3D { --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817703; cv=none; d=zohomail.com; s=zohoarc; b=B0tp5yfE3DzHYc0IykkzJpo7rbYNAi43BZDpooACU1osEv/pd8BL5Rw78FfVxrRj6krqFexDh0xeTAiFtImVc2/vM9aA1ktNkBG6tU2byXaw/YiCnLUIkZIJ+GS6T49i3gyilkb3iAX+JaK9L6FMSQEEX6ylG7ahR3SNoh9yc20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817703; 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:Sender:Subject:Subject:To:To:Message-Id; bh=8pehCOpu14U96pPALBKxZw+FwtcRSZWqcNAlSAWQxRQ=; b=RtJ+oNAUOr7CqCG0zejbugiFozOTfTYYDnwhc8yv4kU5vI6b6Y2+WoE/ZYHOaIAPRuh5dvMEwHiarwd/fAHIXcVks97X/WOsXRYSQbOA8BBlqYajszR49LO/VRViy7OEsz4keDV9yOIFqwJXgVGevAq+Kud1ks1xsuNs0UiGH/4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179181770378075.8234045584536; Mon, 12 Oct 2026 08:08:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHd3-0007V5-6W; Mon, 12 Oct 2026 11:07:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHd0-0007UK-U9 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:07:51 -0400 Received: from mail-wr1-f45.google.com ([209.85.221.45]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHcy-0007Eb-71 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:07:50 -0400 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-48c6f764f82so602638f8f.0 for ; Mon, 12 Oct 2026 08:07:47 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48db98c2800sm19908900f8f.26.2026.10.12.08.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:07:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817667; x=1792422467; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=8pehCOpu14U96pPALBKxZw+FwtcRSZWqcNAlSAWQxRQ=; b=nx0LjfhOWsA+EJm1jMz+PS3OR59wrAbluNIPPxJTQ6M9gwRlHG60mNXFlkUxKOG0t0 LYp4NfdwJY3cfTb6uu3o0B+d2s+JhyF/C6G0AgTMII/esBhxT/B8cuw4VKu1YbpYKRPI BeFEW7sPaQQ9NSW59Y4CZQ3NMBApgU4Ao5xdk9p2SV3201I3Jm7CwIfw6eNdbYLCt5OF JY1der+L+cdKWhWyCvsJwIPcju/1D0JqmzV2fNTQTJIhM0uLzufA68rf362WwhtM/JP5 MOUEnaOQtJQMRBOM3l4zvwkCjnhwA2MRX7mb/wistJ1D3DuWngXEbL7JwBfEIUe2mAzf C8Jg== X-Gm-Message-State: AFq9FYIpb53sjMw/LYNYwUllQUW9FzYQ8Twfqa02fcqDNbWT4dM0qbsN SSMnj2olx9xQFx60QrC+UtmJfbdMPl16RppmdHB2GCgLzDhvli998Hmibt6UgqCY X-Gm-Gg: AYBFou3OpLI0LBI2ap4RjdxjDUADvDKpT4127zKiFdrThXCwGx6Vyejr+EJtGnmh0aG Ik7yjBCH3a2/aL0F0S+90Xjox6X2bAvhZw2nEi944EchwuIwIsGy3yptnvib22hIy4EPrECTHdr sTfc0Wo0laT7+Gd5H6i3YegEfwhPLRJVaeXasMqbAY0Z6A8ChF0sKpGEqTv9hYhwJi2WI8uW3+u wUDMWEt1zfisbgsS1VLN6NA1nKFnM6oQ6JQh38oMy/PUvdIwdb+lUlITqMoB4lsPO02arfdTdud RCnNrHkn5Rmp4OpUmhJ8TVYhCW/zO1mCLnS/Jtf2Ik7Vv/Fgci/iD6ICPgyEr5KCG0qw/qalLCQ 6cZ+4eV7MH+lmi1X7LnAeJXJyAwcjMcXf4WSDRi0tdcOywSuXgCZbVuZcVAiOoip087ctp0XGFx qi77vCOU0NGXEEiSDKJWJ8VqbCc/s/GqLNzK/EVpt6EtE+zh9MYKPtrFwZMZDimwUZB0AeFdrHn fREsiqkIRf66W8Eh/Pp/AnLU1ZqiAiYRrD6SHVnirqMtQ== X-Received: by 2002:a5d:4748:0:b0:488:8111:6f4e with SMTP id ffacd0b85a97d-48dbaaddd64mr13130331f8f.9.1791817666529; Mon, 12 Oct 2026 08:07:46 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:08 +0200 Subject: [PATCH v2 15/50] hw/rtc: ds1338: refresh the user registers on a read rollover only MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-15-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=1980; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=/o1Te60tyzFbC8yX3wDit9+fgGxpiXPXZOuAAft1sW4=; b=kyaQZtTIK81J5Ez4N+xGy9A27RRMagoh+yw19yATn0YTxSbtB3kAAMavF4+UJ9yRUSNDUzf+V d+tLPpQKZTtDcej5Ds+OaWkbILkMZQN/yVYOSVz3/C9IrvJvEyjeirA X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.45; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f45.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817705841158500 Synchronising the user buffers when the register pointer rolls over to zero is a property of reading them; hardware routes a write to the counters themselves. Doing it from the shared pointer increment meant a write transfer long enough to wrap overwrote the bytes the guest had just sent with the current time. Move the refresh to the read path. Signed-off-by: Emmanuel Blot --- hw/rtc/ds1338.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/hw/rtc/ds1338.c b/hw/rtc/ds1338.c index 79bcff4599..c5fc74e6ca 100644 --- a/hw/rtc/ds1338.c +++ b/hw/rtc/ds1338.c @@ -12,6 +12,8 @@ * Limitations: * - Writing the seconds register does not reset the internal countdown ch= ain, * so the sub-second phase of the clock is not modelled. + * - The user registers are refreshed on a START and on a read that wraps = the + * register pointer, but not on a STOP. * - Leap years follow the Gregorian rule, where the parts stop at 2100: t= hey * derive the leap year from the two-digit year alone. * - The model comes up with the clock running; real hardware comes up hal= ted. @@ -157,15 +159,7 @@ static void ds1338_inc_regptr(DS1338State *s) { DS1338Class *k =3D DS1338_GET_CLASS(s); =20 - /* - * The register pointer wraps around after the last register; wraparou= nd - * causes the current time/date to be retransferred into the secondary - * registers. - */ s->ptr =3D (s->ptr + 1) % k->num_regs; - if (!s->ptr) { - ds1338_capture_current_time(s); - } } =20 static int ds1338_event(I2CSlave *i2c, enum i2c_event event) @@ -201,6 +195,10 @@ static uint8_t ds1338_recv(I2CSlave *i2c) trace_ds1338_recv(s->ptr, res); =20 ds1338_inc_regptr(s); + if (!s->ptr) { + /* Read-only: a wrapping write must keep the bytes it just sent. */ + ds1338_capture_current_time(s); + } return res; } =20 --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817768; cv=none; d=zohomail.com; s=zohoarc; b=mEeDPSUrJhMsCSkTWRx3Fyen5HyLCtLlU97DK9LL9Kh2ITTcoj5lEBiPjLVvwb7x2J6FhD2A7zTz0TB1mWo4xUXxq+BE3d6BI5imMo1Jrw35GkmZ5dnR4CauGPoiaLBDhYi/TTGKCVXLcLciR5cDpmfleMH2hBdNBDjhv98Al8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817768; 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:Sender:Subject:Subject:To:To:Message-Id; bh=yoI5CWQNkKU3FBXCClJtroQLxmdLnKfTK0MOA70taBk=; b=eKpgLHgYbndUcK1K4kRdGwm9RKZC6vOLTNhdNE50Bfuj5wDKSFZIr40QKm72I8KxtRy8h1uXOwrWfKVpqjs/hgp4vHakO/sgjKJKe7197uLI6rEty3QqiiGy4knXNoEFfbraAEOuE/ruigxJQAa1N01yuZhq8OBr+zmwZBDHWxA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817768817928.4011111832654; Mon, 12 Oct 2026 08:09:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHe7-00081E-B3; Mon, 12 Oct 2026 11:08:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHe0-00080W-3u for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:08:52 -0400 Received: from mail-wm1-f52.google.com ([209.85.128.52]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHdy-0007KA-Bb for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:08:51 -0400 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4a061a13884so17416755e9.3 for ; Mon, 12 Oct 2026 08:08:49 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be8c5e7sm369203195e9.4.2026.10.12.08.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:08:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817728; x=1792422528; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yoI5CWQNkKU3FBXCClJtroQLxmdLnKfTK0MOA70taBk=; b=WnZe6mYOBq/XbnpoRfjtWXDvw790w5MBmcCd5T/PzfSVAoVkTmIzUAQwb9Nn3q4XP7 nERVoz0P9RBaHO0cxu/C+mMh4QPESu1fhvLKqhkt0TRS6+ZWXJHT8mTb3A867ZSCQgFl NtCE3iuGbizii6Kh5QyLbJBjUvv+Qr+/BAhl10wUrQvWtgET/yWoHnOUxCtq2BqQrMpj n9AKxk8RJWHMhZGndubWB5k2G0LNwdzhLsE60J0t+CfvpH+6xvf11Xz1JetvxQe+lPjC oJ5yH7ZSTen/HEeODvQpphj8BZVf5jbd8QzrRiBJsDZoL2m8wwfkZiO+NZ6Bwj6BFu0d St5w== X-Gm-Message-State: AFq9FYJ6ZWx+zgqsBImLpcRAFsd03hHYmokqM9vJgatLE1hAKNw1zSKh CBJZGeig39CC0+68KGPXY7yrNV8NXNYA4qQphHFF2SOpwV4EmeTPZhYCatigh9BC X-Gm-Gg: AYBFou1Yw4QjB3dTD7MqO70MDzxM6p2f5HKN/QQMLgLE/jyMhG1vdY006+r4JySPhqA RayeLybxKlg9k2H96C1MsgcnTPatC7Y/QQniCeHEDrDHCg4ADOUlmojqlK2Dt6iS8v8H8IM+uT3 Zw2JPxWOGe1xmOtlaYTslJ5K8M/Aa1JuFAQ81rL6IaH1Oh+nylS1Wo/dWC2oPwLkOK9K/F6tWK/ 2U2eI9EnYVs7LNrDZ0n1W2STCof9/yTbJ+IoK/uqsdmRSOeQLBhWcfSrsun4q8dmHZOvAp2xVgn tPyS0m7FjeEdnKDVdkKKkx9vIbc1nLdHn/6zVZQJNgpX3qs2LBG/Dc9mBwnZ8NHvjMfiGBCp/ps jg3COAfOwSwg6b5kXHmxLz+ux826xeRaiuu9pKR3ImH/W2B9y1PHe5gvr05N/RIJxzfpNJ6oZ5w FGO3pbuGyYk8zwgPwKydOGu+Pq86VFoJcy/qEBvaE+xmTmJjFUdOwyZHDM0YkuJZF+uNZ2PSzjR nAsXMibjNixWzJqm9zIcz3MLarx52RBZTqXRKzmwOFcWw== X-Received: by 2002:a05:600c:674a:b0:49f:f0bd:1e40 with SMTP id 5b1f17b1804b1-4a18e4afe9cmr172116475e9.23.1791817727904; Mon, 12 Oct 2026 08:08:47 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:09 +0200 Subject: [PATCH v2 16/50] hw/rtc: ds1338: add a persist-on-reset property MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-16-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=2768; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=iRJ3rs2DSADN75Y/aKHhGRl/gUKlcklqtq6S9GY4iFg=; b=LDDgByaSsE/yCzMpiyeYGFE3fRE0Wq8PEfJurPiQ/qp7WDod40sbkL0nj7CsyRJxYzeRMsPnc OAA9dAKXSnzCjd9kplVbXmIQFhHqE/XjRIWRhoZEzBVB3DIGbnybUUO X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.52; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f52.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817771001158500 A real RTC keeps counting across a reboot of the machine it sits in, and its register file comes back with it. The model instead wiped the registers on every reset and resynchronised the clock with the host. Add a property selecting between the two. It defaults off, leaving every board as it was. Signed-off-by: Emmanuel Blot --- hw/rtc/ds1338.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/hw/rtc/ds1338.c b/hw/rtc/ds1338.c index c5fc74e6ca..21deb94689 100644 --- a/hw/rtc/ds1338.c +++ b/hw/rtc/ds1338.c @@ -22,6 +22,7 @@ #include "qemu/osdep.h" #include "hw/i2c/i2c.h" #include "hw/rtc/ds1338.h" +#include "hw/core/qdev-properties.h" #include "migration/vmstate.h" #include "qemu/bcd.h" #include "qom/object.h" @@ -56,7 +57,8 @@ struct DS1338State { uint8_t nvram[NVRAM_SIZE]; int32_t ptr; bool addr_byte; - bool osc_stopped; /* oscillator halted: time is frozen */ + bool osc_stopped; /* oscillator halted: time is frozen */ + bool persist_on_reset; /* keep the registers across a reset */ }; =20 struct DS1338Class { @@ -263,9 +265,8 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) return 0; } =20 -static void ds1338_reset_hold(Object *obj, ResetType type) +static void ds1338_power_on(DS1338State *s) { - DS1338State *s =3D DS1338(obj); DS1338Class *k =3D DS1338_GET_CLASS(s); =20 /* The clock is running and synchronized with the host */ @@ -273,11 +274,29 @@ static void ds1338_reset_hold(Object *obj, ResetType = type) s->wday_offset =3D 0; memset(s->nvram, 0, NVRAM_SIZE); s->nvram[k->ctrl_addr] =3D k->ctrl_reset; + s->osc_stopped =3D false; +} + +static void ds1338_realize(DeviceState *dev, Error **errp) +{ + ds1338_power_on(DS1338(dev)); +} + +static void ds1338_reset_hold(Object *obj, ResetType type) +{ + DS1338State *s =3D DS1338(obj); + + if (!s->persist_on_reset) { + ds1338_power_on(s); + } s->ptr =3D 0; s->addr_byte =3D false; - s->osc_stopped =3D false; } =20 +static const Property ds1338_properties[] =3D { + DEFINE_PROP_BOOL("persist-on-reset", DS1338State, persist_on_reset, fa= lse), +}; + static void ds1338_class_init(ObjectClass *klass, const void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -289,6 +308,8 @@ static void ds1338_class_init(ObjectClass *klass, const= void *data) k->recv =3D ds1338_recv; k->send =3D ds1338_send; rc->phases.hold =3D ds1338_reset_hold; + dc->realize =3D ds1338_realize; + device_class_set_props(dc, ds1338_properties); dc->desc =3D "DS1338 I2C RTC with 56-byte NV RAM"; dc->vmsd =3D &vmstate_ds1338; =20 --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817841; cv=none; d=zohomail.com; s=zohoarc; b=CRBIjAizstaDi4pBwzP2/F3839pK1PnrvyE5XF25TBXd3s5H6V/6yYwWV9Scb3CscpvNk71gNUJOZA+f6WfYv657kV15LKAd/ql1GAdh8FDyANJioBEHQOu8nY53DX+XstSqIuSOlFi21lk2/0Mf/YKckZAoWcyiNOHsI8Gmk5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817841; 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:Sender:Subject:Subject:To:To:Message-Id; bh=swEPfqBhLhRQqBx1yQ6epg19lZgaV2YVKrysQPpGbtE=; b=ODfur3JPWH9xD1gjr7BEDB+aRQjjbZY9DXVlvV7Ba5UJlYU+zyv3L0kXiR4xbXv2AfstH5YG//hfbh2rF6r4MQMiU/pa9YJrUmkbYSb/RxnKj0pcZFxI0xwhAp9pJc4TodrHcCXNNeGKjTAf+k+KuQtMTd1rzl1Xr5dAeL5Qnuw= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817841205257.00931477023687; Mon, 12 Oct 2026 08:10:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHfH-0000GB-OX; Mon, 12 Oct 2026 11:10:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHf9-00006Z-HW for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:10:05 -0400 Received: from mail-wm1-f47.google.com ([209.85.128.47]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHf2-0007Q9-Cq for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:10:03 -0400 Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4a171b677d2so11920805e9.0 for ; Mon, 12 Oct 2026 08:09:50 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1a571294dsm1845815e9.3.2026.10.12.08.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:09:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817790; x=1792422590; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=swEPfqBhLhRQqBx1yQ6epg19lZgaV2YVKrysQPpGbtE=; b=1+aeEUYxgUnlykfs1naDghZMOAe/beiVWnupXLpj+1CPMsceEPm9oQNBfBZNIbsezV dq9fAMMdf9npvspmqmKbPVGadEIXvVqlkC9mZfmeUyd2lBsihJlM//KWphOKA8fihSH5 xBEuJI9ym8kdtbie6U48c8yAyCr0uYVtc2Fxss32IpSEAB3YK60vyw0hymB6Vjn2YaZN kmIJK7CzW7YGWFEJSSsmMGFSv7c4mFTCYvCuaOGTIGmlGBNA0d1c1kpYUYKmVxLNyc5l Xc+nT66TPUh2IoLJfwMujBoY1NKCpRnwsXu/CLAwckvNiLvNmaPgAmjvuLMbvTnUXBfp 32pA== X-Gm-Message-State: AFq9FYLa3e8kb/cVPBZVtCnVZw4G2grvFTtB0lp+MM96DInw4+Cs7EYt AKSj1y4jBRvvKWq3j7PQnUrt8E5Vb1zt/QIYD2vxIpQ67J2E0qsOOawZvvvLwZYP X-Gm-Gg: AYBFou3NTnKRxO/VkkLHscSBwhSZcznLWbtxShGoGyyH+I5FK0veXLtetvO2GOO2ua0 z4Z/yAl0X6K2LZVk8XgSXkqjpNfnWbW2AbG5ySTKiiBxx2/oJGOuukbs56r+/xj0aekzLfNzmtB sFQ3oEmVR4oKrY+8EvgczL1tzXchGUw7RhsY8qXCa5FOXZfk0dDkNRy9DcTN+TFdD2T4KA/yrqw OVBWYzCKN1gCUo/3llGjYATRdmA+9cbCV2px4BnwwHiX1UZaiPdJoig6VelM69mRgfPmR2gzGas SZdt11l/ZyTw00zHlcEVp7EedVtyIaboNmJjGA4+xSE6uPLcVTg2RW7FPgHeni6wgoY3+aA6Gc/ N8lP4PVAh/ktxirlLNr6PFrRfnNyLvkTCB4JCgRcMCBW19Tfz0+fdP2FNi4k4QC8RupKhYIf9Ch 958vHke0HFkni8vF0lVZQEBz/0xoQbdwDrji5CEAMcWVZkznkdjFjkgM+Ep6WPTHgBF1l2G4kHU ql+Lll4AVv6wlDNXnaR17FJv0LZ8qvVIwZ3waJ/E0sFkQ== X-Received: by 2002:a05:600c:6388:b0:4a1:6f78:8419 with SMTP id 5b1f17b1804b1-4a18e3ee8f9mr184492125e9.0.1791817789483; Mon, 12 Oct 2026 08:09:49 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:10 +0200 Subject: [PATCH v2 17/50] tests/qtest: ds1338: cover the DS1338-specific register map MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-17-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=4125; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=f3xwMcybpUuYM4No52iJ5xYNXDYQs4KcmfHzwqwanMw=; b=8/Krx+jLDWUoiyTq5575d8wTJCHv2D7IMrOCjBKm+Nwf/aZoJlYmq+tzWNd3P3VgAH1gfTO2d QGcbCWT/GecBMwiBCkphCM3WN7RG0Moi4PsoA5RhaQTLXcWn1CsxcWG X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.47; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f47.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817842960158500 The register map is a set of per-model class properties. Pin the values it holds for this part, so a later change cannot alter them unnoticed. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1338-test.c | 67 +++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/tests/qtest/ds1338-test.c b/tests/qtest/ds1338-test.c index b8d0e65ec4..6066a34846 100644 --- a/tests/qtest/ds1338-test.c +++ b/tests/qtest/ds1338-test.c @@ -24,6 +24,15 @@ =20 #define DS1338_ADDR 0x68 =20 +/* DS1338 register map */ +#define DS1338_SECONDS 0x00 +#define DS1338_CONTROL 0x07 +#define DS1338_NVRAM 0x08 +#define DS1338_NUM_REGS 0x40 + +#define DS1338_CTRL_OSF 0x20 + +/* The clock and calendar come up on the host time. */ static void send_and_receive(void *obj, void *data, QGuestAllocator *alloc) { QI2CDevice *i2cdev =3D (QI2CDevice *)obj; @@ -32,7 +41,7 @@ static void send_and_receive(void *obj, void *data, QGues= tAllocator *alloc) time_t now =3D time(NULL); struct tm *tm_ptr =3D gmtime(&now); =20 - i2c_read_block(i2cdev, 0, resp, sizeof(resp)); + i2c_read_block(i2cdev, DS1338_SECONDS, resp, sizeof(resp)); =20 /* check retrieved time against local time */ g_assert_cmpuint(from_bcd(resp[4]), =3D=3D , tm_ptr->tm_mday); @@ -40,6 +49,56 @@ static void send_and_receive(void *obj, void *data, QGue= stAllocator *alloc) g_assert_cmpuint(2000 + from_bcd(resp[6]), =3D=3D , 1900 + tm_ptr->tm_= year); } =20 +/* Writable control bits round-trip; the reserved ones read back zero. */ +static void test_control_register(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + i2c_set8(i2cdev, DS1338_CONTROL, 0x93); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL), =3D=3D, 0x93); + + i2c_set8(i2cdev, DS1338_CONTROL, 0x4c); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL), =3D=3D, 0x00); +} + +/* The oscillator-stop flag can only be cleared by a write, never set. */ +static void test_osf_write_protect(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL) & DS1338_CTRL_OSF, + =3D=3D, DS1338_CTRL_OSF); + i2c_set8(i2cdev, DS1338_CONTROL, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL) & DS1338_CTRL_OSF, = =3D=3D, 0); + i2c_set8(i2cdev, DS1338_CONTROL, DS1338_CTRL_OSF); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL) & DS1338_CTRL_OSF, = =3D=3D, 0); +} + +/* The user RAM returns what the guest wrote to it. */ +static void test_nvram(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + i2c_set8(i2cdev, 0x08, 0xaa); + i2c_set8(i2cdev, 0x20, 0x55); + i2c_set8(i2cdev, 0x3f, 0xc3); + + g_assert_cmphex(i2c_get8(i2cdev, 0x08), =3D=3D, 0xaa); + g_assert_cmphex(i2c_get8(i2cdev, 0x20), =3D=3D, 0x55); + g_assert_cmphex(i2c_get8(i2cdev, 0x3f), =3D=3D, 0xc3); +} + +/* The register pointer wraps at the end of the map. */ +static void test_address_wrap(void *obj, void *data, QGuestAllocator *allo= c) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + i2c_set8(i2cdev, DS1338_NVRAM, 0x5a); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_NVRAM + DS1338_NUM_REGS), =3D= =3D, 0x5a); +} + static void ds1338_register_nodes(void) { QOSGraphEdgeOptions opts =3D { @@ -49,6 +108,12 @@ static void ds1338_register_nodes(void) =20 qos_node_create_driver("ds1338", i2c_device_create); qos_node_consumes("ds1338", "i2c-bus", &opts); + qos_add_test("tx-rx", "ds1338", send_and_receive, NULL); + qos_add_test("control-register", "ds1338", test_control_register, NULL= ); + qos_add_test("osf-write-protect", "ds1338", test_osf_write_protect, NU= LL); + qos_add_test("nvram", "ds1338", test_nvram, NULL); + qos_add_test("address-wrap", "ds1338", test_address_wrap, NULL); } + libqos_init(ds1338_register_nodes); --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817886; cv=none; d=zohomail.com; s=zohoarc; b=X4YNlxhR95itIqARcCSYOA4HAkh7fX2r7coqDnelq8sXqO2NJvzDkymdf2DkasHV7ityO7WCYp6dwsjIv8zYVuva/wo/szQ6HKIoqoCoWacwIzMYuL5S/9Gx1VxOIy0rrAN96fFBtKeToW4WPbvWSW5i54WWfEt9DChQZuoL8Mc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817886; 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:Sender:Subject:Subject:To:To:Message-Id; bh=9bQz/dpQcTFmknV0ZVNikpRUpVUFhyWc4TFL1C+8fm4=; b=mqhiiSv/LHcSTVbg6tywGyTTx8M3jH6TQ30mIqjarhSImFrAhgYvQSGMg86W0FuNDM8LJf5flq1rJoleh3vNA1SxfCckZM52yc5CxfcN7rG1iEqFRZ63Q3sxzPC5HycmACuvCNXciz9C38gRDheYA+wRgPW6FXFZRi5T11+r48A= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179181788697085.62300236099281; Mon, 12 Oct 2026 08:11:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHgD-0000om-7B; Mon, 12 Oct 2026 11:11:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHfz-0000gm-5B for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:10:55 -0400 Received: from mail-wr1-f47.google.com ([209.85.221.47]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHfw-0007ky-Uz for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:10:54 -0400 Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-48c6955a7c3so425071f8f.1 for ; Mon, 12 Oct 2026 08:10:52 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48db9abd3aasm19361499f8f.32.2026.10.12.08.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:10:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817851; x=1792422651; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9bQz/dpQcTFmknV0ZVNikpRUpVUFhyWc4TFL1C+8fm4=; b=LX1kpW95Dko5BpmKlDal/my712Ay97Mk8Ta8cZvHlzi3vGdxdLeXLLcGyHGfJzLpfH X9ItyE0LZuxAMYfo7bqfkQSkndwngD9kboRPu4NWF7hqZY+xLieU+FmOemOj+Mjb/Vmt bq9MFRxb5WjONB02taWdfbAMOIsSJJ+SKiPGRUfTKIA3bFKRdCzuSyajZxmdaNVkRJ8p kTOe869rEMPBNDSV1w27SRAFk7YOi6aNC4+WxZIfr+cAQ7Frth0vaBrSuWgykOpuDG8Y 8nqLvlbonl8Mz3k2etTrAOn8grqbBlOr9g2G1GMniw4GJ5ecTSt58yQ2UUhmH2g0EDfG hY2Q== X-Gm-Message-State: AFq9FYIqWRBkf7Z6AoO5n+wO2qqaem1hvUBnlbZu6SCDHEOqF0s/LYUL 2Mp3LgaHvco1A70Jbm//PNHUspOfYMvRGf54y7UOnfEV76SWW2lTBplhbxMbGorH X-Gm-Gg: AYBFou0j/tNr7MNaAuuo3i1UcuuZ+jnN8yfVMfNDqVnKRbuYW4uRqJdU9zW5978uEcZ wDEQ0K8tzjB/iXrwfbLnr02mZwai0uyXOhaoJJRXgcRljwO5WslrA09fdcJz1iiI9ivE3R4FB/I 9O4ehFjUC+Rd7HU8ppyynLhBmohy8JBTOV2Jrv6GXWCc0KFnvRhZCW4h1mq3+k5j2+TMaiVi9lM Nh0i2wAf8dnhYF1zDTZqKdeSsicb3PJwB+ms2PiqkZfOPNeo1CXfEpMPanT8PrZZ3k3z/Ds6cfO gGPlMCgAHGecaTbvvHrN7c4Ah3cJR3fJ28ApHbXbaWwH7VRgL4N+AF36oAnSbvN983V5P2yCZGL Vyzpg1ssBIC0Vtig2dh9iLeZZLd3N6TeWFz89gtQUzeLp8EjvL2I0FE0335fyoKTVuexjvguobu /06R9NlvSWJ0nZ5mWMsp1afB6SA3CMQKNT1WlyWP45pezHj5TnTybDt49mTNPpWJCBcI6WXHWQ2 cT/2x5uo02v7TmSK50MxwCwKgaMAp/XHIaGeE/urxqZug== X-Received: by 2002:a05:6000:29d6:b0:487:40a:5ba8 with SMTP id ffacd0b85a97d-48dbacecc29mr10911946f8f.15.1791817850809; Mon, 12 Oct 2026 08:10:50 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:11 +0200 Subject: [PATCH v2 18/50] tests/qtest: ds1338: cover the power-on register defaults MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-18-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=1856; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=9nlnuEXuVbr9L6NPGTObkdBzIqjpFAqXLz9Eqo8+gf4=; b=EJka7OBMD+c0KBxDRvlXbDlcNQsODRKuSGgPWLO44rhTjOmICbJOPv7rRbgDjhdmigeBEQo8V 88tDnBOTX2eCk+HxE0JRj6QNbiPu+RHy+uCJpiagxA9hyRs7ktIb/Oy X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.47; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f47.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817889526158500 Nothing pinned the reset value of the control register, which is how it sat at zero rather than at its documented power-on state. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1338-test.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/qtest/ds1338-test.c b/tests/qtest/ds1338-test.c index 6066a34846..fad0ca53d4 100644 --- a/tests/qtest/ds1338-test.c +++ b/tests/qtest/ds1338-test.c @@ -31,6 +31,7 @@ #define DS1338_NUM_REGS 0x40 =20 #define DS1338_CTRL_OSF 0x20 +#define DS1338_CTRL_POR 0xb3 =20 /* The clock and calendar come up on the host time. */ static void send_and_receive(void *obj, void *data, QGuestAllocator *alloc) @@ -49,6 +50,14 @@ static void send_and_receive(void *obj, void *data, QGue= stAllocator *alloc) g_assert_cmpuint(2000 + from_bcd(resp[6]), =3D=3D , 1900 + tm_ptr->tm_= year); } =20 +/* The control register comes up in its documented power-on state. */ +static void test_reset_defaults(void *obj, void *data, QGuestAllocator *al= loc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL), =3D=3D, DS1338_CTRL_= POR); +} + /* Writable control bits round-trip; the reserved ones read back zero. */ static void test_control_register(void *obj, void *data, QGuestAllocator *alloc) @@ -110,6 +119,7 @@ static void ds1338_register_nodes(void) qos_node_consumes("ds1338", "i2c-bus", &opts); =20 qos_add_test("tx-rx", "ds1338", send_and_receive, NULL); + qos_add_test("reset-defaults", "ds1338", test_reset_defaults, NULL); qos_add_test("control-register", "ds1338", test_control_register, NULL= ); qos_add_test("osf-write-protect", "ds1338", test_osf_write_protect, NU= LL); qos_add_test("nvram", "ds1338", test_nvram, NULL); --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817941; cv=none; d=zohomail.com; s=zohoarc; b=nG8X+k4fygMgkzYoFNk0pq/eU/4Pm01c2QQgG96xMeWvDAYAmCl9fmhTApEE08xibZjozKivK7dnR3Qg0lxO2xczqF9OEMSrnWoRI3VoCBk5v3NP1M47taL4bQIGo8/n3ME6u83BVXQFtr04aIaVeI5XCPWmaS031JTo1jc6gGs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817941; 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:Sender:Subject:Subject:To:To:Message-Id; bh=QueqO13xdW/ZwsAlzziCNKkk2yOl7iMFMMHkLAoSdjc=; b=jNqE3aKwUXYy34hYbZ9m5gTbwcn9s0SKOxXjIsTqTH5oIF33H076/2gCJ0QS7bQTaT2kgtLUBaENaKiEp9XlLacbExeiHGJF3Pps6LWTikZM2MbS/9W3rwwwRL6U9Eu/7GHTrFd7yARP8FxUV2aeiVsn73CuYmtl3j/r7GLYbv0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817941047271.90100091106876; Mon, 12 Oct 2026 08:12:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHh6-0001a3-4k; Mon, 12 Oct 2026 11:12:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHgz-0001XZ-07 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:11:58 -0400 Received: from mail-wm1-f52.google.com ([209.85.128.52]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHgv-0007rf-MC for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:11:56 -0400 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4a020e65269so12455245e9.2 for ; Mon, 12 Oct 2026 08:11:53 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a19c71a1d7sm114618035e9.5.2026.10.12.08.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:11:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817912; x=1792422712; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QueqO13xdW/ZwsAlzziCNKkk2yOl7iMFMMHkLAoSdjc=; b=uHYaPx0Qrj9lUSzuOpW+ESfRzapBlEn8LkifA2ll4MYLF7/gzYvuHH39TQgjpXdBy1 DHemY/YFb3mFkADG1ow38RaIg4UuMEycQ449X/DLWgn+SJlDy4n0QcIUXDS++1I0HItn 2LjJC2NaOiPNojhDo023QB+awMdMbV9tn5uwgAjavxlEwh5fv7fzNzrcfAIcHGF9zGsD gAnYms7790ah9v9BEV5qFUCLAhp94xpjZVlQdXIBspzVyY90dUMgbjG67JJG9QV45bAV iAA8RS1fjCAruNKCEkN/qgmAsMdJXLUv49U/PE51BV9qjWXZ4k7X/8CX3KxQ/rIY8MTx pbsg== X-Gm-Message-State: AFq9FYIGcpAO0ZjicOUu7nrXA1/c5qugiT5Qcz7LsEZJnWJXBOxeF0d9 DM6ftwMAvDJMyED3A8RaTlcNgPKeO07maws+QpHNBMcOQky0arxOr8wGB/JGIL5v X-Gm-Gg: AYBFou2RhwfG+4+MHXZgW2o2PLgyBicQukSUrs2NvrrFaIkPskhI8ZMuuzs34C8vV/F m5yShM580sbj3N4mw9DNpBL1Pq58XGrq0zA06/ISXGbK46rP/qi4wCgEUyWLvEagsUchGoEPras r6xONzs+nyz851Y4RZ3fENb1XcRi8cQPbTfqzjAQ1hLhUDUQF6Xdp/4t20Y6f0i9uwRjRuS9cic ZBgXQR3ukcWwoX4GKrOl5fHwCQe2Zp789nySyLS8tM/J0hP4prHNRtiQUimTAAoGm4AlER4Jg7r n2/jEWrgMiJ4XQdU0hlcHHtlnc0QeL7up9BQVbSRmhfWqjVGa0jsxgcmQxhvXTTG2tDSL5ThCP/ hvh0+5JEK6ysXBI0F9IoTnIO40QITJV+5feEGPdKZ52XhGGTvEoHmirwuoCo38KYpLzaUDc5Ayd 3fF2dWV8GSRB7nXLkerlwiLZIsZT0mwc3RBH5mxEGmMXe3d/OEKHPtvE1O/eqRo5U3ZXSz7L624 WZeNjT0O7CWZkov7rqnxF12p6QKKNR4TiB7EtyJ3VMqDw== X-Received: by 2002:a05:600c:8b83:b0:4a1:811c:8064 with SMTP id 5b1f17b1804b1-4a18e4d5512mr184353285e9.26.1791817912010; Mon, 12 Oct 2026 08:11:52 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:12 +0200 Subject: [PATCH v2 19/50] tests/qtest: ds1338: cover the clock-halt bit MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-19-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=2993; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=PGqbxjw1SjqsGpwA7KFSLwn1aqj7opA+7ReWeQn2c+U=; b=zjTBktTePMzZboKFMmcjtbHyQErYjv+tMeqwk9qkm+WoYd9cxaciTIh0isAwQ1FsWxHZ9yEHg rQ6oNNGuQPNDv8Q4lgAm75fXFpeTK5XJDpL4LhW5OewWi1hYz8uOfUd X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.52; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f52.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817942230158500 The clock-halt bit had no coverage, nor did its effect on the oscillator-stop flag. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1338-test.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/qtest/ds1338-test.c b/tests/qtest/ds1338-test.c index fad0ca53d4..1b73dca98d 100644 --- a/tests/qtest/ds1338-test.c +++ b/tests/qtest/ds1338-test.c @@ -32,6 +32,7 @@ =20 #define DS1338_CTRL_OSF 0x20 #define DS1338_CTRL_POR 0xb3 +#define DS1338_SEC_CH 0x80 =20 /* The clock and calendar come up on the host time. */ static void send_and_receive(void *obj, void *data, QGuestAllocator *alloc) @@ -85,6 +86,42 @@ static void test_osf_write_protect(void *obj, void *data, g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL) & DS1338_CTRL_OSF, = =3D=3D, 0); } =20 +/* Halting the clock freezes the counters; clearing the halt resumes them.= */ +static void test_clock_halt(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + uint8_t frozen[7], again[7]; + unsigned idx; + + /* Clear OSF first, so that halting the clock is what sets it again. */ + i2c_set8(i2cdev, DS1338_CONTROL, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL) & DS1338_CTRL_OSF, = =3D=3D, 0); + + i2c_set8(i2cdev, DS1338_SECONDS, DS1338_SEC_CH | 0x30); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_SECONDS), =3D=3D, + DS1338_SEC_CH | 0x30); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL) & DS1338_CTRL_OSF, + =3D=3D, DS1338_CTRL_OSF); + + i2c_read_block(i2cdev, DS1338_SECONDS, frozen, sizeof(frozen)); + g_usleep(1200 * 1000); + i2c_read_block(i2cdev, DS1338_SECONDS, again, sizeof(again)); + g_assert_cmpmem(frozen, sizeof(frozen), again, sizeof(again)); + + i2c_set8(i2cdev, DS1338_SECONDS, 0x30); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_SECONDS) & DS1338_SEC_CH, =3D= =3D, 0); + for (idx =3D 0; idx < 50; idx++) { + if (i2c_get8(i2cdev, DS1338_SECONDS) !=3D 0x30) { + break; + } + g_usleep(100 * 1000); + } + g_assert_cmpuint(from_bcd(i2c_get8(i2cdev, DS1338_SECONDS)), >, 30); + + g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL) & DS1338_CTRL_OSF, + =3D=3D, DS1338_CTRL_OSF); +} + /* The user RAM returns what the guest wrote to it. */ static void test_nvram(void *obj, void *data, QGuestAllocator *alloc) { @@ -122,6 +159,7 @@ static void ds1338_register_nodes(void) qos_add_test("reset-defaults", "ds1338", test_reset_defaults, NULL); qos_add_test("control-register", "ds1338", test_control_register, NULL= ); qos_add_test("osf-write-protect", "ds1338", test_osf_write_protect, NU= LL); + qos_add_test("clock-halt", "ds1338", test_clock_halt, NULL); qos_add_test("nvram", "ds1338", test_nvram, NULL); qos_add_test("address-wrap", "ds1338", test_address_wrap, NULL); } --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791817987; cv=none; d=zohomail.com; s=zohoarc; b=CQn5FLnFBW/RuhHOJ0e30/LyH4I7bUZ4xEdH4199BPRJz+q8HJDIuIWsWnPsjuZJvWYO4GL/DauCYiJ6qAgH1KtBWYqlfgXJoEvS0gARQQ1keOxMSPL9CKOzvuyix6PqoVKrT91x3MzL8gut/Q4qShOZsrCJsYtf37oCyVMNacI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791817987; 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:Sender:Subject:Subject:To:To:Message-Id; bh=CE66LIeSclgE4NkiTTrzb49MDOENKPAt6wmOxVbF85E=; b=jGF2tKD22+NFFX95FqxbnMOm3+qFnw9FPssDplUAh4iPI5yqqZmENxbKUoenI8oZ63sBO614M3GwNAzs1uM6T1HqEaXXpalTdm044dlj2pwfPcD174/Elluldc0qilO7n1psx2EDrnu+BBKgJJwWGwoXSALchY1d3HqkmS6GEwM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791817986973344.0941312153826; Mon, 12 Oct 2026 08:13:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHhz-00022x-8j; Mon, 12 Oct 2026 11:12:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHhy-00022d-Hy for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:12:58 -0400 Received: from mail-wm1-f51.google.com ([209.85.128.51]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHhu-0007yK-On for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:12:57 -0400 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4956869750eso15660175e9.2 for ; Mon, 12 Oct 2026 08:12:54 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48db98c2800sm19934060f8f.26.2026.10.12.08.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:12:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791817973; x=1792422773; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=CE66LIeSclgE4NkiTTrzb49MDOENKPAt6wmOxVbF85E=; b=dS/a1uzCoHKXvCX1470RkWB56cRXPRuPMJNf950Iz9U6W+Q+ighV8m3CUTCa/FbIfo XDydyAdT/zOZDFrkAVpTXZ2WjP3kVuxYOhAsM4rsRNKxY87AovjJ2l+31Pi6ZiejVeBI sosB56zUoaYhUIfGiCwvym7saLLU3BrI5vJKEU+lDGsR64v8ifhcx3McBOwEQjAyDHFQ SYu4dYh5ge5eU+kSmi+6gfPAzoZjktQFjLUhQOzJdlzTWu7tQAn3OxZZ6R2OcL3Rn3Wd bDX6Pr975wKVt7MINWmgSlrTZ8ueP8LA48GEOifJNy8jroAronZ6+iKJALCg3tpxx8Zd 5+Cg== X-Gm-Message-State: AFq9FYII02mcbY5vrUc6qb8WWwloo4oBjHJxuriI52PNmO13lhTpU0By dBS8K85J16w5apMKs+fS/QHPsagW71S4fCFGipx7sS10dycfXPEO2JatksgHxe4N X-Gm-Gg: AYBFou2k9Vxc6e5r0/U5Wipb1+ejkBxfwZQ0XbifKmOGN6KqwMLammTM/Su6d+hdblM ZieGkgXH45Wa99TO6p3YvZENnn97zZRJcdHy7bm2538tI2j02M2kO+UK1VgGcdO7jvnZ8fc/1A5 hsLm5eSdZ/hrud4fbkbgtoHfs5rfLnda6klGEygVxGIhs6zob+TjLEx+/ItwUknypA82CLP9UyR sfbdOCITeIUorY6yuhsQhlYlODyUQHXc9P9rkBwcJj5OKr0gCHNfBu+sV84U3VEzaLPah9ltYfD cru0sDPeJTjHQFXMvZ/wcbF2ehRKzCaXRqmAd1EOY4DY2M4Mwrm0SpW3/6qzw2d9PPQ3sElnBmi rvjOp8pidIcFk9Gd3et7wgAEas1zbKcL3KHIqMC1waCFp3g9DpPAcUFXYl2bxh8ForQmyL5D3Vf 62XbnKTTZhzb4BvURLZU7ckCloGoUBSuQ6RCiF1q67ZWThCEv04UK7Ta/8iuUxVFxXgIJmOC6iE sKuNPa5dZRsuPz/w5G/BczH0/+8tZquI42VTxoOiDaZBR8= X-Received: by 2002:a05:600c:5247:b0:4a1:6991:36d7 with SMTP id 5b1f17b1804b1-4a18e49d570mr182551895e9.10.1791817973142; Mon, 12 Oct 2026 08:12:53 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:13 +0200 Subject: [PATCH v2 20/50] tests/qtest: ds1338: cover persist-on-reset MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-20-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=3608; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=whBRDkq86D+HpAogEE9qlSe08li7AMBnF3gE+b/1tiI=; b=oylJ/3/R/JR+puOD69en13ppagms6hP/Q1YumayLxX1u2VKcVoQ0z5PHE0+X6J0iOyuwhwp5N Y4kwiNuyQ6rDMibV7fOZrGDEe2s3B8JrU3weIPpW+sIxGq9KfB7OajV X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.51; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f51.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791817989239158500 The property had no coverage in either of its two settings. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1338-test.c | 54 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 54 insertions(+) diff --git a/tests/qtest/ds1338-test.c b/tests/qtest/ds1338-test.c index 1b73dca98d..1b9c02d931 100644 --- a/tests/qtest/ds1338-test.c +++ b/tests/qtest/ds1338-test.c @@ -20,12 +20,15 @@ #include "qemu/osdep.h" #include "qemu/bcd.h" #include "libqtest.h" +#include "libqtest-single.h" #include "libqos/i2c.h" +#include "qobject/qdict.h" =20 #define DS1338_ADDR 0x68 =20 /* DS1338 register map */ #define DS1338_SECONDS 0x00 +#define DS1338_YEAR 0x06 #define DS1338_CONTROL 0x07 #define DS1338_NVRAM 0x08 #define DS1338_NUM_REGS 0x40 @@ -136,6 +139,50 @@ static void test_nvram(void *obj, void *data, QGuestAl= locator *alloc) g_assert_cmphex(i2c_get8(i2cdev, 0x3f), =3D=3D, 0xc3); } =20 +/* A reset restores the power-on state, unless persist-on-reset is set. */ +static void check_reset(QI2CDevice *i2cdev, bool persists) +{ + uint8_t year =3D i2c_get8(i2cdev, DS1338_YEAR); + /* A year the clock is not already showing, so the check discriminates= . */ + uint8_t marker =3D year =3D=3D 0x42 ? 0x77 : 0x42; + QDict *rsp; + + i2c_set8(i2cdev, DS1338_NVRAM, 0xa5); + i2c_set8(i2cdev, DS1338_CONTROL, 0x00); + i2c_set8(i2cdev, DS1338_YEAR, marker); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_NVRAM), =3D=3D, 0xa5); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL), =3D=3D, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_YEAR), =3D=3D, marker); + + rsp =3D qmp("{ 'execute': 'system_reset' }"); + g_assert(qdict_haskey(rsp, "return")); + qobject_unref(rsp); + qmp_eventwait("RESET"); + + if (persists) { + g_assert_cmphex(i2c_get8(i2cdev, DS1338_NVRAM), =3D=3D, 0xa5); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL), =3D=3D, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_YEAR), =3D=3D, marker); + } else { + g_assert_cmphex(i2c_get8(i2cdev, DS1338_NVRAM), =3D=3D, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1338_CONTROL), =3D=3D, DS1338_C= TRL_POR); + /* Back on host time, which is where the year came from. */ + g_assert_cmphex(i2c_get8(i2cdev, DS1338_YEAR), =3D=3D, year); + } +} + +/* Without persist-on-reset, a reset takes the part back to power-on. */ +static void test_reset_clears(void *obj, void *data, QGuestAllocator *allo= c) +{ + check_reset((QI2CDevice *)obj, false); +} + +/* With persist-on-reset, the registers and the clock survive a reset. */ +static void test_reset_persists(void *obj, void *data, QGuestAllocator *al= loc) +{ + check_reset((QI2CDevice *)obj, true); +} + /* The register pointer wraps at the end of the map. */ static void test_address_wrap(void *obj, void *data, QGuestAllocator *allo= c) { @@ -162,6 +209,13 @@ static void ds1338_register_nodes(void) qos_add_test("clock-halt", "ds1338", test_clock_halt, NULL); qos_add_test("nvram", "ds1338", test_nvram, NULL); qos_add_test("address-wrap", "ds1338", test_address_wrap, NULL); + qos_add_test("reset-clears", "ds1338", test_reset_clears, NULL); + + opts.extra_device_opts =3D "address=3D0x68,persist-on-reset=3Don"; + qos_node_create_driver_named("ds1338-persist", "ds1338", i2c_device_cr= eate); + qos_node_consumes("ds1338-persist", "i2c-bus", &opts); + + qos_add_test("reset-persists", "ds1338-persist", test_reset_persists, = NULL); } =20 libqos_init(ds1338_register_nodes); --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818075; cv=none; d=zohomail.com; s=zohoarc; b=n3rI3KZUxJTpx6TGEb+1qdJVamEeG4xLEWKEt0+wxlFqYgLUkGVPDMzMzGYf/Kng7mRPPc5LcbCXCqhdpMuC8QwddNCWcE/UA642fJCv/v5r+qvpnB9fIt3wGv2ijsS8LvUrro8xI3nKU0ZyF1jm4lCzekjy1Zww0+RBq4BUGMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818075; 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:Sender:Subject:Subject:To:To:Message-Id; bh=m2GA4fazsDlog1s+fRBtwXY8L09cn4aW6lhQjZ5SfME=; b=jaHzOWDEs5gk6eLybf6TXfxrReO31+bYzWAYqMx3k1FosRgVB0uPHwY0a65pvFJo7wocyY/Jik8zc4mxSAvnzLlQf5Yj+UJnhYSKk8Ljm6zu/NiYMOIrs+RAu6W0LhwNXyZnjpG1hR6NiYjL/0Bo247a9BxF22OWCxuRUjn+nLs= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179181807513857.94888139540012; Mon, 12 Oct 2026 08:14:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHj9-0002Z5-8N; Mon, 12 Oct 2026 11:14:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHiw-0002Y4-UM for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:14:00 -0400 Received: from mail-wr1-f46.google.com ([209.85.221.46]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHiu-00085C-1P for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:13:58 -0400 Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-48af4d4e61fso1403307f8f.2 for ; Mon, 12 Oct 2026 08:13:55 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0514ab1sm122891f8f.0.2026.10.12.08.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:13:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818034; x=1792422834; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=m2GA4fazsDlog1s+fRBtwXY8L09cn4aW6lhQjZ5SfME=; b=YhKx3H4/SwQU9TSJUT8ckKH6bhQlM1FKLheNPghFN/yBdFWsROQaeAR4WyH4CpSMGF kEWH2S0fO+70kLV8t3/qgR1rrB7K5FpPXjEmu54BkG4eJyD0MTxSXFDIYHKMhw7gU+Rw iObkz5SnkxGb1nBGMzTeT4d7YBKAqn0Pd3TR0Ck2JhIqHQjzlznHNNUABmfSl4Qnv1KN 1GJncuQggsEkr4gy8riIx8bFmSP1NMosLyFobB6kcFE1VjYofd7IqBeenAYUooqP8XQU opb/EdJHg47V7BcJpOhvMflrbExMFbCjmZaZvdzAcm8qzalX3mfqZeCUt3vhpV8AiHih LXSQ== X-Gm-Message-State: AFq9FYKfI6TRtMpLqNG00JGAAfvg4U7PbBgtEyb3Lkogu4lBYUqRdCCd /LxuhDifRSEqVlYHJCIdAZSI3AriKa1JA5YEvCTwQ39JuvJH9kOePHKsS/qPtV27 X-Gm-Gg: AYBFou2sMv//W91FKncP7fJ1cGqJmYbyZZcN/ovfxUDGrKMlGNlgTVi5FM5UGlNEN0W d067cZMx4Vbk+O73KVw9VjLiQqKmIEZfbfBSrqZnQ9u30e3gaCKWM+zazk1ItfMXRgrmpDSI4UE +8BDR3tBndbFLOAr6h/jFbf8F0Fexz23eEgSC5CFnVAIOzNiMgVYBOuWTkjNkyNC9Xo9ev/32Mt KE79Ad/RphJ4Ql2Nlq5NdVuFJsKbmmSBTu4U6BXG3onp+gxslwBvFqTYaphqxpYK3CTLeoZJ9dY xg7w4If5gfI4rTw3KIrCghq7T9lk5a0s62fxpmiZ7YbYWN5yVOHFeWbnwj9MNAhbX8Slt/iHRK0 qIzHz42krDpMMk7ACghQr9o2Ujh5M9vyvgKmM15lW4jyhWW/RWMa0WPuGV/ausST5KFPUYg8SFg LTQ1le9dQdUpgJh+v9bTFhJ0gfIm3jp+lFuW4WOVtYKOxOzI6FaNnG+YxJLC1MWZPRmx3Qvn0g1 avyJvFmWxu/vT59Q5HZ4TijyWrW/CacZUypJJotIOqstw== X-Received: by 2002:a5d:59c5:0:b0:48a:f592:fb63 with SMTP id ffacd0b85a97d-48dba7bea5dmr18541428f8f.1.1791818034234; Mon, 12 Oct 2026 08:13:54 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:14 +0200 Subject: [PATCH v2 21/50] tests/qtest: ds1338: cover the reserved bits of the time registers MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-21-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=2162; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=KJY0zIrKxG//LL1WKd4K1qyh6CHHxQ+6MszW1XMqpgc=; b=1iKV0oV3yRvjn623f+4E7dwXeJvrn/Atpfy20ZcQS0vfIIs2QwYrYErpilCTCDogvTZkW0I7j s42MtSTZ0vFByJP2wL5Ur5U+fqT3yfRebJ4WUolrZbgU803kZn3A1Ck X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.46; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f46.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818076903158500 Nothing pinned which bits of a time register survive a write. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1338-test.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/qtest/ds1338-test.c b/tests/qtest/ds1338-test.c index 1b9c02d931..9e2e257307 100644 --- a/tests/qtest/ds1338-test.c +++ b/tests/qtest/ds1338-test.c @@ -125,6 +125,26 @@ static void test_clock_halt(void *obj, void *data, QGu= estAllocator *alloc) =3D=3D, DS1338_CTRL_OSF); } =20 +/* Reserved time-register bits read back zero even with the clock halted. = */ +static void test_stopped_reserved_bits(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + const uint8_t all_ones[7] =3D { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x= ff }; + uint8_t resp[7]; + + i2c_write_block(i2cdev, DS1338_SECONDS, all_ones, sizeof(all_ones)); + + i2c_read_block(i2cdev, DS1338_SECONDS, resp, sizeof(resp)); + g_assert_cmphex(resp[0], =3D=3D, 0xff); /* the halt bit is writable = here */ + g_assert_cmphex(resp[1], =3D=3D, 0x7f); + g_assert_cmphex(resp[2], =3D=3D, 0x7f); + g_assert_cmphex(resp[3], =3D=3D, 0x07); + g_assert_cmphex(resp[4], =3D=3D, 0x3f); + g_assert_cmphex(resp[5], =3D=3D, 0x1f); /* no century bit on this pa= rt */ + g_assert_cmphex(resp[6], =3D=3D, 0xff); +} + /* The user RAM returns what the guest wrote to it. */ static void test_nvram(void *obj, void *data, QGuestAllocator *alloc) { @@ -207,6 +227,8 @@ static void ds1338_register_nodes(void) qos_add_test("control-register", "ds1338", test_control_register, NULL= ); qos_add_test("osf-write-protect", "ds1338", test_osf_write_protect, NU= LL); qos_add_test("clock-halt", "ds1338", test_clock_halt, NULL); + qos_add_test("stopped-reserved-bits", "ds1338", + test_stopped_reserved_bits, NULL); qos_add_test("nvram", "ds1338", test_nvram, NULL); qos_add_test("address-wrap", "ds1338", test_address_wrap, NULL); qos_add_test("reset-clears", "ds1338", test_reset_clears, NULL); --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818165; cv=none; d=zohomail.com; s=zohoarc; b=hkOmWRcbzzGYYT/7477HBFL8xwF5rNeUGB6yzIVswyl8ssNRtpooTSATnHOH3XN6Ae8nhdHAQ1ksz38H3JhFu54CgAETSBicAgnbonTxEyTAk1WOQv+hAITsXyyv21Tpcc3y/oor26CHt9SJTq1rSeFbnOciw0ukw4PJBBgpMjQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818165; 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:Sender:Subject:Subject:To:To:Message-Id; bh=xjPmksDx32sBE3I0U0f2mMmY0tOvAwSTdWeiZF0OcZw=; b=PjJcGY9Z1AaV4mKFkKu3TWv+Ae+uDEO/Y7E+oJiCRiX3nvi9alpsx3QECuqTK7H5yHndCDEOMJAg2/CuoHreQMJKyD4QBgCGRo6ERQeqzlH97O8dnTThGP5u0vFJNTO6cXyWhF+lA/k/qmrSM1thRG6x4nWS3t6bqHPwR1SJhfs= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791818165216998.8734940954489; Mon, 12 Oct 2026 08:16:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHk4-000374-AG; Mon, 12 Oct 2026 11:15:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHjw-000359-Ks for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:15:02 -0400 Received: from mail-wm1-f43.google.com ([209.85.128.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHjt-0008BE-2O for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:15:00 -0400 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4a180fbeef5so18462275e9.1 for ; Mon, 12 Oct 2026 08:14:56 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1a1feb78csm88245365e9.0.2026.10.12.08.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:14:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818096; x=1792422896; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=xjPmksDx32sBE3I0U0f2mMmY0tOvAwSTdWeiZF0OcZw=; b=LedYGPUAJCkyCM1gRSmzl+C6tr+W2v5NLIw0ENCgmSuZtEO9F+HpkDnQlB6VQodg7B GlyJ2y7uvtFmJchxXJuLBkIzuHUvQoL2pQaxt2ydfZpAHzX1OKqreiavViWzH4Y1zces JEHkGrojUpPRCg1fzHeMbehy1sWa9Ve43ZEq4L3vVhzQME+eyWvSTQi+6HRwWSuVDMeb 1kjIbjyBUIXfEUSmSWnM2JqQj0B2yr2bwoyrJ4+Oo5p7iiBi/qPzcUNWKuU4Q40WzwLK 08R29DEeTBeDvwkOg4Ia7nYLcWchTy6QPSxRDACdSgDDWwJRBybx1CkZn1AHubYzvCyS /Zsg== X-Gm-Message-State: AFq9FYKuFVpIAj51evM1o0B/ljxeXGEbZZWeSt7gt0OrcJMgg0CqOjqo HEIYXqx7n58x7z2wN7Oxy42tDH4oEmaTgGgsLCRspyYIPB6I8nVl9/5zC49tWypc X-Gm-Gg: AYBFou3Ubk9c5gjwwP2c+IcyI2eG6jWfZMZxFrTU4HWvNudGvgy4WmEYzr9wuYIv66P EpcnobP9wTme+y02mBnRXwv6IXd7x/Gp9Mfn5TGEvmAs4RfTYELCdinsm+u96U4OBg0hYwZZk1P 6jw7SQy7od+Vsmb8O3B0Hc+zjWgpK+Jv32VMRaD+Lhd+1va38dyXPoQGw3NV01nW+9s8E9Vto4J Gqw+KjpPrz6fCccxTlnl5ZtZ7LKoWQ+0f6YaePrEElOopjRsbSeLC59tOT0fGuVvIAoiS0LFlOD j/Svx52WgxCuCQW198drmGm86xsFVEiz1f2ABen1XeER6u01lcELwMQwX+RtqDOUbZS9ogCpmVd ZF5q02XyEaYHYsKavJvN0YjENU1XmeDbu5GYIN9SVJug1s9T1MV9k/lV283zm5AGrkaQ6FMHBwL ifzSWsV8LoqLlOkrf+z2mfwTm3Wya3sUv2ext+KKMd4OtKw2LpkWkjSPbPlzBUQVDpNwAen6W0w ibZ7ow1F8pOSWNYQ8jjibZG+yjsDTscqReqqu+U8DBTQZqpgLYJCDcR X-Received: by 2002:a05:600c:8b51:b0:49f:d6f0:6f24 with SMTP id 5b1f17b1804b1-4a18e443b3fmr186393375e9.2.1791818095438; Mon, 12 Oct 2026 08:14:55 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:15 +0200 Subject: [PATCH v2 22/50] hw/rtc: ds1338: add DS1339 variant MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-22-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=13372; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=xoWhr5Wtvx2t0SPDX34IEK+W+ImMd1a8R+3tANP1tIE=; b=4WCb3FyCPzvR5vENM5Hoo9TNk4uoeGRuJC2f31+VI4GeTGpw1gwUswDXbsc4uU3KIoLagG840 MRyDLjfCf4XBsfD/tC3xKRMVIEK6nEfrxTt6MK+zWB83k8s871MMmZB X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.43; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f43.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818167023158500 The Dallas/Maxim DS1339 register map is only partially compatible with the DS1338: it shares the clock/calendar time registers but differs elsewhere. It has no general-purpose NVRAM, moves the control register, and relocates the oscillator-stop flag. Add a 'ds1339' variant, modelling the EOSC oscillator stop, the OSF/A2F/A1F status register and the century bit. The alarm, square-wave and trickle-charger functions are not modelled. A migrated register pointer is now range-checked; it used to index the register array unvalidated. Signed-off-by: Emmanuel Blot --- hw/rtc/ds1338.c | 180 ++++++++++++++++++++++++++++++++++++++++++++= ---- include/hw/rtc/ds1338.h | 3 +- 2 files changed, 168 insertions(+), 15 deletions(-) diff --git a/hw/rtc/ds1338.c b/hw/rtc/ds1338.c index 21deb94689..63a049292e 100644 --- a/hw/rtc/ds1338.c +++ b/hw/rtc/ds1338.c @@ -1,5 +1,5 @@ /* - * MAXIM DS1338 I2C RTC+NVRAM + * MAXIM DS1338/DS1339 I2C RTC+NVRAM * * Copyright (c) 2009 CodeSourcery. * Written by Paul Brook @@ -10,6 +10,13 @@ * GNU GPL, version 2 or (at your option) any later version. * * Limitations: + * - The DS1339 alarm registers, the alarm-enable control bits, the A1F/A2F + * status flags and the trickle charger are stored but never evaluated: = no + * alarm matching is performed, no flag is ever set by hardware and no + * charging happens. + * - The INT#/SQW output pin is not exposed: neither alarm interrupts nor + * square-wave generation are produced. No board wires this pin and the = guest + * does not use the RTC wakealarm here. * - Writing the seconds register does not reset the internal countdown ch= ain, * so the sub-second phase of the clock is not modelled. * - The user registers are refreshed on a START and on a read that wraps = the @@ -47,6 +54,23 @@ /* POR: OUT, OSF, SQWE and both rate-select bits come up set. */ #define DS1338_CTRL_RESET 0xb3 =20 +/* Sentinel register address meaning "this variant has no such register". = */ +#define DS1338_NO_REG 0xff + +/* DS1339 register map: 0x00..0x10 only, no general-purpose NVRAM */ +#define DS1339_NUM_REGS 0x11 /* 0x00..0x10, then wraps */ +#define DS1339_CONTROL 0x0e +#define DS1339_CTRL_MASK 0xbf /* bit 6 is reserved, reads back z= ero */ +#define DS1339_CTRL_EOSC 0x80 /* EOSC: 1 stops the oscillator */ +#define DS1339_CTRL_RESET 0x18 /* POR: RS2=3DRS1=3D1 (32 kHz), re= st zero */ +#define DS1339_MONTH_CENTURY 0x80 /* Century is bit 7 of the month r= eg */ +#define DS1339_STATUS 0x0f +#define DS1339_STATUS_OSF 0x80 /* OSF is bit 7 of the status reg = */ +/* Status bits that exist (OSF | A2F | A1F); bits 6..2 are reserved, read = 0. */ +#define DS1339_STATUS_MASK 0x83 +/* All three status flags are hardware-set and clear-only (write 0). */ +#define DS1339_STATUS_W0 0x83 + OBJECT_DECLARE_TYPE(DS1338State, DS1338Class, DS1338) =20 struct DS1338State { @@ -58,6 +82,7 @@ struct DS1338State { int32_t ptr; bool addr_byte; bool osc_stopped; /* oscillator halted: time is frozen */ + uint8_t prev_century; /* century index (tm_year/100) at last capture = */ bool persist_on_reset; /* keep the registers across a reset */ }; =20 @@ -69,24 +94,70 @@ struct DS1338Class { uint8_t ctrl_mask; /* writable/read-back bits of the control reg = */ uint8_t osf_addr; /* register holding the OSF flag */ uint8_t osf_mask; /* OSF bit within osf_addr */ + uint8_t status_addr; /* status register address */ + uint8_t status_mask; /* bits that exist; reserved bits read 0 */ + uint8_t status_w0_mask; /* flags that can only be cleared */ uint8_t ctrl_reset; /* control-register power-on value */ + uint8_t status_reset; /* status-register power-on value */ + uint8_t eosc_mask; /* oscillator-disable bit in the control reg */ + uint8_t century_mask; /* Century bit in the month register */ uint8_t ch_mask; /* Clock-halt bit in the seconds reg */ }; =20 +static int ds1338_post_load(void *opaque, int version_id) +{ + DS1338State *s =3D opaque; + DS1338Class *k =3D DS1338_GET_CLASS(s); + + /* Both accessors index nvram[] with ptr before incrementing it. */ + if (s->ptr < 0 || s->ptr >=3D k->num_regs) { + return -EINVAL; + } + + /* + * prev_century did not exist before version 3, so an older incoming s= tream + * leaves it zero. + */ + if (version_id < 3) { + struct tm now; + + qemu_get_timedate(&now, s->offset); + s->prev_century =3D now.tm_year / 100; + } + return 0; +} + +static const VMStateField vmstate_ds1338_fields[] =3D { + VMSTATE_I2C_SLAVE(parent_obj, DS1338State), + VMSTATE_INT64(offset, DS1338State), + VMSTATE_UINT8_V(wday_offset, DS1338State, 2), + VMSTATE_UINT8_ARRAY(nvram, DS1338State, NVRAM_SIZE), + VMSTATE_INT32(ptr, DS1338State), + VMSTATE_BOOL(addr_byte, DS1338State), + VMSTATE_BOOL_V(osc_stopped, DS1338State, 3), + VMSTATE_UINT8_V(prev_century, DS1338State, 3), + VMSTATE_END_OF_LIST() +}; + static const VMStateDescription vmstate_ds1338 =3D { .name =3D "ds1338", .version_id =3D 3, .minimum_version_id =3D 1, - .fields =3D (const VMStateField[]) { - VMSTATE_I2C_SLAVE(parent_obj, DS1338State), - VMSTATE_INT64(offset, DS1338State), - VMSTATE_UINT8_V(wday_offset, DS1338State, 2), - VMSTATE_UINT8_ARRAY(nvram, DS1338State, NVRAM_SIZE), - VMSTATE_INT32(ptr, DS1338State), - VMSTATE_BOOL(addr_byte, DS1338State), - VMSTATE_BOOL_V(osc_stopped, DS1338State, 3), - VMSTATE_END_OF_LIST() - } + .post_load =3D ds1338_post_load, + .fields =3D vmstate_ds1338_fields, +}; + +/* + * The DS1339 reuses the DS1338 migration field list, so it migrates the f= ull + * NVRAM_SIZE-byte nvram[] array even though it only implements registers + * 0x00..0x10. + */ +static const VMStateDescription vmstate_ds1339 =3D { + .name =3D "ds1339", + .version_id =3D 3, + .minimum_version_id =3D 3, + .post_load =3D ds1338_post_load, + .fields =3D vmstate_ds1338_fields, }; =20 /* Reconstruct a struct tm from the BCD time registers in nvram. */ @@ -109,7 +180,7 @@ static void ds1338_time_from_regs(DS1338State *s, struc= t tm *now) } now->tm_mday =3D from_bcd(s->nvram[4] & 0x3f); now->tm_mon =3D from_bcd(s->nvram[5] & 0x1f) - 1; - now->tm_year =3D from_bcd(s->nvram[6]) + 100; + now->tm_year =3D s->prev_century * 100 + from_bcd(s->nvram[6]); } =20 static void ds1338_resync_from_regs(DS1338State *s) @@ -129,13 +200,22 @@ static void ds1338_capture_current_time(DS1338State *= s) /* Capture the current time into the secondary registers * which will be actually read by the data transfer operation. */ + DS1338Class *k =3D DS1338_GET_CLASS(s); struct tm now; + uint8_t century; =20 if (s->osc_stopped) { return; } =20 qemu_get_timedate(&now, s->offset); + + century =3D now.tm_year / 100; + if (k->century_mask && ((century ^ s->prev_century) & 1)) { + s->nvram[5] ^=3D k->century_mask; + } + s->prev_century =3D century; + s->nvram[0] =3D to_bcd(now.tm_sec); s->nvram[1] =3D to_bcd(now.tm_min); if (s->nvram[2] & HOURS_12) { @@ -153,7 +233,7 @@ static void ds1338_capture_current_time(DS1338State *s) } s->nvram[3] =3D (now.tm_wday + s->wday_offset) % 7 + 1; s->nvram[4] =3D to_bcd(now.tm_mday); - s->nvram[5] =3D to_bcd(now.tm_mon + 1); + s->nvram[5] =3D to_bcd(now.tm_mon + 1) | (s->nvram[5] & k->century_mas= k); s->nvram[6] =3D to_bcd(now.tm_year % 100); } =20 @@ -204,6 +284,16 @@ static uint8_t ds1338_recv(I2CSlave *i2c) return res; } =20 +/* OSF is raised by hardware whenever the oscillator stops. */ +static void ds1338_raise_osf(DS1338State *s) +{ + DS1338Class *k =3D DS1338_GET_CLASS(s); + + if (k->osf_addr !=3D DS1338_NO_REG) { + s->nvram[k->osf_addr] |=3D k->osf_mask; + } +} + static int ds1338_send(I2CSlave *i2c, uint8_t data) { DS1338State *s =3D DS1338(i2c); @@ -234,12 +324,14 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) if (k->ch_mask) { halt =3D data & k->ch_mask; } + } else if (s->ptr =3D=3D 5) { + mask |=3D k->century_mask; } =20 if (halt && !s->osc_stopped) { /* CH set: freeze the counters before the register is stored. = */ ds1338_capture_current_time(s); - s->nvram[k->osf_addr] |=3D k->osf_mask; + ds1338_raise_osf(s); } s->nvram[s->ptr] =3D data & mask; s->osc_stopped =3D halt; @@ -250,6 +342,19 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) if (s->ptr =3D=3D k->ctrl_addr) { /* Control register: reserved bits read back as zero. */ data &=3D k->ctrl_mask; + if (k->eosc_mask) { + bool now_stop =3D data & k->eosc_mask; + bool was_stop =3D s->nvram[k->ctrl_addr] & k->eosc_mask; + if (now_stop && !was_stop) { + ds1338_capture_current_time(s); + s->osc_stopped =3D true; + ds1338_raise_osf(s); + } else if (!now_stop && was_stop) { + /* EOSC cleared: resume counting from the frozen time.= */ + ds1338_resync_from_regs(s); + s->osc_stopped =3D false; + } + } } if (s->ptr =3D=3D k->osf_addr) { /* @@ -259,6 +364,13 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) data =3D (data & ~k->osf_mask) | (data & s->nvram[s->ptr] & k->osf_mask); } + if (s->ptr =3D=3D k->status_addr) { + /* Reserved bits read zero; flags are clear-only, OSF included= . */ + uint8_t cur =3D s->nvram[s->ptr]; + data &=3D k->status_mask; + data =3D (data & ~k->status_w0_mask) | + (data & cur & k->status_w0_mask); + } s->nvram[s->ptr] =3D data; } ds1338_inc_regptr(s); @@ -268,13 +380,19 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data) static void ds1338_power_on(DS1338State *s) { DS1338Class *k =3D DS1338_GET_CLASS(s); + struct tm now; =20 /* The clock is running and synchronized with the host */ s->offset =3D 0; s->wday_offset =3D 0; memset(s->nvram, 0, NVRAM_SIZE); s->nvram[k->ctrl_addr] =3D k->ctrl_reset; + if (k->status_addr !=3D DS1338_NO_REG) { + s->nvram[k->status_addr] =3D k->status_reset; + } s->osc_stopped =3D false; + qemu_get_timedate(&now, 0); + s->prev_century =3D now.tm_year / 100; } =20 static void ds1338_realize(DeviceState *dev, Error **errp) @@ -318,10 +436,39 @@ static void ds1338_class_init(ObjectClass *klass, con= st void *data) dsc->ctrl_mask =3D DS1338_CTRL_MASK; dsc->osf_addr =3D DS1338_CONTROL; dsc->osf_mask =3D CTRL_OSF; + dsc->status_addr =3D DS1338_NO_REG; /* the DS1338 has no status regi= ster */ + dsc->status_mask =3D 0; + dsc->status_w0_mask =3D 0; dsc->ctrl_reset =3D DS1338_CTRL_RESET; + dsc->status_reset =3D 0; + dsc->eosc_mask =3D 0; + dsc->century_mask =3D 0; dsc->ch_mask =3D SECONDS_CH; } =20 +static void ds1339_class_init(ObjectClass *klass, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + DS1338Class *dsc =3D DS1338_CLASS(klass); + + dc->desc =3D "DS1339 I2C serial real-time clock"; + dc->vmsd =3D &vmstate_ds1339; + + dsc->num_regs =3D DS1339_NUM_REGS; + dsc->ctrl_addr =3D DS1339_CONTROL; + dsc->ctrl_mask =3D DS1339_CTRL_MASK; + dsc->osf_addr =3D DS1339_STATUS; /* OSF lives in the status regist= er */ + dsc->osf_mask =3D DS1339_STATUS_OSF; + dsc->status_addr =3D DS1339_STATUS; + dsc->status_mask =3D DS1339_STATUS_MASK; + dsc->status_w0_mask =3D DS1339_STATUS_W0; + dsc->ctrl_reset =3D DS1339_CTRL_RESET; + dsc->status_reset =3D DS1339_STATUS_OSF; /* OSF set at power-on */ + dsc->eosc_mask =3D DS1339_CTRL_EOSC; + dsc->century_mask =3D DS1339_MONTH_CENTURY; + dsc->ch_mask =3D 0; /* bit 7 of the seconds register reads back zero= */ +} + static const TypeInfo ds1338_types[] =3D { { .name =3D TYPE_DS1338, @@ -330,6 +477,11 @@ static const TypeInfo ds1338_types[] =3D { .class_size =3D sizeof(DS1338Class), .class_init =3D ds1338_class_init, }, + { + .name =3D TYPE_DS1339, + .parent =3D TYPE_DS1338, + .class_init =3D ds1339_class_init, + }, }; =20 DEFINE_TYPES(ds1338_types) diff --git a/include/hw/rtc/ds1338.h b/include/hw/rtc/ds1338.h index f4cfe6a8e7..fff04c225d 100644 --- a/include/hw/rtc/ds1338.h +++ b/include/hw/rtc/ds1338.h @@ -1,5 +1,5 @@ /* - * MAXIM DS1338 I2C RTC+NVRAM + * MAXIM DS1338/DS1339 I2C RTC+NVRAM * * Copyright (c) 2009 CodeSourcery. * Written by Paul Brook @@ -16,5 +16,6 @@ #define HW_RTC_DS1338_H =20 #define TYPE_DS1338 "ds1338" +#define TYPE_DS1339 "ds1339" =20 #endif --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818193; cv=none; d=zohomail.com; s=zohoarc; b=j2Ylcd7PLpocxM5aGwKYhfaRWExu3uy5fzaJVGq5eSMOLDmGE+H0k5jnkszRMMZL9KVWuQfI8tA5fVXnlT+n2L7YfF3pwlzq23gMJ/yOR+oaMMzYlF6zV8iiBwcMu0CCk2TFARoB99xIbRv1QrJ9MRwG9oeXbyJsFQCsHTydY1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818193; 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:Sender:Subject:Subject:To:To:Message-Id; bh=hXF/Uyp0IqUhL1rx9an+YyWuRquSX9DskObYxu27U/A=; b=JuXrjigDtqD8to0wYLom7ee+nbwzjLa/52M4G0jrfl5HJiAmVU9sAQbgVASJ3nhXDuz9c6b4mWZi1ntFkPr3n30thkvw7fIqlZ9JR5XxVqm7wGJHNy9BsyBsxA0GPJkOu8tI1IbrVx4zpkyWkT6xYw5EifByd88IiiJYJT3kxmg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179181819354775.29947187612129; Mon, 12 Oct 2026 08:16:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHlH-0003mn-6F; Mon, 12 Oct 2026 11:16:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHl0-0003bL-PT for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:16:12 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHkt-0008Uh-AF for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:16:03 -0400 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-48af27fe287so1741321f8f.0 for ; Mon, 12 Oct 2026 08:15:58 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0aaaad1sm9541f8f.17.2026.10.12.08.15.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:15:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818158; x=1792422958; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hXF/Uyp0IqUhL1rx9an+YyWuRquSX9DskObYxu27U/A=; b=pZ+Wuc+SPtzEp+TpWb0U8u1XYtImhaca2Xql8yyAl5ifhOr50xwsAVimyssE1Ngbx3 7xRllmR9rW1j2rc88IExDlBljpw6LeGkUoaQjv1e0onAqT46mGP7dIrx0xJ1odMKqW1O FdwkQ8MWpjLPy78sxEaxtuxugW6VHbaHrCrzu1gS7u+ysV/zhH22THwcacDKaqcgd1zA bEAEnNRGOnS7HVN1R5VWkVyK8yoWRmFoW444Tt9ALw2YxlOnRfSAfwmkhz90GgMCuZQE 93o54HDss2Wd9YUYB18m0dYWRZJV9jrfk1lUJaWr6Vrx9oEn7EOulvvESCeIAGXOLVZI n1fg== X-Gm-Message-State: AFq9FYKUNwciIzvRXMhqT4th3heZCJ1qGF3bUSRcVuBruSWSCHZPG7Od uPSsZBE+xve2rTWSWrzvLp9aJle4HT9Kmb6oBCbFVGjULOs3tI5ELaMd5WQEgj6f X-Gm-Gg: AYBFou3RoCPGROw2RSLANI/a7iOAcWNYvKdiBR532dhRbqb18eUjsQt1eZVp3yd1Ukg 6I0WdmFOAu8ZlNhyW/LECNzxjQ9jKu1+X3tQMvdP79/WdvZuPkdLCkcjs8RnrbzADrAA2VDzl4e Q559mRYSPPUcYd3LwyXI0YF3OUGzgucV2ETFPYE3H+C3XEgx2+R65sLDJtehVvhQ5nQCwE5PsH8 5Y932suVfvvgDs1PprVxP4NsciFmxG1bR4qriRZZS+RUzXbkUmRuRNrcqlsaJmExxoHYxFLxl99 X6Q8X7+IYtxpN1sbTASNrfCai/d6c/hA0WOpa7CsFT/YhVYMILykv+jhdYCXIgQ0RzOBDQu/1+e pKQAExLc6aPN9dufqGlO6RvU1b2J1bzjhzwLmCo0q1dxwWy0xgwB28Veaa0iNyoUab+dI5QyI8I C+BuGvzXoWmxacm9xDsaofPAGr0dCW/a2EubzeuKc4F+1voFofR29tiRaYHiVZYBCo2dKYnsXz8 s+xydL5SAJvj/uw4LN0KLpNSRrEwyX+Yz+CBCebJMhcbA== X-Received: by 2002:a5d:6084:0:b0:488:8525:4979 with SMTP id ffacd0b85a97d-48dbacdb462mr14942243f8f.45.1791818157642; Mon, 12 Oct 2026 08:15:57 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:16 +0200 Subject: [PATCH v2 23/50] tests/qtest: ds1339: add RTC test MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-23-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=7120; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=3fFqJMbI+w2Mg/c2PcpO40N3CXUqXKnFcNeMq9t8SbQ=; b=6t130iCePXBh6J4cRIyZZ9rCE1CNs/1qc64NRzus65WZ8pJb3AHEQPZsMwhVfrqYyUXPmtMZy 0qpsD/GcGmVBNIeXasdSddzm+BRfrnE56Ha6nOMc1XAJaY/a1tAnIrt X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.41; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f41.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818195112158501 The variant had no test of its own. Cover its register map, the write-protection of the oscillator-stop flag, and the wrap of the register pointer at the end of the map. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1339-test.c | 166 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qtest/meson.build | 1 + 2 files changed, 167 insertions(+) diff --git a/tests/qtest/ds1339-test.c b/tests/qtest/ds1339-test.c new file mode 100644 index 0000000000..08fc16acda --- /dev/null +++ b/tests/qtest/ds1339-test.c @@ -0,0 +1,166 @@ +/* + * QTest testcase for the DS1339 RTC + * + * Copyright (c) 2026 Meta Platforms, Inc. and affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/bcd.h" +#include "libqos/i2c.h" + +#define DS1339_ADDR 0x68 + +/* DS1339 register map */ +#define DS1339_SECONDS 0x00 +#define DS1339_MONTH 0x05 +#define DS1339_YEAR 0x06 +#define DS1339_ALARM1 0x07 +#define DS1339_ALARM2 0x0b +#define DS1339_CONTROL 0x0e +#define DS1339_STATUS 0x0f +#define DS1339_TRICKLE 0x10 +#define DS1339_NUM_REGS 0x11 + +#define DS1339_STATUS_OSF 0x80 + +/* The clock and calendar come up on the host time. */ +static void test_time(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + uint8_t resp[7]; + time_t now =3D time(NULL); + struct tm *tm_ptr =3D gmtime(&now); + + i2c_read_block(i2cdev, DS1339_SECONDS, resp, sizeof(resp)); + + g_assert_cmpuint(from_bcd(resp[4]), =3D=3D, tm_ptr->tm_mday); + g_assert_cmpuint(from_bcd(resp[5]), =3D=3D, 1 + tm_ptr->tm_mon); + g_assert_cmpuint(2000 + from_bcd(resp[6]), =3D=3D, 1900 + tm_ptr->tm_y= ear); +} + +/* Writable control bits round-trip; the reserved one reads back zero. */ +static void test_control_register(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + i2c_set8(i2cdev, DS1339_CONTROL, 0x1c); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_CONTROL), =3D=3D, 0x1c); + + i2c_set8(i2cdev, DS1339_CONTROL, 0xff); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_CONTROL), =3D=3D, 0xbf); + + i2c_set8(i2cdev, DS1339_CONTROL, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_CONTROL), =3D=3D, 0x00); +} + +/* The oscillator-stop flag can only be cleared by a write, never set. */ +static void test_osf_write_protect(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS) & DS1339_STATUS_OSF, + =3D=3D, DS1339_STATUS_OSF); + i2c_set8(i2cdev, DS1339_STATUS, DS1339_STATUS_OSF); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS) & DS1339_STATUS_OSF, + =3D=3D, DS1339_STATUS_OSF); + + i2c_set8(i2cdev, DS1339_STATUS, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS) & DS1339_STATUS_OSF, = =3D=3D, 0); + i2c_set8(i2cdev, DS1339_STATUS, DS1339_STATUS_OSF); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS) & DS1339_STATUS_OSF, = =3D=3D, 0); +} + +/* The register pointer wraps at the end of the map. */ +static void test_address_wrap(void *obj, void *data, QGuestAllocator *allo= c) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + i2c_set8(i2cdev, DS1339_CONTROL, 0x2a); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_CONTROL + DS1339_NUM_REGS), + =3D=3D, 0x2a); +} + +/* A block transfer off the end of the map carries on from the start. */ +static void test_block_wrap(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + /* The alarm 2 block, then on into the time registers once it wraps. */ + const uint8_t out[11] =3D { + 0x0b, 0x0c, 0x0d, /* alarm 2 */ + 0x18, /* control */ + 0x00, /* status */ + 0xa5, /* trickle charger */ + 0x30, 0x20, 0x10, 0x05, 0x12, /* 10:20:30, day 5, the 12th */ + }; + uint8_t resp[11]; + + /* A month and year the wrapping write never reaches. */ + i2c_set8(i2cdev, DS1339_MONTH, 0x07); + i2c_set8(i2cdev, DS1339_YEAR, 0x31); + + i2c_write_block(i2cdev, DS1339_ALARM2, out, sizeof(out)); + + i2c_read_block(i2cdev, DS1339_SECONDS, resp, 7); + g_assert_cmphex(resp[2], =3D=3D, 0x10); + g_assert_cmphex(resp[3], =3D=3D, 0x05); + g_assert_cmphex(resp[4], =3D=3D, 0x12); + g_assert_cmphex(resp[5] & 0x1f, =3D=3D, 0x07); + g_assert_cmphex(resp[6], =3D=3D, 0x31); + + i2c_read_block(i2cdev, DS1339_ALARM2, resp, sizeof(resp)); + g_assert_cmphex(resp[0], =3D=3D, 0x0b); + g_assert_cmphex(resp[1], =3D=3D, 0x0c); + g_assert_cmphex(resp[2], =3D=3D, 0x0d); + g_assert_cmphex(resp[3], =3D=3D, 0x18); + g_assert_cmphex(resp[4], =3D=3D, 0x00); + g_assert_cmphex(resp[5], =3D=3D, 0xa5); + g_assert_cmphex(resp[8], =3D=3D, 0x10); + g_assert_cmphex(resp[9], =3D=3D, 0x05); + g_assert_cmphex(resp[10], =3D=3D, 0x12); +} + +/* The alarm and trickle registers are stored but never evaluated. */ +static void test_alarm_registers(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + static const uint8_t regs[] =3D { + DS1339_ALARM1, 0x08, 0x09, 0x0a, /* alarm 1 */ + DS1339_ALARM2, 0x0c, 0x0d, /* alarm 2 */ + DS1339_TRICKLE, + }; + static const uint8_t vals[] =3D { 0xff, 0x00, 0x5a, 0xa5 }; + unsigned reg, val; + + for (reg =3D 0; reg < ARRAY_SIZE(regs); reg++) { + for (val =3D 0; val < ARRAY_SIZE(vals); val++) { + i2c_set8(i2cdev, regs[reg], vals[val]); + g_assert_cmphex(i2c_get8(i2cdev, regs[reg]), =3D=3D, vals[val]= ); + } + } +} + +static void ds1339_register_nodes(void) +{ + QOSGraphEdgeOptions opts =3D { + .extra_device_opts =3D "address=3D0x68" + }; + add_qi2c_address(&opts, &(QI2CAddress) { DS1339_ADDR }); + + qos_node_create_driver("ds1339", i2c_device_create); + qos_node_consumes("ds1339", "i2c-bus", &opts); + + qos_add_test("time", "ds1339", test_time, NULL); + qos_add_test("control-register", "ds1339", test_control_register, NULL= ); + qos_add_test("osf-write-protect", "ds1339", test_osf_write_protect, NU= LL); + qos_add_test("address-wrap", "ds1339", test_address_wrap, NULL); + qos_add_test("block-wrap", "ds1339", test_block_wrap, NULL); + qos_add_test("alarm-registers", "ds1339", test_alarm_registers, + NULL); +} + +libqos_init(ds1339_register_nodes); diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index e05d8a07b9..e23eb9bbca 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -326,6 +326,7 @@ qos_test_ss.add( 'adm1272-test.c', 'adm1266-test.c', 'ds1338-test.c', + 'ds1339-test.c', 'e1000-test.c', 'eepro100-test.c', 'es1370-test.c', --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818297; cv=none; d=zohomail.com; s=zohoarc; b=hV/3IJ0t/yrS6sWTsAcgb9v7o8hVIiLbJxJiH5Qa9gIt61y22vUjIYlTEdUDDcBAS5aIhaOSPLjyv50KSfAr0KgbCcA8Av3qXuIQA2gRHCMxWvlrJ0xeg29JeRimmYj4ANSnO7rnzrpdLZ6wEF3iAccgvJvkCMDO7I5PySML+jA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818297; 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:Sender:Subject:Subject:To:To:Message-Id; bh=T0UIfa5fY9UvW53K8vxfMmiR1L171Gz3N0KwneftI8Y=; b=nxscdR951ceuI1dmc6SWHn769nqV9otxiEz9ZCfnmDH0GhYDM3sCMN1eWBmOR2hfVxA6H2yEeSuFVCdiH55IStAJMIP73AzKQdECMv0gquphpkqbOcZRSzfkR48rZyMPLNZRUOo8cVfMmn2AaNiPPGQdkpLHzt3PsZ5uymeNatc= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791818297438527.1108571978452; Mon, 12 Oct 2026 08:18:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHmw-0004TQ-Dz; Mon, 12 Oct 2026 11:18:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHlv-00047N-HU for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:17:05 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHls-00009S-KR for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:17:03 -0400 Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-48c4d870d54so1176829f8f.2 for ; Mon, 12 Oct 2026 08:17:00 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0ab506bsm8143f8f.27.2026.10.12.08.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:16:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818219; x=1792423019; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=T0UIfa5fY9UvW53K8vxfMmiR1L171Gz3N0KwneftI8Y=; b=LKX0xfd27W+lovVC292aLa95Xp4txX5bf/AHxmv3/X0ZoO1NVx1zmoXsXRDSGy0p8u RhafPcl+VMt0oJIY9nM2n0pWcycyboOsrABJjWokfY+NP8pbjzHU0zF2MdFEJAjbE8Dr fPcYz+Cg7UkIyEO0oqQj6Vm3rpL3hrnK/sXdKOADnSHqFFiHE7wxnucGcfHoKjWBbJlC /31oqlikzn+2pndOgwfcC9bUT6AkzsqAyCu8f9iyW7+YGiYLGqaZXFTZre7LKRCbwFF/ YLX0L4lnD92hj8/GGF/+07qOhFe7NrD2qXFAfZxcoaeOOl4bWgSlZR8nvdqZoX9E5azD 3sWg== X-Gm-Message-State: AFq9FYL0wwiqQHmfMXy2QGfj4mrKSlUU7IhgOcUaxEeWI0eRdT2mp/tn 6VS0hiTtAm7zPxZWGQpy9on61Pvrjplf5aQcKkuPVOhIOyJuqvjE04uQQ/4nmv/L X-Gm-Gg: AYBFou1ERpFSA5qQP1DBKHnd0kGMx8zZAGb/0BFxVc4IqoISmgWSjVopT3oxwreO6XE n+Tt4wS62ZB6xnNJIl1+aEXbyOyancsDUozNqwhuD/k8iU6aA60399D4xs5qjAAh+gtVI7astSJ LUtlJV6ghTpqNbO6JohI5Eg7X27r+vzWsWdiBFbuBgj/cojIr/JRO9UJJCADsVj6JxKJNBNbS0W BBB1DJaiNyT8HO253LkiYhWn0kXBvOLdgWcIbiz9Mc3La9XxuDABMvG5xhT9KE0l+RMKNUnvEHd pdg/LjlqKvziVN9RVSp1cXLcfjhh3fpEZDAxw5ktKUMMDZGrBJRsclSx0c3OhSvJvOd7mrpPxR5 UqLV5Ggehw2G7WG849jl3G8+Jp+5cRsigRigwH9TN2e/n3DJpIg89pxN37gYGNew/pXOxalpPRT 9aWBcFDBmOs164pmYLo1GGxIjD2lvQe9r5xFbyDo7hJYFgvmaibbWDBkRQ7s0DfMXdg/C0wyTSU xK7vS7Ma+FAaR+WziORUV7AE5PDqp/BC38KCRpXOJOo5VRorLhJIR357A== X-Received: by 2002:a05:6000:1290:b0:488:83f7:633a with SMTP id ffacd0b85a97d-48dbaaf0096mr12446491f8f.28.1791818218859; Mon, 12 Oct 2026 08:16:58 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:17 +0200 Subject: [PATCH v2 24/50] tests/qtest: ds1339: cover power-on defaults and reserved-bit masking MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-24-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=3426; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=g7DB+ARtVObCPTzzGVKyyO/c/Gk+v4O2cZLGywD17yk=; b=0+cnuysTYuhHUOyMTWnyYC3FsFUHKhO6Pbmrq+BoOdgYjrFpu2za3VffpGMlzdFCDTjxVI3yQ zgrZLlPbxKjDknRoNhoPcgMLYp4Kixv2luYuNQoQW4ZMqEKRJTpf6Nf X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.42; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f42.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818298854158500 Neither the power-on defaults nor the reserved bits of the register file were pinned. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1339-test.c | 51 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 51 insertions(+) diff --git a/tests/qtest/ds1339-test.c b/tests/qtest/ds1339-test.c index 08fc16acda..e9dcdc36da 100644 --- a/tests/qtest/ds1339-test.c +++ b/tests/qtest/ds1339-test.c @@ -74,6 +74,53 @@ static void test_osf_write_protect(void *obj, void *data, g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS) & DS1339_STATUS_OSF, = =3D=3D, 0); } =20 +/* The control and status registers come up in their power-on state. */ +static void test_reset_defaults(void *obj, void *data, QGuestAllocator *al= loc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + g_assert_cmphex(i2c_get8(i2cdev, DS1339_CONTROL), =3D=3D, 0x18); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS) & DS1339_STATUS_OSF, + =3D=3D, DS1339_STATUS_OSF); +} + +/* Neither the reserved status bits nor the alarm flags are guest-writable= . */ +static void test_status_register(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + i2c_set8(i2cdev, DS1339_STATUS, 0x7c); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS), =3D=3D, 0x00); + + i2c_set8(i2cdev, DS1339_STATUS, 0x03); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS), =3D=3D, 0x00); + + i2c_set8(i2cdev, DS1339_STATUS, 0xff); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS), =3D=3D, 0x00); +} + +/* Reserved time-register bits read back zero even with the clock stopped.= */ +static void test_stopped_reserved_bits(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + const uint8_t all_ones[7] =3D { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x= ff }; + uint8_t resp[7]; + + i2c_set8(i2cdev, DS1339_CONTROL, 0x18 | 0x80); + i2c_write_block(i2cdev, DS1339_SECONDS, all_ones, sizeof(all_ones)); + + i2c_read_block(i2cdev, DS1339_SECONDS, resp, sizeof(resp)); + g_assert_cmphex(resp[0], =3D=3D, 0x7f); + g_assert_cmphex(resp[1], =3D=3D, 0x7f); + g_assert_cmphex(resp[2], =3D=3D, 0x7f); + g_assert_cmphex(resp[3], =3D=3D, 0x07); + g_assert_cmphex(resp[4], =3D=3D, 0x3f); + g_assert_cmphex(resp[5], =3D=3D, 0x9f); + g_assert_cmphex(resp[6], =3D=3D, 0xff); +} + /* The register pointer wraps at the end of the map. */ static void test_address_wrap(void *obj, void *data, QGuestAllocator *allo= c) { @@ -155,8 +202,12 @@ static void ds1339_register_nodes(void) qos_node_consumes("ds1339", "i2c-bus", &opts); =20 qos_add_test("time", "ds1339", test_time, NULL); + qos_add_test("reset-defaults", "ds1339", test_reset_defaults, NULL); qos_add_test("control-register", "ds1339", test_control_register, NULL= ); + qos_add_test("status-register", "ds1339", test_status_register, NULL); qos_add_test("osf-write-protect", "ds1339", test_osf_write_protect, NU= LL); + qos_add_test("stopped-reserved-bits", "ds1339", + test_stopped_reserved_bits, NULL); qos_add_test("address-wrap", "ds1339", test_address_wrap, NULL); qos_add_test("block-wrap", "ds1339", test_block_wrap, NULL); qos_add_test("alarm-registers", "ds1339", test_alarm_registers, --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818349; cv=none; d=zohomail.com; s=zohoarc; b=BZ8CJI2w1AlC0bnysUug7MORrF0ZWqhkMulU3kMwbeFWbtMpeGw5Iq+dftaOXCYd43BzMX9nVkGGRdgxRIiW3yCYBcDf+QVnXk9eZGDdF8q4iGuRPvALwSFnHca5RwRlDSm7oRUlwb8dT2eS2s08QhNUxfYDS1qEKl3Oc4GkxtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818349; 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:Sender:Subject:Subject:To:To:Message-Id; bh=9Z7GCM1tL+WVU4df/9TtqoR10rm4Dif9ExOLVyo6FeE=; b=UEhZyY6gJFHZGtMls+KV0Zdnk90+l4tEr7GFXQgEseizKE+1yyGADG+DKlDU2A8cdJN7A5xeh8ZP4WSUGbXoZ8GeTDdyBV+nHR3Qk3NK1EEOH/1GuZjlNY32Av1lwI6w7NSLrCxQpfz4CkQ4wfsqnpkUZkK9Tp91xbCF1KjKqrs= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791818349667770.7420358025988; Mon, 12 Oct 2026 08:19:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHnU-0004qY-CZ; Mon, 12 Oct 2026 11:18:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHmt-0004Vh-Hl for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:18:06 -0400 Received: from mail-wm1-f41.google.com ([209.85.128.41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHmr-0000GT-VY for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:18:03 -0400 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4a172eb31f0so14810915e9.1 for ; Mon, 12 Oct 2026 08:18:01 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18c198134sm295148385e9.15.2026.10.12.08.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:17:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818280; x=1792423080; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9Z7GCM1tL+WVU4df/9TtqoR10rm4Dif9ExOLVyo6FeE=; b=PFRIeW7V2F8fRYAjxb2w7zrasDqLLZ/E2TG+8xD5MFwsd2fpJ0uuknOg0CoMUU4ud0 6lkRzPNn3tYLMF4fgc5OvFDVYogt788XzymC9mcwvLWOGo/dAuHWdFGZooZcAUV2wrlY rO9XIjzuA61Vt090Pr+06PwjtNCUnvSLTpv97Cp38J3sZhZdZz6c7c7DpcnIsRXloBmQ cZApl7Gsgcsth3zaTD9PfeSFtQEOpCwHIQO24GmTkisCnJNhTVBu8ulrjPoIiK/LYTa5 o74iHeeC9IOkwYTBhU21KQ2Bego6+BKTeBHT6kwpJwu2T6BqPWkqnvDhc7snTZwmeBAI WwHQ== X-Gm-Message-State: AFq9FYLzCQis7QtiVIX6ILwRI6VSpiN7lM3B4oK6dNE0o48eVmyCKOCL n0utfaav49wrHoaosQpauIhlemX+bITbyLWAigQ01V6BTFOJyjbG3gcQCScflAlc X-Gm-Gg: AYBFou22MUCekcrJV/WZy+vS3X9vjay+n878R0T8sUXqWnsFjQYn2pPWJt5GSqYZjgj 5JxuxQEAGh3AeSQHrHF6SFsoLtoQioGgzMmZ9lWhEaKt5L719MkMMiSp/j+zLElnsDWtbeVYyjs 8DYG1vl8Uja9nXBn7Lh2L9mO5AbfmHv6sgtUaRZ2ks5GRZUI+LKlVQ7UZ+T2Hy65GEHEVJZiTpK llL/D3IGDFBm3P77isPqd4tl/3e9ExeyA0Moy07hw8XKIQdKVUr6epdXQX45PiuwWz5kqoUKEGF hOj8SDDJ5p3DmZGwoIZbyy2h6WIN9FONrAHY7cCEGjDEL73xJvEY9JukB5X2N3jsLbAoPeRKWz1 TPWvVfW343xiOUmNVmkiPQVs3D/Q6Vszp90xZCPpIopHMFiTxjQ0wim1lVku2si0Ju7kYY/B0mA mzywmvQqkEfNUCGFTxs8ffy8FMrPPt77mDN09Td5oCcYej3TlqUzwRny+aRDIoBqSt/7UdhOvZR wKyzr8Qdi4KcNAthDCK9HtrMhO1vMtqibweUYWT3r0RtA== X-Received: by 2002:a05:600c:1908:b0:49f:ce73:5e94 with SMTP id 5b1f17b1804b1-4a18e4dd018mr188370435e9.34.1791818279914; Mon, 12 Oct 2026 08:17:59 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:18 +0200 Subject: [PATCH v2 25/50] tests/qtest: ds1339: cover oscillator stop/restart and time programming MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-25-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815520; l=3342; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=esijdRHOnlyhX21Z9j9OPDDssjLY1EB+c0uBQYJ2KSk=; b=MOw9N0s++3yN+hGM84UByGLThnpwrDptXO0NVpuP8imLKb9i9JGfkbB2+yFmtD/IakBybU0eD x/zpIsCjoc1AESXcxuUaKya2XFIs8q9A2Gt+kM8DgPDo/b2aoGY9uf4 X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.41; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f41.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818351736158500 Stopping and restarting the oscillator had no coverage, nor did the time the clock resumes from. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1339-test.c | 50 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 50 insertions(+) diff --git a/tests/qtest/ds1339-test.c b/tests/qtest/ds1339-test.c index e9dcdc36da..ac19ebd71d 100644 --- a/tests/qtest/ds1339-test.c +++ b/tests/qtest/ds1339-test.c @@ -121,6 +121,54 @@ static void test_stopped_reserved_bits(void *obj, void= *data, g_assert_cmphex(resp[6], =3D=3D, 0xff); } =20 +/* Setting EOSC stops the oscillator and sets OSF; OSF outlives the restar= t. */ +static void test_eosc(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + i2c_set8(i2cdev, DS1339_STATUS, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS) & DS1339_STATUS_OSF, = =3D=3D, 0); + + i2c_set8(i2cdev, DS1339_CONTROL, 0x18 | 0x80); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS) & DS1339_STATUS_OSF, + =3D=3D, DS1339_STATUS_OSF); + + i2c_set8(i2cdev, DS1339_CONTROL, 0x18); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS) & DS1339_STATUS_OSF, + =3D=3D, DS1339_STATUS_OSF); + i2c_set8(i2cdev, DS1339_STATUS, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS) & DS1339_STATUS_OSF, = =3D=3D, 0); +} + +/* A stopped clock resumes from the time it was programmed with. */ +static void test_eosc_restart(void *obj, void *data, QGuestAllocator *allo= c) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + /* 10:20:30 on the 12th of July 2031, the day counter reading 2. */ + const uint8_t tod[7] =3D { 0x30, 0x20, 0x10, 0x02, 0x12, 0x07, 0x31 }; + uint8_t resp[7]; + unsigned idx; + + i2c_set8(i2cdev, DS1339_CONTROL, 0x18 | 0x80); + i2c_write_block(i2cdev, DS1339_SECONDS, tod, sizeof(tod)); + + i2c_read_block(i2cdev, DS1339_SECONDS, resp, sizeof(resp)); + g_assert_cmpmem(resp, sizeof(resp), tod, sizeof(tod)); + + i2c_set8(i2cdev, DS1339_CONTROL, 0x18); + /* The seconds counter steps within a second of the restart. */ + for (idx =3D 0; idx < 15 && i2c_get8(i2cdev, DS1339_SECONDS) =3D=3D 0x= 30; idx++) { + g_usleep(100 * 1000); + } + + i2c_read_block(i2cdev, DS1339_SECONDS, resp, sizeof(resp)); + g_assert_cmpuint(from_bcd(resp[0]), >, 30); + g_assert_cmphex(resp[2], =3D=3D, 0x10); + g_assert_cmphex(resp[4], =3D=3D, 0x12); + g_assert_cmphex(resp[5] & 0x1f, =3D=3D, 0x07); + g_assert_cmphex(resp[6], =3D=3D, 0x31); +} + /* The register pointer wraps at the end of the map. */ static void test_address_wrap(void *obj, void *data, QGuestAllocator *allo= c) { @@ -206,6 +254,8 @@ static void ds1339_register_nodes(void) qos_add_test("control-register", "ds1339", test_control_register, NULL= ); qos_add_test("status-register", "ds1339", test_status_register, NULL); qos_add_test("osf-write-protect", "ds1339", test_osf_write_protect, NU= LL); + qos_add_test("eosc", "ds1339", test_eosc, NULL); + qos_add_test("eosc-restart", "ds1339", test_eosc_restart, NULL); qos_add_test("stopped-reserved-bits", "ds1339", test_stopped_reserved_bits, NULL); qos_add_test("address-wrap", "ds1339", test_address_wrap, NULL); --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818362; cv=none; d=zohomail.com; s=zohoarc; b=AZ7uJ1BqCCPdu4PzlY8Mh5JMspLXBlgDog8QAopkUn/4lkKgZBbIPJ1zEIr1zywEbSvuWaBr/kb6ZV/b7HS7WzvQNj/FMmndfCgJqg0hln6DNjZnBp9WUIPwli3zyMgqIMyaKw2V2aE2RgO3HikFVKdf1Th37tOYd0V9VdWt7HA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818362; 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:Sender:Subject:Subject:To:To:Message-Id; bh=ofy5Q7w1hiOQ65qRkRFvKTBxqy4svZeHJL4ReaZKNBI=; b=EJko4Suc/EMppcCyLrEhQ9lUOLSwqxjyDOCLwFrYIM0ZT+KiCeA7fIuFmZUYULipyiJvyiCDgcw27RxOtE496bG14vl/bfDDcPJq5KVA+V29ltVj2DefgdaBvoZMMXR5IiVklZyMgPZy5i+5/pJBDk9pavhE8QCPZ2FoadSwwYg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791818362622473.25868346562834; Mon, 12 Oct 2026 08:19:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHnw-0005Qk-Mo; Mon, 12 Oct 2026 11:19:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHnt-0005KZ-IY for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:19:06 -0400 Received: from mail-wr1-f45.google.com ([209.85.221.45]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHnq-0000NX-KX for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:19:05 -0400 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-48b001cd92bso1146513f8f.2 for ; Mon, 12 Oct 2026 08:19:02 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0ab506bsm16935f8f.27.2026.10.12.08.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:19:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818341; x=1792423141; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ofy5Q7w1hiOQ65qRkRFvKTBxqy4svZeHJL4ReaZKNBI=; b=KDx9L3upN53oBOd9Phhk838CoHKgddfZ5N5ub5a73/CAukJFCu32QG0DLLkJ1ivuCO xbSnTXX1NUhRv4OFwkfUVhdIw9FEwt1eZi1+UYpcUtHnCd9zohcP6KCfp2nRCQuGrbBz JKXucYPAYJt23Hmw97BPjQ5OkXx7GmMKVFAvczMSQs7AJ7b3aJcLxS+pHZIoJerofMPk zOwZufWKRVXeGHPfD6aca8jjMtPCvatINOcXwf/U039C56AGPSqYeWsQyQn15x3PYnUP M/WU80l835A5jYwpV9BU3lTR/mOZSP1C7Wp0KSsGT9gwBXfFVB0cP2I0c/fGg6V9573N uFzg== X-Gm-Message-State: AFq9FYLB4J4w4RHVLRkIhBxgOgr5dy13IGMBCedn7V91KkGHLBfRd0JN 22Da/sRqGbxAvLzcEJGHRQ8sKQ5WzpbYhSUQJ9xbLogdkGt8fadcxmZKN24u8DG1 X-Gm-Gg: AYBFou1f3WamuxeHsL1Zi6alf1joAeds6byuNkmyOiNZg5oPYhleTQQerbRBI7yxxj5 1IF7h8i0VquHayAYlffGZfdWAG3Fj0FVj3/12qOXqKZLQWoBH05+QqgfxMYYu7eIYEjZIiYzaA7 KS1oKohO6e4pmF8mUhxXxj7GckDsHE5ehs36fpml/Qa4uhUZSItoG8rRqR3/L/69OA+ngxUx/kL /3UA6NbMzoBuTQhoOeS35q4j2HGWHcbATJkIUnr8L+GAuIvdwY1/a835+7G04VvLcDoBle4Ji2L 2BgxRZpfW15ergFiIbmGXmV7T/0yuibWV1875QrkcKzlgRPlI1w3Nex14QwKFY+MLL78hDrzvke zEv43JlMfandscMfD8kdCJ2GXAEuPKGLVwgCmYg8ku293pFOHI95EpvVOncoJAOCnqmc/acbigK Jw297UNItWT3p09fTeiJl15ePDp9D7NHdTWwQysnzXE/de/UrENj+R1OYWhSpPJEeJzQ7zzIeJr Fy2Np4HMu3n0677V5GfshQaxSqq3fV2GMRQ5LH6R1121pAyOwMhu+gt X-Received: by 2002:a05:6000:2503:b0:48c:7083:be67 with SMTP id ffacd0b85a97d-48dbace462emr15821467f8f.42.1791818341002; Mon, 12 Oct 2026 08:19:01 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:19 +0200 Subject: [PATCH v2 26/50] tests/qtest: ds1339: cover the Century bit MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-26-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=3686; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=/UwwOgMrezr7gWWbisIg/npwXf+K73UBVrdeGOhT6D4=; b=BMQjhHEhJM96Dydf3SrrUcv4UzlD0zhtGSM+sbAn/w5+eTtqpQE1J8XOpgW6cFgxMaHEFmQ/V hKJomWLyBSxDiS1A0mQMNmTe5AQIkm0Sfz/u8eDEQ3JzSPbNUEUbHQZ X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.45; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f45.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818364216158500 The Century bit had no coverage: neither its guest read/write behaviour, nor the rule that only an elapsed rollover toggles it. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1339-test.c | 60 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 60 insertions(+) diff --git a/tests/qtest/ds1339-test.c b/tests/qtest/ds1339-test.c index ac19ebd71d..8c144579e6 100644 --- a/tests/qtest/ds1339-test.c +++ b/tests/qtest/ds1339-test.c @@ -169,6 +169,62 @@ static void test_eosc_restart(void *obj, void *data, Q= GuestAllocator *alloc) g_assert_cmphex(resp[6], =3D=3D, 0x31); } =20 +/* The Century bit is guest-writable and survives an oscillator restart. */ +static void test_century_bit(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + i2c_set8(i2cdev, DS1339_MONTH, 0x86); /* Century | June */ + g_assert_cmphex(i2c_get8(i2cdev, DS1339_MONTH) & 0x80, =3D=3D, 0x80); + + i2c_set8(i2cdev, DS1339_CONTROL, 0x18 | 0x80); + i2c_set8(i2cdev, DS1339_CONTROL, 0x18); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_MONTH) & 0x80, =3D=3D, 0x80); + + i2c_set8(i2cdev, DS1339_MONTH, 0x06); /* June, century clear */ + g_assert_cmphex(i2c_get8(i2cdev, DS1339_MONTH) & 0x80, =3D=3D, 0x00); +} + +/* A guest write never toggles the Century bit. */ +static void test_century_write_no_toggle(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + i2c_set8(i2cdev, DS1339_MONTH, 0x86); + i2c_set8(i2cdev, DS1339_YEAR, 0x99); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_MONTH) & 0x80, =3D=3D, 0x80); + i2c_set8(i2cdev, DS1339_YEAR, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_MONTH) & 0x80, =3D=3D, 0x80); + + i2c_set8(i2cdev, DS1339_MONTH, 0x06); + i2c_set8(i2cdev, DS1339_YEAR, 0x99); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_MONTH) & 0x80, =3D=3D, 0x00); + i2c_set8(i2cdev, DS1339_YEAR, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_MONTH) & 0x80, =3D=3D, 0x00); +} + +/* A clock-driven year rollover from 99 to 00 toggles the Century bit. */ +static void test_century_rollover(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + const uint8_t tod[7] =3D { 0x59, 0x59, 0x23, 0x01, 0x31, 0x12, 0x99 }; + unsigned idx; + + i2c_write_block(i2cdev, DS1339_SECONDS, tod, sizeof(tod)); + + for (idx =3D 0; idx < 50; idx++) { + if (i2c_get8(i2cdev, DS1339_YEAR) =3D=3D 0x00) { + break; + } + g_usleep(100 * 1000); + } + + g_assert_cmphex(i2c_get8(i2cdev, DS1339_YEAR), =3D=3D, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_MONTH) & 0x80, =3D=3D, 0x80); +} + /* The register pointer wraps at the end of the map. */ static void test_address_wrap(void *obj, void *data, QGuestAllocator *allo= c) { @@ -258,6 +314,10 @@ static void ds1339_register_nodes(void) qos_add_test("eosc-restart", "ds1339", test_eosc_restart, NULL); qos_add_test("stopped-reserved-bits", "ds1339", test_stopped_reserved_bits, NULL); + qos_add_test("century-bit", "ds1339", test_century_bit, NULL); + qos_add_test("century-write-no-toggle", "ds1339", + test_century_write_no_toggle, NULL); + qos_add_test("century-rollover", "ds1339", test_century_rollover, NULL= ); qos_add_test("address-wrap", "ds1339", test_address_wrap, NULL); qos_add_test("block-wrap", "ds1339", test_block_wrap, NULL); qos_add_test("alarm-registers", "ds1339", test_alarm_registers, --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818430; cv=none; d=zohomail.com; s=zohoarc; b=AGcM7qYIoSxfwg93gtQT2ojxGFiY4u7U5o3A7xARwdZESm+fReR9cqiFITu02qgtpwn1b13cQqKFwWT8VRkxaP3UzTUdX8UNN6KX0qHJBdN20OhM20Jw3asjBf2NUkNfVxVSms4mDfuKbzmsxgGx5bjDQ2tzhHg4Yf+hHAjRSI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818430; 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:Sender:Subject:Subject:To:To:Message-Id; bh=zfzexpI+Sf5r0TVpd7delVcigz2TZ/5dYES5EEOvYCg=; b=PRpgwPTCAu3FIoq5Nrx11OjWsAQIG3kZ3inBfyb1n0ODbihy3JkC0swl24D43swXJM5N52itU4QfTDqWXfvBgGpyQ5tWNZf+qbCf+lIDmtinvvxsvIP//8TeR8aQxwb+sauAzyow6tnYVJAH9HRjEaV+gse5MlxsKRF0KgCIqUk= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791818430599975.3603570620553; Mon, 12 Oct 2026 08:20:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHot-0006YM-5M; Mon, 12 Oct 2026 11:20:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHor-0006Y3-Js for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:20:05 -0400 Received: from mail-wr1-f44.google.com ([209.85.221.44]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHop-0000Ub-Sv for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:20:05 -0400 Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-48b0584ad71so1086858f8f.0 for ; Mon, 12 Oct 2026 08:20:03 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0514ab1sm171427f8f.0.2026.10.12.08.20.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:20:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818402; x=1792423202; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=zfzexpI+Sf5r0TVpd7delVcigz2TZ/5dYES5EEOvYCg=; b=Kcp4SZuyhG6nnm7tHonr8aCnIBGUNHx1OhGFqw2PkRyd22hkGk5ySf9nZ9Ynp1lNyd i9JtwEs5hmDkfhUWNeIpIGO6VY/OdYwyyk4vOzjqmvkEDzHs19PjhIkdwd9uzyrO5mDJ ERZMTXYnwOtqXXESLHhZFh7LyvYBcwZ+1IZ2Oiy0CWxcEV+RvXI3lHrh43s3kQVZHhMs WxKUQuXQOVos40RCYT4qwRGUo55lAqbiBe2LYUjaq7nZ3hSBgXZ1wHSzD4/wvJfBBFKa mgmPqFOYYJCHaR4mOCAKSqLE91nsqpAOohhDgmGS0FozHRjcwNyl5PwwLxbH8U4y7Qi/ 9ZnA== X-Gm-Message-State: AFq9FYLU1QMkmE6F5rTj+bNCRuHlnO/x6g7aVO9CtjbEGr7uIUoCiiiT ccVWqYOF9EFDFJ6xTaePbwIQjX2kKxaKrl5ZHL7AAvK3LEPXK1sfI76l30+KobWT X-Gm-Gg: AYBFou0VTKEl6oqowY1pUi2BPjvugs4h1BOtzXvVOacqU5D7PAjfyYhqzixVJeKbUP7 y5gUcF5hgKN4gCksyQtKvbdI57E+lAVPEDexAJy/l4jd6Rqk5pAr4xpZW8HvQJyhXdO2N/Ys3S1 KTdxfveOSpJwhUAKHoCZXpqN5NQWyQalbIiE8Ldzzm9Ho1pnaXGVeJyrn2fSKSFv7QiOjkERFUw ZDVl4YakmDDzjYs/X7jsuB4FRzlRrVw4rmPbKOocdUjCtErL7GnpB1Sm4rtZDjwu4aJ54zP5SKl eqwutvEMz9rFh2oxnmplu2hyTnrv6Swsdb9wYzAmkdZGZffCPLuf1KGax66kE7YhUmThA6VJbLC ArfGqgAeHP/chX89PeX4rCDzkYP/fc+dDOvqE7uvKHfqWtLA7FIC+fEyOGydiuQ0Dp1rLL118ns J7udeVe68edbIbgr682EPIWqEBjAO/yDNgnQ3ToaQ4r9iVq3OqDuRoayc0rGX1N5CMJcN38hBJ6 od03ViNfb7FM5UEt2P6i0c+X8K2GHk5g/WxRwcOXGHeeQ== X-Received: by 2002:a05:6000:2905:b0:48b:1119:5756 with SMTP id ffacd0b85a97d-48dbaceab8fmr14473744f8f.17.1791818402274; Mon, 12 Oct 2026 08:20:02 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:20 +0200 Subject: [PATCH v2 27/50] tests/qtest: ds1339: cover the end-of-month rollover MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-27-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=3753; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=X7KAfuckHBZBi2zykYy65RlVdT/TDTky7m/n0BwbF7w=; b=nwYCQgJ5SfEK46aZJb/XOfwFTrra1+YZItemSS7wsljzlFE5XHwx4hgBbR7+4Io1qsruofT7n umf5bfvNsK8CB5k0bBZEOKSp7de+rUHEjgu4CscyW3VMPCGkJjvg9h3 X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.44; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f44.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818431057158500 The end-of-month rollover was untested, for any of the lengths the calendar gives a month. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1339-test.c | 60 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 60 insertions(+) diff --git a/tests/qtest/ds1339-test.c b/tests/qtest/ds1339-test.c index 8c144579e6..7eec163049 100644 --- a/tests/qtest/ds1339-test.c +++ b/tests/qtest/ds1339-test.c @@ -14,6 +14,7 @@ =20 /* DS1339 register map */ #define DS1339_SECONDS 0x00 +#define DS1339_DATE 0x04 #define DS1339_MONTH 0x05 #define DS1339_YEAR 0x06 #define DS1339_ALARM1 0x07 @@ -169,6 +170,61 @@ static void test_eosc_restart(void *obj, void *data, Q= GuestAllocator *alloc) g_assert_cmphex(resp[6], =3D=3D, 0x31); } =20 +/* Program 23:59:59 on the last day of a month and run the clock past it. = */ +static void check_month_rollover(QI2CDevice *i2cdev, + uint8_t date, uint8_t month, uint8_t year, + uint8_t next_date, uint8_t next_month, + uint8_t next_year) +{ + const uint8_t tod[7] =3D { 0x59, 0x59, 0x23, 0x01, date, month, year }; + uint8_t resp[7]; + unsigned idx; + + i2c_write_block(i2cdev, DS1339_SECONDS, tod, sizeof(tod)); + + for (idx =3D 0; idx < 50; idx++) { + if (i2c_get8(i2cdev, DS1339_DATE) !=3D date) { + break; + } + g_usleep(100 * 1000); + } + + i2c_read_block(i2cdev, DS1339_SECONDS, resp, sizeof(resp)); + g_assert_cmphex(resp[4], =3D=3D, next_date); + g_assert_cmphex(resp[5] & 0x1f, =3D=3D, next_month); + g_assert_cmphex(resp[6], =3D=3D, next_year); +} + +/* A 31-day month rolls over to the first of the next. */ +static void test_month_31_days(void *obj, void *data, QGuestAllocator *all= oc) +{ + check_month_rollover((QI2CDevice *)obj, + 0x31, 0x01, 0x23, 0x01, 0x02, 0x23); +} + +/* A 30-day month rolls over to the first of the next. */ +static void test_month_30_days(void *obj, void *data, QGuestAllocator *all= oc) +{ + check_month_rollover((QI2CDevice *)obj, + 0x30, 0x04, 0x23, 0x01, 0x05, 0x23); +} + +/* Outside a leap year, February rolls over after the 28th. */ +static void test_month_28_days(void *obj, void *data, QGuestAllocator *all= oc) +{ + check_month_rollover((QI2CDevice *)obj, + 0x28, 0x02, 0x23, 0x01, 0x03, 0x23); +} + +/* In a leap year the 28th is not the last day of February. */ +static void test_month_29_days(void *obj, void *data, QGuestAllocator *all= oc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + + check_month_rollover(i2cdev, 0x28, 0x02, 0x24, 0x29, 0x02, 0x24); + check_month_rollover(i2cdev, 0x29, 0x02, 0x24, 0x01, 0x03, 0x24); +} + /* The Century bit is guest-writable and survives an oscillator restart. */ static void test_century_bit(void *obj, void *data, QGuestAllocator *alloc) { @@ -314,6 +370,10 @@ static void ds1339_register_nodes(void) qos_add_test("eosc-restart", "ds1339", test_eosc_restart, NULL); qos_add_test("stopped-reserved-bits", "ds1339", test_stopped_reserved_bits, NULL); + qos_add_test("month-28-days", "ds1339", test_month_28_days, NULL); + qos_add_test("month-29-days", "ds1339", test_month_29_days, NULL); + qos_add_test("month-30-days", "ds1339", test_month_30_days, NULL); + qos_add_test("month-31-days", "ds1339", test_month_31_days, NULL); qos_add_test("century-bit", "ds1339", test_century_bit, NULL); qos_add_test("century-write-no-toggle", "ds1339", test_century_write_no_toggle, NULL); --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818524; cv=none; d=zohomail.com; s=zohoarc; b=RqvQmhTLb5AFBjjVIx3pHf4sNNvyWnVx2hcJA1AJtZbwR7M8ShfW1bTIOtg9H+KRIzayHgaBrZCTMWKl0/v9kT6/GStNytcOc7b1qD0NTP1W+kIiS4oIhOKniBOcZpj5XGJ/B8pET05fOGMZuJWKdFkGtzv1JzehATyldEmX4X8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818524; 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:Sender:Subject:Subject:To:To:Message-Id; bh=LphZT+IzejkArL3oUvhqeY3sCcOug01WUt4J0/5+FMM=; b=iiBgVqWaJH+QkSHZJW5SRaHCkw26VNWTMw6yqfxDUAaq614X1kAw7MP9Z1gS2EPgw2qMcM92obh8ngRpP6yoNvFfWQ9pPhpvDpQmMV5sUzSgYHUe5hee1Orazcp0BdVCVmhdy0dQVkS5oUjdnVRV4r+TwHnbKMXFbP8tTZHRNBY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791818524103171.41744356103948; Mon, 12 Oct 2026 08:22:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHqE-0007J2-9F; Mon, 12 Oct 2026 11:21:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHps-0007FI-UG for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:21:10 -0400 Received: from mail-wm1-f50.google.com ([209.85.128.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHpq-0000sS-3C for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:21:08 -0400 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4956869750eso15713205e9.2 for ; Mon, 12 Oct 2026 08:21:05 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0bd7729sm2280f8f.59.2026.10.12.08.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:21:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818464; x=1792423264; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=LphZT+IzejkArL3oUvhqeY3sCcOug01WUt4J0/5+FMM=; b=HSXaANDGK2vVUO8ayBlf1j+k0nNAiy4EBErma9lvNSDsJWXPVI9N5lNV4g60MkebvJ ytysLjII8cvCB3dc8+LbDt7as+8pBdK3RZLR1PPZ/RGIOLYI+uCJ86MZ1vmBmorP5/E6 vjcVhsrR8sY0vfXKfjmiMNNwyJTrc43Y/r/1UVn+iA5pRMdAamog7iFIVqnuB1/5NWzy vdmGpdjK219Xn9xBHZqTWy7V7JgdVFfMLRXt16/H8K4ReNEI0Q7wJSB75KXxwpCKV2mi dgUPLqtZ8zFger0l1h0vD1Ww0nvZBLY0iG2bhSwE4zJ48KXUBOMN2OSphnfG0BVgi7p4 yw9w== X-Gm-Message-State: AFq9FYKLWHWdfcoiLuTEpbM9H7Z4K7rYwf6L3yEDeaBa0e3KJ5v2RgYV weJ+HO1f/sOUKYMqPZYeWF9SvES/2acwGtzbi9g5QxzyeahbfGYFpANLzUP+KL8L X-Gm-Gg: AYBFou2R2/xzGAF8l4WTUPG22SoE7RzVZ61qyrrIn7PiYNHi/n5o3d46r7NpwW5GVoR jKUSO1guRE1mZnV3v9UBVqmNSdaVwxxnHk9zSB5Lq6TK8FmAuhjQXxf2LyE3uUW0Badf0MN0SZM 506OIV/ipn2geK/9vRdqQS7FKUhFiV6KMa1JxPZpd9WFPa3m2G48bZxvf54RsrNBJ7Dzfm025Fo 0/T2SOsKgjUYajM4pgY0Oe9ozGpx0HfKUVVpCDnzxmkZNz+bERZ9xzTAThpDNPVxECfNVXz+hql Hmtom7+nWISN7cMurYo6sUyXdHCyrdkThwAhb7fYItuu/XcVGEKYzHektK3HLtHBE4klkt52jo+ VgCoR+UUOrkYrM0Fa3Y6+XRaVmRakL6iO58uOdqvVOuKGBILcH4+9diwggKjrqq35XIwycASLmj wmLWUuF79+9wCuWEykyG+972ZkfAwzkle8aE9kLYYGWcKg9bcWIOi+fo1Ey+Ki94pwqB6x8/d/g WSFMfGDO/BXiDRF3IVnYXgftdFDgXuO7Gb2M8GJsG9tZ2TkCcZqYg9n X-Received: by 2002:a05:600c:310b:b0:4a1:813f:2a5b with SMTP id 5b1f17b1804b1-4a18e4a9da8mr176801105e9.14.1791818464129; Mon, 12 Oct 2026 08:21:04 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:21 +0200 Subject: [PATCH v2 28/50] tests/qtest: ds1339: cover the 12-hour format MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-28-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=3517; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=d52DOv2V3QB3CGvMZYkl6mYb22coBmAW9Fq+mpMglf8=; b=h+dYr85Mf424qKP5s6jFxgWLffK+UzbdywL5bCL+JDxQh7PvG57hYQ/moP/E9StF5ob7jaqbQ HNA6Ui/PPqeBc0itK0wsWifHQbbGX8FcZ3sw3xsDLC1vRd9zLT+FInx X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.50; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f50.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818525017158500 Both directions of the 12-hour conversion carry a fixup for midnight and noon, and neither had been exercised. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1339-test.c | 45 +++++++++++++++++++++++++++++++++++++++++++= ++ 1 file changed, 45 insertions(+) diff --git a/tests/qtest/ds1339-test.c b/tests/qtest/ds1339-test.c index 7eec163049..3259fa1df3 100644 --- a/tests/qtest/ds1339-test.c +++ b/tests/qtest/ds1339-test.c @@ -14,6 +14,7 @@ =20 /* DS1339 register map */ #define DS1339_SECONDS 0x00 +#define DS1339_HOURS 0x02 #define DS1339_DATE 0x04 #define DS1339_MONTH 0x05 #define DS1339_YEAR 0x06 @@ -26,6 +27,9 @@ =20 #define DS1339_STATUS_OSF 0x80 =20 +#define DS1339_HOURS_12 0x40 +#define DS1339_HOURS_PM 0x20 + /* The clock and calendar come up on the host time. */ static void test_time(void *obj, void *data, QGuestAllocator *alloc) { @@ -170,6 +174,46 @@ static void test_eosc_restart(void *obj, void *data, Q= GuestAllocator *alloc) g_assert_cmphex(resp[6], =3D=3D, 0x31); } =20 +/* Midnight and noon are the hours the 12-hour encoding special-cases. */ +static void test_hour_mode_12(void *obj, void *data, QGuestAllocator *allo= c) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + const uint8_t tod[3] =3D { + 0x59, 0x59, DS1339_HOURS_12 | DS1339_HOURS_PM | 0x11 /* 11:59:59 P= M */ + }; + unsigned idx; + + i2c_set8(i2cdev, DS1339_HOURS, DS1339_HOURS_12 | 0x12); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_HOURS), =3D=3D, + DS1339_HOURS_12 | 0x12); /* 12 AM is midnight= */ + + i2c_set8(i2cdev, DS1339_HOURS, DS1339_HOURS_12 | DS1339_HOURS_PM | 0x1= 2); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_HOURS), =3D=3D, + DS1339_HOURS_12 | DS1339_HOURS_PM | 0x12); /* 12 PM no= on */ + + i2c_set8(i2cdev, DS1339_HOURS, DS1339_HOURS_12 | DS1339_HOURS_PM | 0x0= 1); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_HOURS), =3D=3D, + DS1339_HOURS_12 | DS1339_HOURS_PM | 0x01); + + i2c_set8(i2cdev, DS1339_HOURS, DS1339_HOURS_12 | 0x11); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_HOURS), =3D=3D, + DS1339_HOURS_12 | 0x11); + + i2c_set8(i2cdev, DS1339_HOURS, 0x13); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_HOURS), =3D=3D, 0x13); + + /* An elapsed midnight moves 11 PM on to 12 AM, not to 00 or 13. */ + i2c_write_block(i2cdev, DS1339_SECONDS, tod, sizeof(tod)); + for (idx =3D 0; idx < 50; idx++) { + if (i2c_get8(i2cdev, DS1339_HOURS) !=3D tod[2]) { + break; + } + g_usleep(100 * 1000); + } + g_assert_cmphex(i2c_get8(i2cdev, DS1339_HOURS), =3D=3D, + DS1339_HOURS_12 | 0x12); +} + /* Program 23:59:59 on the last day of a month and run the clock past it. = */ static void check_month_rollover(QI2CDevice *i2cdev, uint8_t date, uint8_t month, uint8_t year, @@ -370,6 +414,7 @@ static void ds1339_register_nodes(void) qos_add_test("eosc-restart", "ds1339", test_eosc_restart, NULL); qos_add_test("stopped-reserved-bits", "ds1339", test_stopped_reserved_bits, NULL); + qos_add_test("hour-mode-12", "ds1339", test_hour_mode_12, NULL); qos_add_test("month-28-days", "ds1339", test_month_28_days, NULL); qos_add_test("month-29-days", "ds1339", test_month_29_days, NULL); qos_add_test("month-30-days", "ds1339", test_month_30_days, NULL); --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818563; cv=none; d=zohomail.com; s=zohoarc; b=kjMnWtWL4KbAXL6QL0+TbhxjArHOw+lYhYGEJoojszSp/PDeqrhBvtBpZjjyJuMXHzfKKWYovVjJhPXrjpNwL2zC76chYv6qsCvj5+FgSVwCLib0UlS+6B+sEsmTb2YJUelFS3d1cr8uoS8bUYYXcVDDNiTPOEsa3UhN47+TtkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818563; 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:Sender:Subject:Subject:To:To:Message-Id; bh=xDaZUroT2n8sJrtLzMe0uCr4D4Xox3szI0g/uL81yHs=; b=TkBfS4q8Luz25XhqW58LGBh7pxIO8ARVakBEf0Ip8hyMuGpynBHUf3uHb/89utS+LG1y/EyWhiqINrPjAfEVLXkUJ6cERuDNeilMznnIxInVNkLr34g0ta4ngQpQvt+AS3JyDVPLrtuYkqzlNPoUSUWM2BjY6oo1+HHv4LgD4K8= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179181856372862.424611052113505; Mon, 12 Oct 2026 08:22:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHr4-0007mc-2X; Mon, 12 Oct 2026 11:22:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHqs-0007hi-Nc for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:22:12 -0400 Received: from mail-wm1-f54.google.com ([209.85.128.54]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHqp-00010L-Qz for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:22:10 -0400 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4a021c809e3so19755725e9.0 for ; Mon, 12 Oct 2026 08:22:07 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0bc85b1sm8340f8f.54.2026.10.12.08.22.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:22:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818526; x=1792423326; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=xDaZUroT2n8sJrtLzMe0uCr4D4Xox3szI0g/uL81yHs=; b=oOm647623JerdlerBVYBZqrSeuNkwfJjXmk8ju+C1vfcjq1nS+hN1WCCfYfZLRiT7+ OQgniTkbibYZludH1AhZ5wrt+Qunpm+0VfcrgLTXvcSOwQl692Xu2IgpRbaz82edqunx KLcqK9c1LcQzvQLm5/Dw1NwyrsIhJnTb9H2+BHQdBFTCyTkZVh5prCjgZ8b4H3OuNVOP eX+IT0Bg29WqZRWQb5tnCemPzoj65GFE0JAqIBjhcLjRJCBub+3JRkRPJ65T3z+IUpP8 wyhTTv0FRqaN0bTttQk9eJiTyeY0sX6ayUrQpjKoZeWTEenNoNFMZPxzebP2Y/kgUNkb iRhw== X-Gm-Message-State: AFq9FYJo5jpdrSSGRJXbMESrXUV3X76zizrBmTf7tQwDj3Jdkf57+sqi YIdajrbVQs0u7K0+fXSH2YxrZpdvbnROAm029oYTJsjBNLOeWQlPStdwyeql9UdX X-Gm-Gg: AYBFou0lOY6kk25HV3wARntOSSY3QJzDrYcdoEMRBSoK5tUFqh7S+JGJjQnuulMFPAj bbYs0cP0FOYclHmCzQ1cbCjp6pd9dTjVC3nxbWgeXSaTTtWLUCJfiou73pbHknoEqVZd/tbEpJ3 80niK+5iuOOa7eyLB16D05Qyj4k5TOu+Czwr5PjadYfgZDLY/P9RcqUvAIIrqXatAqo0nCRIV9y lI/En083QADeEAbXiyjDfYJ60ROAUEWb8hZJAXSaR/TZ0Z20jC1iJ4E52wV1k5G1ocOnVAfalOx sUVH1oIBqSfK29VM4r4Si5YISphIhND6Lc0XNkHMSH2sCtsT+C5L0hZmGiY/I/lcw4tvB8GkTSA LGvYjsT7AlpgDuz60mwCNMXBuNU7oyfVU2XWpPoBTL3I9ZLcrEBAtQVxqBFlZ9c0aaKvs/NM5Z1 DYPU0FIx/5XV4njw5vWY7Va233RtFyLCJUkbjLyOviOzI0mNMs7RDzbuJwreWQUvToap97n08Kw z29E4vfqd1FCzxgpFqE+II68ZzXK+iYt9j4qxveS2uJag== X-Received: by 2002:a05:600c:8709:b0:4a0:20c7:6d4c with SMTP id 5b1f17b1804b1-4a18e3eccebmr193751195e9.0.1791818526154; Mon, 12 Oct 2026 08:22:06 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:22 +0200 Subject: [PATCH v2 29/50] tests/qtest: ds1339: cover the day-of-week counter MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-29-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=2630; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=K9HOm83SsQOK9R4XDnsjhxDGcTLTCjXMrgk6bTqgUo0=; b=becHwSrqJhCcJAcvCpfFfr3igfA+ZHnrM6SShPCihQ1wDv3AdB0mXZW/d11ZJMqrAuh/S/IOF XBHKs7RokgPDlhEPwCvo3TG/wgfxZxNBZYRJDCMcpGRTBDEwfIBm2Zc X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.54; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f54.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818565545158500 The day-of-week register and the offset behind it had no coverage at all. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1339-test.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/qtest/ds1339-test.c b/tests/qtest/ds1339-test.c index 3259fa1df3..12562eff5f 100644 --- a/tests/qtest/ds1339-test.c +++ b/tests/qtest/ds1339-test.c @@ -15,6 +15,7 @@ /* DS1339 register map */ #define DS1339_SECONDS 0x00 #define DS1339_HOURS 0x02 +#define DS1339_DAY 0x03 #define DS1339_DATE 0x04 #define DS1339_MONTH 0x05 #define DS1339_YEAR 0x06 @@ -174,6 +175,36 @@ static void test_eosc_restart(void *obj, void *data, Q= GuestAllocator *alloc) g_assert_cmphex(resp[6], =3D=3D, 0x31); } =20 +/* The day counter is the guest's own numbering, and steps at midnight. */ +static void test_day_of_week(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + /* 23:59:59 on 14 June 2024, the day counter reading 7. */ + const uint8_t tod[7] =3D { 0x59, 0x59, 0x23, 0x07, 0x14, 0x06, 0x24 }; + unsigned idx; + + for (idx =3D 1; idx <=3D 7; idx++) { + i2c_set8(i2cdev, DS1339_DAY, idx); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_DAY), =3D=3D, idx); + } + + i2c_set8(i2cdev, DS1339_DAY, 0x03); + i2c_set8(i2cdev, DS1339_DATE, 0x14); + i2c_set8(i2cdev, DS1339_MONTH, 0x06); + i2c_set8(i2cdev, DS1339_YEAR, 0x24); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_DAY), =3D=3D, 0x03); + + i2c_write_block(i2cdev, DS1339_SECONDS, tod, sizeof(tod)); + for (idx =3D 0; idx < 50; idx++) { + if (i2c_get8(i2cdev, DS1339_DAY) !=3D 0x07) { + break; + } + g_usleep(100 * 1000); + } + g_assert_cmphex(i2c_get8(i2cdev, DS1339_DAY), =3D=3D, 0x01); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_DATE), =3D=3D, 0x15); +} + /* Midnight and noon are the hours the 12-hour encoding special-cases. */ static void test_hour_mode_12(void *obj, void *data, QGuestAllocator *allo= c) { @@ -414,6 +445,7 @@ static void ds1339_register_nodes(void) qos_add_test("eosc-restart", "ds1339", test_eosc_restart, NULL); qos_add_test("stopped-reserved-bits", "ds1339", test_stopped_reserved_bits, NULL); + qos_add_test("day-of-week", "ds1339", test_day_of_week, NULL); qos_add_test("hour-mode-12", "ds1339", test_hour_mode_12, NULL); qos_add_test("month-28-days", "ds1339", test_month_28_days, NULL); qos_add_test("month-29-days", "ds1339", test_month_29_days, NULL); --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818618; cv=none; d=zohomail.com; s=zohoarc; b=AfMEAYwsZnPR6CXtdfaTzs28RUfI3Nn28B52l9J7r5ZCT+rK0vEFEOTCYCNI6EN+i9dyr/+syD1+1G+6qW31z/J+cqmLhYIPehRbRa+4rXWrnKciD7TdAmv/lbVPE9NUlt7u8trsfOVqmTo/H6/+L9jUWbAxyUJyfke9/UOLzYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818618; 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:Sender:Subject:Subject:To:To:Message-Id; bh=UwwxETLAztE1k6Pih+RsWxpK5u/uYELdrNm5CxCbYqw=; b=jQbZ4GMylkcnmZa1emWsfZDaWOV5LMAVh65DGQyhpw0udj2Ysa/1DTSWONEntP4T3/v9mCDk+ywMAL5/5z0OfkOJwP7sK/9jss9666G5kIqR+bfGR2bEuoJBONCqEil60/r0pPPT+5H/ypHAdBEkfuVbYqyati73sby6RcxqFKM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791818618460729.4524767716058; Mon, 12 Oct 2026 08:23:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHrt-0008VN-Q9; Mon, 12 Oct 2026 11:23:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHrr-0008UX-RQ for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:23:11 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHro-00019H-UX for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:23:11 -0400 Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-48c4be28b82so1952166f8f.2 for ; Mon, 12 Oct 2026 08:23:08 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0ab48a7sm31524f8f.24.2026.10.12.08.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:23:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818587; x=1792423387; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=UwwxETLAztE1k6Pih+RsWxpK5u/uYELdrNm5CxCbYqw=; b=sy9z1jvkFcmW+THnbWXG44MsYifWnyewm2NaC+Sc9MeuIRsIHy6VpdN/xmduRbP13W d+q+f6UVNrBQEBtkKJR++cDru6dFvUFA/NOBh8l2Qb55WicXeSY2dwSiboQBH5MW1CS8 54/brqQmNBi/fZnQIBYYGxE6h4IAyGO9NIBCLBueZ12pjoNFjNpRnjH1ONPIIbvuOeTn jZBLDS5PHzPxmjfOYmivbbXfIPAzHOSlU4wnt06cF/ktjP6IYL5cqf7TgNEyDsyBb9/V cUv5xq57K+Jf9dyZ0K3wx4TuD1PUlFviLenDDlCTm4eF0qi/i0/6L+m0HlxFoTUNiOxv uIWA== X-Gm-Message-State: AFq9FYLVA4VXmDpoCPYlL0bWA8kMBjWXiYY475YHavi7gT7/0VbILERw J04fefXAwO/cgiONh9dseew+BDkM2OILNcP+PHCd+wxbzom08gi1Nt4ZQ9hjzS5K X-Gm-Gg: AYBFou2OkCHp5jkVUR+Z6JYTHjq2IE/YWB3bxGo+rceOzeCl7ZZVuv+wXsy8V4/gJf9 2ApCn+zw/jKc3Fpj53ipKoSlCfrKl4kQJvLgXP336rf4HQrOCkf1xP+1VPBTFHXCBMc6I2V5fxw 9pLVemZFEG+PAcfJrbrrklj0NIJGZSEa8I7I2KR1QH9MU4zu8w+msn+jCulLnykkfI+y88xpJYE tAP/f4D0Cv7r2lA17VDPIIHZOw9VC8NdNdjxlVIsNX0147zXGn29eV1YB90ZKvMhBlFkL2gS3Zb zJS0NP2n2ndZe+EJbOosFc7Zo7x8kBT9ylpNLBURbRvMZlrPhF0ElsEGndVMvvVas9/QXhVBQSd /a8iHpwiFMIFOd2GUOOHeZfV95JlPmekL/oCigauPYLcEgLKffkpumsPvYAiKgbKw56T8MOP4Mf f6JhuqW4DGB1EntrC1ZJxz1wlWLHeIHKaGMIKoLcipQRGfIl1IQhtc7MGob2YmSc4hpxod/p4Pv ECk49+OycLarwcuAQTV8FJzwq9M774EQSFd156zSphHQQ== X-Received: by 2002:a05:6000:1ace:b0:48c:571a:a1aa with SMTP id ffacd0b85a97d-48dba9dacf6mr20300737f8f.19.1791818587322; Mon, 12 Oct 2026 08:23:07 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:23 +0200 Subject: [PATCH v2 30/50] tests/qtest: ds1339: cover persist-on-reset MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-30-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=3347; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=40jEbTSK65E3MsKCMaeknpjZMmqbQRo2Y3v73NUToek=; b=kcRzjDxjALOy3ssy8xfSwO6TSEFkSkA6pMvfUJLNuyInT+kHRJRipoqafXS6LlQlBb1JKQDoU Ej+9jnT/xftATiqrtNUOu2D0fgmTKgWMBuToQ3ywFhKXP9v7t3UAGig X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.53; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f53.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818620661158500 The property was untested on this variant. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1339-test.c | 56 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 56 insertions(+) diff --git a/tests/qtest/ds1339-test.c b/tests/qtest/ds1339-test.c index 12562eff5f..a1b5afb331 100644 --- a/tests/qtest/ds1339-test.c +++ b/tests/qtest/ds1339-test.c @@ -8,7 +8,10 @@ =20 #include "qemu/osdep.h" #include "qemu/bcd.h" +#include "libqtest.h" +#include "libqtest-single.h" #include "libqos/i2c.h" +#include "qobject/qdict.h" =20 #define DS1339_ADDR 0x68 =20 @@ -426,6 +429,52 @@ static void test_alarm_registers(void *obj, void *data, } } =20 +/* A reset restores the power-on state, unless persist-on-reset is set. */ +static void check_reset(QI2CDevice *i2cdev, bool persists) +{ + uint8_t year =3D i2c_get8(i2cdev, DS1339_YEAR); + /* A year the clock is not already showing, so the check discriminates= . */ + uint8_t marker =3D year =3D=3D 0x42 ? 0x77 : 0x42; + QDict *rsp; + + i2c_set8(i2cdev, DS1339_ALARM1, 0xa5); + i2c_set8(i2cdev, DS1339_STATUS, 0x00); + i2c_set8(i2cdev, DS1339_YEAR, marker); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_ALARM1), =3D=3D, 0xa5); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS), =3D=3D, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_YEAR), =3D=3D, marker); + + rsp =3D qmp("{ 'execute': 'system_reset' }"); + g_assert(qdict_haskey(rsp, "return")); + qobject_unref(rsp); + qmp_eventwait("RESET"); + + if (persists) { + g_assert_cmphex(i2c_get8(i2cdev, DS1339_ALARM1), =3D=3D, 0xa5); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS), =3D=3D, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_YEAR), =3D=3D, marker); + } else { + g_assert_cmphex(i2c_get8(i2cdev, DS1339_ALARM1), =3D=3D, 0x00); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_CONTROL), =3D=3D, 0x18); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS), =3D=3D, + DS1339_STATUS_OSF); + /* Back on host time, which is where the year came from. */ + g_assert_cmphex(i2c_get8(i2cdev, DS1339_YEAR), =3D=3D, year); + } +} + +/* Without persist-on-reset, a reset takes the part back to power-on. */ +static void test_reset_clears(void *obj, void *data, QGuestAllocator *allo= c) +{ + check_reset((QI2CDevice *)obj, false); +} + +/* With persist-on-reset, the registers and the clock survive a reset. */ +static void test_reset_persists(void *obj, void *data, QGuestAllocator *al= loc) +{ + check_reset((QI2CDevice *)obj, true); +} + static void ds1339_register_nodes(void) { QOSGraphEdgeOptions opts =3D { @@ -459,6 +508,13 @@ static void ds1339_register_nodes(void) qos_add_test("block-wrap", "ds1339", test_block_wrap, NULL); qos_add_test("alarm-registers", "ds1339", test_alarm_registers, NULL); + qos_add_test("reset-clears", "ds1339", test_reset_clears, NULL); + + opts.extra_device_opts =3D "address=3D0x68,persist-on-reset=3Don"; + qos_node_create_driver_named("ds1339-persist", "ds1339", i2c_device_cr= eate); + qos_node_consumes("ds1339-persist", "i2c-bus", &opts); + + qos_add_test("reset-persists", "ds1339-persist", test_reset_persists, = NULL); } =20 libqos_init(ds1339_register_nodes); --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818700; cv=none; d=zohomail.com; s=zohoarc; b=Vdw3KxQfPextiFA1sBsppXbkGBEBItM7fKLtelo1L+VLjCIchHOyrchdMm9TIl+eU2y4hZkllhYbsVw8/BbIeHrWuoZ1D+JZBJ7t0NT3WhX1TrgXQGFFNsvo0h1aM6chI/Og1PJEYXnvGHq/8S7DuBhaSm+mEgLPKihGhmAMs8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818700; 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:Sender:Subject:Subject:To:To:Message-Id; bh=RnkBBeLG1eQDE9P6Yi95zQOq3H0LATrNJD3fWP7niYw=; b=D7ybgAB7h8YXkJFpLlBUe68hsGDSkEfqbsvYABYocZezbghod7XFGY5hJB+d7DRuB0AdqUnjqaU2M2aCcZ30HyOtCW/oTPiypJeGlq4VpCY6zPhBZHQvi0WAKr5qZnKzzhFTFkW1OvTzVXt/I5dIDGLexShFcCHKCNv1mphq5fI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791818700813602.3034878407487; Mon, 12 Oct 2026 08:25:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHtL-00015C-Kp; Mon, 12 Oct 2026 11:24:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHsr-0000m1-1G for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:24:14 -0400 Received: from mail-wm1-f47.google.com ([209.85.128.47]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHso-0001G1-7M for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:24:12 -0400 Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4a0213948d3so12551015e9.2 for ; Mon, 12 Oct 2026 08:24:09 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0aaaa21sm53474f8f.9.2026.10.12.08.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:24:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818648; x=1792423448; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=RnkBBeLG1eQDE9P6Yi95zQOq3H0LATrNJD3fWP7niYw=; b=GK0Ac5O2WGS5r9jZhurpjbWedIaA93p/ei2Fa8x2BVv8bQaSVXmzJFxqp4OUMd38rg 4HVKs0CzEesf1uO4ZbCx0RHWZZ4cYy6eamauTDyhEowtL5BsL7cPwmcQTsGe8KpTM5So pLoaE41lr9iu5x9vRFLM0rJxp5pMuK4Wpq1VkPOe1/+xEd7ZicSlo+PoDSatdpmA4JO9 TURNfv83pQlnYgOxszNhwopRkl1llp67403u/OsAlVnOFhVfz9o+V2/FTUeterkNWaon n6Bep6odkP+BVbkDAaWZNYjX08D2Svl4L0NLiqXiQKw4kbNntlNua6bdPAJ84AvEoW2N AhmA== X-Gm-Message-State: AFq9FYLakMqGf6DiVfyXjUGEsTNML/iW8ztvj83iYDnrqweAGEi1oEe2 nSmK8Xz1tnXtRtjqIvnFSpursi5kAKJ106fCZ7lmiNZlqdbSdNC8R873kjsSIZj5 X-Gm-Gg: AYBFou1c1bwB+dj+qnGsJGKKKEU+oB8OmCexm0fr1YA8FC1QhX8P6M08A8IDrTG872R jmk5Tdgd3YHZGwdhs50oHdLD0KE2oSgrwvYXizyI9aTgDKH1ec6NSA5kQNcKkJnc9KzV6B6mC5a TibhrVKL3Aa5kWVTRA426CYxjSP+D2Pi4GapxTXnYCTapAOgLETRFuKKAxRWxRe5rg02cZ6xKMW cTEpBzK8JXUgb5yR06a7x3z1LtGGosI8o5iJfPfN4Ctpef6oaFzIecmei4ikDWzEGbfZsuPT3i9 +b7JRlHoIoJYWlX0hIq60VLoxRBR2G5eFls7u9Tq7bjwVJ1ue9yR80xiAuNGEqeZQRShIfeWgPc oFWUb14HjO5KGf5PFThxj1rkavFpRbsUZJsuOHvPLIXyRLWHPEA7Xj+3d76iNZax2UVyPKFFBTk 3idHpZsv6eDUfkE32YBzAOEriiyLeduQJT4OlNP0+6t2mRryoADpgeIJwMrcHjHKaYnspxZ+fl8 QmSTmwpnyLa4pNeZBmh3sPoDLU694itzoCpbvHAJIP5Cv9XXqLP0Emx X-Received: by 2002:a05:600c:6208:b0:4a1:698d:3042 with SMTP id 5b1f17b1804b1-4a18e493143mr173062925e9.6.1791818648485; Mon, 12 Oct 2026 08:24:08 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:24 +0200 Subject: [PATCH v2 31/50] tests/qtest: ds1339: cover the migration round trip MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-31-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=3500; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=BGMUGmamSzCjRMfmtfuZ7L1tiySTP5BVtx1tPB5MRVw=; b=09msNMADcOqJDOIGdmsta2N/yH18MGNxRjUF0Rff6cXAuxImRJDWpc+ttxrlwq0cXac8nE9A/ x+KIUMwNB1SCuIrVo6W/R1zh1b7PQV+KwrWm5YiswCcVGQTCCmz2yeE X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.47; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f47.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818702198158500 Nothing covered the migration of the register file or the oscillator state, so a dropped field or a wrong version gate would have gone unnoticed. Signed-off-by: Emmanuel Blot --- tests/qtest/ds1339-test.c | 61 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 61 insertions(+) diff --git a/tests/qtest/ds1339-test.c b/tests/qtest/ds1339-test.c index a1b5afb331..ca2378aa34 100644 --- a/tests/qtest/ds1339-test.c +++ b/tests/qtest/ds1339-test.c @@ -7,9 +7,13 @@ */ =20 #include "qemu/osdep.h" + +#include + #include "qemu/bcd.h" #include "libqtest.h" #include "libqtest-single.h" +#include "libqos/qgraph.h" #include "libqos/i2c.h" #include "qobject/qdict.h" =20 @@ -475,6 +479,62 @@ static void test_reset_persists(void *obj, void *data,= QGuestAllocator *alloc) check_reset((QI2CDevice *)obj, true); } =20 +/* The register file, the Century bit and a stopped clock all migrate. */ +static void test_migration(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + /* 23:59:59 on the last day of 2099, Century set. */ + const uint8_t tod[7] =3D { 0x59, 0x59, 0x23, 0x03, 0x31, 0x8c, 0x99 }; + g_autofree char *tmpfs =3D NULL; + g_autofree char *mig_path =3D NULL; + g_autofree char *uri =3D NULL; + GString *dest_cmdline; + GError *err =3D NULL; + QTestState *from, *to; + uint8_t resp[7]; + QDict *rsp; + + tmpfs =3D g_dir_make_tmp("ds1339-test-XXXXXX", &err); + g_assert_no_error(err); + g_assert(tmpfs); + + mig_path =3D g_strdup_printf("%s/socket.mig", tmpfs); + uri =3D g_strdup_printf("unix:%s", mig_path); + + /* Stop the clock first, so both sides have the same time to compare. = */ + i2c_set8(i2cdev, DS1339_CONTROL, 0x18 | 0x80); + i2c_write_block(i2cdev, DS1339_SECONDS, tod, sizeof(tod)); + i2c_set8(i2cdev, DS1339_ALARM1, 0xa5); + + dest_cmdline =3D g_string_new(qos_get_current_command_line()); + g_string_append_printf(dest_cmdline, " -incoming %s", uri); + to =3D qtest_init(dest_cmdline->str); + + rsp =3D qmp("{ 'execute': 'migrate', 'arguments': { 'uri': %s } }", ur= i); + g_assert(qdict_haskey(rsp, "return")); + qobject_unref(rsp); + + qmp_eventwait("STOP"); + qtest_qmp_eventwait(to, "RESUME"); + + from =3D i2cdev->bus->qts; + i2cdev->bus->qts =3D to; + + i2c_read_block(i2cdev, DS1339_SECONDS, resp, sizeof(resp)); + g_assert_cmpmem(resp, sizeof(resp), tod, sizeof(tod)); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_ALARM1), =3D=3D, 0xa5); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_CONTROL), =3D=3D, 0x18 | 0x80); + g_assert_cmphex(i2c_get8(i2cdev, DS1339_STATUS) & DS1339_STATUS_OSF, + =3D=3D, DS1339_STATUS_OSF); + + i2cdev->bus->qts =3D from; + + qtest_quit(to); + g_unlink(mig_path); + g_rmdir(tmpfs); + g_string_free(dest_cmdline, true); +} + static void ds1339_register_nodes(void) { QOSGraphEdgeOptions opts =3D { @@ -509,6 +569,7 @@ static void ds1339_register_nodes(void) qos_add_test("alarm-registers", "ds1339", test_alarm_registers, NULL); qos_add_test("reset-clears", "ds1339", test_reset_clears, NULL); + qos_add_test("migration", "ds1339", test_migration, NULL); =20 opts.extra_device_opts =3D "address=3D0x68,persist-on-reset=3Don"; qos_node_create_driver_named("ds1339-persist", "ds1339", i2c_device_cr= eate); --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818723; cv=none; d=zohomail.com; s=zohoarc; b=gj4xbjyJqmliqlapEbLEXDRLjsnh+8MeIEwh5zV8WoexKhxOl1STUB7sllrLxN/Zzm3LN8/B0gcdstY8P0BvzV0dIEUdUdJAA+cdYGbrS0Jua4SZqWfzXkp6IicKcELu9eXUty2cD12iyVTDa2+KcWTI0sYbcTsqLPg3jYm90O4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818723; 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:Sender:Subject:Subject:To:To:Message-Id; bh=Ag9641mffFjfdRUhsMi2t2u0YfaeWNL/TR54cDC5J1U=; b=GEoVzCzcjRRUTYgfvsrkYPZ27xCtk1sdbruvZayDT6FZuR8SBguQryWuuFr0TXU0qyi5bi+AnEd/qgWvl3NdwHC4IgUr+AbJywIhOfcYy0PGplbeHJ27/rf+frse8uOM9sqwc5DIAn/3Rvmu6z78Rqc5Qi7Vmi00FwkU4KBkU4M= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791818723333109.13195261347198; Mon, 12 Oct 2026 08:25:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHtu-0001ny-54; Mon, 12 Oct 2026 11:25:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHtr-0001hN-I8 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:25:15 -0400 Received: from mail-wr1-f46.google.com ([209.85.221.46]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHtn-0001Wv-PA for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:25:15 -0400 Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-48870973bddso1225028f8f.1 for ; Mon, 12 Oct 2026 08:25:11 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0bd1843sm19188f8f.56.2026.10.12.08.25.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:25:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818710; x=1792423510; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Ag9641mffFjfdRUhsMi2t2u0YfaeWNL/TR54cDC5J1U=; b=BE6cEK2hk/jkod4sET0fl+hbWqTZunBE2UlmlEjPKlvfbTlYKDFV9u452mPUx/L5dd VWkjNyTDeuuWBBO8fHdEo5M9IXhP72/kBXs4fvko3m8bCO4+gMwbtFE8KOWQU3Lkda4C v4DFhdtlrom6NuNZaUjOWOr7JiFQgTiCiWKbmWpLyEPJ5iMEcVUoSrx8d+MPiGBNqVio mP2OWBjBNq4sBZEX2ue5YV0eaqi/Xyg5ttMBsWzPUpfPJUVJIqlY00HM7fdXxUweXnS0 NnyPkuKZgEdOOluFi/BM6GGYxI1+4Cw1uyN2zkeQ24I+3uSLC/viq30YxUfXTgRibt71 3yvA== X-Gm-Message-State: AFq9FYKrAvQ2An11DnUKBWTy6YeJeZ3OU4wwet2WUCqTy4J490LI98Mo sp5wU/uJKHaYkoCcxj7Zl0q57oq5haELK8tuyU9bApVv5iD1+MrthKeg19hX87MM X-Gm-Gg: AYBFou17k6VoSRo3hQuDNQSls/gssu7f9i4Sl06b4aj47Ri7LMqLfL8PDraj6gUy3aP rtBUW65Rt04vdWwuQv2E3h/pYTb6K7GDBeTuYrobtF7cdhNs1+iqCH2wuXd4b5huFqUzgdh5HgT MLMaNla2LohTOn0eZZSZiE3ymwS7xVE4wO1g4zU/8dOfvMX/yFRj91IfjLehmymozOPbZequABD RH8AmDxaRV+6j9oW/tFlwsog2v+V8MoWtUrryHZudvNmtwgmcT62DTEKgtK+ogrylSuq4EmDzdk 69wGpKtf8yrmUhz+wiK6SC1ScuJu88o787joJYv0myYrgg6Fn4dzA/52NpP7M6ea6XCqdUcqAAF MlKrRhV7UKn0moNTWDPyO7uJcbG9HZR4eMcF5ug8m2rWIm0kcITDxCN5VDgBeygIVoRdLJyolGU qAsBN9dYzUJqmAJr8/x1gFojLRXTgwpnGJu8y8eMe48eMzJcDjf9mf44ChBfK/LczDJ1Sh3C+lt /qm8yGzXipxUz40nJqhKsX8NPAzR5a1Mc0XbdoqjZVFiQ== X-Received: by 2002:a05:6000:4287:b0:48c:77ae:c39a with SMTP id ffacd0b85a97d-48db9475d10mr25985293f8f.15.1791818709847; Mon, 12 Oct 2026 08:25:09 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:25 +0200 Subject: [PATCH v2 32/50] hw/sensor: ina230: add current/voltage/power monitor MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-32-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=23168; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=bF3WLBzrzmPzCcecz4KA3X149jCVfk95RJ82tLiZwCQ=; b=FatiGTNpW7gs6E7wBs1btkfVnRvvUZ/GTTyYLtE5m7LFF1dbR36WpQDBQ5X3ZUiNg0KuCqhU+ m40KtbYXM0yB+OU19rkEvmCYbxDXYCXMij2ppV+zYGvbYI6Qlhc5+4T X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.46; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f46.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818724655158500 Add a model for the Texas Instruments INA230, a 36V, 16-bit I2C current-shunt and power monitor. The device measures a differential shunt voltage and a bus voltage; the current and power registers are not measured directly but derived by the device from the shunt voltage and the guest-programmed Calibration register. The alert is modelled. Shunt and bus voltages can be injected through the "shunt-voltage" and "bus-voltage" QOM properties (in nV and uV respectively). Note: Conversion is instantaneous: the averaging and conversion-time fields are stored but have no timing effect. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- hw/arm/Kconfig | 1 + hw/sensor/Kconfig | 4 + hw/sensor/ina230.c | 597 +++++++++++++++++++++++++++++++++++++++++= ++++ hw/sensor/meson.build | 1 + hw/sensor/trace-events | 7 + include/hw/sensor/ina230.h | 14 ++ 6 files changed, 624 insertions(+) diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 4445f16f45..116d1c64ac 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -539,6 +539,7 @@ config ASPEED_SOC select TMP105 select TMP421 select EMC141X + select INA230 select OR_IRQ select UNIMP select LED diff --git a/hw/sensor/Kconfig b/hw/sensor/Kconfig index b459ac2240..da519159ac 100644 --- a/hw/sensor/Kconfig +++ b/hw/sensor/Kconfig @@ -2,6 +2,10 @@ config ADC128D818 bool depends on I2C =20 +config INA230 + bool + depends on I2C + config TMP105 bool depends on I2C diff --git a/hw/sensor/ina230.c b/hw/sensor/ina230.c new file mode 100644 index 0000000000..988d12a6c5 --- /dev/null +++ b/hw/sensor/ina230.c @@ -0,0 +1,597 @@ +/* + * Texas Instruments INA230 36V, 16-bit current/voltage/power monitor + * with an I2C interface. + * + * Copyright (c) 2026 Meta Platforms, Inc. and affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * The INA230 measures a differential shunt voltage and a bus voltage. + * Current and power are not measured directly: they are derived by the + * device from the measured shunt voltage. + * + * Limitations: + * - Conversion timing is instantaneous. A conversion runs synchronously w= hen an + * input, the calibration or the configuration changes; the per-channel + * conversion times (VSH_CT/VBUS_CT), the averaging count (AVG) and cont= inuous + * re-conversion on a timer are not modelled. A read always returns the = value + * derived from the current inputs and CVRF is set once a conversion has= run. + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qapi/error.h" +#include "qapi/visitor.h" +#include "qom/object.h" +#include "hw/sensor/ina230.h" +#include "hw/core/irq.h" +#include "hw/core/qdev-properties.h" +#include "hw/core/registerfields.h" +#include "hw/i2c/i2c.h" +#include "migration/vmstate.h" +#include "trace.h" + +#define INA230_REG_CONFIG 0x00 +#define INA230_REG_SHUNT 0x01 +#define INA230_REG_BUS 0x02 +#define INA230_REG_POWER 0x03 +#define INA230_REG_CURRENT 0x04 +#define INA230_REG_CALIBRATION 0x05 +#define INA230_REG_MASK_ENABLE 0x06 +#define INA230_REG_ALERT_LIMIT 0x07 +#define INA230_REG_DIE_ID 0xFF + +FIELD(INA230_CONFIG, MODE, 0, 3) +FIELD(INA230_CONFIG, VSH_CT, 3, 3) +FIELD(INA230_CONFIG, VBUS_CT, 6, 3) +FIELD(INA230_CONFIG, AVG, 9, 3) +FIELD(INA230_CONFIG, RST, 15, 1) + +#define INA230_CONFIG_POR 0x4127 + +FIELD(INA230_MASK_ENABLE, LEN, 0, 1) /* alert latch enable */ +FIELD(INA230_MASK_ENABLE, APOL, 1, 1) /* alert polarity */ +FIELD(INA230_MASK_ENABLE, OVF, 2, 1) /* math overflow flag (status) */ +FIELD(INA230_MASK_ENABLE, CVRF, 3, 1) /* conversion ready flag (status) = */ +FIELD(INA230_MASK_ENABLE, AFF, 4, 1) /* alert function flag (status) */ +FIELD(INA230_MASK_ENABLE, CNVR, 10, 1) /* conversion ready alert */ +FIELD(INA230_MASK_ENABLE, POL, 11, 1) /* power over-limit */ +FIELD(INA230_MASK_ENABLE, BUL, 12, 1) /* bus under-limit */ +FIELD(INA230_MASK_ENABLE, BOL, 13, 1) /* bus over-limit */ +FIELD(INA230_MASK_ENABLE, SUL, 14, 1) /* shunt under-limit */ +FIELD(INA230_MASK_ENABLE, SOL, 15, 1) /* shunt over-limit */ + +/* Writable Mask/Enable bits: alert-function selects + APOL + LEN */ +#define INA230_ME_WMASK (R_INA230_MASK_ENABLE_SOL_MASK | \ + R_INA230_MASK_ENABLE_SUL_MASK | \ + R_INA230_MASK_ENABLE_BOL_MASK | \ + R_INA230_MASK_ENABLE_BUL_MASK | \ + R_INA230_MASK_ENABLE_POL_MASK | \ + R_INA230_MASK_ENABLE_CNVR_MASK | \ + R_INA230_MASK_ENABLE_APOL_MASK | \ + R_INA230_MASK_ENABLE_LEN_MASK) +/* Read-only status bits: AFF, CVRF, OVF */ +#define INA230_ME_STATUS_MASK (R_INA230_MASK_ENABLE_AFF_MASK | \ + R_INA230_MASK_ENABLE_CVRF_MASK | \ + R_INA230_MASK_ENABLE_OVF_MASK) + +FIELD(INA230_CALIBRATION, FS, 0, 15) +#define INA230_CAL_MASK R_INA230_CALIBRATION_FS_MASK + +#define INA230_SHUNT_LSB_NV 2500 /* 2.5 uV per LSB */ +#define INA230_BUS_LSB_UV 1250 /* 1.25 mV per LSB */ +#define INA230_SHUNT_MIN_NV (-81920000) /* -32768 * 2.5 uV */ +#define INA230_SHUNT_MAX_NV 81917500 /* 32767 * 2.5 uV */ +/* + * A real rail should not drive the pin past 36 V, so bus codes above 0x70= 80 + * are intentionally unreachable in the model. + */ +#define INA230_BUS_MAX_UV 36000000 /* bus pin rated 0..36 V */ + +#define INA230_CURRENT_DIV 2048 +#define INA230_POWER_DIV 20000 + +#define INA230_DIE_ID_VAL 0x2310 + +OBJECT_DECLARE_SIMPLE_TYPE(INA230State, INA230) + +struct INA230State { + I2CSlave parent_obj; + + qemu_irq alert; /* ALERT open-drain output */ + + /* I2C transfer state */ + uint8_t ptr; /* register pointer */ + uint8_t len; /* bytes received in current transfer */ + uint8_t wr_hi; /* pending write MSB */ + uint8_t rx_byte; /* 0: return MSB next, 1: return LSB next */ + uint16_t rx_word; /* value latched at the start of a read */ + + /* Register file */ + uint16_t config; + uint16_t calibration; + uint16_t mask_enable; + uint16_t alert_limit; + + /* Derived measurement registers */ + uint16_t shunt_reg; + uint16_t bus_reg; + uint16_t current_reg; + uint16_t power_reg; + + /* Injected physical inputs */ + int32_t shunt_nv; /* shunt voltage, nanovolts (signed: bidirectional)= */ + uint32_t bus_uv; /* bus voltage, microvolts (never negative) */ + + /* + * In latch mode AFF and the ALERT pin stay asserted until the + * Configuration register is written or the Mask/Enable register is re= ad + * (datasheet 7.3.3). + */ + bool alert_latched; + + char *description; +}; + +/* + * Evaluate the selected alert function. @shunt_fresh and @bus_fresh tell = which + * of the measurement registers hold a fresh value; a function fed by a ch= annel + * that did not convert cannot assert. + */ +static bool ina230_limit_alert(const INA230State *s, bool shunt_fresh, + bool bus_fresh) +{ + uint16_t me =3D s->mask_enable; + int16_t shunt =3D (int16_t)s->shunt_reg; + int16_t limit_s =3D (int16_t)s->alert_limit; + uint16_t limit_u =3D s->alert_limit; + + if (FIELD_EX16(me, INA230_MASK_ENABLE, SOL)) { + return shunt_fresh && shunt > limit_s; + } + if (FIELD_EX16(me, INA230_MASK_ENABLE, SUL)) { + return shunt_fresh && shunt < limit_s; + } + if (FIELD_EX16(me, INA230_MASK_ENABLE, BOL)) { + return bus_fresh && s->bus_reg > limit_u; + } + if (FIELD_EX16(me, INA230_MASK_ENABLE, BUL)) { + return bus_fresh && s->bus_reg < limit_u; + } + if (FIELD_EX16(me, INA230_MASK_ENABLE, POL)) { + return bus_fresh && s->power_reg > limit_u; + } + return false; +} + +static void ina230_refresh_alert(INA230State *s) +{ + bool latch =3D FIELD_EX16(s->mask_enable, INA230_MASK_ENABLE, LEN); + bool aff =3D latch ? s->alert_latched : ina230_limit_alert(s, true, tr= ue); + bool cnvr; + bool active; + int level; + + s->mask_enable =3D FIELD_DP16(s->mask_enable, INA230_MASK_ENABLE, AFF,= aff); + + cnvr =3D FIELD_EX16(s->mask_enable, INA230_MASK_ENABLE, CNVR) && + FIELD_EX16(s->mask_enable, INA230_MASK_ENABLE, CVRF); + + active =3D aff || cnvr; + + level =3D FIELD_EX16(s->mask_enable, INA230_MASK_ENABLE, APOL) ? + active : !active; + + trace_ina230_alert(s->description, level); + qemu_set_irq(s->alert, level); +} + +static void ina230_sample_alert(INA230State *s, bool shunt_fresh, + bool bus_fresh) +{ + if (FIELD_EX16(s->mask_enable, INA230_MASK_ENABLE, LEN) && + ina230_limit_alert(s, shunt_fresh, bus_fresh)) { + s->alert_latched =3D true; + } + ina230_refresh_alert(s); +} + +static void ina230_convert(INA230State *s) +{ + uint8_t mode =3D FIELD_EX16(s->config, INA230_CONFIG, MODE); + bool shunt_en =3D mode & 0x1; + bool bus_en =3D mode & 0x2; + int64_t sr, br, cur, pwr; + bool ovf =3D false; + + if (!shunt_en && !bus_en) { + return; + } + + if (shunt_en) { + sr =3D s->shunt_nv / INA230_SHUNT_LSB_NV; + sr =3D MAX(INT16_MIN, MIN(INT16_MAX, sr)); + s->shunt_reg =3D (uint16_t)(int16_t)sr; + + cur =3D (int64_t)(int16_t)s->shunt_reg * s->calibration / + INA230_CURRENT_DIV; + if (cur > INT16_MAX || cur < INT16_MIN) { + ovf =3D true; + cur =3D MAX(INT16_MIN, MIN(INT16_MAX, cur)); + } + s->current_reg =3D (uint16_t)(int16_t)cur; + } + + if (bus_en) { + br =3D s->bus_uv / INA230_BUS_LSB_UV; + br =3D MAX(0, MIN(INT16_MAX, br)); + s->bus_reg =3D (uint16_t)br; + } + + /* + * In bus-only mode the current register is retained from the last shu= nt + * conversion rather than measured anew, but the power register is sti= ll + * refreshed. + */ + if (bus_en) { + pwr =3D (int64_t)(int16_t)s->current_reg * s->bus_reg / INA230_POW= ER_DIV; + /* POWER is an unsigned, positive-only register (datasheet). */ + if (pwr < 0) { + pwr =3D 0; + } else if (pwr > UINT16_MAX) { + ovf =3D true; + pwr =3D UINT16_MAX; + } + s->power_reg =3D (uint16_t)pwr; + } + + /* Without a calibration the device reports neither current nor power.= */ + if (s->calibration =3D=3D 0) { + s->current_reg =3D 0; + s->power_reg =3D 0; + } + + s->mask_enable =3D FIELD_DP16(s->mask_enable, INA230_MASK_ENABLE, OVF,= ovf); + s->mask_enable =3D FIELD_DP16(s->mask_enable, INA230_MASK_ENABLE, CVRF= , 1); + + trace_ina230_convert(s->description, s->shunt_reg, s->bus_reg, + s->current_reg, s->power_reg); + + ina230_sample_alert(s, shunt_en, bus_en); +} + +/* + * A physical input or the calibration changed. + * - in continuous mode the device keeps converting and immediately tracks + * the new value + * - in a triggered mode it performs exactly one conversion per trigger + */ +static void ina230_input_update(INA230State *s) +{ + if (FIELD_EX16(s->config, INA230_CONFIG, MODE) & 0x4) { + ina230_convert(s); + } +} + +static void ina230_reset_regs(INA230State *s) +{ + s->config =3D INA230_CONFIG_POR; + s->calibration =3D 0; + s->mask_enable =3D 0; + s->alert_limit =3D 0; + s->alert_latched =3D false; + + s->ptr =3D 0; + s->len =3D 0; + s->wr_hi =3D 0; + s->rx_byte =3D 0; + s->rx_word =3D 0; + + s->shunt_reg =3D 0; + s->bus_reg =3D 0; + s->current_reg =3D 0; + s->power_reg =3D 0; + + ina230_refresh_alert(s); +} + +static uint16_t ina230_read_reg(INA230State *s, uint8_t reg) +{ + uint16_t val; + + switch (reg) { + case INA230_REG_CONFIG: + val =3D s->config; + break; + case INA230_REG_SHUNT: + val =3D s->shunt_reg; + break; + case INA230_REG_BUS: + val =3D s->bus_reg; + break; + case INA230_REG_POWER: + val =3D s->power_reg; + break; + case INA230_REG_CURRENT: + val =3D s->current_reg; + break; + case INA230_REG_CALIBRATION: + val =3D s->calibration; + break; + case INA230_REG_MASK_ENABLE: + val =3D s->mask_enable; + s->mask_enable =3D FIELD_DP16(s->mask_enable, INA230_MASK_ENABLE, + CVRF, 0); + s->alert_latched =3D false; + ina230_refresh_alert(s); + break; + case INA230_REG_ALERT_LIMIT: + val =3D s->alert_limit; + break; + case INA230_REG_DIE_ID: + val =3D INA230_DIE_ID_VAL; + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: %s: read from undefined register 0x%02x\n", + __func__, s->description, reg); + val =3D 0; + break; + } + + trace_ina230_read(s->description, reg, val); + return val; +} + +static void ina230_write_reg(INA230State *s, uint8_t reg, uint16_t val) +{ + trace_ina230_write(s->description, reg, val); + + switch (reg) { + case INA230_REG_CONFIG: + if (val & R_INA230_CONFIG_RST_MASK) { + trace_ina230_reset(s->description, "reg"); + ina230_reset_regs(s); + break; + } + s->config =3D val & ~R_INA230_CONFIG_RST_MASK; + /* + * The write itself releases a latched alert, so the release reach= es + * the ALERT pin before the conversion it triggers can relatch it. + */ + s->alert_latched =3D false; + ina230_refresh_alert(s); + ina230_convert(s); + break; + case INA230_REG_CALIBRATION: + s->calibration =3D val & INA230_CAL_MASK; + ina230_input_update(s); + break; + case INA230_REG_MASK_ENABLE: + s->mask_enable =3D (val & INA230_ME_WMASK) | + (s->mask_enable & INA230_ME_STATUS_MASK); + ina230_refresh_alert(s); + break; + case INA230_REG_ALERT_LIMIT: + s->alert_limit =3D val; + ina230_refresh_alert(s); + break; + case INA230_REG_SHUNT: + case INA230_REG_BUS: + case INA230_REG_POWER: + case INA230_REG_CURRENT: + case INA230_REG_DIE_ID: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: %s: write to read-only register 0x%02x\n", + __func__, s->description, reg); + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: %s: write to undefined register 0x%02x\n", + __func__, s->description, reg); + break; + } +} + +static uint8_t ina230_recv(I2CSlave *i2c) +{ + INA230State *s =3D INA230(i2c); + uint8_t byte; + + if (s->rx_byte =3D=3D 0) { + s->rx_word =3D ina230_read_reg(s, s->ptr); + byte =3D s->rx_word >> 8; + s->rx_byte =3D 1; + } else { + byte =3D s->rx_word & 0xff; + s->rx_byte =3D 0; + } + + return byte; +} + +static int ina230_send(I2CSlave *i2c, uint8_t data) +{ + INA230State *s =3D INA230(i2c); + + if (s->len =3D=3D 0) { + s->ptr =3D data; + } else if ((s->len & 1) =3D=3D 1) { + s->wr_hi =3D data; + } else { + ina230_write_reg(s, s->ptr, ((uint16_t)s->wr_hi << 8) | data); + } + s->len++; + + return 0; +} + +static int ina230_event(I2CSlave *i2c, enum i2c_event event) +{ + INA230State *s =3D INA230(i2c); + + s->len =3D 0; + s->rx_byte =3D 0; + + return 0; +} + +static void ina230_get_shunt(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + INA230State *s =3D INA230(obj); + int64_t value =3D s->shunt_nv; + + visit_type_int(v, name, &value, errp); +} + +static void ina230_set_shunt(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + INA230State *s =3D INA230(obj); + int64_t value; + + if (!visit_type_int(v, name, &value, errp)) { + return; + } + + if (value < INA230_SHUNT_MIN_NV || value > INA230_SHUNT_MAX_NV) { + error_setg(errp, + "%s: shunt-voltage %" PRId64 " out of range (%d..%d nV)= ", + s->description, value, + INA230_SHUNT_MIN_NV, INA230_SHUNT_MAX_NV); + return; + } + + s->shunt_nv =3D (int32_t)value; + ina230_input_update(s); +} + +static void ina230_get_bus(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + INA230State *s =3D INA230(obj); + int64_t value =3D s->bus_uv; + + visit_type_int(v, name, &value, errp); +} + +static void ina230_set_bus(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + INA230State *s =3D INA230(obj); + int64_t value; + + if (!visit_type_int(v, name, &value, errp)) { + return; + } + + if (value < 0 || value > INA230_BUS_MAX_UV) { + error_setg(errp, + "%s: bus-voltage %" PRId64 " out of range (0..%d uV)", + s->description, value, INA230_BUS_MAX_UV); + return; + } + + s->bus_uv =3D (uint32_t)value; + ina230_input_update(s); +} + +static void ina230_reset_hold(Object *obj, ResetType type) +{ + INA230State *s =3D INA230(obj); + + trace_ina230_reset(s->description, "hw"); + ina230_reset_regs(s); +} + +static int ina230_post_load(void *opaque, int version_id) +{ + INA230State *s =3D opaque; + + ina230_refresh_alert(s); + + return 0; +} + +static const VMStateDescription ina230_vmstate =3D { + .name =3D "INA230", + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load =3D ina230_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT8(ptr, INA230State), + VMSTATE_UINT8(len, INA230State), + VMSTATE_UINT8(wr_hi, INA230State), + VMSTATE_UINT8(rx_byte, INA230State), + VMSTATE_UINT16(rx_word, INA230State), + VMSTATE_UINT16(config, INA230State), + VMSTATE_UINT16(calibration, INA230State), + VMSTATE_UINT16(mask_enable, INA230State), + VMSTATE_UINT16(alert_limit, INA230State), + VMSTATE_UINT16(shunt_reg, INA230State), + VMSTATE_UINT16(bus_reg, INA230State), + VMSTATE_UINT16(current_reg, INA230State), + VMSTATE_UINT16(power_reg, INA230State), + VMSTATE_INT32(shunt_nv, INA230State), + VMSTATE_UINT32(bus_uv, INA230State), + VMSTATE_BOOL(alert_latched, INA230State), + VMSTATE_I2C_SLAVE(parent_obj, INA230State), + VMSTATE_END_OF_LIST() + } +}; + +static void ina230_initfn(Object *obj) +{ + object_property_add(obj, "shunt-voltage", "int", ina230_get_shunt, + ina230_set_shunt, NULL, NULL); + object_property_set_description(obj, "shunt-voltage", + "Injected shunt (differential) voltage= , " + "in nanovolts"); + object_property_add(obj, "bus-voltage", "int", ina230_get_bus, + ina230_set_bus, NULL, NULL); + object_property_set_description(obj, "bus-voltage", + "Injected bus voltage, in microvolts"); +} + +static void ina230_realize(DeviceState *dev, Error **errp) +{ + INA230State *s =3D INA230(dev); + + if (!s->description) { + s->description =3D g_strdup(object_get_typename(OBJECT(dev))); + } + + qdev_init_gpio_out(dev, &s->alert, 1); +} + +static const Property ina230_properties[] =3D { + DEFINE_PROP_STRING("description", INA230State, description), +}; + +static void ina230_class_init(ObjectClass *klass, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + I2CSlaveClass *ic =3D I2C_SLAVE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + + ic->event =3D ina230_event; + ic->recv =3D ina230_recv; + ic->send =3D ina230_send; + dc->realize =3D ina230_realize; + rc->phases.hold =3D ina230_reset_hold; + dc->vmsd =3D &ina230_vmstate; + device_class_set_props(dc, ina230_properties); +} + +static const TypeInfo ina230_types[] =3D { + { + .name =3D TYPE_INA230, + .parent =3D TYPE_I2C_SLAVE, + .instance_init =3D ina230_initfn, + .instance_size =3D sizeof(INA230State), + .class_init =3D ina230_class_init, + }, +}; + +DEFINE_TYPES(ina230_types) diff --git a/hw/sensor/meson.build b/hw/sensor/meson.build index fe36c9ef91..b81f001fdf 100644 --- a/hw/sensor/meson.build +++ b/hw/sensor/meson.build @@ -1,4 +1,5 @@ system_ss.add(when: 'CONFIG_ADC128D818', if_true: files('adc128d818.c')) +system_ss.add(when: 'CONFIG_INA230', if_true: files('ina230.c')) system_ss.add(when: 'CONFIG_TMP105', if_true: files('tmp105.c')) system_ss.add(when: 'CONFIG_TMP421', if_true: files('tmp421.c')) system_ss.add(when: 'CONFIG_DPS310', if_true: files('dps310.c')) diff --git a/hw/sensor/trace-events b/hw/sensor/trace-events index 5a3630f7bb..f809b6b506 100644 --- a/hw/sensor/trace-events +++ b/hw/sensor/trace-events @@ -8,6 +8,13 @@ adc128d818_convert(const char *id, uint8_t channel, uint16= _t value) "%s ch %u va adc128d818_irq(const char *id, bool level) "%s level %u" adc128d818_reset(const char *id, const char *source) "%s %s" =20 +# ina230.c +ina230_read(const char *id, uint8_t reg, uint16_t value) "%s reg 0x%02x va= l 0x%04x" +ina230_write(const char *id, uint8_t reg, uint16_t value) "%s reg 0x%02x v= al 0x%04x" +ina230_convert(const char *id, uint16_t shunt, uint16_t bus, uint16_t curr= ent, uint16_t power) "%s shunt 0x%04x bus 0x%04x current 0x%04x power 0x%04= x" +ina230_alert(const char *id, bool level) "%s level %u" +ina230_reset(const char *id, const char *source) "%s %s" + # tmp105.c tmp105_read(uint8_t dev, uint8_t addr) "device: 0x%02x, addr: 0x%02x" tmp105_write(uint8_t dev, uint8_t addr) "device: 0x%02x, addr 0x%02x" diff --git a/include/hw/sensor/ina230.h b/include/hw/sensor/ina230.h new file mode 100644 index 0000000000..4394727d47 --- /dev/null +++ b/include/hw/sensor/ina230.h @@ -0,0 +1,14 @@ +/* + * Texas Instruments INA230 current/voltage/power monitor with I2C interfa= ce + * + * Copyright (c) 2026 Meta Platforms, Inc. and affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_SENSOR_INA230_H +#define HW_SENSOR_INA230_H + +#define TYPE_INA230 "ina230" + +#endif --=20 2.50.1 From nobody Thu Oct 22 19:27:19 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818790; cv=none; d=zohomail.com; s=zohoarc; b=i/Blb/kZkhq86OGq1vB82uRNl9p67xrii6F8O7uTGCekdRk27YVJs+UPBFIkdgb8FhhMXRG+xgQKbmyMwlr11ZvTXBvsKMfs7FDYBq77lHQA6PDKsqqhInZ3hXLnoqplnBACIGw6VBHmRScWZ5sWOAwpTALgUE8S3PL+W2pMB1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818790; 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:Sender:Subject:Subject:To:To:Message-Id; bh=pVFmeSSk5C2LeCsDwy5d1Hb10DQrqE+ifqDeBxV7YtE=; b=WiKVha8hosdzvFSoD5ytx2+5urP1OLRF2ZipcJg8vPeMo5JEGM6JJAxZhyeyv0Hmzt67dElK9z7PToLLZaZfViBkjpBL89hOYPpz/7EMARKON7FuaGQqdFNELSIBx8voGL14I1kLqCCAcR46J/uywep51WXgEe8g98AHdOSrTm4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179181879089291.0559120853909; Mon, 12 Oct 2026 08:26:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHur-00038Z-97; Mon, 12 Oct 2026 11:26:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHup-00037D-EL for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:26:15 -0400 Received: from mail-wm1-f43.google.com ([209.85.128.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHum-0001fv-MS for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:26:15 -0400 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-49d05d51553so13125835e9.2 for ; Mon, 12 Oct 2026 08:26:12 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18bf15691sm289125915e9.6.2026.10.12.08.26.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:26:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818771; x=1792423571; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pVFmeSSk5C2LeCsDwy5d1Hb10DQrqE+ifqDeBxV7YtE=; b=Qd7l2CzKq2fC87TR20KEYELRb6IcM2p1i/4Ud+J5QX5DKN5VUlCO8BoyYq2dTBGkTI ZxMHiN3/y/B7BX4RKFvnmxupRRYzKN1l6V0yicvgK5o4lKRanWUmg0rGBisKGPITaBHs dBu8AiX1So3SqIkhtah07bOkDTABttmlkw9feXLXhnkw/x3LWFamTkx9CvtwT7WiZEMC mOlXewfYNdOtaOARmMeGwEW101+VQSnJI04le6JJH3xMc8qqhH6qkwFhx9lB4X0qP6/G 7iE1hOc2j/mNiYs3VdOasQleGr5EyGQ8snWzLR46FJEf5TembaPlvMcZFByM46lPxlT+ GlzQ== X-Gm-Message-State: AFq9FYItLeHVfOZlUgvWOWHO28t//OHBxt4UzvTqYlUCOkibMP6qpAyI rpqtf2UhVSqTp/IkMU8VhZ22pYCo6SZpxWLcbSWs02yosxw96RRda08ja7JXIEiL X-Gm-Gg: AYBFou01pdWBNP+1Y9iiuzj0Yxe7F2rgDa7cFPHEZQKB1zfT4nnLJva/lHJMr5BI98D yJIr6fBCcqiXdW/hkYMBsOJ0BIBZdRdzYhG1HmZpD74alUrzzAHn5pI9m+Cn/oHFgu/dX2YokVa 16Cygv6RlvQQVGU0/dC3QNXsS2TDhOlWPsoEs1XblvEd0lclwe9ExIIUx9CKhvBwZ3gREhJVWon lzZGeM1Xi4FXdDuDSFpjvO4u2nSY10oN1eWpuIL9bUJ7GDkx3ldEXo3Nx0p13aoN4Amql9yyZvT mc9ElOXBVu0LeilYqHd3hMqK0P+/KQe5ewv4FBvdT7ros7SGOfJ8ivkG5w0bdiDBCR09Kwupkym EuBndYsqayZF5W6wbZceF7ZZ3J+TXhduUhEX/20sgYBtztyXt7Qj3fSI43RqSf6/2/SC5BtqPIC 47zCK0bV7HbjHem0YG2KpjYWos9zYvLimmObckaUK/h3LhbJBhw3Tt6n15kZWNrFDqzcZFmG3j+ Zy54iIpdNCJId/fT3t5fUcqv/cL9NRLRIpG4N02A9DZaA== X-Received: by 2002:a05:600c:609a:b0:4a1:717b:7976 with SMTP id 5b1f17b1804b1-4a18e4b15e5mr186600595e9.35.1791818771028; Mon, 12 Oct 2026 08:26:11 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:26 +0200 Subject: [PATCH v2 33/50] tests/qtest: ina230: add current/voltage/power monitor test MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-33-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=5192; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=Ib67K8NIh73SBMHYK5G4nxgo3VsZ3kwz+ZvqDd0gy4M=; b=fjk5O0otE4oaEmTS3m5QV0lG+/HIf2v5H+JUTjA+FVRi42K7HfS+A7iGYqNx5eKBi9c+RNFzV 6ZMvPlcVux9A39rFOfuVDg3LcdDyc6bvA9zhHOeBVc8KzqsnjDDAxDH X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.43; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f43.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818791988158500 Introduce the INA230 qtest: the qgraph node and the register map. Cover the power-on-reset defaults and Die ID, the software reset, and the Configuration register write mask. The QMP voltage-injection helpers arrive with the following commit that exercises them. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina230-test.c | 115 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qtest/meson.build | 1 + 2 files changed, 116 insertions(+) diff --git a/tests/qtest/ina230-test.c b/tests/qtest/ina230-test.c new file mode 100644 index 0000000000..f7aefd2d97 --- /dev/null +++ b/tests/qtest/ina230-test.c @@ -0,0 +1,115 @@ +/* + * QTest testcase for the INA230 current/voltage/power monitor + * + * Copyright (c) 2026 Meta Platforms, Inc. and affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "libqos/i2c.h" +#include "libqos/qgraph.h" +#include "libqtest-single.h" +#include "qobject/qdict.h" + +#define INA230_TEST_ID "ina230-test" +#define INA230_TEST_ADDR 0x40 + +/* Register pointer addresses */ +#define REG_CONFIG 0x00 +#define REG_SHUNT 0x01 +#define REG_BUS 0x02 +#define REG_POWER 0x03 +#define REG_CURRENT 0x04 +#define REG_CALIBRATION 0x05 +#define REG_MASK_ENABLE 0x06 +#define REG_ALERT_LIMIT 0x07 +#define REG_DIE_ID 0xFF + +/* Configuration register bits */ +#define CONFIG_POR 0x4127 +#define CONFIG_RST 0x8000 + +/* Mask/Enable register bits */ +#define ME_LEN 0x0001 +#define ME_APOL 0x0002 +#define ME_OVF 0x0004 +#define ME_CVRF 0x0008 +#define ME_AFF 0x0010 +#define ME_CNVR 0x0400 +#define ME_POL 0x0800 +#define ME_BUL 0x1000 +#define ME_BOL 0x2000 +#define ME_SUL 0x4000 +#define ME_SOL 0x8000 + +/* Injected-input scaling (datasheet fixed LSBs) */ +#define SHUNT_LSB_NV 2500 +#define BUS_LSB_UV 1250 + +#define DIE_ID_VAL 0x2310 + +/* Power-on-reset default values and the Die ID */ +static void test_defaults(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + g_assert_cmphex(i2c_get16(dev, REG_CONFIG), =3D=3D, CONFIG_POR); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_BUS), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_POWER), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_CALIBRATION), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_ALERT_LIMIT), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_DIE_ID), =3D=3D, DIE_ID_VAL); +} + +/* Software reset via the Configuration RST bit */ +static void test_soft_reset(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CALIBRATION, 0x1234); + i2c_set16(dev, REG_MASK_ENABLE, ME_SOL); + i2c_set16(dev, REG_ALERT_LIMIT, 0x0500); + + g_assert_cmphex(i2c_get16(dev, REG_CALIBRATION), =3D=3D, 0x1234); + g_assert_cmphex(i2c_get16(dev, REG_ALERT_LIMIT), =3D=3D, 0x0500); + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + g_assert_cmphex(i2c_get16(dev, REG_CONFIG), =3D=3D, CONFIG_POR); + g_assert_cmphex(i2c_get16(dev, REG_CALIBRATION), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_ALERT_LIMIT), =3D=3D, 0x0000); +} + +/* Every bit except the self-clearing RST is writable and reads back */ +static void test_config_wmask(void *obj, void *data, QGuestAllocator *allo= c) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + /* Reserved bits are not forced: the guest value is retained */ + i2c_set16(dev, REG_CONFIG, 0x0007); + g_assert_cmphex(i2c_get16(dev, REG_CONFIG), =3D=3D, 0x0007); + + i2c_set16(dev, REG_CONFIG, 0x7FFF); + g_assert_cmphex(i2c_get16(dev, REG_CONFIG), =3D=3D, 0x7FFF); +} + +static void ina230_register_nodes(void) +{ + QOSGraphEdgeOptions opts =3D { + .extra_device_opts =3D "id=3D" INA230_TEST_ID ",address=3D0x40" + }; + add_qi2c_address(&opts, &(QI2CAddress) { INA230_TEST_ADDR }); + + qos_node_create_driver("ina230", i2c_device_create); + qos_node_consumes("ina230", "i2c-bus", &opts); + + qos_add_test("defaults", "ina230", test_defaults, NULL); + qos_add_test("soft-reset", "ina230", test_soft_reset, NULL); + qos_add_test("config-wmask", "ina230", test_config_wmask, NULL); +} +libqos_init(ina230_register_nodes); diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index e23eb9bbca..e413a0cc75 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -330,6 +330,7 @@ qos_test_ss.add( 'e1000-test.c', 'eepro100-test.c', 'es1370-test.c', + 'ina230-test.c', 'lsm303dlhc-mag-test.c', 'isl_pmbus_vr-test.c', 'max34451-test.c', --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818886; cv=none; d=zohomail.com; s=zohoarc; b=n45TtHYiwH1aD0HKWN+HIyRbaXgLT0cgiXZRYruaXVYDFLCW3XNrpwlqPmD0z+wmqOxr8pLM1wHTq9O7Pa8xIRyWKUvpSop5YfnweAFOXHVh0UHmDtBt3htrSuXBmkcL0pnsVQyaDr6iMCC10tWtmFzgOwxXKzs4qI3aGNpDKzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818886; 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:Sender:Subject:Subject:To:To:Message-Id; bh=yMnW4a8crPYO2wOiMAzPMEvePpA+mW750LYZ6d0wg08=; b=X3eDPUxHCzhN7U++VYHao0fubi+M4DzloTMj3Y+iewHSXi+n6UfQVtBZ/aAq5cJ0LXB3T5kU6jjmX895y+eWqAbGRWOFSvY7lA/b9aVUlpFtlryghQHckd8J5AeiKiue3s+Fea+rbsFiPfPeDuZd+p1KGKQBtDR7gY6X4gVZKDo= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791818885980676.8567180927172; Mon, 12 Oct 2026 08:28:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHw0-0003pH-SE; Mon, 12 Oct 2026 11:27:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHvs-0003mt-0U for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:27:21 -0400 Received: from mail-wr1-f48.google.com ([209.85.221.48]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHvo-0001mD-1Y for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:27:18 -0400 Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-486e70f2457so886750f8f.2 for ; Mon, 12 Oct 2026 08:27:14 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0bd733fsm21996f8f.58.2026.10.12.08.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:27:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818833; x=1792423633; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yMnW4a8crPYO2wOiMAzPMEvePpA+mW750LYZ6d0wg08=; b=OhteZuqp/p1tHg3+FexD6jjfZC9sshjQFCWV7ugtzOOVPNtK1yGIUEaZ7jB7ge/ypx Rs/J/zkIUVXgX7kfpitXaCmbkreoBodOMEfNsoakQZaFZ/c6y1o5fKGdwWWfOuK3gGsE P4wrUseAWjbrf0r+Xhwvv+GQrZjlBnvJrETPyBo/2FxtcwLBak2DHl4SS5eF/FrOo7eg tTLo5FhLzYrLVOkJyVQ8KwK/XZ0FZlJkvv4qKnT39aIph/DQW0WMWB18HOR/chBLr20A HPeTf2t5Epduf1Qug9iENERpQPvn/MYtsttCjUNDDlpPCcDQnW7+1LymvkholSk1SSiq c83A== X-Gm-Message-State: AFq9FYJ7U5q+1HvIDrqVsNz7nbNtajD3fcMNDX+1lq6WKUecqAReNMcw rxvexk94U8yNcske8rEah+Aq55OiPZAoZJbEFf1irz6iGLOOQZcE3UPpbwrskwfY X-Gm-Gg: AYBFou04beOskljMrLuzutJQ9QdtCx+EXUhfmxqZXyiRNLExmmnRTFNufZeBoMbICCx wH259htqXMMBlKqYQn5Fr9p5jFuF4994n4H4WmaTOSjC9ANRUTVqKoiMrDI2J9vFCWW7IUuZFw7 zrWa4qsg3jWdNDapnlVjEI99zvFaNYcZuN58sf0i9D3N7q8QZN1B4iGYUXmprlhj2CAoF6ZtRrb wTzI6wHYwxxyCnM+JYwYRQ93Ea5FA5NNyIngupuIRtEpdjiJiYkYf1RPmZqkqAX4ejEwF9ESQKA /xh6ZLexM7C6hhdbDf7lOsoYGDgz5lyDlTuHqwCt7Y25+w2Ysi2iZRitogq8mMS7TKbK+zt2XxL 3d2mpPvzqGT1wP29zA7V9dJ7n/PS+hcjMBsq2k0GJ8l7Xw3OluL8QDf2pl3BGLINWdcJU+hgd+2 5f9Eb6wxc1eIxNx9FM2wTekC7blYa18OOJed3ZVU99Rbqr1aorLCayr0cQF6kBxKluNjEzdCr6b kFZZxZ3utI2AJ88OOASzrih8ImXucpKaOJWkI2uyBiWBw== X-Received: by 2002:adf:f341:0:b0:487:197a:5c1f with SMTP id ffacd0b85a97d-48dbaae84e0mr14930321f8f.49.1791818832771; Mon, 12 Oct 2026 08:27:12 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:27 +0200 Subject: [PATCH v2 34/50] tests/qtest: ina230: cover voltage injection and power derivation MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-34-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=5751; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=Lxa/vLTiqltAne2a9oGEC4v4uDweYMzTuPg2HL1aV2c=; b=qlM2sMAwtWBpe7RscPECgWxplCp5Dir6hNCtOQM4g5waAub3h+xyXuVvKg5qB4o2bJsPFZExO JeufTS4x2rNDXRK29THBkdLWGuYJux4qfT4d4XyUflzmQoUigIGGwpq X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.48; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f48.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818887919158500 Cover the shunt- and bus-voltage injection properties and the current and power values the device derives from them through the Calibration register, including the zero-calibration case and the clamp/overflow edges. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina230-test.c | 124 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 124 insertions(+) diff --git a/tests/qtest/ina230-test.c b/tests/qtest/ina230-test.c index f7aefd2d97..b01f9445d1 100644 --- a/tests/qtest/ina230-test.c +++ b/tests/qtest/ina230-test.c @@ -49,6 +49,33 @@ =20 #define DIE_ID_VAL 0x2310 =20 +/* QMP helpers for injecting the physical inputs */ + +static void qmp_ina230_set(const char *property, int value) +{ + QDict *resp; + + resp =3D qmp("{ 'execute': 'qom-set', 'arguments':" + " { 'path': %s, 'property': %s, 'value': %d } }", + INA230_TEST_ID, property, value); + g_assert(qdict_haskey(resp, "return")); + qobject_unref(resp); +} + +static int qmp_ina230_get(const char *property) +{ + QDict *resp; + int ret; + + resp =3D qmp("{ 'execute': 'qom-get', 'arguments':" + " { 'path': %s, 'property': %s } }", + INA230_TEST_ID, property); + g_assert(qdict_haskey(resp, "return")); + ret =3D qdict_get_int(resp, "return"); + qobject_unref(resp); + return ret; +} + /* Power-on-reset default values and the Die ID */ static void test_defaults(void *obj, void *data, QGuestAllocator *alloc) { @@ -98,6 +125,96 @@ static void test_config_wmask(void *obj, void *data, QG= uestAllocator *alloc) g_assert_cmphex(i2c_get16(dev, REG_CONFIG), =3D=3D, 0x7FFF); } =20 +/* Shunt voltage register, including two's-complement negatives */ +static void test_shunt_injection(void *obj, void *data, QGuestAllocator *a= lloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + qmp_ina230_set("shunt-voltage", 20000000); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, 0x1F40); + + qmp_ina230_set("shunt-voltage", -80000000); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, 0x8300); + + g_assert_cmpint(qmp_ina230_get("shunt-voltage"), =3D=3D, -80000000); +} + +/* Bus voltage register */ +static void test_bus_injection(void *obj, void *data, QGuestAllocator *all= oc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + qmp_ina230_set("bus-voltage", 12000000); + g_assert_cmphex(i2c_get16(dev, REG_BUS), =3D=3D, 0x2580); + + qmp_ina230_set("bus-voltage", 11980000); + g_assert_cmphex(i2c_get16(dev, REG_BUS), =3D=3D, 0x2570); +} + +/* Calibration-derived current, using the datasheet worked example */ +static void test_calibration_current(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina230_set("shunt-voltage", 20000000); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x0000); + + i2c_set16(dev, REG_CALIBRATION, 0x0A00); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x2710); +} + +/* Calibration-derived power, using the datasheet worked example */ +static void test_power(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina230_set("shunt-voltage", 20000000); + qmp_ina230_set("bus-voltage", 11980000); + i2c_set16(dev, REG_CALIBRATION, 0x0A00); + + g_assert_cmphex(i2c_get16(dev, REG_POWER), =3D=3D, 0x12B8); +} + +/* With Calibration =3D=3D 0 the Current and Power registers stay at zero = */ +static void test_zero_cal(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina230_set("shunt-voltage", 20000000); + qmp_ina230_set("bus-voltage", 11980000); + + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_POWER), =3D=3D, 0x0000); +} + +/* Clamping at full scale and the OVF (math overflow) flag */ +static void test_edges_overflow(void *obj, void *data, QGuestAllocator *al= loc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina230_set("shunt-voltage", 81917500); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, 0x7FFF); + qmp_ina230_set("shunt-voltage", -81920000); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, 0x8000); + + qmp_ina230_set("bus-voltage", 36000000); + g_assert_cmphex(i2c_get16(dev, REG_BUS), =3D=3D, 0x7080); + + qmp_ina230_set("shunt-voltage", 20000000); + i2c_set16(dev, REG_CALIBRATION, 0x7FFF); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x7FFF); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_OVF, =3D=3D, ME_O= VF); +} + static void ina230_register_nodes(void) { QOSGraphEdgeOptions opts =3D { @@ -111,5 +228,12 @@ static void ina230_register_nodes(void) qos_add_test("defaults", "ina230", test_defaults, NULL); qos_add_test("soft-reset", "ina230", test_soft_reset, NULL); qos_add_test("config-wmask", "ina230", test_config_wmask, NULL); + qos_add_test("shunt-injection", "ina230", test_shunt_injection, NULL); + qos_add_test("bus-injection", "ina230", test_bus_injection, NULL); + qos_add_test("calibration-current", "ina230", test_calibration_current, + NULL); + qos_add_test("power", "ina230", test_power, NULL); + qos_add_test("zero-cal", "ina230", test_zero_cal, NULL); + qos_add_test("edges-overflow", "ina230", test_edges_overflow, NULL); } libqos_init(ina230_register_nodes); --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818928; cv=none; d=zohomail.com; s=zohoarc; b=DReurubwyCkw5xcWwyWyKYOUykisd8ynoo9j3VTCd3Qcyz2yPzv+V9EYNYIgvbDYYkVfEEGM0g+TYfeznf5aWOZqToXv7gM59gKN8EKNi3mKnjEmalp0XD3gbKd2NSKccgOS/F3fx9pFITNH+DmxLRxDLMX/CyJUZ9trN4e3pN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818928; 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:Sender:Subject:Subject:To:To:Message-Id; bh=MZwOnu4u3mbwMqdzuk9WWRV5vzGX0PpwyIdVH5RHZDU=; b=nx9OSela0Z9j1aW9OI8aiz/8rsw1bclco11UzlwU/p9VZQa440l3KSHfyvQHXlzAQa+edSR+WuoIRIXwn31Nvywor3scckJThaBQMROxlJrOuZB0YQ3eRLJXLYR8KyXCgTca0AC1xNLuTgDStMW8incYFbW1K/BIXZZcOzHh7zk= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791818928899740.7512904501514; Mon, 12 Oct 2026 08:28:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHx1-0004Nt-C7; Mon, 12 Oct 2026 11:28:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHwo-0004J5-NL for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:28:18 -0400 Received: from mail-wr1-f48.google.com ([209.85.221.48]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHwl-0001rt-S1 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:28:18 -0400 Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-48c6955a7c3so432328f8f.1 for ; Mon, 12 Oct 2026 08:28:15 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0bc50e0sm45948f8f.49.2026.10.12.08.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:28:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818894; x=1792423694; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MZwOnu4u3mbwMqdzuk9WWRV5vzGX0PpwyIdVH5RHZDU=; b=ywfWKbkDP6rt5PApvVg/GP2pCtVzYiuKqwfxLym33YYEL833uLn4zRqsyfc41OKKJv VGV563OPWa1Fw9i1ND1eqMj4dOgQOEvEwyuoPc/KGtPrk5ojWiu70D7j9vizg9Opumg8 AjHoj8gOK2O1owPA2P7R5IOKfEWuhEF7jwUNBR4T5omIEuf4GtnE9LDK+C9rN9FGNf/N Nk8nnKyjaKZk6/SGVZ6Kn/O/Jj9cE1LD2CUVxB+Kp6DpJV3U4QTaiDp88KW0Snek7AG7 osLYlWGxRXygGOc95hR689/y8ppOsKUUsmpToU8nyjDh0t6GMouYpGZTm1i5RLOvT687 b0hQ== X-Gm-Message-State: AFq9FYLgiC8o8PdHE1t+o5SxFucLyRBzTBi3W43Y05tZRGdl3ba0b30p EzYwsTqllMy4OIp1kNcfpheLdV+b+CjGMAJ+vEvL4be3nN7QcUjiPH5mPUZM0Vl0 X-Gm-Gg: AYBFou2rpcZvxBoLys1x0/mUjdk13T7eFR5VjVN1EL5SIC4PvlhepvJTkrcgS/06BC+ ig5zkHO48+56N2g5bd0BEj4exFq2Qd8CuOwB7TUfjDXsC4eP2nximBZcuraVVx/BHvE37TmDNgX 3vbDRa6Ml/kCCrCLoFKMphqIAbet+XkdtgQmnvIxLDHq8oEzY6/OFtfSoRbX5PvcFMYCK3jl4oN rdWPBZorzHivRtgTNb0PAqrPQ+ET3TZcN9xjzjvpTJinwhKZlyS7yEQsQoHwpNB5dm1LgTM3ZE8 o00FsZxhjm0HsKPofqCe1fRGMYmvUEHWR+fP291BqEJzzjEHpDWna5uPF8lkyrDD+y/McgiW0bi 9Fx/fATwsONEEy6vPAdUPTMmOtRLaHzHskLj6K9ZEl5iQlbsA9IKQco0TkzaZbSoUaOo09p2egg J+kNYeqC56iZYFrUKu3mAFWTn2NWLFHWa4b9ar1ac/iF7+EtSHBX4ilCNEx2gDk3s2N4+F9sCGv 2dX36hPtiNbNDFWq2EjD0XHFMKC0InkhPIRg+FaESKbbh9bFjzPl1SymQ== X-Received: by 2002:a05:6000:481b:b0:48b:11ee:de66 with SMTP id ffacd0b85a97d-48dbad1217fmr16296782f8f.34.1791818894054; Mon, 12 Oct 2026 08:28:14 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:28 +0200 Subject: [PATCH v2 35/50] tests/qtest: ina230: cover the ALERT limit functions and CVRF MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-35-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=4599; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=g1WQNWNWvejsNUmKknPzwDjtl/zzqUIEuhP5ANmhVl4=; b=65OnQLfX8QBukL+ykDWwsyLTTx2PdYzkrPwt93bRTQOwUz6a3SBgM8G/Y8a6EqH1nmCbL95Pz f02zXQq2+KlBIlZ4Blc/ffjRIeXlvDSBzpkHxXTPvXVni3VSXIToVvl X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.48; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f48.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818930463158500 Cover the shunt/bus/power alert-limit functions, the alert latch behaviour and the conversion-ready flag. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina230-test.c | 97 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 97 insertions(+) diff --git a/tests/qtest/ina230-test.c b/tests/qtest/ina230-test.c index b01f9445d1..1c55028fcb 100644 --- a/tests/qtest/ina230-test.c +++ b/tests/qtest/ina230-test.c @@ -215,6 +215,98 @@ static void test_edges_overflow(void *obj, void *data,= QGuestAllocator *alloc) g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_OVF, =3D=3D, ME_O= VF); } =20 +/* Shunt over-limit alert (transparent mode) sets the AFF flag */ +static void test_alert_shunt_over(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + i2c_set16(dev, REG_ALERT_LIMIT, 0x1000); + i2c_set16(dev, REG_MASK_ENABLE, ME_SOL); + + qmp_ina230_set("shunt-voltage", 2500000); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, 0); + + qmp_ina230_set("shunt-voltage", 20000000); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, ME_A= FF); + + qmp_ina230_set("shunt-voltage", 2500000); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, 0); +} + +/* Latch mode holds the alert until the Mask/Enable register is read */ +static void test_alert_latch(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + uint16_t me; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + i2c_set16(dev, REG_ALERT_LIMIT, 0x1000); + i2c_set16(dev, REG_MASK_ENABLE, ME_SOL | ME_LEN); + + qmp_ina230_set("shunt-voltage", 20000000); + qmp_ina230_set("shunt-voltage", 2500000); + + me =3D i2c_get16(dev, REG_MASK_ENABLE); + g_assert_cmphex(me & ME_AFF, =3D=3D, ME_AFF); + + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, 0); +} + +/* Bus over-limit alert */ +static void test_alert_bus(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + i2c_set16(dev, REG_ALERT_LIMIT, 0x2000); + i2c_set16(dev, REG_MASK_ENABLE, ME_BOL); + + qmp_ina230_set("bus-voltage", 5000000); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, 0); + + qmp_ina230_set("bus-voltage", 12000000); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, ME_A= FF); +} + +/* Power over-limit alert */ +static void test_alert_power(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina230_set("shunt-voltage", 20000000); + qmp_ina230_set("bus-voltage", 11980000); + i2c_set16(dev, REG_CALIBRATION, 0x0A00); + + i2c_set16(dev, REG_ALERT_LIMIT, 0x1000); + i2c_set16(dev, REG_MASK_ENABLE, ME_POL); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, ME_A= FF); + + i2c_set16(dev, REG_ALERT_LIMIT, 0x2000); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, 0); +} + +/* Conversion Ready Flag: set on conversion, cleared by reading Mask/Enabl= e */ +static void test_cvrf(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + /* A conversion (triggered by injection) sets CVRF */ + qmp_ina230_set("shunt-voltage", 20000000); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_CVRF, =3D=3D, ME_= CVRF); + + /* The previous read cleared CVRF; no conversion since, so it stays cl= ear */ + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_CVRF, =3D=3D, 0); +} + static void ina230_register_nodes(void) { QOSGraphEdgeOptions opts =3D { @@ -235,5 +327,10 @@ static void ina230_register_nodes(void) qos_add_test("power", "ina230", test_power, NULL); qos_add_test("zero-cal", "ina230", test_zero_cal, NULL); qos_add_test("edges-overflow", "ina230", test_edges_overflow, NULL); + qos_add_test("alert-shunt-over", "ina230", test_alert_shunt_over, NULL= ); + qos_add_test("alert-latch", "ina230", test_alert_latch, NULL); + qos_add_test("alert-bus", "ina230", test_alert_bus, NULL); + qos_add_test("alert-power", "ina230", test_alert_power, NULL); + qos_add_test("cvrf", "ina230", test_cvrf, NULL); } libqos_init(ina230_register_nodes); --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791818968; cv=none; d=zohomail.com; s=zohoarc; b=hCjr7aS3ki5fOuHqztbpBmvYMCFBjSPyXhQR1c3k0CSKItb8k2Yyo6ValTBmnmAdxOfdw3p1K8TOIlSFSDgi3JOe7gCQYgHixKAGO0YXSYcn3TI60QFqSoxFamkbueutTgOOehhobiwJlVczk2a+iDp2B1IJSujJgzEBPnEhVyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791818968; 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:Sender:Subject:Subject:To:To:Message-Id; bh=tT25q+kAs26amHD55A44HNQvdNP+ZXuCq/4WXpNirRE=; b=aNXmEdKR04xZbkRugFGni1bwsiwqf5y4uhMZjOLqOjary5qMqdiG+UzphtEEuWwtN2VgUBG5TlzMewkt0UBeOHrv4rSqd/i59iQv96iecJTNKo6cytxTF41CJ2GMD6VEbuCQ3kwPAphRlWY8L/ZG5ZpdN8HPp3YIHAw7Emj9twk= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791818968789761.2921091611228; Mon, 12 Oct 2026 08:29:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHxo-00053g-RE; Mon, 12 Oct 2026 11:29:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHxn-00053B-CX for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:29:19 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHxl-0001xh-LK for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:29:19 -0400 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-48afe0081a6so1390675f8f.2 for ; Mon, 12 Oct 2026 08:29:16 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm412198175e9.6.2026.10.12.08.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:29:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791818956; x=1792423756; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=tT25q+kAs26amHD55A44HNQvdNP+ZXuCq/4WXpNirRE=; b=hanFetzrsxSdv1XCa/oQN0D2x6M9BzrA767vIO6ox0nvO8NScY6PE887KKmtO/TEQn 3F32qIjU9Ln/+/t2Jqrtc+NJ5rlQo50MXQG7jCCL0nf3gyT9hK0HjRbBM8Ec1deFEnk9 gJyB6XuJ7YAaAjrhuwodkZn5eUSYFIEfhedad5sX6JdxJrEk5F3dktTA5A1CCGL+AY3L SeqskYi4wLW/C+C94cxpAzqp+tylytEo8D3H3wgpFxBjW+0aibUn+ycokbujGbEUiGcW /OXMynbzLG0Q4QVX7vDozOvSLAVzgZToYq5ZK+jkYctb7mLi14b8NYX4YNTA0tJTcMJW 3efQ== X-Gm-Message-State: AFq9FYKCMk6wDxhRfF//6k+BfqzZJ+k/zkK6y4ljXs5UwyG/L3Onjrk4 cT12YVJ+vP2iQ1X2yV+z8MD0ccq8WZ/dRjjclrlr02AUJotdbbWpGhDy5lzce4Ok X-Gm-Gg: AYBFou1MWdAS2IrhdayakqZGlOFxV5Vm/CUicGMjfebE34kSPEAAL0R/sE8Drevd5kT S1PIce1S9jk4LnPFp8IAIf/+iaD6BAuzqVxrf+9vEWUKJ3MAaCH2oiRVuI44uHv0xeaide95NXW Hfy03h1IHEfSkRL+LKYhdT+L8AoA2hCp9iVUN4bL3QZtr15Y4EdG9TqmSv5pS8bFLKcfdMKXm9V 6ckYUvSpRRdesdweOLrbOuFcUhZI5t2YM5kqTUMLf5alKgcjJZOz0noZ62IxDbV/EyU+8wzrmcT U+9wkaP/CL+DhGlU2YkFkwT0oXMAJ94y5FP4WYDP6dlvHl4aJ/YwuK41HwfGJXpLOebkyP26L/L Wqat/kZW4zoayf43Zgl2Y9V6hrSP+3BDSJXeZX+71SiTnYbNNuXvgIReI+n27M1P6KyQybrLzXr bQy5Im7woLmPzDA5asdU5+H+cv8ajuGtdHfNKOdMz0P4k/HWGJkwAY8j+kXjW3rF4LNPkLf31sd S3KldQsKDQuopX4DeNgCPdY9haRJ9hAvJolYyArDT3AkA== X-Received: by 2002:a05:600c:4689:b0:4a0:1cfd:321 with SMTP id 5b1f17b1804b1-4a18e4a9b31mr206769825e9.12.1791818955589; Mon, 12 Oct 2026 08:29:15 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:29 +0200 Subject: [PATCH v2 36/50] tests/qtest: ina230: cover the injection-property limits MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-36-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=4015; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=wQmdLPHBw+ci32U6sjobS3P/cDhoGbED08CSbaHRchk=; b=ULt1AFcU9DxFHXJ8AO/WqFOV1c/kzM1HuvBVB9jjlltna8IL1WYAGKBhqrT4nxsaL5rUnaqhy INMx42npWwSDmSQzBatjaKyfm6Ff6+ltj3emotsR+wJFudx/vR7TFCr X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.41; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f41.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791818969210158500 Verify that the extremes of the shunt- and bus-voltage injection ranges round-trip through the QOM property without truncation or wraparound, and that values just outside are rejected rather than silently wrapped. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina230-test.c | 59 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 59 insertions(+) diff --git a/tests/qtest/ina230-test.c b/tests/qtest/ina230-test.c index 1c55028fcb..36c899efee 100644 --- a/tests/qtest/ina230-test.c +++ b/tests/qtest/ina230-test.c @@ -47,6 +47,11 @@ #define SHUNT_LSB_NV 2500 #define BUS_LSB_UV 1250 =20 +/* Injection-property limits (see ina230.c) */ +#define SHUNT_MIN_NV (-81920000) +#define SHUNT_MAX_NV 81917500 +#define BUS_MAX_UV 36000000 + #define DIE_ID_VAL 0x2310 =20 /* QMP helpers for injecting the physical inputs */ @@ -76,6 +81,18 @@ static int qmp_ina230_get(const char *property) return ret; } =20 +/* A qom-set expected to be rejected (value outside the supported range) */ +static void qmp_ina230_set_fail(const char *property, int64_t value) +{ + QDict *resp; + + resp =3D qmp("{ 'execute': 'qom-set', 'arguments':" + " { 'path': %s, 'property': %s, 'value': %lld } }", + INA230_TEST_ID, property, (long long)value); + g_assert(qdict_haskey(resp, "error")); + qobject_unref(resp); +} + /* Power-on-reset default values and the Die ID */ static void test_defaults(void *obj, void *data, QGuestAllocator *alloc) { @@ -307,6 +324,46 @@ static void test_cvrf(void *obj, void *data, QGuestAll= ocator *alloc) g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_CVRF, =3D=3D, 0); } =20 +/* Shunt-voltage injection limits */ +static void test_shunt_limits(void *obj, void *data, QGuestAllocator *allo= c) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina230_set("shunt-voltage", SHUNT_MAX_NV); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, 0x7FFF); + g_assert_cmpint(qmp_ina230_get("shunt-voltage"), =3D=3D, SHUNT_MAX_NV); + + qmp_ina230_set("shunt-voltage", SHUNT_MIN_NV); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, 0x8000); + g_assert_cmpint(qmp_ina230_get("shunt-voltage"), =3D=3D, SHUNT_MIN_NV); + + qmp_ina230_set_fail("shunt-voltage", (int64_t)SHUNT_MAX_NV + 1); + qmp_ina230_set_fail("shunt-voltage", (int64_t)SHUNT_MIN_NV - 1); + g_assert_cmpint(qmp_ina230_get("shunt-voltage"), =3D=3D, SHUNT_MIN_NV); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, 0x8000); +} + +/* Bus-voltage injection limits. */ +static void test_bus_limits(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina230_set("bus-voltage", 0); + g_assert_cmphex(i2c_get16(dev, REG_BUS), =3D=3D, 0x0000); + + qmp_ina230_set("bus-voltage", BUS_MAX_UV); + g_assert_cmphex(i2c_get16(dev, REG_BUS), =3D=3D, 0x7080); + g_assert_cmpint(qmp_ina230_get("bus-voltage"), =3D=3D, BUS_MAX_UV); + + qmp_ina230_set_fail("bus-voltage", (int64_t)BUS_MAX_UV + 1); + qmp_ina230_set_fail("bus-voltage", -1); + g_assert_cmpint(qmp_ina230_get("bus-voltage"), =3D=3D, BUS_MAX_UV); +} + static void ina230_register_nodes(void) { QOSGraphEdgeOptions opts =3D { @@ -322,6 +379,8 @@ static void ina230_register_nodes(void) qos_add_test("config-wmask", "ina230", test_config_wmask, NULL); qos_add_test("shunt-injection", "ina230", test_shunt_injection, NULL); qos_add_test("bus-injection", "ina230", test_bus_injection, NULL); + qos_add_test("shunt-limits", "ina230", test_shunt_limits, NULL); + qos_add_test("bus-limits", "ina230", test_bus_limits, NULL); qos_add_test("calibration-current", "ina230", test_calibration_current, NULL); qos_add_test("power", "ina230", test_power, NULL); --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819064; cv=none; d=zohomail.com; s=zohoarc; b=BRlYoVk8B/9cAjt8c4RXc6nSJ1wdjJlXYBHvREfrUtBoZ+xm/GcEF9RCtBEY2GtP50It8JnuB5Rifehg1SqAhuUNrcqm8wUSf0tPyFbxqeRmUVWM/oqMLXvVEt8HXJDYVkDSbp7V2oQFiagWQLgSBriBuvxO9UQJx6mMin3EWSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819064; 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:Sender:Subject:Subject:To:To:Message-Id; bh=vlKqMzmrK40spXKv/yB5zNGWaGlUqMdf8882/o2C+B4=; b=gnZb+xKpzKFRxDUjoF2QYhrdpgECK+7bjS5A5tRdOfZXYPPDj2cFTUfmU7iVeXVuWtVAF9I6YY/q1yhL3/Chi5EBCw29i/Bb8Vx6nQYb1OxHy+nteMuvedtePJTTN1XqDPH/HI7FZMlgzVGjxUdihEpzu6flTjUrZlHKryjj5J4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791819064197210.01907929373783; Mon, 12 Oct 2026 08:31:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHyu-0005fK-5y; Mon, 12 Oct 2026 11:30:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHyn-0005dj-D6 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:30:25 -0400 Received: from mail-wm1-f43.google.com ([209.85.128.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHyl-0002Gc-6S for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:30:21 -0400 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4a02753c04fso10810405e9.3 for ; Mon, 12 Oct 2026 08:30:18 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18bea1021sm271495325e9.10.2026.10.12.08.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:30:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819018; x=1792423818; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=vlKqMzmrK40spXKv/yB5zNGWaGlUqMdf8882/o2C+B4=; b=yc+oDlIntSNdpB4GLJMz4nWqftNpwSw7+Tw3phSrfvxgQiOUXTYfdBpyUhqjEqg+0P PR3riGSRV9TgMKeNTe9AnYbmZtsIdNOyMPAW87myf4pPwIAmFpLfChlH+qPplYY1JMm4 x/YIEaxHGe1p1Jwjuk21d3UrguehaIDBr1VnZfxfegl1NQNjMcBxn/Nr8Yf1TnDfLnrq EKt6OPqcf2zwBpyIO9wmNhDWzYYNBPMMA9aW1lP6iP7Ri1ZWXicB7TH/nuW8vd5xt8Ao 1l3R2IgFZ1Uwmo7jHmWF+eoLmFNM3tjmSHii2pb56QKIBP0oPlPUNs+GV8+u7Hr8suNG Ckcw== X-Gm-Message-State: AFq9FYK8fgRoGDQgMWzFJzmWRD7A2GqDsZoXzW9c6oaa/jpc4lvuJ6vI NiUoBjr2NB22n1qPVeUqEe2yKFCyF/x4+RP/RaQefaXVeAQethsid1ubRdgKAM4d X-Gm-Gg: AYBFou0NmSklT5bpXlY1Ex45h+1B2meW+ofaAdeLWpytcl30o+aBFGW8792UKegHT+9 hIVrEIzKE7PhLoyaIWGeFfDl7jfjKnR0uqP05iJsj68lRARFbwzPCFFUs3gzK+DdRuIDB7yBpu6 B8ZKbMsKf4ZZraeh3f4JnumBjL5tFtUhWMUevRcEESaqV2yvFLjHPEDE2z3yWz0TogKTg8sEPua Hw7AGtSY9IFdcueg7NoZo2KAZ1M9vFhiLi/LiEOv+w1+Dcke9ORGysf/LrA/TAA0MGiY9vznixZ V87aELqFZoZNjmTK33PA9ApPm8pe6oc1VFfgAZNPaBBHrKxx8KdusyOkq3d+GdqXK9DExCRRnT0 XRpp0Gcd/EIOD5ROJq8o7aTBWLYtUyS6+W0UNfeXNLgnYwZKaRJYE5d+1YjA2gecpFub4duXCm/ Q9GeS5FpCFvnZAzucFoWbBXDnsfl1iEguF1xyDufcpanbKZrlnwFWeh4l2PeGTkLIJ7a/xCU9tV wNueacElnUB29iG9cftyWi3rEL/MlJt1AV6rr4CD1YsYQ== X-Received: by 2002:a05:600c:4f10:b0:4a0:d1f4:b1d1 with SMTP id 5b1f17b1804b1-4a18e4bff89mr221912075e9.24.1791819017443; Mon, 12 Oct 2026 08:30:17 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:30 +0200 Subject: [PATCH v2 37/50] tests/qtest: ina230: cover operating modes and triggered conversions MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-37-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=5271; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=Mc0oCEh0KqXrK8lJcAnq4Li1G/vyttVEriaHtSwE3o8=; b=6JUWNrFNExmDDh+pIANIiQTj+Ktw5ya8FUvv6cJqVdcxCfhBtc84QAI+GjQybGblQgDGA/5Qr Q+s/es8G2/tCxtMZL9S/W//nr4UNkotojCJRD5RX0ZrreuDoWvh9Ces X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.43; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f43.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819065296158500 Add coverage for the MODE field: power-down retains the last results, the shunt/bus channel-enable bits gate which registers track new inputs, triggered modes convert once per Config write, and bus-only mode still derives power from the retained current. Signed-off-by: Emmanuel Blot --- tests/qtest/ina230-test.c | 95 +++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 94 insertions(+), 1 deletion(-) diff --git a/tests/qtest/ina230-test.c b/tests/qtest/ina230-test.c index 36c899efee..f8b982686a 100644 --- a/tests/qtest/ina230-test.c +++ b/tests/qtest/ina230-test.c @@ -142,7 +142,97 @@ static void test_config_wmask(void *obj, void *data, Q= GuestAllocator *alloc) g_assert_cmphex(i2c_get16(dev, REG_CONFIG), =3D=3D, 0x7FFF); } =20 -/* Shunt voltage register, including two's-complement negatives */ +/* Operating modes */ +static void test_modes(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + static const struct { + uint8_t mode; + uint16_t shunt, bus, current, power; + } cases[] =3D { + /* Power-down: no conversion, every register retains the baseline = */ + { 0x0, 0x1F40, 0x2570, 0x2710, 0x12B8 }, + { 0x4, 0x1F40, 0x2570, 0x2710, 0x12B8 }, + /* Shunt only (continuous): shunt and current track the probe */ + { 0x5, 0x0FA0, 0x2570, 0x1388, 0x12B8 }, + /* Shunt and bus (continuous): every register tracks the probe */ + { 0x7, 0x0FA0, 0x12C0, 0x1388, 0x04B0 }, + }; + size_t idx; + + for (idx =3D 0; idx < ARRAY_SIZE(cases); idx++) { + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_CALIBRATION, 0x0A00); + qmp_ina230_set("shunt-voltage", 20000000); + qmp_ina230_set("bus-voltage", 11980000); + + i2c_set16(dev, REG_CONFIG, cases[idx].mode); + qmp_ina230_set("shunt-voltage", 10000000); + qmp_ina230_set("bus-voltage", 6000000); + + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, cases[idx].shun= t); + g_assert_cmphex(i2c_get16(dev, REG_BUS), =3D=3D, cases[idx].bus); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, cases[idx].cu= rrent); + g_assert_cmphex(i2c_get16(dev, REG_POWER), =3D=3D, cases[idx].powe= r); + } +} + +/* + * Triggered modes perform exactly one conversion per trigger, where the + * trigger is a Configuration-register write. Injected input changes + * between triggers are ignored until the next write. + */ +static void test_triggered(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_CALIBRATION, 0x0A00); + + qmp_ina230_set("shunt-voltage", 20000000); + qmp_ina230_set("bus-voltage", 11980000); + + i2c_set16(dev, REG_CONFIG, 0x03); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, 0x1F40); + g_assert_cmphex(i2c_get16(dev, REG_BUS), =3D=3D, 0x2570); + + qmp_ina230_set("shunt-voltage", 10000000); + qmp_ina230_set("bus-voltage", 6000000); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, 0x1F40); + g_assert_cmphex(i2c_get16(dev, REG_BUS), =3D=3D, 0x2570); + + i2c_set16(dev, REG_CONFIG, 0x03); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, 0x0FA0); + g_assert_cmphex(i2c_get16(dev, REG_BUS), =3D=3D, 0x12C0); + + i2c_set16(dev, REG_CONFIG, 0x07); + qmp_ina230_set("shunt-voltage", 20000000); /* A */ + g_assert_cmphex(i2c_get16(dev, REG_SHUNT), =3D=3D, 0x1F40); +} + +/* + * In a bus-only mode the current register is retained, but the power regi= ster + * is still refreshed on each bus conversion from that retained current. + */ +static void test_bus_only_power(void *obj, void *data, QGuestAllocator *al= loc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_CALIBRATION, 0x0A00); + qmp_ina230_set("shunt-voltage", 20000000); + qmp_ina230_set("bus-voltage", 11980000); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x2710); + + i2c_set16(dev, REG_CONFIG, 0x06); + qmp_ina230_set("bus-voltage", 6000000); + + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x2710); + g_assert_cmphex(i2c_get16(dev, REG_BUS), =3D=3D, 0x12C0); + g_assert_cmphex(i2c_get16(dev, REG_POWER), =3D=3D, 0x0960); +} + +/* Shunt voltage register */ static void test_shunt_injection(void *obj, void *data, QGuestAllocator *a= lloc) { QI2CDevice *dev =3D (QI2CDevice *)obj; @@ -377,6 +467,9 @@ static void ina230_register_nodes(void) qos_add_test("defaults", "ina230", test_defaults, NULL); qos_add_test("soft-reset", "ina230", test_soft_reset, NULL); qos_add_test("config-wmask", "ina230", test_config_wmask, NULL); + qos_add_test("modes", "ina230", test_modes, NULL); + qos_add_test("triggered", "ina230", test_triggered, NULL); + qos_add_test("bus-only-power", "ina230", test_bus_only_power, NULL); qos_add_test("shunt-injection", "ina230", test_shunt_injection, NULL); qos_add_test("bus-injection", "ina230", test_bus_injection, NULL); qos_add_test("shunt-limits", "ina230", test_shunt_limits, NULL); --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819162; cv=none; d=zohomail.com; s=zohoarc; b=EhG9C8Y94J6eBvThQkoLklqdCTENsi72Ct/JKUXO2Vk+dBAhWdIFk4B9oauWTYIn7FWk+QODGu9P6uKsun5Wn7t5uB5HDFSas92kIU0LknydApzUFN/nf0fLkouMgt2yQ2YZu2dJln8xWSxS2Bv1m0y28ElLzDK0LKhcfWY3dPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819162; 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:Sender:Subject:Subject:To:To:Message-Id; bh=ss51PCL4wPLTllRT5+2kCLycXbHqe9UGZco7OGSZnQA=; b=kDokhNjnAM5YEMtWRwN654FOSjd4GQWErJMcJOerjzzwmNQX4cCOesdPcAqEKwVk8NeOp1aglaZHPI5VtWnFX35X1PEp6hCeCzgOLCLWYtLSXDwVa70ijRMZGGFkQ9J2aUdlJFn4ue0ZGULjurv1eg3SC8mJSXC/WVx1UavH5vg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179181916267268.02262913676589; Mon, 12 Oct 2026 08:32:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGHzs-0006L3-3B; Mon, 12 Oct 2026 11:31:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGHzn-0006FF-SW for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:31:23 -0400 Received: from mail-wm1-f53.google.com ([209.85.128.53]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGHzl-0002RB-2z for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:31:23 -0400 Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4a1880e1bf1so18974835e9.1 for ; Mon, 12 Oct 2026 08:31:20 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0967a0dsm102603f8f.3.2026.10.12.08.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:31:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819079; x=1792423879; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ss51PCL4wPLTllRT5+2kCLycXbHqe9UGZco7OGSZnQA=; b=ICbWESxQ3pVRXNqloVSIwxttH/UioqitqWdaT6NnlZISgIx4FR6LpZU165TYJJVASG hP4n+7hNMr5uhgbnMy1XQvA+sLE+irzXu/1lGnB+9V15MCCxDBgQ6uqrniT9j1zw7q0O 0YW10BMwe1TB9ERAT/n8ou84UnSEDu+WRMug8waSjgRjFtU/z2k25xDWC42decIm9c+a 1ZRJQ+UWeI6Y/7yMlnx9B1O/CUeAJrovQGG5gNI55iCZFd8en8lg5aAjpKgoyu8LU/VA My9h/xloK5w0gmcDWNIiVtH3N7oqD9uAP+hAs/kpnGjEXlMiRn/Vjy/lTFReGbExKjQK y7cg== X-Gm-Message-State: AFq9FYLacs/VjQ5kMwNhHZ93p/JoE/wEL2BmB5dhk/Hwjs1AErWJfDQ2 LT0AmNDkyhl/dFcxrYnuyovHgPCuMNgXfoN/aTz6yrc0SW1VDCIjCbi5UiU0IHMt X-Gm-Gg: AYBFou1reMyAh2Qm/KfMZ8NITAI8gUQhv220wVSUt5USuo5QkyS4qNILhFlH3Ulymng OIMcnUPURXZ5ZXNJxXran4iH+cH5koQzRQdnEQ24qnMkrv+KaFYaqSnf8uwiqwAFr91bCgbyQ4/ 1Y/RvLLYjTGpa/uYX/BPRt2DRQDAbsxS2yuWS3Cw1rgXBAVaN2w1cFDhcFHIS0HFL/JQqRqLOV5 nBlLUD9quvubTNfRfiNE2wzm/EnQv9hAxd9afWIsu7TbzGv5/WEpQFH4tTVytvSkKAKN2Mf0O4V D9khLDcvLGxKpctWciq9nrCAEs5n1Twy/LoHUWqaWC1l4F280hLX+GfFjQwLoNUm5cZGXsZpv2C rR1Uo6k9jed8UH0cIVEetLpmSKc5pvt79GCS3q5j9rIIfIdggCwyKnAMCGAbZ03ztuZ9Doq3+d7 IyeWAWYEV559lMhBKP48s7HyT2D3U7P3x4oFpnAWcO3eBsKY+shc/0+jfQ5zObkFnsO5svRZ61t cC6AqGI6r2VtodwFe65V0h/1ITSXd6vsDS329Z6Mw+qrw== X-Received: by 2002:a05:600d:6413:10b0:4a1:88d7:4e6a with SMTP id 5b1f17b1804b1-4a19470eccamr93577085e9.27.1791819078612; Mon, 12 Oct 2026 08:31:18 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:31 +0200 Subject: [PATCH v2 38/50] tests/qtest: ina230: cover ALERT latch persistence MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-38-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=4916; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=jOC1vYeVhUY+5GdpU2iOwoUFRCa5a2ZvcAIYA/RAl8s=; b=ThodW9poXQ6lo666YxHvdLiafRZcgdhyvXtVIZpC8rNiT/mJFpsjM2vSMilw3a0/WIP+8UWc0 gWxbNv23ltnCLHUvBqkyQgfsm+xoE1U9kevWlNc97N74YJkf2IEjcPK X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.53; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f53.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819164851158500 Verify what releases a latched alert and what can bring it back: a Mask/Enable read and a Configuration write both clear it, and only a conversion that re-samples the fault on a channel it converted asserts it again. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina230-test.c | 89 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 89 insertions(+) diff --git a/tests/qtest/ina230-test.c b/tests/qtest/ina230-test.c index f8b982686a..591927e551 100644 --- a/tests/qtest/ina230-test.c +++ b/tests/qtest/ina230-test.c @@ -364,6 +364,88 @@ static void test_alert_latch(void *obj, void *data, QG= uestAllocator *alloc) } =20 /* Bus over-limit alert */ +static void test_alert_latch_persist(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_ALERT_LIMIT, 0x1000); + i2c_set16(dev, REG_MASK_ENABLE, ME_SOL | ME_LEN); + + qmp_ina230_set("shunt-voltage", 20000000); + + /* First read shows the latched AFF and clears the latch */ + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, ME_A= FF); + + /* Fault still present but no new conversion: AFF stays cleared */ + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, 0); + + qmp_ina230_set("shunt-voltage", 20000000); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, ME_A= FF); +} + +/* A Configuration write releases the latch as a Mask/Enable read does. */ +static void test_alert_latch_config(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_ALERT_LIMIT, 0x1000); + i2c_set16(dev, REG_MASK_ENABLE, ME_SOL | ME_LEN); + + /* Latch a fault, then bring the input back below the limit */ + qmp_ina230_set("shunt-voltage", 20000000); + qmp_ina230_set("shunt-voltage", 2500000); + + i2c_set16(dev, REG_CONFIG, CONFIG_POR); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, 0); + + /* With the fault present, the reconversion latches it again */ + qmp_ina230_set("shunt-voltage", 20000000); + i2c_set16(dev, REG_CONFIG, CONFIG_POR); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, ME_A= FF); +} + +/* The releasing write need not reconvert: a power-down leaves it clear. */ +static void test_alert_latch_shutdown(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_ALERT_LIMIT, 0x1000); + i2c_set16(dev, REG_MASK_ENABLE, ME_SOL | ME_LEN); + + qmp_ina230_set("shunt-voltage", 20000000); + + i2c_set16(dev, REG_CONFIG, 0x0000); /* power-down */ + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, 0); +} + +/* + * A conversion only re-samples the alert of a channel it converted: the b= us + * register a shunt-only conversion left stale must not re-latch. + */ +static void test_alert_channel(void *obj, void *data, QGuestAllocator *all= oc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_ALERT_LIMIT, 0x2000); + i2c_set16(dev, REG_MASK_ENABLE, ME_BOL | ME_LEN); + + qmp_ina230_set("bus-voltage", 12000000); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, ME_A= FF); + + /* Shunt-only mode: the bus register keeps its over-limit value */ + i2c_set16(dev, REG_CONFIG, 0x0005); + qmp_ina230_set("shunt-voltage", 20000000); + g_assert_cmphex(i2c_get16(dev, REG_BUS), =3D=3D, 0x2580); + g_assert_cmphex(i2c_get16(dev, REG_MASK_ENABLE) & ME_AFF, =3D=3D, 0); +} + static void test_alert_bus(void *obj, void *data, QGuestAllocator *alloc) { QI2CDevice *dev =3D (QI2CDevice *)obj; @@ -481,6 +563,13 @@ static void ina230_register_nodes(void) qos_add_test("edges-overflow", "ina230", test_edges_overflow, NULL); qos_add_test("alert-shunt-over", "ina230", test_alert_shunt_over, NULL= ); qos_add_test("alert-latch", "ina230", test_alert_latch, NULL); + qos_add_test("alert-latch-persist", "ina230", test_alert_latch_persist, + NULL); + qos_add_test("alert-latch-config", "ina230", test_alert_latch_config, + NULL); + qos_add_test("alert-latch-shutdown", "ina230", test_alert_latch_shutdo= wn, + NULL); + qos_add_test("alert-channel", "ina230", test_alert_channel, NULL); qos_add_test("alert-bus", "ina230", test_alert_bus, NULL); qos_add_test("alert-power", "ina230", test_alert_power, NULL); qos_add_test("cvrf", "ina230", test_cvrf, NULL); --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819192; cv=none; d=zohomail.com; s=zohoarc; b=jY6RYYMTnkOWhDK62sQZESBYiN+i3KKz+/R5vhQ5P3e0rHHyxXDSHqb954Ub6tJOx8jkGmmq+P5N7/yYporQVmBjEypm3SYJ9d18AnXkcND31Z3I4xqhfZGWhUsIKny4ZHeg9+P/uT3yoRL0/tVihQp7wzYpMoBusT1xHTpvYvQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819192; 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:Sender:Subject:Subject:To:To:Message-Id; bh=7JIouwvsYhybUqJx3bKqTjTPWbvwF34ZaZVav4+/RP8=; b=Phgjp0C4s5CVo10ECcm6JU4B4hefM0fxXhh8O4KNq44UByrOTkApPO6LTOZwFBWhZt/Kc6EpZwKb7N6zOrfauj+xuRLAbB99GTav7+3PtPUKABlGDeyo/6HByRO0cRj93AZLjFxVidbhNdm26EzVvnhHewTbnm0/vlM/+HlUBhE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791819192214875.274372641333; Mon, 12 Oct 2026 08:33:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGI1L-0006to-4A; Mon, 12 Oct 2026 11:33:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGI0s-0006i7-Vl for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:32:35 -0400 Received: from mail-wm1-f45.google.com ([209.85.128.45]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGI0p-0002jL-Ed for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:32:30 -0400 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4a018792ab3so17425165e9.0 for ; Mon, 12 Oct 2026 08:32:21 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0aaa9f9sm85865f8f.19.2026.10.12.08.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:32:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819141; x=1792423941; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7JIouwvsYhybUqJx3bKqTjTPWbvwF34ZaZVav4+/RP8=; b=HZ4pvob/KsGoHWb84v6kK31tbjuHv0NNfMzeeiV4i4v/E33fTy62REuF+D7YRNuM9f eedtsdin/2o3vkKTKNLRY099H4jmazXybk8kypENyWkOtDa/TFShhbCkjxXv+LjgMaIa vkHgvHgDiWBGE07/wRpXxaky9N0WkxgSTBNsYcZirNb2tcGrerx+IUbioNzWsbVmBwg0 ryXeXi+bhIVnQmqNxAI6tx4xpml02t70pTxxQz1My6bHXQLnpcuRdJeuPhfjghAMCUpY +hv/BmREtc7bmgZyvmv7bT7GrSI8B0gzkSDt5q6CU+Bwev689uopVKwbHFh26MeMtxBx Q5Zw== X-Gm-Message-State: AFq9FYJzC5JLRh+OY9/aJ8sdJ3aMUu9LHuMBoSfEBlVwzr01drC3NkE3 +qkRLOwFbNjXOFfOztTnnLujt95CMJ+9zM44niPVjancsdPh/YImjNHrbQXUmccH X-Gm-Gg: AYBFou3QlnRDL4c30Swa77u9jY3tdiyZXNPZfBPI6rLcZzCFL6SqCjkufcfKn0XNqg3 XHOoaoJD0T2mFdAYaUqcCoOt4zQ70mWeraSL8u98JUW9xlzDkMnAG3GzqYmZ2fo5EOvYIpIoghy 8dF4F116yO91Kr1Thc7AT/ANMlEBgTCZU7vem+ckfMODtn2tt6FjXbbw++7u7/MC0gBuVhs+xT0 uqniAG+LAAAEBsymV3oKqdo3Bj9Hs+0UztEkzDNG7JtQekpz2Oi6mxsnHf6rc0HRFnUPzBToRzb /fM6SMDt8MkCwH/4Lle6Willt8yL94L3aCetPV17fHuhaPdGZlhcAbrCBDCbIZ6GzE7DOlFjSXf Ar3LpTE3gPQ3c1K/oGYkwjSJLOD0xUdJ7huQ8chYv4OVjLRx64tnfEFs3fdMHzBHH6v4VGUefCp 0vPgwMiDikWoaEAaAPQo4NgyGyHzmTa8YvXvriKdmqg2mozIBuLp1C/n8kT0QGkX95h/8KPfIEl akl60M7ZiRwPuTpYSZ3aGxXqEw22/Qw+HVVgJYLklgHUg== X-Received: by 2002:a05:600c:3e0a:b0:4a0:1c10:1419 with SMTP id 5b1f17b1804b1-4a18e4cd667mr186910165e9.26.1791819140449; Mon, 12 Oct 2026 08:32:20 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:32 +0200 Subject: [PATCH v2 39/50] tests/qtest: ina230: cover a cleared calibration per channel MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-39-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=2259; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=GNmGo7bU7FZIBaUuYEeUYDpyrPaavNbXBkjimavlGKE=; b=YHHcAWAL+RN/mB2DoSS6parFIvowP00mb1BSSostYSkVZ3/SSqW4obiZgjD8l/BZpUp350YFr 5qNe/1wGWl7CDAUdOv5Dw5YM2jtNJeS4xjpTNnfdJwWiY7dOVIndjHS X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.45; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f45.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819193640158500 Verify that without a calibration value the current and power registers read zero, whichever channels the mode converts. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina230-test.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/qtest/ina230-test.c b/tests/qtest/ina230-test.c index 591927e551..5749b0bd46 100644 --- a/tests/qtest/ina230-test.c +++ b/tests/qtest/ina230-test.c @@ -301,6 +301,30 @@ static void test_zero_cal(void *obj, void *data, QGues= tAllocator *alloc) g_assert_cmphex(i2c_get16(dev, REG_POWER), =3D=3D, 0x0000); } =20 +/* Clearing the Calibration zeroes both derived registers in any mode */ +static void test_zero_cal_channels(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + static const uint8_t modes[] =3D { 0x5, 0x6, 0x7 }; + size_t idx; + + for (idx =3D 0; idx < ARRAY_SIZE(modes); idx++) { + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_CALIBRATION, 0x0A00); + qmp_ina230_set("shunt-voltage", 20000000); + qmp_ina230_set("bus-voltage", 11980000); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), !=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_POWER), !=3D, 0x0000); + + i2c_set16(dev, REG_CONFIG, modes[idx]); + i2c_set16(dev, REG_CALIBRATION, 0x0000); + + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_POWER), =3D=3D, 0x0000); + } +} + /* Clamping at full scale and the OVF (math overflow) flag */ static void test_edges_overflow(void *obj, void *data, QGuestAllocator *al= loc) { @@ -560,6 +584,7 @@ static void ina230_register_nodes(void) NULL); qos_add_test("power", "ina230", test_power, NULL); qos_add_test("zero-cal", "ina230", test_zero_cal, NULL); + qos_add_test("zero-cal-channels", "ina230", test_zero_cal_channels, NU= LL); qos_add_test("edges-overflow", "ina230", test_edges_overflow, NULL); qos_add_test("alert-shunt-over", "ina230", test_alert_shunt_over, NULL= ); qos_add_test("alert-latch", "ina230", test_alert_latch, NULL); --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819233; cv=none; d=zohomail.com; s=zohoarc; b=a2wG0psG6SduWVCbJ66OxgRsbu5QIhuWmAkNeuKtBELyqb2NlAlM1P5B8QmMGWfrbEDoui5LR9cQWIwl/4tErxe0lw5HOkYHYSyDi4iZFu5WtcRUdifALJNEkRQytIghK3vbihRRVi8ljIrtl5bgGSnzLK00R9BQsvrl7WcTTeQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819233; 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:Sender:Subject:Subject:To:To:Message-Id; bh=mjGFKEAlVLzPNd4DcWHnOsLf9aZieMbc6MXVHeHo+V8=; b=RPgmhAssoZHfRy7YBMQCgX4V3ecYomPolfVP7DDqs1Kiw6700eSUwxq1JHpf+bii6eeM3eB7MdKeRNGsnCHM9xZ51WTENAChSM+JxOSToBsU5z/tVf9UTSnM9doIzgSYYY3fY1B7U3nGMZfTzX7SY4nnok0JzBIRFQRRuLxe8mo= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791819233420584.1478444904081; Mon, 12 Oct 2026 08:33:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGI23-0007hO-R5; Mon, 12 Oct 2026 11:33:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGI1r-0007Zw-Vj for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:33:33 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGI1k-0002qk-1M for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:33:31 -0400 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4a168355946so17588375e9.0 for ; Mon, 12 Oct 2026 08:33:23 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a19f249692sm177555645e9.3.2026.10.12.08.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:33:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819202; x=1792424002; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mjGFKEAlVLzPNd4DcWHnOsLf9aZieMbc6MXVHeHo+V8=; b=B5QFFa+w9+UFAnxqOPe4bTZzjVq58feYPF6To9ODayWzkf0a6SPYMPr5Ur6MwYXpbe 6rzi+HCL+gmbak22W/9203kMtW+OY1451ut+1TCVWf6GqQkXxERrDEJIBQKgDpkT+LYW cOD9ndYnEIDMiuXvj6Va2bopChn6GH1UVQqlv9iyQQVAlCDIdrVYEqQwGSn1A/pHHY0o Usn6xD0J/GaJ6h8c7Ji3/8aReHo+8Bh9ShVPEh18L3obm3rexlk56tNw8X0WKceatW6g M6P7SzroraFanXsD5hiYQZ17xpLx7YIi/hCTQkfPHDsc2xQSHkb3gOPJPoLF1EHS15iU IQUw== X-Gm-Message-State: AFq9FYJwJMyNvWLK4+l8vR9hjCP9fbAKC/10aT28j/qOv1S2ua60SUVm sYo8O/32F67G0Ddv7G5XTtgMHFpUFOBkdqHsbCa6gbwWgD2I72OI1JYA66e8nO02 X-Gm-Gg: AYBFou3aSugWw5tKPI0heU35TKp/j8W3zx55tnCF9vz6f+FbC7hNsJLFFNRcucj5XfR WidJ6M0jb9Lxb/PsKLz2z7tNY1qhzXBDWkflGDGwoTz+FTynmbOK0xF+MIjRorEiglWcbe6qDI5 QZ2ZuE0pZrvWrLxSI6xSEiI9MstsFwfBjUyLjoyBtxjyQvGYGanzJUoEFSdoOW5sFdhCXYRePOA aCYu1MQb2N1i5DBiKQeM1HZcVHc4ASrB5jgHELuKWuAPUw73MdQT05eR/32l8X9UBmCcS3u9+Ni tPfm591xzXECyROZuR8oWDLxcIcM96KMk3Efs1s1y8Ro0lfFGw0e7g046i+BDCK39cAnwSCp1V6 ioRil4+ZsNpdzGMEBIiZ2qgEDWYqqvm0e5k0qTVItMAelMgrTvmK8XocaQkZPwKyAY16OW33DYr 8pjlaWXZ7zV78M6U6ENCoQVzzms3s6VmQfMi1MfEaylb0cv9lxI9Za7diGFiceEF+7lmO3loUCO VHAXP5uP3EtsmEVtlQHd2EdlXDF2KRWDU2X/RlvIWFhHA== X-Received: by 2002:a05:600c:354a:b0:49c:d019:70c5 with SMTP id 5b1f17b1804b1-4a18e3ef23cmr182027335e9.0.1791819201825; Mon, 12 Oct 2026 08:33:21 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:33 +0200 Subject: [PATCH v2 40/50] hw/sensor: ina238: add current/voltage/power monitor MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-40-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=32726; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=LJkZjiZ4MSIrSyhGbPncYC/Wh4N+s4AppQ7czCKz7Kk=; b=lD8rVNSvDTdTmYmRDS10J9E4aXZBP1PtEqoj/jm2a7bAVTXqvD7+OeSpUA6W80e+drph/Wxed KzpzLqGdAvjDlcKohz5zEb1ghk5pFzjOQevxUhQIt73aULyeowEYjBj X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.42; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f42.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819234267158500 Add a model for the Texas Instruments INA238, an 85V, 16-bit I2C current-shunt, power and temperature monitor. The device measures a differential shunt voltage, a bus voltage and its own die temperature; the current and power registers are not measured directly but derived by the device from the shunt voltage and the guest-programmed Shunt Calibration register. The alert is modelled. Shunt and bus voltages and the die temperature can be injected through the "shunt-voltage", "bus-voltage" and "die-temperature" QOM properties. Note: Conversion is instantaneous: the averaging and conversion-time fields are stored but have no timing effect. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- hw/arm/Kconfig | 1 + hw/sensor/Kconfig | 4 + hw/sensor/ina238.c | 802 +++++++++++++++++++++++++++++++++++++++++= ++++ hw/sensor/meson.build | 1 + hw/sensor/trace-events | 7 + include/hw/sensor/ina238.h | 14 + 6 files changed, 829 insertions(+) diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 116d1c64ac..3abe249ed5 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -540,6 +540,7 @@ config ASPEED_SOC select TMP421 select EMC141X select INA230 + select INA238 select OR_IRQ select UNIMP select LED diff --git a/hw/sensor/Kconfig b/hw/sensor/Kconfig index da519159ac..9b7c76fcf5 100644 --- a/hw/sensor/Kconfig +++ b/hw/sensor/Kconfig @@ -6,6 +6,10 @@ config INA230 bool depends on I2C =20 +config INA238 + bool + depends on I2C + config TMP105 bool depends on I2C diff --git a/hw/sensor/ina238.c b/hw/sensor/ina238.c new file mode 100644 index 0000000000..e4033771b0 --- /dev/null +++ b/hw/sensor/ina238.c @@ -0,0 +1,802 @@ +/* + * Texas Instruments INA238 85V, 16-bit current/voltage/power monitor + * with an I2C interface. + * + * Copyright (c) 2026 Meta Platforms, Inc. and affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * The INA238 measures a differential shunt voltage, a bus voltage and its= own + * die temperature. Current and power are not measured directly: they are + * derived by the device from the measured shunt voltage and the programma= ble + * Shunt Calibration register. The INA238 exposes six independent limit + * registers, all monitored simultaneously (multi-alert), a die-temperature + * sensor, a 24-bit power register and an ADCRANGE-dependent shunt LSB. + * + * Limitations (not modelled): + * - Conversion timing is instantaneous. Conversions run synchronously whe= n an + * input, the calibration, the ADC range or the ADC configuration change= s; the + * ADC conversion times (VBUSCT/VSHCT/VTCT), the averaging count (AVG) a= nd the + * CONVDLY start delay are not modelled, and continuous mode does not + * re-convert on a timer. A read always returns the value derived from t= he + * current inputs and CNVRF is set once a conversion has run. + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qapi/error.h" +#include "qapi/visitor.h" +#include "qom/object.h" +#include "hw/sensor/ina238.h" +#include "hw/core/irq.h" +#include "hw/core/qdev-properties.h" +#include "hw/core/registerfields.h" +#include "hw/i2c/i2c.h" +#include "migration/vmstate.h" +#include "trace.h" + +#define INA238_REG_CONFIG 0x00 +#define INA238_REG_ADC_CONFIG 0x01 +#define INA238_REG_SHUNT_CAL 0x02 +#define INA238_REG_VSHUNT 0x04 +#define INA238_REG_VBUS 0x05 +#define INA238_REG_DIETEMP 0x06 +#define INA238_REG_CURRENT 0x07 +#define INA238_REG_POWER 0x08 +#define INA238_REG_DIAG_ALRT 0x0B +#define INA238_REG_SOVL 0x0C +#define INA238_REG_SUVL 0x0D +#define INA238_REG_BOVL 0x0E +#define INA238_REG_BUVL 0x0F +#define INA238_REG_TEMP_LIMIT 0x10 +#define INA238_REG_PWR_LIMIT 0x11 +#define INA238_REG_MANUFACTURER_ID 0x3E +#define INA238_REG_DEVICE_ID 0x3F + +FIELD(INA238_CONFIG, ADCRANGE, 4, 1) +FIELD(INA238_CONFIG, CONVDLY, 6, 8) +FIELD(INA238_CONFIG, RST, 15, 1) + +#define INA238_CONFIG_POR 0x0000 +#define INA238_CONFIG_WMASK (R_INA238_CONFIG_ADCRANGE_MASK | \ + R_INA238_CONFIG_CONVDLY_MASK) + +FIELD(INA238_ADC_CONFIG, AVG, 0, 3) +FIELD(INA238_ADC_CONFIG, VTCT, 3, 3) +FIELD(INA238_ADC_CONFIG, VSHCT, 6, 3) +FIELD(INA238_ADC_CONFIG, VBUSCT, 9, 3) +FIELD(INA238_ADC_CONFIG, MODE, 12, 4) + +#define INA238_ADC_CONFIG_POR 0xFB68 + +#define INA238_SHUNT_CAL_POR 0x1000 +#define INA238_SHUNT_CAL_MASK 0x7FFF /* bit 15 reserved */ + +FIELD(INA238_DIAG_ALRT, MEMSTAT, 0, 1) /* memory checksum ok (always 1)= */ +FIELD(INA238_DIAG_ALRT, CNVRF, 1, 1) /* conversion ready flag */ +FIELD(INA238_DIAG_ALRT, POL, 2, 1) /* power over-limit */ +FIELD(INA238_DIAG_ALRT, BUSUL, 3, 1) /* bus under-limit */ +FIELD(INA238_DIAG_ALRT, BUSOL, 4, 1) /* bus over-limit */ +FIELD(INA238_DIAG_ALRT, SHNTUL, 5, 1) /* shunt under-limit */ +FIELD(INA238_DIAG_ALRT, SHNTOL, 6, 1) /* shunt over-limit */ +FIELD(INA238_DIAG_ALRT, TMPOL, 7, 1) /* over temperature */ +FIELD(INA238_DIAG_ALRT, MATHOF, 9, 1) /* arithmetic overflow */ +FIELD(INA238_DIAG_ALRT, APOL, 12, 1) /* alert polarity */ +FIELD(INA238_DIAG_ALRT, SLOWALERT, 13, 1) /* alert on averaged value */ +FIELD(INA238_DIAG_ALRT, CNVR, 14, 1) /* conversion-ready on ALERT pin= */ +FIELD(INA238_DIAG_ALRT, ALATCH, 15, 1) /* alert latch enable */ + +#define INA238_DIAG_ALRT_POR 0x0001 /* MEMSTAT =3D 1 */ + +/* Control (writable) bits */ +#define INA238_DIAG_CTRL_MASK (R_INA238_DIAG_ALRT_ALATCH_MASK | \ + R_INA238_DIAG_ALRT_CNVR_MASK | \ + R_INA238_DIAG_ALRT_SLOWALERT_MASK | \ + R_INA238_DIAG_ALRT_APOL_MASK) +/* Read-only status bits (preserved across a control-bit write) */ +#define INA238_DIAG_STATUS_MASK (R_INA238_DIAG_ALRT_MATHOF_MASK | \ + R_INA238_DIAG_ALRT_TMPOL_MASK | \ + R_INA238_DIAG_ALRT_SHNTOL_MASK | \ + R_INA238_DIAG_ALRT_SHNTUL_MASK | \ + R_INA238_DIAG_ALRT_BUSOL_MASK | \ + R_INA238_DIAG_ALRT_BUSUL_MASK | \ + R_INA238_DIAG_ALRT_POL_MASK | \ + R_INA238_DIAG_ALRT_CNVRF_MASK | \ + R_INA238_DIAG_ALRT_MEMSTAT_MASK) +/* Threshold flags cleared when the DIAG_ALRT register is read */ +#define INA238_DIAG_LATCH_MASK (R_INA238_DIAG_ALRT_TMPOL_MASK | \ + R_INA238_DIAG_ALRT_SHNTOL_MASK | \ + R_INA238_DIAG_ALRT_SHNTUL_MASK | \ + R_INA238_DIAG_ALRT_BUSOL_MASK | \ + R_INA238_DIAG_ALRT_BUSUL_MASK | \ + R_INA238_DIAG_ALRT_POL_MASK) + +#define INA238_SOVL_POR 0x7FFF +#define INA238_SUVL_POR 0x8000 +#define INA238_BOVL_POR 0x7FFF +#define INA238_BUVL_POR 0x0000 +/* + * The datasheet is self-inconsistent on the TEMP_LIMIT reset value. + * Writes mask with INA238_TEMP_LIMIT_MASK and the alert comparison shifts= both + * operands >>4. + */ +#define INA238_TEMP_LIMIT_POR 0x7FF0 +#define INA238_PWR_LIMIT_POR 0xFFFF + +#define INA238_BUS_LIMIT_MASK 0x7FFF /* BOVL/BUVL are 15-bit, positiv= e */ +#define INA238_TEMP_LIMIT_MASK 0xFFF0 /* TOL occupies bits [15:4] */ + +#define INA238_MANUFACTURER_ID_VAL 0x5449 /* "TI" */ +#define INA238_DEVICE_ID_VAL 0x2381 /* DIEID 0x238, REV 0x1 */ + +/* Shunt voltage LSB depends on ADCRANGE; bus and temperature are fixed */ +#define INA238_SHUNT_LSB_NV_R0 5000 /* 5 uV per LSB (ADCRANGE =3D 0) = */ +#define INA238_SHUNT_LSB_NV_R1 1250 /* 1.25 uV per LSB (ADCRANGE =3D = 1) */ +#define INA238_BUS_LSB_UV 3125 /* 3.125 mV per LSB */ +#define INA238_TEMP_LSB_MC 125 /* 125 m-degC per LSB */ + +/* + * current =3D shunt_reg * K / SHUNT_CAL. K derives from the fixed 819.2e6 + * internal constant and the ADCRANGE=3D0 shunt LSB: 5e-6 * 819.2e6 =3D 40= 96. + * power =3D current * bus / 64 (0.2 / 3.125mV expressed in the register d= omain). + */ +#define INA238_CURRENT_K 4096 +#define INA238_POWER_DIV 64 +#define INA238_POWER_MAX 0xFFFFFF /* POWER is a 24-bit register */ + +/* Injection property ranges */ +#define INA238_SHUNT_MIN_NV (-163840000) /* -32768 * 5 uV */ +#define INA238_SHUNT_MAX_NV 163835000 /* 32767 * 5 uV */ +#define INA238_BUS_MAX_UV 85000000 /* 85 V full common-mode ra= nge */ +#define INA238_TEMP_MIN_MC (-40000) /* package limited */ +#define INA238_TEMP_MAX_MC 125000 + +OBJECT_DECLARE_SIMPLE_TYPE(INA238State, INA238) + +struct INA238State { + I2CSlave parent_obj; + + qemu_irq alert; /* ALERT open-drain output */ + + /* I2C transfer state */ + uint8_t ptr; /* register pointer */ + uint8_t len; /* bytes received in current transfer */ + uint8_t wr_hi; /* pending write MSB */ + uint8_t rx_byte; /* index of the next byte to return within rx_val */ + uint8_t rx_width; /* width in bytes of the register being read (2 or 3= ) */ + uint32_t rx_val; /* value latched at the start of a read */ + + /* Register file */ + uint16_t config; + uint16_t adc_config; + uint16_t shunt_cal; + uint16_t diag_alrt; + uint16_t sovl; + uint16_t suvl; + uint16_t bovl; + uint16_t buvl; + uint16_t temp_limit; + uint16_t pwr_limit; + + /* Derived measurement registers */ + uint16_t shunt_reg; + uint16_t bus_reg; + uint16_t dietemp_reg; + uint16_t current_reg; + uint32_t power_reg; /* 24-bit */ + + /* Injected physical inputs */ + int32_t shunt_nv; /* shunt voltage, nanovolts (signed: bidirectional)= */ + uint32_t bus_uv; /* bus voltage, microvolts (never negative) */ + int32_t temp_mc; /* die temperature, millidegrees Celsius (signed) */ + + char *description; +}; + +/* + * Update the _field_ limit flag in _diag_ from the current comparison _co= nd_. + * In latch mode (_latch_) a flag that is already set stays set until the + * register is read; in transparent mode it tracks _cond_ directly. A flag + * whose measurement register was not refreshed (_fresh_) keeps its value. + */ +#define INA238_UPD_FLAG(_diag_, _latch_, _fresh_, _field_, _cond_) = \ + do { = \ + if (_fresh_) { = \ + uint16_t _old_ =3D FIELD_EX16(_diag_, INA238_DIAG_ALRT, _field= _); \ + uint16_t _new_ =3D (uint16_t)((_cond_) || ((_latch_) && _old_)= ); \ + (_diag_) =3D FIELD_DP16(_diag_, INA238_DIAG_ALRT, _field_, _ne= w_); \ + } = \ + } while (0) + +static void ina238_refresh_alert(INA238State *s) +{ + uint16_t diag =3D s->diag_alrt; + bool active; + bool cnvr; + int level; + + /* MATHOF is a diagnostic; it does not drive the ALERT pin. */ + active =3D FIELD_EX16(diag, INA238_DIAG_ALRT, SHNTOL) || + FIELD_EX16(diag, INA238_DIAG_ALRT, SHNTUL) || + FIELD_EX16(diag, INA238_DIAG_ALRT, BUSOL) || + FIELD_EX16(diag, INA238_DIAG_ALRT, BUSUL) || + FIELD_EX16(diag, INA238_DIAG_ALRT, TMPOL) || + FIELD_EX16(diag, INA238_DIAG_ALRT, POL); + + cnvr =3D FIELD_EX16(diag, INA238_DIAG_ALRT, CNVR) && + FIELD_EX16(diag, INA238_DIAG_ALRT, CNVRF); + + active =3D active || cnvr; + /* APOL: 0 =3D active-low (default), 1 =3D active-high */ + level =3D FIELD_EX16(diag, INA238_DIAG_ALRT, APOL) ? active : !active; + + trace_ina238_alert(s->description, level); + qemu_set_irq(s->alert, level); +} + +/* + * @shunt_fresh, @bus_fresh and @temp_fresh tell which measurement registe= rs + * hold a fresh value: after a partial conversion the flags fed by the oth= er + * channels must not be re-evaluated against their stale registers. + */ +static void ina238_update_alert(INA238State *s, bool shunt_fresh, + bool bus_fresh, bool temp_fresh, + bool power_fresh) +{ + bool latch =3D FIELD_EX16(s->diag_alrt, INA238_DIAG_ALRT, ALATCH); + int16_t shunt =3D (int16_t)s->shunt_reg; + int16_t temp =3D (int16_t)s->dietemp_reg >> 4; /* sign-extend [15= :4] */ + int16_t temp_lim =3D (int16_t)s->temp_limit >> 4; + uint16_t diag =3D s->diag_alrt; + + INA238_UPD_FLAG(diag, latch, shunt_fresh, SHNTOL, shunt > (int16_t)s->= sovl); + INA238_UPD_FLAG(diag, latch, shunt_fresh, SHNTUL, shunt < (int16_t)s->= suvl); + INA238_UPD_FLAG(diag, latch, bus_fresh, BUSOL, + s->bus_reg > (s->bovl & INA238_BUS_LIMIT_MASK)); + INA238_UPD_FLAG(diag, latch, bus_fresh, BUSUL, + s->bus_reg < (s->buvl & INA238_BUS_LIMIT_MASK)); + INA238_UPD_FLAG(diag, latch, temp_fresh, TMPOL, temp > temp_lim); + INA238_UPD_FLAG(diag, latch, power_fresh, POL, + s->power_reg > ((uint32_t)s->pwr_limit << 8)); + + s->diag_alrt =3D diag; + + ina238_refresh_alert(s); +} + +static void ina238_convert(INA238State *s) +{ + uint8_t mode =3D FIELD_EX16(s->adc_config, INA238_ADC_CONFIG, MODE); + bool bus_en =3D mode & 0x1; + bool shunt_en =3D mode & 0x2; + bool temp_en =3D mode & 0x4; + bool adcrange =3D FIELD_EX16(s->config, INA238_CONFIG, ADCRANGE); + int shunt_lsb =3D adcrange ? INA238_SHUNT_LSB_NV_R1 : INA238_SHUNT_LSB= _NV_R0; + int64_t sr, br, tr, cur, pwr; + uint16_t mathof =3D 0; + bool power_fresh =3D bus_en; + + if (!bus_en && !shunt_en && !temp_en) { + return; + } + + if (shunt_en) { + sr =3D s->shunt_nv / shunt_lsb; + sr =3D MAX(INT16_MIN, MIN(INT16_MAX, sr)); + s->shunt_reg =3D (uint16_t)(int16_t)sr; + + if (s->shunt_cal =3D=3D 0) { + cur =3D 0; + } else { + cur =3D (int64_t)(int16_t)s->shunt_reg * INA238_CURRENT_K / + s->shunt_cal; + } + if (cur > INT16_MAX || cur < INT16_MIN) { + mathof =3D 1; + cur =3D MAX(INT16_MIN, MIN(INT16_MAX, cur)); + } + s->current_reg =3D (uint16_t)(int16_t)cur; + } + + if (bus_en) { + br =3D s->bus_uv / INA238_BUS_LSB_UV; + br =3D MAX(0, MIN(INT16_MAX, br)); + s->bus_reg =3D (uint16_t)br; + } + + if (temp_en) { + /* Die temperature: 12-bit signed value stored in bits [15:4] */ + tr =3D s->temp_mc / INA238_TEMP_LSB_MC; + tr =3D MAX(-2048, MIN(2047, tr)); + s->dietemp_reg =3D ((uint16_t)(int16_t)tr << 4) & INA238_TEMP_LIMI= T_MASK; + } + + /* + * In bus-only mode the current register is retained from the last shu= nt + * conversion rather than measured anew, but the power register is sti= ll + * refreshed. + */ + if (bus_en) { + cur =3D (int16_t)s->current_reg; + if (cur < 0) { + cur =3D -cur; + } + pwr =3D cur * (int64_t)s->bus_reg / INA238_POWER_DIV; + if (pwr > INA238_POWER_MAX) { + mathof =3D 1; + pwr =3D INA238_POWER_MAX; + } + s->power_reg =3D (uint32_t)pwr; + } + + /* Without a calibration the device reports neither current nor power.= */ + if (s->shunt_cal =3D=3D 0) { + s->current_reg =3D 0; + s->power_reg =3D 0; + power_fresh =3D true; + } + + s->diag_alrt =3D FIELD_DP16(s->diag_alrt, INA238_DIAG_ALRT, MATHOF, ma= thof); + s->diag_alrt =3D FIELD_DP16(s->diag_alrt, INA238_DIAG_ALRT, CNVRF, 1); + + trace_ina238_convert(s->description, s->shunt_reg, s->bus_reg, + s->dietemp_reg, s->current_reg, s->power_reg); + + ina238_update_alert(s, shunt_en, bus_en, temp_en, power_fresh); +} + +/* + * A physical input, the calibration or the ADC range changed. + * - in continuous mode the device keeps converting and immediately tracks + * the new value + * - in a triggered mode it performs exactly one conversion per trigger + */ +static void ina238_input_update(INA238State *s) +{ + if (FIELD_EX16(s->adc_config, INA238_ADC_CONFIG, MODE) & 0x8) { + ina238_convert(s); + } +} + +static void ina238_reset_regs(INA238State *s) +{ + s->config =3D INA238_CONFIG_POR; + s->adc_config =3D INA238_ADC_CONFIG_POR; + s->shunt_cal =3D INA238_SHUNT_CAL_POR; + s->diag_alrt =3D INA238_DIAG_ALRT_POR; + s->sovl =3D INA238_SOVL_POR; + s->suvl =3D INA238_SUVL_POR; + s->bovl =3D INA238_BOVL_POR; + s->buvl =3D INA238_BUVL_POR; + s->temp_limit =3D INA238_TEMP_LIMIT_POR; + s->pwr_limit =3D INA238_PWR_LIMIT_POR; + + s->ptr =3D 0; + s->len =3D 0; + s->wr_hi =3D 0; + s->rx_byte =3D 0; + s->rx_width =3D 0; + s->rx_val =3D 0; + + /* + * The measurement registers power up at zero and stay zero until the = next + * conversion. The injected physical inputs are retained, but no conve= rsion + * is performed here, so a software reset does not resurrect a previous + * measurement. + */ + s->shunt_reg =3D 0; + s->bus_reg =3D 0; + s->dietemp_reg =3D 0; + s->current_reg =3D 0; + s->power_reg =3D 0; + + ina238_update_alert(s, true, true, true, true); +} + +static uint32_t ina238_read_reg(INA238State *s, uint8_t reg) +{ + uint32_t val; + + switch (reg) { + case INA238_REG_CONFIG: + val =3D s->config; + break; + case INA238_REG_ADC_CONFIG: + val =3D s->adc_config; + break; + case INA238_REG_SHUNT_CAL: + val =3D s->shunt_cal; + break; + case INA238_REG_VSHUNT: + val =3D s->shunt_reg; + break; + case INA238_REG_VBUS: + val =3D s->bus_reg; + break; + case INA238_REG_DIETEMP: + val =3D s->dietemp_reg; + break; + case INA238_REG_CURRENT: + val =3D s->current_reg; + break; + case INA238_REG_POWER: + val =3D s->power_reg; + break; + case INA238_REG_DIAG_ALRT: + val =3D s->diag_alrt; + /* + * A read always clears CNVRF; the latched limit flags clear too, = but + * only in latch mode. + */ + s->diag_alrt &=3D ~R_INA238_DIAG_ALRT_CNVRF_MASK; + if (FIELD_EX16(s->diag_alrt, INA238_DIAG_ALRT, ALATCH)) { + s->diag_alrt &=3D ~INA238_DIAG_LATCH_MASK; + } + ina238_refresh_alert(s); + break; + case INA238_REG_SOVL: + val =3D s->sovl; + break; + case INA238_REG_SUVL: + val =3D s->suvl; + break; + case INA238_REG_BOVL: + val =3D s->bovl; + break; + case INA238_REG_BUVL: + val =3D s->buvl; + break; + case INA238_REG_TEMP_LIMIT: + val =3D s->temp_limit; + break; + case INA238_REG_PWR_LIMIT: + val =3D s->pwr_limit; + break; + case INA238_REG_MANUFACTURER_ID: + val =3D INA238_MANUFACTURER_ID_VAL; + break; + case INA238_REG_DEVICE_ID: + val =3D INA238_DEVICE_ID_VAL; + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: %s: read from undefined register 0x%02x\n", + __func__, s->description, reg); + val =3D 0; + break; + } + + trace_ina238_read(s->description, reg, val); + return val; +} + +static void ina238_write_reg(INA238State *s, uint8_t reg, uint16_t val) +{ + trace_ina238_write(s->description, reg, val); + + switch (reg) { + case INA238_REG_CONFIG: + if (val & R_INA238_CONFIG_RST_MASK) { + trace_ina238_reset(s->description, "reg"); + ina238_reset_regs(s); + break; + } + s->config =3D val & INA238_CONFIG_WMASK; + ina238_input_update(s); + break; + case INA238_REG_ADC_CONFIG: + s->adc_config =3D val; + /* Writing the MODE bits (re)starts a conversion: it is the trigge= r. */ + ina238_convert(s); + break; + case INA238_REG_SHUNT_CAL: + s->shunt_cal =3D val & INA238_SHUNT_CAL_MASK; + ina238_input_update(s); + break; + case INA238_REG_DIAG_ALRT: { + uint16_t status =3D s->diag_alrt & INA238_DIAG_STATUS_MASK; + /* + * In latch mode a write clears the latched limit flags and the + * conversion-ready flag. In transparent mode the flags track the = live + * condition and are preserved. The pin is only refreshed, so a cl= eared + * flag re-asserts on the next conversion rather than immediately. + */ + if (FIELD_EX16(s->diag_alrt, INA238_DIAG_ALRT, ALATCH)) { + status &=3D ~(R_INA238_DIAG_ALRT_CNVRF_MASK | INA238_DIAG_LATC= H_MASK); + } + s->diag_alrt =3D (val & INA238_DIAG_CTRL_MASK) | status; + ina238_refresh_alert(s); + break; + } + case INA238_REG_SOVL: + s->sovl =3D val; + ina238_update_alert(s, true, true, true, true); + break; + case INA238_REG_SUVL: + s->suvl =3D val; + ina238_update_alert(s, true, true, true, true); + break; + case INA238_REG_BOVL: + s->bovl =3D val & INA238_BUS_LIMIT_MASK; + ina238_update_alert(s, true, true, true, true); + break; + case INA238_REG_BUVL: + s->buvl =3D val & INA238_BUS_LIMIT_MASK; + ina238_update_alert(s, true, true, true, true); + break; + case INA238_REG_TEMP_LIMIT: + s->temp_limit =3D val & INA238_TEMP_LIMIT_MASK; + ina238_update_alert(s, true, true, true, true); + break; + case INA238_REG_PWR_LIMIT: + s->pwr_limit =3D val; + ina238_update_alert(s, true, true, true, true); + break; + case INA238_REG_VSHUNT: + case INA238_REG_VBUS: + case INA238_REG_DIETEMP: + case INA238_REG_CURRENT: + case INA238_REG_POWER: + case INA238_REG_MANUFACTURER_ID: + case INA238_REG_DEVICE_ID: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: %s: write to read-only register 0x%02x\n", + __func__, s->description, reg); + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: %s: write to undefined register 0x%02x\n", + __func__, s->description, reg); + break; + } +} + +static uint8_t ina238_recv(I2CSlave *i2c) +{ + INA238State *s =3D INA238(i2c); + uint8_t byte; + + if (s->rx_byte =3D=3D 0) { + s->rx_val =3D ina238_read_reg(s, s->ptr); + s->rx_width =3D (s->ptr =3D=3D INA238_REG_POWER) ? 3 : 2; + } + + byte =3D (s->rx_val >> (8 * (s->rx_width - 1 - s->rx_byte))) & 0xff; + s->rx_byte++; + if (s->rx_byte >=3D s->rx_width) { + s->rx_byte =3D 0; + } + + return byte; +} + +static int ina238_send(I2CSlave *i2c, uint8_t data) +{ + INA238State *s =3D INA238(i2c); + + if (s->len =3D=3D 0) { + s->ptr =3D data; + } else if ((s->len & 1) =3D=3D 1) { + s->wr_hi =3D data; + } else { + ina238_write_reg(s, s->ptr, ((uint16_t)s->wr_hi << 8) | data); + } + s->len++; + + return 0; +} + +static int ina238_event(I2CSlave *i2c, enum i2c_event event) +{ + INA238State *s =3D INA238(i2c); + + s->len =3D 0; + s->rx_byte =3D 0; + + return 0; +} + +static void ina238_get_shunt(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + INA238State *s =3D INA238(obj); + int64_t value =3D s->shunt_nv; + + visit_type_int(v, name, &value, errp); +} + +static void ina238_set_shunt(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + INA238State *s =3D INA238(obj); + int64_t value; + + if (!visit_type_int(v, name, &value, errp)) { + return; + } + + if (value < INA238_SHUNT_MIN_NV || value > INA238_SHUNT_MAX_NV) { + error_setg(errp, + "%s: shunt-voltage %" PRId64 " out of range (%d..%d nV)= ", + s->description, value, + INA238_SHUNT_MIN_NV, INA238_SHUNT_MAX_NV); + return; + } + + s->shunt_nv =3D (int32_t)value; + ina238_input_update(s); +} + +static void ina238_get_bus(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + INA238State *s =3D INA238(obj); + int64_t value =3D s->bus_uv; + + visit_type_int(v, name, &value, errp); +} + +static void ina238_set_bus(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + INA238State *s =3D INA238(obj); + int64_t value; + + if (!visit_type_int(v, name, &value, errp)) { + return; + } + + if (value < 0 || value > INA238_BUS_MAX_UV) { + error_setg(errp, + "%s: bus-voltage %" PRId64 " out of range (0..%d uV)", + s->description, value, INA238_BUS_MAX_UV); + return; + } + + s->bus_uv =3D (uint32_t)value; + ina238_input_update(s); +} + +static void ina238_get_temp(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + INA238State *s =3D INA238(obj); + int64_t value =3D s->temp_mc; + + visit_type_int(v, name, &value, errp); +} + +static void ina238_set_temp(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + INA238State *s =3D INA238(obj); + int64_t value; + + if (!visit_type_int(v, name, &value, errp)) { + return; + } + + if (value < INA238_TEMP_MIN_MC || value > INA238_TEMP_MAX_MC) { + error_setg(errp, + "%s: die-temperature %" PRId64 + " out of range (%d..%d m-degC)", + s->description, value, + INA238_TEMP_MIN_MC, INA238_TEMP_MAX_MC); + return; + } + + s->temp_mc =3D (int32_t)value; + ina238_input_update(s); +} + +static void ina238_reset_hold(Object *obj, ResetType type) +{ + INA238State *s =3D INA238(obj); + + trace_ina238_reset(s->description, "hw"); + ina238_reset_regs(s); +} + +static int ina238_post_load(void *opaque, int version_id) +{ + INA238State *s =3D opaque; + + ina238_refresh_alert(s); + + return 0; +} + +static const VMStateDescription ina238_vmstate =3D { + .name =3D "INA238", + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load =3D ina238_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT8(ptr, INA238State), + VMSTATE_UINT8(len, INA238State), + VMSTATE_UINT8(wr_hi, INA238State), + VMSTATE_UINT8(rx_byte, INA238State), + VMSTATE_UINT8(rx_width, INA238State), + VMSTATE_UINT32(rx_val, INA238State), + VMSTATE_UINT16(config, INA238State), + VMSTATE_UINT16(adc_config, INA238State), + VMSTATE_UINT16(shunt_cal, INA238State), + VMSTATE_UINT16(diag_alrt, INA238State), + VMSTATE_UINT16(sovl, INA238State), + VMSTATE_UINT16(suvl, INA238State), + VMSTATE_UINT16(bovl, INA238State), + VMSTATE_UINT16(buvl, INA238State), + VMSTATE_UINT16(temp_limit, INA238State), + VMSTATE_UINT16(pwr_limit, INA238State), + VMSTATE_UINT16(shunt_reg, INA238State), + VMSTATE_UINT16(bus_reg, INA238State), + VMSTATE_UINT16(dietemp_reg, INA238State), + VMSTATE_UINT16(current_reg, INA238State), + VMSTATE_UINT32(power_reg, INA238State), + VMSTATE_INT32(shunt_nv, INA238State), + VMSTATE_UINT32(bus_uv, INA238State), + VMSTATE_INT32(temp_mc, INA238State), + VMSTATE_I2C_SLAVE(parent_obj, INA238State), + VMSTATE_END_OF_LIST() + } +}; + +static void ina238_initfn(Object *obj) +{ + object_property_add(obj, "shunt-voltage", "int", ina238_get_shunt, + ina238_set_shunt, NULL, NULL); + object_property_set_description(obj, "shunt-voltage", + "Injected shunt (differential) voltage= , " + "in nanovolts"); + object_property_add(obj, "bus-voltage", "int", ina238_get_bus, + ina238_set_bus, NULL, NULL); + object_property_set_description(obj, "bus-voltage", + "Injected bus voltage, in microvolts"); + object_property_add(obj, "die-temperature", "int", ina238_get_temp, + ina238_set_temp, NULL, NULL); + object_property_set_description(obj, "die-temperature", + "Injected die temperature, " + "in millidegrees Celsius"); +} + +static void ina238_realize(DeviceState *dev, Error **errp) +{ + INA238State *s =3D INA238(dev); + + if (!s->description) { + s->description =3D g_strdup(object_get_typename(OBJECT(dev))); + } + + qdev_init_gpio_out(dev, &s->alert, 1); +} + +static const Property ina238_properties[] =3D { + DEFINE_PROP_STRING("description", INA238State, description), +}; + +static void ina238_class_init(ObjectClass *klass, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + I2CSlaveClass *ic =3D I2C_SLAVE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + + ic->event =3D ina238_event; + ic->recv =3D ina238_recv; + ic->send =3D ina238_send; + dc->realize =3D ina238_realize; + rc->phases.hold =3D ina238_reset_hold; + dc->vmsd =3D &ina238_vmstate; + device_class_set_props(dc, ina238_properties); +} + +static const TypeInfo ina238_types[] =3D { + { + .name =3D TYPE_INA238, + .parent =3D TYPE_I2C_SLAVE, + .instance_init =3D ina238_initfn, + .instance_size =3D sizeof(INA238State), + .class_init =3D ina238_class_init, + }, +}; + +DEFINE_TYPES(ina238_types) diff --git a/hw/sensor/meson.build b/hw/sensor/meson.build index b81f001fdf..7e6fd64488 100644 --- a/hw/sensor/meson.build +++ b/hw/sensor/meson.build @@ -1,5 +1,6 @@ system_ss.add(when: 'CONFIG_ADC128D818', if_true: files('adc128d818.c')) system_ss.add(when: 'CONFIG_INA230', if_true: files('ina230.c')) +system_ss.add(when: 'CONFIG_INA238', if_true: files('ina238.c')) system_ss.add(when: 'CONFIG_TMP105', if_true: files('tmp105.c')) system_ss.add(when: 'CONFIG_TMP421', if_true: files('tmp421.c')) system_ss.add(when: 'CONFIG_DPS310', if_true: files('dps310.c')) diff --git a/hw/sensor/trace-events b/hw/sensor/trace-events index f809b6b506..98158e37c6 100644 --- a/hw/sensor/trace-events +++ b/hw/sensor/trace-events @@ -15,6 +15,13 @@ ina230_convert(const char *id, uint16_t shunt, uint16_t = bus, uint16_t current, u ina230_alert(const char *id, bool level) "%s level %u" ina230_reset(const char *id, const char *source) "%s %s" =20 +# ina238.c +ina238_read(const char *id, uint8_t reg, uint32_t value) "%s reg 0x%02x va= l 0x%06x" +ina238_write(const char *id, uint8_t reg, uint16_t value) "%s reg 0x%02x v= al 0x%04x" +ina238_convert(const char *id, uint16_t shunt, uint16_t bus, uint16_t diet= emp, uint16_t current, uint32_t power) "%s shunt 0x%04x bus 0x%04x dietemp = 0x%04x current 0x%04x power 0x%06x" +ina238_alert(const char *id, bool level) "%s level %u" +ina238_reset(const char *id, const char *source) "%s %s" + # tmp105.c tmp105_read(uint8_t dev, uint8_t addr) "device: 0x%02x, addr: 0x%02x" tmp105_write(uint8_t dev, uint8_t addr) "device: 0x%02x, addr 0x%02x" diff --git a/include/hw/sensor/ina238.h b/include/hw/sensor/ina238.h new file mode 100644 index 0000000000..3bc3c02073 --- /dev/null +++ b/include/hw/sensor/ina238.h @@ -0,0 +1,14 @@ +/* + * Texas Instruments INA238 current/voltage/power monitor with I2C interfa= ce + * + * Copyright (c) 2026 Meta Platforms, Inc. and affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_SENSOR_INA238_H +#define HW_SENSOR_INA238_H + +#define TYPE_INA238 "ina238" + +#endif --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819273; cv=none; d=zohomail.com; s=zohoarc; b=iDcad3oAEHnRel6sZcP3/zL0n7SN/vr2iU78oVX9JpaGXLjNEt4eu4F+VwrllUrQ/oWrQPwiVJ9C9xbWv3VmAh7yX0RIz17w2HFxqlEejWynikmJAY9NX0e5R3ejw+qjQFu9lThh5x2OE6n+PtmuwkTBRzK7bjh4tWhiyJcTDVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819273; 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:Sender:Subject:Subject:To:To:Message-Id; bh=9m6xeuXDGuPCKQgTcqEoBMjzYqVoeLEW2xyy05z+8Wk=; b=jQ9V2e/LnVdwc3vH1uG4eWeF81ZZc6r0daP9z11FEP1GKu/uE8Q3qXuBWFNHMPy+315HJ+1cuutW7FLaZsUDkGkx0MAO1HCgH4DeXA+MdtzO5GJJYdflV01yno1j0yPxGhAEAWkx/fRH40ODVQpXbHtMu7FNt60tVKf3OKxt9BU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791819273331967.2477328118958; Mon, 12 Oct 2026 08:34:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGI2n-0008Km-VJ; Mon, 12 Oct 2026 11:34:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGI2m-0008Ie-L2 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:34:28 -0400 Received: from mail-wm1-f48.google.com ([209.85.128.48]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGI2j-0002wl-2s for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:34:28 -0400 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4a16c1608faso26873855e9.0 for ; Mon, 12 Oct 2026 08:34:24 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18e49792bsm476339065e9.4.2026.10.12.08.34.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:34:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819263; x=1792424063; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9m6xeuXDGuPCKQgTcqEoBMjzYqVoeLEW2xyy05z+8Wk=; b=Xg7QiqCFUNX1qRGkZ9ZJKmKMteEp1BMQkXDHfpU1Qu+xe1Da4LJyydp2trBSuSruG1 VvHkoDwYQyDM3/69G5sbYKS51htgN5LdiHqYxLfTWdRrMi+JmsX3yymnDbXulLhNd1QP 7L/7IrzcI2YDx3Z6vViXbKfIXx4G2TzBnB+Gz14YFpVXb17rMMy7CiAd2FE9hSIVWFQh a6AZI7S7LpCi4pHveGyLC7cKV4lEVNRsv43L5SPqmUNOrgSjzPbwy6o4l9iRadlAJWC3 hXxAJrW9Keq3zEoy7nAMLxQkkStrUCpGUApfEAv0q+4LwoqcLMJG82FakQ2RSRx/gCbF NtKg== X-Gm-Message-State: AFq9FYJ3S4TTUVRxk2N+4KSMUvEBlGLmkBoGif851HRaX6L3qQbiLRkM +xYOySjkHM4I/i4Xty3h9P1W6IyqZAXtxZfZH7Fi7P7qofyXUFmcKo7wriaGa1Dw X-Gm-Gg: AYBFou2aUcC14CH9TiOe++ljJ/uD12Gb2vBK+Jfy6B+L547bwh929j/t4H/LiOVfoCq J3rPkwlfNCT0gWd4i6bbFdNHPWInmE/9IFMRHdRWfvgsmE1ry1RmU4tUePgS86kCzXLZJTutQWn KRF+EpXd+vFBLMP/g2bSyBabOq+p0hdQ68d50mbrtn4tGe9dvgUyNpBZizlKan1q+vdviAY9oT/ bieQNFETonmQ0iZ7TluRkABpJjR7Oquzs/qOPHzwCsx3Xl1layCE5dXpzajoO5UPbqTfRgpcZ7V qtD0SfrrvuLaY84xYyWl/sKV5SS0GU3ZF2nMaNOaSklUTggIJmaWdFurYCJxXl6usCkoRTh7z7I 0Z7EZXxqpqsHg8nlKIyW2NeTjI/nUGk3YstIxE8rPPLtTghF5mvx+iic81JlczKu9GVYMvpHXHc 9wsBKSlhhXqojKHHY4XZhFiilwE7BqbSJl+jEVwYu/VfrOvjWBi1WbTnT3se4f1CT2/4dlEzoVU tIQJXUHYRDcxloN/8ol68BHcHgRACucFBEbRs6IOL8zFw== X-Received: by 2002:a05:600c:4708:b0:4a1:88df:8a2a with SMTP id 5b1f17b1804b1-4a18e4a6ea5mr193790435e9.13.1791819263182; Mon, 12 Oct 2026 08:34:23 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:34 +0200 Subject: [PATCH v2 41/50] tests/qtest: ina238: add current/voltage/power monitor test MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-41-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=7697; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=bGeHvwJFYqhFeLZQKGrvAYOCIAIYNERh3xZiVrwzj4k=; b=yc0I4Rkt3OiJIOFuJrjZgxVoq3FSjtJUDVZ3CEpxdlfIlSj8EhkVgO3neVBBaA8v9vhblx7+Y +FMJLlQ/vnrAPFDn/s/xgxuomQfYjOYdV2warZv5jg4hgo6KE7aAVLs X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.48; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f48.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819274936158500 Introduce the INA238 qtest: the qgraph node, the QMP injection helpers and the register map. Cover the reset defaults, the software reset, and the Configuration register write mask. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina238-test.c | 177 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qtest/meson.build | 1 + 2 files changed, 178 insertions(+) diff --git a/tests/qtest/ina238-test.c b/tests/qtest/ina238-test.c new file mode 100644 index 0000000000..6e59ed30b5 --- /dev/null +++ b/tests/qtest/ina238-test.c @@ -0,0 +1,177 @@ +/* + * QTest testcase for the INA238 current/voltage/power monitor + * + * Copyright (c) 2026 Meta Platforms, Inc. and affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "libqos/i2c.h" +#include "libqos/qgraph.h" +#include "libqtest-single.h" +#include "qobject/qdict.h" + +#define INA238_TEST_ID "ina238-test" +#define INA238_TEST_ADDR 0x40 + +/* Register pointer addresses */ +#define REG_CONFIG 0x00 +#define REG_ADC_CONFIG 0x01 +#define REG_SHUNT_CAL 0x02 +#define REG_VSHUNT 0x04 +#define REG_VBUS 0x05 +#define REG_DIETEMP 0x06 +#define REG_CURRENT 0x07 +#define REG_POWER 0x08 +#define REG_DIAG_ALRT 0x0B +#define REG_SOVL 0x0C +#define REG_SUVL 0x0D +#define REG_BOVL 0x0E +#define REG_BUVL 0x0F +#define REG_TEMP_LIMIT 0x10 +#define REG_PWR_LIMIT 0x11 +#define REG_MANUFACTURER_ID 0x3E +#define REG_DEVICE_ID 0x3F + +/* Configuration register bits */ +#define CONFIG_RST 0x8000 +#define CONFIG_ADCRANGE 0x0010 + +/* DIAG_ALRT register bits */ +#define DIAG_MEMSTAT 0x0001 +#define DIAG_CNVRF 0x0002 +#define DIAG_POL 0x0004 +#define DIAG_BUSUL 0x0008 +#define DIAG_BUSOL 0x0010 +#define DIAG_SHNTUL 0x0020 +#define DIAG_SHNTOL 0x0040 +#define DIAG_TMPOL 0x0080 +#define DIAG_MATHOF 0x0200 +#define DIAG_APOL 0x1000 +#define DIAG_SLOWALERT 0x2000 +#define DIAG_CNVR 0x4000 +#define DIAG_ALATCH 0x8000 + +/* Reset values */ +#define CONFIG_POR 0x0000 +#define ADC_CONFIG_POR 0xFB68 +#define SHUNT_CAL_POR 0x1000 +#define DIAG_ALRT_POR 0x0001 +#define SOVL_POR 0x7FFF +#define SUVL_POR 0x8000 +#define BOVL_POR 0x7FFF +#define BUVL_POR 0x0000 +#define TEMP_LIMIT_POR 0x7FF0 +#define PWR_LIMIT_POR 0xFFFF +#define MANUFACTURER_ID_VAL 0x5449 +#define DEVICE_ID_VAL 0x2381 + +/* Read the 24-bit POWER register (MSB first) */ +static uint32_t i2c_get24(QI2CDevice *dev, uint8_t reg) +{ + uint8_t resp[3]; + + i2c_read_block(dev, reg, resp, sizeof(resp)); + return (resp[0] << 16) | (resp[1] << 8) | resp[2]; +} + +/* QMP helpers for injecting the physical inputs */ + +static void qmp_ina238_set(const char *property, int value) +{ + QDict *resp; + + resp =3D qmp("{ 'execute': 'qom-set', 'arguments':" + " { 'path': %s, 'property': %s, 'value': %d } }", + INA238_TEST_ID, property, value); + g_assert(qdict_haskey(resp, "return")); + qobject_unref(resp); +} + +/* Power-on-reset default values and the ID registers */ +static void test_defaults(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + g_assert_cmphex(i2c_get16(dev, REG_CONFIG), =3D=3D, CONFIG_POR); + g_assert_cmphex(i2c_get16(dev, REG_ADC_CONFIG), =3D=3D, ADC_CONFIG_POR= ); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT_CAL), =3D=3D, SHUNT_CAL_POR); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_VBUS), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_DIETEMP), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get24(dev, REG_POWER), =3D=3D, 0x000000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT), =3D=3D, DIAG_ALRT_POR); + g_assert_cmphex(i2c_get16(dev, REG_SOVL), =3D=3D, SOVL_POR); + g_assert_cmphex(i2c_get16(dev, REG_SUVL), =3D=3D, SUVL_POR); + g_assert_cmphex(i2c_get16(dev, REG_BOVL), =3D=3D, BOVL_POR); + g_assert_cmphex(i2c_get16(dev, REG_BUVL), =3D=3D, BUVL_POR); + g_assert_cmphex(i2c_get16(dev, REG_TEMP_LIMIT), =3D=3D, TEMP_LIMIT_POR= ); + g_assert_cmphex(i2c_get16(dev, REG_PWR_LIMIT), =3D=3D, PWR_LIMIT_POR); + g_assert_cmphex(i2c_get16(dev, REG_MANUFACTURER_ID), =3D=3D, + MANUFACTURER_ID_VAL); + g_assert_cmphex(i2c_get16(dev, REG_DEVICE_ID), =3D=3D, DEVICE_ID_VAL); +} + +/* Software reset via the Configuration RST bit */ +static void test_soft_reset(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_SHUNT_CAL, 0x1234); + i2c_set16(dev, REG_SOVL, 0x0500); + i2c_set16(dev, REG_TEMP_LIMIT, 0x0A00); + i2c_set16(dev, REG_DIAG_ALRT, DIAG_ALATCH); + + qmp_ina238_set("shunt-voltage", 97200000); + qmp_ina238_set("bus-voltage", 48000000); + qmp_ina238_set("die-temperature", 25000); + + g_assert_cmphex(i2c_get16(dev, REG_SHUNT_CAL), =3D=3D, 0x1234); + g_assert_cmphex(i2c_get16(dev, REG_SOVL), =3D=3D, 0x0500); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x4BF0); + g_assert_cmpuint(i2c_get16(dev, REG_CURRENT), !=3D, 0); + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + g_assert_cmphex(i2c_get16(dev, REG_CONFIG), =3D=3D, CONFIG_POR); + g_assert_cmphex(i2c_get16(dev, REG_SHUNT_CAL), =3D=3D, SHUNT_CAL_POR); + g_assert_cmphex(i2c_get16(dev, REG_SOVL), =3D=3D, SOVL_POR); + g_assert_cmphex(i2c_get16(dev, REG_TEMP_LIMIT), =3D=3D, TEMP_LIMIT_POR= ); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT), =3D=3D, DIAG_ALRT_POR); + + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_VBUS), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_DIETEMP), =3D=3D, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x0000); + g_assert_cmpuint(i2c_get24(dev, REG_POWER), =3D=3D, 0); +} + +/* CONFIG keeps only the writable ADCRANGE/CONVDLY bits and self-clears RS= T */ +static void test_config_wmask(void *obj, void *data, QGuestAllocator *allo= c) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_ADCRANGE | 0x0040); + g_assert_cmphex(i2c_get16(dev, REG_CONFIG), =3D=3D, CONFIG_ADCRANGE | = 0x0040); + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + g_assert_cmphex(i2c_get16(dev, REG_CONFIG), =3D=3D, CONFIG_POR); +} + +static void ina238_register_nodes(void) +{ + QOSGraphEdgeOptions opts =3D { + .extra_device_opts =3D "id=3D" INA238_TEST_ID ",address=3D0x40" + }; + add_qi2c_address(&opts, &(QI2CAddress) { INA238_TEST_ADDR }); + + qos_node_create_driver("ina238", i2c_device_create); + qos_node_consumes("ina238", "i2c-bus", &opts); + + qos_add_test("defaults", "ina238", test_defaults, NULL); + qos_add_test("soft-reset", "ina238", test_soft_reset, NULL); + qos_add_test("config-wmask", "ina238", test_config_wmask, NULL); +} +libqos_init(ina238_register_nodes); diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index e413a0cc75..7005509d4d 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -331,6 +331,7 @@ qos_test_ss.add( 'eepro100-test.c', 'es1370-test.c', 'ina230-test.c', + 'ina238-test.c', 'lsm303dlhc-mag-test.c', 'isl_pmbus_vr-test.c', 'max34451-test.c', --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819372; cv=none; d=zohomail.com; s=zohoarc; b=l7hSfE18+20zc7f3+UMxYzeAsTnuE0K7mGzovlTkb0Thc4i9YtHG2FVjQVwUlILxjyf9p5cHc6DQoWysFLgd3Jd0ExAJyBSpJfbP7RGgY8nYCeNbmlRFb6FoTzMNkiCCLd5kDi5PIf4z5vupnYSojY7D8Zsg37UhE0dGqsNrcQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819372; 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:Sender:Subject:Subject:To:To:Message-Id; bh=NhyqqnT6pOmjCgHy3cHsQQlI9jpPszBbMEh9VGPKhUI=; b=UyKww3COy6mzCLWVxSLcvZ2AUw9BcM6SB07ejh4ybC+ZhVOX0nf7rvVJwQLWDQZ2aSkmfBmrNmsooI/V+RyobyGdROiG1ua2brJqeAXja0Kwe81RyatO7gXR81XaK2BZyklg+t2AiP16qSXhClhlosY21jRbqHWsCYUnF1fIw9s= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791819372808622.2671309428229; Mon, 12 Oct 2026 08:36:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGI3o-0000cY-Hc; Mon, 12 Oct 2026 11:35:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGI3l-0000bW-L6 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:35:30 -0400 Received: from mail-wr1-f52.google.com ([209.85.221.52]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGI3i-0003Fo-Bi for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:35:29 -0400 Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-48c411d6615so1401037f8f.3 for ; Mon, 12 Oct 2026 08:35:25 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0aaaa34sm91705f8f.20.2026.10.12.08.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:35:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819325; x=1792424125; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=NhyqqnT6pOmjCgHy3cHsQQlI9jpPszBbMEh9VGPKhUI=; b=Pyr0Pma0wg/hbx5vg6sUiAZN+2Y3haWIZ3zLRyGi5IsLtl+09FYnFZ1JlBTX1jsbKJ zoZD+vReA1uw0sWaeXz9p1A4ZhzxwHwuZFMyY40aOz8WkagmcWxAj/8bck+5OZUV/let LxQHsbjfppbJ0rmyuATyeoZkNL8Kqb8h9+B1hw30/N1nrN5n9eYd68OYwBd2aOu233IB x4JNejXA3YgoepiPuvjMNTNBor9xkVsBXq4OIQECwZ6SNZ8+oNGh9AOM3HbcOzg7Z6XR YjC6gUzvOKM35f+nqAWqdIALlT2Ao/PqU4X74gZIdrVcXaFMQHM97Rhs0qJLfzm5yDvU Uk+g== X-Gm-Message-State: AFq9FYJjvKrUeICWgzOshCcPqJBj7yxym/adRnIg4ZE+GcBglBTIWfa/ pAC8WbvW+FzzvOQDPy+3GoodpA3rsRms25BQgSuVq4ihSgf/PbcAQ7Dk9S4wYVjb X-Gm-Gg: AYBFou0ZKwroKd6PWpMpL1T581ms9efVMP8bhwAz4KAkAWr8WD4ljotpm7VLtOUhKSP BhNbJav+9P5L3b3UqQP/OgmSRnbJEydV5lf1aMmLCewv/prS2TrLfIkaBm4GMUqQPyQlbR7s7oi T4J0KPqEVkG+hblC/DL8lZVQsTRSNhqDCritI0kcq4fFvFlvekZ0Y+0q6VcRsYOsUgxOmUkfCwP vsmzvfIV6C4PayW0NpVil9gz/58zhqvcRF7xxOPjSV+bpdv6I5j/QxFPiRljg9cUAV8e9uJ5OC6 jurObkZasQReEimZUgpgiZRmCfgm/C9fJ2Gm4JnypKAVPZOtk/lDLcOPCO00OiV3dCj7f5+kg+5 glUozUs+6I88FiWuZFg8hgWd9vFRSMX7m6bcXMCbBY6BI4/XuGffYiCNY3d4sENkqBetrhp2wyE bl1wxMr/hE28d1x0u/clAR/UFMV8uB2kYTpZhYZ7l8weA/w7pXBHs+mIFqdWcjkIf1lQ24nG1AM 9Pyv3BHmjX54I7DhZmHNoW2bj/Xy7freEiefR6kh3VcDw== X-Received: by 2002:a05:6000:4814:b0:48a:f929:e140 with SMTP id ffacd0b85a97d-48dbaadaa3cmr17069931f8f.10.1791819324550; Mon, 12 Oct 2026 08:35:24 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:35 +0200 Subject: [PATCH v2 42/50] tests/qtest: ina238: cover voltage/temperature injection and derivation MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-42-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815521; l=6961; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=egEW5taK1N7S1o1f0z7+qaFgBpk2txeW9L73zPjwY8M=; b=+xhwx5wtWKyw8oCJzSR2/s/xEfdXTBEtJohD43JYNkRrqtFMm6iPQy9EVzPp8hZtdETGjCTr0 RzhDelhdpe2AEZ6yhXV/BdeRDxXekikUUhux2B4agfTA1BDV7rLtGgG X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.52; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f52.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819374853158500 Cover the shunt-, bus- and die-temperature injection properties and the current and power values derived through the Shunt Calibration register, including the zero-calibration case, the ADCRANGE rescaling and the clamp/overflow edges. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina238-test.c | 156 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 156 insertions(+) diff --git a/tests/qtest/ina238-test.c b/tests/qtest/ina238-test.c index 6e59ed30b5..693139f988 100644 --- a/tests/qtest/ina238-test.c +++ b/tests/qtest/ina238-test.c @@ -89,6 +89,20 @@ static void qmp_ina238_set(const char *property, int val= ue) qobject_unref(resp); } =20 +static int qmp_ina238_get(const char *property) +{ + QDict *resp; + int ret; + + resp =3D qmp("{ 'execute': 'qom-get', 'arguments':" + " { 'path': %s, 'property': %s } }", + INA238_TEST_ID, property); + g_assert(qdict_haskey(resp, "return")); + ret =3D qdict_get_int(resp, "return"); + qobject_unref(resp); + return ret; +} + /* Power-on-reset default values and the ID registers */ static void test_defaults(void *obj, void *data, QGuestAllocator *alloc) { @@ -160,6 +174,139 @@ static void test_config_wmask(void *obj, void *data, = QGuestAllocator *alloc) g_assert_cmphex(i2c_get16(dev, REG_CONFIG), =3D=3D, CONFIG_POR); } =20 +/* Shunt voltage register */ +static void test_shunt_injection(void *obj, void *data, QGuestAllocator *a= lloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina238_set("shunt-voltage", 97200000); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x4BF0); + + qmp_ina238_set("shunt-voltage", -80000000); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0xC180); + + g_assert_cmpint(qmp_ina238_get("shunt-voltage"), =3D=3D, -80000000); +} + +/* Bus voltage register */ +static void test_bus_injection(void *obj, void *data, QGuestAllocator *all= oc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina238_set("bus-voltage", 48000000); + g_assert_cmphex(i2c_get16(dev, REG_VBUS), =3D=3D, 0x3C00); + + qmp_ina238_set("bus-voltage", 12000000); + g_assert_cmphex(i2c_get16(dev, REG_VBUS), =3D=3D, 0x0F00); +} + +/* Die temperature register */ +static void test_temp_injection(void *obj, void *data, QGuestAllocator *al= loc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina238_set("die-temperature", 25000); + g_assert_cmphex(i2c_get16(dev, REG_DIETEMP), =3D=3D, 0x0C80); + + qmp_ina238_set("die-temperature", -25000); + g_assert_cmphex(i2c_get16(dev, REG_DIETEMP), =3D=3D, 0xF380); + + g_assert_cmpint(qmp_ina238_get("die-temperature"), =3D=3D, -25000); +} + +/* Calibration-derived current */ +static void test_calibration_current(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + qmp_ina238_set("shunt-voltage", 97200000); + + i2c_set16(dev, REG_SHUNT_CAL, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x0000); + + i2c_set16(dev, REG_SHUNT_CAL, 0x0FD2); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x4CCC); +} + +/* Calibration-derived power */ +static void test_power(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + qmp_ina238_set("shunt-voltage", 97200000); + qmp_ina238_set("bus-voltage", 48000000); + i2c_set16(dev, REG_SHUNT_CAL, 0x0FD2); + + g_assert_cmpuint(i2c_get24(dev, REG_POWER), =3D=3D, 4718400); +} + +/* With SHUNT_CAL =3D=3D 0 the current and power registers stay zero */ +static void test_zero_cal(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_SHUNT_CAL, 0x0000); + qmp_ina238_set("shunt-voltage", 97200000); + qmp_ina238_set("bus-voltage", 48000000); + + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x0000); + g_assert_cmpuint(i2c_get24(dev, REG_POWER), =3D=3D, 0); +} + +/* ADCRANGE changes the shunt LSB, not the current divisor. */ +static void test_adcrange(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina238_set("shunt-voltage", 20000000); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x0FA0); + + i2c_set16(dev, REG_SHUNT_CAL, 0x0800); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x1F40); + + i2c_set16(dev, REG_CONFIG, CONFIG_ADCRANGE); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x3E80); + + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x7D00); + + i2c_set16(dev, REG_SHUNT_CAL, 0x2000); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x1F40); +} + +/* Clamping at full scale and the MATHOF flag */ +static void test_overflow(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + i2c_set16(dev, REG_CONFIG, CONFIG_ADCRANGE); + qmp_ina238_set("shunt-voltage", 97200000); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x7FFF); + qmp_ina238_set("shunt-voltage", -97200000); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x8000); + + i2c_set16(dev, REG_CONFIG, CONFIG_POR); + qmp_ina238_set("shunt-voltage", 163835000); + i2c_set16(dev, REG_SHUNT_CAL, 0x0001); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x7FFF); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_MATHOF, =3D=3D, + DIAG_MATHOF); +} + +/* Shunt over-limit alert (transparent mode) */ static void ina238_register_nodes(void) { QOSGraphEdgeOptions opts =3D { @@ -173,5 +320,14 @@ static void ina238_register_nodes(void) qos_add_test("defaults", "ina238", test_defaults, NULL); qos_add_test("soft-reset", "ina238", test_soft_reset, NULL); qos_add_test("config-wmask", "ina238", test_config_wmask, NULL); + qos_add_test("shunt-injection", "ina238", test_shunt_injection, NULL); + qos_add_test("bus-injection", "ina238", test_bus_injection, NULL); + qos_add_test("temp-injection", "ina238", test_temp_injection, NULL); + qos_add_test("calibration-current", "ina238", test_calibration_current, + NULL); + qos_add_test("power", "ina238", test_power, NULL); + qos_add_test("zero-cal", "ina238", test_zero_cal, NULL); + qos_add_test("adcrange", "ina238", test_adcrange, NULL); + qos_add_test("overflow", "ina238", test_overflow, NULL); } libqos_init(ina238_register_nodes); --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819434; cv=none; d=zohomail.com; s=zohoarc; b=NXDzRz4m/4Rt3rwn9Miel8JRM+cek0Bs4KvB35dxUxz8TUWss4ztBwiYo/AZMNk5WjRBJkGtJrYYMK9h7bptyWbPING2mXLTMOzngLjH6cxgwWEagHDPT9+ix0fADF9QGDsuoxuvwDs/Qb+AXMbbHAJ9iAnR1NMkJlnooZMhwiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819434; 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:Sender:Subject:Subject:To:To:Message-Id; bh=3XplpicYtnjwg/F/PhuqE/con32vEXnk067HsKJkOiY=; b=iI3gwZiiS6l4wuQMX1nOQkk1nmQJ/z+baCtau1FaB6Q6rWYZDbav95pZD0m8a3GTdQDkrZH+w8Mxrm+RjN7Y/MODXboUbkv5xbqPuzwtOsEuG8GZAOf+XPpvtF/MpFUD9YlEZs27AJuGS4LTDR0ZdcHxIeYJPo8O5dnqGIUWhQU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791819434272291.80198449745455; Mon, 12 Oct 2026 08:37:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGI4u-0001Ap-Uh; Mon, 12 Oct 2026 11:36:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGI4k-0001A4-M0 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:36:33 -0400 Received: from mail-wm1-f53.google.com ([209.85.128.53]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGI4i-0003O9-Ov for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:36:30 -0400 Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4a168355946so17614645e9.0 for ; Mon, 12 Oct 2026 08:36:27 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18bf214a1sm340431605e9.7.2026.10.12.08.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:36:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819386; x=1792424186; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=3XplpicYtnjwg/F/PhuqE/con32vEXnk067HsKJkOiY=; b=I7ad45M6FhSaHs6e36v182V9ciuHSNmwptrj1GkjhFYVReyEQiDCj5W4bivcMQvZD5 oI2ZQczJXfH9JUQspJownkxhdu+1VumB5eKn0nU1+HoXLDas/0+CoiXNFUz7ZF9R1vsd zhLmq/WGmQlIJjiwpnqXNClDaaGGkoNNxRcFaXsS1Hs/Q/Wa+YuYjJKO45lcbbQVupF5 TYIdKNCFWoVRQlAz1NpfpveFZDZ2b9rGycoe0IiOKxTVSrFg2+fX5ODwMkjXN3XzzMJz SmIscNqJyUhYh1AgHS/JQ6o/Lx7qamowTVwx9ENLVBg+U8XnRqlsN84qIp/rKNv26Ujg wpFA== X-Gm-Message-State: AFq9FYJD1HzmBwaV3UEd/VsFS5fKr1ZIglKFjk5NDZf/Cm3I6DTF5BM5 PCs6v1ne4N5AzLzNdOGcGxssw//89EvXFod7wjp/iuOVnz7A9AqlEHm4tunBfZMJ X-Gm-Gg: AYBFou2xfdeCo5yrn6wyarLZRjpdPZADd/v7BqVLdHK+VifuCP3t1pnpRkvygJ50nJK atuhlI6ketNc4LVds2W5ngpeGgpaqTar99fNANrF1zVil/VlgGhYFjnSkaFt3ankoCCcuOw0hwC 3UPe3vVvzNqIPctbwZ2Q5SgZgoO0yBPMUc2J4qH60lv5rhrEDI9cF+yf4Gc3DBI/sLiIO1AAXV3 abKmioNcxUqoow/uoxzumTkBT60A49y8X59n+B/zCsr2aUdgdO1EP6QTROBuHVPVD5//r8nHRSi FU40AIFp4DvlvnAOf8cu2462bu+P0iSazNQN3n4O54jvU64DbJH+OSCaiPLx2F0GAgVgvgNmLg7 6Tb4ad2/hdyCpkmdzMFl6jfUY8nZHlWwNye9VMA0FNRVBefDCmf8pE29CC/ADagiLtXB/D+tRCM vDGik7FFjSvb+vUdAGK9kL0x0tE1HAMc5luvJF2fB0G7WVMtTsGLQ4b7MJ+QZsAp38PJDxpIGcC 7yO0uPu6XKBny3fbCatlckVEp1vQqybBstl73TU7nSyxw== X-Received: by 2002:a05:600c:3488:b0:4a1:7690:d878 with SMTP id 5b1f17b1804b1-4a18e4b8028mr195587315e9.17.1791819386106; Mon, 12 Oct 2026 08:36:26 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:36 +0200 Subject: [PATCH v2 43/50] tests/qtest: ina238: cover the ALERT path and conversion-ready flag MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-43-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815522; l=6665; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=in5M3OrP79f45k7Uk1wA7KrYQ9pr2rECNsyuX2iK4go=; b=lPTDkqyx2BghMey/BI0wIZhMVQa4ufsY6iBk7KaIPkYXxxuFogIVDoCCKXbE+WJ1rHzcPAcKF rU09oHfyp2pA5eSTsJjp0rSmPfVIIq4OtqC7vlmv+uxYkgPBUi7cXj6 X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.53; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f53.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819435883158500 Cover the shunt/bus/temperature/power alert thresholds, the multi-alert OR behaviour, the alert latch, the DIAG_ALRT control bits and the conversion-ready (CNVRF) flag. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina238-test.c | 146 ++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 145 insertions(+), 1 deletion(-) diff --git a/tests/qtest/ina238-test.c b/tests/qtest/ina238-test.c index 693139f988..08813377c9 100644 --- a/tests/qtest/ina238-test.c +++ b/tests/qtest/ina238-test.c @@ -306,7 +306,143 @@ static void test_overflow(void *obj, void *data, QGue= stAllocator *alloc) DIAG_MATHOF); } =20 -/* Shunt over-limit alert (transparent mode) */ +/* Shunt over-limit alert */ +static void test_alert_shunt(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_SOVL, 0x1000); + + qmp_ina238_set("shunt-voltage", 5000000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, 0= ); + + qmp_ina238_set("shunt-voltage", 97200000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, + DIAG_SHNTOL); + + qmp_ina238_set("shunt-voltage", 5000000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, 0= ); +} + +/* Bus over-limit alert */ +static void test_alert_bus(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_BOVL, 0x1000); + + qmp_ina238_set("bus-voltage", 12000000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_BUSOL, =3D=3D, 0); + + qmp_ina238_set("bus-voltage", 48000000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_BUSOL, =3D=3D, DI= AG_BUSOL); +} + +/* Over-temperature alert */ +static void test_alert_temp(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_TEMP_LIMIT, 0x0A00); + + qmp_ina238_set("die-temperature", 10000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_TMPOL, =3D=3D, 0); + + qmp_ina238_set("die-temperature", 25000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_TMPOL, =3D=3D, DI= AG_TMPOL); +} + +/* Power over-limit alert */ +static void test_alert_power(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + qmp_ina238_set("shunt-voltage", 97200000); + qmp_ina238_set("bus-voltage", 48000000); + i2c_set16(dev, REG_SHUNT_CAL, 0x0FD2); + + i2c_set16(dev, REG_PWR_LIMIT, 0x0100); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_POL, =3D=3D, DIAG= _POL); + + i2c_set16(dev, REG_PWR_LIMIT, 0x7FFF); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_POL, =3D=3D, 0); +} + +/* Two thresholds crossed at once are reported simultaneously (multi-alert= ) */ +static void test_alert_multi(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + uint16_t diag; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_SOVL, 0x1000); + i2c_set16(dev, REG_BOVL, 0x1000); + + qmp_ina238_set("shunt-voltage", 97200000); + qmp_ina238_set("bus-voltage", 48000000); + + diag =3D i2c_get16(dev, REG_DIAG_ALRT); + g_assert_cmphex(diag & DIAG_SHNTOL, =3D=3D, DIAG_SHNTOL); + g_assert_cmphex(diag & DIAG_BUSOL, =3D=3D, DIAG_BUSOL); +} + +/* Latch mode holds the flag until the DIAG_ALRT register is read */ +static void test_alert_latch(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_SOVL, 0x1000); + i2c_set16(dev, REG_DIAG_ALRT, DIAG_ALATCH); + + qmp_ina238_set("shunt-voltage", 97200000); + qmp_ina238_set("shunt-voltage", 5000000); + + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, + DIAG_SHNTOL); + + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, 0= ); +} + +/* DIAG_ALRT control bits are writable; status bits are read-only */ +static void test_diag_control(void *obj, void *data, QGuestAllocator *allo= c) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + uint16_t diag; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + i2c_set16(dev, REG_DIAG_ALRT, + DIAG_ALATCH | DIAG_CNVR | DIAG_SLOWALERT | DIAG_APOL); + diag =3D i2c_get16(dev, REG_DIAG_ALRT); + g_assert_cmphex(diag & DIAG_ALATCH, =3D=3D, DIAG_ALATCH); + g_assert_cmphex(diag & DIAG_CNVR, =3D=3D, DIAG_CNVR); + g_assert_cmphex(diag & DIAG_SLOWALERT, =3D=3D, DIAG_SLOWALERT); + g_assert_cmphex(diag & DIAG_APOL, =3D=3D, DIAG_APOL); + /* MEMSTAT stays set */ + g_assert_cmphex(diag & DIAG_MEMSTAT, =3D=3D, DIAG_MEMSTAT); +} + +/* Every DIAG_ALRT read clears CNVRF, whatever the alert-latch mode. */ +static void test_cnvrf(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + qmp_ina238_set("shunt-voltage", 20000000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_CNVRF, =3D=3D, DI= AG_CNVRF); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_CNVRF, =3D=3D, 0); + + i2c_set16(dev, REG_DIAG_ALRT, DIAG_ALATCH); + qmp_ina238_set("shunt-voltage", 20000000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_CNVRF, =3D=3D, DI= AG_CNVRF); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_CNVRF, =3D=3D, 0); +} + static void ina238_register_nodes(void) { QOSGraphEdgeOptions opts =3D { @@ -329,5 +465,13 @@ static void ina238_register_nodes(void) qos_add_test("zero-cal", "ina238", test_zero_cal, NULL); qos_add_test("adcrange", "ina238", test_adcrange, NULL); qos_add_test("overflow", "ina238", test_overflow, NULL); + qos_add_test("alert-shunt", "ina238", test_alert_shunt, NULL); + qos_add_test("alert-bus", "ina238", test_alert_bus, NULL); + qos_add_test("alert-temp", "ina238", test_alert_temp, NULL); + qos_add_test("alert-power", "ina238", test_alert_power, NULL); + qos_add_test("alert-multi", "ina238", test_alert_multi, NULL); + qos_add_test("alert-latch", "ina238", test_alert_latch, NULL); + qos_add_test("diag-control", "ina238", test_diag_control, NULL); + qos_add_test("cnvrf", "ina238", test_cnvrf, NULL); } libqos_init(ina238_register_nodes); --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819510; cv=none; d=zohomail.com; s=zohoarc; b=RO2UK6AoX4P+ZBVTc25Q5Bxbjrr6hzELzJ8WdxzFoyi1VYtrvfQJZZRfxHdcV49L1QmuZdYfyTD7ttg9TWcZQEk5ph4ZZfGbPsQlL0Oy1T3bXNlgutQT6qFQj9GxxVJigWmuJ2f7MEFm5l55uhRNcOTvmG3PYrzBJp9Y36bNTJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819510; 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:Sender:Subject:Subject:To:To:Message-Id; bh=Fhp3wv+1ffAiyOIOMf1hqrOLyXTWHsYqm0QrDErev70=; b=mY3K2g1K9n3qTlX/U/X8eGrXZqQGM37PSrmM0oEc8cnNHiGqCXaqbX6Rj+6PchDEmHiRTLBMni96cnY04l70Y/MGRVOTeeKylFw35ErXEAAbnWdjXLaIePD8VJQ2/kbyJjcKdOnfL2nrrtyOajXpzGuga1XYyuVVDWNf/rbOy4Y= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791819510711203.62574190369696; Mon, 12 Oct 2026 08:38:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGI6J-0001cm-9N; Mon, 12 Oct 2026 11:38:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGI5k-0001T6-NT for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:37:38 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGI5g-0003Up-Q3 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:37:30 -0400 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4a17baef589so16441955e9.0 for ; Mon, 12 Oct 2026 08:37:28 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18bf2e0dbsm314783575e9.11.2026.10.12.08.37.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:37:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819447; x=1792424247; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Fhp3wv+1ffAiyOIOMf1hqrOLyXTWHsYqm0QrDErev70=; b=0S83YOjqhmmlePmShgT+uS89awxrjWBbhssL39g2dANhcAgW4owQI2zu8htaJtYqe4 bafAnNuuS2W8mjF03pqO8dyHi056YWuvOuQY+0CGJLLL8kbgSIPSZXfC/DK8T7PXSICb /7viwk4MCMZxRMIIGCPSryjWvSP8ffDfPdVfkS5q6Yz3fFEKM4OT2l8WMnntnotJBD73 RPEpDGUC1gBC+qkQG0b11F90Jc1gwQUdI4p7z65IFXqzt2j53jSe/G2i9P05CkuhCi66 /WKap0Ap/B7mCI8hrNa2u83CB/MhUvJ0MRKL8dpiOhVBjFROXyNrnUpQ6vzHWfrjS78p xYPg== X-Gm-Message-State: AFq9FYKxpzy0M4roWGY03u6Duyu+skNPRyDJh9UxADAyY+gfmMbVlpfv DgN7ymL4DiV4MIl8z0ZqZqdP7hu/OmvBtrCNqrWk358xvmLmnxRdBvrAY+YUaEH5 X-Gm-Gg: AYBFou1X4cL49BAxmumtXzDA5qLaCkBVj66bL49I4BTdvhowDDzDqU0E2HtOLzzUl1H Nzay0RIFEhjNfMbWAUcYXJc97VV5YDWwVByCx4zw0evwD9jSPMk1VWmAL23VPC8xkwuRHjILlle jkvH7laXtdzvPWB0kuFaRd/xfGbpyOlOLnVeK0iTWE4UqZhMh1rOOpCN+3TQc4KAJotJwjWzs/d C/dQfNp1jr1wYpNpDGOi2JfeFJRp7+nkX9jS6IfA7vu8p214cAIewsAg6jnP9iWPufneKxmEAxj jQxNrp4Y5DH8Ao5X1pYA4WAoVVwI9R7V13I2d13W/I/T9wjuceRO8pbabqkLk5lmlE1EPTaNpYc 4TXQ6pl7LPVUY8Mn7dQ5h7HM3UjR+TOMXuwahOUdh45Nktxa7/TUlGMp8uiNlil/PNvYBKBQU61 G0DV9SYskb6rmzF1IjSNToSO5mYJn9U5FQcHTrQ3wLzuBj9KzB4BELAz5Pfm8wc28UuluCtdX3B WTCWw4ZmcWyMQotN1w3oGRv/HypFJWt7h820TAfD2uvLA== X-Received: by 2002:a05:600c:620f:b0:49f:dc71:e609 with SMTP id 5b1f17b1804b1-4a18e499874mr178712715e9.20.1791819447221; Mon, 12 Oct 2026 08:37:27 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:37 +0200 Subject: [PATCH v2 44/50] tests/qtest: ina238: cover the injection-property limits MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-44-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815522; l=5321; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=JgwMXMS8XORDALoqQbGBJ4suPCUY8Bpl7Mu6Xt66s/I=; b=KcLhAcJG532wxOFfBCNz7nnWV8CurTa9x+WvY+eexQKyoq5Wqn+4GDuJo++iv4dS5w87vGxq1 HF1p4cn2991Ar4nG9JrM1fRr3YznpSXy2FazfOP4fnDFj4S+gPZgUtM X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.42; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f42.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819513299158500 Verify that the extremes of the shunt-voltage, bus-voltage and die-temperature injection ranges round-trip through the QOM property without truncation or wraparound, and that values just outside are rejected rather than silently wrapped. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina238-test.c | 84 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 84 insertions(+) diff --git a/tests/qtest/ina238-test.c b/tests/qtest/ina238-test.c index 08813377c9..74912424c0 100644 --- a/tests/qtest/ina238-test.c +++ b/tests/qtest/ina238-test.c @@ -67,6 +67,13 @@ #define MANUFACTURER_ID_VAL 0x5449 #define DEVICE_ID_VAL 0x2381 =20 +/* Injection-property limits (see ina238.c) */ +#define SHUNT_MIN_NV (-163840000) /* -32768 * 5 uV */ +#define SHUNT_MAX_NV 163835000 /* 32767 * 5 uV */ +#define BUS_MAX_UV 85000000 /* 27200 * 3.125 mV */ +#define TEMP_MIN_MC (-40000) /* -320 * 125 m-degC */ +#define TEMP_MAX_MC 125000 /* 1000 * 125 m-degC */ + /* Read the 24-bit POWER register (MSB first) */ static uint32_t i2c_get24(QI2CDevice *dev, uint8_t reg) { @@ -103,6 +110,18 @@ static int qmp_ina238_get(const char *property) return ret; } =20 +/* A qom-set expected to be rejected (value outside the supported range) */ +static void qmp_ina238_set_fail(const char *property, int64_t value) +{ + QDict *resp; + + resp =3D qmp("{ 'execute': 'qom-set', 'arguments':" + " { 'path': %s, 'property': %s, 'value': %lld } }", + INA238_TEST_ID, property, (long long)value); + g_assert(qdict_haskey(resp, "error")); + qobject_unref(resp); +} + /* Power-on-reset default values and the ID registers */ static void test_defaults(void *obj, void *data, QGuestAllocator *alloc) { @@ -443,6 +462,68 @@ static void test_cnvrf(void *obj, void *data, QGuestAl= locator *alloc) g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_CNVRF, =3D=3D, 0); } =20 +/* Shunt-voltage injection limits */ +static void test_shunt_limits(void *obj, void *data, QGuestAllocator *allo= c) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina238_set("shunt-voltage", SHUNT_MAX_NV); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x7FFF); + g_assert_cmpint(qmp_ina238_get("shunt-voltage"), =3D=3D, SHUNT_MAX_NV); + + qmp_ina238_set("shunt-voltage", SHUNT_MIN_NV); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x8000); + g_assert_cmpint(qmp_ina238_get("shunt-voltage"), =3D=3D, SHUNT_MIN_NV); + + qmp_ina238_set_fail("shunt-voltage", (int64_t)SHUNT_MAX_NV + 1); + qmp_ina238_set_fail("shunt-voltage", (int64_t)SHUNT_MIN_NV - 1); + g_assert_cmpint(qmp_ina238_get("shunt-voltage"), =3D=3D, SHUNT_MIN_NV); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x8000); +} + +/* Bus-voltage injection limits */ +static void test_bus_limits(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina238_set("bus-voltage", 0); + g_assert_cmphex(i2c_get16(dev, REG_VBUS), =3D=3D, 0x0000); + + qmp_ina238_set("bus-voltage", BUS_MAX_UV); + g_assert_cmphex(i2c_get16(dev, REG_VBUS), =3D=3D, 0x6A40); + g_assert_cmpint(qmp_ina238_get("bus-voltage"), =3D=3D, BUS_MAX_UV); + + qmp_ina238_set_fail("bus-voltage", (int64_t)BUS_MAX_UV + 1); + qmp_ina238_set_fail("bus-voltage", -1); + g_assert_cmpint(qmp_ina238_get("bus-voltage"), =3D=3D, BUS_MAX_UV); + g_assert_cmphex(i2c_get16(dev, REG_VBUS), =3D=3D, 0x6A40); +} + +/* Die-temperature injection limits */ +static void test_temp_limits(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + + qmp_ina238_set("die-temperature", TEMP_MAX_MC); + g_assert_cmphex(i2c_get16(dev, REG_DIETEMP), =3D=3D, 0x3E80); + g_assert_cmpint(qmp_ina238_get("die-temperature"), =3D=3D, TEMP_MAX_MC= ); + + qmp_ina238_set("die-temperature", TEMP_MIN_MC); + g_assert_cmphex(i2c_get16(dev, REG_DIETEMP), =3D=3D, 0xEC00); + g_assert_cmpint(qmp_ina238_get("die-temperature"), =3D=3D, TEMP_MIN_MC= ); + + qmp_ina238_set_fail("die-temperature", (int64_t)TEMP_MAX_MC + 1); + qmp_ina238_set_fail("die-temperature", (int64_t)TEMP_MIN_MC - 1); + g_assert_cmpint(qmp_ina238_get("die-temperature"), =3D=3D, TEMP_MIN_MC= ); + g_assert_cmphex(i2c_get16(dev, REG_DIETEMP), =3D=3D, 0xEC00); +} + static void ina238_register_nodes(void) { QOSGraphEdgeOptions opts =3D { @@ -459,6 +540,9 @@ static void ina238_register_nodes(void) qos_add_test("shunt-injection", "ina238", test_shunt_injection, NULL); qos_add_test("bus-injection", "ina238", test_bus_injection, NULL); qos_add_test("temp-injection", "ina238", test_temp_injection, NULL); + qos_add_test("shunt-limits", "ina238", test_shunt_limits, NULL); + qos_add_test("bus-limits", "ina238", test_bus_limits, NULL); + qos_add_test("temp-limits", "ina238", test_temp_limits, NULL); qos_add_test("calibration-current", "ina238", test_calibration_current, NULL); qos_add_test("power", "ina238", test_power, NULL); --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819538; cv=none; d=zohomail.com; s=zohoarc; b=Ur7E11J/a1b+ytcZ7lXstLH7Lil46brAJWlKVJgMLZWzKMQETtQlEZoEwxSQe/C8auk5D3Qeb6G6bZMH9RNP7k4wg0xfGGUinu/RYwLf1oIOWH2nSr6mUpfPBSp7Cgs3/KwnMl01hxa1Jj7EEmj8/wCiy+H8m3XGBe95GAS0JyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819538; 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:Sender:Subject:Subject:To:To:Message-Id; bh=RR0BfuP3zH0vPwsVTweTuUz+ywrZng5C/2ivP+6b+uc=; b=kHjHZ1pZxWrCam/DhqYycNuVtnUcfLwwyDj6zaInqYIASxP4AFjWUpzcJDs9pzdn1zOXg9SaX3IC64Tc29lNyKvXiQLCp0yVC5Ao6Br5//X0JEVTTCf+ws9ej/tL59vtwbPUYfdszVh92rEKnFMRE6jRcPV3PNoLy5TGxV6tM/0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179181953897959.0838517498114; Mon, 12 Oct 2026 08:38:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGI6m-000269-75; Mon, 12 Oct 2026 11:38:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGI6j-00023v-3n for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:38:33 -0400 Received: from mail-wm1-f48.google.com ([209.85.128.48]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGI6f-0003b9-V2 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:38:32 -0400 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-49d0da752ffso19444695e9.3 for ; Mon, 12 Oct 2026 08:38:29 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a19471edd5sm360428535e9.11.2026.10.12.08.38.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:38:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819508; x=1792424308; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=RR0BfuP3zH0vPwsVTweTuUz+ywrZng5C/2ivP+6b+uc=; b=BOlFZywpR56piaUlBFRSSYJSoOHDnDzQqHidSbY28r2ntFvGbQkkwQQSVtRHVZlzoB EgzwJIQDVJ/HM3+toU/S3YptfmopNLrlG9wUcL90koepGkQVYRRpPQR8sL0c/+mY+dgq nRAZ3bKZUWc41KTuvkePunQtxFGih/fNQYtlsaJVvy3JALMSifFV1y2Tq1PZX8Y/2vbT fEnzZaesbuPM+Zss23PXuzn4nJTIT8s6WmCUshRp4i3qVUMTF82FP9kQn8h8wOtE9bjR n+jJQbNIUt2ugEL6TlgIPt4+hypCapPRI3qL/HDrbHObqUffmFiB8godJ32FCyjAfkiQ wx8g== X-Gm-Message-State: AFq9FYK/GTJToda69vJeA8EbUwoB5856A/zVlI5kzT/XtpaJ29uSFADH g2SXCTNVFfuXN6QyN8Cw4cIYxly+XHQ4+eOc2B8k8CmuKlQHyo6ihLAd586z+O/e X-Gm-Gg: AYBFou1ZluUA9n58zKRnXYZMs43CBf/H+0TSjDIPgO//HHlb8G3tcVJS39OpH54IFS7 vXnvYuT0ctX6/hBhYYGo+qsR0i2DG01djDE/jnIpR1e9iRB+ptiluutH5oOdfhXmdL5DxpACeDE sg4PnZ5Vp97F9VWnxbsypgrXWPr/+I39Zlxjn/qTi3ZYxPgpsp6qYY+KpjN59UX8PFVTPt7wteu a5dUL5jfeqxYvyCPD0m/xpCq67R0VoK24/Q6koMEkaMpgR01ux6KknzLWQkqlg+Z+Hn0qe5quL0 PgF+TtKAA1BoV4WUJfqa+owC8fbx2de+rV5Q8LtkMA28zrTVbcseUtsKqTssfaHEhW6AD4jlQNz 33iqOpekPathEgfs8lWfe+tBjaYS8xbtRi9VKsmEhqrLEYxOOIwFXgtsfYtNnJm2ogSzKf/N9kw gQGGL2TPFEmTYpuIgWukNcuvvCK8lpL0YPCOdshml8/nU5j7I1aaNJ2VaJ07JmnW/qcMLUBrFpf TQyMZEPYsUSuaj4jt7/vSREPSt3ckxQozSVott1KaCnVA== X-Received: by 2002:a05:600c:3b0a:b0:4a0:f4:1c76 with SMTP id 5b1f17b1804b1-4a18e448987mr196290585e9.4.1791819508387; Mon, 12 Oct 2026 08:38:28 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:38 +0200 Subject: [PATCH v2 45/50] tests/qtest: ina238: cover the operating modes MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-45-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815522; l=4308; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=lzxHz2iTzcTzaY4NX8qYKf/WE7cfp3wqr3BkHmJe9dY=; b=Gz0KMMxcqiIBjZWupaaaQONqSo2+vNw8uNiH6cijXNE/ZLXKYJndLY3cRooT7oqH+UBxqWQ2H EBez46XgVouARQK88TRDGiA9YO6bK1TwBk/qBEFMvgft/UsMuj96i7o X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.48; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f48.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819539919158500 Add coverage for the ADC_CONFIG MODE field: shutdown modes perform no conversion and leave the measurement registers and CNVRF untouched, triggered modes convert once per ADC_CONFIG write, and continuous channel-select modes refresh only the enabled measurement registers. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina238-test.c | 70 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 70 insertions(+) diff --git a/tests/qtest/ina238-test.c b/tests/qtest/ina238-test.c index 74912424c0..fb7bcc265c 100644 --- a/tests/qtest/ina238-test.c +++ b/tests/qtest/ina238-test.c @@ -304,6 +304,73 @@ static void test_adcrange(void *obj, void *data, QGues= tAllocator *alloc) g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x1F40); } =20 +/* Shutdown converts nothing: registers are held, CNVRF stays clear. */ +static void test_mode_shutdown(void *obj, void *data, QGuestAllocator *all= oc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_SHUNT_CAL, 0x1000); + qmp_ina238_set("shunt-voltage", 20000000); + qmp_ina238_set("bus-voltage", 12000000); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x0FA0); + g_assert_cmphex(i2c_get16(dev, REG_VBUS), =3D=3D, 0x0F00); + + /* Clear CNVRF, then enter shutdown (MODE =3D 0). */ + (void)i2c_get16(dev, REG_DIAG_ALRT); + i2c_set16(dev, REG_ADC_CONFIG, 0x0000); + + /* Injecting while shut down performs no conversion: registers are hel= d. */ + qmp_ina238_set("shunt-voltage", 40000000); + qmp_ina238_set("bus-voltage", 24000000); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x0FA0); + g_assert_cmphex(i2c_get16(dev, REG_VBUS), =3D=3D, 0x0F00); + + /* No conversion completed, so CNVRF stays clear. */ + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_CNVRF, =3D=3D, 0); +} + +/* Triggered modes convert once per ADC_CONFIG write. */ +static void test_mode_triggered(void *obj, void *data, QGuestAllocator *al= loc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_SHUNT_CAL, 0x1000); + qmp_ina238_set("shunt-voltage", 20000000); + + /* Enter triggered bus+shunt+temp mode: one conversion. */ + i2c_set16(dev, REG_ADC_CONFIG, 0x7000); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x0FA0); + + /* A new input does not convert until the next trigger. */ + qmp_ina238_set("shunt-voltage", 40000000); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x0FA0); + + /* Re-triggering with another ADC_CONFIG write samples the new input. = */ + i2c_set16(dev, REG_ADC_CONFIG, 0x7000); + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x1F40); +} + +/* A bus-only mode refreshes the bus register alone; the rest are held. */ +static void test_mode_channels(void *obj, void *data, QGuestAllocator *all= oc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_SHUNT_CAL, 0x1000); + qmp_ina238_set("shunt-voltage", 20000000); + qmp_ina238_set("bus-voltage", 12000000); + + /* Continuous bus-only mode. */ + i2c_set16(dev, REG_ADC_CONFIG, 0x9000); + qmp_ina238_set("shunt-voltage", 40000000); + qmp_ina238_set("bus-voltage", 24000000); + + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x0FA0); + g_assert_cmphex(i2c_get16(dev, REG_VBUS), =3D=3D, 0x1E00); +} + /* Clamping at full scale and the MATHOF flag */ static void test_overflow(void *obj, void *data, QGuestAllocator *alloc) { @@ -548,6 +615,9 @@ static void ina238_register_nodes(void) qos_add_test("power", "ina238", test_power, NULL); qos_add_test("zero-cal", "ina238", test_zero_cal, NULL); qos_add_test("adcrange", "ina238", test_adcrange, NULL); + qos_add_test("mode-shutdown", "ina238", test_mode_shutdown, NULL); + qos_add_test("mode-triggered", "ina238", test_mode_triggered, NULL); + qos_add_test("mode-channels", "ina238", test_mode_channels, NULL); qos_add_test("overflow", "ina238", test_overflow, NULL); qos_add_test("alert-shunt", "ina238", test_alert_shunt, NULL); qos_add_test("alert-bus", "ina238", test_alert_bus, NULL); --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819594; cv=none; d=zohomail.com; s=zohoarc; b=jBfN2kF5Wd1YCHxFfbMguDkLC/kxK7YfJMiiGimMhUzfjw74s0UQAntHooMJMuZ3BZDEKCMQ6PJkC/pCvp9KuMsO7ABFgEOq97Q1UjpNIKlrLqhQnIiB4DBtfppSP+eieKoexuCuLB83qP6C8kK8Y4YF22n7zekF2bSRX2HPxEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819594; 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:Sender:Subject:Subject:To:To:Message-Id; bh=YTjYUeqnG0FlRaXGHN4hD5QBCzdcaj4DW5tltJJmmu4=; b=iAX3Pz9a7OeJIe5nqfO4LFqqL+7sCWkSZ0pvSUR4ja2LSi/ntw+t6SCBmoIxWcCxVcEEG1TNKRdrTa1pLYVe4mMuoUewhR+wFviAOyBG70xHHC2KhXneWX4qhJDhQNHRCn/7kGzsDdvfC3Pz+IQFoVVEvZRrmly6YbxMgpyJL/s= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791819594246129.97267664134324; Mon, 12 Oct 2026 08:39:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGI7k-000385-50; Mon, 12 Oct 2026 11:39:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGI7i-00037Q-8s for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:39:34 -0400 Received: from mail-wm1-f48.google.com ([209.85.128.48]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGI7g-0003hg-7v for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:39:33 -0400 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4a020e65269so12695005e9.2 for ; Mon, 12 Oct 2026 08:39:31 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18c198134sm296467685e9.15.2026.10.12.08.39.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:39:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819571; x=1792424371; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YTjYUeqnG0FlRaXGHN4hD5QBCzdcaj4DW5tltJJmmu4=; b=Q7xCit10cFzCKuBcOTJX8XTEUynZUcYkGS0vZwZbTEt+iGwikrvgs39kIDIglVjlwb cwPpwW89dtz4acRUkPYfZFffaTp+4e3lxEQSuc2f84naXif6qG0OOqqhsoCq6VAC17KO aNTpmkYjX0PJEEdx+HSRB3RrIcFkYoS/2Lfd8MqC729I4DM7CqeuWbsnil49DTMSDbuD m/a3nDH0Bv5JIl0vC5yRB0fYTNQeCfYBrr+miTafMQ+Uq8/e4dnPYUgOiV8z3H9uvcJj NctXc1Hfkmm+sMW0qqEva580AWylioomfzfWJdvwXaBWoIQJOsXXSj6CSy+nd3jD/Yl3 EL7A== X-Gm-Message-State: AFq9FYKSqLFV7youruj8tZzd9POjI4AVFx4S+Rrr30b8RNAMb2E+H0aC TYGYK7B/D6lnhkrVsKBIKPm9pf13WVftaWzLEdJr1Zh6Oi/WR11pRyEkNoHtdaVh X-Gm-Gg: AYBFou1gnzPOL43Ifk0AKQFkAVS4p+Di1XjBw0RxM69fbV4+PAA+iekBlmXJg5bsyEB 8P2TAQpPc9d7BAeuP+l9UEfT2FLfsE03eopCoIuf194cy9RoV0OhaS60YYfFMwNlcxfmnsl0EET uq4dIB5TpEdyLEqNzR0PLNLbMRXGzd8LWbhxyQ0uvZyiCfvfupsmBLWf/mHs9OYSBMTmZcjNqWB H6Dhrrbbz+xMwneMm81m4FQXNdwBUI9fHIiDvupSl5ZJvRBgBcwNUReqzpKMNYq/XuRPYd85I9Y 2DiEj6lMw++snE7TOE7KZ8EK+UcGO5XIAlCmsW2E7ZI7cCEVh3+Yv2RaFFheaLjT9tI/PNYidrN cg9d2HIuZnSiwA1aOZ1Cu9r7Rs1DYjPAN6pYWXkomTIPDWVOCMQweXiRQWGSGDbhTetCYK7e05Y KgY1IlWAxOducS4J670bEdXkStbnn0N4f9G0Tv28V1Q1zOFnN9SVmSwsK+C9Qy3FbTikKu+vdPB HD6uUipBab0AIaQaTFqQ4IFmp8013LmtjBo9CgkGk6FMJY= X-Received: by 2002:a05:600c:6215:b0:4a0:eae0:b30e with SMTP id 5b1f17b1804b1-4a18e4ca157mr161813135e9.22.1791819570538; Mon, 12 Oct 2026 08:39:30 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:39 +0200 Subject: [PATCH v2 46/50] tests/qtest: ina238: cover conversion-ready and alert-latch semantics MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-46-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815522; l=6797; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=MyS/xSNcSv5LSSPZg2ndQf9zSlLfmLoiztp1hbYzpOs=; b=xnDUphlTqyJPwfS1ABCmgzR8NLRAFXaxpNYp8MXZSigjJvc4CkVRyT/sV5eGoNiWW1ynbCYSV QuPbxeUXX/RBGxUdr/recPupa2F8U4Io0H+Tc5tmt6LJV3cPAwozzX3 X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.48; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f48.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819595112158500 Add coverage for the DIAG_ALRT flag-clearing rules: which of a read and a write clears CNVRF and the limit flags in each alert mode, and that a conversion only re-evaluates the flags of the channels it converted. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina238-test.c | 127 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 127 insertions(+) diff --git a/tests/qtest/ina238-test.c b/tests/qtest/ina238-test.c index fb7bcc265c..e7dd50a822 100644 --- a/tests/qtest/ina238-test.c +++ b/tests/qtest/ina238-test.c @@ -494,6 +494,106 @@ static void test_alert_latch(void *obj, void *data, Q= GuestAllocator *alloc) g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, 0= ); } =20 +/* In latch mode a read releases the flag even while the fault persists. */ +static void test_alert_latch_persist(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_SOVL, 0x1000); + i2c_set16(dev, REG_DIAG_ALRT, DIAG_ALATCH); + + qmp_ina238_set("shunt-voltage", 97200000); + + /* First read shows the latched flag and clears it */ + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, + DIAG_SHNTOL); + + /* Fault still present but no new conversion: the flag stays cleared */ + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, 0= ); + + qmp_ina238_set("shunt-voltage", 97200000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, + DIAG_SHNTOL); +} + +/* + * In transparent mode a limit flag follows the live condition: a read lea= ves + * it set while the fault persists. + */ +static void test_alert_transparent_persist(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_SOVL, 0x1000); + + qmp_ina238_set("shunt-voltage", 97200000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, + DIAG_SHNTOL); + + /* Repeated reads do not clear the flag while the fault is still prese= nt. */ + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, + DIAG_SHNTOL); + + /* A conversion with the fault gone clears it. */ + qmp_ina238_set("shunt-voltage", 5000000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, 0= ); +} + +/* A DIAG_ALRT write releases a latched limit flag as a read does. */ +static void test_alert_latch_write_clears(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_SOVL, 0x1000); + i2c_set16(dev, REG_DIAG_ALRT, DIAG_ALATCH); + + qmp_ina238_set("shunt-voltage", 97200000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, + DIAG_SHNTOL); + + /* The read above cleared it; re-latch it with another conversion. */ + qmp_ina238_set("shunt-voltage", 97200000); + + /* A write (keeping latch mode) clears the flag while the fault persis= ts. */ + i2c_set16(dev, REG_DIAG_ALRT, DIAG_ALATCH); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, 0= ); + + /* The next conversion re-asserts the still-present fault. */ + qmp_ina238_set("shunt-voltage", 97200000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, + DIAG_SHNTOL); +} + +/* + * A conversion only re-evaluates the flags of the channels it converted: = the + * shunt register a bus-only conversion left stale must not resurrect one. + */ +static void test_alert_channel(void *obj, void *data, QGuestAllocator *all= oc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_SOVL, 0x1000); + i2c_set16(dev, REG_DIAG_ALRT, DIAG_ALATCH); + + qmp_ina238_set("shunt-voltage", 97200000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, + DIAG_SHNTOL); + + /* Continuous bus-only mode */ + i2c_set16(dev, REG_ADC_CONFIG, 0x9000); + qmp_ina238_set("bus-voltage", 12000000); + + g_assert_cmphex(i2c_get16(dev, REG_VSHUNT), =3D=3D, 0x4BF0); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_SHNTOL, =3D=3D, 0= ); +} + /* DIAG_ALRT control bits are writable; status bits are read-only */ static void test_diag_control(void *obj, void *data, QGuestAllocator *allo= c) { @@ -529,6 +629,25 @@ static void test_cnvrf(void *obj, void *data, QGuestAl= locator *alloc) g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_CNVRF, =3D=3D, 0); } =20 +/* A DIAG_ALRT write clears CNVRF only in latch mode. */ +static void test_cnvrf_write(void *obj, void *data, QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + /* Latch mode: a write clears CNVRF. */ + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_DIAG_ALRT, DIAG_ALATCH); + qmp_ina238_set("shunt-voltage", 20000000); + i2c_set16(dev, REG_DIAG_ALRT, DIAG_ALATCH); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_CNVRF, =3D=3D, 0); + + /* Transparent mode: a write does not clear CNVRF. */ + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + qmp_ina238_set("shunt-voltage", 20000000); + i2c_set16(dev, REG_DIAG_ALRT, 0x0000); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_CNVRF, =3D=3D, DI= AG_CNVRF); +} + /* Shunt-voltage injection limits */ static void test_shunt_limits(void *obj, void *data, QGuestAllocator *allo= c) { @@ -625,7 +744,15 @@ static void ina238_register_nodes(void) qos_add_test("alert-power", "ina238", test_alert_power, NULL); qos_add_test("alert-multi", "ina238", test_alert_multi, NULL); qos_add_test("alert-latch", "ina238", test_alert_latch, NULL); + qos_add_test("alert-latch-persist", "ina238", test_alert_latch_persist, + NULL); + qos_add_test("alert-transparent-persist", "ina238", + test_alert_transparent_persist, NULL); + qos_add_test("alert-latch-write-clears", "ina238", + test_alert_latch_write_clears, NULL); + qos_add_test("alert-channel", "ina238", test_alert_channel, NULL); qos_add_test("diag-control", "ina238", test_diag_control, NULL); qos_add_test("cnvrf", "ina238", test_cnvrf, NULL); + qos_add_test("cnvrf-write", "ina238", test_cnvrf_write, NULL); } libqos_init(ina238_register_nodes); --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819654; cv=none; d=zohomail.com; s=zohoarc; b=R/btz0UzYCQfvYTkb3+qiINT1/wNaQBy6a6F7Ocbh/O60nsqn0yGPuDnmGuTvE+9sCwb3lwe5TFqN/p4sIfo/0XZ53bVMMQSS3XI4paRB2cRWT5H2YdkMi+pzojazod8ETo1W92wHl+BdCZtU0L0mMBqrvlFajrdfMV2DhUnJ6Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819654; 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:Sender:Subject:Subject:To:To:Message-Id; bh=DtmNqWBTeMCh3h6zcOOCMvs2LhtYSQ9Lz7AsIV3ilrU=; b=RuTHjXtwM4O1wwbimliVmQ8aF7bkRzixGBcS7KmwW4x1kiYq08BbZAc8X0yk7e1g+OzV88tqdCoFzZpgJoTcPcJ4DgRgrOIlrZq+Oo+W9S6KmDx4NATWmABVgiapcgqZIz97H2vUfVBjHrPp/fzMHCmtndqV78+OzzlpEqTJi+Q= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791819654803843.0514740058799; Mon, 12 Oct 2026 08:40:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGI8j-000449-TD; Mon, 12 Oct 2026 11:40:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGI8i-00042W-0x for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:40:36 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGI8g-00041x-9s for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:40:35 -0400 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-48b02b1b4cfso2615753f8f.0 for ; Mon, 12 Oct 2026 08:40:33 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0ab48a7sm101118f8f.24.2026.10.12.08.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:40:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819633; x=1792424433; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=DtmNqWBTeMCh3h6zcOOCMvs2LhtYSQ9Lz7AsIV3ilrU=; b=UsUZk6BDRbkxegnNRrgy2mZZFxMrqWdxevL6E+sGjCXp/6yrpdYDPeJVeQf9A/Aosz l+6hsUKSa4wdxHilDCubryQo9zbehGaeqcZP+0wADhKBOxI46y2nNZaRiyWsW7Ue/rdN tq214jLatv/9D4fse1aso+Falr6esB/PHlz597PXQAZAJBZWxiDwA9ymTa2hubmyJmRT HIR3SPMFslBb6gQNwseEDFAo2SVRgVavZ56Zg8OQBxVIPUUypD8RGzqXbOBUXjpm3iXZ QjVT0fIrNjUPb6VFDQ3pPC78ZVazETyrXbfN8wyoc0bNa8Zg1E/g3tYG77WCPEz8MYht 5u9w== X-Gm-Message-State: AFq9FYJQosUFrQEx7F9XLXi6JfPxkT6CV9Skou3fLCJfnOZvrOC6NWYB +Es+wWAX0YbNxlHLUXfPh7uw7x3TUZjd4XF3eOxArMoXFljs1QtdKJFzaFwSHTCH X-Gm-Gg: AYBFou345qPFrWu3tDtX9xUvPNxE2d0Wzhut9BoOKPuTbAu65DDSR2aGgLJt6RBN/+6 J8tNfnmvdt1bDE52WWujFXCTQz8231Tr6wLSJdSHX9gcDbOLK+BYCWw9enk46yd4EeL8kCvB3O2 Kd9gjX+YdTPqGBLbNle+Iydn3DLB08Gb2DuGZw5j7vgD4KDoXTgwU6Iw1jS7qkL6YIhKw9VtGD8 Iuwq9KKm2yDbr/PnjO2n83F1bNs0XwEKPxVKyLTcAPWimjZAQ19k36mBIVaG50t1oSGb8WulMhx UtJS/UcoFom44RYuqJMu0yFxblT1Tv4E90NulOvQjRstk3o20k4td1ajen/lQp8s7lhrZwJGC+y K5mY2+Eybxz2bUQ4mXXSS5K/mnWiCQCGYtepBM/AD9vfXlfe4XRwZiAjTQuoinPuJOPILRA1v+W 46cfDiFuS7vIP80IoiN6pC0y1Oyty4/tw7kLxso96pV40xnX7B2iX9yvQ/rPXIV1q7KQUCHGTyq V7MhGG/kvVzwa172QWcppv+30DmjCzfN5vxtSYCo1fXlw== X-Received: by 2002:adf:f885:0:b0:488:5468:c23a with SMTP id ffacd0b85a97d-48dbace0ba6mr14073207f8f.17.1791819631671; Mon, 12 Oct 2026 08:40:31 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:40 +0200 Subject: [PATCH v2 47/50] tests/qtest: ina238: cover a cleared calibration per channel MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-47-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815522; l=4048; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=AlHMNosYKAAxMErgMhv2dpLo39gC6fRYeKA3EA+XnDY=; b=i9znjbhG13bAsAynFkdjHhVE3Aru1IvoKMi09Y0UyWvn1LLe5qJ0/G+VSVqhWG2GLtep1YVDm YZWEHcWI2zMA/brdrNV1sVSvI1fRbHiJrYcCq/PS+swf17XQDzBFsPk X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.41; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f41.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819655947158500 Verify that without a calibration value the current and power registers read zero, whichever channels the mode converts. Signed-off-by: Emmanuel Blot Reviewed-by: Glenn Miles --- tests/qtest/ina238-test.c | 48 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 48 insertions(+) diff --git a/tests/qtest/ina238-test.c b/tests/qtest/ina238-test.c index e7dd50a822..4e4146461c 100644 --- a/tests/qtest/ina238-test.c +++ b/tests/qtest/ina238-test.c @@ -282,6 +282,30 @@ static void test_zero_cal(void *obj, void *data, QGues= tAllocator *alloc) g_assert_cmpuint(i2c_get24(dev, REG_POWER), =3D=3D, 0); } =20 +/* Clearing SHUNT_CAL zeroes both derived registers in any mode */ +static void test_zero_cal_channels(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + static const uint16_t modes[] =3D { 0x9000, 0xA000, 0xF000 }; + size_t idx; + + for (idx =3D 0; idx < ARRAY_SIZE(modes); idx++) { + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + i2c_set16(dev, REG_SHUNT_CAL, 0x0FD2); + qmp_ina238_set("shunt-voltage", 97200000); + qmp_ina238_set("bus-voltage", 48000000); + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), !=3D, 0x0000); + g_assert_cmpuint(i2c_get24(dev, REG_POWER), !=3D, 0); + + i2c_set16(dev, REG_ADC_CONFIG, modes[idx]); + i2c_set16(dev, REG_SHUNT_CAL, 0x0000); + + g_assert_cmphex(i2c_get16(dev, REG_CURRENT), =3D=3D, 0x0000); + g_assert_cmpuint(i2c_get24(dev, REG_POWER), =3D=3D, 0); + } +} + /* ADCRANGE changes the shunt LSB, not the current divisor. */ static void test_adcrange(void *obj, void *data, QGuestAllocator *alloc) { @@ -458,6 +482,27 @@ static void test_alert_power(void *obj, void *data, QG= uestAllocator *alloc) g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_POL, =3D=3D, 0); } =20 +/* Clearing SHUNT_CAL drops the power alert with the power reading */ +static void test_alert_power_zero_cal(void *obj, void *data, + QGuestAllocator *alloc) +{ + QI2CDevice *dev =3D (QI2CDevice *)obj; + + i2c_set16(dev, REG_CONFIG, CONFIG_RST); + qmp_ina238_set("shunt-voltage", 97200000); + qmp_ina238_set("bus-voltage", 48000000); + i2c_set16(dev, REG_SHUNT_CAL, 0x0FD2); + i2c_set16(dev, REG_PWR_LIMIT, 0x0100); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_POL, =3D=3D, DIAG= _POL); + + /* Continuous shunt-only: the power register is not reconverted. */ + i2c_set16(dev, REG_ADC_CONFIG, 0xA000); + i2c_set16(dev, REG_SHUNT_CAL, 0x0000); + + g_assert_cmpuint(i2c_get24(dev, REG_POWER), =3D=3D, 0); + g_assert_cmphex(i2c_get16(dev, REG_DIAG_ALRT) & DIAG_POL, =3D=3D, 0); +} + /* Two thresholds crossed at once are reported simultaneously (multi-alert= ) */ static void test_alert_multi(void *obj, void *data, QGuestAllocator *alloc) { @@ -733,6 +778,7 @@ static void ina238_register_nodes(void) NULL); qos_add_test("power", "ina238", test_power, NULL); qos_add_test("zero-cal", "ina238", test_zero_cal, NULL); + qos_add_test("zero-cal-channels", "ina238", test_zero_cal_channels, NU= LL); qos_add_test("adcrange", "ina238", test_adcrange, NULL); qos_add_test("mode-shutdown", "ina238", test_mode_shutdown, NULL); qos_add_test("mode-triggered", "ina238", test_mode_triggered, NULL); @@ -742,6 +788,8 @@ static void ina238_register_nodes(void) qos_add_test("alert-bus", "ina238", test_alert_bus, NULL); qos_add_test("alert-temp", "ina238", test_alert_temp, NULL); qos_add_test("alert-power", "ina238", test_alert_power, NULL); + qos_add_test("alert-power-zero-cal", "ina238", test_alert_power_zero_c= al, + NULL); qos_add_test("alert-multi", "ina238", test_alert_multi, NULL); qos_add_test("alert-latch", "ina238", test_alert_latch, NULL); qos_add_test("alert-latch-persist", "ina238", test_alert_latch_persist, --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819706; cv=none; d=zohomail.com; s=zohoarc; b=Bg9BFN8/bl3EPW8Ja/o+cVO4GOOknVxgRNwCG5YbFHr1l2GAvk9aCl9HL+Gw9rze7a2IKH7NuobZemJNdPupo8hBiEQHqoLIdemqJ1f9hxOuf9B/WReEHAvcqYr1+MUvOk+JTaUP+CY89CMlS52XKfRxsbjRHba1fDVds4muJJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819706; 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:Sender:Subject:Subject:To:To:Message-Id; bh=B93lbF1AB8TDmaiV+Eh5ZQzyxvlqzMHBTF/j93JXN/E=; b=GC06VrrAQr3hltz1AQvCN4i+59RbIgkZ1nDVd98SRKgfPjIgRukIL7nSihj3AR8x8EIDG2vWL805oAKDfisAzkox3FX2Afm7FvLQTaPoMC/5sbmUVZWyQ3abIDbSLReCOlANN5A/0ZYG3Xy9egjFske7qOIKN2zRfCPnDp0lGq4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791819705980508.5388157133333; Mon, 12 Oct 2026 08:41:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGI9j-0004vz-Al; Mon, 12 Oct 2026 11:41:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGI9h-0004ui-83 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:41:37 -0400 Received: from mail-wr1-f46.google.com ([209.85.221.46]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGI9e-0004CJ-Qr for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:41:36 -0400 Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-48b02b1b4cfso2616514f8f.0 for ; Mon, 12 Oct 2026 08:41:34 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0ac35dfsm97864f8f.33.2026.10.12.08.41.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:41:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819693; x=1792424493; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=B93lbF1AB8TDmaiV+Eh5ZQzyxvlqzMHBTF/j93JXN/E=; b=Rj+m5Q0Pq2h/NuiT48EJplp+2KTAOd0p6Qos+l19Dlu5d5rmrJDcQKTjeM+/4pGuHf Hr5aRxG17tL/PI1SDQsI9Dk3yUY2cAJO59XWDrjOP/080ZrsKerTecHM3Z0JJbJ7CJ7j C/ZXAcPzJsQypjWAj7Uxz00tR4TgdjFpw5bayEMCuv7CN9E1fjdkRav5su9ooewnCErS 6yDQ6Wc2VXHEhUiFrUO63Huvn514rNc6RMwfjSlcL6szp1ihedeDz7c9NMoCABMGK5sK fCaVQHIsUek/wvtyUre9uP8jRn9n3ntOShGi9wKKSFYf18HM6GKRUscV0IRVWB+rjeFz gL6A== X-Gm-Message-State: AFq9FYLN8TLI1HCGZXCaL7zuP5snvZxIIKindqT8iuq0L2r67mxs/VNn O7nqkJVfFdWJL2BwHVfZpzWKWQMc82//FKOiQbZwP90rwfeT6TsvSdZFwPR3nLRA X-Gm-Gg: AYBFou3V1Fqr7Jvf2ocbkhP0xn1MhXY8Z9YHC9X3thKGjLKC/VaqjKMhr2im8O2Wx1i 3azwIrCKpLbGvKfFowYSTSYlMIO4zEKQfhrc4ZzPhHMgTuCBWDiI5uv27MAcg6dAvgQtft3HZYK AbDdECxAFhJfzSeP8BipOig7r5yJZmsWfI6pb89SCdcp7PriTi2oRnR/tPQ1tFB5CR4lOzIueW2 8XR5VSoQoKh2ajJxouv4V+QTvP4NDl0Y+ToY9ShLKSKB81PhF31AGiRBuSSv3DY5lRg2FVn++fa mZp/BeY5pw1yOfBP5joX33SmR01xVdZIn/Avzsk4XywAIuFflzQrgeOOz3wSCsp/8aHIxS31bSu 9+5diWcevFmGdvModz7q2sTNnfshS9x+HwnH62Y/i554Wu4RSvkXhlxuHZW4eexFm08QL3h9m/f KaGpIAwHHr5QHo2QmEDqwDOIJkX08xNDMpqDqYDQD/TXjEviBeroTvjz3jUhsGocbTcPLpUGjsm JpRWHHqX7aqjnnnxm3B2u6T6V2BLwMwwQiFmuDnikifYw== X-Received: by 2002:a05:6000:240d:b0:48c:55c1:fb7e with SMTP id ffacd0b85a97d-48db94743e8mr20136133f8f.11.1791819693011; Mon, 12 Oct 2026 08:41:33 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:41 +0200 Subject: [PATCH v2 48/50] hw/arm: minerva: add Facebook BMC machine MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-48-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815522; l=8430; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=1AtBc0pagvipMFLYb/Fka5t4gJc/Ah7jZctQNlIXOxo=; b=tnI5tkj95JsY9ytomSX4IYOqcfNjRWBm6rEFmhVyruiFLy2oeg7T4PQrmAlhGpaD1GVEsH4UA XiX5HwcgaNiBbXd8VN9Vp4MbHDFtSVrbL+5I5XwOnzPJIsAA5cewcdS X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.221.46; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-f46.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819706858158500 Add a machine for the Facebook Minerva Chassis Management Module (BMC), an AST2600-based board modelled from its device tree (aspeed-bmc-facebook-minerva.dts). The board uses INA230 and INA238 power monitors, TMP75 temperature sensors, PCA9555 IO expanders, PCA9545 and PCA9548 I2C muxes, AT24C EEPROMs and a DS1339 RTC. Every device the Minerva device tree describes and QEMU already models is instantiated. The remaining ones (LTC4287, XDP710, MAX31790, PCF8563 and IPMB) have no QEMU model and are left documented as comments. Signed-off-by: Emmanuel Blot --- docs/system/arm/aspeed.rst | 1 + hw/arm/aspeed_ast2600_minerva.c | 180 ++++++++++++++++++++++++++++++++++++= ++++ hw/arm/meson.build | 1 + 3 files changed, 182 insertions(+) diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst index f38f33cbe1..bbd3d9cdf4 100644 --- a/docs/system/arm/aspeed.rst +++ b/docs/system/arm/aspeed.rst @@ -36,6 +36,7 @@ AST2600 SoC based machines : - ``catalina-bmc`` Facebook Catalina BMC - ``sanmiguel-bmc`` Facebook SanMiguel BMC - ``anacapa-bmc`` Facebook Anacapa BMC +- ``minerva-bmc`` Facebook Minerva BMC - ``gb200nvl-bmc`` Nvidia GB200nvl BMC =20 Supported devices diff --git a/hw/arm/aspeed_ast2600_minerva.c b/hw/arm/aspeed_ast2600_minerv= a.c new file mode 100644 index 0000000000..93abc64770 --- /dev/null +++ b/hw/arm/aspeed_ast2600_minerva.c @@ -0,0 +1,180 @@ +/* + * Facebook Minerva Chassis Management Module + * + * Copyright (c) 2026 Meta Platforms, Inc. and affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/arm/aspeed.h" +#include "hw/arm/aspeed_soc.h" +#include "hw/i2c/i2c_mux_pca954x.h" +#include "hw/gpio/pca9552.h" +#include "hw/nvram/eeprom_at24c.h" +#include "hw/rtc/ds1338.h" +#include "hw/sensor/ina230.h" +#include "hw/sensor/ina238.h" +#include "hw/sensor/tmp105.h" + +/* + * Minerva hardware values. + */ +#define MINERVA_BMC_HW_STRAP1 0x00002002 +#define MINERVA_BMC_HW_STRAP2 0x00000800 +#define MINERVA_BMC_RAM_SIZE (2 * GiB) + +/* + * Fan Controller Board (FCB). The Minerva BMC device tree describes six + * identical FCBs, each hanging off one channel of the PCA9548 on i2c2. + */ +static void minerva_fcb_i2c_init(I2CBus *bus) +{ + /* eeprom@50 - atmel,24c128 */ + at24c_eeprom_init(bus, 0x50, 16 * KiB); + /* pwm@5e - maxim,max31790 (no model) */ + /* power-sensor@40/41/44/45 - ti,ina238 */ + i2c_slave_create_simple(bus, TYPE_INA238, 0x40); + i2c_slave_create_simple(bus, TYPE_INA238, 0x41); + i2c_slave_create_simple(bus, TYPE_INA238, 0x44); + i2c_slave_create_simple(bus, TYPE_INA238, 0x45); + /* temperature-sensor@4b - tmp75 */ + i2c_slave_create_simple(bus, TYPE_TMP75, 0x4b); + /* gpio@11/12/13/17 - pca9555 */ + i2c_slave_create_simple(bus, TYPE_PCA9555, 0x11); + i2c_slave_create_simple(bus, TYPE_PCA9555, 0x12); + i2c_slave_create_simple(bus, TYPE_PCA9555, 0x13); + i2c_slave_create_simple(bus, TYPE_PCA9555, 0x17); +} + +static void minerva_pca9545_eeprom_init(I2CBus *bus, uint8_t addr, + unsigned neeprom) +{ + I2CSlave *i2c_mux =3D i2c_slave_create_simple(bus, TYPE_PCA9545, addr); + + for (unsigned idx =3D 0; idx < neeprom; idx++) { + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, idx), 0x50, 8 * KiB= ); + } +} + +static void minerva_bmc_i2c_init(AspeedMachineState *bmc) +{ + /* Reference: aspeed-bmc-facebook-minerva.dts */ + + AspeedSoCState *soc =3D bmc->soc; + I2CBus *i2c[16] =3D {}; + I2CSlave *i2c_mux; + + for (unsigned idx =3D 0; idx < ARRAY_SIZE(i2c); idx++) { + i2c[idx] =3D aspeed_i2c_get_bus(&soc->i2c, idx); + } + + /* &i2c0 */ + /* power-monitor@40/41 - ti,ina230 */ + i2c_slave_create_simple(i2c[0], TYPE_INA230, 0x40); + i2c_slave_create_simple(i2c[0], TYPE_INA230, 0x41); + /* power-monitor@44 - lltc,ltc4287 (no model) */ + /* power-monitor@43 - infineon,xdp710 (no model) */ + /* leds_gpio: gpio@19 - pca9555 */ + i2c_slave_create_simple(i2c[0], TYPE_PCA9555, 0x19); + /* gpio@11/12/13 - pca9555 */ + i2c_slave_create_simple(i2c[0], TYPE_PCA9555, 0x11); + i2c_slave_create_simple(i2c[0], TYPE_PCA9555, 0x12); + i2c_slave_create_simple(i2c[0], TYPE_PCA9555, 0x13); + + /* &i2c1 */ + /* temperature-sensor@4b/4f - tmp75 */ + i2c_slave_create_simple(i2c[1], TYPE_TMP75, 0x4b); + i2c_slave_create_simple(i2c[1], TYPE_TMP75, 0x4f); + /* eeprom@54 - atmel,24c128 */ + at24c_eeprom_init(i2c[1], 0x54, 16 * KiB); + + /* &i2c2 */ + /* i2c-mux@77 (PCA9548) - six Fan Controller Boards */ + i2c_mux =3D i2c_slave_create_simple(i2c[2], TYPE_PCA9548, 0x77); + /* FCB 1 - imux16 (channel 1) */ + minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 1)); + /* FCB 2 - imux17 (channel 0) */ + minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 0)); + /* FCB 3 - imux18 (channel 3) */ + minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 3)); + /* FCB 4 - imux19 (channel 2) */ + minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 2)); + /* FCB 5 - imux20 (channel 4) */ + minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 4)); + /* FCB 6 - imux21 (channel 5) */ + minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 5)); + /* imux22/imux23 (channels 6/7) - empty */ + + /* &i2c3 */ + /* i2c-mux@72 (PCA9545) - imux24-27, eeprom@50 on each channel */ + minerva_pca9545_eeprom_init(i2c[3], 0x72, 4); + + /* &i2c4 */ + /* i2c-mux@72 (PCA9545) - imux28-31, eeprom@50 on each channel */ + minerva_pca9545_eeprom_init(i2c[4], 0x72, 4); + + /* &i2c5 */ + /* i2c-mux@72 (PCA9545) - imux32-35, eeprom@50 on each channel */ + minerva_pca9545_eeprom_init(i2c[5], 0x72, 4); + + /* &i2c6 */ + /* i2c-mux@72 (PCA9545) - imux36-39, eeprom@50 on each channel */ + minerva_pca9545_eeprom_init(i2c[6], 0x72, 4); + + /* &i2c7 - empty */ + /* &i2c8 - empty */ + + /* &i2c9 */ + /* eeprom@50 - atmel,24c64 */ + at24c_eeprom_init(i2c[9], 0x50, 8 * KiB); + /* rtc@51 - nxp,pcf8563 (no model) */ + /* rtc@68 - dallas,ds1339 */ + i2c_slave_create_simple(i2c[9], TYPE_DS1339, 0x68); + + /* &i2c12 */ + /* i2c-mux@70 (PCA9545) - imux40-42 eeprom@50, imux43 empty */ + minerva_pca9545_eeprom_init(i2c[12], 0x70, 3); + + /* &i2c13 */ + /* i2c-mux@70 (PCA9545) - imux44-46 eeprom@50, imux47 empty */ + minerva_pca9545_eeprom_init(i2c[13], 0x70, 3); + + /* &i2c14 */ + /* ipmb@10 - ipmb-dev (no model) */ + + /* &i2c15 */ + /* eeprom@50 - atmel,24c128 */ + at24c_eeprom_init(i2c[15], 0x50, 16 * KiB); + /* eeprom@56 - atmel,24c64 */ + at24c_eeprom_init(i2c[15], 0x56, 8 * KiB); +} + +static void aspeed_machine_minerva_class_init(ObjectClass *oc, + const void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + AspeedMachineClass *amc =3D ASPEED_MACHINE_CLASS(oc); + + mc->desc =3D "Facebook Minerva BMC (Cortex-A7)"; + amc->soc_name =3D "ast2600-a3"; + amc->hw_strap1 =3D MINERVA_BMC_HW_STRAP1; + amc->hw_strap2 =3D MINERVA_BMC_HW_STRAP2; + amc->fmc_model =3D "mx66l1g45g"; + amc->spi_model =3D NULL; + amc->num_cs =3D 2; + amc->macs_mask =3D ASPEED_MAC3_ON; + amc->i2c_init =3D minerva_bmc_i2c_init; + mc->default_ram_size =3D MINERVA_BMC_RAM_SIZE; + aspeed_machine_class_init_cpus_defaults(mc); +} + +static const TypeInfo aspeed_ast2600_minerva_types[] =3D { + { + .name =3D MACHINE_TYPE_NAME("minerva-bmc"), + .parent =3D TYPE_ASPEED_MACHINE, + .class_init =3D aspeed_machine_minerva_class_init, + } +}; + +DEFINE_TYPES(aspeed_ast2600_minerva_types) diff --git a/hw/arm/meson.build b/hw/arm/meson.build index bcc068de04..a9e8270b85 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -63,6 +63,7 @@ arm_common_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: fil= es( 'aspeed_ast2600_fby35.c', 'aspeed_ast2600_fuji.c', 'aspeed_ast2600_gb200nvl.c', + 'aspeed_ast2600_minerva.c', 'aspeed_ast2600_rainier.c', 'aspeed_ast2600_sanmiguel.c', 'aspeed_ast10x0.c', --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819775; cv=none; d=zohomail.com; s=zohoarc; b=HgrfsnBC/aBfn35makMS+f+M8LWyN5ipDkvZZzCnEodvyO4Ug7OWYijfz9fFep5wELNuS3D5SXOyRgZbAlj7RB5pTAg17YWj9nPYa6NlK862d3Xf9CZkeqlgh70A5IvcRosLBKJuEBaNA1hPgOS7adsl3d7nJA874pRu1u++aCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819775; 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:Sender:Subject:Subject:To:To:Message-Id; bh=VzQGu6sEjJGgi7AoIexbG2f3S2/FIKUHjDnFgptrAeE=; b=oLjG0UYhyXUoUSL0IMVCbphtj6sSZpEkxHv12SZaKzpcRftszHLpPMHCJlKVAuG8UrZ3Q+JpG7wi/8JtEYbwcbU/kdteklnDCvBBtB8lWLWK+zNnBkK/Ni7UqfZVAA4zB7YhK4K0bSxkQ1D1+cdEZNrQYe2CocYM+7t0U40Udk4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791819775673965.5050004324985; Mon, 12 Oct 2026 08:42:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGIAo-0005kU-HL; Mon, 12 Oct 2026 11:42:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGIAn-0005jR-48 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:42:45 -0400 Received: from mail-wm1-f44.google.com ([209.85.128.44]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGIAe-0004Ka-LI for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:42:44 -0400 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4a02667ccebso14090785e9.0 for ; Mon, 12 Oct 2026 08:42:36 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18c1e33d2sm407370775e9.0.2026.10.12.08.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:42:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819755; x=1792424555; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=VzQGu6sEjJGgi7AoIexbG2f3S2/FIKUHjDnFgptrAeE=; b=HvdstyYlwcxnNkUXCuaOrUqqFNtRivSynYdidJWO9yHQx4iOGLiP4ZR2gmo6b2xOJ2 qN1m8jOFN95qCaAZy3EgfIYjWikgxwk06FG0OFYNLUIP43gtgbjdlgZwttzcg/ptTG/+ dykqN+Ud8MuunSW96u51P63KXo2mEKZOSzlUBRQjX9/h5GP5Rk+9o+Phh6Lm+iDwG4Ma yx4nHVPM14uJ6kmi6PV88fVYc7icaWICjxheYpB5rXB3jtrfQ8FXjUrCBX7Tqi8QH+f8 zpoTFWxMwjCuBYZ3EdkOcq1XIIS7Z4zOVowUUH+DTBlzJ+HRHEOipyHkudRV4DXlobPU nUnw== X-Gm-Message-State: AFq9FYIzFuA+yE8JyAvnKvfDeIk0kIGiRHA2g148hUeUp9+GfP0CmW/k 8YcL5CI0wSIuhkQucCLUgbcpDEri0JK+VN7rtTkyQ6OOSjA6rlW3VGNZvkjWrK5j X-Gm-Gg: AYBFou17YXeqIMojhpxuFyhIQw3zlI0wHYejumfgKfywHiHKnn64NEhNT+Unmyp6+pT D8Ma6yop08a6sXB+PgDvkn4yZH6Ix/7yFZUti2zGtGU6ZlJ75dl45OX5SCxnOCcmpMEPIqsxz7C cy8114TgF4m/2xbG/w0hzZksR4OCMyhuOoUjEz0DukmI5EnSAxxkgT22JyDxvHdGov/i86Ijfjj DeVKW4H8NKS1st4ltJsmZMydugmz/xfGVHuGoXfLBY0HFInkfQ2LnqAL8OICdnlKSN3v8zVzMfE U7bFIvn1niUdpsiI7jqzHPa80sP5HGaFcpwvVLvThVujYuYrPVzHg4LssZMNc4rh0dOI2crLg+P LUK8FUGoOL9RP+MG+MAyPCBX1nzD0OxYRumsuUZ177YTfmYoXaZwrTzap1haFrFpn+CSp8oC87A TPbXU8bCimaeZHkt0hodT+K4weAd3WvcOtTHAxTXe6LLVs9mC97Z/h9NamDdM2DfJlHZDG3jWyM /mTrCwpXYnpNJ2WmJMCu5xCtaoYaz4jrUGNi6y/ZXmsvg== X-Received: by 2002:a05:600c:524d:b0:4a1:702f:c736 with SMTP id 5b1f17b1804b1-4a18e446461mr195136725e9.3.1791819754582; Mon, 12 Oct 2026 08:42:34 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:42 +0200 Subject: [PATCH v2 49/50] hw/arm: minerva: populate EEPROM data MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-49-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815522; l=48642; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=lVD8efxZPc7oCiW6ND0ETG6NO0vpih+lOG0sDZbPeO4=; b=rOyx2DOWb5qjcKfsG007hSY1UpsZBr2lkI/KBSBlZ+0FGIJTov02FNvQOtpppAb8c1YrMZDCj GLm1T4SmaUxCgrVq4pOdOs76mk++uTaQv/p3FdjWJiR9yxpRnHwUOz4 X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.44; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f44.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819776144158500 The board carries 31 FRU EEPROMs: three on the management module itself, one per fan controller board, and the rest on the compute and switch boards reached through the I2C muxes. Populate them from a sanitized dump read from hardware, so guest firmware can identify the chassis inventory instead of finding blank parts. Signed-off-by: Emmanuel Blot Reviewed-by: Jamin Lin --- hw/arm/aspeed_ast2600_minerva.c | 714 ++++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 695 insertions(+), 19 deletions(-) diff --git a/hw/arm/aspeed_ast2600_minerva.c b/hw/arm/aspeed_ast2600_minerv= a.c index 93abc64770..4b6731e279 100644 --- a/hw/arm/aspeed_ast2600_minerva.c +++ b/hw/arm/aspeed_ast2600_minerva.c @@ -24,14 +24,667 @@ #define MINERVA_BMC_HW_STRAP2 0x00000800 #define MINERVA_BMC_RAM_SIZE (2 * GiB) =20 +/* FRU EEPROM content meaningful size */ +#define MINERVA_FRU_LEN 192 + +/* Motherboards behind each of the four i2c3..i2c6 muxes */ +#define MINERVA_MB_PER_MUX 4 + +/* Minerva CMM PVT */ +static const uint8_t cmm_eeprom[] =3D { + 0x01, 0x00, 0x01, 0x08, 0x11, 0x00, 0x00, 0xe5, 0x01, 0x07, 0x17, 0xcb, + 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x31, 0xd0, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0xc0, 0xcc, 0x39, 0x30, 0x38, 0x32, 0x43, 0x33, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0xc0, 0xc1, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x13, 0x01, 0x09, 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, + 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcf, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, + 0x61, 0x20, 0x43, 0x4d, 0x4d, 0x20, 0x50, 0x56, 0x54, 0xce, 0x41, 0x41, + 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, + 0xcb, 0x30, 0x41, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x31, + 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, 0x31, + 0x35, 0xc1, 0x00, 0xef, 0x01, 0x08, 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, + 0x74, 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, + 0x76, 0x61, 0xcb, 0x30, 0x41, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x30, 0x31, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, 0x41, 0x30, + 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0xc4, 0x51, 0x45, 0x4d, 0x55, 0xc0, 0xc1, 0x65, +}; + +/* Minerva_CMM_SCM PVT */ +static const uint8_t scm_eeprom[] =3D { + 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, 0x00, 0xcb, + 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x31, 0xd0, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, + 0x01, 0x0a, 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd3, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x5f, 0x43, 0x4d, + 0x4d, 0x5f, 0x53, 0x43, 0x4d, 0x20, 0x50, 0x56, 0x54, 0xce, 0x41, 0x41, + 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, + 0xcb, 0x30, 0x41, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x32, + 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, 0x31, + 0x30, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6b, 0x01, 0x08, 0x19, 0xc6, + 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, + 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0xcb, 0x30, 0x41, 0x41, 0x30, 0x41, + 0x41, 0x41, 0x30, 0x30, 0x30, 0x31, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, + 0x41, 0x41, 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x33, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0xc0, 0xc1, 0x65, +}; + +/* BMC Storage Module PVT */ +static const uint8_t bsm_eeprom[] =3D { + 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, 0x00, 0xcb, + 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x31, 0xd0, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, + 0x01, 0x0a, 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd6, 0x42, 0x4d, 0x43, 0x20, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x20, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x50, 0x56, 0x54, + 0xce, 0x41, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x35, 0xcb, 0x30, 0x41, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x41, 0x33, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, + 0x30, 0x2e, 0x31, 0x30, 0xc1, 0x00, 0x00, 0x47, 0x01, 0x08, 0x19, 0xc6, + 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, + 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0xcb, 0x30, 0x41, 0x41, 0x30, 0x41, + 0x41, 0x41, 0x30, 0x30, 0x30, 0x31, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, + 0x41, 0x41, 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x33, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0xc0, 0xc1, 0x65, +}; + +/* Minerva Fan Board 1 PVT */ +static const uint8_t fcb1_eeprom[] =3D { + 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, 0x00, 0xcb, + 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x31, 0xd0, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, + 0x01, 0x0a, 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd5, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, 0x46, 0x61, + 0x6e, 0x20, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x50, 0x56, 0x54, 0xce, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x36, 0xcb, 0x30, 0x41, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x30, 0x34, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, + 0x2e, 0x31, 0x30, 0xc1, 0x00, 0x00, 0x00, 0xa6, 0x01, 0x05, 0x19, 0xc6, + 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, + 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0xc0, 0xc3, 0x50, 0x56, 0x54, 0xc0, + 0xc4, 0x51, 0x45, 0x4d, 0x55, 0xc0, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x83, +}; + +/* Minerva Fan Board 2 PVT */ +static const uint8_t fcb2_eeprom[] =3D { + 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, 0x00, 0xcb, + 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x31, 0xd0, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, + 0x01, 0x0a, 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd5, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, 0x46, 0x61, + 0x6e, 0x20, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x50, 0x56, 0x54, 0xce, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x37, 0xcb, 0x30, 0x41, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x30, 0x34, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, + 0x2e, 0x31, 0x30, 0xc1, 0x00, 0x00, 0x00, 0xa5, 0x01, 0x05, 0x19, 0xc6, + 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, + 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0xc0, 0xc3, 0x50, 0x56, 0x54, 0xc0, + 0xc4, 0x51, 0x45, 0x4d, 0x55, 0xc0, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x83, +}; + +/* Minerva Fan Board 3 PVT */ +static const uint8_t fcb3_eeprom[] =3D { + 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, 0x00, 0xcb, + 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x31, 0xd0, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, + 0x01, 0x0a, 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd5, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, 0x46, 0x61, + 0x6e, 0x20, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x50, 0x56, 0x54, 0xce, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x38, 0xcb, 0x30, 0x41, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x30, 0x34, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, + 0x2e, 0x31, 0x30, 0xc1, 0x00, 0x00, 0x00, 0xa4, 0x01, 0x05, 0x19, 0xc6, + 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, + 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0xc0, 0xc3, 0x50, 0x56, 0x54, 0xc0, + 0xc4, 0x51, 0x45, 0x4d, 0x55, 0xc0, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x83, +}; + +/* Minerva Fan Board 4 PVT */ +static const uint8_t fcb4_eeprom[] =3D { + 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, 0x00, 0xcb, + 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x31, 0xd0, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, + 0x01, 0x0a, 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd5, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, 0x46, 0x61, + 0x6e, 0x20, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x50, 0x56, 0x54, 0xce, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x39, 0xcb, 0x30, 0x41, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x30, 0x34, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, + 0x2e, 0x31, 0x30, 0xc1, 0x00, 0x00, 0x00, 0xa3, 0x01, 0x05, 0x19, 0xc6, + 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, + 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0xc0, 0xc3, 0x50, 0x56, 0x54, 0xc0, + 0xc4, 0x51, 0x45, 0x4d, 0x55, 0xc0, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x83, +}; + +/* Minerva Fan Board 5 PVT */ +static const uint8_t fcb5_eeprom[] =3D { + 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, 0x00, 0xcb, + 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x31, 0xd0, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, + 0x01, 0x0a, 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd5, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, 0x46, 0x61, + 0x6e, 0x20, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x50, 0x56, 0x54, 0xce, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x31, 0x30, 0xcb, 0x30, 0x41, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x30, 0x34, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, + 0x2e, 0x31, 0x30, 0xc1, 0x00, 0x00, 0x00, 0xab, 0x01, 0x05, 0x19, 0xc6, + 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, + 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0xc0, 0xc3, 0x50, 0x56, 0x54, 0xc0, + 0xc4, 0x51, 0x45, 0x4d, 0x55, 0xc0, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x83, +}; + +/* Minerva Fan Board6 PVT */ +static const uint8_t fcb6_eeprom[] =3D { + 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, 0x00, 0xcb, + 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x31, 0xd0, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, + 0x01, 0x0a, 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd5, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, 0x46, 0x61, + 0x6e, 0x20, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x50, 0x56, 0x54, 0xce, + 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x31, 0x31, 0xcb, 0x30, 0x41, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x30, 0x34, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, + 0x2e, 0x31, 0x30, 0xc1, 0x00, 0x00, 0x00, 0xaa, 0x01, 0x05, 0x19, 0xc6, + 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, + 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0xc0, 0xc3, 0x50, 0x56, 0x54, 0xc0, + 0xc4, 0x51, 0x45, 0x4d, 0x55, 0xc0, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x83, +}; + +/* Harma motherboards, in i2c3/i2c4/i2c5/i2c6 mux channel order */ +static const uint8_t minerva_mb_eeprom[][MINERVA_FRU_LEN] =3D { + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x32, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x31, 0x33, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x23, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x34, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x31, 0x35, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x21, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x36, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x31, 0x37, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x1f, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x38, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x16, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x31, 0x39, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x1d, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x30, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x32, 0x31, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x24, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x32, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x32, 0x33, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x22, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x34, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x19, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x32, 0x35, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x20, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x36, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x17, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x32, 0x37, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x1e, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x38, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x15, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x32, 0x39, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x1c, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x30, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x33, 0x31, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x23, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x32, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x33, 0x33, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x21, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x34, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x33, 0x35, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x1f, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x36, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x16, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x33, 0x37, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x1d, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x38, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x14, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x33, 0x39, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x1b, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x30, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x34, 0x31, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x22, + }, + { 0x01, 0x00, 0x01, 0x06, 0x10, 0x00, 0x00, 0xe8, 0x01, 0x05, + 0x17, 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, + 0x30, 0x30, 0x31, 0xd0, 0x41, 0x41, 0x41, 0x41, 0x30, 0x41, + 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, + 0x61, 0xd4, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, 0x20, + 0x48, 0x61, 0x72, 0x6d, 0x61, 0x20, 0x4d, 0x42, 0x20, 0x50, + 0x56, 0x54, 0xce, 0x41, 0x41, 0x41, 0x41, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x32, 0xcb, 0x30, 0x41, + 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, 0x41, 0x35, 0xcc, + 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, 0x30, 0x2e, + 0x31, 0x31, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x19, 0x01, 0x08, + 0x19, 0xc6, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x61, 0xcb, 0x54, + 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x76, 0x61, + 0xcb, 0x30, 0x30, 0x41, 0x30, 0x41, 0x41, 0x41, 0x30, 0x30, + 0x41, 0x32, 0xc3, 0x50, 0x56, 0x54, 0xd1, 0x41, 0x41, 0x41, + 0x41, 0x30, 0x41, 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x34, 0x33, 0xc4, 0x51, 0x45, 0x4d, 0x55, 0x00, + 0xc1, 0x20, + }, +}; + +/* The four muxes take a quarter of the table each, by hand-written index.= */ +QEMU_BUILD_BUG_ON(ARRAY_SIZE(minerva_mb_eeprom) !=3D 4 * MINERVA_MB_PER_MU= X); + +/* Switch boards on the i2c12 mux */ +static const uint8_t minerva_smb12_eeprom[][MINERVA_FRU_LEN] =3D { + { 0x01, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0xf3, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc9, 0x43, 0x65, 0x6c, 0x65, 0x73, + 0x74, 0x69, 0x63, 0x61, 0xd1, 0x4d, 0x69, 0x6e, 0x65, 0x72, + 0x76, 0x61, 0x20, 0x4a, 0x61, 0x6e, 0x67, 0x61, 0x20, 0x53, + 0x4d, 0x42, 0xcd, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x34, 0x34, 0xce, 0x41, 0x30, 0x30, + 0x30, 0x30, 0x2d, 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x30, + 0x36, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, + 0x30, 0x2e, 0x30, 0x32, 0xc1, 0x00, 0x00, 0xcc, 0x01, 0x09, + 0x19, 0xc9, 0x43, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x63, + 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, + 0x72, 0x76, 0x61, 0xce, 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, + 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x41, 0x33, 0xc2, 0x4d, + 0x50, 0xcd, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x34, 0x35, 0xc4, 0x51, 0x45, 0x4d, 0x55, + 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf1, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + }, + { 0x01, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0xf3, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc9, 0x43, 0x65, 0x6c, 0x65, 0x73, + 0x74, 0x69, 0x63, 0x61, 0xd1, 0x4d, 0x69, 0x6e, 0x65, 0x72, + 0x76, 0x61, 0x20, 0x4a, 0x61, 0x6e, 0x67, 0x61, 0x20, 0x53, + 0x4d, 0x42, 0xcd, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x34, 0x36, 0xce, 0x41, 0x30, 0x30, + 0x30, 0x30, 0x2d, 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x30, + 0x36, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, + 0x30, 0x2e, 0x30, 0x32, 0xc1, 0x00, 0x00, 0xca, 0x01, 0x09, + 0x19, 0xc9, 0x43, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x63, + 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, + 0x72, 0x76, 0x61, 0xce, 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, + 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x41, 0x33, 0xc2, 0x4d, + 0x50, 0xcd, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x34, 0x37, 0xc4, 0x51, 0x45, 0x4d, 0x55, + 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + }, + { 0x01, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0xf3, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc9, 0x43, 0x65, 0x6c, 0x65, 0x73, + 0x74, 0x69, 0x63, 0x61, 0xd1, 0x4d, 0x69, 0x6e, 0x65, 0x72, + 0x76, 0x61, 0x20, 0x54, 0x61, 0x68, 0x61, 0x6e, 0x20, 0x53, + 0x4d, 0x42, 0xcd, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x34, 0x38, 0xce, 0x41, 0x30, 0x30, + 0x30, 0x30, 0x2d, 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x30, + 0x37, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, + 0x30, 0x2e, 0x30, 0x32, 0xc1, 0x00, 0x00, 0xbc, 0x01, 0x09, + 0x19, 0xc9, 0x43, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x63, + 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, + 0x72, 0x76, 0x61, 0xce, 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, + 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x41, 0x34, 0xc2, 0x4d, + 0x50, 0xcd, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x34, 0x39, 0xc4, 0x51, 0x45, 0x4d, 0x55, + 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + }, +}; + +/* Switch boards on the i2c13 mux */ +static const uint8_t minerva_smb13_eeprom[][MINERVA_FRU_LEN] =3D { + { 0x01, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0xf3, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc9, 0x43, 0x65, 0x6c, 0x65, 0x73, + 0x74, 0x69, 0x63, 0x61, 0xd1, 0x4d, 0x69, 0x6e, 0x65, 0x72, + 0x76, 0x61, 0x20, 0x54, 0x61, 0x68, 0x61, 0x6e, 0x20, 0x53, + 0x4d, 0x42, 0xcd, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x35, 0x30, 0xce, 0x41, 0x30, 0x30, + 0x30, 0x30, 0x2d, 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x30, + 0x37, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, + 0x30, 0x2e, 0x30, 0x32, 0xc1, 0x00, 0x00, 0xc3, 0x01, 0x09, + 0x19, 0xc9, 0x43, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x63, + 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, + 0x72, 0x76, 0x61, 0xce, 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, + 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x41, 0x34, 0xc2, 0x4d, + 0x50, 0xcd, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x35, 0x31, 0xc4, 0x51, 0x45, 0x4d, 0x55, + 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + }, + { 0x01, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0xf3, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc9, 0x43, 0x65, 0x6c, 0x65, 0x73, + 0x74, 0x69, 0x63, 0x61, 0xd1, 0x4d, 0x69, 0x6e, 0x65, 0x72, + 0x76, 0x61, 0x20, 0x54, 0x61, 0x68, 0x61, 0x6e, 0x20, 0x53, + 0x4d, 0x42, 0xcd, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x35, 0x32, 0xce, 0x41, 0x30, 0x30, + 0x30, 0x30, 0x2d, 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x30, + 0x37, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, + 0x30, 0x2e, 0x30, 0x32, 0xc1, 0x00, 0x00, 0xc1, 0x01, 0x09, + 0x19, 0xc9, 0x43, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x63, + 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, + 0x72, 0x76, 0x61, 0xce, 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, + 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x41, 0x34, 0xc2, 0x4d, + 0x50, 0xcd, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x35, 0x33, 0xc4, 0x51, 0x45, 0x4d, 0x55, + 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf1, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + }, + { 0x01, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0xf3, 0x01, 0x0a, + 0x19, 0xc0, 0xc6, 0xf0, 0xc9, 0x43, 0x65, 0x6c, 0x65, 0x73, + 0x74, 0x69, 0x63, 0x61, 0xd1, 0x4d, 0x69, 0x6e, 0x65, 0x72, + 0x76, 0x61, 0x20, 0x54, 0x61, 0x68, 0x61, 0x6e, 0x20, 0x53, + 0x4d, 0x42, 0xcd, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x35, 0x34, 0xce, 0x41, 0x30, 0x30, + 0x30, 0x30, 0x2d, 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x30, + 0x37, 0xcc, 0x46, 0x52, 0x55, 0x20, 0x56, 0x65, 0x72, 0x20, + 0x30, 0x2e, 0x30, 0x32, 0xc1, 0x00, 0x00, 0xbf, 0x01, 0x09, + 0x19, 0xc9, 0x43, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x63, + 0x61, 0xcb, 0x54, 0x32, 0x31, 0x20, 0x4d, 0x69, 0x6e, 0x65, + 0x72, 0x76, 0x61, 0xce, 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, + 0x41, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x41, 0x34, 0xc2, 0x4d, + 0x50, 0xcd, 0x41, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x35, 0x35, 0xc4, 0x51, 0x45, 0x4d, 0x55, + 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + }, +}; + /* * Fan Controller Board (FCB). The Minerva BMC device tree describes six * identical FCBs, each hanging off one channel of the PCA9548 on i2c2. */ -static void minerva_fcb_i2c_init(I2CBus *bus) +static void minerva_fcb_i2c_init(I2CBus *bus, const uint8_t *fru, + uint32_t fru_size) { /* eeprom@50 - atmel,24c128 */ - at24c_eeprom_init(bus, 0x50, 16 * KiB); + at24c_eeprom_init_rom(bus, 0x50, 16 * KiB, fru, fru_size); /* pwm@5e - maxim,max31790 (no model) */ /* power-sensor@40/41/44/45 - ti,ina238 */ i2c_slave_create_simple(bus, TYPE_INA238, 0x40); @@ -48,12 +701,14 @@ static void minerva_fcb_i2c_init(I2CBus *bus) } =20 static void minerva_pca9545_eeprom_init(I2CBus *bus, uint8_t addr, + const uint8_t fru[][MINERVA_FRU_LE= N], unsigned neeprom) { I2CSlave *i2c_mux =3D i2c_slave_create_simple(bus, TYPE_PCA9545, addr); =20 for (unsigned idx =3D 0; idx < neeprom; idx++) { - at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, idx), 0x50, 8 * KiB= ); + at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, idx), 0x50, + 8 * KiB, fru[idx], MINERVA_FRU_LEN); } } =20 @@ -87,46 +742,61 @@ static void minerva_bmc_i2c_init(AspeedMachineState *b= mc) i2c_slave_create_simple(i2c[1], TYPE_TMP75, 0x4b); i2c_slave_create_simple(i2c[1], TYPE_TMP75, 0x4f); /* eeprom@54 - atmel,24c128 */ - at24c_eeprom_init(i2c[1], 0x54, 16 * KiB); + at24c_eeprom_init_rom(i2c[1], 0x54, 16 * KiB, + cmm_eeprom, sizeof(cmm_eeprom)); =20 /* &i2c2 */ /* i2c-mux@77 (PCA9548) - six Fan Controller Boards */ i2c_mux =3D i2c_slave_create_simple(i2c[2], TYPE_PCA9548, 0x77); /* FCB 1 - imux16 (channel 1) */ - minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 1)); + minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 1), + fcb1_eeprom, sizeof(fcb1_eeprom)); /* FCB 2 - imux17 (channel 0) */ - minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 0)); + minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 0), + fcb2_eeprom, sizeof(fcb2_eeprom)); /* FCB 3 - imux18 (channel 3) */ - minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 3)); + minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 3), + fcb3_eeprom, sizeof(fcb3_eeprom)); /* FCB 4 - imux19 (channel 2) */ - minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 2)); + minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 2), + fcb4_eeprom, sizeof(fcb4_eeprom)); /* FCB 5 - imux20 (channel 4) */ - minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 4)); + minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 4), + fcb5_eeprom, sizeof(fcb5_eeprom)); /* FCB 6 - imux21 (channel 5) */ - minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 5)); + minerva_fcb_i2c_init(pca954x_i2c_get_bus(i2c_mux, 5), + fcb6_eeprom, sizeof(fcb6_eeprom)); /* imux22/imux23 (channels 6/7) - empty */ =20 /* &i2c3 */ /* i2c-mux@72 (PCA9545) - imux24-27, eeprom@50 on each channel */ - minerva_pca9545_eeprom_init(i2c[3], 0x72, 4); + minerva_pca9545_eeprom_init(i2c[3], 0x72, + &minerva_mb_eeprom[0 * MINERVA_MB_PER_MUX], + MINERVA_MB_PER_MUX); =20 /* &i2c4 */ /* i2c-mux@72 (PCA9545) - imux28-31, eeprom@50 on each channel */ - minerva_pca9545_eeprom_init(i2c[4], 0x72, 4); + minerva_pca9545_eeprom_init(i2c[4], 0x72, + &minerva_mb_eeprom[1 * MINERVA_MB_PER_MUX], + MINERVA_MB_PER_MUX); =20 /* &i2c5 */ /* i2c-mux@72 (PCA9545) - imux32-35, eeprom@50 on each channel */ - minerva_pca9545_eeprom_init(i2c[5], 0x72, 4); + minerva_pca9545_eeprom_init(i2c[5], 0x72, + &minerva_mb_eeprom[2 * MINERVA_MB_PER_MUX], + MINERVA_MB_PER_MUX); =20 /* &i2c6 */ /* i2c-mux@72 (PCA9545) - imux36-39, eeprom@50 on each channel */ - minerva_pca9545_eeprom_init(i2c[6], 0x72, 4); + minerva_pca9545_eeprom_init(i2c[6], 0x72, + &minerva_mb_eeprom[3 * MINERVA_MB_PER_MUX], + MINERVA_MB_PER_MUX); =20 /* &i2c7 - empty */ /* &i2c8 - empty */ =20 /* &i2c9 */ - /* eeprom@50 - atmel,24c64 */ + /* eeprom@50 - atmel,24c64 (no FRU data captured) */ at24c_eeprom_init(i2c[9], 0x50, 8 * KiB); /* rtc@51 - nxp,pcf8563 (no model) */ /* rtc@68 - dallas,ds1339 */ @@ -134,20 +804,26 @@ static void minerva_bmc_i2c_init(AspeedMachineState *= bmc) =20 /* &i2c12 */ /* i2c-mux@70 (PCA9545) - imux40-42 eeprom@50, imux43 empty */ - minerva_pca9545_eeprom_init(i2c[12], 0x70, 3); + minerva_pca9545_eeprom_init(i2c[12], 0x70, + minerva_smb12_eeprom, + ARRAY_SIZE(minerva_smb12_eeprom)); =20 /* &i2c13 */ /* i2c-mux@70 (PCA9545) - imux44-46 eeprom@50, imux47 empty */ - minerva_pca9545_eeprom_init(i2c[13], 0x70, 3); + minerva_pca9545_eeprom_init(i2c[13], 0x70, + minerva_smb13_eeprom, + ARRAY_SIZE(minerva_smb13_eeprom)); =20 /* &i2c14 */ /* ipmb@10 - ipmb-dev (no model) */ =20 /* &i2c15 */ /* eeprom@50 - atmel,24c128 */ - at24c_eeprom_init(i2c[15], 0x50, 16 * KiB); + at24c_eeprom_init_rom(i2c[15], 0x50, 16 * KiB, + scm_eeprom, sizeof(scm_eeprom)); /* eeprom@56 - atmel,24c64 */ - at24c_eeprom_init(i2c[15], 0x56, 8 * KiB); + at24c_eeprom_init_rom(i2c[15], 0x56, 8 * KiB, + bsm_eeprom, sizeof(bsm_eeprom)); } =20 static void aspeed_machine_minerva_class_init(ObjectClass *oc, --=20 2.50.1 From nobody Thu Oct 22 19:27:20 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=quarantine dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1791819859; cv=none; d=zohomail.com; s=zohoarc; b=B3WPnz3flfzXMFBGJmCzVG/MRbbgxAW1F8nrnxYrhNMsbs1b6PFI56MqmdBOZj7daJHntyWQYce9tbfxOlKPZUbW3FtFskyd1KwNp7DvaWsAk2vKtZTN+C+F9EkD8bkpOmQYCzplR4aiEYbUNpdOwCkgd/AYYYnVMZW5RBjmIqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791819859; 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:Sender:Subject:Subject:To:To:Message-Id; bh=SvxLkYLFxBz+kmta5sRtklppBkoMZNtdkurTxLQZymc=; b=m97jbC1GmRMOTGtKYYaVjAyR7DSTZN12zWQBgDSiyOv6TZYmCtnI6cozZnXe1/hfTOp0ZyQ3KBSKGpUJ/WQtlbhpwWEULKrGcqWsXZ35qzolHpI3NktHsU/Kr0QiA6rPXu5GlmFsuClJmmMB1SAavD9xIBytxRbzN6ZJbrev+gg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791819859336787.1782600256308; Mon, 12 Oct 2026 08:44:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGIBn-0006QX-EX; Mon, 12 Oct 2026 11:43:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGIBg-0006Pm-Fn for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:43:40 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGIBd-0004TM-HQ for qemu-devel@nongnu.org; Mon, 12 Oct 2026 11:43:40 -0400 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4a020e65269so12730265e9.2 for ; Mon, 12 Oct 2026 08:43:37 -0700 (PDT) Received: from localhost (89-93-216-19.hfc.dyn.abo.bbox.fr. [89.93.216.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18bf2343asm549923185e9.9.2026.10.12.08.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 08:43:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791819816; x=1792424616; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=SvxLkYLFxBz+kmta5sRtklppBkoMZNtdkurTxLQZymc=; b=vTCfDjkwH259KLDZejl8AZDWih6Jv7+OJ85N8NonG2mv7tWbH4rut+qUP78D5vjWtb PVQIsTqOtx+parXBA91m6OMhvTijrFYoqnBmW4yvjGPuCu4OR2LlMgY5U64tAf2P7qMe tPNjRe5UGclQsYth5PqNJMI5DRDWRTKNK5uo1eXm+nUd+6lMsKbW5k3zgF4LLpn2UUPR Ffhtd6a+NYwRrCwYNsxTlaLctwJzitR5Pn7SOCspeJlHknv6CUlBoZdms/6Du2lziz2F GT74jdhUYYBcC6EIhijjIgToxpyZCs2VBFw5nlqkdZFiW4g50a1dG3XjZwq8/zDx20p5 MoXg== X-Gm-Message-State: AFq9FYKVmP3PO9wFja9to68xRNqQtyBfZ3renpHs/vGCxDbAKTEnGzYJ F2YXopPGEkgYN3XU9lR4rzK7RTuqZ9oBtNddlmrXjZGSzWMtuDuEGmnIxzOoJA== X-Gm-Gg: AYBFou3RLwNhREKuCYfQQf01xdpUHJu1DbQWT1BMForIA48aqv0OUui1p94kSwEnN0s Ms4gWxNG2ouKWdrP0blLfHGB/8RT8dykM9R8L85ZIMQxtufZl2ueaGjdIxhcWvPimG8n9UCpg5W OZ564uxWQFZhsW7JRP9DEnE7gRJA3dvHtIP0t18if4MMS0AnDdnb0pygbY2D3gCzsBRBhmGDNeA yWprx0mM9XZANRPko8HtsFDs2x86n5VJDy15HazT0ejgIK5XssNzdkP+X+DMX5NmkFpWZamKvB6 kOOcxwL2a7p6t8aYqSzSKVJreOMzoIUy8XfOaWw9KeTh2G4st5m0p16n/MLBKyf58IDFrIVbr38 G7vEDAAtq4WxxGhTp9qTVlX7zg+iZZdFwdrispxHMkAvC8FXMxdKFhiHlUJw5d7XRXCRS969sik N2TG2gQU3p+hh+h6SHNDYWMXcXR0rP2XqXa0hES5YS4panbDXJJjRvq1fFHeFNqjQ3vNTOoyaC2 vk7cMgfvnN4uA/37tfQ806LowB8Dtfnka5w8j52UI94ZA== X-Received: by 2002:a05:600c:46cf:b0:49e:8191:e5cb with SMTP id 5b1f17b1804b1-4a18e4a3ac7mr203566265e9.5.1791819815754; Mon, 12 Oct 2026 08:43:35 -0700 (PDT) Date: Mon, 12 Oct 2026 16:32:43 +0200 Subject: [PATCH v2 50/50] tests/functional/arm: minerva: add BMC boot test MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-bmc-minerva-v2-50-4c3dff084ec9@free.fr> References: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> In-Reply-To: <20261012-bmc-minerva-v2-0-4c3dff084ec9@free.fr> To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Jamin Lin , Kane Chen , Andrew Jeffery , Joel Stanley , Pierrick Bouvier , qemu-arm@nongnu.org, Patrick Leis , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emmanuel Blot X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791815522; l=2482; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=zMnHp1SdNieEAjweeitFky57rPPnAgy18OpmLaUpJ1g=; b=nyi8/XBH9UGmX2jVpKGkPotKXBP+6qgCH8/kFF3zlDpCxKWzlCrCE5166Mwx1mGaS3fPQdgBt lC3vUfcIfIODPHsZmTDAwhyk09JVuJuoJKLKsYYO+a267DsTK/gtylH X-Developer-Key: i=emmanuel.blot@free.fr; a=ed25519; pk=0qFrZ21FAAN8OfVsSoVcCFTk/NMYOWzxJz4paSAVm0g= 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.85.128.42; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f42.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Emmanuel Blot From: Emmanuel Blot 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: 1791819859787158502 Add a functional test booting the Facebook Minerva BMC machine. Note: The boot image currently lives on a personal fork; a TODO in the test notes it should be relocated under legoater/qemu-aspeed-boot before upstreaming. Signed-off-by: Emmanuel Blot --- tests/functional/arm/meson.build | 2 ++ tests/functional/arm/test_aspeed_minerva.py | 30 +++++++++++++++++++++++++= ++++ 2 files changed, 32 insertions(+) diff --git a/tests/functional/arm/meson.build b/tests/functional/arm/meson.= build index 61b00932db..dd1ddf7f6f 100644 --- a/tests/functional/arm/meson.build +++ b/tests/functional/arm/meson.build @@ -16,6 +16,7 @@ test_arm_timeouts =3D { 'aspeed_bletchley' : 480, 'aspeed_catalina' : 480, 'aspeed_gb200nvl_bmc' : 480, + 'aspeed_minerva' : 480, 'aspeed_rainier' : 480, 'bpim2u' : 500, 'collie' : 180, @@ -51,6 +52,7 @@ tests_arm_system_thorough =3D [ 'aspeed_bletchley', 'aspeed_catalina', 'aspeed_gb200nvl_bmc', + 'aspeed_minerva', 'aspeed_rainier', 'bpim2u', 'canona1100', diff --git a/tests/functional/arm/test_aspeed_minerva.py b/tests/functional= /arm/test_aspeed_minerva.py new file mode 100644 index 0000000000..925a82b139 --- /dev/null +++ b/tests/functional/arm/test_aspeed_minerva.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# +# Functional test that boots the ASPEED machines +# +# Copyright (c) 2026 Meta Platforms, Inc. and affiliates. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +from qemu_test import Asset +from aspeed import AspeedTest + + +class MinervaMachine(AspeedTest): + + # TODO: the boot image currently lives on a personal fork; move it und= er + # legoater/qemu-aspeed-boot before upstreaming. + ASSET_MINERVA_FLASH =3D Asset( + 'https://github.com/eblot/qemu-aspeed-boot/raw/refs/heads/minerva-= bmc/images/minerva-bmc/openbmc-20260720025047/' + 'obmc-phosphor-image-minerva-20260720025047.static.mtd.xz', + 'bd713df39d3c09846299a2377315465187a4dcd33c29d3b3d683ef13b59f36bb') + + def test_arm_ast2600_minerva_openbmc(self): + image_path =3D self.uncompress(self.ASSET_MINERVA_FLASH) + + self.do_test_arm_aspeed_openbmc('minerva-bmc', image=3Dimage_path, + uboot=3D'2019.04', cpu_id=3D'0xf00= ', + soc=3D'AST2600 rev A3') + +if __name__ =3D=3D '__main__': + AspeedTest.main() --=20 2.50.1