From patchwork Wed Nov 3 21:59:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 1550596 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=GWcejfUU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hl18f47jdz9sR4 for ; Thu, 4 Nov 2021 09:07:14 +1100 (AEDT) Received: from localhost ([::1]:36128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1miOPY-0003Bn-Eu for incoming@patchwork.ozlabs.org; Wed, 03 Nov 2021 18:07:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3bQaDYQgKCpgOM92GLK98GG8D6.4GEI6EM-56N6DFGF8FM.GJ8@flex--wuhaotsh.bounces.google.com>) id 1miOIs-0000sI-6r for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:00:18 -0400 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]:45038) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3bQaDYQgKCpgOM92GLK98GG8D6.4GEI6EM-56N6DFGF8FM.GJ8@flex--wuhaotsh.bounces.google.com>) id 1miOIp-0001Hb-NG for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:00:17 -0400 Received: by mail-yb1-xb49.google.com with SMTP id z2-20020a254c02000000b005b68ef4fe24so5967397yba.11 for ; Wed, 03 Nov 2021 15:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=XzmzLTw129AfoXJexFTDBkJFYclTTe0/WMWRnSEgR+o=; b=GWcejfUUsqu+ZPi165+WbVhHRzZKCUHSN++uCP/IFTsB/Bt2xhIzfeEuh+s+6Sc3nU 33ac1VWClS5jn2UqO6znYMXUGjUvpM6j5xZvw4XgDDoBM//gCt50hiFJvQIpnxxvBvEe 6NkwhjxOUpE1e6sTR9kooVAJ1K7L2e81W00l5WKfgDdw4lc1u28Qq2Ds/SyA1XfipvMq AHVoh1iHNKcg8RzK8xGitvfwlIx+NFkLCRoRoZRhEwREhDFZMNwPEY/rEz8SCbJJlI+P 5nK/nV3VdRjVo8MY63AGt3/+44poU8WDIImORJnP+gwTeattA2ztM36GCgNCiEm/Mkhp YQ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=XzmzLTw129AfoXJexFTDBkJFYclTTe0/WMWRnSEgR+o=; b=1DwVy6hs3K/YaAwI65isUx9MIwsZA/S00qpnoN5fMfFuyryvY75+p2i5fmDcHP3XDb IQ9AK9taTEHE/ITy+mFsSb1n8b+NxYoccY45RUXLyetmzjLNZ9qlLrUGakL8MdPqcaDW 3jsel27QWFPJJabIdbcoCk8VX0VkiGoMOKRdIKGjn63v7ogk9AqaiLhDdwouAYpq+3dc DtqUERU8PSgS0aZKpveigaHdq+8/H5VsgBFKo4i9dLlEAlwi91SC0qcjjhm/mghSSgIh +h4OXFVPtoejmmK/veCk88S38wzdYfidROowxhvYv6rpmMUWLiE57DvRua35ZpyhISJ6 AgUg== X-Gm-Message-State: AOAM53100fzXQwR9swqKU1LegrcskG2/ASGxRp1EicXdNnbfH7WWBEPl keTTSrMQJHEtjvIFyzbn0mBWjzG0bruynQ== X-Google-Smtp-Source: ABdhPJwDDa+jw8v0JD+BO0pWIgaoFcWUs8daYOcJNAQVxPdb9jB0+5XDuLlfAbKkWwWLWp3xD4gjMBSdBlrsIw== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a25:f620:: with SMTP id t32mr25122659ybd.437.1635976813431; Wed, 03 Nov 2021 15:00:13 -0700 (PDT) Date: Wed, 3 Nov 2021 14:59:48 -0700 In-Reply-To: <20211103215954.1401805-1-wuhaotsh@google.com> Message-Id: <20211103215954.1401805-2-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211103215954.1401805-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v4 1/7] hw/i2c: Clear ACK bit in NPCM7xx SMBus module From: Hao Wu To: peter.maydell@linaro.org Cc: richard.henderson@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com, f4bug@amsat.org, bin.meng@windriver.com, qemu-block@nongnu.org, armbru@redhat.com, thuth@redhat.com, Titus Rwantare Received-SPF: pass client-ip=2607:f8b0:4864:20::b49; envelope-from=3bQaDYQgKCpgOM92GLK98GG8D6.4GEI6EM-56N6DFGF8FM.GJ8@flex--wuhaotsh.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The ACK bit in NPCM7XX SMBus module should be cleared each time it sends out a NACK signal. This patch fixes the bug that it fails to do so. Signed-off-by: Hao Wu Reviewed-by: Titus Rwantare Reviewed-by: Peter Maydell --- hw/i2c/npcm7xx_smbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i2c/npcm7xx_smbus.c b/hw/i2c/npcm7xx_smbus.c index e7e0ba66fe..f18e311556 100644 --- a/hw/i2c/npcm7xx_smbus.c +++ b/hw/i2c/npcm7xx_smbus.c @@ -270,7 +270,7 @@ static void npcm7xx_smbus_recv_byte(NPCM7xxSMBusState *s) if (s->st & NPCM7XX_SMBCTL1_ACK) { trace_npcm7xx_smbus_nack(DEVICE(s)->canonical_path); i2c_nack(s->bus); - s->st &= NPCM7XX_SMBCTL1_ACK; + s->st &= ~NPCM7XX_SMBCTL1_ACK; } trace_npcm7xx_smbus_recv_byte((DEVICE(s)->canonical_path), s->sda); npcm7xx_smbus_update_irq(s); From patchwork Wed Nov 3 21:59:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 1550594 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=N57HLd44; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hl14v5wKHz9sR4 for ; Thu, 4 Nov 2021 09:03:59 +1100 (AEDT) Received: from localhost ([::1]:56864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1miOMP-0006Ya-Lh for incoming@patchwork.ozlabs.org; Wed, 03 Nov 2021 18:03:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3bwaDYQgKCpoQOB4INMBAIIAF8.6IGK8GO-78P8FHIHAHO.ILA@flex--wuhaotsh.bounces.google.com>) id 1miOIt-0000ur-9Q for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:00:19 -0400 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]:44932) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3bwaDYQgKCpoQOB4INMBAIIAF8.6IGK8GO-78P8FHIHAHO.ILA@flex--wuhaotsh.bounces.google.com>) id 1miOIr-0001K6-Hc for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:00:18 -0400 Received: by mail-pl1-x64a.google.com with SMTP id m5-20020a170902bb8500b0013a2b785187so1745292pls.11 for ; Wed, 03 Nov 2021 15:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=pXfgJHvome9hq7DD3kgavdSisX+d0Zxf80aI+vn8Zlk=; b=N57HLd44e2ihGy27+ZU+s8olg+tWgamGXaZRP4whEIS7iU7CZJTK5A9yKHoYNKxoFT KPotifQO8vEn8MfrEVSK5HoqOKBahNHgJxqLTepu8nLlWTvwzggbLGQ+917U/6WvNzuv lYb+Ahepg+8Z6uxy6hTAocSGZJHL6DmVURV+FpHYzDkJnNqtHhCW8C0lkkuu1FJwOCPZ Vvyocg/dY5XyiB56oRaSs7uLatdY03MixQ8A9AR6n1qpSRjnUIgJvZMreezmlmGCX18Q EMAKvPPQkfBFztttdSaPmu8lbeZkIE+yqjdA5CVOGVD8HV36OUWtIVvtRoUi3CSEgM7t UchQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=pXfgJHvome9hq7DD3kgavdSisX+d0Zxf80aI+vn8Zlk=; b=4HK9eriuVgUBJuXoHSk0tjSp/lEOB6ZUQ1EZaS7Do+CkqnBv6wW+R/H1Nuqx3Qu0AD bMCKCgoKvQH7W7nU+KjQDHnXuC4TOrbpCvZJvHHbTHdrvbc2gobmSTWORzTorTlUf2lp nixEjBtpUDikINWdwJQ2cbpTjn3I25T6o0WTzCSGdYEMQtaHd4oWVWGKiluXoPbJejJr j/ZvDHHpw9s9LK/bGwjuAFSVJXoWTBxbHGKSSUdj8grCORLu9tlLnq1p6EmRK7LSCfG6 KJ7GeJNCL1R+/cVDJgHRR0XJ8pGnFKCbd0McrinUHUncUTGF7OzQk785OO/VfpXhIkuc A+rA== X-Gm-Message-State: AOAM531jOx6Jd1gOCHaHNfn6Ld+3c2fDV1U7viXptQCz1saCqeD9E0od EQyu0C0JkdJLRxVu6NwAvCjtnTAPNNe/Ag== X-Google-Smtp-Source: ABdhPJw5jxlp5p4GtEk8dd1TepDGIzBWDvsYXPIT41SzwazI6aqOPLe/I/giVVAA/2VXUlC+dHrSeGvOZhzBOg== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a63:5f56:: with SMTP id t83mr4504327pgb.432.1635976815259; Wed, 03 Nov 2021 15:00:15 -0700 (PDT) Date: Wed, 3 Nov 2021 14:59:49 -0700 In-Reply-To: <20211103215954.1401805-1-wuhaotsh@google.com> Message-Id: <20211103215954.1401805-3-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211103215954.1401805-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v4 2/7] hw/i2c: Read FIFO during RXF_CTL change in NPCM7XX SMBus From: Hao Wu To: peter.maydell@linaro.org Cc: richard.henderson@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com, f4bug@amsat.org, bin.meng@windriver.com, qemu-block@nongnu.org, armbru@redhat.com, thuth@redhat.com, Titus Rwantare , Corey Minyard Received-SPF: pass client-ip=2607:f8b0:4864:20::64a; envelope-from=3bwaDYQgKCpoQOB4INMBAIIAF8.6IGK8GO-78P8FHIHAHO.ILA@flex--wuhaotsh.bounces.google.com; helo=mail-pl1-x64a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Originally we read in from SMBus when RXF_STS is cleared. However, the driver clears RXF_STS before setting RXF_CTL, causing the SM bus module to read incorrect amount of bytes in FIFO mode when the number of bytes read changed. This patch fixes this issue. Signed-off-by: Hao Wu Reviewed-by: Titus Rwantare Acked-by: Corey Minyard --- hw/i2c/npcm7xx_smbus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/i2c/npcm7xx_smbus.c b/hw/i2c/npcm7xx_smbus.c index f18e311556..1435daea94 100644 --- a/hw/i2c/npcm7xx_smbus.c +++ b/hw/i2c/npcm7xx_smbus.c @@ -637,9 +637,6 @@ static void npcm7xx_smbus_write_rxf_sts(NPCM7xxSMBusState *s, uint8_t value) { if (value & NPCM7XX_SMBRXF_STS_RX_THST) { s->rxf_sts &= ~NPCM7XX_SMBRXF_STS_RX_THST; - if (s->status == NPCM7XX_SMBUS_STATUS_RECEIVING) { - npcm7xx_smbus_recv_fifo(s); - } } } @@ -651,6 +648,9 @@ static void npcm7xx_smbus_write_rxf_ctl(NPCM7xxSMBusState *s, uint8_t value) new_ctl = KEEP_OLD_BIT(s->rxf_ctl, new_ctl, NPCM7XX_SMBRXF_CTL_LAST); } s->rxf_ctl = new_ctl; + if (s->status == NPCM7XX_SMBUS_STATUS_RECEIVING) { + npcm7xx_smbus_recv_fifo(s); + } } static uint64_t npcm7xx_smbus_read(void *opaque, hwaddr offset, unsigned size) From patchwork Wed Nov 3 22:01:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 1550595 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=YhqHm2sJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hl15839WDz9sR4 for ; Thu, 4 Nov 2021 09:04:12 +1100 (AEDT) Received: from localhost ([::1]:57792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1miOMb-0007A3-Mg for incoming@patchwork.ozlabs.org; Wed, 03 Nov 2021 18:04:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3wgaDYQgKCu0ljWPdihWVddVaT.RdbfTbj-STkTacdcVcj.dgV@flex--wuhaotsh.bounces.google.com>) id 1miOKM-0003Dn-9A for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:01:52 -0400 Received: from mail-pl1-x649.google.com ([2607:f8b0:4864:20::649]:47989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3wgaDYQgKCu0ljWPdihWVddVaT.RdbfTbj-STkTacdcVcj.dgV@flex--wuhaotsh.bounces.google.com>) id 1miOKH-0002X5-7m for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:01:48 -0400 Received: by mail-pl1-x649.google.com with SMTP id e10-20020a17090301ca00b00141fbe2569dso1730673plh.14 for ; Wed, 03 Nov 2021 15:01:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=efR0JnoYVaUP6guc+xz5CQ8KCIXNVxNPRHjKAJdjqms=; b=YhqHm2sJR2Lu2FuGEcviRLIiLtzzgfaQ+xtE4z28nALoH3CyYCgsDvchTG3zGbGfYV bQ2yPjq74VOyOxkP8KKEAI60lAbILu1TTRixvZ7KecEqDRMOdEdxzimkqyGR0h2Si89R xEDEmeF90esK++PkqXK7vHzhycoi0vv6XYj4KWO1tn8FVsIi3VNffAV/rjj87DW86uRV N7QcbQl3bZfw5qGAltWFi9YIv7GooDBrlJNA+Jm7wQb3EKG25aRfCRuO7/5awYVQPvBm PLDTJ8WfVlzpTpxwvE5uTkSYX48B52kxM2VbhD2J5cNSm12sleIYO3gqmomjXnmAv/cK rkkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=efR0JnoYVaUP6guc+xz5CQ8KCIXNVxNPRHjKAJdjqms=; b=r7UQcfqyND34JtH//IhD7op/nnKsI1zg6MBtUCgLjigheG44Zn05E1ZVSfqc9jwZGd 9vJT5AJO1Z3pAsNcbg/mdWxiZKh3BSx2TNuxTQmZA74YvIuG4sWeo3Sswpet86f9KLgt ep3eNsG3562b2gZd7n2ENIs9DtFV3LsOIwLKH+c0Zej5+BoqwtTDSc+W0NVNaEkrJHmX 4KyRH18peRbnn/BTSj8lwyWzuTAhzk3f8G5MWG2ftWT8oTut25DzCdUShv1MSxpt7qqL SVXnq4zd5lqVWIJpY83Oy+Fh++bcSmYjGH2AvlqqtVuBDMN03o1LTqGQ7K4gxM86SuWK Rwsw== X-Gm-Message-State: AOAM532ytgQmkAWceHoXJNn+E19O7SEULuriawNU5dcfYUyCbXasm8m0 Pjvn6U1A0LNeyrJl4/N/3K0DWHYTgE6Wgw== X-Google-Smtp-Source: ABdhPJzs7VedtkeLCKM+i1rQemXiLdCkDK8ibOug00aWsctnIs2d77KGXpUCZpAHRpX8bbSH029xw6R64M9Png== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a17:903:1c5:b0:141:fbe2:56c1 with SMTP id e5-20020a17090301c500b00141fbe256c1mr17610907plh.52.1635976898569; Wed, 03 Nov 2021 15:01:38 -0700 (PDT) Date: Wed, 3 Nov 2021 15:01:29 -0700 Message-Id: <20211103220133.1422879-1-wuhaotsh@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v4 3/7] hw/adc: Fix CONV bit in NPCM7XX ADC CON register From: Hao Wu To: peter.maydell@linaro.org Cc: richard.henderson@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com, f4bug@amsat.org, bin.meng@windriver.com, qemu-block@nongnu.org, armbru@redhat.com, thuth@redhat.com Received-SPF: pass client-ip=2607:f8b0:4864:20::649; envelope-from=3wgaDYQgKCu0ljWPdihWVddVaT.RdbfTbj-STkTacdcVcj.dgV@flex--wuhaotsh.bounces.google.com; helo=mail-pl1-x649.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The correct bit for the CONV bit in NPCM7XX ADC is bit 13. This patch fixes that in the module, and also lower the IRQ when the guest is done handling an interrupt event from the ADC module. Signed-off-by: Hao Wu Reviewed-by: Patrick Venture Reviewed-by: Peter Maydell --- hw/adc/npcm7xx_adc.c | 2 +- tests/qtest/npcm7xx_adc-test.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c index 0f0a9f63e2..47fb9e5f74 100644 --- a/hw/adc/npcm7xx_adc.c +++ b/hw/adc/npcm7xx_adc.c @@ -36,7 +36,7 @@ REG32(NPCM7XX_ADC_DATA, 0x4) #define NPCM7XX_ADC_CON_INT BIT(18) #define NPCM7XX_ADC_CON_EN BIT(17) #define NPCM7XX_ADC_CON_RST BIT(16) -#define NPCM7XX_ADC_CON_CONV BIT(14) +#define NPCM7XX_ADC_CON_CONV BIT(13) #define NPCM7XX_ADC_CON_DIV(rv) extract32(rv, 1, 8) #define NPCM7XX_ADC_MAX_RESULT 1023 diff --git a/tests/qtest/npcm7xx_adc-test.c b/tests/qtest/npcm7xx_adc-test.c index 5ce8ce13b3..aaf127dd42 100644 --- a/tests/qtest/npcm7xx_adc-test.c +++ b/tests/qtest/npcm7xx_adc-test.c @@ -50,7 +50,7 @@ #define CON_INT BIT(18) #define CON_EN BIT(17) #define CON_RST BIT(16) -#define CON_CONV BIT(14) +#define CON_CONV BIT(13) #define CON_DIV(rv) extract32(rv, 1, 8) #define FST_RDST BIT(1) From patchwork Wed Nov 3 22:01:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 1550601 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=PN6MgwhI; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hl1FQ47nMz9sR4 for ; Thu, 4 Nov 2021 09:11:22 +1100 (AEDT) Received: from localhost ([::1]:45784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1miOTY-0001xB-Co for incoming@patchwork.ozlabs.org; Wed, 03 Nov 2021 18:11:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3xAaDYQgKCu8nlYRfkjYXffXcV.TfdhVdl-UVmVcefeXel.fiX@flex--wuhaotsh.bounces.google.com>) id 1miOKO-0003Ec-Us for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:01:56 -0400 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]:56198) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3xAaDYQgKCu8nlYRfkjYXffXcV.TfdhVdl-UVmVcefeXel.fiX@flex--wuhaotsh.bounces.google.com>) id 1miOKH-0002YP-76 for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:01:50 -0400 Received: by mail-pf1-x449.google.com with SMTP id t62-20020a625f41000000b004807e0ed462so2105229pfb.22 for ; Wed, 03 Nov 2021 15:01:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=dMycM0iTAsn10hNJmp4h6CEEwqweLqLM9YjEB0Wk4fM=; b=PN6MgwhITl+W/ne1Iazq0YDgkUZK2QrCL2PDFrZEkEY9jTBiQ/i+RVxkUqXBYPh3Ix hbYyzLUXLaa36QKnf66odxXD1vbF0IBaOcxMZXPGXgx6jhXDg3lWXGOc/lC52kVtzRHF 3GyiwsQktn8b475dvv+CwpF8GpeeCFqIqm9rNkjr/zqDPRhaFszAQKqN/8Jre8KwkNxi vEnL3BZvG4+6ucEjDB8r0QFuSrUycJ+JnatMSVEtutLIh+5ORds90EeCS96PMdWx2Qs6 nWnpzWf6TLe8LH9IW7Os0HLa4GL0cVNglWBCRebBv5XhFUOO1P75+k086YUsdpaMtJv1 hD5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=dMycM0iTAsn10hNJmp4h6CEEwqweLqLM9YjEB0Wk4fM=; b=cttTbyKEBuGIeRbBk5rVl7Gwlq3ovQWrQDektsuS93LdFPLMCpM1AqmZqVqbmSGSWE /sgPWNbJWHvNOJ76wyNZDG5is7jfvYZZsx6AWjgqRn6uAp87JOykxwKKHtE6FGnY3lBP HVf7PadE5eF0ot0+r6DriEhDZzhWpVflIBYfO6Nx/Os3lSUDjHyb/vFQ8OhGKfsFQdGU ix3TLcTa/4w5felZlm2br2PpAqyBHDcJOTsdvA1dy+RSyHBWJsf7t3kOzr7F4DB/pe/K 8Dm0C9+EbQe5mX8QJ1RSQqBgSwa0D0h7MzHLu3JbbJ479uUF8imj0KuvmihwEmbhSH5D tfZA== X-Gm-Message-State: AOAM5301W4e8yj6v9fI0B6KLoI1Q5bzMpJG+j29yKJss+ruR6PUMGz3k PgT/UDfJpdsKuJ53tTrSK+JkvDMdXnnimw== X-Google-Smtp-Source: ABdhPJwMfSwSg294VsfgrPQFrRcCJzdMgwjajYYDcVV/58B6DxsLOyZhwJZuQnde8ko9W0yqZVXxWe/M5eZ3BA== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a62:7756:0:b0:492:656c:3b84 with SMTP id s83-20020a627756000000b00492656c3b84mr7372825pfc.43.1635976900343; Wed, 03 Nov 2021 15:01:40 -0700 (PDT) Date: Wed, 3 Nov 2021 15:01:30 -0700 In-Reply-To: <20211103220133.1422879-1-wuhaotsh@google.com> Message-Id: <20211103220133.1422879-2-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211103220133.1422879-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v4 4/7] hw/adc: Make adci[*] R/W in NPCM7XX ADC From: Hao Wu To: peter.maydell@linaro.org Cc: richard.henderson@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com, f4bug@amsat.org, bin.meng@windriver.com, qemu-block@nongnu.org, armbru@redhat.com, thuth@redhat.com, Titus Rwantare Received-SPF: pass client-ip=2607:f8b0:4864:20::449; envelope-from=3xAaDYQgKCu8nlYRfkjYXffXcV.TfdhVdl-UVmVcefeXel.fiX@flex--wuhaotsh.bounces.google.com; helo=mail-pf1-x449.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Our sensor test requires both reading and writing from a sensor's QOM property. So we need to make the input of ADC module R/W instead of write only for that to work. Signed-off-by: Hao Wu Reviewed-by: Titus Rwantare Reviewed-by: Peter Maydell --- hw/adc/npcm7xx_adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c index 47fb9e5f74..bc6f3f55e6 100644 --- a/hw/adc/npcm7xx_adc.c +++ b/hw/adc/npcm7xx_adc.c @@ -242,7 +242,7 @@ static void npcm7xx_adc_init(Object *obj) for (i = 0; i < NPCM7XX_ADC_NUM_INPUTS; ++i) { object_property_add_uint32_ptr(obj, "adci[*]", - &s->adci[i], OBJ_PROP_FLAG_WRITE); + &s->adci[i], OBJ_PROP_FLAG_READWRITE); } object_property_add_uint32_ptr(obj, "vref", &s->vref, OBJ_PROP_FLAG_WRITE); From patchwork Wed Nov 3 22:01:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 1550599 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=HjzD7ZSH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hl1F640wyz9sR4 for ; Thu, 4 Nov 2021 09:11:06 +1100 (AEDT) Received: from localhost ([::1]:44372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1miOTI-0000zE-EC for incoming@patchwork.ozlabs.org; Wed, 03 Nov 2021 18:11:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3xgaDYQgKCvEpnaThmlaZhhZeX.VhfjXfn-WXoXeghgZgn.hkZ@flex--wuhaotsh.bounces.google.com>) id 1miOKX-0003Ic-2y for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:02:01 -0400 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]:38861) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3xgaDYQgKCvEpnaThmlaZhhZeX.VhfjXfn-WXoXeghgZgn.hkZ@flex--wuhaotsh.bounces.google.com>) id 1miOKH-0002aO-7N for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:01:59 -0400 Received: by mail-pf1-x44a.google.com with SMTP id j3-20020a628003000000b004811bc66186so2142469pfd.5 for ; Wed, 03 Nov 2021 15:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=4NP9rIxBTEklu2hTKeeix8BSJczBevQhyLOZN1vXyl4=; b=HjzD7ZSHFMQUj0fc+ANHMaObSi8ycW3y9crT6lTITfS0G03l18t76hGPqBQEVEg2V7 dYDRjQAX/M1oeqvdfnusP5sji/vSG5hP4C3IGSaR3HeZhLNNsbZIw2at1pn+6cv4e7AT rbR6oGPxmKBPYQLwVEc8cgpryB6G3ScWqnZJB9PwR1U0bRbhgTxALqPTj0bC6Ae5m6fQ I/x2dLEHKx2aWtBi/sBevE2Awvzcmnj3qOdUaSISLKQGF79za34DtQqynwoHJ9xRZOPD +9+dqDy4WYh8t/sNNSoRX5T6Zy+mWYvq7df6nBtabvuVUIy0Vm/he1jnqhtRgy7QZpSx aWbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=4NP9rIxBTEklu2hTKeeix8BSJczBevQhyLOZN1vXyl4=; b=hSr/fsiEA0ewd9XSs3k4QsPuHp1QM6JP9eLbuwAg/5czyQEGBEME08Yfutja23a1ik EAFwznxjsUFX9akD8rdyCmTUGHY/AV+SZLhAjBmPVLgNsgopqmCRAyxG7eL8e/S46aVp kXctNyIStxyMDzUlDEcnvI8/JbP3SAnnDmmyyrxN/zkbKDUxvdPxPneJgxQSQbIFzYlx e/GVSuFLB9Gu0DWbgPYimliOYG4umNyIxyQHXHJ7/Az0iSTPBwRNlncLTtL9eeqeLmAt RLIjQqyFehiPTzS+reacHprorgp1VzxzkvRZvus3NsE15fOd0deb+y+SfrVlfhDzMkHH Pa5Q== X-Gm-Message-State: AOAM532RkBlTdzlNzm3/Wjg+8e3LBVC5UNagD5WALUoF7+y5BWI5TDZm cHZUdmBn3UgdLxW+hmFWltpD2TlNkPxONQ== X-Google-Smtp-Source: ABdhPJwqBHdGtRi3Y9Dd/GdNyEO7XSkgK4KfF5lQDya3EI/iar3+F1fTbCX7y1xytB7rxyGsrbdev3iWsn2YVQ== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a17:90a:9295:: with SMTP id n21mr17523809pjo.229.1635976902489; Wed, 03 Nov 2021 15:01:42 -0700 (PDT) Date: Wed, 3 Nov 2021 15:01:31 -0700 In-Reply-To: <20211103220133.1422879-1-wuhaotsh@google.com> Message-Id: <20211103220133.1422879-3-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211103220133.1422879-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v4 5/7] blockdev: Add a new IF type IF_OTHER From: Hao Wu To: peter.maydell@linaro.org Cc: richard.henderson@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com, f4bug@amsat.org, bin.meng@windriver.com, qemu-block@nongnu.org, armbru@redhat.com, thuth@redhat.com Received-SPF: pass client-ip=2607:f8b0:4864:20::44a; envelope-from=3xgaDYQgKCvEpnaThmlaZhhZeX.VhfjXfn-WXoXeghgZgn.hkZ@flex--wuhaotsh.bounces.google.com; helo=mail-pf1-x44a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This type is used to represent block devs that are not suitable to be represented by other existing types. Signed-of-by: Hao Wu --- blockdev.c | 3 ++- include/sysemu/blockdev.h | 1 + meson | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index b35072644e..c26cbcc422 100644 --- a/blockdev.c +++ b/blockdev.c @@ -80,6 +80,7 @@ static const char *const if_name[IF_COUNT] = { [IF_MTD] = "mtd", [IF_SD] = "sd", [IF_VIRTIO] = "virtio", + [IF_OTHER] = "other", [IF_XEN] = "xen", }; @@ -739,7 +740,7 @@ QemuOptsList qemu_legacy_drive_opts = { },{ .name = "if", .type = QEMU_OPT_STRING, - .help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)", + .help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio, other)", },{ .name = "file", .type = QEMU_OPT_STRING, diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index 32c2d6023c..bce6aab573 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -24,6 +24,7 @@ typedef enum { */ IF_NONE = 0, IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN, + IF_OTHER, IF_COUNT } BlockInterfaceType; diff --git a/meson b/meson index b25d94e7c7..776acd2a80 160000 --- a/meson +++ b/meson @@ -1 +1 @@ -Subproject commit b25d94e7c77fda05a7fdfe8afe562cf9760d69da +Subproject commit 776acd2a805c9b42b4f0375150977df42130317f From patchwork Wed Nov 3 22:01:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 1550597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=Ir/f1gSb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hl18j3qhxz9sR4 for ; Thu, 4 Nov 2021 09:07:17 +1100 (AEDT) Received: from localhost ([::1]:36478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1miOPb-0003PC-C5 for incoming@patchwork.ozlabs.org; Wed, 03 Nov 2021 18:07:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3xwaDYQgKCvIqobUinmbaiiafY.WigkYgo-XYpYfhihaho.ila@flex--wuhaotsh.bounces.google.com>) id 1miOKR-0003Eo-O3 for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:01:58 -0400 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]:34562) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3xwaDYQgKCvIqobUinmbaiiafY.WigkYgo-XYpYfhihaho.ila@flex--wuhaotsh.bounces.google.com>) id 1miOKM-0002bm-04 for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:01:54 -0400 Received: by mail-pf1-x449.google.com with SMTP id x25-20020aa79199000000b0044caf0d1ba8so2155677pfa.1 for ; Wed, 03 Nov 2021 15:01:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=DofkSRTXRKtEMsEmkHJldcRscNyPS9ZKqUEISxFiUzc=; b=Ir/f1gSbLy9cLdndt/s2yFMzleVVnjUGZlYAjIpJyjKSVbCL+zQIxFrSO20Yn9jv6e pBHGwuHaSczYjjkroQcQIW9H/WhUBlugYMbtfW/+udprAskcGv1IfqvgQ5xgKZjWdPaY j7yobWBylCM+ZEeHP9PhAf/VGu6gX/6NPPCKuK+XE4Vef/xZLLUFmpvL+URkRF6ba6iC XnLRDGC7OvdYzaCFVOJTXvsq7hn/RT55E6E+/6CIT+XdAdRx9L+c4euzhEbKkLSk0hc4 bgcpoOTnoxxR7e2MsAP5Z0nS/0CtpqC9/lfHtmCo+JKwcecuPMt1MwJ3KyTZpefrE/UH /mDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=DofkSRTXRKtEMsEmkHJldcRscNyPS9ZKqUEISxFiUzc=; b=tDuQQNHYFlfhcu8ZhG8HriQUyjdODdb56YBnvkWwk4X5DFFUlam6lfucytsi/aPA9/ O+W6LRE0AZacxQXwLIDESkd3838QQJVWsLVIVu34gciSPjZjrI6odHtTQVGwzLixEmiX fkbfzoRjnnl2fGmQa22C9Uts/GgXbdXrs6CBLxAPjNGQd3lRnc9rSlYxLh2UqeSuxnZw IOgnxRdJc8u9cfRHUUu2BAPCW4hHvQh2QmPZL+K4cEoa/zFdgnFDU+VpbjBi1Ha7fdim PNdOGbUC4trFrxSz/e0zP6DYF5yDO8XVnAXOQXnKsDbM9KzTNPPnpR0DrbzD62WAUT93 /J+A== X-Gm-Message-State: AOAM5325ioLSDrFuMAaQykVbBcfSwr8hvMduK4gE9tge9k0WMo4Zjx01 9F12dKYTtGBJy0o/wemiO2bvoOg1/0eccw== X-Google-Smtp-Source: ABdhPJyeAWGrglgE32IfnWZDuwyZaX4inqjW1ka6u7wNh9KAzyxAxtexjF4rqZm1qR6i6V9afzpJBQU0ZJVd5w== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a17:902:ce8c:b0:141:d411:7e25 with SMTP id f12-20020a170902ce8c00b00141d4117e25mr26691523plg.85.1635976903943; Wed, 03 Nov 2021 15:01:43 -0700 (PDT) Date: Wed, 3 Nov 2021 15:01:32 -0700 In-Reply-To: <20211103220133.1422879-1-wuhaotsh@google.com> Message-Id: <20211103220133.1422879-4-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211103220133.1422879-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v4 6/7] hw/nvram: Update at24c EEPROM init function in NPCM7xx boards From: Hao Wu To: peter.maydell@linaro.org Cc: richard.henderson@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com, f4bug@amsat.org, bin.meng@windriver.com, qemu-block@nongnu.org, armbru@redhat.com, thuth@redhat.com Received-SPF: pass client-ip=2607:f8b0:4864:20::449; envelope-from=3xwaDYQgKCvIqobUinmbaiiafY.WigkYgo-XYpYfhihaho.ila@flex--wuhaotsh.bounces.google.com; helo=mail-pf1-x449.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We made 3 changes to the at24c_eeprom_init function in npcm7xx_boards.c: 1. We allow the function to take a I2CBus* as parameter. This allows us to attach an EEPROM device behind an I2C mux which is not possible with the old method. 2. We make at24c EEPROMs are backed by drives so that we can specify the content of the EEPROMs. 3. Instead of using i2c address as unit number, This patch assigns unique unit numbers for each eeproms in each board. This avoids conflict in providing multiple eeprom contents with the same address. In the old method if we specify two drives with the same unit number, the following error will occur: `Device with id 'none85' exists`. Signed-off-by: Hao Wu --- hw/arm/npcm7xx_boards.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c index dec7d16ae5..9121e081fa 100644 --- a/hw/arm/npcm7xx_boards.c +++ b/hw/arm/npcm7xx_boards.c @@ -126,13 +126,17 @@ static I2CBus *npcm7xx_i2c_get_bus(NPCM7xxState *soc, uint32_t num) return I2C_BUS(qdev_get_child_bus(DEVICE(&soc->smbus[num]), "i2c-bus")); } -static void at24c_eeprom_init(NPCM7xxState *soc, int bus, uint8_t addr, - uint32_t rsize) +static void at24c_eeprom_init(I2CBus *i2c_bus, int bus, uint8_t addr, + uint32_t rsize, int unit_number) { - I2CBus *i2c_bus = npcm7xx_i2c_get_bus(soc, bus); I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr); DeviceState *dev = DEVICE(i2c_dev); + DriveInfo *dinfo; + dinfo = drive_get(IF_OTHER, bus, unit_number); + if (dinfo) { + qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo)); + } qdev_prop_set_uint32(dev, "rom-size", rsize); i2c_slave_realize_and_unref(i2c_dev, i2c_bus, &error_abort); } @@ -239,8 +243,8 @@ static void quanta_gsj_i2c_init(NPCM7xxState *soc) i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 3), "tmp105", 0x5c); i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), "tmp105", 0x5c); - at24c_eeprom_init(soc, 9, 0x55, 8192); - at24c_eeprom_init(soc, 10, 0x55, 8192); + at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 9), 9, 0x55, 8192, 0); + at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 10), 10, 0x55, 8192, 1); /* * i2c-11: From patchwork Wed Nov 3 22:01:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 1550598 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=LdKZ6V9H; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hl1Bp33GDz9sR4 for ; Thu, 4 Nov 2021 09:09:05 +1100 (AEDT) Received: from localhost ([::1]:40922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1miORJ-0006u1-5P for incoming@patchwork.ozlabs.org; Wed, 03 Nov 2021 18:09:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3yQaDYQgKCvQsqdWkpodckkcha.Ykimaiq-Zarahjkjcjq.knc@flex--wuhaotsh.bounces.google.com>) id 1miOKT-0003F6-J4 for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:01:58 -0400 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]:36807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3yQaDYQgKCvQsqdWkpodckkcha.Ykimaiq-Zarahjkjcjq.knc@flex--wuhaotsh.bounces.google.com>) id 1miOKO-0002c7-LK for qemu-devel@nongnu.org; Wed, 03 Nov 2021 18:01:57 -0400 Received: by mail-pf1-x449.google.com with SMTP id c207-20020a621cd8000000b0048060050cfeso2145649pfc.3 for ; Wed, 03 Nov 2021 15:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=zKsthWD6aLJepNequIRsE8wsdkCHtKgMHCSXi5pgrhc=; b=LdKZ6V9HSdXlROBBmA/fypBCta8ug4XXGnUmkBApf2ExIWyZcJDcEBZjmrLnHHiuic 9Dz/rp4xR/kgBEiUD9UdaB7uI4TljLwlkNseSVXUbBdpjdZZrJ5qtLWnRpk9VsOYn/A5 napPDpH/wgOhqEZdtUmIM/V72DvmElO5A/3X/XLJ2kuNPwzv1/zEWan1zxXdcD6FDRG1 fNNvlXW1PTbmoAK7GVkX4XPoSqHIp7MBKWeu9l/mkZLQoM//HD47ECh499q0jxkPpd4t pMYM1qBsal1IcQuVjAgKLgv1oxrcif41nWVwiWVUQVd7x/KUwVEye9MaEocfYggRBrw2 G9IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=zKsthWD6aLJepNequIRsE8wsdkCHtKgMHCSXi5pgrhc=; b=thvdMnj0L/FmGVedcAUMFNz2qlKENwCTH/O0BdFdxlLR8mCH2ykJ15XAohb7aI+b9w ou+14IwbYH6nQLgsfWLNfx/xCIg3MQFqWde5d7Rl4+4peJm04GIYLY7blcVbMxsvHJ5P v1Youxkr5z86mE+TWgL3BDSggl66XAK/CRY//RHDDdRVNlbizQe0pagBlP4/hbqudoUk Y+kkEYy0F396EXTS+nqdp0rgUd6xn2w09QVZo4xR355WtW/xXYXfP7C5mwg/XUou9pHd +mpgxMJwWURVUCSwmW0nCpwHRVujRlBUPw4FTZaS622CIndHV/B/jCD8MGqb2EE+yYMd jZkQ== X-Gm-Message-State: AOAM530g19WN64JNyfSVRs+vAj+o6Q8QGa/7ux4t++mDfDLGyP36ofJR HGqoEHLt466T6c1aaR8eWYV3TQHOkNS9xw== X-Google-Smtp-Source: ABdhPJw7o3c1yLN1sC5c9BSpKwnQ5XLGbing+MBEiGbq0wkKpqz9S+xnrJpqlZu6cebjO9B1f2LIs8wmpHn35A== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a17:90b:2487:: with SMTP id nt7mr17397144pjb.75.1635976905864; Wed, 03 Nov 2021 15:01:45 -0700 (PDT) Date: Wed, 3 Nov 2021 15:01:33 -0700 In-Reply-To: <20211103220133.1422879-1-wuhaotsh@google.com> Message-Id: <20211103220133.1422879-5-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211103220133.1422879-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v4 7/7] hw/arm: quanta-gbs-bmc add i2c devices From: Hao Wu To: peter.maydell@linaro.org Cc: richard.henderson@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com, f4bug@amsat.org, bin.meng@windriver.com, qemu-block@nongnu.org, armbru@redhat.com, thuth@redhat.com Received-SPF: pass client-ip=2607:f8b0:4864:20::449; envelope-from=3yQaDYQgKCvQsqdWkpodckkcha.Ykimaiq-Zarahjkjcjq.knc@flex--wuhaotsh.bounces.google.com; helo=mail-pf1-x449.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Patrick Venture Adds supported i2c devices to the quanta-gbc-bmc board. Signed-off-by: Patrick Venture Reviewed-by: Hao Wu --- hw/arm/npcm7xx_boards.c | 82 ++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c index 9121e081fa..7fb1b3dbc2 100644 --- a/hw/arm/npcm7xx_boards.c +++ b/hw/arm/npcm7xx_boards.c @@ -276,10 +276,12 @@ static void quanta_gsj_fan_init(NPCM7xxMachine *machine, NPCM7xxState *soc) static void quanta_gbs_i2c_init(NPCM7xxState *soc) { + I2CSlave *i2c_mux; + + /* i2c-0: */ + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 0), TYPE_PCA9546, 0x71); + /* - * i2c-0: - * pca9546@71 - * * i2c-1: * pca9535@24 * pca9535@20 @@ -288,46 +290,60 @@ static void quanta_gbs_i2c_init(NPCM7xxState *soc) * pca9535@23 * pca9535@25 * pca9535@26 - * - * i2c-2: - * sbtsi@4c - * - * i2c-5: - * atmel,24c64@50 mb_fru - * pca9546@71 - * - channel 0: max31725@54 - * - channel 1: max31725@55 - * - channel 2: max31725@5d - * atmel,24c64@51 fan_fru - * - channel 3: atmel,24c64@52 hsbp_fru - * + */ + + /* i2c-2: sbtsi@4c */ + + /* i2c-5: */ + /* mb_fru */ + at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 5), 5, 0x50, 8192, 0); + i2c_mux = i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 5), + TYPE_PCA9546, 0x71); + /* max31725 is tmp105 compatible. */ + i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 0), "tmp105", 0x54); + i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 1), "tmp105", 0x55); + i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 2), "tmp105", 0x5d); + /* fan_fru */ + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 5, 0x51, 8192, 1); + /* hsbp_fru */ + at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 3), 5, 0x52, 8192, 2); + + /* * i2c-6: * pca9545@73 * * i2c-7: * pca9545@72 - * - * i2c-8: - * adi,adm1272@10 - * - * i2c-9: - * pca9546@71 - * - channel 0: isil,isl68137@60 - * - channel 1: isil,isl68137@61 - * - channel 2: isil,isl68137@63 - * - channel 3: isil,isl68137@45 - * + */ + + /* i2c-8: */ + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 8), "adm1272", 0x10); + + /* i2c-9: */ + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 9), TYPE_PCA9546, 0x71); + /* + * - channel 0: isil,isl68137@60 + * - channel 1: isil,isl68137@61 + * - channel 2: isil,isl68137@63 + * - channel 3: isil,isl68137@45 + */ + + /* * i2c-10: * pca9545@71 * * i2c-11: * pca9545@76 - * - * i2c-12: - * maxim,max34451@4e - * isil,isl68137@5d - * isil,isl68137@5e - * + */ + + /* i2c-12: */ + i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 12), "max34451", 0x4e); + /* + * isil,isl68137@5d + * isil,isl68137@5e + */ + + /* * i2c-14: * pca9545@70 */