From patchwork Tue Aug 21 17:02:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 144770 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp5555312ljj; Tue, 21 Aug 2018 10:39:06 -0700 (PDT) X-Google-Smtp-Source: AA+uWPznbfmZiLlMDeSHsb2ghnmMZ1mOJYi/bVt/8jY9ypfmCVzYSm4/xwGTlw8dZFSsRkyRRnal X-Received: by 2002:ac8:2575:: with SMTP id 50-v6mr20914372qtn.88.1534873146116; Tue, 21 Aug 2018 10:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534873146; cv=none; d=google.com; s=arc-20160816; b=vs88G/8EUnd0zUQMD5V0CgMNosyjKQTL4PkrXiO2p+uRFeJlH3pryfAO1toSg84j55 9EqmZDx9+h3COWa/IEx8B6vmFnkj0QtJ2G1hMu+cdwmu7wnp+5tQMl4NgGUdQloHBDFf plnQQChk5jEzpWRY7QKamf6L3nqA72dQAGYnbMfOquonUxBCW2smofMUzJjidn8HWQyQ +gPp0YGytFVi/BSQxrAwQrgTBtN7xRzCyHxiAZ3XNy1sxB6oGdnh+PLLiR2arhMOPhAz PvlWQ6bFAc9OV92cmauAza5zb7LkfSSd1DF2CPDX7Go11zkk3Lcy5o0fE6raKIczBlCN Rirg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=VUitJI+l9JViJbfK5zml7cSDVsgzItJZaGFga0cII3A=; b=eqICZxVkyyttsKR2AcAMj83FH+oPaTRTukvtzbvp7EfJ9+1vbTu2RZCLfEu4kPPApH SvqQKLYjNceVwrDIlOkBGVQ3tYs77RA2BB9hnN0Et3T56l4ZsRFczEEsPjza8yvtKrW5 xM4MSTN8w06mF8DfCIlwRqMVGUPOGPYnW8Dtydm2yoT1ofAfUnAdwxjfkJxAJ9+yELgN b7c3Y/xrwP64fMPcPjBiUncFb3YHvZuquSzj67nPZWOEflrW8f2zvvdfhcE2ILxw+VbB oBcGZxqCwh+eVcpXuMjE0G0SQEEpL5Pqoxz0Q822WW/tZqjKUdQmI6sKzNkotS1QauTP OTsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VRuDUG8Z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k42-v6si4910518qtf.286.2018.08.21.10.39.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 21 Aug 2018 10:39:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VRuDUG8Z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:55126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsAcT-0002Ws-GY for patch@linaro.org; Tue, 21 Aug 2018 13:39:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsA56-0002a9-W5 for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsA4o-0007D3-HZ for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:31 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:45852) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsA4n-00076D-NG for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:18 -0400 Received: by mail-wr1-x42f.google.com with SMTP id 20-v6so10508612wrb.12 for ; Tue, 21 Aug 2018 10:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VUitJI+l9JViJbfK5zml7cSDVsgzItJZaGFga0cII3A=; b=VRuDUG8Za6wCWYL6UIxHTWqmNn30LbSBcdnc+jRKweLNRS/547LN0Ja5DX7XParPzR y/8crlQaiHRG+7dCxjEGxL1RhAu9bow3LLsfWExQULNdr2Stw7GXp0XxTlwuoNnNsVw8 f8hcY4sQR6Ozyvix583i4w6AqUV9sTNj+ghU93UMMjVccFihTTtH34mVs73O5MiUBbqW GafQU0zjbLQqxN6plxY9s/jTb8AAGW8qO0e0GYb4zc6LsZXBOZjFAhD0bzQGm1qlWwmw M2O0wbqhg2KCI42hRkYMaNOVXJDZgfkvpt2blKiS1+SmFitZGUFlbSqX6SD+R7GmnFeL 565w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=VUitJI+l9JViJbfK5zml7cSDVsgzItJZaGFga0cII3A=; b=I5c1XekBgprEBx7f9PsUNYa/jJI7fI+4+JO6wHLpmoo3DmAbEwrz1/lfMIHL5humrC 5iX1D5AF8x+PzD7fXOlBNh7ZvEI5p+JGG3jNTDZO5m54fKpqlmNmu3tr7R72gfOu3FMf Fl9foEvEjRSqNlY9L1XByVxntiiexgUR37JMScmiODF+jP6jnrTc98ZWZCQEghJl4GO5 BTHAqJeKdw42cIuuTEIXELIwErgOgu/mXGCmS98F8rvQ0pibBZi73CUl7fSQF1wadIgD FmdLJhVD2pftlK3j6eq2QYJoZVwDVBoFrbGe7r8qRlrNgfp1+vGkPaWBFj4v0QOE/9Py Yuxw== X-Gm-Message-State: APzg51DCg8n6u92lVe49+0p4l/Rk4WRuMfSQMwRPmFbbXm4Hjc6pXaV5 dFr756/Pj0neYlpPJ581VVU5maCX X-Received: by 2002:a5d:4605:: with SMTP id t5-v6mr998866wrq.200.1534871053160; Tue, 21 Aug 2018 10:04:13 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v6-v6sm2608955wmc.43.2018.08.21.10.04.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 10:04:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 19:02:38 +0200 Message-Id: <1534870966-9287-67-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> References: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f Subject: [Qemu-devel] [PULL 66/74] i2c: pm_smbus: Add interrupt handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Add the necessary code so that interrupts actually work from the pm_smbus device. Signed-off-by: Corey Minyard Cc: Michael S. Tsirkin Cc: Paolo Bonzini Message-Id: <1534796770-10295-7-git-send-email-minyard@acm.org> Signed-off-by: Paolo Bonzini --- hw/i2c/pm_smbus.c | 14 +++++++++++++- hw/i2c/smbus_ich9.c | 16 ++++++++++++++++ include/hw/i2c/pm_smbus.h | 2 ++ 3 files changed, 31 insertions(+), 1 deletion(-) -- 1.8.3.1 diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 32132be..6322f07 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -214,6 +214,12 @@ static void smb_transaction_start(PMSMBus *s) s->smb_stat |= STS_HOST_BUSY; } +static bool +smb_irq_value(PMSMBus *s) +{ + return ((s->smb_stat & ~STS_HOST_BUSY) != 0) && (s->smb_ctl & CTL_INTREN); +} + static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, unsigned width) { @@ -309,7 +315,9 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, } out: - return; + if (s->set_irq) { + s->set_irq(s, smb_irq_value(s)); + } } static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width) @@ -365,6 +373,10 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width) SMBUS_DPRINTF("SMB readb port=0x%04" HWADDR_PRIx " val=0x%02x\n", addr, val); + if (s->set_irq) { + s->set_irq(s, smb_irq_value(s)); + } + return val; } diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c index a66a114..522a703 100644 --- a/hw/i2c/smbus_ich9.c +++ b/hw/i2c/smbus_ich9.c @@ -40,6 +40,8 @@ typedef struct ICH9SMBState { PCIDevice dev; + bool irq_enabled; + PMSMBus smb; } ICH9SMBState; @@ -109,11 +111,25 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data) dc->user_creatable = false; } +static void ich9_smb_set_irq(PMSMBus *pmsmb, bool enabled) +{ + ICH9SMBState *s = pmsmb->opaque; + + if (enabled == s->irq_enabled) { + return; + } + + s->irq_enabled = enabled; + pci_set_irq(&s->dev, enabled); +} + I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base) { PCIDevice *d = pci_create_simple_multifunction(bus, devfn, true, TYPE_ICH9_SMB_DEVICE); ICH9SMBState *s = ICH9_SMB_DEVICE(d); + s->smb.set_irq = ich9_smb_set_irq; + s->smb.opaque = s; return s->smb.smbus; } diff --git a/include/hw/i2c/pm_smbus.h b/include/hw/i2c/pm_smbus.h index 99d5489..1afa3cf 100644 --- a/include/hw/i2c/pm_smbus.h +++ b/include/hw/i2c/pm_smbus.h @@ -23,6 +23,8 @@ typedef struct PMSMBus { /* Set by the user. */ bool i2c_enable; + void (*set_irq)(struct PMSMBus *s, bool enabled); + void *opaque; /* Internally used by pm_smbus. */