From patchwork Mon Nov 1 23:23:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 12597547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53807C433EF for ; Mon, 1 Nov 2021 23:26:45 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 08DBB60F56 for ; Mon, 1 Nov 2021 23:26:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 08DBB60F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:33878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhghQ-0004gl-4y for qemu-devel@archiver.kernel.org; Mon, 01 Nov 2021 19:26:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3DXeAYQgKChACAxq498xw44w1u.s426u2A-tuBu1343w3A.47w@flex--wuhaotsh.bounces.google.com>) id 1mhgen-0001j3-FR for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:24:01 -0400 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]:55857) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3DXeAYQgKChACAxq498xw44w1u.s426u2A-tuBu1343w3A.47w@flex--wuhaotsh.bounces.google.com>) id 1mhgel-0002v3-Fz for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:24:01 -0400 Received: by mail-pf1-x449.google.com with SMTP id t62-20020a625f41000000b004807e0ed462so4323630pfb.22 for ; Mon, 01 Nov 2021 16:23:58 -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=cV4lkirVsBCQabmzo/ALBPhmjaSB5+HRLGedyUZrUKTHBXinsTLN4Tb+Qlmfq8z2hi gfbMytI81qzq8/FKkoDBuuBwjCBCYtwfj05A/7zgGlYu8UUxXQwU7swhNhm08ffK59qN mK13wtnomVrzApfnuPkZPKKo6Ip+aPZwUZW6YF6jMi8MMhUuuV7uh1W/CQFhgisQQc4u i9XoLMXK4hsbc+xV+V8RsznI5MMUhqXzz6pQ5PzlkErcoBuV2cEMsojtNDEfaFefir8M QAjtPqsrAVW9036CiQ7PQtWKNpZM7yDUGGSG7gfSqlmqdKgGU3tjkPam1HXWCmHNJhwD gWbw== 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=0vOo/WPwc8awiMJryB+zmjXrPDzxIe95YhoydIdURJJ5kbKqn6KQkpn77DAVDfzaUT FlzBw9nlXqEWJpcxf2plGlwQe5BgOaiJeiHOPvZu+gKxNPpgDZpkpD8cbvXXgmrVSngC EWKyLEJ6uB+hhjN0url0brBrkxHyArXKdO1Y9dg+erm/PhPXiTE67T8lvvibaw4WR4wa Qei1Gwtb3IgVZ/wtfMc64t9BMpaHmyYXxwIvN44tbGmHqqPaHubrzR4jnFqreV6Y+zIu sXe3XxPTFlGG6M22A9mQAP0ZeBg7Ie9LdfEzjQR0y+VeM7kUFlw7MDHVCHPerXcjUKNy QYTA== X-Gm-Message-State: AOAM533SlFQ21YgGjVey2Cmg7xE/I17O9DGFVRKzWlpRY2ilWc/oi8K2 qgJRZRUawWP7dd8T8qy3EyK34Xz0SWA25Q== X-Google-Smtp-Source: ABdhPJyKxiqT7CmiWsecyVdjPy6LmZ7+CTKio+M8PhykhDq3vUl/hpCfJZSWMZtZ6cCZx4aX20z5bZrgVXu2DQ== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a17:902:d2cf:b0:141:b347:df9d with SMTP id n15-20020a170902d2cf00b00141b347df9dmr20630352plc.37.1635809037724; Mon, 01 Nov 2021 16:23:57 -0700 (PDT) Date: Mon, 1 Nov 2021 16:23:41 -0700 In-Reply-To: <20211101232346.1070813-1-wuhaotsh@google.com> Message-Id: <20211101232346.1070813-2-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211101232346.1070813-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v3 1/6] hw/i2c: Clear ACK bit in NPCM7xx SMBus module From: Hao Wu To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com, Titus Rwantare Received-SPF: pass client-ip=2607:f8b0:4864:20::449; envelope-from=3DXeAYQgKChACAxq498xw44w1u.s426u2A-tuBu1343w3A.47w@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+qemu-devel=archiver.kernel.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 Mon Nov 1 23:23:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 12597551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A39CC433F5 for ; Mon, 1 Nov 2021 23:27:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0C10960C40 for ; Mon, 1 Nov 2021 23:27:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0C10960C40 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:34854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhghg-0005LG-1y for qemu-devel@archiver.kernel.org; Mon, 01 Nov 2021 19:27:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3D3eAYQgKChIECzs6BAzy66y3w.u648w4C-vwDw3565y5C.69y@flex--wuhaotsh.bounces.google.com>) id 1mhgeo-0001jt-Ou for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:24:02 -0400 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]:51830) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3D3eAYQgKChIECzs6BAzy66y3w.u648w4C-vwDw3565y5C.69y@flex--wuhaotsh.bounces.google.com>) id 1mhgen-0002vT-Cy for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:24:02 -0400 Received: by mail-pl1-x64a.google.com with SMTP id g20-20020a170902869400b0014002b0f5bcso6674950plo.18 for ; Mon, 01 Nov 2021 16:24:00 -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=F/odgL06mHj9hb0bXbwtWGyI4vGh0hGbE7wVh8tg5zZPV1yWzhOhTzaJCs97hF7+cs gB28R6tuzrb9SnodIP3h8BShJ+FMH8xpNJNaMG2SjBTsYjJMFCHE2Z3Pq2Lf16Mo4xFB 9A3q5HxuFwDb+0kZ3mrn/VzV93rhOwxlKsaF0UHmuFXqqoxvHgsbERdm+0ozpfj3IMdS Xgp/X1PFNlDAol8cA9RfrpwuX6eTkVZPLNzi/j2+PZ/BawxOil4iDWbbi36uFwxDutV1 4I83N6mEt0/UlwGd60wRZmIFqQvVSIh4JD5fk65C12G7izVzvTO0ZCOTk5V3+uuOSbMb ZctQ== 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=dkj+0SI6gYYh5IF2FydVC3ODffGsff9pWNnaenLnbYflVL65ppmPeCQPJkmDXo1OHp +mTpZGuGilZ2A8D8f3qJjZ6AzDJVLQpAtE1AEoYxe3z9fZXdovup6N3fUlL49HfEbnFN 63EC8PCyql32feVXCe3bZZfHbTvgIIEYAynuPHfFJOF84dlmahFcDt1fmRvk5lKqOb90 IEXhWIU51+QzlLorrjfwFs9H2f3KSvuI6K6/LBlhjB9AMx2Lv6+xuZW8cex2Q8dVMmfP lpTEwko/4yUo5SlVMUr7gb7KWaVpDwQcPedq0b8B+qxFEoqqih694gpQyx25fUElV5ZZ yuRw== X-Gm-Message-State: AOAM531FTyudjB/XYavcY1poNkGyIOnZjuJkoAdNbpQ+le7LbLt6DYj0 tn3VXJwgTiKD0n8P1oSCQ6CV4eErJgQJ0A== X-Google-Smtp-Source: ABdhPJw0FKrfqjt+ebZNa7yRazo5cpYYlQ9KbCZV78nQz++Mi5usA4T4XYJoUgHieZPLbe0X8/qRIoxeVcyCzQ== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a17:90a:d317:: with SMTP id p23mr2266383pju.196.1635809039239; Mon, 01 Nov 2021 16:23:59 -0700 (PDT) Date: Mon, 1 Nov 2021 16:23:42 -0700 In-Reply-To: <20211101232346.1070813-1-wuhaotsh@google.com> Message-Id: <20211101232346.1070813-3-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211101232346.1070813-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v3 2/6] hw/i2c: Read FIFO during RXF_CTL change in NPCM7XX SMBus From: Hao Wu To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com, Titus Rwantare , Corey Minyard Received-SPF: pass client-ip=2607:f8b0:4864:20::64a; envelope-from=3D3eAYQgKChIECzs6BAzy66y3w.u648w4C-vwDw3565y5C.69y@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+qemu-devel=archiver.kernel.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 Mon Nov 1 23:23:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 12597549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C417C433FE for ; Mon, 1 Nov 2021 23:27:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E3E7F60F56 for ; Mon, 1 Nov 2021 23:27:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E3E7F60F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:34806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhghg-0005J6-2d for qemu-devel@archiver.kernel.org; Mon, 01 Nov 2021 19:27:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3NXeAYQgKCjgqobUinmbaiiafY.WigkYgo-XYpYfhihaho.ila@flex--wuhaotsh.bounces.google.com>) id 1mhgfT-0002Ft-KS for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:24:44 -0400 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]:55876) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3NXeAYQgKCjgqobUinmbaiiafY.WigkYgo-XYpYfhihaho.ila@flex--wuhaotsh.bounces.google.com>) id 1mhgfQ-00030F-DP for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:24:43 -0400 Received: by mail-pg1-x549.google.com with SMTP id n22-20020a6563d6000000b0029261ffde9bso10121167pgv.22 for ; Mon, 01 Nov 2021 16:24:38 -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=6AUI0+PiGPmUzag0ZNUEPDyJly7ggJ1Nhpqw9WWQjcs=; b=nHq50hJrrVhslHc/JmRUl/s9XpJJgpGqNrXMJHS83cAflSo1Ic5WpnVVyg3V6WdKGN /HO84CyiOtQePtMhZqh9j66Nild1K1pFVd75cyYCFY2emqybZWBgM6B94CJoIjqxo9ua /ieCGxEQavK7hnJLnNUHpXMvKjzy93oSZHZvtU7YfjwcyOcK7p49NYxp2Eb8TcpXn55j yKevqx0AtzwPb71IjWqYp/A/34rM04fHd1mUExjSn/dCHghc9Y0hGOFNWqAtPkbukPct +TRU/oDmN3Pu0x5K/SU6rV2YjOVbjHrLq3wCgkM2gM9dqYRsGyFB+3T+lreFhTredNVL dArQ== 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=6AUI0+PiGPmUzag0ZNUEPDyJly7ggJ1Nhpqw9WWQjcs=; b=YmWzmb2fCXmgemqyO5t4SBAdlXVGxfsMA4hCSGuYLEehyXsioFAIzuwsCs30uWZ6oO qtqVcjjn4BQvtjn9DJMCueSY2iRQAZmyc4vPP5yJCULQHO8HKwiyB4GqicFyAvDiLBBh LhoHc5naiJOFf2W6VNCzhM7FMSnSNpmAgEIOdOaERzczhYSdirCvhVsj60ANqoksBGPL ABqp5LPUnD7WrjIwATlQ9SoNPT9IFqF3HZCofVLUjhwVcsHogMUIsekMo0p3FqOIP8t5 13E0i/FlFGIVTUQ7vhipjNdPnRgPSDo+lP8PGj8yfw9l++8wk7M+A9/qsaEN8ZgOIe3W 9vdg== X-Gm-Message-State: AOAM531tHJlmdFbDY+7qRPK0mJAeXcdHSAaP0B3ubOQ/YCxhiAC7ZsOR iJFJljnJzBjnMGy/uOgBZorCqm3ahTHr+A== X-Google-Smtp-Source: ABdhPJyjZ5whpvu+Z/PwQrg8udEJor/9q8miNbMbbcqeKrq22uf5O4h9L37JRU4+YjFOM1fkD0wYtllG9gVldA== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a17:90b:3802:: with SMTP id mq2mr2213021pjb.213.1635809077424; Mon, 01 Nov 2021 16:24:37 -0700 (PDT) Date: Mon, 1 Nov 2021 16:23:43 -0700 In-Reply-To: <20211101232346.1070813-1-wuhaotsh@google.com> Message-Id: <20211101232346.1070813-4-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211101232346.1070813-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v3 3/6] hw/adc: Fix CONV bit in NPCM7XX ADC CON register From: Hao Wu To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com Received-SPF: pass client-ip=2607:f8b0:4864:20::549; envelope-from=3NXeAYQgKCjgqobUinmbaiiafY.WigkYgo-XYpYfhihaho.ila@flex--wuhaotsh.bounces.google.com; helo=mail-pg1-x549.google.com X-Spam_score_int: -76 X-Spam_score: -7.7 X-Spam_bar: ------- X-Spam_report: (-7.7 / 5.0 requ) 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+qemu-devel=archiver.kernel.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 Mon Nov 1 23:23:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 12597555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54055C433F5 for ; Mon, 1 Nov 2021 23:31:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 057EA60C40 for ; Mon, 1 Nov 2021 23:31:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 057EA60C40 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:42922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhglq-0002Qs-3e for qemu-devel@archiver.kernel.org; Mon, 01 Nov 2021 19:31:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3N3eAYQgKCjosqdWkpodckkcha.Ykimaiq-Zarahjkjcjq.knc@flex--wuhaotsh.bounces.google.com>) id 1mhgfU-0002Fv-LU for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:24:44 -0400 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]:38761) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3N3eAYQgKCjosqdWkpodckkcha.Ykimaiq-Zarahjkjcjq.knc@flex--wuhaotsh.bounces.google.com>) id 1mhgfS-00030P-F3 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:24:44 -0400 Received: by mail-yb1-xb49.google.com with SMTP id f92-20020a25a465000000b005bea37bc0baso28375342ybi.5 for ; Mon, 01 Nov 2021 16:24:39 -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=KjjhAw3K9MXqFjIQgMemsuTd8nJ8JJvWb1RLNXCDCdGXh9lHXJjQ5/23S3LwHNqVZs K2cfUHiT2U7D+3vRqky/9LSgM+jMSvEYZLTg7jmvW5eWgcM8MleEjM8LQigFsmjl9sdw Mf2kdmdMmCPpkr5EtleGd/WdzLQ1w6Wfjl0JHZ+f4Yhh1iVOCy+m5Wp2M1btE1epSQVG ql8ORQW6Fh36WoLIIMsQdLFO6HlyW4z3HPXV0jBnZwf/hHr/BdUaA+CEl3TWTiXwEMDg ZDeXSroO1OBXLNn+UrkkDXP35ywe6tEJqFMlXZkNMZ1HEGP1nBajMlQANDug8F4HiOjS K9iQ== 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=rHD91pAsbG//uhY2rQ5vtNbKrGDW8x1eBMmh3foNLzog7AmjZak2TRFJ5dkFqPxcst /IUOw8AplkhIzO4L6RoWh22vb14lcgb1uCsW33MaLS3I9Hacjx/aGUGZbmXhNJRJcn0V o1JnJJF0HnFDJ0GCQ0Z8lH6CmBVQRmcM/XDi4MslfY9M+si8Yo3vACeBprjkANOfbYtl 0REOVMMCe7D4c6VkUpu8ExwvjoZSQcxFuBimgGI/Ga+NIr6gZfPZJe96VVqmmYvjeodl MkSwXXUccJZzewbSApebkYjNleZZf0edMB5ZxnIQukccwyAtRXnLk7FZDJuiHdG1PDdq mEJg== X-Gm-Message-State: AOAM5325pe1nOHX16aApZ7wlZYlRrvIx4/AE+s2JMkyUpWR8ZDnM+YNp GywFIxbLEdJSne312Ad4I45GWec5LKt/yg== X-Google-Smtp-Source: ABdhPJybrhvySMlSXkwVPZEttdPtSxSi0vsrn9AYRmm543qrontwoxEy3e1phJPmVJ3QtXl9Pz9lnsjA+BI3Ow== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a5b:786:: with SMTP id b6mr35849908ybq.112.1635809079185; Mon, 01 Nov 2021 16:24:39 -0700 (PDT) Date: Mon, 1 Nov 2021 16:23:44 -0700 In-Reply-To: <20211101232346.1070813-1-wuhaotsh@google.com> Message-Id: <20211101232346.1070813-5-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211101232346.1070813-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v3 4/6] hw/adc: Make adci[*] R/W in NPCM7XX ADC From: Hao Wu To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com, Titus Rwantare Received-SPF: pass client-ip=2607:f8b0:4864:20::b49; envelope-from=3N3eAYQgKCjosqdWkpodckkcha.Ykimaiq-Zarahjkjcjq.knc@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=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+qemu-devel=archiver.kernel.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 Mon Nov 1 23:23:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 12597557 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DA6CC433F5 for ; Mon, 1 Nov 2021 23:32:00 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C6DB860EE5 for ; Mon, 1 Nov 2021 23:31:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C6DB860EE5 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:43702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhgmV-0002wf-01 for qemu-devel@archiver.kernel.org; Mon, 01 Nov 2021 19:31:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3OHeAYQgKCjstreXlqpedlldib.Zljnbjr-absbiklkdkr.lod@flex--wuhaotsh.bounces.google.com>) id 1mhgfV-0002I8-UD for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:24:46 -0400 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]:53069) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3OHeAYQgKCjstreXlqpedlldib.Zljnbjr-absbiklkdkr.lod@flex--wuhaotsh.bounces.google.com>) id 1mhgfT-00030s-Aq for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:24:45 -0400 Received: by mail-pf1-x44a.google.com with SMTP id a127-20020a627f85000000b0047feae4a8d9so4869712pfd.19 for ; Mon, 01 Nov 2021 16:24: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=vZuuJBScVpwz/n6NghZWtiMoiaQStfl6YzFYf/q2BWQ=; b=M6EIbF/mliLkmHyNM9t3oU/YOI6NqNO3kVQiT3Jtp6VQy1J4waNKVjl1v1GFmkIQvK WiNq0TtRvOKP8VVVE9+rFBoqVEoE94AFl239u0eH60c6jPMBMLd/Luwc35mHIs99PBxt SwNqySxIvTgfx45+IVGo+zXW+zrJubyzn7CIP2rypf1LVERpCuSCLkc/elUrqIqdf7UD rhhU35mUZp2GbVnbIAGw/9qWZgDBw+bu2FllB+0P/z47Az151/rsHBUsijb+8SQyBZSg RXALg7lO2oZIQmMyYqppN9TUaN/6tthtJNHj4bDeYJbrBUCTIJNoG6qAGZa0qI+eWcYL hXSQ== 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=vZuuJBScVpwz/n6NghZWtiMoiaQStfl6YzFYf/q2BWQ=; b=iNRUVAnNPQT3tjbAvsGgpDS4+iDrRqXROsfzXJSumM1EmY3QuXQ807wdX7fjzHLjb7 uApsq5NOjE5MFm+P12gZWHB2tIOO+6R08yioawmOGBznvMEe52QpjaFClCJHEN9ymmFK 8/J+uv7Fu0hWUrwt/hm+EzKXqawa1xQ7qjVGVhjiCFTcbKtAQfaVMwH4hvWFyP8oendP TXIw625s6fBFcJIw8jXUbuWIWuBtT/UAU5kbf8I2EgYDeQ6JUiVhiAdp03w5Mx4QnWwN zIzZ/XaECbTqXEHfWJncAO/d8ImOF8ETvIZk3MzilLuJwyRit8Un3Zk2T1sM16llAJBR vMew== X-Gm-Message-State: AOAM532pcJrMI/J4JqXppozH9oLDdH8/g1l6IdgTkUJEwBVZSLgjUxCm RQVYu5WUzd4BQeK/QdoZN/ttQ8jXOwmPow== X-Google-Smtp-Source: ABdhPJyGBQ2vFx0wHrMaKd5ANfIecrEWBxDNrhXuWui0sUCG44xWXJCYdFx1vNcGqKSojdinDudLiEQfaHT3mw== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a17:90b:3144:: with SMTP id ip4mr2267169pjb.153.1635809080988; Mon, 01 Nov 2021 16:24:40 -0700 (PDT) Date: Mon, 1 Nov 2021 16:23:45 -0700 In-Reply-To: <20211101232346.1070813-1-wuhaotsh@google.com> Message-Id: <20211101232346.1070813-6-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211101232346.1070813-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v3 5/6] hw/nvram: Update at24c EEPROM init function in NPCM7xx boards From: Hao Wu To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com Received-SPF: pass client-ip=2607:f8b0:4864:20::44a; envelope-from=3OHeAYQgKCjstreXlqpedlldib.Zljnbjr-absbiklkdkr.lod@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, 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+qemu-devel=archiver.kernel.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 a656169f61..8c72024007 100644 --- a/hw/arm/npcm7xx_boards.c +++ b/hw/arm/npcm7xx_boards.c @@ -107,13 +107,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_NONE, 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); } @@ -220,8 +224,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 Mon Nov 1 23:23:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 12597553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C64AC433EF for ; Mon, 1 Nov 2021 23:31:03 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E01D960EE5 for ; Mon, 1 Nov 2021 23:31:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E01D960EE5 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:42690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhglZ-0002HL-Lz for qemu-devel@archiver.kernel.org; Mon, 01 Nov 2021 19:31:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3OneAYQgKCj0vtgZnsrgfnnfkd.bnlpdlt-cdudkmnmfmt.nqf@flex--wuhaotsh.bounces.google.com>) id 1mhgfX-0002JM-4v for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:24:47 -0400 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]:41585) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3OneAYQgKCj0vtgZnsrgfnnfkd.bnlpdlt-cdudkmnmfmt.nqf@flex--wuhaotsh.bounces.google.com>) id 1mhgfV-000316-8H for qemu-devel@nongnu.org; Mon, 01 Nov 2021 19:24:46 -0400 Received: by mail-pf1-x449.google.com with SMTP id r2-20020a627602000000b00480f8ce37abso3514546pfc.8 for ; Mon, 01 Nov 2021 16:24: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=Y1cuabKo+Ks9hRYNhU8759StOoTQ0i2j4/XnXE1Q61g=; b=YcT/fAZEE8kr1aWMQS91oGsXqm9rMPjbxWqYHe4djv6pzXjnaIEzZixlqws3T6+7xm cQD2NwEaEAmhGJpvw4KGiy+CM0mB6MKcwyDLIEjd2RxvBH9mRgeKB9quQ/1kQo01sU/i IkdsogAvatq/oLuDeyDYGvYtlnPBxYu87jUO34oqMMHoC64KnAV3rS3JtD6c39mQgvZ0 SPa0NFu33G1l6GIYM4c8U9tzuBTg4p1oIMb9hz4vCS/oN21qSasCXyRf1HdiGei+ZU32 82lzf3peTaMQv10nvr+0NHVVkoDuEoz6+10xiAYYIyNhMHWU0NeepdyWhmu6cH69aMap C9kg== 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=Y1cuabKo+Ks9hRYNhU8759StOoTQ0i2j4/XnXE1Q61g=; b=In7CXXLeLkjCEksXoB+S00PhPoey435uyx7/zBrMGqlP4sw0Qt1CX73j30Enn8Dlfn YMnuCWWHZBqfpZDvE5Z9ZYcpq8vjsCwthWPb/LOYzkjSTK9ykErsdKrkIUOTgMA+Ly66 5QAlzUXufjO+/84GabzhmWikjfYe6+wqC9UYKlnrVZU3Gp7gUbaio7Icte86/Aqd7Xa/ zdjFtwkJXymvGUy6v0oiiiMMJzGR56VrRYemZwAyAa8ZateiVsPZFsaO83S8hXhHTMgx +53rV3lkCZGK9iPDHdaYwlax177SbD4PnRoBlWyib5AtczaKKHSBN7kUT8HWw721sVGk W+TA== X-Gm-Message-State: AOAM532xALCzab9+ylqBBkAolV3ohiENw3Jc0SDhu60eHni7SqsAbFLO 4Ant4GEbZWvLm4JD9Q/6PhMiH5fFuhUB/Q== X-Google-Smtp-Source: ABdhPJzPbwyv1odjLqqTcT5OeRrqyn7b57gW6pY9vaDXcQGxkujbK4WwmU7afp0Vf6XVsJ5IGQ2dbvGAgtbJUg== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a17:902:b70f:b0:141:88fb:6506 with SMTP id d15-20020a170902b70f00b0014188fb6506mr27295438pls.28.1635809082537; Mon, 01 Nov 2021 16:24:42 -0700 (PDT) Date: Mon, 1 Nov 2021 16:23:46 -0700 In-Reply-To: <20211101232346.1070813-1-wuhaotsh@google.com> Message-Id: <20211101232346.1070813-7-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211101232346.1070813-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v3 6/6] hw/arm: quanta-gbs-bmc add i2c devices From: Hao Wu To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com Received-SPF: pass client-ip=2607:f8b0:4864:20::449; envelope-from=3OneAYQgKCj0vtgZnsrgfnnfkd.bnlpdlt-cdudkmnmfmt.nqf@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+qemu-devel=archiver.kernel.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 8c72024007..e3f0d337ab 100644 --- a/hw/arm/npcm7xx_boards.c +++ b/hw/arm/npcm7xx_boards.c @@ -257,10 +257,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 @@ -269,46 +271,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 */