From patchwork Mon Aug 20 20:26:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 144665 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4417883ljj; Mon, 20 Aug 2018 13:40:22 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYGFB/E2JOMVjwBrKbqLYNNkQiG2lGelNddbvTadb4ZBukyPUKkAmg0drb7J2E8oSXRPioC X-Received: by 2002:a37:6747:: with SMTP id b68-v6mr4099047qkc.108.1534797622357; Mon, 20 Aug 2018 13:40:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534797622; cv=none; d=google.com; s=arc-20160816; b=mJIxy0m1WttBnvWCLBiddSWoZhKXNidMGuYapnT6WiJM8xTLKMLv8YEDejOoBeRNvA paAWqEtYe2fCbqOj6eaGnwAjRehyp/2z768rVptlFPaM8w3cwYHy9LJ94WrLjiU9tvez 8DZLi8QhldSNUY9srp67BgqJvdCToy+Z33Hdh0Egcwlsdf9yfKeZQTin9uOxSYO7LuL9 laq257ix/+EFbmwPhs3idO/s1qy5+QwYOigQ4ZfoiwJnAMUiri0s4xlkLAHprhFlG3VQ nG+t8Ni96tnCRSMk3exMG9I5vm7PV3FjeKpKCp31x/sZa5gnf6uMVX7th/07/fYow74b JHFA== 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=IJQAbtRGAP1eRHGmjX5N0dPohyN92tJOEZD+Yo0r4Ao=; b=K8AX73GY4seAHG675Om2IrpAGkUn7OKql4ztJSSVMBezHv7T5LP2nR2Fev11Kuipau qOBQPh5mivQylkGnu0J4/qo7IwSUCLhV5oqg3rfvCdScs4OHx1rXq72RayBfgfa9HO5k HA+XCKJJoIG496Q7Jyn3U4AnPOKPQAEjg43uGVYJ272VQGWPOQhcxf1+IYuu8h5K/xsq Mpvvy8mgtj/Nle3ZeQnPraUgvDAakzww9kdsZlRhnc3BlZ1IehJ+GOdEespoMSYtiWvv O+21OlTIC+QKDZSXH+NNlCooq4OvvTJB0a9yS1qrKXLBKTiF9JXKOyzuBO1C2XOGuJ8H B2BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=SPYH9S5H; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m14-v6si584183qvo.155.2018.08.20.13.40.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 20 Aug 2018 13:40:22 -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=SPYH9S5H; 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" Received: from localhost ([::1]:49198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frqyL-0003o6-Nn for patch@linaro.org; Mon, 20 Aug 2018 16:40:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frqll-0003Ht-Ez for qemu-devel@nongnu.org; Mon, 20 Aug 2018 16:27:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frqlb-0003qP-Gb for qemu-devel@nongnu.org; Mon, 20 Aug 2018 16:27:14 -0400 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:45840) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frqlR-0003Nr-Qq for qemu-devel@nongnu.org; Mon, 20 Aug 2018 16:27:05 -0400 Received: by mail-oi0-x232.google.com with SMTP id q11-v6so28135827oic.12 for ; Mon, 20 Aug 2018 13:26:57 -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=IJQAbtRGAP1eRHGmjX5N0dPohyN92tJOEZD+Yo0r4Ao=; b=SPYH9S5HReV1wto2AE4zhOrVa1aEd5NJL05hUQfhH2ookwY++8e2Rk6gi3Yuv3EYqO H/QZed0kSsHy2mBDBkh5r4jYkgQM5i5wuKB92eT+iZafJyjH/+oJj9ibDipGvpg3cEFm Hm359o5pfgwaaC9DprXJJ6OsS75e8nYmt0H46gPAWQUP1tfaksJbeFyWfG+mM6NpVzTj 9UDyk94wa946jb+EG5RDffPMGofC4yPwGWi0aOFvL8a/W7MmoqoR+vWWtKA3QWyokqYI 9DYO24NSqi76JqPYI9ExfpV+PNAwt/dZOpqfCpv9z4uihgIIz/PYYqYtnD6jDWPkI7gI Yhvw== 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=IJQAbtRGAP1eRHGmjX5N0dPohyN92tJOEZD+Yo0r4Ao=; b=E7tjaco1O/oq41vJ1BYU4LCsCKA7uC/h3qAd8JlLw6TuHZPERam4WMPtHFew1OCGMI 3vfNyFMEYOrVzF977sEBYAHfOvpo1AQGuVkGEESA1WC5q3zRtqU35yeqrRmFAnQE9gkW m3JjPy2IoIdrJZLfLJS/Ppq+Xg6jGsirZyZ2TVI+/WLWakS6GdZdeColsvEKP5eE9UZL o8GTt3nHfyNMBGhnqdD6xa+YODqz0qCwbUhzwAxnv2LWDGzJfJgTsOdlmFFvawir6HX7 Xat+Tj16tQ62m5Ewt6yAxRbaawSR8kHiuw0e35iu2xGl3doWBUbnklHruYxtsaduVA8Z NJbw== X-Gm-Message-State: AOUpUlHHa9FsrsZkQ4ftR5moPLW5tslljD9JHtIVrqXmjk5udHd8kToe ureH1og6+Q9Bm8IOekAFsjvoMF4= X-Received: by 2002:aca:e184:: with SMTP id y126-v6mr14576325oig.313.1534796817042; Mon, 20 Aug 2018 13:26:57 -0700 (PDT) Received: from serve.minyard.net ([47.184.170.128]) by smtp.gmail.com with ESMTPSA id v202-v6sm11017123oie.47.2018.08.20.13.26.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 13:26:56 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:7d98:76b7:e7fd:495f]) by serve.minyard.net (Postfix) with ESMTPA id 69DBC1271; Mon, 20 Aug 2018 15:26:24 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id A6C4D300109; Mon, 20 Aug 2018 15:26:21 -0500 (CDT) From: minyard@acm.org To: Paolo Bonzini , qemu-devel@nongnu.org Date: Mon, 20 Aug 2018 15:26:06 -0500 Message-Id: <1534796770-10295-7-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534796770-10295-1-git-send-email-minyard@acm.org> References: <1534796770-10295-1-git-send-email-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::232 Subject: [Qemu-devel] [PATCH v2 06/10] 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 --- hw/i2c/pm_smbus.c | 14 +++++++++++++- hw/i2c/smbus_ich9.c | 19 ++++++++++++++++++- include/hw/i2c/pm_smbus.h | 2 ++ 3 files changed, 33 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 9e11d47..664a6b1 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 c8b8413..316c2a4 100644 --- a/hw/i2c/smbus_ich9.c +++ b/hw/i2c/smbus_ich9.c @@ -40,15 +40,18 @@ typedef struct ICH9SMBState { PCIDevice dev; + bool irq_enabled; + PMSMBus smb; } ICH9SMBState; static const VMStateDescription vmstate_ich9_smbus = { .name = "ich9_smb", - .version_id = 2, + .version_id = 3, .minimum_version_id = 1, .fields = (VMStateField[]) { VMSTATE_PCI_DEVICE(dev, ICH9SMBState), + VMSTATE_BOOL_V(irq_enabled, ICH9SMBState, 3), VMSTATE_STRUCT(smb, ICH9SMBState, 2, pmsmb_vmstate, PMSMBus), VMSTATE_END_OF_LIST() } @@ -110,11 +113,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 b1e1970..cfe596f 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. */