From nobody Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799395; cv=none; d=zohomail.com; s=zohoarc; b=mCJKXfmUtIsLNLy7bbO4YFUE9M+K1VW3UJQiwgRdJys+eLeFtJ6DoRXAe/nCMY9M1oWiReO2OJDMkolARrmESzolUT4Vu2+PUFhDdJ08E/x8c9MGfmaN3w60FqzSDN2jgwNo2mEplQvi91EP85RvP60Lx3PLarj7MqPZtcc70j8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799395; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=yXN++fw5zgOO6Nzdt5aDXW+w27r6GydROb+GJyYC31Y=; b=CBrwZTjzNvzOb1pnUQh44BXTsT35aUbUC3Fu3WweiQEP7TGX8/XBocAdjyT0VuEMBvOOfPnHQV9M5Sq7HRzQqnHVO9uMS5OoC6vQIYACYgSG9JzKmDv/nWyfVrEBl0oh00QmG05C2qN+glv1l2OfesQgCqSJC0k0tB1ovL1ybsE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799395700416.7351803603233; Mon, 7 Sep 2026 09:43:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cQh-0007Ab-CG; Mon, 07 Sep 2026 12:42:47 -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 1x3cQf-00079f-8w for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12: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 1x3cQd-0002lU-NU for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:42:45 -0400 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-49d036e0e99so12787545e9.1 for ; Mon, 07 Sep 2026 09:42: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 5b1f17b1804b1-49ce58da3acsm859019835e9.0.2026.09.07.09.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:42:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799362; x=1789404162; 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=PNqVRwEo+6wZ9eTvX9PTQTmU98n0adb65RWyV5eNXR7VBdpmJcaA4pqQ9mrakIx+s3 AnIXQ2rm+DXwKN3hxSAs5rVMYgG0uKOnpUQszi4rXxLDqVKssrvHcsBG3RuYAmh5AYgQ ZpGNQt5kCB3XqS9SGDvFKC/xpb7chvY2oHCAlAC5IUQHxOexW0cVE3+QPyZ7lL6VY5kN G5iUCd2TzU6MqQjEopWjAxwHZs6Fua+pbn7DODfBPbDWvNXs7ML6eLspNagSF2sDu9D0 5Fjr1KE4Eq3Qx+caeBpm+PMF22tCIPdGzAeEMHEZTZ3bqOz/XVeRG4jrtMoUssnGAclc Au6g== X-Gm-Message-State: AFuF++mvBZR0IBRO84NSXF8KD9a10t8hF8a+nO38QS/bs34fBmJIFxbz 9HmxvUdf6J0F21RGEkv0SXmnQtHswbOYnjsZeaidZENHcbHyQ6xweJBbECJRnTt5 X-Gm-Gg: AYBFou37AQD+qiwI2IADYPDkJKFlsobcfWvpqFFphUfWBDTNAs6/jC4nJEJVW2hfE2g L5Gle5+5+MdvyC1XIZdcXFLxQJ7cjBHdf6NhB1t0DhneL6zV9Qbb+0Bcff+lZOZ3nKWn/pxK4Y4 9Fn2GNzFy4axtYhdhiTZZh5SqWtpMD/m6oN3zZ1xkH9fwrkZY6hk2ZG5stQJcrII6y9OCRzYcYx 9U2LbOSUrYsvGbY/UgzUNygT+7wzTvsPL4GRVV80epdHObF2M1kxoWvzPWWvsJ3f2lNZ5rR25GA lAQCpnNGCm50dhSIKNlIOEqY/s1JY0yCz+VQctppof5KhSyG5+bEdNG9i+86Uwk/biv1vzLOw+A +do5BHx+y4YD8NmeS1fexJhIibsmXe1XKuc7IMBzm3wPuFYUfVg8iR6uuAi68YhKWZsDk9L/DnK cxGDenzeStDBCwMmnpF15Cf5MJtVZX+gSCoiazgILAvdUNDxpYDuNa39xoynAxXSCl+AS07QVLT 94IAofn1vjGTIulRDN3PbKZsyN4ir/OGt1c84ZT1JLrFw== X-Received: by 2002:a05:600c:4505:b0:49c:dca2:ac47 with SMTP id 5b1f17b1804b1-49cf7fe607cmr220873985e9.2.1788799362092; Mon, 07 Sep 2026 09:42:42 -0700 (PDT) Date: Mon, 07 Sep 2026 18:41:51 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-1-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799319; l=1992; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=jOGxphM6i2yuU0VVdWKJiaxsh0O18wnvUcN3/3+xhQk=; b=Cto8ykDil9oYTgsGQA7AV/sd/46SI4OKM5pjwd/qHnmnAUrZ5/O41M3k3fD3BoRESR9x0Yiqr RO2VXaUU39KA/25jod8P9EPZ8LSlJktDSIebEUsVeyBbuLcZQfdWPhz 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: 1788799400882154100 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 --- 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799443; cv=none; d=zohomail.com; s=zohoarc; b=Vo0m3y7CAnhski9bZ0yt9C/NTbHNW/oKXoizUX2TtMHGfQF8oiDoIOoyWVGtQPZoPk4HDJMACO/l6d681mDvTHO313guHxSGa8HbejVtDk0uOvRTQKajL5bi6he/VhLWd8c6anxefB48JR2sgu50D3DuT5tKf93SLVngypsA5kE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799443; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=pWk7MV0WjBOJc/s9RX0ZBDFXEdiiCKZ4mANozxUHjQs=; b=GP3tWoT0q5SumuCpVsCVvjFWGL2YAA35vNKbylaUeeD56L2TjkhJ7ijEqD5g/Qscke7IFdYNa/wZw4lA3y2SMgjVi3ZGxZBRhIILhsBpUkc4S9D+OFk4duC2i+1BgXr4SQd8ZDJGUciD9YMI+vEXTA+ekCSR3a3LkExXT1atpYo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799443202523.148908756872; Mon, 7 Sep 2026 09:44:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cQs-0007Es-5Z; Mon, 07 Sep 2026 12:42:58 -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 1x3cQq-0007E3-MC for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:42:56 -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 1x3cQp-0002n1-2P for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:42:56 -0400 Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-49b8ce9b733so30213565e9.1 for ; Mon, 07 Sep 2026 09:42: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 5b1f17b1804b1-49ce5927b68sm408228125e9.1.2026.09.07.09.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:42:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799373; x=1789404173; 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=gRZHZaVoAFPDGrWIOJeH3YDwCB1RpBAlgOcGfqOyJdkM+E4ViGe2hQ6JOZa0yE5s3A npFYGDi2REjLbiBdrl4YiyCQNwucheSC8CKeVqQ906kaHo6L0zv1fADO676mxpKLveZC uV0FKUKTmdi1zRTMvzBHpi+rrDmUIf7yx0vbzCK0G3CEtFXxUPz1EuNXyytKpjX3pGlY uSgYRCzF4+l2XZemuXidlPXMjQsW5FFU/pvlHDr6JvGmFZgi/km4xRD/Wo5204QL+Q3y HDMdxdbP1/wbK1jRf3httZx09S6i4aWFOAaUg/PcoyyB4ekFnDpFgh3UKZ2iVNWYBUM8 7AkQ== X-Gm-Message-State: AFuF++lX20R83+2B68nTYlT8QFs7OuPzLhCDS+yaBOGUGQC7FPK4iqK9 eSc9Yr1lCAsQoM+wcBCKeGd/SQD1SNo3kg1nXr7P6M8R7LFQENTDuCOqbMNJYJGq X-Gm-Gg: AYBFou2BVeNMULIRvfzEmE8isI8C/85s/efIO5de0pNF6yiiA1v7xMKoSYdr67Jtm5l STdIjzmLcF4zYLF/UqRHBsGrsCRDq+Cw3DZ/KLbwRsd79QtPB24kKkmcNjRMQatuRm5hrUwlOWG PU0HwKC7508HACVO2OymH9/3RS4yt8hE2ipluNaqD7rU+joULOnRByn+U1cu7E0aAq2n2OcN2ru bfhpC+y4YI9S2gMd6EZb+hsGbaPO2QuBPp0ghcpVHDQhGdkHWijGEisobikZ4SeiCJCPznp2aQS NSn4XWqpWrmCSMqyFsYDqJPF4d16h4onD5PTpDRlvLarm3MgPEqKcus0BbqmPNJ2GIn0Ut9aiFl QlUYi0vSw9fxB940xFF7hHhE/MbrcuKlT/DazO1uRjRQOTOqrF3Hw/b6/yuKMd7K54cjAJnc9vK 3yHWOm0mX4PCsx3cwkmCdhYx+RjDxx3MBN/S+20L1IMsDU97C5AhZGfbVYp2HWFTKantCF/jgZj y1rV6VEL/vsOry1zgwy42UgpJ11rC0B3ck= X-Received: by 2002:a05:600c:4e49:b0:49c:fa20:cc05 with SMTP id 5b1f17b1804b1-49cfa20ccd2mr220297615e9.28.1788799373426; Mon, 07 Sep 2026 09:42:53 -0700 (PDT) Date: Mon, 07 Sep 2026 18:41:52 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-2-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799319; l=827; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=OuuDyLAyQiERaSazvNIfVs0crUzUw8PgfLhgJ7loAvM=; b=4YbwkbfJ2rItupdRU7HedBVqsWVfaM8izdAwpE+mCra/75bjWknMooS+YmE3J9KMGUJk009cz FywRamSunRYAlL52c0gu+MNFZxhDlTwBpa+DwIH5lxMDsHStk8d0Hst 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: 1788799445572158500 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 --- 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799433; cv=none; d=zohomail.com; s=zohoarc; b=nkl1Vcc+WvnFHpjPjlJ/cdrjohggt/B2w7P2Cz46/XCv9lWjiqIGye2zd2zgRtrwtNot6zY2wMFyfUYbCHq4u5npnUMIJUY8v7tXZURmcjw6SHsF5ogJJlFfhg7ip549jRhj8/tmVUfj4LXnS9BouzOZgkfqwCzZLANx/qAxmUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799433; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=6rZV+0Rq4PmlZn+kvmoVgaQLW2OyVLJsEpdjV2a5OvI=; b=SOokQU9UutWYo4dGNk3pl3Z5j8FCcJExgtTAlUYIhkvt2TiKkct+xM/0ful4PiCYbJ2qBlKdjZ3LJObizAtDkYPTpvOaHt0feqGXQtf29IJNgEn4h6yPaMgkgXXFH/FdjGeJiu0x4llR8MsX5/uHldn+ZdN2A8QRzOf+wXSF63Y= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178879943327456.508985666242666; Mon, 7 Sep 2026 09:43:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cR4-0007KJ-H0; Mon, 07 Sep 2026 12:43: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 1x3cR2-0007J6-Bx for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:43:08 -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 1x3cR0-0002oN-Mk for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:43:08 -0400 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-49cca4ffdcfso31085625e9.0 for ; Mon, 07 Sep 2026 09:43:06 -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-49ce46696e8sm291092065e9.0.2026.09.07.09.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:43:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799385; x=1789404185; 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=6rZV+0Rq4PmlZn+kvmoVgaQLW2OyVLJsEpdjV2a5OvI=; b=HQjIohRDviAxiZ9KURvOj4ELkVlEDGVQV9A2U6XmW7Zm0O9gJVMqfaHpI0gqUDVi2Q rEd+4kvgXWbPv+nivz2ozWDizEIu+USuxMmakfAR7MJPgabV2F7JrByAKIkb4bmxqlOm yUzBZZ+QxfeRxWRJsj1ddcDMsCH9Mnalod9QGx8kjvuFztf0zbSxOHhfb8rBfuhd5Dj7 oAzHBhNxT1YZp/iU6OjYgqBF/ZTJK1Ra/D1NMaes4md7K/yvCZe+0d6Jbdc8j5P6PHDe wTIQyM9xmvHB0lZLjh8Lcu/GZbWQ9cJ5/BTrX/57rnZEV+JhGxdBHKyOtjRt/kSc9X3s S38w== X-Gm-Message-State: AFuF++nem3fou5/GO/7blw1vUu3Ya8eZxaqwDhTvvaJmS0v6fPF8WHIV AE9t04KEZa2u2tVxncZZeetfHTL+2wWnrgj9/f744fOKVJa5hxKeZVtc9er4hcGf X-Gm-Gg: AYBFou22QuxJMyOli+x0Ftpkj55jQzRSY1eAror2Km596f+aL+UeXyeL/aHa5awIrq1 ZHcLbyGagdy7KRN22hfbn3ruSeFpQttN3U07ScfPvGVth4NOgYHAkDwvhJ1SbUpElWiUVxjolAf OFgpBggoc5HlsU2rH7IV02qJgcwrzEU6cWIRGhkAGg51jk1aMVd16dcSt+4BK5xskr+9Ok6quER 4xn6e+AV+QaX44cxLJh4SQPs/eCKmLo0gOImtdwJR1F1EsZKLb1pvCj4jBpZhEtUX0XR2Th8AVV IonYDSlJcsb6Y21QnDgdepumw1ExKOd9a1kyk2wsiNmzzug7qpbSl77iU1lv3OjHhAaFHm9xnEx GRHGQrStfLX0AXaW472HZY5EVBUhsTZaRAMN3dlnVdCTFQj+ilJEJEtIqoBnNdK601aw2j9cy2Y q2G/ttraIqfkxv78zr/EuKjUdjc1L4lmSCmWdPQkBLhDC9QwDCmixh2xwNtYk6lE0lgOZkouBsI xrjjxfE6137+V0ERmMZjDJWNRXJRWk8Fj0= X-Received: by 2002:a05:600c:1d0d:b0:49d:99c:3bd9 with SMTP id 5b1f17b1804b1-49d099c3fc9mr105824635e9.33.1788799384968; Mon, 07 Sep 2026 09:43:04 -0700 (PDT) Date: Mon, 07 Sep 2026 18:41:53 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-3-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799319; l=1273; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=A/n8ct+D5Xu+mMgfHstzXeaf3QPL+KzcwDlNWjocwiE=; b=cqM5K1I8x8srHtJZ7eQ24cJrKOwHfhjzCBExf6iCiP2xEGdxhprPiDhShDDYyx3oDp/VNGd/U B4JJR/ufbTqBFIsfEEdq9W8VAmtwiYqQRpn0eDgPFMyknNP6tP8k0oi 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: 1788799436153154100 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 --- 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 599ef1701f..1dbbef11f2 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799422; cv=none; d=zohomail.com; s=zohoarc; b=R8O47sXG3vgkJQZ+2QvtnFV3QQpH+edw9BBaUEjaaKyvCt1mP1nkCzPYJM+fVlTrkuJInum733dC+HvCyqK5mFYGC38p5ySEvQb1MX0pi/V6I0MDI559YAvsSA5OO+CMqxzCKxPx817irKnUgqCYQxcavGy6CwwUTWtravKWI1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799422; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=ojXOoPy7qb9Ji3StIqOoikH1Y+fN6ya8UhzSWcfVEz4=; b=l3CgHU5KkF+lziSotUm3UjhR8dbumbW3aNnQXaoBKTigjutzq3nNIw8TrY82jjnTTn68VNgpD0F/freidlhnW+hDcNTrlGr/jEy/EwuurBpplNjFqCswub68YY9yuPZGP8tWD1pg57KJOuGci1VhRm+nyk4zZboHBpjeuo51TFE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799422383967.9436755719214; Mon, 7 Sep 2026 09:43:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cRF-0007TW-WC; Mon, 07 Sep 2026 12:43: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 1x3cRE-0007QC-A3 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:43:20 -0400 Received: from mail-wr1-f43.google.com ([209.85.221.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cRB-0002pg-RO for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:43:20 -0400 Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-482e067e908so3092477f8f.2 for ; Mon, 07 Sep 2026 09:43:17 -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-4858ac2b4cdsm28550376f8f.16.2026.09.07.09.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:43:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799396; x=1789404196; 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=ojXOoPy7qb9Ji3StIqOoikH1Y+fN6ya8UhzSWcfVEz4=; b=ZThtO8b2qok75u3dhTAF2xUWmfg4tsXNCmI1J9+PsFtAg4SuVSaP9p1MRxM4PWNWHc zrUC/bKoUZL6anfEO6Q28gN1gR5+M2es0uKFkAWoCHqnSkKkWNrHGihGBbLCD5FtRBYD bKO5eQdTQnafeeJx6JvfqIhca1ISxJ2hEBrk9+g+FJaEEDdH0EUsIRC3cpppXHYCPlRb BPbDmz572qYKn/29GxmXZtIOpyiXi1TXQTGLEoK7GRuC2u2KLn2JNMT31X/bUSqlFwyn nEB77V7beaq8BU1fS4M90f6cEO46Bz/6iYFphhwI2hP4nUWWkGq2CjETAuHSU2SjLxel 8CCg== X-Gm-Message-State: AFuF++lDqZk8ewetnsuRLxBrMng84ZuIPE+lbVjgEhPp2cPMohDgHzw2 /ligRiP1/qfgzqJ8N7TTos07wg6htMx78nHc7+Dc2z6PA35oAmoWcAsCkBz0CwHv X-Gm-Gg: AYBFou0kTatbW/buTns4475lTCylXfDhWe03Z2mvjokRhxvTUV7ffet2VdY1LPBgE3A SPY7brOOIzUngsMKw/+7BImZRhunjORNHPKwvmjC+EpKBnFfkq9PaKI070snwt0yObjzCSnnDo0 ne0aCGj30LpZfsyQtpT/uCejfkAMB/QOqu/FoavW1Fq9AQtFVB6gHFfhBAQx6QO29o3vKwc6MUX k2O3P8wyo2WxYo69+AoR66SHrIE72CgXjShdSVvJAuZamzFY3p1x5kHqpUMWaq2aRzyVy2gsZ8L mdKMC6BFkhQLWc5NuvbZWFeFz0djIvPEP2oGQyIpNufDVYTy4ro+b+2IHlFbDMFatT2yS/d6vKM h8Kvn8NKYdZdDvPrszop823kdPYw0e8ih7sprEtyZME4SlJm9SpFZP3zdcfyl9jcA3I4IbxN5Mq 4nNDq2vpmSmTelpulTHpYvkMbndIKnEn6U+uSg0JAGo+xuPLbQqCHxemS05ffyQhTWtanNDW0X/ k4Cteh9wSJe3q/s6ec3yUgKgYsrPTdTl10lvJY5ovUMSw== X-Received: by 2002:a05:6000:1863:b0:485:8a46:704c with SMTP id ffacd0b85a97d-4858a46716bmr21823339f8f.30.1788799396182; Mon, 07 Sep 2026 09:43:16 -0700 (PDT) Date: Mon, 07 Sep 2026 18:41:54 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-4-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799319; l=840; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=uUIqo2cMsRAcBY+czFTMxvhiWXutmm3Zl9xFpRFXck0=; b=zDu2jnqnvbVCx2F+4Yl7UpI+XoysiLJwJphorKoCApt7XdSoDeuVqvz8LYcgIUrNG58L4m+OM optoI6Xt6vcBCMKQws3B6b64hdvAB9MjyaauK3l2NPxwly6BDC2SHWC 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.43; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-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: 1788799426112154100 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 --- 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 c6034460284..c8e75da8b2e 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799450; cv=none; d=zohomail.com; s=zohoarc; b=g/4eZt/ytWsCvfaglDbb+tF/+ngRQ4uNkvPKISjh6B4+8Tz+0MO+YC6hshvVeV5NJmNWk3XxM/B5VWKFddPCyld+hFjXKLIb78kI2vaSIS4zJWOZea5stFDDA2ceIII+utoeFXbPP3CddEUTaJ+cQcp+9GgJoSPxK8SmSi4YTDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799450; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=qc09au/ziPEmptgRaZky6L4t/5n2HyRsY7eNCEjWR84=; b=ErJQUN/cKmJpgzNqclRND+7YjXv1CNjLUELwplOS5RThz90xn/4CnT4+e4lecaE8wrX+hU41vVbS9/vxXSV6qtJj3N4njLhTBljrmkouD7ME09KmKrR7dirwOq472tX5G4IhNLT7vmRYUcmsChUugn+V9jaRfrgUDhWcdYxXu3o= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799450062820.2978464301194; Mon, 7 Sep 2026 09:44:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cRe-0007nc-78; Mon, 07 Sep 2026 12:43: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 1x3cRQ-0007b0-UV for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:43:33 -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 1x3cRN-0002rE-LZ for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:43:32 -0400 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-49b8e527d63so44634325e9.2 for ; Mon, 07 Sep 2026 09:43: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-49ce551bf7asm278333335e9.2.2026.09.07.09.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:43:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799408; x=1789404208; 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=qc09au/ziPEmptgRaZky6L4t/5n2HyRsY7eNCEjWR84=; b=a6HuQY6n1EubCz8ySSdlZAh0kQZhRB13NOgJCl2j9yqrNvAVom26zwZQznkA5QsNcx DoJWm7QaRChJN5obAjyf8o+7ft5CduavTgDzvFWiKMDloHH8xKVt7DCq6y2FhhUyM0+e /UA7nX9axjBjG1gVV4jiplO3o4sVNVC+fBCZmzxM10nf4sIrDERVY5mqp23gqEEg2D33 pRXEaxBpnkPDVfpBU3xy79E6pvmYUh0LtQGErh/9BL1Yg0StUOysv6t2ozZbdXaeC0FC VJzLJc+PBSbTIGGdhbRY/IojODrIaNhH/4a20XkAkSdzkHunjcNXp27dM3WFZLptA8su ydyg== X-Gm-Message-State: AFuF++nFuVX0hBHqFVEjmdgeQf89ZIrqGXDbfAs1LURJZeW+pbV3HMds DU6Dtfc83lSBOh/jOX4VxvATOyApTa8ClrOnKBXu9NrLVkiSws+hrQOVP4m5tVZg X-Gm-Gg: AYBFou1NosIF2FWjXCVJa8AbQbr/WI9Bxr4WfvP1P5rfYzxnBBy0IPnigqb9f99iH1/ 717hvI0WbyQ5uqBKJ9JG8CQMCEynxmlrLamJrFNJUYTQml5E7BUnrxELJrYSgGpBmr8tYk4n/UQ na/Xln4QtT2KPKC98X4mOAzqRp8dZUAF9OZA9Tif+qyMXPqIVJ4Z7+5QLiWG+mWtDMQCAFqC33V g3V14pzQDLR4gDEpY3LFFmFH9D/eJyh4BJnBA34SNKCdplFPuWXChMnLJdHaeoSWxQ4sU0t2X6A QEukalykL7r6EJXcRh8F7Nk+DXBUnwSNBgXD7IDzVr00ciyyPTJzlDiTtG30ppFw9eHg18+KSXY tLGANU4IxcGvrcs03CAFVVY2e1p6cnIdzJ/D0CqVyKGRZouU/cb2oRtUOpVu6UtI2nTaQUA5pI0 IuneIFroPa8wlW8rOn+h6zyiQ6TEfdYiag8/aKVp6pt+mR5ShQkbDvMonGhgy0/NBgSLRSV0os3 FT1oGRGpRqt1J3PIQ4PbvoI9AQrVGFWd58= X-Received: by 2002:a05:600c:6209:b0:49c:fed6:cd3f with SMTP id 5b1f17b1804b1-49cfed6cd4dmr178926145e9.23.1788799407779; Mon, 07 Sep 2026 09:43:27 -0700 (PDT) Date: Mon, 07 Sep 2026 18:41:55 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-5-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799319; l=6619; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=jN11PUN0iIxLB/VOsPy3liNV/U5718SCu3GBbjUm/BQ=; b=c56iercpKB7ct5JF1sNh1xeMobbsC3o5OUjsuwlVUtaHSEUxBHAenaokDzUUDnPoN9ltyWhLY 9hOTvnzE7FhATYaLjDth0MdLUPbBOnFy5BNv7Jnny5l2kAsGklQu6CP 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: 1788799451874158500 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 --- 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 c8e75da8b2e..4bb078a03c4 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 3dd25ec9830..19a10505056 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799464; cv=none; d=zohomail.com; s=zohoarc; b=nVpundopBQeBsQjdItfidEHJ0VwSRO/DPyurqL4DvbWXGyJnuucXSk5EptY7Osx+t+1WHbD7gu570UM4ANNrstBtdFbP5LCgbBuCatZVRd77QyHQ8t2khbY0X0Ja/6l0fHoA3+IvH6LjkdAN2lH+B69HNvcIT0mpkBLPo0qKs0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799464; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=cBS24KyVkFdx9K1mrb9mnaPLSyXbJlcPXKfV6TpuYbc=; b=O0aoVyADVjvDOHGs+FERE00OqxFOj8aRWKcoZFaATyG1GSNz5Cvx258SESolRBcXhBryTISVl+tFaGLc9lyGmB+X6Q5SczPXbJEtnGYbxRbi9eP2ptWUjWbz+3ygXJHokFbbRzRpJg7oXd7PEAnkd2qQq0QygVX86PDb0Z7hvgo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178879946454826.89847836222043; Mon, 7 Sep 2026 09:44:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cRh-0007w7-3v; Mon, 07 Sep 2026 12: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 1x3cRf-0007tS-Fc for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:43:47 -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 1x3cRd-0002uA-Cw for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:43:47 -0400 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-49d036e0e99so12792905e9.1 for ; Mon, 07 Sep 2026 09:43: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-49ce5563c6csm349072185e9.4.2026.09.07.09.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:43:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799420; x=1789404220; 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=ZQmSSBixt8PZKoi+RWOmkj1lKhpyyTLZNjpG1f3yCF/tijy5r6xUAHMBYeJIaN2Lar 9sQCjZ5BUXaoBxeS7wunDfWPst0PZG7u8b5D1FI8d2s8JM2b1AxH1VnsTsAag9L7xyMO 461cc4G//OzdQUUOUHu0vlysR3xJMYizuaL5tM8INbRuLqNJjRrDjRRDe92PpuLq7mj7 KFuh2Yp7mn2fBloCEpA3Ypo77FR1Hw6nAiPTxVRykHKjQzRv38SEkwJvTdYCeuJVRngA zivsiqDd8+NYn1JggdwyQCMUWKGtcTUBeWv0RujxPsakEElI3kXiJg8Jnci6GHy+05mn iIgA== X-Gm-Message-State: AFuF++kbYpPcoSHrWTeN7VN6SrIySjIavp9rFNtHGBUEKSfkGggl/6Fu ZXh4v3QCt1TcKUgsjmbQsogtI4GEamM0Verd+bOPMoOFBIFoGMKad9pelUKsklpn X-Gm-Gg: AYBFou1DQ9WUwPwRjg/5/Rlu8HK71jWskcJXmt1M33pSEinpluAbrHK/TUxeJxDPr0u U57yDeMGNztt8hCq9GDmAiqAysk/B9QipOrPbHhvA2g9OUhZW1UNyomA/lLIv12VLhIqifz4MED 9QzvqXWVpZOGJuRdyt+XBEUxcf0cbqJlp9LGj303tgfKe/HMddIEXBfCe8pW5tu/Pb6SQuiyE0t ZmTOts3mroTYGNjY8wdOOHBy0d6Dme2/eG/330OF2sx4/dtAFYEi166uv4/VMoeJWTq6wMMmPcw hhqkS3/HO7k3UwD2a77zSFKtC9/JA6BWnIcE8bUBZDd7+7MJ+Q/5NIfclHwgEindrN7Dj70YxVH 2ozsSacHBj7UBM/Isa1Nrcsj4bixE65PwTXCb7WVpzXE8JfntJv0F8c6ojntZwJL2sk70KuVPHV 2UTFhB1eeAICiC+dnBnGulPwhbKJsU1Oww0LplJMSruIvCZlNBF9vmoywIxFi2OjPRx+N9EWO+A eYVePvBvM11XmdSN3aaztWz1zT6MqhMbWQ= X-Received: by 2002:a05:600c:474a:b0:49c:e42b:a4ac with SMTP id 5b1f17b1804b1-49cf823f60amr211651975e9.11.1788799420181; Mon, 07 Sep 2026 09:43:40 -0700 (PDT) Date: Mon, 07 Sep 2026 18:41:56 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-6-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799319; l=1912; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=6X3qtF5y9bDFv2QNu2TGa306El/FnP4ElGjKxh8N7cM=; b=RiY+touNeouJPHPg0XaLz54f1yFoRxrHYeecw6h5+E0u9TudjvUcFTHm+cxKznm1V2R++OJcC WWf1JvKmu5fD9TJJYF0+bv84pS8EjMvOlHxF49uXBu7d64srbnWoc5A 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: 1788799466178154100 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 --- 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799453; cv=none; d=zohomail.com; s=zohoarc; b=fgbYHAB9XMZ7vWphAKkdNaEiinzoNZDiYQqYQHnxmkTbZcjwg1EkIToHRV3ZU58rVnP51Jz6DCfAp4Nw3ijQr6fN22Mp0Qp7nJfdrHfEMNttc6PbwCVGi9GtPSeW08L3hxJwCaNJXfJTtex8P9ANDl60wPbk7Y2lNN/c3TurxtE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799453; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=da4bGANhf55tfJs66hIW0MEMPfCwE/DCUaxLMtQ8Qmc=; b=LVEwczKW7hE0gBqJbvBnBueJ9Aa3F8KsGRVg6+2h7ZezbhgaXEUXQPMuE4XQNl7U2SXvSWaioQBYbzuWH7BSQmhCGCAEF+z6qHL5gqR/cnfrH5c1urXSlgct9/IG81y7c/ZrIHjCtGO+OamTjOm5yqgyMCmLcztISxW5dadGDF4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799453333465.11798179726384; Mon, 7 Sep 2026 09:44:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cRp-0008MG-C7; Mon, 07 Sep 2026 12:43:57 -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 1x3cRn-0008Eq-Nz for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:43:55 -0400 Received: from mail-wm1-f49.google.com ([209.85.128.49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cRl-00030y-Tc for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:43:55 -0400 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-49954b88fffso28400995e9.0 for ; Mon, 07 Sep 2026 09:43: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-49d0af538d0sm174307545e9.8.2026.09.07.09.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:43:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799432; x=1789404232; 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=da4bGANhf55tfJs66hIW0MEMPfCwE/DCUaxLMtQ8Qmc=; b=N+7AxZEKLCBor/85Zw9m97X54rfjPK1u8TlSNSMr4GGS1r88sqh5aFxD6sXRHZthtU K+dBZ+2mqVz9KR0w5uM1BxRTsJzH3wvevWvLBn0fS5xOT4HVBlEOKDMWk/UtFhxq+dwE cyRojz6Yd9+MARPt2tNQj0gIld1tTqm+EW9gO8tnDt6Vj6LGkb9im170/6/YXpcxig5g e4ObXdWlLvmPEJuMxtl5SNO7wp2PWocKyHnP+CyI+FJ84SdiOse+ooCsPbWulSbPXJ8C nmZSjGRppyWNcbVScE6dxVFWaMXpgj9N0hNBOjcV+OOdpRd4DgVDYPVs3izgCZuNOEPR vhsA== X-Gm-Message-State: AFuF++mCfjwHolNajdQ992SbSuJVQ1j56Lku8s4zcp40uOoMRVYwclR0 0xFWu/qiK32zhzRwbhYn7vlV8bxnxJOeKlhYYRt/7oWYSKpRzS1JWC9tMnnmYBYp X-Gm-Gg: AYBFou2kyauldiR/xwBnusdfLuuQb+RzlTxW1n5NGk5Y2ltb5NkC87Bp8LVtMa0vxO4 QJb/BMWKiQx5Y4ZvnGaP9K74PFmMLR+W52P3ZjpDChgM98LgRFaWqV1ku5KEmzO7eOJ2gRuDwJW gLRMssYYt5dGhzgU222Os2mbcM30IA0ZQi4whDHPbFKdEiBVXkbBogWyet7lDMzp3D2Ky83UKeB 9/W481JogeBKalo7LUTXLyqqacShjpp7+6Ep2jMxt/0yloMoni9rSMuRuqmBNx2cIKbliu70hAi 8IOdNmVRRp0ZNmcUF09Hvb82mRDO9WtpUy9VgjOvcqShv5jxIAF300g3uJn/03IriUn9yk1FPvh HUHDBGIQWYAHuFU5sLzZlLj4meOlWy+O6TvnbuMoufjguw6fgWFoSgnrY97scXdSGW0bD1cqYnS IKzeoWcQQXa8U6+CKmSbtj1ibJXp4ZZFyYUgl8pbFcMyThrenj7uH5FLEKmfItBM4UbUBbqaB2V 1aquQTkVJnsClPG8Ei6JLVguFWH4lF9k1+U X-Received: by 2002:a05:600c:b93:b0:49d:17c5:8f7a with SMTP id 5b1f17b1804b1-49d17c58fa8mr13030315e9.18.1788799432142; Mon, 07 Sep 2026 09:43:52 -0700 (PDT) Date: Mon, 07 Sep 2026 18:41:57 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-7-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799319; l=4644; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=6hFsJeHQBLg1M6vZ+OK9OUMoAu/LgU1tQxS6nBl8oxg=; b=ro24/EbVPlNXCmusVV5Ds3KYLLwY/19fNIkBkT/SaFDB93skdxboRLmW2r4iL9nE3/LlMUifA kln0U2w4kIiCPuXe4eDYLi+fYgOZSNtfgkawpTT7pNLQuhp6pGEHjr5 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.49; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f49.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: 1788799455980154100 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 --- 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 c3593f7530..2da91ee791 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -330,6 +330,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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799458; cv=none; d=zohomail.com; s=zohoarc; b=b7OxvpOpjJevdw75Ba5u7vt4bJXY2HToTJfCFmSWRUWvzI9NkmliypagWSN0XBVHSoeoNN9HlqYKBSEooLT+M4Jf6tlTx6AyTdjoqw7X3AIf0yMnAaZ5UNo980R+8tRhDUe0kSrIynJozGJu0hNc8ciyt26mh04XIeh0E3b9FVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799458; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=+nb48/mqPn7+bPDRAaLkgFFQLPP5yyaURUgKFTQWIgU=; b=T5AGPzK41s9/OmFadHH0txY32Yj/OjWkyP+j4I3dfsm7H/x6gbcHvdQrqiuDkj6I0uLJR3dg2JwUWGSa/983lzpVz+iH5Yw6JjHBv27qVJKL58bLqXVjwTWGVrr6IXQCvF09ICWo+qWe/DnHVdcnUPlLiFlZ2FKt67kAMSreBf4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799458295828.2280297223022; Mon, 7 Sep 2026 09:44:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cS1-00015i-RB; Mon, 07 Sep 2026 12:44:09 -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 1x3cRz-0000yH-MK for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:44:07 -0400 Received: from mail-wm2-f12.google.com ([74.125.225.140]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cRy-00033R-4N for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:44:07 -0400 Received: by mail-wm2-f12.google.com with SMTP id 5b1f17b1804b1-49cd6185db7so2436555e9.1 for ; Mon, 07 Sep 2026 09:44: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 5b1f17b1804b1-49cee6024a8sm423469295e9.6.2026.09.07.09.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:44:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799444; x=1789404244; 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=+nb48/mqPn7+bPDRAaLkgFFQLPP5yyaURUgKFTQWIgU=; b=KyfrfKaFo2ma0pYLeSya/FSEtJLLJniPY+Sz+TakBVS+Q/7aVU76eFlYI59wvcnpS2 3DabTIMoKK77V9xVf/9owh5XvpFd900Hc/TIji7lbwJGjPxbTrUZxOVX/9l3QpAokD4X 245e+8rUjPAjctrLGlo+KPowcD9hxgUS0WYgSPXhUzWBhmtkR5+WdTMIhszUxmIjGpy/ 7lSEbDYHWECNq31CVJInVuI+BnmdH8y/QDVcFZe2OUhmEDuVcbOXy/FTjNA7oSe7Cti6 ZZs43UufThHhwGik7mCJ0cDh5Jp1TO6YSciFa4f22JhL38eAIpurBLPSd30roK6jxfEm w37A== X-Gm-Message-State: AFuF++mOppiL19brNQoesvAZjBwIgf6zxFciRiQrfokrqrnm+CodlySS X5y27Eufh1S1MRZyjfNaYJP5hGl4ZYevYQoVrlFz/l+eozyKYbzWfCL6ZYiI6mJy X-Gm-Gg: AYBFou1k4pC7YOTvpfMYiLkUZ9vp8YsHmV55GGuj4r9gdf5jw8agZe7/vfx39ROXcrl qUyjaLZPzKQnQo48R0xqiGdyvEEWNC1JidVqWo7cMybShHU+Ch0En/2Klwz/tPhFbkBem/e+CJd 2R0mhaeThnRm/lpCewC8SP3fn09HxhdNRboBWtbCUxnD6FXmJSg+d6UU43tXEs3u79wWKeZqkk7 Z3tkIrdupYiA6AKgJ2nmpFwkdbIaFV8IVNInojwYyRMigmoWMvUC7XuWiFvci+1rN3c2ydI/ueq I9/GeLKNN4qNuQityAmNGysi6DhxT7Our/59Lz5KhLyiESzQ+uL/1sLI437dMD2ZM6W+OkQywub K8Ry61HoE8mkFkYE+GEyrrLZ4clrgyro7kRqQFupxtwz9Xeo0VkmU0oDnNq+NqJj7I4yNmZVKVe mCbuUFi4MGwMJViePgUatyt3NgprNiZoW70pRqq5+IHXCt06QGnBUT5XgoD5cS0BjQVGYGKC8LP 2sY+5Tv0QCcZWdqlGipew5WZtep3syzraw= X-Received: by 2002:a05:600c:b8d:b0:49c:e37e:4389 with SMTP id 5b1f17b1804b1-49d1754e950mr23261705e9.4.1788799444266; Mon, 07 Sep 2026 09:44:04 -0700 (PDT) Date: Mon, 07 Sep 2026 18:41:58 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-8-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799319; l=1555; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=rDiuDaI9O+3b6OvM3HVMevuI7PTOL9dpbkK/b/AU00Y=; b=TJjwhDYORc6vDrt5LIRvQ49PiDCLxbk25KlMDreMqTb/SaS2ALuZeVzGwRczc7nwjNk6xjWFO Xs5RyVKQbsdCjmEo9KNgOnszVkOpUgnFQj3sNDNtvSUMi8Tgqx6NHgP 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=74.125.225.140; envelope-from=eblot.ml@gmail.com; helo=mail-wm2-f12.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: 1788799459381158500 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 --- 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 5f1ee2e410a..f8b3340bf0f 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 00000000000..f4cfe6a8e76 --- /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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799475; cv=none; d=zohomail.com; s=zohoarc; b=nbw345uNHSgLnxhP5eVc3kNHpqCBr2gA5waajUa53D+meVpdy6M2UmfYtqPKaDiyy0IObkhWFVCQ3LtAU7HD8R5ABkmadmH9W2Cos3gqCZlOUwfSscCJfE8ubBdEpr+xY+F+51u+LU6+DKs5f9TQZbB3FzQk9EckQwLy1zDzYg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799475; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=8FHzwKk8anKZlTGdAonYHGrVBnObKIm5SAMSfQi1o6k=; b=ZhOKIrjfQrJdDeOxuOhXcJFd+veny/Z2nWuxQLqEg6rDt8yYmPPMgkRSVfL9yjR4C5vWzDNUJd2eY50wn76mMkBxc4DhD/qSfujcWA/1HxE8yW853CKh5sGG3dKsoaFhRMTZyqInCV8DpvBH58n0S+D0zKT3/XnpxC1olAc0rSw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799475819140.584755092612; Mon, 7 Sep 2026 09:44:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cSD-0001Tr-Ev; Mon, 07 Sep 2026 12:44:21 -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 1x3cSB-0001Q5-MP for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:44:19 -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 1x3cS9-00035W-CN for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:44:19 -0400 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-49b96837ca3so29900945e9.3 for ; Mon, 07 Sep 2026 09:44: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 ffacd0b85a97d-4858e239862sm24820268f8f.9.2026.09.07.09.44.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:44:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799456; x=1789404256; 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=8FHzwKk8anKZlTGdAonYHGrVBnObKIm5SAMSfQi1o6k=; b=ctU+iYItLTlPEZktpBqShgnqCnUoxiNA3nlQ3J4dLS8GeemQs0nuvLJ/F8di81hoTC 4bY7VuFOF8DIVty0phDAgeY878nYEWHp8zuIhixns3Ccyxv57bU2m3Cpc1kr3kMLi3ep hgT99Ep3ZVthKGfrjyOkSER+CVa3hdbo1isE4kefg9SLIhPHFT54x68dEyRlTFXWIU9m /Su/DjJnV0BBvrB3witGp+WoZ7ekDJAZTHMgyLntBgzquHrA7M/exj67mAQl9N0oywSE mxkA4YFSM4ihqQfzO2OskB3Hu9xi6+kWDyYCHyHcoqbba6yMaUtiF4hObVsYadjj6Pvu 8Vag== X-Gm-Message-State: AFuF++n7+Ve0O3T0Uoq0SmR3cLIT3NxZNEANCyd66XJc3sRkTt3qPoAN PediHqRvM3VQkqBDM4xiy8vaJESm84FL7ZwASf0NtDzLqzDA6c56WpftNeAG28/S X-Gm-Gg: AYBFou1tk/1Vknha8wRL5Kv7QCuPuEEeeuSQdvQmb0PX1QBtLbG1KHvEUEj8mgwfBFu mPj31ZGXQWVU5lu4jPYITQF7cyIwK85ALwqG7f/MnpAsTXtpMrwN6n/otKIYdUJZ0hlDDUOtnvU EsOAHogtGW+DA4bWpds6syBXIGjisvRiv170Eg3e+RMlTpLWCxcEQw5u6tUDCTrMBEWfPFdT5t5 BBzIGlkwo0MOCyCbvgigJ6b7Z/qN8xn8X9Aibi7UQnra4oUyaKpI3KPVWcd4te7aQk3osWg21Kl G2E69Zre3iuKOKpVjBKBGpxLgWN40B8Q1hRS//bcFcxh0JlIxv8xtB+X6cy6FnvwlONUlmFWrHm Q+uJSaNDVKogsUjCHotWMqzO90SavlcWFuedkrQL5OS3lYJcIF3vIPrqEpOPc4KOwGqeG/RZNSd XLBcKeYqpV4vABggXv21gbHfSl4eW0H4S/JjpfAAuecla2Idn3UAr5CAZsI1AiKAyUhhdxbw0y8 IBjS095IenDscZAIQ8lMYzOUTMLQvu3e3c= X-Received: by 2002:a05:600d:4444:20b0:49c:fc6c:be0a with SMTP id 5b1f17b1804b1-49cfc6cc001mr157672795e9.33.1788799455795; Mon, 07 Sep 2026 09:44:15 -0700 (PDT) Date: Mon, 07 Sep 2026 18:41:59 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-9-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799320; l=11044; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=nH6+IRCmLNoTSb8wnIb/AbS2T50zARIVS2dxd7pZsVU=; b=VE+T6zbJGZenZpyNtmFtEHB6EwRWiYL7ogB0mbPwfzprphi+xiXev1IMIQId3zwDsozDjliby a07ilUydWK/A2bxxoAa4WxGjltlGbVW6jozpbq0W+wAUMWJC5vt6j2x 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: 1788799478448154101 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 Acked-by: Bernhard Beschow --- 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 2822f6bdf5..7bd1f90555 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 ad2953dfea..e1dc988425 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 ASPEED_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 1dbbef11f2..5ab2b43e9c 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 ASPEED_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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799479; cv=none; d=zohomail.com; s=zohoarc; b=hbIvXtNJzGjQNW00RIkDONiUJyOUGnaLCEBbZwv4BnRxGDiURrnYvJYy8g/KZaIdi005mdeaxVoPUQ7SWTlUQ6nCFr2B0mUCf2NH4czhLe5LzxBXphdwLkgZ2vPp47UQ4cGIeCqLyjrc4NVyWufcKVbtLZkNjhKOz+5/EzSMo2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799479; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=uBN2fajLUkSLR6UGUjgMftgFKf7I37iwakER3PeDYqk=; b=ge5nt18PvN75sStwTijQjLJuSAH8EKczUI2gMMJ6coKOwJD4D4lEpPqUQsKBVFRxpNkTnCfVxnsJfXZ1KqNGhiUFzPOYzZdGVT9kn/kk/cnrK8REkw71fQirf22qtEE39JRFwRtsN5skOwUwJgcW5O9I4riD1eGKYiB8AljYmqA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178879947925883.8711714769546; Mon, 7 Sep 2026 09:44:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cSP-0002XP-28; Mon, 07 Sep 2026 12:44:33 -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 1x3cSN-0002QF-F4 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:44:31 -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 1x3cSK-00037e-O5 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:44:31 -0400 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-485888b3c3dso3876613f8f.2 for ; Mon, 07 Sep 2026 09:44: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 ffacd0b85a97d-48594172546sm21043507f8f.15.2026.09.07.09.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:44:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799467; x=1789404267; 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=pBo9t+ncVw8FT54xOAhA6WHB2077uarIs6bjKDpohMxQ3dywh4XCnUnrdJMo4QzxaS 5eLfsAQzIX90r+5mWNRhLeU+Xx7Ly59cD9eF5cKyotxZHxPnNG3w3Ut+pml+gM4t2VNH rb8GLkRlEfZBzmrxI3quMcS4pdzSwD5SmObpfMmV18V77Wscf/ZPbCPlclmiEI5uN4NP BfuScOriLZ+UpJ3SpT4kyVl6BRKyM/eZmE0UD699dht+cRV0H3aLz1vhCOEmTJPZjGve YONsW7UMNXPnjnbf35QEiPPaZend2XZYo1RCo4u4OYt6vv0am3iz7DpayW6dQ3vtueYp e0zQ== X-Gm-Message-State: AFuF++kqmLRvAGton0aZlMKDKh29MWCuyXd7cIjI06PLCv4eso9ydOfx f7Zhpwuz1bgYI4jrLguVw/s5TiF0fG32egPU6Arxk1+qroiZ6aoxj4NwOm68MbSW X-Gm-Gg: AYBFou1NexSuGJlfHESF2lJNw4MF0K+kghJR837GlFGce1X4WdnZGC4W89rsTYco/p+ WVRLEcM06MIzkLHSKWfSzTYCdGjELf1ss1HH7l71vVeQWBT/MtqbObjiR56xC/tG4fJVchK/ng9 R3s3uMWxqHyAyQ0LREf9JPd56L3ng3XIW+bNLH9/Lp41B89bs9n9ksVEitox6Z3GQsyPtuTYtf4 NR8Mmasuxcaja7xVRx+kJz8QKALIBU0STVipDx2ChtW5oqwHfvawNOlzDjhSwwbbQ4cTQlLRQ2Q X0+e/qCGrH1IJ94SOo0NzfTCi78GygBtuMXUZYylBr9ISA5xjg5b8mreX6VeEmuQSrcxQ6fYre+ 8AX9IOuitT+EmNn0EI94k53E7Uy/cS/eJUv1qc55AsTmY0XggVFcfbozvCdAs02JKgIzakkTPkl TchbzbKSXm9l7ckA0YC/U/3IzcSsNvZSJUR4YxkL9nqbLVJEZvoVmgdk6z1ADfzF7ERRKxARoqg 7/VccdHwPWnxoJ9mHarhNIPhLvHNSZDKt33xYdmSUcJvA== X-Received: by 2002:a5d:6f1e:0:b0:485:8c16:5ef0 with SMTP id ffacd0b85a97d-4858c166129mr22614304f8f.42.1788799467119; Mon, 07 Sep 2026 09:44:27 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:00 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-10-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799320; l=1334; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=dw30TFJwCbFZiHnP+oufY0O0rlo9ULUgYxm9lxU/N6I=; b=pu9ebqJet/tiBDoaaf4BN7KUK21xC4ntJwcGAkWudZttiuCq9DRmHNE0e48w2ji6Ngrs8Oway igoMaykKGBXCwok8q42UE3LL5LVRMFqrmdFeQ6XBKAts6Zxg+dH4wlK 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: 1788799480782154100 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 --- 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799491; cv=none; d=zohomail.com; s=zohoarc; b=Er3/DED8j6FOQ/+jB4lwkc7j7SONovAP/Aj0rsigw876ZwzlgZMe75F0EcNypgk/R29m0bORnJeD4sdtZD7BDkEOt/h3dCGVnajDsdJNFg4L4iTxc1vG3tB7h0QDvyMNx+KbmSo+nLG8DyFUCi5Ku/f/B6jD15MNKkAB3ZwqDMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799491; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=vPB5f/PPZ/fTGUrJWi/0AwBmdqaHERhdZDqmO3v6YS0=; b=hmXnjq4hEZnG/PmgBsZQc43Iwo0FEhiJVUdD6+EKHClX0Ci4/J6b3yuWgd0pOy5RdId3VK0ruFps8KMKt/Cym/F+aFN36b7vgm22jsx7Hh6Gjgc1FUaSteYU1wYjBycsdk/A0J3zsE9ZcwfPF8ArK7GmjgRjmDPATPYxBrc0+ZU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799491980418.892642450929; Mon, 7 Sep 2026 09:44:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cSa-0003YW-1K; Mon, 07 Sep 2026 12:44: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 1x3cSX-0003KA-On for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:44:41 -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 1x3cSW-00039x-03 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:44:41 -0400 Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-48441a2ba14so3294346f8f.1 for ; Mon, 07 Sep 2026 09:44: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-485883927a3sm23015695f8f.11.2026.09.07.09.44.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:44:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799478; x=1789404278; 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=jdbF0a/8bJaVFsusoFzAynxFt5Xy+7XDW+ed3nmu7S8CI0WCJ10P0tR0UxHnGVBMZP Aba9hpgU42y2K1I6Bc4g9bhDStJooOff4qnr7BLN+Abnue/Z0Qfmn8L58Hh43d25p+ZP fuwvKTVlJorTyaeZLOHmyEljmI5UpyNgGbzOQaEUzzJttc/FnBzubgyyhulIS9o0KqYd C4KLU74eNrj+KBArs4Qeh0ctM5dPt/xzoZ2Snit6R4AZAoq2uSQPastclYMN5xvcvWvw FIx1vm0/63UMArdfcZHlhzo49Tp6eehN+JlsIfUiQgmCqehTMxgy+9ZqODg5o0wG4mOT 5Tyw== X-Gm-Message-State: AFuF++kRGkJ49Gq2evmFSGm8v638z9lMeXewOqXYIeM7f6LFKf+RMArs oipHhTwf26RmJq5hhKtrxRqZ+j8eJMuHTLjK1NXnxgijjVYBaVhrtAb1p4opS0W9 X-Gm-Gg: AYBFou1Yn3zAT/x+/c9/oM8OKN60QU/Yr3jhNNfCC+58fQfABIKJsOYeeZ1Ot1yyJnZ WUJHXJfdsbcqusD8QIKLbNVqN+mHRtsCOr95uy2ZzXY4LCw/VxTwIbchEypn63+s+Oxlm/8/lQR tZGSj8ITpLaIQiuzUjeBqROJaawv92554l5NUEHaOQ+BIoJYSIbnYCDJbQ02MhlzfoyQGZ/jUft eblCKoc6khCjQJ0i/lIRypwzXpZo872sMf9Do3bdU+UQkZUWFleHykCbl7k3CY6vfL6VZftKIDM jyAWpl/xlQDUIEhxUlwIZWyDiW09C6414afLgmzTk6tVVNT5WVXFQROeYmoSKdjlL1de7jAR2d6 foX84tPtS+2/CaZqEu3kXSYsk/uxoHyc/GFjK0OxAC5A/JZ9mrhjE/2ENrFVTgQjTUvmJRS064a 0+x5FPHQmDq2rRM+a9m4+oUurjkiY6/GhMY1ayQPT8I2mU9/YVzjklEjOLCIDHdYY7ie3hERmuZ U0fIZ1Nt0gfpwEv12lBTGsmLxyFRkAaMtiOzzHSTB5WTw== X-Received: by 2002:a05:6000:470c:b0:485:8a46:705c with SMTP id ffacd0b85a97d-4858a4671b8mr21557003f8f.46.1788799478484; Mon, 07 Sep 2026 09:44:38 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:01 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-11-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799320; l=2049; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=4sMpXciwY1X59HescikiS3PryefwPgkY5TQZ1q6pfqQ=; b=uSaJznH3FOG8c+yD3ATwl7VuNxgErZBEkZOqbUIASUkavFu1CREfsyLsPzg5jz2YtoZmu2x2Q 61Rt+Q3/k8+AA2QhSFjwyIHQltWfCGX2vOkH331NfNs0AZQ/VJOgsir 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: 1788799494509154100 Two static helpers predate the rest of the file and carry no device prefix. Signed-off-by: Emmanuel Blot --- 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799532; cv=none; d=zohomail.com; s=zohoarc; b=XZJUbACxGZa0dDXwNkazdTc7GLQ9LtVLFFTr1lVxJLzoQWa0+QGs8V9FU6c0l84DeUeA7ngyuBkfM/DXeFXyZQMtIhOOeDzrABERdbT/mpqdY4wlojENxgq9+Zdny2GC7KMD7BqhZJKRpmQPa26l2F5DPLKZ7mgYjnyclYf0/UE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799532; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=um44cl8FTErmKq2v7teNfkRsHWMpEkMy+vm/KZ2VsJY=; b=EKmDGSt6qbHmyTT392xD8GTHZEXUNkK8HlN176Bsb6uwBc1G8AGWrUtPzySJF62aR7XDsNZZm9s7UkN/OnonhNW79G9eA5CaaE5zoGy5FCzC2xtIpGGWklUYf7gBEAGVjqxrFyN9rGBlfmFrKopfxbkM2TxMdY9mUVW2nGPJiNs= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799532411388.6800997167953; Mon, 7 Sep 2026 09:45:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cSp-0004L9-DJ; Mon, 07 Sep 2026 12:44: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 1x3cSn-0004GX-Db for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:44:57 -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 1x3cSj-0003CH-SO for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:44:57 -0400 Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-48589798dbbso3116710f8f.3 for ; Mon, 07 Sep 2026 09:44: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 ffacd0b85a97d-4858ab73c2bsm28107240f8f.22.2026.09.07.09.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:44:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799492; x=1789404292; 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=CTmTm/bwEU1Ri4UBS1k4Z60XEqgJplYbe/BujikMLTCRDceoshdAzI6CdpSt2e6tNK qSzel0RtIhlan6lX7sfL3g1t4pxuVArnw3E5/8lVgXi1swXIxpzD8rBekS/Eei6cMZx4 mMlatCJA2/QK42HxSgybB86jFchcvLkPibWWfNREoBpxJxf6eVFDHcwmAnIvKbtamHHs Yu7PFa3Rduoz5rK3ADJ9wPydC/FInfH2xJrGSKd3Z0BS5fcppvPktYksURCErv1xtXcR ef2zMpxzzE28Ph52Eqa9YZKd5UBnkWjQUlnuZcn/wU1zcj2KtPj+CfQt0xeQ8M2db/Ex O61Q== X-Gm-Message-State: AFuF++nUD+qF7bjlmjUqnbFjSb5B6UsQkKWVMaabTM7SvLeDxADHqurU DcdOIIWCekY2bN1iD5X7LuE1YliP9UXBST8UPCDm92K29kThzb2asDj/WH0XucSD X-Gm-Gg: AYBFou0fmN6cTviCpR+HQxPbVuJP+SEpy7tW4OGGb9d6Yp0Ambgyn0b7+Xhlh6jHbeo 0C7l0XWHuqWUKU9Fzc4zBz6x14LFt7zjDeTw2ri5iIxeA6hPG8k2MvBfn848g5W/xuTGCUdHryP iJSIGchDP7aB53CR2wiHgmsVkovgb65vNsT1m2PP0Djy8/vxllLH76Rtg+c5mBJvZBujOGXOiRu Ne6AeF3tlPtjetuLU8eh9hVQq50+efhKqmsWwL8T4xKsBtedKayGmBZ3MjQoaoybR9gGck7+e0n I/H41v4mJ9T7fQ7wxfPxQ+kGRV/ZBr41yGtq0E1RQU+6iW4S97LhFxKHlMQhyoPLD5UvwUDV4iV ToA0R/K/+7nbgp3qXm/Z1jsT5FX5Z3P5sxbHePOpVKbOx1T5it/x+mwR7FIWb25IHzhIuA2vCYY V1nFhyVmKWsd2qZIzeR3ykWajsd4q1nKUFUuxpuzwulVfVPug3wDhCaCp/xkwEwCZS3baT9D6zQ VasPUXv1kELk9cRSoQFqkcQ/eHkkun0VHs= X-Received: by 2002:a05:6000:26c2:b0:485:93a2:db50 with SMTP id ffacd0b85a97d-48593a2db8emr15088710f8f.6.1788799490884; Mon, 07 Sep 2026 09:44:50 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:02 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-12-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799320; l=6098; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=3HDBdw1nikFPpNJwTwE1d2HiJ1KBQ/Q3c9Vz2uyln2k=; b=ycBI7fUNaCU/pmedPF5Fl/ztnxCZKXwXgBZlXfn3gj509tTXJlP21/JM+sJLj1uPWeB07Uz2i jhs0Jy/PGM8AJ6EPzTf/iuTyi1lysOp13UY7ySTFEhCIn8+0bXJFR18 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: 1788799535285154100 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 --- 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799555; cv=none; d=zohomail.com; s=zohoarc; b=nWc5QCQyEr8SgKcXKkcok6pu2pD18BSe29dyTzmw7BfscTAjGUamavbPl//rhIWq12jGDK2Psx3b94R3E+G/VfZYERV8GIjBN9EKyElYHmQ2fcAj6Fy5zcam/8W29evKJXEPiMREChPoZg25KheIbil11Of9CovKKS/aUEDVX0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799555; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=yBWuUC9nCHI6TiTYFhtomTYUcrNr6zcNAyZPSG6aMfs=; b=NcTC2PeUzTHMS+s/8VtKnVXKvFLv0ScCv5dF/auyRcj4HGtvGIUTkkwL0vTtE2ivh0BCsysiGa8u+OwXzWBkJv9PRwJU1n7TEBmF63Wa3X7cd9OJG2UEtZecaVdxHsBXzWXEtlf6Yr+3yuFNs4JC+i+yGVWs5yyFYRxqkDwLVI0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799555180179.01264754916156; Mon, 7 Sep 2026 09:45:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cSy-0004Te-Ik; Mon, 07 Sep 2026 12:45: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 1x3cSv-0004R9-U1 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:45:06 -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 1x3cSu-0003Ge-0P for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:45:05 -0400 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-484374f54d0so2335430f8f.3 for ; Mon, 07 Sep 2026 09:45: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-4859207c28fsm23561762f8f.5.2026.09.07.09.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:45:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799502; x=1789404302; 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=s2LCjDbQmj969CnjO/qc3HLgSgUZbSTsLQPZbk+JQWZZteA8HAr9ze+zeUHZU+fUnZ Qd03DmJ24pkluLkjypzIJ4jQX6fV97tWmTGjH4qb8QMEjq85gYQeUAHz2m24f2X4qFvJ iYIvXNKMOMiLhxcq+Mpnh19Dqo8iBGnsOuWmCL6uNnBm5njHro+/Un+PzZTyQGBgtS4z 8297keF3cWWznSaYZtFqteAiGXvpswMr+ZfkjsheV6OvSh3j5XKy6r0ASv3agrn8g2Ch z5nbBTz3I/S1qFGeAzkAz99JAvvBiCNkngSGWBN2IZB+cNYYFOUu32Ayd22YkRLQAOF3 p3xA== X-Gm-Message-State: AFuF++lUoiSeygO31P/yrnvPlT/lbt9tmq0l67VQTgKkUQHgI1cpiDkL qnp5JfwRS77g5hTQN/KnHo7Q9AxZFNlN9S5bFKRnxaymFMUFUqidF6H7N6gOHNaD X-Gm-Gg: AYBFou294sDliqjKG8m9XqjF9VBWF/Dr6nu7cblcbFVAm/IsaV0C0WK7T0SkWnoq9AG TeDTljFhiJe9Jv/AGTetA2TQv8E1htQlxmrqejM/bGeELn8LMs6sAUcSp8MRp7MHLzwRYg+ECMj 1F6AREuv368zvhxM26+XH32p9IWRCaJcSzLpGc/w4/UiikudUXuQRuOwAVXWKfa3KoxCRMfNqmi 7xkDa37TlKy1ETUydS64kqQmk9LK/F4yuIFCKOcyN3gYuMs+jWYIiinFvjkS/9tcQx5aXC9zC3L 7Yd7t/JwqluCCvn1D/lJwnj+i8AbDJPykhiQmmt7PrYc1Sx0Ee8OiqQPwpMZykgvr0XnMyHq+GB f3jGsUy7Ci8V4DCTJ4Pn/DcuZ2i68yVI0OL8jMdbYpcuHgDv68KL02wMHkqBXzzmwPfv20meJ8w xUL3dJhI3I1YpQkXuCVHMxyjX1piLfytWzqheHFlhyxziu+v/52xlr5YdFYsTgc+5DO68A0xce3 /SvjAXC8NvJz/fDWNWkC2MhdifWjCQBiSE= X-Received: by 2002:a05:6000:4a1a:b0:484:3334:9dc2 with SMTP id ffacd0b85a97d-4858708cb0dmr48723251f8f.15.1788799502363; Mon, 07 Sep 2026 09:45:02 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:03 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-13-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799320; l=6063; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=94bqjrDMcc1+WPuTzltyln162tXTYcpioUu3J7GfTG8=; b=enfbjnm54sNEHQGOqYxZqFA//vEMXuE7ypSXEfr2Lp3tQ/zXoebt4tmN+/ad32mt5/sXVKPRf 3V1Es1LuQ/4Bu3MrBukLJ73YUskYXpyqh/+6u9p1qnuVUI0TgqAP7eM 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: 1788799557764154100 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799546; cv=none; d=zohomail.com; s=zohoarc; b=nEuq4eP1l9dE7YJOIhfWgFXDiCT8nLKgbH2iY4kMKO0XAL/FMdRItouE6srEIfsgWJg6UFhOMpbAMitaAVbPalVQ3VbKWFJ7O/8Tmh4ygkd9woLpEc8guoJm5AGtIP2YZORgVKRqjp3EPymyRNhaoChFc8Jzi2Oe/Ty3Im1SVQA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799546; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=G/mKfLQNBKAXK5zANjKJNAiRPm31akVLZZtUavo8HIg=; b=UKE19Ha3q0HgL6vLY+JSabyQGF7eR3wScUmH1yyTghpMyuWyZo0lSlOAW98Cg4CICL9k1nL1VY/M3f0Ti1fiqHUGSpCXvxUwT81ohXdbzeEWYt7JuuZjmVXn18YTJI7g5WyH/fp8+45CfAIEmk5oPQq/U2d+RuugmZsZqrRGdfo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799545906334.5094217032711; Mon, 7 Sep 2026 09:45:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cT9-0004ey-6Y; Mon, 07 Sep 2026 12:45:19 -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 1x3cT7-0004dk-5r for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:45:17 -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 1x3cT5-0003Sf-D9 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:45:16 -0400 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-49b8687630fso32278305e9.3 for ; Mon, 07 Sep 2026 09:45: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 5b1f17b1804b1-49cffdb2c40sm191187145e9.1.2026.09.07.09.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:45:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799514; x=1789404314; 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=NS/a3P0pJA+t+tNcS+J2pXeyqbTBjIs1/WUB/9EOnzYMdctcm8YOp2XrdwsSHBzoNa 6YNDafav+WboeoLmTKBmhTkaXUmkhQGK6YmB1jPl3MKItHyYXy87+2AJGR4GiHIxb0Tv H6qJ2jGAnmxNUdiC6bHysbnAkh7C/Yt46ZxPEw+3vQ1U8m4vrPH0clA+PKkiju8BGMvS PDzSunq99bkFmI00+uiT4T4oOkdbB5AwcLHI+Dt8PxRbJ+Rt0xXY7ZMBqi+6QGdf1Sns Z8ZXEX/YRde2pUB9XKSt31SP2BwMnECSHknx8DDDuHbrYF5cM0wIPze0sfysi00MgIQc 0wSA== X-Gm-Message-State: AFuF++k5B/Vj2nKbNBuT2TQZTnDpptnyWwRuIkq8yqR3V/QXpTMFfRTL y0FR+BYWOXvM3Fc3VpZBOWkrr7WNtAq4tVrMLrvfD2U95APUtc36GbSq/zPT1lqM X-Gm-Gg: AYBFou1rsFzfdyIYR8Y2CpkS3xWAw4VJHRSVhFVIhb3G6hgVEM/SWRm92xQo34JqAB0 wUc/tqr70Zh4Pm9INw/I1icy6grcbVx1Vsoa0QI1jGCcNUbOPL3JrU62uZGZzVNGujDHp4wx/XA ERIrXrLXCExsKbpIyZG0YB2fvEaJoPXsQiOH86sZAiOwljk2ybwItpSMY2OK3EL+Hc/gE7FcVMk ovzrzF/CHUcAZHd831waOgmaEMGNBaD4/htuLJY7BESFmoqZS3wso0DlrjBLHfIts53/rKD9euK cFqhxqTRU/w8zjkklKYAtRw0tPlM/rzKlVa5XOKLjZ2qW1/KGdYUENzCQRvvUS4CnnaN5vlXkUE dcnfmVrKUJ+rdXXrqSnvndv9t6A/HR4rQYpbQrZC/7NA3PgPybX/c+H7XRTBWfrEPAZ/6zTVmji FbdHmyuhV53KYRXUkWb6Prbsx9nsSvbaLzBH2FtyVe1vMA5yw50Yas1967gvPdehi7xFzbFRwoo T/gScHzohTpPhheRsVwCf9Rx4WAim3ZGnc= X-Received: by 2002:a05:600c:4f83:b0:49d:91:274 with SMTP id 5b1f17b1804b1-49d00910374mr160875785e9.10.1788799513726; Mon, 07 Sep 2026 09:45:13 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:04 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-14-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799320; l=4393; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=a6K3mP3V1bOItKsHSSEEMqE6FAeOlFgY8HlKMCgf6ls=; b=VNb4MoxMYZVwwCbNDVutS+tnhtgVQpwFStW+fZVVM/X22xzE23yQ7i+r/VM33+0PQECAIb6sB 3zzCMySa26KA/Ug1uYX2OVMerXR5R+NdP2eOfrwzf3QfxZzL3wDnzmr 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: 1788799547780158500 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799572; cv=none; d=zohomail.com; s=zohoarc; b=E67CCYxEOMDWVG1Xo7OB+j7oaNeI65YOeTLUdyov+kLxd34sxVJRzhR0Msh5JVRzI4SJUqgdwwG0iWGsfhKmrGFLK4pruMHvpQzL29vG8IHuUAQPvTm2XirS+AhmB8qPXImGdRG0wHGbDZBwhvreOBAW6FgBa1gJaIRyGoxdPB4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799572; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=8pehCOpu14U96pPALBKxZw+FwtcRSZWqcNAlSAWQxRQ=; b=GvcbzE8iKOtUv2oaLxsaX4cfmWNb7lxV73qgsKhfG/lFLuKSsrhCB37EEgtmWpXgaNhHl+B2apbxCI85cbbutYFPzZLNt1jLKWgPPo1pak4a1+9Ic6tgawQNf7BpyGRKIZxF2RzYapJqtPHS9ezTXHX9jbQxP8O1LiNeJXdpLAg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799572498597.0786706391335; Mon, 7 Sep 2026 09:46:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cTb-000526-U6; Mon, 07 Sep 2026 12:45:48 -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 1x3cTJ-0004qO-Pf for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:45:31 -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 1x3cTG-0003U0-JH for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:45:29 -0400 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-499ae1c6471so36748285e9.3 for ; Mon, 07 Sep 2026 09:45: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-49cf75cd8d0sm301952595e9.2.2026.09.07.09.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:45:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799525; x=1789404325; 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=AWVg4ZTlpdoScKpQp88Fx9b+vQRC74gslnpN76YPZL2oVBQUfbHYWpdt86/kRz+juM BNkpobT2M9aVXIWtA5TqKJ/xTmtdI9htY/tFzaUioWc5Q8Mm7qL/zK5f3nrQ4d7w1DF3 wlPUnHvmVBNucpgpjO24Hpy+uj706tGO6co0z6BJYZIsRYVm+YdPWV/h216FChOw5rab OaAWcc3LKs1gaCjTdlJLQsA6qTjI95xrqM6993OptWlC5HgHzdGWnOW0+ecVIUPs+5+Z wG9ikxpJVeBCOMqQF7DaG+7zNENkIxd5Ff5s7Ye9cjha+lT3VqU2FlJLjpcl/Sx73KsG szVA== X-Gm-Message-State: AFuF++krcfZjVcqso4Z11sK0n3FUUxpk/Gs38j9q40UfKlBYdDAxPRZJ j78cusolci+ZaItCX67iv1X6/IEpsIu9BhB9NH4oTxzTReByDmu9CVu1/zbT3Wf1 X-Gm-Gg: AYBFou23U2dPnOsu1yVle9VpGr7t9DApL1m+ljrUyB3yWYgIzT24jP8wv/yUn4+28AN hlhz0m0bPWfymG+ijyTFODrQsFn2L3dBwu4DjK2aNRjnYlT/ASFXH2eeVqr8lpSWWrIgICdzxI6 ORj0gWtTJpJQkF6UzSdIhIw0iE8MF4tODaZb0ABxukQ1k/p9S9yl8Z0c2L9UZFK26HRHh2UGivB ZsIxgqCMCk7HCN1IHqRSQ/2MS5ZOzUg2X4SW8qQmo+1XSCti92sh7r7ocKVDACcNvXasRNNYrbR 9zmN6AUli6E9zTC+psAZPwfXIY0GOGfLPBWi/4mrp87dIh5d8v1Av+p8Eli1fz4HcvZJ8fHMYIn mbKBIQR/2YgHfM7DZmFH1RYv/PXhJSuqg9uTZVdmkYHgJ8A0VLDk4T+cXPmQncXy5MsQGkGdfGS +LMV9mfbL5LSfXhoDJoSeVY1t7dSMJHUNN4+Ml7PE7nnHgFQfSW96Dge3poGCFjGuzFvADZx5on SeiV+oPu5X1nNiSCMkBb3ad5Ak6p8m9oS0= X-Received: by 2002:a05:600c:4e51:b0:49c:ff8d:b548 with SMTP id 5b1f17b1804b1-49cff8db5demr407389125e9.11.1788799525075; Mon, 07 Sep 2026 09:45:25 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:05 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-15-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799320; l=1980; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=/o1Te60tyzFbC8yX3wDit9+fgGxpiXPXZOuAAft1sW4=; b=f15x0jIyNuUi46sinkjJoM/PZjrjJ1fBNnM59WzMt4MJyhcmPGIhJW7FaJ+g7uJabYF5Gv9sB +ENB4W4OukIBNZ+DoUx6z94x3yDlmjzu2SBCOytGMpQFt9PpDVNu10w 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: 1788799574190154100 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799586; cv=none; d=zohomail.com; s=zohoarc; b=PcjVyJKfvFoUSnmTgMcSaBfECfo69q1DvmypbBoQBeXufIoGpDnk0ArLB4QUxus0c6MRPxgMnziUmOBhvhqEB0gjg+vmwShc6fRUlL3jMTJXeSKu2dQlWYwEVnWGjLqH7Vuo67hZ+jr6elXofRV4bTG4vU9UvYhgTJ2g7KTzb0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799586; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=yoI5CWQNkKU3FBXCClJtroQLxmdLnKfTK0MOA70taBk=; b=GbgVgE4OsIgLUYzCzv8PXo/hqcMaVzC7Cccf9qQ502HNcEQVIzuTXnGT9n8QC7X5Vqh7wrUd3belUbkHsVJOdSGMbcHhS0J+3btgDKCvMyT47pbOXtd2sbXO/yNRDC7p5HjiCMWEhXSzCs05cj8oODLOM0J2+ZjXP8DnazX24as= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799586077294.27715453935605; Mon, 7 Sep 2026 09:46:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cTc-00057i-Jy; Mon, 07 Sep 2026 12:45:48 -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 1x3cTV-0004zc-4E for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:45:43 -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 1x3cTT-0003W0-2m for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:45:40 -0400 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4995b0343c1so52967455e9.3 for ; Mon, 07 Sep 2026 09:45:38 -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-49ce5533ffbsm327256975e9.3.2026.09.07.09.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:45:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799537; x=1789404337; 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=dlC6j2ElPMFys0IOaxGw+mrYmThKdbBnbaMC7g15fjih5Q4qIF9aIUzho4nGFLa5CD G3AqpLV9tjoY+zWjMGxnRD2skx+g2AtpkNRmPvuuM3n/62iilEShYK1uYOQVOWlHTClN MVqLwhpFEL7iKBry+u2NfKzzeXry0DYWrJgCoXBayTrJlTJfpdIokpqrmcAIvst1B4hV qhk/rLuSyXq/6mM5sf/12kQNQEs7p2bhNaYSpZAiWl6PkGPwfyVJHGrLRhIBeET2TygD DZGJyRJJsXkEikYF8Y3QEt8aJw8/b8wMmLFZgEdkN87VYqa8Hl6V8Hndn9zzOFr2/u0I 5USw== X-Gm-Message-State: AFuF++lOkdM1l8FiMjRBArDAyC8yhqTnIBoXQjUoJ0TE5QL7bXr9/ju5 tWNYWg6XxvzsIas2YcwzAh7vYOrkvBB0tYvOZuQZSQQNostUraLbM5+ZJlfUsdDO X-Gm-Gg: AYBFou0Ud9WPixfi1FbBX+SsPMscqcADgCv5o5oLR/7IamsR6EthO0Wv07opdVHNUEz 2iehLYuRzxmPMYpMHmnaQKYgnUZCZKJyBSgPZDPtMDDz1TaVOL2N17dQmIrdSIc2TiVxGrmf0+4 e4HQ3zswV2b94tzDeX4MTBq8HTmaGx9DyJdxC2OBj8S5Bf5Tucv+REirMW/lnx8y+fm3Y214S26 GM9hAq6U+dLaZupJLrj07gHia7H1V4hVtRuciaqQ8bamzT17NAO2oI4LiW4CeV4zYoiJfx9PDJ3 2Ntj3e0G+CSlxHdwnLjgFtcKM+TIjkF1y73bg4KrXITd5SSSbtrSQNk+iHGB9Ou9kSeh3mfLuTf P+pRP1r5CsEoLsFs3UQHufgasgqAo6Vf+FcbWUTciQ/GZY3C/FDPXnNclVbGdgnLRoOctphlKqU i3KpqBKIlWHkVktL0LJKP9MI/WaVbBJmUaGMqQaNut4ps6j0Sit9i2fg9hy0oCKQ58RewoFQoxd bnR2Hp3H/N54ACxQlPvRz6i1Hf1cdQG8Qc= X-Received: by 2002:a05:600c:5303:b0:49c:fa21:1c87 with SMTP id 5b1f17b1804b1-49cfa211dadmr202126655e9.28.1788799537542; Mon, 07 Sep 2026 09:45:37 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:06 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-16-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799320; l=2768; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=iRJ3rs2DSADN75Y/aKHhGRl/gUKlcklqtq6S9GY4iFg=; b=R1zNsI39Wl6jksng4NyYVJYC2BQuA6xSnHaHVXPj/v9jnRKS9zfyzLQs/rxG/3dJmDtQ+EEn2 bTl0tSv/mlLAIpwmVTyiK5tUUdcySRpKst8ZmuJWIMCWgE9enT86e1f 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: 1788799588054154101 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799586; cv=none; d=zohomail.com; s=zohoarc; b=aIJV7bvFd2mflZ3u3rdB157ycKlQgSsFW6BSGkAEMOsVW/VFDAp1L21AqjeamBuVTgwkgZSeBRdV3whihA2hlvk0OA7Rr/GBSo8NgFltloKWIRkAQfd+K2X1pNE9ln5OcmpAoz1ZGzMOukbWDrIy9zlDAXiHddiCx7/e0GMWCJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799586; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=gTQyBGjiyIwy9r2vZspazLrSMojxjIw2ELy8e30WQmA=; b=KY5QTeelUfqFGL/76BdHw+kfSrVt6PaPkYeZqbtgTMolENfESis1RJUmVD4tIJnEhxZVdWgEkRjNo33RoED9BVF5MFersbTWmSpncz+hKpeiKezJzlhghIySCq2x5DMzON9my8pl0gNBwxeT1Gl34m3enckehxQ2OnYbxZZY7qk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799586029893.3554245375024; Mon, 7 Sep 2026 09:46:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cU9-0005ee-CF; Mon, 07 Sep 2026 12:46: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 1x3cTg-0005Ma-Jk for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:45:55 -0400 Received: from mail-wr1-f54.google.com ([209.85.221.54]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cTe-0003Xc-Dv for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:45:52 -0400 Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-48586861639so2633663f8f.0 for ; Mon, 07 Sep 2026 09:45: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 ffacd0b85a97d-48591eb3d3bsm17614891f8f.0.2026.09.07.09.45.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:45:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799549; x=1789404349; 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=gTQyBGjiyIwy9r2vZspazLrSMojxjIw2ELy8e30WQmA=; b=XGRVDvaVhv8DHDsmIkiH0flI5+oPmOsPizyIWOFVeK9FDLPPLCa9vWA/s3IfLZNStZ YQr5yCZURQ/4sDQ46XNcWHvCaSmYQYsOGXpHcYEUMVtHkQmmmHOy8EQABn/58lg5EmM6 flZhInCy+fQvsXHpHcBrOd7SJd84Tq+ZgNhqmrIvegGOWXtRK2AURxPWBDmg4pq2c3Mk VG0F2lVXRyq2jzvqHx3Ks/iUV5aAn+llFJtKweA9AQPd9BYXrulPQGka8uuUxNmec/mT ykVf9SHXqNSmFFZd8FH98B2C9mORVb3dKqiFKws6Y2M8b9rODiSve14BKP+mh9uypnuU j8qQ== X-Gm-Message-State: AFuF++nACkuoytZvnb2hQQUrw83ObjfCIBPbTZfnIHZg+ujPI/c1vBFD RTAVwM/x1fTP07JnCcltj4SW1X/vh2Db2Pz1F2m4R4Zpur709zvFlarBrfOw4Gut X-Gm-Gg: AYBFou3EckoRV+nmFqR1C8mbL8OnpP25SSKrAqxSI2H680+b3JJ0gFDx/aN8ePsA0uf FooI+r4oBYVkXwg2RvGO4XgURJuevJ2AdHm69lPqIMWd61DzivCZ/RUMWPF62E9GArY7d8CF+AE dP116/adtFYQlxtEOVJj59Of28bRS9BXV/nXLwJpHSTQHng1sWIw8guIbjKb1quoIsloI2XDAc9 AgTCzvAPTxf9usehhaSxwA6C8H/tY8hYoOzCKNd5dqmtHd9ZcgFf14cdmtBGEjI8m1qwVq3lvJN x5e0k7zSOJqIl9WI4rgyL5tUHOvBV4kBVN21Yn5VyHfUKcsebP2NDbOSD/UhSR3M3NrdF8Et0Hy pjKJBlrZqAsz5trQlGJYrvhOUKR9Oc4+bY8fnU4azP7M3xWzndPtEK4RqZTkPYtqSdYGP1Lx68Y LIECRtbBkSHLOkFkIo7v5HYt8joht5mmgHX1TuE27tXogWtWwi+e2r8xod0KQEtyILtNXKam9V8 i2e8xs7ETXWXdw8HiFxkta6FcoqdrcPnR1szrZ7/fZ99Q== X-Received: by 2002:a05:6000:4106:b0:485:8a07:3f0b with SMTP id ffacd0b85a97d-4858a074201mr24972267f8f.0.1788799548796; Mon, 07 Sep 2026 09:45:48 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:07 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-17-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799320; l=4127; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=tY7PIo0ZcZsHwpCofZ6bxj/PZeu4Aq9JxFvHO76x8I4=; b=NK8fxKE3xybO+5plmlCcVSOFJBNu0zuvUYFm7WQt1bB1NI6cdGtWPlwGOmS4MnDOfOUUICUdS AYBlvegyZmxBt5M7OjVFb/TmxHJ19lg6yAhLPDXmxXTVP21YTRJGT5V 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.54; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-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: 1788799588064154100 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 b8d0e65ec44..6066a348465 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799595; cv=none; d=zohomail.com; s=zohoarc; b=Xz1DGKZCfIMSTLL2Y0Sg8bz0eT1EK885ig2sb+TEd/5C1B2WksQsOlgt9kRlN6EFyAxb0gU3hyj8wVjhqlqChBkMJTaVYL75sMRdlAiepBDgSFv3e82ZIGKSI11gHC5GDmjIk7umWXLTP/KU18zq+/JRs4eBTMZMzg1UQxXIi78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799595; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=9bQz/dpQcTFmknV0ZVNikpRUpVUFhyWc4TFL1C+8fm4=; b=ngtmDyx6uR/1NLTFNrUKvFbx9YqknuECxfRMi9AnuOmjE6q0eZO+h+u3HbGXpAqmYUOmoIWoYpWozPlKBOT8g9sOTz0AjdtbwAR3vhY8LRF/EOY6xbDNhUMtf98WoOG5/+EgJarOLmvUu7xkDMFXMba5qBfAl/RC503TNeOlpOQ= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178879959499444.018319387496376; Mon, 7 Sep 2026 09:46:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cUI-0006AW-Rj; Mon, 07 Sep 2026 12:46: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 1x3cTr-0005Xj-BV for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:46:09 -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 1x3cTp-0003ZZ-NA for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:46:03 -0400 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-482ea739de2so2539431f8f.0 for ; Mon, 07 Sep 2026 09:46: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-49ce5533ffbsm327269645e9.3.2026.09.07.09.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:45:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799560; x=1789404360; 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=HAfi/H/MdIeecLa9iDqqQx+Wuw1T9tJI8jikLAan2lykiN9C8GnGvy3XmWjR7I0mh6 VLmZlGop5qCGWo663XPwewsf0P97cl+t6Ugx8BnpbSUxXNAsognoDxU5niJ3q1C2hqL2 QEvPxqSmGdoeGvrMeLgHgW6YfZVbEyWDB8C2UP9OJES3jD+++VttKelI5+fQdoeRBXoH GqbN7VjcVsSyz6wkBryGh5AX6dEiru4BkAPVXlfYgxKg+EJloH74TXur0UJm/qKsYXwA bfbtN6LgjIVUieEy0b9BWZkJaHrU3XFvi1BLQna6dCk3Li8TCr4z0XfJL85URNZ51Fan e5+w== X-Gm-Message-State: AFuF++kho1ItpZ4gSXf615dm8o+PSI24PpzOMjXTzPOH+DGzkFoTzi53 moQcAwoM2gqfNQQnZJKXTmfhL5N7RmtlOe+rpRZZ+KCxKGJqAC1U8uLikvUOfqaQ X-Gm-Gg: AYBFou2zS4/7ATYHghq5CESCR2ASFu1M/me+aW/Bn0cjqvBSCRLIZYANaiq+7svse2j jcb7/b1N08BwD0zeZqthT9Xxe7E8M5phTJGFrnJG82hGhHMytgFpMSMGN07A7S6C14ubZ6aPz4v EOwsLyZVTIGAILzZ8LoXx5smvYzHdVQ3HXjNWu1c6wual0z3Yin6ec46NMTcVZVrQxocjSJ8G7G OXvf2Em33uUf+zA4D+Q3smIqahFr+yfeS8qfX4Q+RMij462HkjuT4wEPuubVR1BYQl2NcRvaOan 70NjSkszwLXXrMULOKsvdZekBAixligSsLCUN0gyU/TGNQGtPtKPERXysm9H2kHbHrgKdJCw1eD sHJL9mr2YNqLE/9Wp3/bFUajnKTUrvdTFx1sIoxA/xodH3UKW5Wh6NMDwXvwXeDNzMQRjj9L5TO zLDilN01XxTsHoOzVcptyBKELmy15vyPl7++dTdtJ73GhJ/ZmCzc9d4+5Spl2Mtp2S6kU/NnFTd 0mSR3hvNuJOVMxiTZBXJwjKdDy36gcBUC8= X-Received: by 2002:a05:600c:3ba3:b0:49d:e79:612f with SMTP id 5b1f17b1804b1-49d0e79635amr87342445e9.26.1788799560138; Mon, 07 Sep 2026 09:46:00 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:08 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-18-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799320; l=1856; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=9nlnuEXuVbr9L6NPGTObkdBzIqjpFAqXLz9Eqo8+gf4=; b=x91vqxodgYiosSFS1bCekIByxelavNlrQRiGJNYP6+RCmICwPqEjqCZ3+zuENbJ6tpLFFfvAS K5UWyZOkty5DJTc9o5tqD73PXezARQl6//Xz26WzmlQlMsN+uuO3c/T 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: 1788799596478154100 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799626; cv=none; d=zohomail.com; s=zohoarc; b=Z70c6E8pAQHeMGddcDyh+7o0bEJ3HQuZOwaQwxiWdlu8IXHx380tSbqOYvZzHHrA/1Szg8O6YOioh8Jhg/DpAf6xzSu5wF0GZaPluMGfZKs+aTfeMCfE8v/14iTder7LHpwYMZtYn4Xr9a+wJZH8h8p/iE3iDn4YXRVGBCojghM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799626; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=QueqO13xdW/ZwsAlzziCNKkk2yOl7iMFMMHkLAoSdjc=; b=U7AWf64qAC3qGKEcg7a3oJ0FJzpE4AMS4YA+YfiCqgSB8PHqp8M4XrFdG5a2d0O24lg9rvEAQWOFVNc7orADsgi9oei9sB0A2AIg1+MtpRfv8KhwipPLKPXsG8XUcnPXEAPq1zb+k30HsSaq5RF+j6M0p/TOis6nS5/RelgfRjo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178879962603631.759539412251456; Mon, 7 Sep 2026 09:47:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cUP-0006cM-Ct; Mon, 07 Sep 2026 12:46: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 1x3cU3-0005gV-AE for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:46:21 -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 1x3cU1-0003d6-6A for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:46:14 -0400 Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-48444ec4fe2so2292226f8f.0 for ; Mon, 07 Sep 2026 09:46: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 ffacd0b85a97d-48588135600sm25864304f8f.2.2026.09.07.09.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:46:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799572; x=1789404372; 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=OEFkzxkkzd3z7JdYdKV8rraoyoM9MAo+8gkBX6ywBG1Vx9JQ27qwR7MOrCr3z3su/x nnbPLB9mDfQleHd9nitiAyaiZT9AvRlpyGpUATeAB/+f42T9sHcYDhX6tySmU662JiLj Mo8zDRoPmukOPBWBJTuCzVfQ3ELnRdOP05Xr5B7mqN91+Jr+jQF5DbPDs9RhT+C4huIn lcWj4kTwVr2M9kefl7zAoME48oJBa5i/qXVoFhrmlRy2ytpInntJ1C5wCiZ9x8IpAtXY Tg5Lbt8kXwgiY/jtpePBo1fWLCng7AZ0qdxVHUOOkqeZ2UrmlDf2K88a04P/drXXFAHM 5q0g== X-Gm-Message-State: AFuF++nr38uge0QD54XuBmypO1ZTx6q1TCO8L300bqflayo3BYYaJSvY pkoaIamTWw6Mgb3uDNXFK2whNWJqsLHBcGVKugq2kYVKt0bAqKnj2W6AwCgllTgV X-Gm-Gg: AYBFou2rL6ZuqCrMCXTGBaab/e6jB/oUBQy+0Ru61qm7w/GjBjx8kd8BTpIaUkM7yNp lwLNrdAhFCimujRzbx4NXZz2Z5sFnXf76/g72irXVpA8PP9pyAjN5+nPZAzAO0c5kuIekIDDA4h iuuBPZKyASuckWAtwg5iCwWrY3vGeOz4+bBuauFrU7tBnV8wjJR/4y/q+n4inJ+eI+gamSjv/Q7 nAEmK4M71urkABFEuqS6z04mWQuR7n0MczXBb7+PYlUgCLHfCvT8AhRKecFG7omPz1s+9KNCbi8 C3EmVFpzamtdx8a9rDNFtXCF4Lespg339iIp9eKUysHCMAOxBIxoTXCLIvqcUeUb4qTlFWLytMJ +yUztFGEcdVyjP+6y0lDdtVhcmwYbFXrAYfpLls7th71MbUfxSZyiXOU3dkTyE+EyJSBHSzj4q1 rRJMlHUq4GtqY0SMbJCetY8f0q+M9gwl3slvUZjY0pY67QfHOzP9l5mRE9PbLRhX8acpZKvdzI2 eH6KLkqhyBmlZkvBNHlshkGOoYTryE+q/M= X-Received: by 2002:a05:6000:612:b0:485:8e19:1979 with SMTP id ffacd0b85a97d-4858e191d46mr38805662f8f.11.1788799571524; Mon, 07 Sep 2026 09:46:11 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:09 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-19-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799320; l=2993; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=PGqbxjw1SjqsGpwA7KFSLwn1aqj7opA+7ReWeQn2c+U=; b=mxihoUkXSwclIFf8U2Czb5eGHX6bwlGb6DU0RvxeGe+mLp9dNf4FZbOagdvHlxDFwvt7ikQuq uLsj5+k/vLuBlrF46LsUuA0EHcV0yftCDK+qEyuVCyejUXtbDf/qE8T 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: 1788799628240158500 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799615; cv=none; d=zohomail.com; s=zohoarc; b=H4yCkayidBzyiVVRm0eqF0iBzvS6qYjigNXLmKqTNTrRpXIC/teBY7XSCLSGz6qKurUxHehwwm4dwFaiz8MryCATyIhcMk5eGT2WvJfNdJs0At2O1tdHOL7dwQLSfr+NEL1XBs97DTSXSkzUlZmiiyfMxg2BE+umWwNlrqKzmQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799615; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=CE66LIeSclgE4NkiTTrzb49MDOENKPAt6wmOxVbF85E=; b=F9H1sNXbK59F0v0sJrwGa2MoSoTNRo/jGyrRlG9YORKAtjFVl8sGoOHrXx4wmnho56EnSMhGzie/fK91XMXBWy8JEnzMBrcNloYou49LtKip6p3ameZcbZj9H3kT5E4KO5OAcxrOMyqTtg5wMxwyvmKFLEQXIRY7L18a8JdBrws= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799615464872.3307406191275; Mon, 7 Sep 2026 09:46:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cUR-0006uz-QE; Mon, 07 Sep 2026 12:46: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 1x3cUH-00064x-Pf for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:46:30 -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 1x3cUD-0003e6-CT for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:46:29 -0400 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-49b8e527d63so44661595e9.2 for ; Mon, 07 Sep 2026 09:46: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-49cf7703cc7sm324542035e9.4.2026.09.07.09.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:46:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799583; x=1789404383; 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=L7qkc/07kgjKBjt9A/mUeRYU4QD5GRXF9RmfMZyAqf4USeKmLnf/XFvQt86NPrttmw NeHSaDXCqCLkjzFiTQJ97bFx0hK9rbOnoFdqQiVFOHm+PxeT8Ya0O+ddoRGv0Mbc56Qe jx+oz8lp4m+nGZYl8GQFwTs9mDFNXFwkbAFqbHVriFYcJnvT68Go5LHq6dyIwJqIhN0a UpYtkMXcfpaeTS0TJ3tRQRFAQAVsP8nBSWFTsJf5DOM8y5L7zFpQ1jSRck/X5vPmSsNN VFKT8918qvvXfwJPf/q2WEnZQcAE1U6MqaPSrA9P1oM/9uqo/Jc0B6ujkuqONoRUKVqw F2sg== X-Gm-Message-State: AFuF++kHpn86up3EDcBMEcfQSfQS+GqsVPXnKR2nvduuqvdKDq34HOQl aC4wYVDaTg8Yiy1PDCSBpPLvaNycgnbOQmlLqdnr+P6dMySOF9gdPCCcTqSCNqu7 X-Gm-Gg: AYBFou3u4WolP1Xh2ALJewPKp8jGPrcnLFCX09ygcjOFeJaSeDhGwmrj1w6tRyOo148 UvE/gaS5ykgAUHjIhi/5JekQK2ycsc8xoE/T+OpecTjI0VITSx/yZzlUucGg9ydxATy6F5QXDzf NVWQY+wAjpYGVa1tfoD25pGkCKkxOwpi8nIVLe/QWHgzFBPcwWFYrh30FkjXmlyk5LiocrWhmi3 sFGzFH09PK7iCCcZPwF+y/9YyhKuqhcv6WiyIApaaUjXWpyB87gCi9gBQ0SBuv5Y1PekTdF1GUE bA4quRJYUGK7SAn2KRf+/45bG4lVamNSHABNc9keOVbcm0FCSGBVVAonvJfn8dButgSDgVLyaDz tKC+LUCtj1lwVZKCOjMiBLO2T8RTsE/EGCfhOXA8MzjagSRTi9xRm+7XhYSnQq9EPk/bTHwVt2Y BybQ7ARjsTGuBIwwrhJdWJQqOp5aqoFLpL6mNHjaMaxh+8v391986bMbhhW5jUA3fJ6cApHO5YI md3/p8tGpw8DmbYy7cvS/AmtaJPXCM0mvyH4xyo1ZMC0wE= X-Received: by 2002:a05:600c:34c2:b0:49d:10d6:fd55 with SMTP id 5b1f17b1804b1-49d10d6fdeemr66158695e9.1.1788799582958; Mon, 07 Sep 2026 09:46:22 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:10 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-20-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799320; l=3608; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=whBRDkq86D+HpAogEE9qlSe08li7AMBnF3gE+b/1tiI=; b=fE3po2qgxHAmHgUa4dRQpxZcl6z4vvKKQ6RD22BiwT5SnNM9Qw32VHN+jGPvf0UX/K0o9Q3P7 ymISKZzSLRVAaz/gLKl2uuJ/UcEezdNlSW2hBLpIyJHiWQ8pGgYf+oc 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: 1788799618485154100 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799629; cv=none; d=zohomail.com; s=zohoarc; b=SgqIppqNVDX+oruNcpy0eGyJTWQbmMWcxDjBVOilxJNfJ/cb1RK66T90VUPCYrBVxYsmcRu95u/ThVNrfQuBFJMOlgwUQmbPYV2Eurpd1jbsvWgeYu2v85fOir0gMgzTILa3QMtlJh2OJ3Zp0tN3+ZG4atAunUMXKQVvV8JNoEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799629; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=m2GA4fazsDlog1s+fRBtwXY8L09cn4aW6lhQjZ5SfME=; b=JftR3htEf0K7axCt9xly4gVInEQabbnXgH3RAIe4wyZp4QRK6Agfy2bUBjt3BhDevVLROZoaxRxsYWBfYTZNs8kISowkUIRjgO+dMpzyQhjGh+16fhySLuiaKnKoMitzZ20aym3mE14se6ftXDnQvxVuMMG8jjX7vIWZy+l0dqU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799629273787.7226902739694; Mon, 7 Sep 2026 09:47:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cUU-00079i-4O; Mon, 07 Sep 2026 12:46: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 1x3cUS-0006yZ-4z for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:46:40 -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 1x3cUO-0003fR-Qj for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:46:39 -0400 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4995b0343c1so52975165e9.3 for ; Mon, 07 Sep 2026 09:46: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-49cee5f912esm418860875e9.4.2026.09.07.09.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:46:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799595; x=1789404395; 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=d+IltZPD1/ZNJTnVZvQEeYHZuPnws1hfVzRRQX/3UOk3w9nl0ZOj+S3NCHnPWS+IUe JlcyHAlxSPA2KyslDv2psxWVbki0BGllhEHStDSRSkyQgoCriM6w0oTQ3FqSSNODdMNL OBoiEzIE+zQ1gZk0zaJHgqjCdIYOXatMa5jx4GtXLy9j6xawcTC7Z88IvyPvlwRSr3ta jwGBjCSeo4nVzE+HdySHRoNorL8XQLU6LjeMzheJmQqSaLayXMZ7EbuUpvlLbZij0iU1 OQ8ZGxQgs9sx1g4LaRWMPU/p9S5Yv9YfhnyQYNRgoT2fiILZwR9EEBAe+Khlk/CWvmGB 0hmg== X-Gm-Message-State: AFuF++n/tlLQ/pTuEKeuDX56hjDXPBYOKoxu39uP4pX/Wap2C0wlpDHy JWg14OsxT6ArBjdYvzK/kTcAmOYjX3IrOF1CsaXDUSBymhScXhL+FrfrEnNrlDFc X-Gm-Gg: AYBFou20d65ig35lRt05HVlGHLT9KMS7gQ6IigzMuaRNMv1FBbbUfvc50GFvyflOWDR RArh2MdWBIC2anbVkr2cLngjg6u0Tp1kUCE9M7471y6ECxXKmpEpe+gYhCHvX+GWPLHzdkFAqwb HmiTVtH5aRApEZ/PsJj+ti3REhjBBcIsBKAAAwz0FNR2PFUnDRAod8m7y85RET+hlR9+qVG3/CZ 7PhyUI+sdQWwg88f9Vl+GGRcwc0zXhUnpVbjZw4YNRtnCre1WufXxvr5nOMgpQWypIM0AITyT8O Z+fLBZWGwjaW4a9vZnPALpYhrba7CQ4gbhnJP3kcDM+3r0qRKGi8ay+7peSM/yfnR3+XJlfJ1gp DE6nZNdqMUemrQyw8UrxooQuy4Eas+jJbGvM+VUT6EB179uOKAkGDHWYPuzRinBWJp9o9x0Gjcz ptbTC0nlgnhFUyIO1jzhwab9aFKdYGvCJTLCjDGr4uCuncwUxARcQGViVk9TAajh4Hy2zV+5Jgf 2li7rXE8Q4zWhqDuc0IOHOzOQFWFqCh9tQ= X-Received: by 2002:a05:600c:358d:b0:49d:797:8488 with SMTP id 5b1f17b1804b1-49d0797853emr138784105e9.1.1788799595177; Mon, 07 Sep 2026 09:46:35 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:11 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-21-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799321; l=2162; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=KJY0zIrKxG//LL1WKd4K1qyh6CHHxQ+6MszW1XMqpgc=; b=DkpZIF6av8FRJBac7TBSPEXMoJk9MJKiRNQQ+5grcndk5XTSmIoBIZK+HYudb+2IEsgln3bA7 +Kp8iiVOQ++CQgvK7QAructEQfgWjkHhaqd7cCHpuZfkUyWAcBNN4Eg 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: 1788799630276158501 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799633; cv=none; d=zohomail.com; s=zohoarc; b=D1kxrflrigMURqsq2QaOhpcVP6V78NycRcG/tupMP8w1Q9zYR4DB89bWYKXplNgt7oCCwabFpizczGlfam4kfLV+w4jv5coCgOi7514YO7ruyLZaFzb6A8CeyNcZEj+bAUZFiUj22iHhWIQwqoOiAMk+9mwzJ4q+gFCFkFDxByY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799633; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=xjPmksDx32sBE3I0U0f2mMmY0tOvAwSTdWeiZF0OcZw=; b=nri6fhmF77BsKrmR4XvLWTykFO9i2p9D2jhEkEyJW5p1AUpyk6cCDOukEAJUXs8A8rIbEMMi4WbQ7QJwHggAURCyqmidQHkh/wmtYNgBtyfOU/0hv8/5L4FdmYg5eT+xGUPDOrcz7I4uaOjlK7Pb/PebwMsnOgyy5qGXXoMS3uI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799633183863.5049984965881; Mon, 7 Sep 2026 09:47:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cUr-0008Ku-32; Mon, 07 Sep 2026 12:47: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 1x3cUd-0007tx-U2 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:46: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 1x3cUb-0003hp-7I for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:46:51 -0400 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4956869750eso33118695e9.2 for ; Mon, 07 Sep 2026 09:46:48 -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-49cfbdacc45sm293364065e9.11.2026.09.07.09.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:46:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799608; x=1789404408; 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=WvGRCvui3wziyIffUf/Cjyjt33DNIIiivGjM6ks1FK2etT2ih7jwI3Ihfb83aXkw/p ljQ/0QuxLYXuhWA9gKX45YbCgQ80krsmAp/xLxMnzMktlR4OEne2TdNjlS4r2S+Vcw7v uKjt1f7HY9BFLBlrDP50ukgpZXhUXIXhufAXd6CcH/AoqLU2RbhndKONgMM1DsM9fJ2u LZ7db8o2MUrsrmYJzrHf4/x/+OfFFpzONjj0pK2uv+YO9aI7iH6SK9x2QxghcCcX/lLZ udlRpcwPwMKYedyttlx1noS5bdKnZlEuoMDiPoaQSJ00mSazdHISWLl+as5i5lIwFXhJ /jow== X-Gm-Message-State: AFuF++nKAnBMt5Zu5yHmPvDxvyVDGTa+dacVG+IvJXVZSg84O4924jDJ EyQbEGy8ggeW/SZQFMHB0xFeJIDgXwUwztIGraf7Lsmxub6Y5UTfcLcvEAH+NWtp X-Gm-Gg: AYBFou2p9lz5q0pt4pRBXkpywxCgLhYMVhwXsqi1mL6ZwIJBurO1v5a1FbnhZDuKojJ yt2jmo7E5abl06+MgeTt+3ZXxhXSc0z6oISPhBxdbaiPH3FDpWXpyVLJ6SXFq2Ot/e8etsXSOY1 quW6BFDAHKWRhj19Wc4F5FCu352ggmVvJlTGR9TPcDsjP01aBN7jPVH1Vp2Vsdd+nmGhc0lY4sG +osYg2jRfBf1M7ZUZit92sOCZ4kxUjtqv+IzDfx2fFHn6fVlU5BtGN6oM/UCuN+pI7R0EvSj7PO j/3TymfOkx/EfvHrOKDgM6QQMjT/ADk/e1GyR8xwBiI0Lm2QhWNc3tLcpAkclT2j/FDbN5M/KbC H3+sS7m3UhEe7CmmpuDW3Xv1rsF/foZ14JZr5pjjx4TxQ+Qcauez8v9l9Q/Kait3kNzNHB17hUv Fjr7nLp2MceW06kqB8cpoP3Ya1qgGyX6ejdaihmR+NnaOdMk6Z0K+zXNjC4HHhdMUKfoK6/MGbY 5b+6GS1ga6Y1axzVWGxE0RaYsf/kks84VI= X-Received: by 2002:a05:600c:524b:b0:49c:fa20:cc08 with SMTP id 5b1f17b1804b1-49cfa20cd2cmr219383905e9.31.1788799607526; Mon, 07 Sep 2026 09:46:47 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:12 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-22-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799321; l=13372; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=xoWhr5Wtvx2t0SPDX34IEK+W+ImMd1a8R+3tANP1tIE=; b=BtxQFuad+wVKkCsHXWHK+1Ki7C9DWRGe2I/IYjXt6uO8EMy5N0Mx4ugDKGDfI2bY9AG2ZrlQ4 but+ru6RE+9COEmq2pmuidiMpwPnCtzwgUk5kSwMeTgI289bgI6btfq 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: 1788799634856154100 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799636; cv=none; d=zohomail.com; s=zohoarc; b=I9eD9weeHDATAtIdjHpXANex7W0GA08tLTLN3lcK/3KfmQ0+dB/zoiKFc7A5iWvI5Cdga7tkA7jjYVztqjo3kSCP9YVirjzayGBLUmB1j1MwMOwDXsGfPAbfoOgixXagt8h2Wbd60AsF+AWksZBNg0+cOHYQhXwS1K4iFOVZJPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799636; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=v8EZF9eDUNIDn179OE58eZL+YWeS9afP2JA0ppZGVjQ=; b=bSVFWiNYKmKcPQs8RoAUDeFMZX8uyc1/TivS333PrMP99lj8qdDu5w/Fu0ovKQJObhgrEvxPu/vKitzqXWT939nUMYYm6FiWuY5Q7nTf3mGySp35l2zm0sTDMts6htQamLGehFTQKNtHh/jW9oKDsIpB02bzgd2qzAxFlRy3pzo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799636877870.9763823037503; Mon, 7 Sep 2026 09:47:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cUs-0008U0-C0; Mon, 07 Sep 2026 12:47:06 -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 1x3cUo-00086S-IX for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:47:02 -0400 Received: from mail-wm1-f49.google.com ([209.85.128.49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cUm-0003kI-Am for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:47:02 -0400 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-49b0dd3c9a0so36184295e9.1 for ; Mon, 07 Sep 2026 09:46:59 -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-4858ab73c2bsm28121655f8f.22.2026.09.07.09.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:46:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799619; x=1789404419; 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=v8EZF9eDUNIDn179OE58eZL+YWeS9afP2JA0ppZGVjQ=; b=Rw+/XOKoiCyT34WkEX31BDdxVdRUtAnSpWcGMX1rygyTaFs+3ug9b2CaGolDOpkbdQ ZauFFMPY1MeVTYdbVaV8D+0ubCVwEGlARjmUUh50/NsqBH/4scCF1XksDEQS0KX8cfKN 01FqLKvRhAhAEzsDj5VlnhKDJIDFdT6Qzq5uwhf1i4oaNV6EvTm51fEIEPbwQfVq2E5V 4mprdhrplbReyz5GGycM0KKuRK4XKhO/6sjnbti9e0HmtfRnEWBuyuCo+LDKMnWTT6Xo XViHXMj3q1BF0NOmTf4eyhj+ZD7LqvXo4444pgNdKC9k8a4OQx7g/HfJGVfAGWyrahtB enCA== X-Gm-Message-State: AFuF++mJSWQV1sblGV+czLaEgPVqoT/XiIgqBa/9sVgU09Rowlwgr8jA wJHDbr8929S0AWPJJXjI6Oe8ytz48QrbaEVnP8ui0EeahTdDjUuN3twMwSLdX6DN X-Gm-Gg: AYBFou1jjKyxGEuUqXImaCq+r0TJCTK9JXOjwXyWaEZM3do7+1r9HX7/8CjoOeY0k6g onoM1+xvglsnALQFu8IK2DpuRYaaS11GHof9BtfKNy1+TTj69YRgxIdGaCbQSVekVr/tpB/E94l C2vnYJXVFKuiYRgNp2VMNAUJdxPQsEg3rQ2xAdY8SDnxTIb7ZlXyTGaP8V+0ijAALQKktdCxhfZ 04SRZG/NWcV+vp5g1HSMV7H0+M3/YUF0gi6UT+oMbW+/j6w2DmBj6An5pAoAQV88+ml9mz4+6gn 5cqG/BZRwy9sOz+lIgnd0ThtwpH5yuGEWT09jWZ+G+oSeVmKJTDQ7lL99U+zmivKPFHC8dAgYli IJq8NPxVD9eFxkkioXV+KhBojrmCi399rTXCoxg9ZpiWBBNUQ6FqSwRLybvfscVU7pEmRPpUWCN uxNhoHNTS680ziGmKZwc88G8L3eiR7SMbqL/RY4f7YIlXgnyyPFymVnRdM8ox5omPN88uSD2aJB 66kXiwWD7Ghl55+U9sBpahnMfexALFdKg8J X-Received: by 2002:a05:600c:a0a:b0:49c:e1f1:3dd5 with SMTP id 5b1f17b1804b1-49cf81e6cebmr426049775e9.4.1788799618781; Mon, 07 Sep 2026 09:46:58 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:13 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-23-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799321; l=7120; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=NRrEUZR1wFCZZqJPWZE7S9XMdfI87+yB8q/8U5BqjJw=; b=PQV2ikqU5bkXKCae8twV5wbX1Zj8UBkiZRIbX31MxxL4GCGvkuzm4xGi6nu43pQy1dVvkPUjk XG9kLA1JYBrBpfnCbr+qp3Wg+iWunCDD7JGIVaAe6+wntX2ut1F6Dqh 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.49; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-f49.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: 1788799638865154100 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 2da91ee791..2bf3f5555b 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -320,6 +320,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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799643; cv=none; d=zohomail.com; s=zohoarc; b=B803VWmrCA/HU+MgyB2eBrz5zVAXWcdiGYmpl4WsnjPHiRxUluVefU1vhTd1IVs1IReBVAF7BCL9uT79w4DxaWdwn01683uLRg9XyfN7Yw0HaAMbpXyVyrhiWJm9hnQD9YDuLa2q2V4V6sABu6yz7ZhmkHE5eY1z8KrB168Fdgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799643; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=T0UIfa5fY9UvW53K8vxfMmiR1L171Gz3N0KwneftI8Y=; b=np2M/o9gctKM+A8SYHhB+gIRQwdEz6LVA6sESd7y3YapXgVI/RRqnptgXZjjZHBFvAUK4bFivlP+hFcJ/g3jtdStFlWxBfJtyo81EUDtbbu8g8WJCqjMson5sounkxlhlLU2VCe2YiledyuYtNb70QRjfmI2y8js3tkPe3gpvCo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799642961309.26146172716096; Mon, 7 Sep 2026 09:47:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cV2-0000ur-E4; Mon, 07 Sep 2026 12:47:16 -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 1x3cUz-0000fp-Hv for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:47:13 -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 1x3cUx-0003ms-Le for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:47:13 -0400 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-49d0da752ffso16167755e9.3 for ; Mon, 07 Sep 2026 09:47: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 5b1f17b1804b1-49d00a5b19dsm256222355e9.2.2026.09.07.09.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:47:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799630; x=1789404430; 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=Gh3yGh2vp+H0r1gqP7rdsC8AeL3vx0YAAD0Xo2gyF2USQeBt9VcKEkgvuqR6E/fd8n YeWZyxRqfi1AbUrAPpMTwqWHXKeddhIIbAnAzQ97r0Zmky5L7C5w82JNKGQ8FPvwqbkQ fCtHZdG1GZkpq7Lk3KGumgCTzIiUNYg3kYKcJmy1C3NMpnX+htHPw1TDEgC6pGB3b46u HXUoI3478qdk25dshGb9Xh1AqQJixQmMCAadfGJYPVxHARRwHH1+tphHFiRVvnV8zNmi y60Zj78plbv942k/l8c93oUJC/1om37cuerztMHBeRcWAkI8fh75UzrvAXRi10PoLWgd HwHA== X-Gm-Message-State: AFuF++nZxo+UhYx5/2N4W4FGgSIuL9mB/ckI6T6DESRvAxba2GOJCDuI 2ArjIFnc/Ae2N8jDYkzIHc1taiovOqOM7DYMs4m2MwuyaJlFR9xCEKOU07CAhMHd X-Gm-Gg: AYBFou2EfJf5GbFjhiX2aH6/nrV55Yk6LX4k310jFICgRfxaS/1tA/ntH3nb43SMEpM Kll8rvuJf0LmR26z48/qcDNjnquWpAiR/ojh2evi0KrEcPEFkquJCKQ2Ro3aELi2Hvi/Ex/PyHH Ol/t/bg+UU3EAyPDfBcdzrCnafTjnvlsV58liHD5RdS7PVJOddpOBkxqN6cf03HMag+yXc28ujB TF/jmDbCntJwY9DmmVo2unYzYQVh05NEzyMY8+QIi9OseV390WHQB3mn86mUTmVW/rLr1kuzPtM X9I21gU6vbu2YCNdTAhtB1ML8gD/5GC9/rCxK+W7dgm5HmiLgBsNO3JT/xC/5qNoeO1WVnjbjWu f+QvyC733Doxh/05kxqj46+Ap5OEVOOKgM4ZO3f3aTtxjzHw9uvcKVaJ4BTVWT7VKRGYsJ2wYtB UKJvkAz/E7YWW7JltxBuphn8Tlmprvh8zqKV7k6KgaP+59e7vIRQFnHVzWPkixyuhMfW110cQm+ QlotvgsRmaWPm0rtnzkknogj0NoQ2prfQ7zplBueCvLog== X-Received: by 2002:a05:600c:6383:b0:49c:f4ff:e872 with SMTP id 5b1f17b1804b1-49cf820507cmr215989205e9.5.1788799630057; Mon, 07 Sep 2026 09:47:10 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:14 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-24-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799321; l=3426; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=g7DB+ARtVObCPTzzGVKyyO/c/Gk+v4O2cZLGywD17yk=; b=vcswS77pIlQV6xFSH92vNxW0UN1CME1XB8GZiB7Jeo01zdFXBkJrP0Nw6t4Czzbynlpaaq9NA r+17S5SzciDAjAn6B7jwDTANIrHl0Er5FaTLKU6r+9PYR2mtwQx4CDR 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: 1788799644338158500 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799665; cv=none; d=zohomail.com; s=zohoarc; b=e/zcxg5loGX51YwNVfmJi9xvJjxIeylsHszm3I1xwYtJSIQ4L71HZe6Q3x6fKMelc3u7GJjZdaXnxk9P3THC3FIJorRqoTzwb/tErTbvCW7g7q2e7FOZg3pdosNuAIA8rdBLUWZ8s59STGZ7j+O1sJfUIykxeoqEjbZYRS9Ge7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799665; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=9Z7GCM1tL+WVU4df/9TtqoR10rm4Dif9ExOLVyo6FeE=; b=hh8WmFNOve9qJ1VGk1CT4Xde1o0MBSrZj8T69fmr65pZWqgjzeujqcFbJPaEWHyy3HrbwP61fkq2PZ3GAvZ38KVVY5rjhFNX760x9SfJIdU0LgiB43PBnB+y1YLMYUXQ7CqIijD4bIS3AWUZ+n6mEkY+cRPXatpDzPTKgEzwsi8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799665087600.1507083973346; Mon, 7 Sep 2026 09:47:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cVS-0001l9-HR; Mon, 07 Sep 2026 12:47: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 1x3cVA-0001Pd-Pn for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:47:31 -0400 Received: from mail-wm1-f46.google.com ([209.85.128.46]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cV9-0003p8-2U for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:47:24 -0400 Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-49d0d2d37ceso9335685e9.0 for ; Mon, 07 Sep 2026 09:47:22 -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-49cf772692dsm383628135e9.10.2026.09.07.09.47.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:47:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799641; x=1789404441; 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=PcbfLfL+HslMzBgGv2NBhhXO06b9Ub1LbHVhmSfXFDL8NdcX2mFsYIZQg1vGJcn6AB 95fCJeRkJEDCbX6+I0UYCt04Y1sMFkmXxNraa8kuBSAAQevWWCU6YrMDcyFRRh213Tkv WOTygh3lcZrN0TXhiRGzinpDHraLuvG1FswRmI3Is4H7HmxNhTysT7Mx8RWRk0YBS5sS FRuPpXX1uY/15nMJ3joJcoi22nt7ro+CzhsCngORjTEax2L/a/Xnc3kBpb40O1288evz sSxGR9tRAtekMePK3NbENbD4XGIaFGmfDpgpGPgi2badItlnGU593gfj84ljpiocOA/m go/A== X-Gm-Message-State: AFuF++nMrCmogwV/1g4Z1xjUSXQNzopdg4/cBRgx4A8bV/DLrtWbXEM6 tt1gC7EJ+Rh/FVbovYeT6cDDbVLIXqSaoS9luIK3bQN+XQCzG8XZg84mxakGBUR7 X-Gm-Gg: AYBFou3glyce8/slMhN9+ZSL02rxo4OMjx0fUnKCPYBBWVCwcL+16oOXq1GU/z9Z6lS GLW/z5fsLKjkhs7p6Hg19gMUvHRcAUNnQAqA//v6Iu8KFCYOppTF09GD6bA3H5mxuGPqtWK8t1B bT4R0ZKZr4oad3P5kAe41vZK2WC8gsNgjxPhRu+XHbugQ1RqnunmB/FUl1y2zGFmOgGK05Cibw0 UVYi7JhiYfm7EEJ1sPAfr4NSAAP3MfqpFLTlHvyyTj6cYtRytFdZjQ533wtxkfUY9IYk6haz8Hr 5Gh6T5r5ctiwWfaIUkmYQOogwSWn/X3NTOklL4Z82aBpqQtQ+b6tdm4xtZyeAPcboAdHUShtMgX VF1xmAT/RJRcVbmfmfGy6wqQHFXs46yT4ywmR6h88u4L/UDFPgQv4nDPBHtba8NqPmUp4TSdI7C nUVLUWKGOfAaKw8KMtbC6uJrrYeLzz6CvztnspxB0g3OgYiXw6tvvtypwLDoYN3E/x2lQaGT0ck h7Nej1c64o63Nu7eZXrJm/DJwA3NQpGLds= X-Received: by 2002:a05:600c:8b8c:b0:49c:e3ad:41d3 with SMTP id 5b1f17b1804b1-49cf7f4aea6mr227666265e9.0.1788799641377; Mon, 07 Sep 2026 09:47:21 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:15 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-25-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799321; l=3342; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=esijdRHOnlyhX21Z9j9OPDDssjLY1EB+c0uBQYJ2KSk=; b=hpZohmErGnafbPmY6SrCvDNdZC15IjJYRUesdKtybWDwS25NNzThv9DYNZs6LYKCAnV4HDSSy ibW6g3IcybwBL3Ppe+9LZLnImxtUxolek31t+7ctZJ/jjoJn1s7p4Au 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.46; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-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: 1788799667225154100 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799680; cv=none; d=zohomail.com; s=zohoarc; b=ezxAA0FXApySkhgIWSLFOCTNXlANsZ6Jnu3PIB/mVtWUqQDf6peI8zomF0ng3+S5nBPRdi90Q366cIFu7/XGtHr/LKh/8+C4LJCcNaCm1GnI6ms9e+Pu0fMXo/vuxp5G4jpdnMAotY21WXKBQwuygtnGouC58KKRQlqVbbK2+UQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799680; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=ofy5Q7w1hiOQ65qRkRFvKTBxqy4svZeHJL4ReaZKNBI=; b=m04SLbSjj3lWNo406Sy4eO6GN9pBnJtyd3ALtiwfD4DVvrbr96LKfP+3YXdp4CaL8bi2xZu674d+JOU4HOydtMUx9RnmKqcYQk9ZT4tRk6W/38NNF2thWqKk5j8wA7nrfKGO9um3cGBTtpOtbOqUbUPHikiTyJAtrhviyCtRd2c= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799680736849.1222592140325; Mon, 7 Sep 2026 09:48:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cVT-0001oN-5r; Mon, 07 Sep 2026 12:47: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 1x3cVO-0001TY-Ay for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:47:39 -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 1x3cVL-0003qk-W2 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:47:37 -0400 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-485843aeab8so4204646f8f.1 for ; Mon, 07 Sep 2026 09:47: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-485885bfe14sm30173358f8f.35.2026.09.07.09.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:47:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799653; x=1789404453; 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=iuY9FmU6CeBJ+UDb5ZqrnWksbuvcbbtKK7E/8NUPVOQ67rHA4nnQ041Fa1HnjbJ7ke Y0/AZhmH32FY2OBrl94q3MjNgLz6J3OjC9G4Nw3RjXDbPtcAPol9wmY5bRf8U9idRIMT IW8PEd54RmncxvxrEejGctd4n141Md4Ao9+MAn4lo6geV243WNhfKjXxDAxv4g2q7y5C Mgckk8EzNEqIFmpULziyJTF5mLTuTypt1rYOrySgNJagWV0I5IUiaikpUHPsnEZQfVzs 6AkD/lGG7/6aBaTCJt6uSiXicq752uZm+XFLlYrEJOeexNZwkHvhLNaqTvUFQVHRFe8w ndOQ== X-Gm-Message-State: AFuF++kJlr0cKlKxCVy9Nhq+Ul6aozwvYcyRasmpEKjOmg6fN3AJEbDN /inC4FDtDjBpiXxrKhdifgyqt9dXO3l5BSjM4HwPVJpy6+GhooKQPM0dLppVFUG5 X-Gm-Gg: AYBFou0MSsd/3RpfpAbj2RStHDsoEjQC9pezK2yJeiaCr+tS4bDk1ESYmZMXglhUvp2 6fM67UzZj36ahksflW6FCu9K27qhTsjfchPDgzbVXLe8idi5Ujnu9X+Cm8VwJSbw09rn0+f3UEO iq135ZUrvGY49C5AcCLg5LvL8GLdshFKaFJoh1Kd13WxbaZpuJ0WswIUkMCnDzHS7ZJsLv19T7/ ft5XB9X3CRPA3wz8JSuBhzBgF76vgNdyc1s1nLKcb0TffgAG5xkKnY+x3lqd6mxm+iwbIzhsv+P MDw4SNl739CYOmAhCEU/5GyhkX85G+cB16pwntuOGYGNGqiXAROwrq16D1Gbfqijf44vyXAFX+a Aeg0opsWcyuq4wWVJuA1SprPrqUQif6oeTp/1tWdp+SbT/egTPUAc6zXBaLmQLo1eZ7HmO8eu1/ BIw+pJ2PHO8SzJ0qPPVVwcFvEZ0Gt4U0Ahc99SQdn0vib4tWSPhqgPcvbOr3360iKtSS8EXWMt7 jxaUPXPU8G7VAsbbgxJ5K4YLW+Ck53c14olgJ/Am/qz8Q== X-Received: by 2002:a05:6000:4796:b0:484:3312:f127 with SMTP id ffacd0b85a97d-4858709b371mr39745451f8f.27.1788799652619; Mon, 07 Sep 2026 09:47:32 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:16 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-26-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799321; l=3686; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=/UwwOgMrezr7gWWbisIg/npwXf+K73UBVrdeGOhT6D4=; b=N6fnnAznNmfjWKA/VE1Pm7HkIlJMDde0pw2072nYiJT415TG6+vkLNOSANxYynvB5LBRwEXzR DRLCwwmBlTiDa58Rlp4RpAau0E9xpAOnuebfL+TWm3ASoc/X4yd/HRu 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: 1788799682557158500 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799681; cv=none; d=zohomail.com; s=zohoarc; b=NHE3kaiDHXHufmP5OS5jGlGczu713htzoFBbz04ArxVJTpQGBXKSAW7yKPtstFHBS87K2YyyKf4c05dJph2HMWJHpJyvadlyOslQkdJjeIrxZeUdqqCOvNWi4JxeNI3/3798quW5IhQ7EnEmsV0EQTwHKdxfLbcfRQqfaTeAdb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799681; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=zfzexpI+Sf5r0TVpd7delVcigz2TZ/5dYES5EEOvYCg=; b=fhey8uZG/I7xej4BRMafceF4p4++PE0TewIki+PmhNl2BQ8jrqWBnII4X0er3tvwViQGA2GJFJexDzceSHfFRoXrK/17B2U4NMRtH+YGhYQYhuspDw0cPF0X6e0OvT2hYTAMLXrxgFb4XtSU4QJRiqJ/7zN9oKM6Wo8EjC9icFM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178879968198774.33336478622789; Mon, 7 Sep 2026 09:48:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cVZ-00028v-2U; Mon, 07 Sep 2026 12:47: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 1x3cVX-00024n-9G for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:47:47 -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 1x3cVV-0003sI-G9 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:47:46 -0400 Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-482e257a23aso2656630f8f.0 for ; Mon, 07 Sep 2026 09:47: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-48591eb3d3bsm17621952f8f.0.2026.09.07.09.47.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:47:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799664; x=1789404464; 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=Hcu4nLekHar1pftlUBzGw+yGaSt0L2ODDM3MgyOzwa74XKM3LXC/FCRdS6O16TJu+T 1nAdO21ztCFQL0bxbeG3GBvpU93iVodUy5Go4mUu0QyigBAWP+xus+efbnQaQ4J0rAah UtUHPbxzjGKznxhBMLrQNZYgaoyGkGv4FIZkU15osRQumC2CpDpQTOAUlCLWQfPWKcX3 vzfBmnniJt2zuMPxFv4YT1hyUsv6a8tWBbyYM/lZzP8ro4lFS58tj+4HtY3qaes4RzSA +a4c3ONu35oDeai6BkggW4Ew1Oa+FFg7IiilGzYNI2k6XOvG0rteUNX4v4d8XFDhoYEF i1XA== X-Gm-Message-State: AFuF++m8FfZR/lZJOCxUx26aSzKfBvOkGUGWolkQHrhF0SQefvAB+NsD ZxvqIZbYUsJqkPFVczzOQ5bitE2qvQx0tTgbXDTFYwWzhWhtAEopw7xG2VtTciyh X-Gm-Gg: AYBFou2R7Ow7nubbWvoGjUojCdCAKkkEkxfpbhewxOUuqTZAYgtqfUI64MoyNcCsXP8 q9Lq/bi3SFL2p5yDn6pdqDrD9GmGd6h9k60X9V/37uYmr9Rtd0sM5KKntOfGEAq4KQJ6QvCjQMx 1KpBGdVU2Mxn3j6GNojVBfrIrbCy5pDTEm/eefKAic5mV4rOlkh8HTY9H1XuzbZOxIXXN5Pg907 HLg8BfyerACXC8dsg2slgXT1ZMdIZipxahh+snKieslGay1YV3Fw/4k61+aKDs9co0GGuO0lfJd OKcZ+cj82yr6oBY+K/bDvf7xJDEL1UPJgqZQcO0gr6H4T35LWjVpU6aNXx7+gOpsWawp4t7+bYy e7aTRkZ3RK1Q0hbsZ3/ZErxUboj94J9a4w+cEarAduUoxI3fr2Q6qsoZIuGhE50ial+qMBinUiY rt2CDYLGdonCWH25TuNaY9j1hnCA60P9G6F3NHGMXGXmG8mobHiu5tvIIcFLAYv33n0f4H7Q3Ok MBowSnKcM/8K3ZXjeVgCjBZKyseE6ahQKk= X-Received: by 2002:a05:6000:41d8:b0:485:8a46:b3cd with SMTP id ffacd0b85a97d-4858a46b548mr22685488f8f.53.1788799664002; Mon, 07 Sep 2026 09:47:44 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:17 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-27-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799321; l=3753; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=X7KAfuckHBZBi2zykYy65RlVdT/TDTky7m/n0BwbF7w=; b=Ao2XdiYTwB0rOlIowzuxajU4TNkrIJ9vNUDQYB3nyEJ7cWEsG8cLBnyXIvxkz7OchYjPl5Bl9 uReD+wIM4WOAcK+15fzMkyPBni9xNvGyPRDYuTBz/MdFDTPlVaVdmPN 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: 1788799683629154100 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799686; cv=none; d=zohomail.com; s=zohoarc; b=SYqOOv5cm4rCTwP5zgEFPTp0ICNFjpeVnuys96X1qW2cdvP2KT5bfpfOJdPm9EiSx7LoOtoUf6gG2lwWYDdnHuOzRPLyFuprjYO6RU07UXtm/dJZvazdIvXXXh3C4t0Pap8Wo0N7Wg1d2HCWovC9W9Xu84sgqGkPqR0ABC2dn5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799686; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=LphZT+IzejkArL3oUvhqeY3sCcOug01WUt4J0/5+FMM=; b=jgnVD4bbXwHwI5k/lcsK8VNjVE3o0bBvXgx2dK3ExG6MgTsadcB09t394GYKz0ae+jjbnLG1gWCRarCuAR2HDCFbMoKcVObSpSPG9xprhhcrq/hczXbHK2Q+NBLy5G1nwL18dxPGHKCOXPigllMD8HoyPTxuf/qbkhr2etzu980= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799686322325.6526346560672; Mon, 7 Sep 2026 09:48:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cVn-000302-RX; Mon, 07 Sep 2026 12:48: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 1x3cVl-0002na-CO for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:48:01 -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 1x3cVi-0003uF-8V for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:48:01 -0400 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-49d0da752ffso16174445e9.3 for ; Mon, 07 Sep 2026 09:47:57 -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-49d00a5b19dsm256272105e9.2.2026.09.07.09.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:47:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799676; x=1789404476; 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=aVlNgXYvkPwVStCFeL85xxIBvd1973s0u6h/KagsDibfxWXgtqHzG71yrAvTUghO0X i+921k8sfnfYKkgcW6YSdxrzotgeXICtfgDrk9IRwwVyQhlMmf5SQFCvbqQOlUBz+ddf MJOyw0x5ESNIhifC9nbtkhZJrB0w7543CjQsBcOdwowAxWbLdtTAftJFc/EtdCBiP0bz nOwGzd5KWwQpwl4GgGSDkQP5zypuzQDqHxsLv11Q9RrXjklPZSKf56Xavx73ZZWqwGVu vt1hxJ9QNPqEBQNVFLVx0T8Gbs17aBDCdYSiNGksLTc/lAUibRS75POeOHJcNI39LGYq 7KNA== X-Gm-Message-State: AFuF++mY/4sLpWSJgkW45dnRlEcb+RI4lYQ8+c5mAb2O4o+1zCTIv5cd jEae9/Nqa3l3LMucbpUic+0U/sHW0aMVFQMcjxnB5fc+hr8FSVpuuHtJSxRkwSBl X-Gm-Gg: AYBFou1TuYGmmwqJ3Tv1eloaQFnO/y10YQGcwQs0baIs1XAaQGIezMRBv4yaRLnSl+W dYh5qj+iuQwwfVW2J0ORHxEblE1YIHxmZrc1jjY+YIJukba6BzRDj6Ulqpb2eUuNW+VwK2HtZPh 9XVeyG/vZoJ/4d4rwxSK/hf/4vIkPMFMCRPRr85VI37E3OpGdAz4zm4UO6uJC3lXCjskadnsjlC IbIPcyfJxwNNK/vf3v+CqxpJFqvBXNwuCS8WLn1UbvRbxwbDUeTIf/xlwTTCDJBwj6k7BACjwzZ 8N+OQUnehQ2yOCiw7sbzLqDdytjG6/gmSZ5akK0meDsxkNFALY2QoK55IOOVSTcbv3V0tMLKWnd VvRO+kT08qwpfy+TPzT9M/xVBTWIOSDlniLgWXiVjo/FEP5unwfJ1yeQNPi4Jz1b+xkJmce4MBU mWiMoSglBeNzp7hgFdsDbrdB67/eAWdk9nJCJScQOiXqhgBqishM0LMVS2J7czhUlxlXMhjOyrX hbhSeWU70koVTOXMMAmHSvz7PhZchAegRg= X-Received: by 2002:a05:600c:4714:b0:49d:462:6eda with SMTP id 5b1f17b1804b1-49d04627387mr147409055e9.28.1788799676293; Mon, 07 Sep 2026 09:47:56 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:18 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-28-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799321; l=3517; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=d52DOv2V3QB3CGvMZYkl6mYb22coBmAW9Fq+mpMglf8=; b=8YgWFhQAHFckAd2VW3wFUmavs5Bco2/obcvgu7M/qizAK5VPt6XBRsk08kjKwkLhWfijPK4Y2 8pQQ88Q1t3YC4kI6csgDojdwBWslTEvHTHBOUQoQtO+YnxF+6vyMBKB 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: 1788799687534154100 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799707; cv=none; d=zohomail.com; s=zohoarc; b=PzriS3LzUBQ4HAi+kknfV+E5YekB2rFvsP+F2juFcADjDd5/8EJeNhKHmrtK2qwpZv5qnHOAAsNSoLKlNyXDE8wbMFkSCfxCImjXHnzZ9uVBccXKJyHEuERQ/0Zj/bqhhOWoK874Lq8C+wdOfcqdHMViustTBYIDN5Szt8FfUWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799707; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=xDaZUroT2n8sJrtLzMe0uCr4D4Xox3szI0g/uL81yHs=; b=mj1/Ju3DSFwcK2l2qN3vCd7I+gfwDGU5x9mFPmJNg0ONY6lddzSlP0SHoV7Hmsb5NOMNZtc6cyqXuhmoKNVTgTdrdmTFelYx6XIhw+OIU6wuV0F3tc5BJf4P5WqxNrSlsk1r+uVsL31rtVsVSIVIBcw1IKjKIB9cOQMvSy2lVc8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799707691495.0410113518667; Mon, 7 Sep 2026 09:48:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cW0-0003ni-0E; Mon, 07 Sep 2026 12:48:16 -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 1x3cVx-0003im-L2 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:48:13 -0400 Received: from mail-wm1-f46.google.com ([209.85.128.46]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cVu-0003w9-N5 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:48:13 -0400 Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-49b0d78a801so38042695e9.2 for ; Mon, 07 Sep 2026 09:48:10 -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-49cee5d476esm447480005e9.1.2026.09.07.09.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:48:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799689; x=1789404489; 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=WjJynR1U/Rmmuj7J8k9hczwuZ6LUQ+eC+obLZpNRnCaNqn6ubSS5zsYcINKlb1rc3g IGeSYaF1VhE8LztC+1bP1RXHRzKyPkhHSD4bld8ggW5D6bS2BZrmefT4uEEOnI9wCyz6 Vv2G7N+3S8T1yNf9JT9U7zikqveOz22b3oKTzNezNmgynyOw0Q/Q7FlbgyPle6mSUhjZ GlEpUnNGnXZqsSo0KVUQWNG07FVS/HWepl4Mkwlz8J2QLLs/IopvTx+B0S4wsXYsN3lB +nrSJSahQcuqfMnVUPQYeVV5vRdauyxqblAwA6NPqjmdFBMK9lidKe7BWCsu7EctwbOL XlNQ== X-Gm-Message-State: AFuF++nBl72KzcIlK2vxNPKukEpy6z+QbGtIJMlfEUgno3S8uHLNAewT OhETci+8LcE7LVDyfVY3MhdXhRvVhF9krjh4Rsms761bvwXkZ/7NHTw//0y1rKmX X-Gm-Gg: AYBFou1dRW8kji40uZiZ5SnAHWGVYHqT6jkWuXwwD9JQ8RkZfrUVeGmDHm3kgdPRlo4 lc/gO1OyG8C9TgNuMuQnvbFmEVK0KR2lsxAUDC67LnFuTjmSfaj/ppTQrwT5v7umj5OdpTlLIzm 3ACH1pJW0B9+NoxPn3QXMOAWJQ0p3gyHMf9VSV/kgSOBBb05sBI0RV/5+gF5nhKxuaEX7LrzWSR 4b68Rr8GmmFOBM/4HFNrn9WGTzYuQD/WOh5X0B/mEwEEYZTmquIz7eLTpiAyjj1zg2Us3oUJVKy R9ZqUYeKoACqIptdfbt+ugSed+stvhqyLOQfg7US/j7VSwMEtEQlbfZLwkIVF6vjdPQbhOMkq44 6XWX+6oNiYypP+WM8tO3XDBxLsEX8Is0zYViitH95piDtbVd+84gZ7+vaQe6gQKeffIO3AeCuuh q0KAGr293bPvGAUVSqHc/22TUIQYdIfqCKNwtTGZNmBt8C9W+9qGDi89YlS0/UkEutSO3bT9Up1 Z+b1QEmQW5fIsvNblVNQO/IG9smAes7lYA= X-Received: by 2002:a05:600c:4f12:b0:49c:fc6c:be00 with SMTP id 5b1f17b1804b1-49cfc6cbfcamr207136815e9.23.1788799689202; Mon, 07 Sep 2026 09:48:09 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:19 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-29-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799321; l=2630; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=K9HOm83SsQOK9R4XDnsjhxDGcTLTCjXMrgk6bTqgUo0=; b=JqTAAXTa1cgPUsXsODqk7cQoKOlWxIWYoUxLPLHP78hdfyu1C66KsHKEnMwiCVuEejruUkYW9 +AjcmKkEYZKDOS7XaDGtsoOYcPKbdBQ6nYI8iT7cbeDpTL7w97ZWif2 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.46; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-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: 1788799708775158501 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799712; cv=none; d=zohomail.com; s=zohoarc; b=HlLSi3TCxvoHIpRC43TdZnMpMrymS645FbUMxzQANef4OwuruEuFEe75MXplWqVkm8B9S81Vw6Ex7z9zSq8O8ZGZkEZg5mVsXSIfriBVP3kniLQYWaRvQoXBiR4vf/fYNFTwenjbnZ1sIGW87j2OQswE6pES5rce4DZVryxcvn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799712; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=UwwxETLAztE1k6Pih+RsWxpK5u/uYELdrNm5CxCbYqw=; b=ZhjdWzcVDd7/FBgxt9BCZAvcePONaaqj5yTJ1XhKF/B4GfChrLLiDJZI/R44QNhd0zUKq3hFOjMqWfHsd/oB2Ft5mLzJzVuo6oqvSJUVFmG9oqFov7lLFIC+PlLF9ygyDFPP34oNHxxrQpnZlxBd110+qwtzE8INU2FfoLLWZnI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799712491556.2264126049644; Mon, 7 Sep 2026 09:48:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cWD-0004Gg-Ta; Mon, 07 Sep 2026 12:48:29 -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 1x3cWB-0004A0-HK for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:48:27 -0400 Received: from mail-wm2-f12.google.com ([74.125.225.140]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cW8-0003yb-EI for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:48:27 -0400 Received: by mail-wm2-f12.google.com with SMTP id 5b1f17b1804b1-49b912e2406so1837895e9.1 for ; Mon, 07 Sep 2026 09:48:22 -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-49ce831af89sm286858465e9.1.2026.09.07.09.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:48:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799702; x=1789404502; 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=ZVyC/SyNozD/nZVf4hL2Piwlrr4kY8EUtTpO0LmRZ6ximwZwy0LeNrbvUd2WlGWTCm VCiPL0cmV3v3KnMabe2hM9X90EmIFc9YkNukGxLvpdYhoX5jsPWSGuTIfRvbc6t7K/lO 7N3bOKqymTkGY/ivn8MCJn1kwcXIqfIeyriI9Dd+R2n6XQ5KDNbQaP66+ObTTyP0TaAj 3JYyiJgPACAgDlE4E8BO4SFKtaW6wCOTtqvkSvtEG5IX8daRQmdAJ38+nPKZHAlvSFRX cIEKLLBMY0YUV8JoSHs8IYWYzoWHjqK68rYLm2WkYs1S9rGo82OTzRhyXpdKfyEj/Njb 6jew== X-Gm-Message-State: AFuF++lhwgkzRQc0Bsak+K6gR3oSlksWnNifZTU3Z78bOqpikxQ7pJrt AiI2ht/Qfq54RGV/7q4WIITlQRvxqnAAhFT/nOZVrNguhoR/j5TihspDCS85cYzJ X-Gm-Gg: AYBFou0aQPSZvcF0HABlstlUL2UyzVr2X9MZIi7fWLZd0GCYU0D7ySI6L/ifJqcGA1H 3mw9Fdscskp47b7VckRIECOHsZ0sF4z+xAm+lj0Hkeommejp1L+OKjT+YkvpEEgLJfxweUKqYML KYsgTW/UBee6mnROmriVZjxSd9nQJvgC7DdIQ1fBl/62eH9ABJN0JhyM7rfF64DPAWzfLOy+hCk 30Wo/gjEAWxmK1cu/J4xsEfjKNdeR5opQ159qj/ALRWweZ0cOGmey1xjU4HkIsNGBsEQhNnLw7y bRVPcYFycQNJ8/O61RiEpSQoxp1pNr5lkPiGe1hbkrk4aNisH4eksv+C1dSDhTkGGW633Ug+36B VqkbvzoJT5WnuLk30/KihXKhJMHwR8LTaafzrNRDTs4zCnAV+SVxW+nNlU0e8tfHAsnaU5RW38m cz8ISN7vvDTXmYYTOpwOGqk8HJ6AbHnSv7xtSDSxwmwJEtrCs5tTyxiCnRADTTfCnojm3PuSG5z 1TGDtGfupc3Nf69glQEHHw8ZFxTvIxr0C0= X-Received: by 2002:a05:600c:c4b8:b0:49b:8f5e:51fb with SMTP id 5b1f17b1804b1-49d17543be5mr23115645e9.3.1788799701596; Mon, 07 Sep 2026 09:48:21 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:20 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-30-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799321; l=3347; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=40jEbTSK65E3MsKCMaeknpjZMmqbQRo2Y3v73NUToek=; b=ZFO5CpeGmTn3Hy1w5L73yZy7vcKC/+kqjkZRXezIpJjiTjL4uJ0/lxPaYjWjgIGjqTHrn25ma OpW9RPEheCBBFNYtjIiKTUzjmgaL10V6emK9mVTgxYCdMkk7sjHZIxQ 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=74.125.225.140; envelope-from=eblot.ml@gmail.com; helo=mail-wm2-f12.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: 1788799712637158500 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799727; cv=none; d=zohomail.com; s=zohoarc; b=a0JTaL/CgLW3VB+GFaFKEEMN0Pfx9/NW+FV9JtF4vtY7iXcVwJDts9i0PMYZl+j8rHqG9gEw2OJPAcnjOYUG8buaY+H9LL5Bn/8H7n4Sztx2IIghPbaJa0kJbFY8enx3IVMjwwm4w2xHfWHQ8e09YDWNIeE5jIoHbJpSpZUqoWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799727; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=RnkBBeLG1eQDE9P6Yi95zQOq3H0LATrNJD3fWP7niYw=; b=DQlKsLJ8VHFz2Ku+IbN9sVxtxOzX/1h0B9TXIWhpUqDf0t0edRtaC1K/gMMfg0vy4y9q4YtYm742rWMzDzvYMeF641AvDRXo41zoVVGL9ijWuZFlwsxxhrE2gum87JSkZ4bBq/Z37XBkSHJipbGpy9nYyrHKBMYbKyW8RfZ9m0Y= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178879972775582.514394161533; Mon, 7 Sep 2026 09:48:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cWM-0004jM-O2; Mon, 07 Sep 2026 12:48:38 -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 1x3cWK-0004gB-OQ for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:48:36 -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 1x3cWI-00040b-NN for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:48:36 -0400 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-495590dde14so54042635e9.0 for ; Mon, 07 Sep 2026 09:48: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-4859162f354sm22111509f8f.20.2026.09.07.09.48.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:48:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799713; x=1789404513; 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=TI+nDieLtpriHLmNQ84ay5eUREmHesXZjpt1S1U+3BEiRLSAD7uwo0lFADzg/D20Eq W23Q9QLs26Q483VS+fMCDLlpqgowNvtW7zMfRRBFbR1kdU1HidHZosBuY+aoFU5Ls6oP aAXiQ8SgzbFFpJ8aXTMtBUZqU2QW6IjhIZ+2rl3iP7Em2894znxvgMUqgU+HXGQMKwA6 vWGStKjoKoNsDE/r+hs0tlvUK/s9H+iXt+hd7OeSG3ceY5xAmwPVoz+d8ngdC68k3AaY cGtqvSnuzhTK2O0zanGlQ1hREFk8u0WmMsW2RW1mpjFvP/JQ1r40ZVSxYNikaGNmFHg5 FP5Q== X-Gm-Message-State: AFuF++mInkfUcORRs5acfdni1+Vh4bWNEvlwR1Xk3PgV2H6k0kmUTCgx sUNKlSwvTcjaD8rNatYuxO1iUMZaAeUl6EI5ubXy7pwiZIt+3oSLw/E+3fVaq+I5 X-Gm-Gg: AYBFou3OtLGu2FLuTAwqwkz6d5iIfa1VQRTGubQ1fM2Kv+Dh3EmS7QJZNDJCBFGeOdr pzCYGV+Xk8hkbA3kx12mlQBG0sCg21GOmMySrt7IlXITINh6wy1LmmKMn9tDpnryRagqNkLYpmi 7E5b+IOTJmh/daVGaTA3VRX74P+xkzJ4bffZNULjXbuQERT9lCNeJO778k+dInJtyjs3OWbizzs u4LEoQNfoQh/MJkwCZ1XR+nY6QE4TlAfnKsv6AB02DWxjaO4nKtbgAtV3Oi1GRZlkwONogWR0hQ +Ljh1NrmiiIf1leXnoUS2J8hkMSfkpj2Lfg0Fw2k/Iygv0SxrPrb3krWDvNVgFR4X2xb72UB9Je fH0Vadx2ePRWnL1U7mlPukWWvuwxHai81Mic+kYtwdVP9vT3I5BOapHiOpcvjFQqMEPR0R6xYzh 8NHA6fA+mKxWfW6aSJ5WQa16qfI0JoPGcUAt0gS2YWpT0cJ66pwgm75OXo+BzHwhiZ2HfmhLNoT MifbCJWWqoDGWjM3lcn28a2j7Nqibz3JAIvR5mwJqi9ZXU= X-Received: by 2002:a05:600c:468b:b0:49b:9105:cdaf with SMTP id 5b1f17b1804b1-49cf8214eaemr417058335e9.8.1788799712977; Mon, 07 Sep 2026 09:48:32 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:21 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-31-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799321; l=3500; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=BGMUGmamSzCjRMfmtfuZ7L1tiySTP5BVtx1tPB5MRVw=; b=G4/lsIrREMbyh33JJLmAuv/nzTrFbZO/vkDL9IAKhpr2+RDXMANBzrHtccpEjfLG9cNlDvAZ5 dI8W4bCUtMzAqSBCDddjRyWEw0AgnZz0unNUjly8dphi6Q0nh/EMZW4 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: 1788799730583154100 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799745; cv=none; d=zohomail.com; s=zohoarc; b=XlQhIjY0PDafTB6wcHl2SsvAON/3cRXdxoX4OqYxe8a5oF7QXeMUNRD5+KQswvD9ZDNrKa/buxPzyp0TLWXddJnbGywX23rTWXt8NjuzJYoHlJHLVyK9Lmn9kpQLnz9TQF084EKBWjxcVmG/5wqgEHYDvAgq3W+T/exetHp2DGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799745; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=h8yIN75eFr9HOSnXFTY5kIZzSuO+nwXc4n8X4nmO7J4=; b=XwEOkZHP8RLg+ZKxmDfKIk/U0tezm4usgO0hPDY1Aoks3p9/VO5b6l8eos66UjC2B5W0J0jnra1WS223oxF7FGbAmS+H2/LnWxoL6+Cu071Vav6ChGHi6uiFLUD3TIWJWoO/GqiUFsNp6falmDHrFHDzA832tZ0iwmRhs8Pu9b8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799745341424.09185895353164; Mon, 7 Sep 2026 09:49:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cWc-0005Ls-Tw; Mon, 07 Sep 2026 12:48:55 -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 1x3cWX-00059g-Ci for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:48:49 -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 1x3cWU-000440-6u for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:48:49 -0400 Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-49954b88fffso28427585e9.0 for ; Mon, 07 Sep 2026 09:48: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 5b1f17b1804b1-49ce831af89sm286878005e9.1.2026.09.07.09.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:48:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799725; x=1789404525; 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=h8yIN75eFr9HOSnXFTY5kIZzSuO+nwXc4n8X4nmO7J4=; b=r3O255uEJIZR1YjpQkBeyNctxJRhataUtml8O+dUWuXxneWhuIZuFWjs9Eqmj2GumA TDOlUeF8cnRmBIzDPUNTtwAQYVWHq9LQah2ybEIuvz1y/TGSstMwjIi/3PjfdM2TZYr2 EgFIOSKGfDA44L+yPTHBfkZwZNp5O7rAVpR4h59mgR0A9ZQ9JtGWLHRZF7l37xAA+HCK jz4oUzExW1rFaSdD0JbV+8zKrdqj3hwJ98RXFpJLeRDc9TiJxC/Hp1LdQOEzLPLmWTla tZtemEz2e6sHgGz2QDaiHZdzU5s+tSfbmG5FOdgQgQd6aTDte3bUBbs3FK9Nd0KqjlzX C0bQ== X-Gm-Message-State: AFuF++lzEaglmAlf23RDPWhsUtws5Knym51A4HVzgV4MIV3es+5PUdQF uMKYDiDFOuw1BiiEFORIiOt2yX0Kt5mpZwmviGiNzor0WhyJi61jueZendIlrwCG X-Gm-Gg: AYBFou1XxgZAeL9CWvy1xklTR/gNvcSpJ6b5X2/uHDwzcW2ndEeNgdRiR8KN0n77KpN V0ChvxKHbQfwqhCjUMGyR1Lgb6bWQ0I9X8KpwE3+Eu6fi7we2HSPPsr6XVcIH3gP62i00ORhUPG 4M//xE+m9tPKV3fF1p1Zj/sYpmPNkishK7vE14DODMhTiq8rIsnF1MjLYC0G2uxFI40tW5FHllf lXZ+DiOXYwS9nq7MLHkvNHxpkQUycdpFe37AkPVncTQSGc3SATnvcN3CuQsg/aA3SOyxJHuIaSH HTNPY6ABOeFujpFaQspEk9ovyjr8/cjAVFOmJ3/twjjYcCU4EVjIA6XTwjwnOugLpHFExC3ukrk q/use1S8QQ0Rs9xCfloEg9YssrwreJH8u74s8TGqL6EKd6NZKkGbUN1dr1S5ikrGovk8vZa2Ybs Le+drtMOVFP+xmtbu1qEBlgmE7P7vMXegMFVGePzyOWcC1eaGGufxvlwu88Ic3Vh7Ac3zTxBXBo 94wK2NqY33WqCA1yOYIwiJnPtRwZ0M32ds= X-Received: by 2002:a05:600c:8716:b0:49a:a101:4157 with SMTP id 5b1f17b1804b1-49cf81f4924mr204866635e9.7.1788799724484; Mon, 07 Sep 2026 09:48:44 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:22 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-32-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799321; l=23168; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=j029W3Btb1HJSk/KuaGalN9EEA9qte8x4Nw5JVDbcVY=; b=0w8cDxAmyup6aD9Q4kQHHFL27DGJz4VgNfWOpoSrLM4qwfPHnUEr1M92HmfQjQKXtPU7zUqrD cxuEwsawBJJDnN1GlYDV0W8P3SQd/uT5NUnRGmD91oFFyPFJHUNHpIF 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: 1788799746916158501 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 --- 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 eae06369b0..1b33877d5c 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -538,6 +538,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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799761; cv=none; d=zohomail.com; s=zohoarc; b=OXZC/VlG2RNAEeXzsOK1h4AKUwhaLdG3LeIARqTKPlmsISGA1XP4XCpKXrJHDKmyGrMqpjeDbPPkDqKe2+iu2jWHeqUA3d0NskjF1KCbB0DFZ4oB4SXxY9ChoTG4eYJ4NbpYB4QIrjh8Ahr+Ri8xI7UZ90tJDzm29ST7wC0xmOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799761; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=zUsTXXEeIFdgO+Vb2tiN7o6xxQ0vkicw8Xmi7qgeMm4=; b=KQWBLTFlaEP//eRxdBg4ztKkQLpShnkT85Ifk4Bf5WkSpIEms/Ie3xV52UzCL3EgxKhMA2S3IzCu89vHLr+eVjSEezyYzW1spAYAMOAUFIlo4jtMkzeD5az67YPAu7WPc60xII5jxxwwXN+dcTnxlqLY5WrE+3lq3YkhfZKgXIM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799761167271.49157882294674; Mon, 7 Sep 2026 09:49:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cWu-0005Xn-Da; Mon, 07 Sep 2026 12:49: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 1x3cWj-0005RN-Mz for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:49:03 -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 1x3cWh-000450-E5 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:49:01 -0400 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-49b9320423cso42471195e9.0 for ; Mon, 07 Sep 2026 09:48:57 -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-49cee6024a8sm423768425e9.6.2026.09.07.09.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:48:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799737; x=1789404537; 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=zUsTXXEeIFdgO+Vb2tiN7o6xxQ0vkicw8Xmi7qgeMm4=; b=C1BNOJQWUVyj0ZfXXUA3MVXpWScNBBHzirsa9dqj3QwknhGJwcuT6794x6I4/TgClV nsLS0A6cCK8oTiDdJMQPLSnMGZaZwXbrodi3PJbzVlZSP2qbdZR4TNZdIP3NImeN28L2 COUfT+LfOQuIRwTKiZsNvzvtj+kZZEWDYiQWvu+b5+mx5AD2U6bU679lFidqt1yKO1E5 5YRuEK2Z6ULlXs4VBMkMIboW2nmKZhXGe3SvMBZiP/5CCAUiwkoG3B0NUe/qHXVoBRZe 4/dR5BkrjRSSgJ+jkTLMh+mV+p6m4SVcp27pcdpdJXwioVizLbY3zHCAkashkN39utaQ kQbw== X-Gm-Message-State: AFuF++nUx5j6uw43AMUOPd6y2A4dbeUFe6b6pgHkdOtPp0s7jjPYDzMs hjcHShtEnORzLVHJveGiJigRSpruz5kdjcQWYNNQSG6mtHOMu8I5sHKiO23VK62w X-Gm-Gg: AYBFou3h7DeMcrGInr3UDDtZ0ZKAu+MBCDV0iXK3e/qzG7/zX+l9iUMNi6koKe7v8he S/80rX+mL70ThzH1xb0bqqllIUd1PMLgulyea413Xy2GUCLGHMqFRd4ZI0xQ3Ywtx4vOHcOTw59 3BmvCUypjZE31VQA2gIQH28v+I8xVyLRTkR+eFfDl4laOSVgimfLVblIUN8BJmg5Xjawj/vpEeH dkZBum3T9wLmES5Un7ySCaJanJioLbU+epuLj72hyYuOdgKlfT5028YJTGXLIgMm8gIk1sBeHTv L/TAyTKhRVKoA6CotmuV56NygvKvPMIu9J6wAW9UvadrwKJe3i7J/SrCbQq0fjtkPRWcNf/2ghh LoOUJuqzHs3llccnGAOtWV+iDT46PBIDbyf8YXOmGYxOse2Py1C52csL7k3KMy0jp3mGCf0LLkE vT9dbW2mLHYSkyRvMxXCZ/2jp9afIpd7iDYnibKxfH65itGWFgLqQK0iGOqllmzzi5KhC/y+Ciz mzsHqNvbV7KjO4bwaJ7+htMSiTnyyhkDKM= X-Received: by 2002:a05:600c:8b6d:b0:499:a277:e8b5 with SMTP id 5b1f17b1804b1-49cf7fdd67emr471961705e9.3.1788799736620; Mon, 07 Sep 2026 09:48:56 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:23 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-33-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799322; l=5192; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=PgiXV2D5MUPvMC/5KaHeQDpxZM0vqyW+GxMY+0uXgS4=; b=nollitU02QchYB4vzHtldawtOY/2bbfcEI2xVmutJ7IBjxwYo8lZ7PgLWtyovhjkVfVvKWkK2 AgYVH0r4fBECa5+UER/mkoOrGILa3BIYDTqKBZEBBJOrFtNvipIA5YX 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: 1788799762710154100 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 --- 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 2bf3f5555b..97480d92aa 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -324,6 +324,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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799781; cv=none; d=zohomail.com; s=zohoarc; b=GV/YqYknoyCtsP/qwYsfsJVCQ6nG92I3vcOyFCOcY7B7+XTFfDN3Wyn3fqfflwJ7POdhRKE+o2UC5P/DldqiN9i2OLYT/Pp5IoPaksc2lqIgrulDzuRxM65/eIaev2z6Dk9Me5OGn95r3A002X80dQVFzKAzmWphRiMZEMpFs5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799781; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=yMnW4a8crPYO2wOiMAzPMEvePpA+mW750LYZ6d0wg08=; b=EfYngdhtSxP5reQffFoTzJVNN5LYKJ3ILUTyfphaopAutW+oZm8n/s9mSpcy+xV0wjXnzJeYfZCJzUrkv+ycy2BuJqU70URI0GlMXcDVxt/PHGGdGJpyCsCXhpGOcWBxj9IhaUehaDuMdXpO1BgBYUw6r7AbUwwLv+Lzym/HGu8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799781892692.4028120062001; Mon, 7 Sep 2026 09:49:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cWy-0005oU-28; Mon, 07 Sep 2026 12:49:16 -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 1x3cWt-0005Wj-6s for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:49:11 -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 1x3cWr-00046d-7d for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:49:10 -0400 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-49557167508so45547565e9.1 for ; Mon, 07 Sep 2026 09:49: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 5b1f17b1804b1-49cee7febb4sm441986105e9.14.2026.09.07.09.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:49:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799748; x=1789404548; 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=YvTASqEdy2XsR75Y7K5lLkAh8ofBTBhSFDmYfNFhlBQnK0uhkoFCuAwwaLmIblSdwM 5ehsds6YFUx6tcn2fS4xH3EyesMaEREyyAgVmBDF1mK4WshTIj1ewSIDGpFmyv3k5hN6 VyDRME55gCdeNlPeZD+ckuwqG8kmA0clm87tHsl639f220mRxLHy7eCetoG0EfiHjhIc XjvYTANG9A9Jx4kFZJ4/NUA0wZMRGyYOL7Sk/eunrtJrnrs53MKsBIv/0vEJRN/p/JAN m7VW70GKW13ttXl07a0FT4bOJX6++5Qa1crUMTsSqT9ESuGcB7ANAHE28s4442hkax2r nB+Q== X-Gm-Message-State: AFuF++l3QK+I01MNcPrybwnbkXceTPU4Z1LagTFWWIeGRsnlxCsZ+UWe keDTuZu3TVzZTOOQP4kOiXUsEiRs24H/9AusnvIpUVn8cG8L/oopIsU5DoYtG3gj X-Gm-Gg: AYBFou1ohN1Z5kdIasQRF65XWjljrshnwFqekb/Mws3Ska6odYlKmmbbW8MP268rcaZ MwNB9t6o42Hd8T3q+pTsgu3SsKC91MCWXVT8IDghXjKDoK9SnDpnmK0DsejnoxiA5wi0amoHpE2 GRSRpzueoW22aafaILQx36D6ZZbLZU2rpr2j7w174QddfUgdOnXzKTE7Ra3gMDYWJJOyPeMk7td JitN93e+8CSXbObaNY6j81Z4moGfIfM/UbUJ7aIAiWxrE9QFJIqXi1IbzfmkHr0dQTtoByTy7/Y DqFigQukTybHGOH7VXM2h+GmTQD/f6TaHSXljNlZYJXUxl2smR0u2kJcDplrAUEFrw7RPgUWhGp txlEIXxdprJvHWWB69RY3MRCKvV3z2VtahsOyRlwsjrQNbj2UbTHUNPM6FPA4KKlDbQQXY0t2/D ISyR5T3JPy2P1fKVzQhh/yWz/c3w6rRUXzD2xpaBxoOzUh5vwI08bxV8qgP7OhHnEN63jcYH0YO qNXL7V1vV/qGNFb/wMv6MrGKlbQII21dBI= X-Received: by 2002:a05:600c:4f4b:b0:499:83f1:398 with SMTP id 5b1f17b1804b1-49cf823f53emr455128335e9.9.1788799747726; Mon, 07 Sep 2026 09:49:07 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:24 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-34-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799322; l=5751; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=Lxa/vLTiqltAne2a9oGEC4v4uDweYMzTuPg2HL1aV2c=; b=NNmaz6nQ0Z1CYNpeUlQLsa5YBdRlrZFxGQp4E5/qtKiQDepQyv7y/6kcki86cX2TqUrJygxN2 TeU9HAUfONeCCFnmQivGsZp85iaFCjqXkzA5vZDv3u+8gVipQV+d+OA 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: 1788799782926158500 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 --- 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799780; cv=none; d=zohomail.com; s=zohoarc; b=nwjhm8PcAHy2yAIMxxVprMaePPkyH9xTQN1/hqcVWGySjnsO1F9LyAtntwNTVS7kKVM44ztpPO7fa747gtkkk+Z6Mh8msvFqiKMtPof6lXLVdAYX+/TFU3DuRXzb4mzuw8B7MNqk+hI6fXE0yoX6ZZaEvWirTz4IxQg6FvhTM9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799780; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=MZwOnu4u3mbwMqdzuk9WWRV5vzGX0PpwyIdVH5RHZDU=; b=WVYZIMtHWskpnvZbLBNiZ24NBT+m3AF01CwHwP6ys6xK6YGkYh4bExAqM7bUW76K1CQTti4szDufeOvhgFQad1ASc9lvJ/OY1oJBVhFecjqMpO8C4O+csDhR/CRM6XhT4qhjf3LsfMTB5FxVQOTkNNr9ETVzqA54MyFg7tQACpY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799780202372.0172238138398; Mon, 7 Sep 2026 09:49:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cX7-00069R-Fd; Mon, 07 Sep 2026 12:49:25 -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 1x3cX4-00061e-Uj for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:49:23 -0400 Received: from mail-wm1-f46.google.com ([209.85.128.46]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cX2-00048n-GO for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:49:22 -0400 Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-49b8e527d63so44685865e9.2 for ; Mon, 07 Sep 2026 09:49: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 5b1f17b1804b1-49cff8195ffsm269860585e9.14.2026.09.07.09.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:49:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799759; x=1789404559; 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=J8PVCiYin2VY11UWZxV1Vss+ZuZOJq4ZXYd12vRqeq5cVd/+3qcbue3SACvgEItMI8 DbRCRwj/5z2OhGCGy++Kp9OxTnBsWaVC4T937zeWTWaMINR0GuFx+tv2Qo6qJpOH6ajI /mbeDECzATlCSigI26SMDKbqMbhQP3JWbJb8VNUXd7/tx2QgWjFxEUQ1QfGNnNAWi2mu rUEPl9xfS4W5/LIN411b8r6zteSau6XCV0+MEKyVNcZoz0Gi6iPSOiqLfYVePF1uBmTM 8SRUaKXgDfIV1EzDIoK8zhSrGgIusDvcoSwGGvuR8+LPGAT2ICtAei2thlhI5IEZfr0p 7hkw== X-Gm-Message-State: AFuF++nzPYt1uLkAT80dLK1JRNlPicIA/HUnnYfk+NgwuIa2GZr8FUqL qkePkFjhFYy3HOGUr5kQLa4pqDfeLL9qhJHxKTiyN6VGiHvqQIX+Pu5v9CI7kmUU X-Gm-Gg: AYBFou3PR0ExKIAILhfZ9eIsvS3Be8L7heh/Fld5Gm98zFe5nmW3oRdwH5+EAAgtYmM UBVR660z6LWyyxCAkvgxiZqbMfVsLssZKOCPMXz3nJ8f7j375RsySfcgdDhyrH1k3TCmQPIfIYG gfkdymTZrWJlpROULN2w08wPQMEMJI8fwwdrlyFffVM3MvT29v1cZ6MCLXiYYGlOB6BqxjmD9F+ Hk9cygBhsjNgih9YVQPHphQ8UCQ+YHpOZMnPOyXOqw1ja0BV0sOutnpilcBVXG23jYbTdfrVFBQ 5aYP+vLT4Rk9EJvWzdboWhJtNA18mPHZSivrlkj7OCdD29MM+d73cmz+aF9wWwY88OTF52fD3d0 R1a9Qw81idt5juY8RvtcAJcJspbwEj4SL5gIZGInGw9ROiPy5USh4W04jmYe/FNLZdWhgL/0p6h AozdQepk0ss3kI0am1x95kuyYZUrgF5hQG0WNuM9nbT6ejSJ0IWFj8iNG9L3ct9jzERKAaSCok5 uT8PyXAclJw4vmwnvZsQYRwnn85UmBjf4RJchgOIDVcFQ== X-Received: by 2002:a05:600c:1da8:b0:49c:cf18:494e with SMTP id 5b1f17b1804b1-49cf825a530mr284573165e9.12.1788799758881; Mon, 07 Sep 2026 09:49:18 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:25 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-35-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799322; l=4599; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=g1WQNWNWvejsNUmKknPzwDjtl/zzqUIEuhP5ANmhVl4=; b=tUBf2HfFmowEQjPjIIQYDcvcY8arjZ+mEQt4LiRsrw0Uk90DyAHpWcXS8BpmEM0TE5JoIRsyR P3su0cibwWhBC6ooPytgNBdFWYreqiBDms0Q1Esag2fFOKkV9e2FTro 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.46; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-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: 1788799780986158500 Cover the shunt/bus/power alert-limit functions, the alert latch behaviour and the conversion-ready flag. Signed-off-by: Emmanuel Blot --- 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799782; cv=none; d=zohomail.com; s=zohoarc; b=UoMDn2cUbgigL+2ZuF4OAxecCvsluHCHgzw8qmxdRJ9QJiu54758PToDe4+oj6de/rHt5HotKmAqqSD3L6yVQMSK2athJomkaVYM01/lQm/hQNvEOs9b6GMCuRjrl6kIYl1BWFEP7CH4NBUwkuCxHM0KfC9A+lWnoVRDOCeJEZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799782; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=tT25q+kAs26amHD55A44HNQvdNP+ZXuCq/4WXpNirRE=; b=Za8yww55GFt4XKs9BqEOdxj91SS5JGi1LmKx7nRNgV2v0D4LKV94hl2doTvwEglzqEQdE3oup/JIvtIVLXSqIKXKWemOVjk0sYGKdwUF3RU0gEv8AzZqSOZtQdK0hEcQDeKvkmm/3VF+wqiV001iANhVVs+hu8te1B0Hllkljw0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799782768586.9498323748335; Mon, 7 Sep 2026 09:49:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cXI-0006sD-OW; Mon, 07 Sep 2026 12:49: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 1x3cXF-0006hK-Ic for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:49:33 -0400 Received: from mail-wr1-f50.google.com ([209.85.221.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cXD-0004AU-Ib for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:49:33 -0400 Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-48442ea8f59so3908214f8f.1 for ; Mon, 07 Sep 2026 09:49: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-485885bfdf6sm30892594f8f.34.2026.09.07.09.49.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:49:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799770; x=1789404570; 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=aariu3wT2J28JL0ACTNF2h1zwa15lyVUStxa9sYbM8ySnGGtinnj+jC3YKgVs0THad 2OC2UPmvoDWx8C8JSWRyPwI4pu8RShZU0hAbTLEcT2TN9mFCjyMmH9+ugOVyjMrN23p6 UkMltOuU80vfBkm88A4JcwKsrMYio/KrnuML2bANyzrUuGZw59+4wldKRf+mNWP2MNPj DRreT4VcKHzCK8dE4zLRF+8a4fhgaHwxHgcpa1ounX5Xbha1owf0PymoR2wUaJKEPrUn fJM90n34TyxOfOR+LC4SJMzrf+7MVaPWTol7oiOkdOtZXKs3Cmr+67XURhG+wkzXFS5J eUSQ== X-Gm-Message-State: AFuF++n+ttD2sSTTgaiMzjxO3d4Nf34ryCCeIVzbUEd/krDJ/rnQuCVG L8G6cw5Ks+iRWADUu6YaF+rVvP07CGzkrVGAhT/s8Md5S8PQRGQuvEI/I40B7f97 X-Gm-Gg: AYBFou0XR0PD8enBnC8FP6nOE4RvjPOSupaFG0Mgye0IIb/ZsTfHonOhfkC1A9+Ydt0 UbLATTrNglP6QI9xx/klAtLvmjM4bQ0C3jNkcMitg4u8wlDiKKPAygBUm8LfvR+j4XBj5wXiI1/ 41A0bA/W7TOfc5Sd7D2NMeRlc++JtjiIFC9WErrS2Eq0fnGL1jYgZwKXaxlkijmMsrq/kiKLgp/ jXPnUtQMhfjhy/WAx3QXw2YcUDuuvBEUm96FNt0sUCL0qfFL65E7kPTwrQAfYe6izblov/5YL26 LMJKeoXrJyU8yVjvSdrBP7rUwhv3BEFc7HDYiEjtqL9iU1YW/mx6CrMONCJOgKJ5yvssfNNVzb5 4m2yFRXYZpgh7+fxCSvpEbLP7yKVoJ9zJICIDlXTx3jMbJqKi+uo94vKXtylsGV9A1lHaQdE01C Y6N9RVKs0XuG+wpIxMCybBJSZ/jHOG1A68GLYMEPloZz/eRhMt4eMH6MpETPbL45rHS87Qtfq9D hWK1AG6oG5KJHLEXIbh1CkanztdzOuNaFc= X-Received: by 2002:a05:6000:64e:b0:485:8226:c69c with SMTP id ffacd0b85a97d-4858226cab5mr34722144f8f.27.1788799769985; Mon, 07 Sep 2026 09:49:29 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:26 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-36-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799322; l=4015; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=wQmdLPHBw+ci32U6sjobS3P/cDhoGbED08CSbaHRchk=; b=GWOaAHfudsUURaeLwOMp7pfcXhHPS8GB2EvTl3/ozpztdphpgnCY7uvriPe0Fot2GqmxEg5Zc /zmtqj8gauhBcywwNPhC+NyBsfPi1OXovHlwngRNyJMdVwJzF93rFDC 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.50; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-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: 1788799782991158500 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 --- 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799816; cv=none; d=zohomail.com; s=zohoarc; b=FnxJOsk2JNr4V8THbgdF5LMzey6qAERtg9TmuzBkFPSKnjFfgzmz0MZyJiuIpBu5HWS5Es/U1KFPzW3N1HF3MKG82fe54Hi6PYMLkgnRq+GJVVJDsTkRkK1Vbn9uMBVnNmp4a7yb7ZEo5pDu6S7zGFFrwc9McEbA00AIn1VlIag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799816; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=vlKqMzmrK40spXKv/yB5zNGWaGlUqMdf8882/o2C+B4=; b=FiI1kGC//q0t010lhZhM4fMgtBIrga3jCjvLl3LmA/SCu3Zu5oXlMf35AG8tDC7GcRujz9eZxrNKJb/P0VNAaUfCRzrDCJNmVfa7D9Hyl8jJ7pOyfJwD0SeCTfZx7oHPsbrDRglajr14vEDJXOBgRrhm0DwRJPFQqPa08W3YPY4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799816343884.5862936525932; Mon, 7 Sep 2026 09:50:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cXd-0007YG-Kf; Mon, 07 Sep 2026 12:49:57 -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 1x3cXS-0007MV-7q for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:49:46 -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 1x3cXO-0004CC-MO for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:49:45 -0400 Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-4858595f997so2249081f8f.1 for ; Mon, 07 Sep 2026 09:49:42 -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-485885bf3f0sm32571466f8f.33.2026.09.07.09.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:49:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799781; x=1789404581; 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=gbZ6SS+RyATpeeQjbcT161/Nxt95NsoG1/Ywipwx7LAdYoZf/AM10hvxQLI1FLts8x +d+YTuNU9VYtKjD9JI9Skl85OgeGByPYGcrGkZMavsInuGpOx/JYOf8rdhp6EtMNEjlF R1tsLcihqTLka0cfxZ89L6amoTP0TnDvOWtkIWciZey6mle9zxKQ8B3qa5guGbbNC02c JpmdEygGhEm/14dAQbP4ZyLcvlPg3gJWqiArxElLw1ml2JERp66iyffc4a/CfzD8zvva Aq1uBQopeoAjqYpmCMlKf9TlSAxG9kFwcYyTAa6cM1+8cdYE8046SjU9caLCJYjqbgNk Cr/Q== X-Gm-Message-State: AFuF++kMuthL9p5KZoWp9nDearWnv5r/vw+Fdo+w7R+eocCK9sLZIO/I GLJ+oasC9tBibo6hmUq6xn1fYS7kxB7o4hMX6lEVDJJpLKFTKxvqjFSVrjNAHFGb X-Gm-Gg: AYBFou191nEs2d1uwIY92KxzpscWX3b+LSnxBU2t+xDJdAsnxNBqfSOi9vc51gVMeaD SeRkeSxB76PMW6bi0Q1emHaH1rVXisq56i6GtoyJSiN2a2XIHxUkr+HvVHObSN2AHUPc1JP4Wsh 9gEYw0tiu1T+zNeNaJ0ESclabp5AgdIQrTw9coFI1RaOikbTKKTwhIxy/ItskQujuNYUSYrjitw Zu3W0RPBP2HJ4NyKVPYcU6RU4nYFbNUxK+2Y5kYxqT2QwvY0QzoV+yyT912Ya7NTiK5ehzAjkBC BfQbQZB3UA0QN5VH5oya5IpJzXEDmvGKb3uQkSDcWpwLTS3ahuQ74qwY/AsNYLa04EoBzrUavVR NyI9o7ArZqb11nAjOzh0VldhNz/7PWl4ZLM3MhuWay4fLXLPwcxlc5MSD/F4DIGHxj4hjILvYpu pzk2Ni9Aq5K0wGE4EFLtc6ophWR7EcD9KZ+iY/SCiSTs2V0P/Dv92HrNKwAk3gPvAFEma0Xz2iD OOymdrlxPAhNi3xxUCPYEZUqCdyeSbJ/xM= X-Received: by 2002:a05:6000:420d:b0:485:8ebb:be1a with SMTP id ffacd0b85a97d-4858ebbbee4mr38457374f8f.4.1788799781076; Mon, 07 Sep 2026 09:49:41 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:27 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-37-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799322; l=5271; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=Mc0oCEh0KqXrK8lJcAnq4Li1G/vyttVEriaHtSwE3o8=; b=Yx/Z6BPfNgz8qAjgf1heLMVSxs0JUqEhTM9MeBEQi5Ax4rW9sNQ82bZ6nZak3Zsm2trWV6MTS Sa28skbvUiNDetNTEhv77D4b+W3yJmXTXk2hdW3rt6hOQURUyWEIlvz 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: 1788799817545154100 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799810; cv=none; d=zohomail.com; s=zohoarc; b=kY0CAF3+pRrEZICjh5YyUPx/+mumqgoJ9LJlidTczFe5PH/pkm2Y7f9zaIAzQnwVGNtFNvK98SthRvLLezINeGhU09cYwrblILQtXG3sccY4Bdea4TlI7j2x4zWUJDMy5ozy2K5V/ev+sJydMgQ37IgrCQoJ5HUTuqeH0eG7c1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799810; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=ss51PCL4wPLTllRT5+2kCLycXbHqe9UGZco7OGSZnQA=; b=bUghMa/7UIWYEQmmLOVubHfkJl8T6Bf5q+jTA4LqkdYxbRI30f9uzUCqqo60AzJo7BXJ8tuydclsDpcVXKUikeA3e6KQ8Ay48aiRdLX13faGXs2U8QNZmn0mU1TseIABUqgMERhNxMiYGXVHE0vyd71KsRH3dclxjBG7+4iuTVM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799810900741.7072387722592; Mon, 7 Sep 2026 09:50:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cXn-0007ps-DG; Mon, 07 Sep 2026 12:50: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 1x3cXc-0007Xf-Kg for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:49:57 -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 1x3cXa-0004Dc-TT for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:49:56 -0400 Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-48444ec4fe2so2294059f8f.0 for ; Mon, 07 Sep 2026 09:49: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 ffacd0b85a97d-4859162f354sm22119673f8f.20.2026.09.07.09.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:49:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799792; x=1789404592; 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=HiDbY2UclXl1MJfs97z8z+BuPvbpuE3wlnQJC5v+7EJwWWFuXBwmB7GybfIEJzssPj tYvz/WKCEVMUh32tSdw+9kalwGvNZgZzk98h2qkyWHluwfvnyLbY4HtJlvOzcdFsd8ta rDYzQ33euAvPKmz7R8VeOdrZr/gKLyQ1zrN1o4d5vJivfj3lEEKSkkzjWy7g2kZfb4+z hmDz5v39CKQKvLRAWeXeW+4mKlEEO2AlzOxwViEpEaYKd3vQiAWbPKC/efz6/lxDp0dP UnBftugzewtWDm41DudVsqAglgsIKD6jkeoB/9p6oe/+QLja4I+RzQaqoc5Uo6kQINPj sZPA== X-Gm-Message-State: AFuF++m/+mfhlTlj9lheyM7Y4e2C+Z+hG+hUAqUXqXBCyvecFtPS7lMn uIFZ6dVM5lwDSxqzt9fkOOyX8Bz7pLqI9KnGEGIN+NNOnWikqkjzKfSBzwOiJ+z0 X-Gm-Gg: AYBFou3YPV7RrOwdS4uV+/LZtYVoRhqk1GEu0E2EEYKaFdMj/4lolpnJSm1FEmBALEC A0f/W2rCzQ0WGcn6DVgJIDU0jJiyWopkItKaUKLIQLW5NKDnPJQOIugLctRWntVSS51hBUVvSGg YNTKmHIteFpgHyrf0cr2rapAyLbvAvqYmBBleZAa8dbBxrSNYLuhtEKJyvFZ9/ZJKEEeT59lFmO a5ooqNyj9HrmmvzMe18hB5DVsyQ69YBTbOf4eOG5AhN7kKyV7F+WYGD8rPOyHm4jVtGc6c/X27n +4WW5CD4F7j4wWqjInYhU/ndTHTygGLMHgj4E5vMEH2rZSQ7LGFRp59t1jjW2qpBJ5slLblleyt CkeLT+etXlDvt94QxHC1zLDJiMLLoXrkdkyGc5HxjTGEN1TD85eiqUmdfe2OpL6NZa0PgAa01Gr W3jYv4ATCsZ6vIkPD3R3DTL50ZaLrdgVSueUesNUeinyoeg3BBdDx9aJRdA8ecFNFP25Kxn+Z+X PHclK5b7O8mxBFEdFB8PEVlV5krlE2shQs= X-Received: by 2002:adf:e181:0:b0:485:a09c:650d with SMTP id ffacd0b85a97d-485a09c6631mr9878753f8f.3.1788799792533; Mon, 07 Sep 2026 09:49:52 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:28 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-38-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799322; l=4916; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=jOC1vYeVhUY+5GdpU2iOwoUFRCa5a2ZvcAIYA/RAl8s=; b=9+FsYKZRQDfJws9BkfSBre0wsTFajref5BiQ0arxIRjxhpwR1gPkAaBG6udpQfJsbFFIFv7NF 12WRtqOZxlNDY/gR9+QjL6UP9lomWSSulG6IsU3PNvb7Jtcdy6Hls5h 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: 1788799813476154100 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 --- 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 Sat Sep 26 20:03:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799826; cv=none; d=zohomail.com; s=zohoarc; b=WTgX9m3BaNFgyYwOzpo7XFlt/B1oi1jr6lI8sGn6DYo6Sg6di8Vjk8z1oWhiZW1zHL+T5AQIAL4QU9kij6myYepOBA1nrrJ8L47pCwosQ0Ia9NlUhRBxUnz07IsxaUWkNTrNfBfcQ99isXzMke7d8f1VMDHSBT+2CVf95c2rlNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799826; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=7JIouwvsYhybUqJx3bKqTjTPWbvwF34ZaZVav4+/RP8=; b=bU/kDHU03tcTr9xu3X1gy/i66E1OIdEpkHpCa7JwlwwKfjx+nLPIUO3NzKtkpJ4grmkExoeyoDlXKY3A8OWZvrKWwnvChXUmJSqwm1zfSrezm0EjWA1wA11wbkwYNPqarGKhVkpP9acgW5uq2tQSTvZDg0f4P1OGNGM+1iEdSIk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799826825561.2290736262264; Mon, 7 Sep 2026 09:50:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cXs-0008Ho-NT; Mon, 07 Sep 2026 12:50: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 1x3cXo-0007xm-J7 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:50:08 -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 1x3cXm-0004QB-13 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:50:08 -0400 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-49b8687630fso32304185e9.3 for ; Mon, 07 Sep 2026 09:50: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 5b1f17b1804b1-49ce591f846sm200827645e9.1.2026.09.07.09.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:50:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799804; x=1789404604; 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=VvylwzgxnJ2VzyNi5LQp9i8SuCZ/xid9CxtohMyGWhHHgjF2tu10XgeqO16dK6aONx 3Pn2ORUXgSjYT3sjB8LNqtl2xi2c/3UhwNPRe+wSTHrh48RJ9m7KLRzFBx5JdgBI9Pet CDvxGm5kA6KAIV8PbqhG98e9RKRR8RfOm9hv1qH7tjU7k1IVnCx0tGAklJJ1IYzcUTp0 Hzd2Rm5RiRXpUi4dAUGyi5MMnebnsqCImp4+ZFrM84X+MfIQLUbHaie8QLeBUJpxy51T Si2EAgriRBTo7mM1sSqD+UTD32CQSC98LpeUag2v5sdsvJCrYU+qyws8CagsqVUbQ2uG 7V3A== X-Gm-Message-State: AFuF++ljkRcnZWBVYIO/FN0K1HRiMGKxvbvOXSdknM6SRG9JsGarGv5J 4+IxGS2oK3rhZjNbd8kdqy7Z2BGlocnLLemW7zo2mabamsUjD7N9jXgkk1KSDzt9 X-Gm-Gg: AYBFou3mhdi5OnnD0F7pqiNlJsY74xG14C7GkyTCmfdEl5+4TPtkXkAgs2DolS1Nual lIZq74c2YhB86yI4TyYmB7sgXc3ODVgatif+xucm7iQBloknHxUVCz/p7cl+PMYmCrzPAv6+wJm +944QqEpt1z2Xmssti1H5NmOY0WKT8aRFxU5brCs1ouTVcaDO63kWYvYSapdcTZ4x6/KGOgr2ZF PwiWvoKJulUmaXy1DvjUGqdZyYggs1XMZQRbp8+om+nyO8n0ApKA/39yY0LZyVzGGOni36++TKl BQPRO5HJwx68sA0D7t2gjiI5liMTHE3Sv4w4kABf4BkS7aRJF/OGx+gwhv+Q8lEQwfjnj+Ndhj8 XJhZ00XIJ1yRcLjdwSFg57f6aTbLwyb5Xc54ot9BFv9Dx6i1niLiFn+5w1SVZAtJXqZP1pQneuL S+tqn8NSIqyMvHAqTqOG4WvIfyVa9G+MQhGecMLGS+6h/trMGhAWwzPVh5d9rRcwbvs0XGhZi/P kL2LHVhQL5quTjd8U/Ig6Mux2TzZSbrGwa0jjbe1Wwytw== X-Received: by 2002:a05:600c:4515:b0:49c:c0d4:53d9 with SMTP id 5b1f17b1804b1-49cf8273002mr232397105e9.14.1788799804299; Mon, 07 Sep 2026 09:50:04 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:29 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-39-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799322; l=2259; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=GNmGo7bU7FZIBaUuYEeUYDpyrPaavNbXBkjimavlGKE=; b=Bxzff034JA32VQyuB9pyTahSx5144M/bWSmix9wX7PcRLpDcyyV78rP35YuNYlveXHJCxHQO3 Nz6cmtOhAaIAZcUOU3HGurJ+xKbriGP/o5JChoVHjOXKUKRJuLzqpFV 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: 1788799827115158500 Verify that without a calibration value the current and power registers read zero, whichever channels the mode converts. Signed-off-by: Emmanuel Blot --- 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 Sat Sep 26 20:03:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799829; cv=none; d=zohomail.com; s=zohoarc; b=MqqwKMuFyP5oxHra3fuELEQB29oQP//JJO7k541b2E1EMYDbmBgkdNxoxU/1fIewjn8eiu9BVDmQwJG+r2lOim12/Ui/1Kq2wy+cuqeFZxEOWY9SCSww1b6tVhKcEujiHcP5mlj38sZtIRsG/ADmRNrYN/32YcLD+tgAokkkSKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799829; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=CsX56+Vmqi1UCgoPxwgvzqpGLXWOqIZmtrOspUpbr54=; b=TBSfVdTx1kOlGdnOuHJcL+YzehBaywvSzv+HZn/9hjqyFJfyrbHbpXaE9cIILZvr40A6DK/u6MgQ4v+WMjY5nrshPbV7Lxz2Z22NaxcNAg3at2nSg8+W+0LjpSTUeD+XUpmNj60jANofLKfY8eZ7oGJmdInns70KKAa0f62uEQM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799829853347.9692784874061; Mon, 7 Sep 2026 09:50:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cY4-0000ib-Nu; Mon, 07 Sep 2026 12:50:24 -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 1x3cY2-0000XU-4y for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:50:22 -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 1x3cXx-0004Za-HV for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:50:21 -0400 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-49ccfae359fso33482315e9.3 for ; Mon, 07 Sep 2026 09:50:17 -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-49cf755c22esm323620115e9.0.2026.09.07.09.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:50:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799816; x=1789404616; 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=CsX56+Vmqi1UCgoPxwgvzqpGLXWOqIZmtrOspUpbr54=; b=YyT+BQuiSg3jYmjNfm+oXoemYMuH6bpzf+h0XCC+ymZwnYiQDd1i4q5NzRQlJIQu9y nCi/nCxDOUa354OM7/cRlHioDH84YW6jQR4V77vyPh+ZpolptkstUpC0Hh6q/27409lg 6NFwopBmBea+KOEh0Itgcu2Ff/Nusns2K2nT9SSpR0OBZgdP6cX1/TuHLtbWmnYO9LPx 81Q39JrAPqcDtA68G5cjS1o2EXAHe+3V7yFg8d9Z6HatFaEgIxh+Kt5uq+l1HHf7MmWz S9mT86Eg2X/ypxMVngYGUdB0Z3KA/vQDhpQVVxHLqvJPegIKErjzdO4+87IrgofNaRCm SZ5A== X-Gm-Message-State: AFuF++n140EtaihDt0GkxSop11qOWOcOIRVrQ8Oy3AfiLPHvlElHBjn5 XmvUE8h3TCt3PPtefSPta35OqtLaKxmjIqYQzfvVTaKcWdI+scSyHmQQeSBgoBmC X-Gm-Gg: AYBFou0oS3PWE7er4paKuogeORjcs3V9G7JhZ9SBx251H3Ilqb07UBiBatRyK6B7c8N 13t7zD37lb2nmJsk8OqLANN8I1JsXl7ffu3rZ6wgOQqWCtehsq8bAT1S9FAgBoI241aFlFOx2cP FdhoNLcnMLJpjyV1GdPlA1Vp8Ff0VR47c1Ms82ODlfrWo/Q8OGH1hDb+tVOvDtYEW/7icSqSH36 EHC+7E3sI5YLkMZefLmEGYC1uaNeq307ERm+TKzQtSdxQeevsw8M4XuX/oTqFNKO1/IkNNeBZhO nHcL0RIp4u7OZUKBs5L85lcBzXipx8thK+MaCZEk3ePTAnxSIOgJcf6OoVFoTUpJG8Wi5jWE6bu O3vusvdKt2oNQ8WswjHO+qtC1r1eqDYSwJNy09lUBPlvxwkZ6Os9F/J6AoFVlYMwLX/k2mzXNtv m4CMLa/EVxgQYveX6Z9kpoMiaWykbatGO1CG0HGAmfKPGYKF87JGDZlguBBFiIA6tgaGqfqRWgm zUysiCzfvnAuvedUiX5nUacZntGYJX4AGs= X-Received: by 2002:a05:600c:620e:b0:49c:fc6c:be19 with SMTP id 5b1f17b1804b1-49cff2078b8mr206968155e9.31.1788799815788; Mon, 07 Sep 2026 09:50:15 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:30 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-40-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799322; l=32726; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=mi3Z9pq+BoSyf01UBDutrhVRfCy03Gs19tHkGmyLaBU=; b=PjAfMgDbsOF15FgfkItTMhyhsoMvTkchlv7myDKyXdNnd/KNUMSJsjeQsifLQhBQRFoUbjPXP Rt+aaElwmn9BDE+2blkbQV6e2gAEwKz3G0wV0LVRqTnDwrD8M3XQGcy 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: 1788799831269158500 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 --- 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 1b33877d5c..97c97aeef8 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -539,6 +539,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 Sat Sep 26 20:03:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799840; cv=none; d=zohomail.com; s=zohoarc; b=CSI4u9P6uTxlrWy7DT8ImM8mwDBRkcAWxxISpImeXWfbW3j0M4hryR7wVD9Ac9cMWIGhDqCdP3iGiuAVxqNn4UZ6EUfFZpsbOQ6gd1VXNPNh4UXNgcQbyAjbQ93/PxspTzkxZLyGWrjvwTR9FSLyAfYQE8K9qTsY50q6bxD1HIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799840; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=Y4/EWXwVZHFeb0TeRF3loH9mbV6+hvbfIMyoc45VomA=; b=HGWE+ccXwMiWtZVCwhwZs9mknLZEW1s5unB/41OeXMM+DYLtoayjZzOo2WpPc1DsRKJYFW4/fbOsmIkUydEuWoQrzcvXQaflrlxIQoS1W6mCqiAwYFHF98c20/w9qMpWMA3Gfv9y1Kr0E0tDPduaASPx+bxydfX2PTXYJdX6w3k= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799840238584.29397856371; Mon, 7 Sep 2026 09:50:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cYE-0001P8-KQ; Mon, 07 Sep 2026 12:50: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 1x3cYC-0001HO-1f for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:50:32 -0400 Received: from mail-wm2-f12.google.com ([74.125.225.140]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cY8-0004e2-Ob for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:50:31 -0400 Received: by mail-wm2-f12.google.com with SMTP id 5b1f17b1804b1-49b912e2406so1843755e9.1 for ; Mon, 07 Sep 2026 09:50: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 ffacd0b85a97d-485883c81c3sm30056619f8f.26.2026.09.07.09.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:50:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799827; x=1789404627; 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=Y4/EWXwVZHFeb0TeRF3loH9mbV6+hvbfIMyoc45VomA=; b=ccofR/sHqnYteTqIqfDEAPjsvEkdP3nsY+C3IV8DQZ68TYLoyJNrvrmVgD6M6mUhAr vRUpgUskUJ86YyGShaOHXcMvb84FbJ60gr9jwyxirhXkO/BycvnMMm727FIGrKy5q5Dq cvcAT45Q9WozcT3oBjxGIJZhnA3q03jImQd4voCjbR3a1n4ZKbFfh3B9G9Sm7tK1WJAR fkmw2/DpvLF+RVnBilBcdrqjPbSiPrYuGxEVNuz+wPq6SJ0ynvn9ETaINaJK4euDCXos 4F4g/s8etQ+IX+YX5J2U3OIcYdxVKA5XbTCfQJ7M6bkhQMnIAaEnZEQEXldc8qjeHUEZ yxLw== X-Gm-Message-State: AFuF++nO67HdPZtZdODf/f3F1jNtkjlc2XKrpiEHf3oL9WBmELh5UosK wY//WuPrgXbUZEinbATMA+uX8eU7/5/5rSAXdv0WXPWDEzZnwPRZ9PKMpz1NR0pU X-Gm-Gg: AYBFou0FWqrZ+l3HYDhVlsyuY8L6hedhesmeINybUUgItq6/RUBQM95ls8jxKRwpN+j 4sl+QBKGr+h4hejciQEhgRzqhFwrV7cYnlkqCCaOcj4eyV4iJYIhxegHv8Ao3B0MGwahkvZ3Uid /la8cW6pdGn9zUcDpRCe2GqdCCAgW9j/mbqbW02n2tJAGM+TgdvZHGQD3KBN80mb1CTvCsqv95b Cbpa6vig5fH8bmAsgsnaIYoL9JDFp+JHWZvViyJ295U8cyrc0THKE8E3DmE7fLW1VHK8bX+x63S wWaLbo9rHVRPBsg+8gArBGvt/oQ1G0AmokpSHFwkDGa1CK3uwqxIrtPAv/NuCb3u4xuo6YBul+D G1iLmjPElwxj2LMBjVmabBSNoPhuMUpFft1XPZQ5B3TWrXv9sV+xrwiHuc4K9rEp9LCmZsqutlI Y1EirqKoEjtz3mtTj6RWpLRBaoXYhL8PoRA0xwO4h+Ro98aUJwuYrJe4oZA0D/5lYX7mWGMcHox k9lDO/51xD0ROIqgLBgnMy/9UqEzu8aixM= X-Received: by 2002:a05:600c:3b12:b0:49c:f13e:e50 with SMTP id 5b1f17b1804b1-49d1757e82emr22400645e9.13.1788799827059; Mon, 07 Sep 2026 09:50:27 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:31 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-41-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799322; l=7697; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=R7atkOfm5/+oNgxmz1EowDUDSQA0iEyPwZTQOrFjeQw=; b=YlNzAknN7XRB9BtjfG4UXir3DAHB08Vu8q1xMQetq4wSMkSwUr5PsO/hkU6TPVtZnHx9y1u5P Zw34wieqrpIBfsuJnig4KRl+2jl3a8enGUyUXyiG6R8738aqMx1rkYn 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=74.125.225.140; envelope-from=eblot.ml@gmail.com; helo=mail-wm2-f12.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: 1788799841277158500 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 --- 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 97480d92aa..e941d78194 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -325,6 +325,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 Sat Sep 26 20:03:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799854; cv=none; d=zohomail.com; s=zohoarc; b=IhWvkkhmwdtEVdZQhnf0UXU7mn4X+cYd4SkfV5n/PZlg4xWxVrvPpc/X7TFxGIh2pTSc9di8jxgSKNzKISk8c6fPON/SafUYw20aCY4O0cfmXKMdYjf8Xe+OYfY8vaHHvAoqUWaxsC7n5AusKT4+kGC9yTpG27ozDCVoifgfVwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799854; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=NhyqqnT6pOmjCgHy3cHsQQlI9jpPszBbMEh9VGPKhUI=; b=axVpo2dT6j55hbMyoXNSR+4zaChUA0voQP8m8K6VoRXDpuHVgpVU//gydIvHTc3AYM9Zf2WjJCRysKvdJxTZ7HHnjtRtdQ2Gtv7cGb32UyzRyU65BTyKbcsMkZqK3sA0wyGsmB6daHp8JtsfwCb5LqR/jMMXXylUTmpxzQkeyRk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799854417130.14301605460003; Mon, 7 Sep 2026 09:50:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cYU-0001tn-Ar; Mon, 07 Sep 2026 12:50:52 -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 1x3cYO-0001nQ-DB for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:50:44 -0400 Received: from mail-wm1-f46.google.com ([209.85.128.46]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cYK-0004gk-5g for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:50:43 -0400 Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-49b9320423cso42484815e9.0 for ; Mon, 07 Sep 2026 09:50: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 5b1f17b1804b1-49d0af538d0sm174747945e9.8.2026.09.07.09.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:50:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799838; x=1789404638; 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=GcKicbTWaM9ZaeHbQMxNftFq6wmTF5hX1fMMsY31Y2QqvTC/lp7ljiee7Ux5bTjlZ5 +/x2Ai5DYskuwjLxq5ysxcBtqd8k5M+eiz0wWRp/JEja9XFHbrUsbZDWvt6bqExbyKvC r3mdSg4PAPNMAvH/PxtohhTrhuw6LPWpLUgmjvtmwiVDHARfxFiqRcH2cyrxp8NeHM9N zw+50nThv0brLC6nLKJlg4vG9AO2IVsMaGNpwv0IxP+DReD/8/VaoreXGl/aYzwyimQw M2U/+3PxR0tkYrj0H3iwn8lN5hlJiwA0bsSVqgIWLwEOsgUVr/nEF0d7Xjy00701Fh5j eKfQ== X-Gm-Message-State: AFuF++kxCQK3gTs13ElC4DOV5vhiPR1rnQjajqJNs7fqQbLdkh4D5Ltn 5zyAnkLMVPAKWSSWguprDa1cjDjjTQ/P9MQyCi8PKAmwgrwjyhISnolVABUn4nlg X-Gm-Gg: AYBFou3EQUJf85THVhenhHrkIy2AkR+u+pCI9/JjcES43ZoQ1kzFCFuWg9lNqDAZgO/ h7NAqzq6qzQCnHn7JgzIkQ4suV0TOVAU89Cqpoy1NYypTsZ49ZXcL8cu/44yNW6Vz2vPzpMTdH2 0/pPZh4lEOTt3O8/UYgDOj5AOK48FuW1OWmvUDt5bYpmEAJyXmdAXxOaGVi7yjOTjNt5RDl/6Jw 5ePZcJrV/hDZFt3jtPcHaSH1+dMEVZNQ0bdTpUQ5KvKMbMCmDhT4xSsi736cxZexzjoUGM33G0x fxLxq9m9U8cRhqUNCf+q6cQttde2Y48pT6EOxLuLtLr9yjA1g+KXOUbZC6GWI0LHLKDNBvAHdVs vmdF6DCWVzAWHAqN1Vv5tmKtljnjhOxN+6MUOB0W1kO4vzjR+LkpU4jkQbwqRjhGEFIOuTAVx0n YFr71F7p72v9fu6xXkwmUNPX+c5EQZKT6/4/XQNYvyzfv9072VzvCbzG9r39c/K5EDZjmI6wGCY Gt+AztCZjVhLTX6KlB2dbZZqkBt8sAfmvFd X-Received: by 2002:a05:600c:3f12:b0:49c:c8de:96a9 with SMTP id 5b1f17b1804b1-49cf7fdd2dfmr473701035e9.2.1788799838374; Mon, 07 Sep 2026 09:50:38 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:32 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-42-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799322; l=6961; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=egEW5taK1N7S1o1f0z7+qaFgBpk2txeW9L73zPjwY8M=; b=pKmHU+eGK/jPlh1kRrfCsWOUteWLVCM/gW+bPIWM3cvG4RaZhrV7MB7qwKa/DmaYZK+UZ96K9 tZVFYXVuZtIC25gRviIqsor42gTWC1F6hfmoL4moKgTUOUXTFLkhRZQ 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.46; envelope-from=eblot.ml@gmail.com; helo=mail-wm1-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: 1788799855278158500 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 --- 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 Sat Sep 26 20:03:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799873; cv=none; d=zohomail.com; s=zohoarc; b=ZtdbOoDVQ2ncjDPSNuUot/7c011DO15pgN0nHMTNd30O79jz2835tDrqs6XLMEG1zatxvSF/mPjwcG36n5dxQGm5Gk1Twp0IKqhcm5B2jzykKSbJuo3STzk+8LteH/gG7SyjDMRm5OAtYPR739JqfxuENaODDKc49hJxICifEIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799873; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=3XplpicYtnjwg/F/PhuqE/con32vEXnk067HsKJkOiY=; b=LKmR3cNzzyfPZKiXw/h8ouVi/X+LVba1xAH2zyr3IRg8FBRddqM2BUI0G2gtHlVB3PnNIV+KdCc92cr97M7GNamaWTxOi+UTKq93Xe8FLts6/+h4eFK8otS1So6HJ47PMyu72VBjCKOj4yynLGMDxkiJmX5FDfq1Miy2KYx5qos= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799873862440.4438717994799; Mon, 7 Sep 2026 09:51:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cYk-0002LL-Tw; Mon, 07 Sep 2026 12:51: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 1x3cYY-00025R-U1 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:50:56 -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 1x3cYV-0004jB-M1 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:50:53 -0400 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-49b9320423cso42486555e9.0 for ; Mon, 07 Sep 2026 09:50: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-49cee7febb4sm442093055e9.14.2026.09.07.09.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:50:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799850; x=1789404650; 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=TQcp/6y0994RXuEAagwMBxHp6D2yKwxqHJ2PriVxh+LcvAEqduxJNyZcOrn2nKX7C7 0NJVRZAnW5jJDRgLaILEHnTHaNcoMBGgOm2VseUzEdvG/azjW0CTk+1AAijVVbshp3Ps ktbDChNvCIcjfIx2ZzBcFKTp1T2RJQJHu6V4l4DTqcT+cw2uFN9al6i5zy3ufBH7VuUo TKWoIbFzs9Nk74I1lZoJD3pslQFBJNZbf0iNHKyMuBDwrtEQ4NW0jjA8eegHGISBiX9k XdngJi/aZuk0/Xmb080WBjaqzI5shDEE9xKk+kNzu95aQTlU/rjHkWCaxIWJ3fhZO2bk aJZg== X-Gm-Message-State: AFuF++lNTM45pU/04zdQURIOStNliBXzyh6p4kxJieJMAq4dQT65lKmS 1Uedb2UiH2SXzoO0QoHqEJz2EQXZLLX48tQMdRSpi6UzCVfQxifNeAOPRvYlEllX X-Gm-Gg: AYBFou0r3a8aoZI+WH+wWGHTXd1gPkX/z2Yc7OSBJZ42sbvmy6LJZWoKFSJVOaRCUBX YjWOgb7al8InAqu1u2g6N6jKQXZDln3g0M3TVXvvEoG8HFTCy19WlQ3BSpSd8KY77kIGkgXLQK6 uhnmfLz/sep0faHMlAaJozz3CNeTaLzCZuzTGskWZFpdwKC97ZZwI3evX7RXQKqJcWpV+lsQfXc sd+CmTw/biaDWBmZlxnSdfVv1/S4T40SpwVcYJzNPLSEQzpVKV0xS9Whr6lCg+oTIr+S6oBF3O0 9GR+V0oX1IbbI67XhtlHJGuUTER+GBZmKvtsq0+I7DdH3rdVivV53O3pILZ+4NyBMTwW7a7YsRD scJXJvR0UAEaff+zCxkeKM+y7mkUh1IxqnEF0ydyt9TRHLega5aRZDVkHzB2J8d5z9siuOYfe+b 1KxzBjbWF2O92b8DrBhWP538SefUTfA6zF68Zang+uz4dTeZcqVFMT3ycroh4Z/rk3ictecx6FM /XvitupEbg6aSu7lq8Z1x5phHYn2qyyK58= X-Received: by 2002:a05:600c:1990:b0:49c:f512:2361 with SMTP id 5b1f17b1804b1-49cf82524a2mr357973325e9.14.1788799849739; Mon, 07 Sep 2026 09:50:49 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:33 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-43-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799322; l=6665; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=in5M3OrP79f45k7Uk1wA7KrYQ9pr2rECNsyuX2iK4go=; b=B+e8ojfnwrt/igqDSazatqwnBaFePSaAXueJchYjWo5SgCcH8zRSfCKv3dKYYoDNMKRL0W/BY F2ACU+Vx0H6CFQGaB+fkfSxuIWVfbN2eRPRx4C5kLKpE4G7H37USwQO 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: 1788799876429154100 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 --- 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 Sat Sep 26 20:03:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799898; cv=none; d=zohomail.com; s=zohoarc; b=POYXn0MatZdWKhPEvdTQo+TRwVe02TDuRh04aXqVRZfVeirDLUNp/qPHDVX74IrJUkxNF35H72ghQTRgExGPLA1hKfjB1WURjTUUKwsquW7kZECYs0biVdgM2oLAIRFdcQUomvhXfkGnLhUorfVeiLuC2dyko6ku8gQTgFjju80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799898; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=Fhp3wv+1ffAiyOIOMf1hqrOLyXTWHsYqm0QrDErev70=; b=P3Q8o5f7kYIn2PtgqA9i1c1H4L3wA61xQJsQXkOVJBF/GyLsgrUDQOuaQT7LzOVklngd0cLLRKLPwBFAjlP1bw7qYikhW2mKEvpOZqPEOW0J7OTShcJSQzniL3OstphFJWWjcNxzZJB5wMdVWZn+2hSBk+srRFZWvdoD7ciHqcc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799898772815.2913973553349; Mon, 7 Sep 2026 09:51:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cYm-0002Us-E4; Mon, 07 Sep 2026 12:51: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 1x3cYi-0002FA-Em for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:51:05 -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 1x3cYg-0004lf-Ht for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:51:04 -0400 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-49557167508so45566515e9.1 for ; Mon, 07 Sep 2026 09:51: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 5b1f17b1804b1-49cee6023edsm395323705e9.7.2026.09.07.09.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:51:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799861; x=1789404661; 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=l67D6hCYmIfV2Z8xLsO033pONJXa1peN5KkZbofINV6dik3w84gE7CLV8R3G7Rlthw 6bhi1OZZ2olv/I5uKBReLf99kwraZgLLGXLPf1ZrXYf5cnkEsRUBIqlDGEJAsmBVfJrF 6h4MhONZ7eoXzgB5bLRaYjDemsyHtpUuRzU784J1v4VfnG+HkcZ6WW91trFyZKEcRhul dMIQaB8R3pN94UxR0oor72R8o12dg92hHYVJFbjK0Kbnt53W+PikRDbSDMuekK7FOYRP NZMNtMgVLUjBqKI+d5r7D5j/K8kuGZ0XbizbySryQ3sB1MA63QfCkj47tO5estEk3gDs ek8g== X-Gm-Message-State: AFuF++kANG1f9CFRZcozl9JhCCCeuzpgxCyjuMpKd4zzLy1pzk0GM43g 9j19kz+haJo5k4PZKzBQlTQZw1Z1SRHg07y14jVBnjYjCW06CP04bcnWSl+wWA6o X-Gm-Gg: AYBFou2BsU8rjQ/HUoIZ9RWEF1hBVZaEBw+1seG6mOGv/U7BUnp+wp6FnRgeeyNce3U ArOED/glfGZXs3e993RmE5dHSCsM3jDYP2fH73d8LyjvDM1TCfbQct98n9mBr7TnpydFodSo5/H zIPrYHJnhMAbR7JwNBuGuy8ZRYZOD/mC4rRtIn+NfNYLrvoP2q5dTTRBq4+whO96xi+gBgczSXI znRP+eVPG5GCqSliB3IandBkHu65Wski9/WC4fxwOE+tgWGVaddLHVtzlLaw9TwxuODTtc542M4 SBaKZDdK4UgLKkUp2KnkyjREOkFdcRrJkJPMGvrbd41YV5RK7SSmZc/rAWiv1Lk4hfB3o/Ga8vL tXe6DfmFFw2k62+LaCzCyZ8cWPEss2tGFK5KLi3aIld0p6AjYsRl2TxHDtT0DP+/bQcsDE/FCof 60lnEPvoioOr+B78Q+svwqrL/nciiV4067OlPr4fEX4qSp3FSi16ZjD3ms+o+uUDRsf39w4L4tR 4ZNRmXjlvFMluhgVDc0NCdT96LK2+F0Abc= X-Received: by 2002:a05:600c:8b6d:b0:499:a277:e8b5 with SMTP id 5b1f17b1804b1-49cf7fdd67emr472184325e9.3.1788799860933; Mon, 07 Sep 2026 09:51:00 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:34 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-44-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799322; l=5321; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=JgwMXMS8XORDALoqQbGBJ4suPCUY8Bpl7Mu6Xt66s/I=; b=ghdomYm5NbgxW+l57AwahoI9RVFSmUDme67jUzTWHLJzgUwbqOm45fAOnxeMz/Ja9IjJJ1O9w kSJl1kETiLUDXT92RbEcfoxMFK1LF+oMprgCFvcfRfUj4ytZ8rw9asR 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: 1788799900813154101 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 --- 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 Sat Sep 26 20:03:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799912; cv=none; d=zohomail.com; s=zohoarc; b=G9lmiDxcBukI0uFjwlP3KCu1Jf5sK3PMYseYaJJqRhfDgwiAIeoRylY2L0t99EDlBO8+VKlCXevugI/tv5e3XjweIsQN2uFMv01kuh9SVrhV4qsd38Ag8X/WeQvtx/++AKF5uEZxs9skKgsiXRClJCk3rshb76IPZdpbNwlsmaU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799912; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=RR0BfuP3zH0vPwsVTweTuUz+ywrZng5C/2ivP+6b+uc=; b=S5MjqeK+STiXKphFig2aM3GXstFCybWIbUjM2hKmn3jbjCoeCK2CgVS78yEZJnhAcVxNEHOMfKYtP0J4uAx7BSP8wt9lAukRNpbV0GlfFOV+Vmq0u5dGOcE8J6atEvCjS+iZ+ojrGjAak4n92ydi0ptJMZV8xSLngqM6mYnfyRU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178879991250787.25981951495623; Mon, 7 Sep 2026 09:51:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cZA-00032W-Ul; Mon, 07 Sep 2026 12:51:33 -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 1x3cYu-0002nE-Pu for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:51:19 -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 1x3cYr-0004n0-Nc for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:51:16 -0400 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-49b9320423cso42490005e9.0 for ; Mon, 07 Sep 2026 09:51:13 -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-49cff8195ffsm269970415e9.14.2026.09.07.09.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:51:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799872; x=1789404672; 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=o32J6P/7Z+MoT7UfAOUaU18me+kVm5cMfL/Xkq4ivMbsLiXllBQJ69NfB8BFNaajpz if/baRWOzaUHAxQVgkwJTrgPx43fFr1h1jNKI+QJdKetQ76Ph8V/UPfM3wmbQs9tElRi Rp115gycvt9ultJ0EBdE24uNlxlkWjyV3Faz4nRdP0d5ooJIITTvtzlqtI5PgRSx5z31 moDYitni+HotcnD3TlUd6g5kBTvgZnQve6s5RdpJyfYnjt5f10wUnW3eLN3pNQU058BU NP1Q/xbmHv5SZKOfq/VR7hl+Lu7s3o0SlcZ4i9gMtm7EcvRYYPpAF6C4+xqKpDXWkI9g pAiA== X-Gm-Message-State: AFuF++lwvNTS6+JrmIrKBZ5LFeZecOhmChterxPFH/bmbC9rWWpAQl/p hOCKWbgt/a4+tjWNkilPYbsvUXXWn8EObokIEnO9xC/VZA1acQXNf/9vgLPqLh+B X-Gm-Gg: AYBFou04vd+GAq/LSy4KxJObCQv9Zpnbixsqa0rlTgtBs0VP6GHtKGSXk8n7yUwOWTd NoieM/to6FPIG0mIGq4j7ZpI8WDdidAr3ZZ8saaLnJVqxwGNP675eejV/S5MMtZl713hbeT1F5Z tXm2PROXHXPet1WquljCZoUTUwtHszPqultJP+9ePPzmiMXh3r7HYJH6jg/sbnRto88N7uy2tqa YUWP4iyaEh+d0OLLDBwMzFMRVIrtTGzxd2+gMe+Wcz0F0uKVYwgjpBscBJ3WVL9ap4CmAkW8LXH nJUiSyJPzlES/SYnnM25BXNT7W59lyTLzC6W9qF6+Ubek7FU46UQcw+leEpzVkn68fgjE2XY3ZA cgCHotU0dL83GEhvwkB54q0Tu21RmsVL2D88A2D4wLa4KSlSGzPAOnexk3LOkH/bllMQwNKpSUI BH8Kbiq+TDa0uddA9iD/1k33EtNa9q4ea0Qm3SCXvRzCQsXKEzwiHWrJUXg9p4DqYEup4DF+9bm LCPc3MpW+w+bcZ/6X1cJap25UOKopx+62ZIVds0txFQtw== X-Received: by 2002:a05:600c:6306:b0:49c:f5c0:aa76 with SMTP id 5b1f17b1804b1-49cf81e366amr585455995e9.5.1788799872044; Mon, 07 Sep 2026 09:51:12 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:35 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-45-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799323; l=4308; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=lzxHz2iTzcTzaY4NX8qYKf/WE7cfp3wqr3BkHmJe9dY=; b=1RzTCsOE0t6uStkKjl1WTxt5fZYdByATy0W6tYxQbJIghBnxFA+je62n4cs3cC3Avh5Ktu76l aJvz9mtokUBCQ/Oma5f4IoGYpSQqeI6u9xJEEaqQn4ufvofrihRtnsS 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: 1788799913114154100 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 --- 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 Sat Sep 26 20:03:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799899; cv=none; d=zohomail.com; s=zohoarc; b=KeWm98NXTGXht8d18rDowV6V8uwH76mSVWHN/RDtSlWnGWtUYamUUPxD+VhJ5798OGPfmuzBHWx6AZARSYg39/6p4gpku+N2oSu1yZpWAsFdJvR8Sbajc+hQW6r0GaTgbjQiPMHgLab/WqS9VYXeYnu3FMZlx04aISxk6Pt3wYs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799899; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=YTjYUeqnG0FlRaXGHN4hD5QBCzdcaj4DW5tltJJmmu4=; b=HSkLAWTaFV9/PBNlTh0RfpvX8+kVnCUV2soQJlzbTzStKoG2L2ST8p8NzFvBfJZQKSzJTDOtxtLGO74X48g0boinUI2uRC4CohPTF+HtZLv6ZxV3qQGUMNNcVWWERzl+Eq54mPoiPJT0+PB569nMhH2nFPqJdZme1pwvIvZROjA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799899346661.6285948256285; Mon, 7 Sep 2026 09:51:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cZD-0003Ep-Tb; Mon, 07 Sep 2026 12:51:35 -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 1x3cZ7-0002vK-Hk for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:51:31 -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 1x3cZ3-0004oD-R7 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:51:29 -0400 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-482e4998d28so2995117f8f.2 for ; Mon, 07 Sep 2026 09:51: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 ffacd0b85a97d-485883c074asm28991228f8f.23.2026.09.07.09.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:51:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799883; x=1789404683; 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=sg4uLfnHpXLNG8urgbmo7A+INQyK5IZDJ5Q1wpBatxANkjxIjj75NkT6hOucQH79EU fDc4QAb4NwNJ+nNyBcm1k0EfH0EQsRpzmIlCeN+4hhvN2m70bKJcnWIdikj4xAX5z0eu OPRbVUeUdgqU8rS6XRPrv2Pef4k5liNJzf8dtVVXpn2VgOMKz7bYp4qtDgVNAM7p2OG3 NDvCaG+xC7lQfOOTlIlfC3HUc0WmOKxmwMUD1Jsbz0lhw/jM/UbI1EHrcDherDNIPosx mtgZXX5jJ1bOMX2sjEFdOoar+giQiS/5bZO1cMwilsm3YzD6rsPQOjwFS3ny0VR/w05u TY9A== X-Gm-Message-State: AFuF++n4LmlpmjAqsK4829S1KVGn5ussDvCqEHp/Psi4HtHjJpl6df7w ilP02KXVSy1rfDgUojOxvbQlIkC6XbRB8mnU6zliKnHoCg6Z4kQbuVYzuw82Yl4n X-Gm-Gg: AYBFou0JTqQ0reM9OrIx3irgNEnuDWE0NAoUv4h+1XHdm7aNZ0P/rbzHYKJg85cSSr9 Z2UN0Cm2t8onQYxbEcnFw1L18owSDlvjWvZ/sIi+dRo2xm0CG8XPhGNidWzmiDFnmmLLdvZ9M98 9d7aXYvKeDTDEJ5WwaAdn8XVm8wKPvm18PKRh0c5b9+OJ+aNYid8cVFlV67e+fOg+e9ODomgj0Q 6ltKJ/DJYwF38SekFt/fs9xaZ8VNHhfTb4iSIi/Vdx/McM4B88CiyxN1bZBf5Bl1JFNzor17jll k+18KTN7zjterCyv0TMMql68DF8OVUCXDEiuW/dpKRV3NiX3ftD0HuBcr6sskkcGXqY6M7wpwyo MtXyVB3Pk5+6DOaSutbY9nCXLegTJ4mGm67EMz8c8Qr03s7Tg0PAMwrmseV06Kv/oJdVSpcmI5l qEv+5MZHSRqvrmH1EJRsVy6q2N3k2YO6bDoK4Xx372MRR5VZ5X75gJ9v+xvZVeJemglM70FRFRY 3kCAmhhAeKfqUUPXJv1ihVmRR+/BAalyvs= X-Received: by 2002:a5d:4691:0:b0:484:3326:983b with SMTP id ffacd0b85a97d-485872eb42amr22386299f8f.26.1788799883246; Mon, 07 Sep 2026 09:51:23 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:36 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-46-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799323; l=6797; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=MyS/xSNcSv5LSSPZg2ndQf9zSlLfmLoiztp1hbYzpOs=; b=gvP8LUtkbNgevtM2ebL+KYBuUtOe9okNxHqfSUP+J9oSVnGhlUm6Tq/u77rqcFEAAuFxnLAYt FoBXEO566oNA9GxF0djFU+2bbwU7YpvoksL3/MRqgloVaNDDjCaHCiR 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: 1788799901752158500 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 --- 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 Sat Sep 26 20:03:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799931; cv=none; d=zohomail.com; s=zohoarc; b=SLAzQ08TRL/0JOxrK+k5SogjLabMXzAM37qZi7TjKROLOKGAf08yUbuw2P6HzAs+rp5YQDb63VIuKXp7zJRror/2mKuwmnOTk1fLEYq88GNVKf6br2byzsKvl4SaK57zNPD5Co9xfKEra/budGIJIzQUt2O0uwLAXhpzLBhKR/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799931; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=DtmNqWBTeMCh3h6zcOOCMvs2LhtYSQ9Lz7AsIV3ilrU=; b=ZJHk1dUiRghUGi96rezJvqVRCJ1x6fTqeM8ql/jDlp0CL0VrVoitzQjsTuHDSAY/3VMmRi+MzSaEhFQrT0m0khKP9gFVybgzGWDF3XfI0rbz51XHeCOu0Z3OMvqVRoL2DWmVMGGOWjLloNSyP5nmmG5DxO5sM9GXDIlLYTP0Pkk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799931744545.4581832077066; Mon, 7 Sep 2026 09:52:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cZI-0003YB-Rt; Mon, 07 Sep 2026 12:51: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 1x3cZH-0003RX-1T for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:51:39 -0400 Received: from mail-wr1-f43.google.com ([209.85.221.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x3cZE-0004qu-FK for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:51:38 -0400 Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-4858595f997so2249992f8f.1 for ; Mon, 07 Sep 2026 09:51:35 -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-485885be01bsm29121377f8f.31.2026.09.07.09.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:51:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799895; x=1789404695; 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=f1l2zxIExA97sAj8YhAJr+gDyBBoHs8PzuITkT6JKwcZm/5f/kgLYNE9/+20r4mUBj sIRXtoPm8HkcJtwyUY2KPeGFn+wpLfGmGCeNC3TBrnPmYb2JqXidNPCU3+M4/QoGsrzZ cskZ430qXjiyu8DC/VHD3ah7onbB97q4hEXt49k/2dlzwF4ROtYeVKAViIvHtLX7c4mN b4iFW5wIjUsHLUaZMp7FaEpfU6Jr0x3xjTWR9rNBPLh7iCVHAHPGFzgcW6j8UACkVL8K 7/Z+rsxjYz5RNgUtNTzAjtzjdxUegdX5yLblo7ywM8LQx0mBAeuX7lCOAT04jFzgNu5s 3Kkg== X-Gm-Message-State: AFuF++mrynU6sR8OTGHmF9vxJ6tcYFygbrdAo0OsomWn2VTbboWimo/S 6gnLaklmGY4t1VLwx4UWY2P5bOqgR7Kd2jEa2r+Ebk3ZwzE2iP0db6VNumI/arx5 X-Gm-Gg: AYBFou0nWT5YS03s16H5sVobFLcEXxeLrTR9bP99ttvy8cFXjBVU42qcFgvsZqwNd/w 1qvKvaTngSsWKdU2QrIpcwQjiOC4Go94eZOHway9wCKy9eEdBAKntknAVXrU1ZiPqVSrlLujrzf otPohQorGigMtPE6PT7f5l3S5o/bXIOhaDvVfZ6KYshB/KgKn3HeMCXBwrQGcqmBTCLisSVvmPC ToI8ha3zF6GygpHLsU8MrjkVJdJAkWYwjw15NEqQzf5ZmTbknEQ2GIApsB04Uo++6o2oTFezz4h FD9QVFtaXFRRadkP5fJox+PoT7V7SuwikgD1oOgLTpmVTS4NEkYbLkl7exsAaQ35iH8ItxH6eiK sqMaJmt3t4swpyHZUQnCWnZRbFVu8KOrtCUnOyZRHQitT9aVl5KHtbHVchqdjryZCLZjRV/1Z7v uyOqrbjohGj/AXIUSEr1f+DKbjESUJYx0XkXun2KSOn31IxqCgGRR105zP2LsIGc7mhjfmUzM6d uRNI8+Qk+8/VyFL/rXxjvypt7zZ5LWdaxEIT6THhYZuNg== X-Received: by 2002:a05:6000:420d:b0:485:8ebb:be1a with SMTP id ffacd0b85a97d-4858ebbbee4mr38478081f8f.4.1788799894826; Mon, 07 Sep 2026 09:51:34 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:37 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-47-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799323; l=4048; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=AlHMNosYKAAxMErgMhv2dpLo39gC6fRYeKA3EA+XnDY=; b=9jMjyF1vTEa5RILmDYgIclOjBKMBT9aCUyeIXq/7z7Nt+zkUT4dWfOhr0tKSIsHd9IhFprHWu t50AXocteDlC7wXXhnMvgDjMbMwj8cWV4SBP3Nw5/B6YoMyAwYvN+/J 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.43; envelope-from=eblot.ml@gmail.com; helo=mail-wr1-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: 1788799933339154100 Verify that without a calibration value the current and power registers read zero, whichever channels the mode converts. Signed-off-by: Emmanuel Blot --- 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 Sat Sep 26 20:03:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799944; cv=none; d=zohomail.com; s=zohoarc; b=LFAv1kvA636U3qBLfgGrGKu3f698IYQs5PE86jadp1BDI8I512bPnNNK7fUd5zxq5VPqXPwh7rZ7MsoYO10CPMZZCLm0/ghaBkv+oxOxMBLW2kU5DLlv689eNdxAp5yB6OeaHGaaP6a6HGRq1n1BFyB0txANoCi8BqCgK10P8ck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799944; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=VYtwdu+iAzlSnT+kltxxhoebaYC0ndIhQT1w/+MKITs=; b=TRIZUGfrWm0qCQDaPOmyZ837YPUTp2S28xXe8LLTJKNprtVZB0BDYGJc6I/7/ZlAiNIezqtQq/7FPL/nl1O+n2G7zwXr7NSqCRtCCLGT4l0kj6Zy6mUS75GqUOu3ys+Rd3eaeJsx8PsHJ5gAYicWzo13lQ7lY4ri535eyoCtHzI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799944811667.8254330318437; Mon, 7 Sep 2026 09:52:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cZV-0004Dm-8j; Mon, 07 Sep 2026 12:51: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 1x3cZT-00048U-7k for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:51:51 -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 1x3cZQ-0004uY-RM for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:51:50 -0400 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-49b0dd3c9a0so36218535e9.1 for ; Mon, 07 Sep 2026 09:51:48 -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-49ce5941cb6sm10681485e9.4.2026.09.07.09.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:51:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799907; x=1789404707; 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=VYtwdu+iAzlSnT+kltxxhoebaYC0ndIhQT1w/+MKITs=; b=iC4rKXeI9tdMpfGY1yWOJ7IlKT2mtF8Bzjiu+LxzexC6qAukX8GwNBoDWJp40dLyQb HV+zo8yvapg6vmPLjOsptf/vFVmUSOOxsx3pPANxR4hnMxzaoyCZ/UH7Oaz5ZpZmDX+6 /cEr3J/cSqB5zeV1QqPkpEzqcrFqQ6YBu9tPWAO0l6G0NyHXvhUgSBaP7w4AdJ/0WsMz PoQMFJwSSm8B1OkyUv5Op1SRi8Aq08W6MfJfSpi6ue8gDjzcutK85lHjZ6Y7YbCwNT3r UCChIx5Im8ViHJtbNaWyldxIVDKcRRGFk7UqeCE9R1Ns6ytf4PMDOAyMpNw4h2RPgvQN SY+w== X-Gm-Message-State: AFuF++nCEP3jgUMF24CTAEBAbIcpzCADqO3elTfAXPkHZ5C9QdSyDlQa GJL6Z+Wij/f96UEJ91gnu+4bv3H3GKq4eKrwBM2lgCGUUkPIW+K4zMd7oibf0ERW X-Gm-Gg: AYBFou3zUuWz6OPINK/Na66M7u+JePdfXYFtmASEAE62J+XT7/QTem+AATURHUbaE0Y OIMB71P3kseVi4LPiPcumb6shmEAaYJOa2ThKc56Ku3t6bEDM6JJ8lYq3bFeIrgVyjNqfSlwM73 yxx9po1fxdWz6HLRs49VxQfjaeutluLGRZtz2MROzIA9+R6yLZic4FRvzELjdLdpGurY0wtrFDC 58emZA+kKwJaf/KPN0ZD1wdhscvjoWns+3IrgiK65VP7ZLTDJy/+R+u35QrWLqk2e48YhwpqwCO OF369HAWaLZmW32uLRyxoH/+yio5FzXFtrOeHV12Aqr2LdwM/A3WkLBYtfLWeE202dOWiTR+n0H kOyPT9w/yYqronptny7CoRUMRHPhjFmEWr3Et6nlZgcojvDE6A8+fvD9LGxnAwf1OlxXqzoRWhx J9jcJ19pGSkOYbkcCmpAaGdh4BOy2xK+H+BYeBkErrZ/B9lKT9+j4eT5Tn48lhhDUn3jAdQqv5L 9hh8K6QW9wdI1+sl5S7vfV6LQiC62f+51E= X-Received: by 2002:a05:600c:a0a:b0:49c:e1f1:3dd5 with SMTP id 5b1f17b1804b1-49cf81e6cebmr426491745e9.4.1788799907031; Mon, 07 Sep 2026 09:51:47 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:38 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-48-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799323; l=8445; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=SuA19+UGy6VZCCoo+Ren2gC1nGBpn0m+kERq/zpGHHc=; b=Nmidngi9VdnWXLBe/+f+r+iEaXi3AkjMY56Cc19h/ZJYoDUEwU+jRC4bFYUh2yeguK26jmvPR 2fmQEV0+f5YDh9XrR976w8j9tgfSq6mVKkLvDt1Hml3Szowo1bLryO+ 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: 1788799945844154100 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..1f46ac7d58 --- /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 ASPEED_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 Sat Sep 26 20:03:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799946; cv=none; d=zohomail.com; s=zohoarc; b=UBb5Hr9XqGx5NhOQHbZIfiWDMlyvdimkcTCmLzUnN6xYoTEEkvOpMsDms3H1yuWSIPsMYvdBBwOBqNVUH5yGTVYvyCIMuJt1l7OZvfSqzzIr/SrGZkLWr8s0oCTMKuCb3TAdGcQ6uBJIFQvSPRvN2t8T8RJarBrHElE6riCkxUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799946; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=0wJPbI+k35n6/DOUs6vi+9KuWK1ootUizf9sT+QKOSE=; b=PFPjbEufPKbTUGqaDty6GRab7nfCVoBb/A+H9S4O5UakHGK365mquUpDSlNyDJZHzCSxb2JJKpYFzkN6qRyLs3N+VJtniykR13Z04GIlaWoo845EKb4DeenB9SFY4D8/joeozpKnLIGe4RHOJ+BdYqOGBxtv6t8l84ey9iQh2kk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178879994666015.409706837357817; Mon, 7 Sep 2026 09:52:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3cZx-00054N-Ha; Mon, 07 Sep 2026 12:52: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 1x3cZj-0004xU-Hk for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:52:07 -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 1x3cZc-0004wh-CU for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:52:06 -0400 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-49b9320423cso42495625e9.0 for ; Mon, 07 Sep 2026 09:51:59 -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-485883c074asm28994221f8f.23.2026.09.07.09.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:51:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799919; x=1789404719; 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=0wJPbI+k35n6/DOUs6vi+9KuWK1ootUizf9sT+QKOSE=; b=LaGNjJazktGw8I/nq25s1DYQO+q0bpcK/znqP+Yesix/Jd8cemrctGU+Gbu0gEGr8F lRkgFdqAop3BMkwu6buTAx5AnyAzzNwi6Kb+fplVfp/4GN8BHqy5Dd74zTxCiXOIWujY ywA4/7Q3GynM1OFu+SJYudUmPVhmI2JopRFdM3/n2hluQ4OEiBtv5YHcRueNgj8sgwK5 WMORFzhRUqeb6lx85OkK+732PZWEvxBhJ3n21OtuEHaOxPGkWPUwq/YTo5BEHn9jtu3D t8KD1ieKx+6EgQwjxbs97SX35gttdXCG4QJ9VqpfEQ5eaBFDrB17sWFIc0WwFzyn+ZnO IOQQ== X-Gm-Message-State: AFuF++lOf/f/GbA0VSLdDJb/EVmHRVe8NOJoZvIgLhCKPFRSWGLtG6DJ 32ePT6tUJsz7x7zMBHtman9mlGMRbWGbiccWf/LJG2AIqQiMPw7d81GkpahKUQ0Q X-Gm-Gg: AYBFou0OM91EA6wpY1XoObJjRIq/f9MWJtaosExElvR9zYajr6n6vPlB6NfnVEq0bVi jjl56/65yaOaKp+ImQ7OyN+R5KWYD6PVQSU8FyZCq1C/Rxilz8avI7AcaXxMzl3MhPkPclu2cE/ LOylrOxBqJLC918YQVMr0mmcRQnHFKh5IoYXacjtvAo7/qYi6kgN/qjrk3vmcPJrSZkVwkAGIG5 bG1mlWin8UqKMfFmRvQd/Uc2vGqH2L9IRX6NoDp727uzbp7rRM6weha7I7URGo1s0KGbMXrQMwN B8E0kN6Xt+FH1WbnkUWedGghxXKM/OG2KKH2ny/Tv+1h4TVRB9J0aslpVlBld9Zm6BD82ALBSFy bTBjwkUEDetTR3c8r4O2TSJimjv0uYjTsoyiDGC8gZjHCPIPLxD+d1u/3lR9FHkoFRlyytLg+DL rkb+cH3DSpykTDzAoGdHkxhydMd1jB6DshZ6emaqpPO0GeD6VXWLe9U7cR5JC72BBUXsh0BFX1d JL7JKBaMMdYxc3uwW0DlkT8VX8yizchXQ4= X-Received: by 2002:a05:600c:3f12:b0:49c:c8de:96a9 with SMTP id 5b1f17b1804b1-49cf7fdd2dfmr473863415e9.2.1788799918475; Mon, 07 Sep 2026 09:51:58 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:39 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-49-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799323; l=48657; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=ZA7RqATqug+n1lIbVHGeBAxD+AGJnt97GsZYWyrasM0=; b=AucNKrXlq+D4grKuBoi2ZMvCTbwb1aTejdJ6fhFcqTJXmhwUpestwbN4pxB0D1wdxow9sRCaJ rJhLi2PTNYIBb9S0yUFHcga3UVOE836qU5148VaTXZdRmh8FPHSijFl 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: 1788799947723158500 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 --- 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 1f46ac7d58..5c95dee99a 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 ASPEED_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 Sat Sep 26 20:03:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1788799971; cv=none; d=zohomail.com; s=zohoarc; b=UVoAyC2ZnwxpR4/Tm3MhOLUqlpV6E483kFHo8t04tfJsxsgsL18rSOx96OjNcoQ6uGVuylriXcQsavnFK79WetWfbVWei2Fv+v6HF20xhNELYH0Y+jKmn27y80Lq0mFBroFktgutSK15SX08NG7pWU822yMGyyXkuyad9OIsLMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788799971; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=SvxLkYLFxBz+kmta5sRtklppBkoMZNtdkurTxLQZymc=; b=WpOreHu/Mj8vqIyXFzmG08rfXs7syljmpDKjw+DLqLpzNH+7RKvAPf3xdYoM9jZImyXAP185eX35MZNgZiyrJ3RkaP0P3PgfdzRajktE1Sz33BuBt2gxdy7CBIbj7TeUXeGJYrJSlUAZ+vT+gwuWPr8OQlZQc1ziIIHNJwIhUT0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788799971597354.6546844660611; Mon, 7 Sep 2026 09:52:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x3ca5-0005SA-Kb; Mon, 07 Sep 2026 12:52:29 -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 1x3cZq-00054J-IB for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:52:17 -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 1x3cZn-0004zs-P9 for qemu-devel@nongnu.org; Mon, 07 Sep 2026 12:52:14 -0400 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4998b5a63e2so44880585e9.1 for ; Mon, 07 Sep 2026 09:52: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 5b1f17b1804b1-49cf772692dsm383936695e9.10.2026.09.07.09.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 09:52:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788799930; x=1789404730; 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=Cl2YPOdrlNQR+3oVGuWV5kXV70D9W+27V/ve7vm7hSrk8XDIgW7Qt8lGJp9GRddWyX hL4p900k5UmEn3wpWk3UX487glKbITRJbm5wslVQT5bZ7IR8Ym0NUeqFibSuEpYUH+It 3Qlm6gS/n8QWgbUhhjRPiZCQB0FxwupwxVyOanv3wrf1yxrtvNfcnYuwjcfj0DS8rggB ggR/6oHHkD3dQNmZxVGXw7fD4gaDtp8f4wqYi7YjkxvgRsykTu2v423GhMdTz5Phl5m2 9KQnmeKhP+pE5dXDdyqwlmwSlJQIGceHkwrRJO28y2IuWXppuyeAW1VENYbUBG4i6C2U eNJg== X-Gm-Message-State: AFuF++mu5m7FSWJn6JSFVPCH/oKINrrmTLXSenVXnKYyIA51Y/weDgbT fQO++SX0de4AoSceY+jSdpgGUwC+qSbij4vhgif5tqDfDkRloQsUq7aZ6Sf+f/0+ X-Gm-Gg: AYBFou2TTfMUps4P+4mhtvYhrjyOS6ka5fIfWnEhbYaywpZFNc2TpKNWGbxQKHSUtll g845H3Go+gvEzfnipa00E9CxpFngj2LLxI0Nb+KkMuhJr0Y5IejTcdzubX3x45ke7dYFC3VwBVt eJUvJa4S+7FEMdXkz/iOjn/oyq2hxX1rb+LJrsypt2ZGJdfgRHlZTGCwdruKhzFqVXOzs9SAZUF ogJApn2Av63AU8shQES/8R53mf/YqoaNsEsMa7E9AwLB1I/ptE2zC/qaqlt4eHTaD9pL/wbJtL8 A6r/KX9+6ox92Sx4Y8cB63pQgPGC+/sn9zPhX8b5dP7IjN9VninwoyCvxcHohkNXXoi+VTLUe30 IbsRqrJsy5t6HwSMQevRZALrqmkU+BN6zCBk9MbDNnO/ttNVVyxhbaxAJ5fdDkiyvHHp9hRB62I Geq5arxyADw8yXdDgBOUWxYejBjG/aJfvYQqdEn9tJPZI4tXjNEzq6pqrE+1f0tjG8o93j8fLJH XrrN3OJI7769mSMNdKeuSgU04NwphktlZY= X-Received: by 2002:a05:600c:c173:b0:49c:cedc:3c36 with SMTP id 5b1f17b1804b1-49cf82a514cmr244391835e9.16.1788799930026; Mon, 07 Sep 2026 09:52:10 -0700 (PDT) Date: Mon, 07 Sep 2026 18:42:40 +0200 Subject: [PATCH 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: <20260907-bmc-minerva-v1-50-0d83ad610c3b@free.fr> References: <20260907-bmc-minerva-v1-0-0d83ad610c3b@free.fr> In-Reply-To: <20260907-bmc-minerva-v1-0-0d83ad610c3b@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.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788799323; l=2482; i=emmanuel.blot@free.fr; s=20260602; h=from:subject:message-id; bh=zMnHp1SdNieEAjweeitFky57rPPnAgy18OpmLaUpJ1g=; b=V1QzQMxFouIxH4+6g0pVsz7I5wTEN7pR2ggQuv3Iq8sMs0tlCTfPc+Z4JyM62A5ZZPXCfz4/Y BQs9aZ1zMwsC5KjI+t1YSLVMlBc+KUKDXGAHdGYkT58OSPpETyxitFy 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: 1788799974018154100 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