From patchwork Thu Dec 7 21:46:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121094 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8903050qgn; Thu, 7 Dec 2017 13:51:40 -0800 (PST) X-Google-Smtp-Source: AGs4zMY3XohNe8B/5OZ6oNI/2lGYJp9Hj9f19mYzTHlunRbjtagFbkECTIj/VgIbWOQWDa1TmXF6 X-Received: by 10.37.183.140 with SMTP id n12mr9748102ybh.9.1512683500485; Thu, 07 Dec 2017 13:51:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683500; cv=none; d=google.com; s=arc-20160816; b=PMQxEzvQp3j7Vg7gZ3vasdH2riOHI2pOohFefHJuaiEsv8yHpTTJOHLBhDYZ/nlqT1 gZ3d1SVT7zI+IaEDtPtrC0S6E02zqmkmEqc8FvAqTyyl8dBX9NCXbPORMAAofRREwSuD ZEe3S/8NHfHIMpskYArW5IA4WCP4xtK0l0jVoWHkgIZ4N0Noqhho7ND4YOQZjTF7xCZ0 oBVMQYgnz0Auvfi/reZhft8CtmQwrHPRF3K99at4jVcSBD5E0HH7bt3KgE/dWR3zm08a MtAJ54oD6tL3uEMpc5PueojU/55cL8XT1LG1tgviEmF1QgnJj5wm/ijxqFgbP+8f2WYq a4Yw== 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=H9QSCS0RwFyWJma1fSfB50PbGNN6KaKfHl1fy3q1SE8=; b=XmpX5XucSGFtPfqMTTaFQVgjuHDp+aGDTZVnzuDv6uNgLGugxAJ8tqdGveN1lhds/E hFsVqHM2EczRUdcTyiYYNr5NbPbKJ8YqqgjmAiDHPEtng3ETrnCohlc/aGURtNlpXKdN m5ne2ewBLXjQUxVW9ySapYrOINaZXgPmDUVCdj0gIe3Jle4n5Vsw54p4qeMDB7ZsvIv3 eewGlxW/jdnbDngebfWPKK96HHtv4RAjWKcshUCzltz9SKvAN1HQYvTKcladi0q8fnQW Pgp9uvN7TtsStASIChKTFXmmRXzi66nhjLy90Jsv3tjsxzwA0ko2SYa9KIZx9Kuacxm8 XYWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=JhlcZi8c; 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 j69si1339394ybg.58.2017.12.07.13.51.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:51:40 -0800 (PST) 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=JhlcZi8c; 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]:34516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN44x-0007Qx-TE for patch@linaro.org; Thu, 07 Dec 2017 16:51:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN3zz-0003zq-H6 for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN3zy-0006L7-E9 for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:31 -0500 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:32902) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN3zy-0006KM-5D for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:30 -0500 Received: by mail-pg0-x242.google.com with SMTP id g7so5397961pgs.0 for ; Thu, 07 Dec 2017 13:46:30 -0800 (PST) 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=H9QSCS0RwFyWJma1fSfB50PbGNN6KaKfHl1fy3q1SE8=; b=JhlcZi8cC3OfcuZsPTu0P8jNVp50EGg2QaLd4j6n+iV6XTG4vaCnRmCzcc9Q1UZylv P0rbwuPWDUMojJwLrnxp5EjV/WCfsWK/c1UWEpoz6gnaFcJOtHzsuzKuQxfBiQefvAHu ntt2E0VMrMViRLcSxvnDMzsIpDgrIugH98gtsJ0hRmIFeZVm06Zfe9FjWitVwMkH+Kzi Xs2anP/AjyYX7PjjFgqO+SVEE2CXSq9M+UzjLCFKUi6fwvCDVpk4debwKEsOlGsJ0CCQ l+REAJS/RDcoi7S3C7seg9GJyJkN7HPNsrY8DKG1vYxDu0JTdMQmSxs384W5g2KqCO8H APFA== 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=H9QSCS0RwFyWJma1fSfB50PbGNN6KaKfHl1fy3q1SE8=; b=oEU2QkqG+IV6DEb5m3+5m2kMCjWS1wuQoLD2UmZRQGjz7Dx7z+Ue6qZaajkDWEWJ9d y7GjYqfioRRIueQEcuEt5YSzexsUJZhqufGKn59Y0h5VpgoI75VgU+9BfJTfYsdgoBtt 83KmCLEL5R2924uDUACwCHyJ0GuWYKz1Vxcx/naO/SR5bnRwx41H96HwDQoknlBfHYL4 d41BrMADwyT+OFmDQ2UNvI0sOAXkncDPQWak5zF4Xfiog/3s5bIara/OP7Jupp8MoZgd AcA0YJHZnxYg10ii3ljQzmS82UpZMZmEpIWRC5kpzSOKZtjnUhs8N6992clsqHdS9Veu yH3w== X-Gm-Message-State: AJaThX4VIvZC7/9P3O0bdXf575CSoys3wIQ9YBE/6oITZbUbx3Zot9l+ O+vmW9fxGJn5ZCiA1w6FENH1KME= X-Received: by 10.99.95.70 with SMTP id t67mr26984937pgb.49.1512683189069; Thu, 07 Dec 2017 13:46:29 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id t202sm8933213pgb.75.2017.12.07.13.46.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:26 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id CD93C8F4; Thu, 7 Dec 2017 15:46:23 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id BF95430000E; Thu, 7 Dec 2017 15:46:22 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:08 -0600 Message-Id: <1512683181-8420-2-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c05::242 Subject: [Qemu-devel] [PATCH 01/14] i2c:pm_smbus: Clean up some style issues 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 , Paolo Bonzini , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Fix some spacing issues, remove extraneous comments, add some defines instead of hard-coding numbers. Signed-off-by: Corey Minyard Cc: Michael S. Tsirkin Cc: Paolo Bonzini --- hw/i2c/pm_smbus.c | 58 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 6fc3923..92c3aebd 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -23,8 +23,6 @@ #include "hw/i2c/pm_smbus.h" #include "hw/i2c/smbus.h" -/* no save/load? */ - #define SMBHSTSTS 0x00 #define SMBHSTCNT 0x02 #define SMBHSTCMD 0x03 @@ -33,19 +31,34 @@ #define SMBHSTDAT1 0x06 #define SMBBLKDAT 0x07 -#define STS_HOST_BUSY (1) -#define STS_INTR (1<<1) -#define STS_DEV_ERR (1<<2) -#define STS_BUS_ERR (1<<3) -#define STS_FAILED (1<<4) -#define STS_SMBALERT (1<<5) -#define STS_INUSE_STS (1<<6) -#define STS_BYTE_DONE (1<<7) +#define STS_HOST_BUSY (1 << 0) +#define STS_INTR (1 << 1) +#define STS_DEV_ERR (1 << 2) +#define STS_BUS_ERR (1 << 3) +#define STS_FAILED (1 << 4) +#define STS_SMBALERT (1 << 5) +#define STS_INUSE_STS (1 << 6) +#define STS_BYTE_DONE (1 << 7) /* Signs of successfully transaction end : * ByteDoneStatus = 1 (STS_BYTE_DONE) and INTR = 1 (STS_INTR ) */ -//#define DEBUG +#define CTL_INTREN (1 << 0) +#define CTL_KILL (1 << 1) +#define CTL_LAST_BYTE (1 << 5) +#define CTL_START (1 << 6) +#define CTL_PEC_EN (1 << 7) +#define CTL_RETURN_MASK 0x1f + +#define PROT_QUICK 0 +#define PROT_BYTE 1 +#define PROT_BYTE_DATA 2 +#define PROT_WORD_DATA 3 +#define PROT_PROC_CALL 4 +#define PROT_BLOCK_DATA 5 +#define PROT_I2C_BLOCK_DATA 6 + +/*#define DEBUG*/ #ifdef DEBUG # define SMBUS_DPRINTF(format, ...) printf(format, ## __VA_ARGS__) @@ -68,11 +81,12 @@ static void smb_transaction(PMSMBus *s) if ((s->smb_stat & STS_DEV_ERR) != 0) { goto error; } + switch(prot) { - case 0x0: + case PROT_QUICK: ret = smbus_quick_command(bus, addr, read); goto done; - case 0x1: + case PROT_BYTE: if (read) { ret = smbus_receive_byte(bus, addr); goto data8; @@ -80,7 +94,7 @@ static void smb_transaction(PMSMBus *s) ret = smbus_send_byte(bus, addr, cmd); goto done; } - case 0x2: + case PROT_BYTE_DATA: if (read) { ret = smbus_read_byte(bus, addr, cmd); goto data8; @@ -89,16 +103,17 @@ static void smb_transaction(PMSMBus *s) goto done; } break; - case 0x3: + case PROT_WORD_DATA: if (read) { ret = smbus_read_word(bus, addr, cmd); goto data16; } else { - ret = smbus_write_word(bus, addr, cmd, (s->smb_data1 << 8) | s->smb_data0); + ret = smbus_write_word(bus, addr, cmd, + (s->smb_data1 << 8) | s->smb_data0); goto done; } break; - case 0x5: + case PROT_I2C_BLOCK_DATA: if (read) { ret = smbus_read_block(bus, addr, cmd, s->smb_data); goto data8; @@ -149,8 +164,9 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, break; case SMBHSTCNT: s->smb_ctl = val; - if (val & 0x40) + if (s->smb_ctl & CTL_START) { smb_transaction(s); + } break; case SMBHSTCMD: s->smb_cmd = val; @@ -185,7 +201,7 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width) break; case SMBHSTCNT: s->smb_index = 0; - val = s->smb_ctl & 0x1f; + val = s->smb_ctl & CTL_RETURN_MASK; break; case SMBHSTCMD: val = s->smb_cmd; @@ -208,7 +224,9 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width) val = 0; break; } - SMBUS_DPRINTF("SMB readb port=0x%04" HWADDR_PRIx " val=0x%02x\n", addr, val); + SMBUS_DPRINTF("SMB readb port=0x%04" HWADDR_PRIx " val=0x%02x\n", + addr, val); + return val; } From patchwork Thu Dec 7 21:46:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121100 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8906651qgn; Thu, 7 Dec 2017 13:56:06 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ72jGU2lNKe7oHxpIvyj7goUg0aTuQulsSmbiC3yM5UGFXN/GYPt0heKfB+/cKI06PNTrM X-Received: by 10.37.231.129 with SMTP id e123mr764877ybh.137.1512683766844; Thu, 07 Dec 2017 13:56:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683766; cv=none; d=google.com; s=arc-20160816; b=UbDLLX7BfNQ/9136u0CGNL4jqjvuf8GLFySGVxTEcL4KahmMT6SjQ2MuY3+IXmsprZ A0VNgK3kfZyijGMi5wwswUXP6c9zd/gBu5IGBRpBY65bAgk6LFct/NlioZxsdFv2D+3/ ixZye3BgNoL3fZrAfTkhxtvRVfG0f9J+4G6E0w3vd1w8vwY+TXKrsPXOqJY/YJnjelXX 9SC64HES6u6gljVn2bu6ceyK3da7fgVHQv1eh1z4gk0jNGniVsagMsf4VrvrjJ9FEU1H NTWlEDFohNfSAcgywdcKvBZEKXK6O7VgDOcDs2HO4Qf8yWSkh2TRXIFCgsC3lqye/BYE rTcA== 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=WHrimqKmkjyLEmn1gNtbYkUZxVq1HyjZWMrrEDTcNTo=; b=a/Z3PudgGMEDih34tM2qJk4BtwYoTRz2zTE/TcOfGl0wLAGHcu1t0wkXWcJSGGDDkL nE2BfuVGI8+KHpodkKYsDBtYw7Qx22uAdETqqNryCT5XIzJmLEglnAMKuPLHsM6jGYJs p942ZHluJaNNVww/CWgcgkJZVAiWLsO7fAnrj90KVKT1uOe6hhu4X/V0Cn5kPm8KR1rT PRCRgqshKeboDoZIZQdLPH2iLUByyaVAgIRSGDNo6VnSH6H26nBDgVJnvbZyq3DhPPEx Q8q53H5mx1X4yt2fNceUUU5fxgr7cCIQBjHzPxnpMsVkAyaaWa8e2jSFMvWLzhmZw4GL H/RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=r3sDHMME; 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 d188si1307853ybh.94.2017.12.07.13.56.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:56:06 -0800 (PST) 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=r3sDHMME; 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]:34539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN49G-00057V-B0 for patch@linaro.org; Thu, 07 Dec 2017 16:56:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN3zz-000406-Pp for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN3zx-0006K3-GV for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:31 -0500 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:45556) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN3zx-0006JR-97 for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:29 -0500 Received: by mail-pg0-x242.google.com with SMTP id m25so5377697pgv.12 for ; Thu, 07 Dec 2017 13:46:29 -0800 (PST) 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=WHrimqKmkjyLEmn1gNtbYkUZxVq1HyjZWMrrEDTcNTo=; b=r3sDHMMEGkTrX1ZIiggpcNqmw4GvsgMNBHzq7FynVANLU1UtsJUext7bsPIRbJLbCz RakA5FOcYgrzQne01p9w00FDMUlXMFYHjlxW/ytq5txXrVeQ/2o6I5/ifEpQViHuPYUh wFEbFxzkZdV5qGadlMWJ66W0gy5X8GrtTm7byhKDc0OrsVwMcCo85HE11XTyYyhq6w0u tJ5OVgTIQbrTLKbGnRGIJ62iky8Po8k1ZmcGgoBOej24+zMmcJVYVF0Q2XhReyzMBcsn xcwZuIxJ71GgsJYISlVwNUjfw8Vf24NtKAlo+qXV+EXpwZW+wfv9waDhMDGcNKLZYlkM 4syA== 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=WHrimqKmkjyLEmn1gNtbYkUZxVq1HyjZWMrrEDTcNTo=; b=SYrkvTkBkynSd94ZUSJ34bJEBMkMFdpkbS4EmL3mtUXxU/rs6dEGYHD5m83sq+fAyW 72RnvT2EPctx7QEw7Lw7PMlET7wgXy8f2yBofG1IoJc3jPmSzOqIq/7+HrcjTcXLBxI6 +Zv7fX3YV26joIlLV1LcqfYtSccsaOoCHVrXp4bpV6L7C3nnsAjRwh4b3ZzA2BCODING 6LJtMwsCvIqijyHdWUtJrPlwuCdSEee9A7tc8obIvGRPMnkKTXz9StGskg2yE9v8MP5m nqejYuN2XaKj6RlbMemM/ebiln/lew0THSzJK/m4USH+uYCjB9q/SnaEcOVgHO1p+bhd sSnw== X-Gm-Message-State: AJaThX4VWsmnSd7X0uRODCI5837VGQoOrVqcroq07WnN8X6cXtKZQ/Ll Ru4jPCQNy+vhkzEWzsxDIA+QubQ= X-Received: by 10.99.152.68 with SMTP id l4mr27256195pgo.208.1512683188127; Thu, 07 Dec 2017 13:46:28 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id y5sm11252936pfd.63.2017.12.07.13.46.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:26 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id E46A6901; Thu, 7 Dec 2017 15:46:23 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id DD0E130007F; Thu, 7 Dec 2017 15:46:22 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:09 -0600 Message-Id: <1512683181-8420-3-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c05::242 Subject: [Qemu-devel] [PATCH 02/14] i2c:pm_smbus: Fix the semantics of block I2C transfers 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 , Paolo Bonzini , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard The I2C block transfer commands was not implemented correctly, it read a length byte and such like it was an smbus transfer. So fix the smbus_read_block() and smbus_write_block() functions so they can properly handle I2C transfers, and normal SMBus transfers (for upcoming changes). Pass in a transfer size and a bool to know whether to use the size byte (like SMBus) or use the length given (like I2C). Signed-off-by: Corey Minyard Cc: Michael S. Tsirkin Cc: Paolo Bonzini --- hw/i2c/pm_smbus.c | 10 ++++++++-- hw/i2c/smbus.c | 37 ++++++++++++++++++++++++------------- include/hw/i2c/smbus.h | 17 +++++++++++++++-- 3 files changed, 47 insertions(+), 17 deletions(-) -- 2.7.4 diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 92c3aebd..679edbc 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -115,10 +115,16 @@ static void smb_transaction(PMSMBus *s) break; case PROT_I2C_BLOCK_DATA: if (read) { - ret = smbus_read_block(bus, addr, cmd, s->smb_data); + int xfersize = s->smb_data0; + if (xfersize > sizeof(s->smb_data)) { + xfersize = sizeof(s->smb_data); + } + ret = smbus_read_block(bus, addr, s->smb_data1, s->smb_data, + xfersize, false, true); goto data8; } else { - ret = smbus_write_block(bus, addr, cmd, s->smb_data, s->smb_data0); + ret = smbus_write_block(bus, addr, cmd, s->smb_data, s->smb_data0, + false); goto done; } break; diff --git a/hw/i2c/smbus.c b/hw/i2c/smbus.c index 2d1b79a..4b0e264 100644 --- a/hw/i2c/smbus.c +++ b/hw/i2c/smbus.c @@ -301,33 +301,42 @@ int smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data) return 0; } -int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data) +int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data, + int len, bool recv_len, bool send_cmd) { - int len; + int rlen; int i; - if (i2c_start_transfer(bus, addr, 0)) { - return -1; + if (send_cmd) { + if (i2c_start_transfer(bus, addr, 0)) { + return -1; + } + i2c_send(bus, command); } - i2c_send(bus, command); if (i2c_start_transfer(bus, addr, 1)) { - i2c_end_transfer(bus); + if (send_cmd) { + i2c_end_transfer(bus); + } return -1; } - len = i2c_recv(bus); - if (len > 32) { - len = 0; + if (recv_len) { + rlen = i2c_recv(bus); + } else { + rlen = len; } - for (i = 0; i < len; i++) { + if (rlen > len) { + rlen = 0; + } + for (i = 0; i < rlen; i++) { data[i] = i2c_recv(bus); } i2c_nack(bus); i2c_end_transfer(bus); - return len; + return rlen; } int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data, - int len) + int len, bool send_len) { int i; @@ -338,7 +347,9 @@ int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data, return -1; } i2c_send(bus, command); - i2c_send(bus, len); + if (send_len) { + i2c_send(bus, len); + } for (i = 0; i < len; i++) { i2c_send(bus, data[i]); } diff --git a/include/hw/i2c/smbus.h b/include/hw/i2c/smbus.h index 544bbc1..f1b8078 100644 --- a/include/hw/i2c/smbus.h +++ b/include/hw/i2c/smbus.h @@ -73,9 +73,22 @@ int smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command); int smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data); int smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command); int smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data); -int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data); + +/* + * Do a block transfer from an I2C device. If recv_len is set, then the + * first received byte is a length field and is used to know how much data + * to receive. Otherwise receive "len" bytes. If send_cmd is set, send + * the command byte first before receiving the data. + */ +int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data, + int len, bool recv_len, bool send_cmd); + +/* + * Do a block transfer to an I2C device. If send_len is set, send the + * "len" value before the data. + */ int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data, - int len); + int len, bool send_len); void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom, const uint8_t *eeprom_spd, int size); From patchwork Thu Dec 7 21:46:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121093 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8902744qgn; Thu, 7 Dec 2017 13:51:19 -0800 (PST) X-Google-Smtp-Source: AGs4zMackRNd6m989SEdEPst/D/TeGbCbLSGst+iM/k2GKEMqmISLJxrLIZuaIJEXvkxyO2NaVJw X-Received: by 10.13.244.130 with SMTP id d124mr19337689ywf.383.1512683479116; Thu, 07 Dec 2017 13:51:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683479; cv=none; d=google.com; s=arc-20160816; b=YhXC+vcuZ4sJC4jVozrypRmzjis9oU6WuRDUxAGZga4IldEisj7GX1jRuJr5jU7Cbd XahzB3xwPgJoAtKSdfP9b/lm0/qhk1tUO3dvob//+zP0wUOvx+d6+PfoFGMUkZlT6lax kYGbvAbJVVzlY9qOFCChJeEJs2yPlexIcLHiBRPfrHvyyWHoFypgs+uKO1Ca76BE/6Rd cvW8RRo0hcVhgDA/s9Z8xDOXvMAwNykBV6wXxzjTVscFMWTVPJD0/bHmrWEEVt8T0Sql n2ijWAdfC67+ETDaCe3C69evzX/0K9VzcDQzww0CFw0d4b/dRgFYikRQqMfbb7w+w/9n pQDg== 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=LbXGo01FGRf4/MoNZZjc4oYZ1YnM6tEfV05xWgFZQLM=; b=hGwQXq3m2+YuHpf+YPgPbUfr4L6lTNd/6+780QC9A4boJsEOw8SjV8zmb2cGA5w7zA HmlIiz2DJD/BeFK6RyX64nko/EkNPPKmVTjjY74Sa8au04OxROvgq0rLuphpuyYrR7mZ trwnzkikqfMSH/jrWJ6S1oki9h0PUmH/613FUN4nq7/lkMXHrOHgVzRHKoX4XjsGZyKO YlvpIHbNSD6Rk8snKS9JgnSYkti506GxW4FOk794gcpy818tztH4jcyUiYAVbngtYkM7 jNiCGJfwdR6JLOkZLzFb3CQH870z1BOj3w2LndbWUPhapW/vD80Z4N9idyN/k12c+DKO 0EOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=aPsKYV5J; 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 i131si463081ybi.200.2017.12.07.13.51.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:51:19 -0800 (PST) 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=aPsKYV5J; 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]:34519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN44c-0007tb-K6 for patch@linaro.org; Thu, 07 Dec 2017 16:51:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN3zz-000404-PM for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN3zw-0006JK-Lh for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:31 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:36362) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN3zw-0006Im-FJ for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:28 -0500 Received: by mail-pf0-x242.google.com with SMTP id p84so5683094pfd.3 for ; Thu, 07 Dec 2017 13:46:28 -0800 (PST) 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=LbXGo01FGRf4/MoNZZjc4oYZ1YnM6tEfV05xWgFZQLM=; b=aPsKYV5JHxTjjgCtp8AdUYPRzUaRUvdNrtdEzsMGvkbhOJlqU0jV+FQVDK53mV4E+H C/MMbRgAVbUM7szGiIPrKu2bQMr4QEItcEpKe/ieTJNYPxxc9J+MlPmCOO79kGr5LlHU 7X6S4b80A+5yfuc5bafSzqvUSvLr2hg6Ld45aaVWsWp52I55rlG6t1w41eKKjbZjvr1e l+0pBuRlR60lj4KUIFBm90l60DQHECYCrQiuR2qU43P9Q4MLI1jyA4muD1iBmbRkU+QQ tzGkg8r3B2UOKxl7iYNJ1hzse+/sD8SP2kTSB5M4EnNasPyOdvaqt4OCkQugErM2U1Xq BKkw== 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=LbXGo01FGRf4/MoNZZjc4oYZ1YnM6tEfV05xWgFZQLM=; b=OQZ2/KWPfJZo9s3Y7o3HM5G2UAzbiaEVaDA3NdS8ixIqNrYzuHH910htp1sGuKWfls NIAWUfiDCimbuT6Lrw81kSctPEJz+svMSc/i02gW9+YBRu3oLKBt/nrEemvUrfDO6KQY Q4t8JgA1twduuULMGEjHfIvhcgM55IRcwpMoozK/9dtVMSQXy5Uafmge6zoqkH6mT/9A Kpcr9Iw8xBiYAutHmVgaElBQqZuUNhLRG8ng4ulaOu+KrVM0SKjEDMw9RNLSCzk0YANl Uzmd4Vh4AeYxaPoEGMnlLGRek11KhdqRukVtMw4v3oqJqQjnAK388jPTtNpcsFKZca1I 4GOQ== X-Gm-Message-State: AJaThX4xu6gwou4XMDe9q4eDWzXlAgN1+k0thvxyMrA1FMFSlaoM8XcR lniQslierCTpbZJ0u94+hgGK0qA= X-Received: by 10.84.132.35 with SMTP id 32mr27019329ple.225.1512683187387; Thu, 07 Dec 2017 13:46:27 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id t75sm9830781pgc.12.2017.12.07.13.46.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:26 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 72E73B76; Thu, 7 Dec 2017 15:46:24 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 0B61730008F; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:10 -0600 Message-Id: <1512683181-8420-4-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c00::242 Subject: [Qemu-devel] [PATCH 03/14] i2c:pm_smbus: Make the I2C block read command read-only 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 , Paolo Bonzini , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard It did have write capability, but the manual says the behavior with write enabled is undefined. So just set an error in this case. Signed-off-by: Corey Minyard Cc: Michael S. Tsirkin Cc: Paolo Bonzini --- hw/i2c/pm_smbus.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 679edbc..e7a8e92 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -56,7 +56,7 @@ #define PROT_WORD_DATA 3 #define PROT_PROC_CALL 4 #define PROT_BLOCK_DATA 5 -#define PROT_I2C_BLOCK_DATA 6 +#define PROT_I2C_BLOCK_READ 6 /*#define DEBUG*/ @@ -113,7 +113,7 @@ static void smb_transaction(PMSMBus *s) goto done; } break; - case PROT_I2C_BLOCK_DATA: + case PROT_I2C_BLOCK_READ: if (read) { int xfersize = s->smb_data0; if (xfersize > sizeof(s->smb_data)) { @@ -123,9 +123,8 @@ static void smb_transaction(PMSMBus *s) xfersize, false, true); goto data8; } else { - ret = smbus_write_block(bus, addr, cmd, s->smb_data, s->smb_data0, - false); - goto done; + /* The manual says the behavior is undefined, just set DEV_ERR. */ + goto error; } break; default: From patchwork Thu Dec 7 21:46:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121091 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8901269qgn; Thu, 7 Dec 2017 13:49:30 -0800 (PST) X-Google-Smtp-Source: AGs4zMYX11uWiQI32uw+as2YMRw5Mht9DEwgYl8AOXMMZIG3NRE9j+X/JTcyIy/5weip97RCRJyg X-Received: by 10.129.78.200 with SMTP id c191mr18713914ywb.92.1512683370468; Thu, 07 Dec 2017 13:49:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683370; cv=none; d=google.com; s=arc-20160816; b=MaYEf1TCVH2KXgLJt17rGUIpNZ1rdbCIMLYcC5AuIU24SwYyIHQ+8hP3+3oQlE6O2S llJW/AjkTk4vjtjT07P6sQ7PgIyRnI2T7F+TqRUTadRsZIZYMxXCJuUODUiwazjFNo7/ Zja9RJWq1vV91uoUMvy3h4buadBMQkfOFBczHdj+CUfxybGNt9z/UoT8KJerlXSwtqC0 sWMqxTY0n+2I+2Fe9jRo9jwwuoHCMxdZu8dgHjX1xgGlFs6rCt0Ecdcam9r+L6sfJg1i GTQAkIzfPvrcWZcaaNFcoMramaTrfNtpBjGrbn1JSHnCb2FDezE22zfTpdF//L0FNX6e woMg== 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=ZTsHCS8+/lym9NlYwHu5cI27AhHhwvJag+r8wBBp5xE=; b=iQYPtJQmmSNl4CF/+X/SltTTjJbV6/bXqgNfCBiGv2/foMe/yPX3SrDYIbCrLoDSad YppzMV2as+OBFELXbGbZ+PwgNdrdtRUFMmSygItxuW1sev7aAmTQurWt13uBFDX+XDaa WF1W7yKxHkIYW8jCCJ5BUGemLga1So0hj21J2vHyWxhwIRQCBVHsV+iJdxXw4n/iTICr VdxsAVwhS7cK/ZHBfbPhS84soxAoJOHYaxbG3QjihtCGpGvMGrF5pyXxs2l8Ytu41B4p xo0E7SNDIL3W7iA7+mZb6VbE9WO23NPCMPr7isYiXAA5FozhRU4bYiZp1U5C4xtlnDQb 2acg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=eGHR1TMk; 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 v185si1347207ywb.80.2017.12.07.13.49.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:49:30 -0800 (PST) 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=eGHR1TMk; 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]:34496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN42r-0005YP-Tw for patch@linaro.org; Thu, 07 Dec 2017 16:49:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN401-000414-6Y for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN3zz-0006Mb-CL for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:33 -0500 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:39837) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN3zz-0006LV-3F for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:31 -0500 Received: by mail-pg0-x244.google.com with SMTP id w7so5384202pgv.6 for ; Thu, 07 Dec 2017 13:46:30 -0800 (PST) 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=ZTsHCS8+/lym9NlYwHu5cI27AhHhwvJag+r8wBBp5xE=; b=eGHR1TMkx8HgB/HvQS2R4V9j/tha32rReZTN3wE/1XoV+7eBH8E+MZOhyG3wI3MSqU zlGpxCpMjoc9TCnddvgt68cq7PsPzSSvdDEONCVddpkuyZ6quWr9g6F7ZIjQ504TIEsX XwN5OUoBsIkFqk1FOzqYNdwqRiC4O7b9qMB++DqQ3L5lnVy50K6xxkwFgvQRmAlVZpz7 oYP7994TZl0IKlWVch8RxAqL+2kzQAsh2FdViPpD5wZii+NzCyiTb0kfAddJnbXar+oy uAPuFKa4ExwB79RGnPNJ7UaHQqdpRYCmFqOPEAzZsMi5cW1QhN8Y9BylZwGswhHGpH+G +Lqg== 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=ZTsHCS8+/lym9NlYwHu5cI27AhHhwvJag+r8wBBp5xE=; b=oVvxy64YUEb43Ky+B9QktTNNs/PQ+aHdxMUKPZyuncjN7uuzVQyPNsT5yGl3ptcptV C5NMpT9O0IDEgoSk94cqxLLmtGzjogsft3fb0Dj+QAoA9k9E4BKDBYIOrB1UjjU6i+os zEIpQQPWbN7WJLUGwlNLDGi3FFTv0H2Oomeqtwpt4OUKJg69rptKG4vkHtAmhBrwg8Hj sOqg8/7VWMm6cLcSXpDd6PXYme5YObldiMe2x+mWbw8sXTRMG1WGRJXeJVJwZ9OJDPpI WUJvkKVm3tRMiS1cVHDJs7KY8OMPFmW06VYMKvNOhf6h9uz3NYzKw3U5oxaGy8zWIt5L ihcg== X-Gm-Message-State: AJaThX6SyTRjHCCQCZZ3Ju3NFcYu7Yv6aQ4eck4QFeOJtjhcoaEI4gwY t6RMpoSMTM/6z3VROoIdFQ== X-Received: by 10.84.149.139 with SMTP id m11mr27287598pla.36.1512683189868; Thu, 07 Dec 2017 13:46:29 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id b67sm10781198pfm.19.2017.12.07.13.46.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:26 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id BEFE9BD7; Thu, 7 Dec 2017 15:46:24 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 17A2F300082; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:11 -0600 Message-Id: <1512683181-8420-5-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c05::244 Subject: [Qemu-devel] [PATCH 04/14] i2c:pm_smbus: Add block transfer capability 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 , Paolo Bonzini , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard There was no block transfer code in pm_smbus.c, and it is needed for some devices. So add it. This adds both byte-by-byte block transfers and buffered block transfers. Signed-off-by: Corey Minyard Cc: Michael S. Tsirkin Cc: Paolo Bonzini --- hw/i2c/pm_smbus.c | 151 ++++++++++++++++++++++++++++++++++++++++++---- hw/i2c/smbus_ich9.c | 8 ++- include/hw/i2c/pm_smbus.h | 20 +++++- 3 files changed, 164 insertions(+), 15 deletions(-) -- 2.7.4 diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index e7a8e92..686d411 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -30,6 +30,7 @@ #define SMBHSTDAT0 0x05 #define SMBHSTDAT1 0x06 #define SMBBLKDAT 0x07 +#define SMBAUXCTL 0x0d #define STS_HOST_BUSY (1 << 0) #define STS_INTR (1 << 1) @@ -58,6 +59,10 @@ #define PROT_BLOCK_DATA 5 #define PROT_I2C_BLOCK_READ 6 +#define AUX_PEC (1 << 0) +#define AUX_BLK (1 << 1) +#define AUX_MASK 0x3 + /*#define DEBUG*/ #ifdef DEBUG @@ -127,6 +132,51 @@ static void smb_transaction(PMSMBus *s) goto error; } break; + case PROT_BLOCK_DATA: + if (read) { + ret = smbus_read_block(bus, addr, cmd, s->smb_data, + sizeof(s->smb_data), !s->i2c_enable, + !s->i2c_enable); + if (ret < 0) { + goto error; + } + s->smb_index = 0; + s->op_done = false; + if (s->smb_auxctl & AUX_BLK) { + s->smb_stat |= STS_INTR; + } else { + s->smb_blkdata = s->smb_data[0]; + s->smb_stat |= STS_HOST_BUSY | STS_BYTE_DONE; + } + s->smb_data0 = ret; + goto out; + } else { + if (s->smb_auxctl & AUX_BLK) { + if (s->smb_index != s->smb_data0) { + s->smb_index = 0; + goto error; + } + /* Data is already all written to the queue, just do + the operation. */ + s->smb_index = 0; + ret = smbus_write_block(bus, addr, cmd, s->smb_data, + s->smb_data0, !s->i2c_enable); + if (ret < 0) { + goto error; + } + s->op_done = true; + s->smb_stat |= STS_INTR; + s->smb_stat &= ~STS_HOST_BUSY; + } else { + s->op_done = false; + s->smb_stat |= STS_HOST_BUSY | STS_BYTE_DONE; + s->smb_data[0] = s->smb_blkdata; + s->smb_index = 0; + ret = 0; + } + goto out; + } + break; default: goto error; } @@ -146,13 +196,13 @@ done: if (ret < 0) { goto error; } - s->smb_stat |= STS_BYTE_DONE | STS_INTR; + s->smb_stat |= STS_INTR; +out: return; error: s->smb_stat |= STS_DEV_ERR; return; - } static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, @@ -164,14 +214,61 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, " val=0x%02" PRIx64 "\n", addr, val); switch(addr) { case SMBHSTSTS: - s->smb_stat = (~(val & 0xff)) & s->smb_stat; - s->smb_index = 0; + s->smb_stat &= ~(val & ~STS_HOST_BUSY); + if (!s->op_done && !(s->smb_auxctl & AUX_BLK)) { + uint8_t read = s->smb_addr & 0x01; + + s->smb_index++; + if (!read && s->smb_index == s->smb_data0) { + uint8_t prot = (s->smb_ctl >> 2) & 0x07; + uint8_t cmd = s->smb_cmd; + uint8_t addr = s->smb_addr >> 1; + int ret; + + if (prot == PROT_I2C_BLOCK_READ) { + s->smb_stat |= STS_DEV_ERR; + goto out; + } + + ret = smbus_write_block(s->smbus, addr, cmd, s->smb_data, + s->smb_data0, !s->i2c_enable); + if (ret < 0) { + s->smb_stat |= STS_DEV_ERR; + goto out; + } + s->op_done = true; + s->smb_stat |= STS_INTR; + s->smb_stat &= ~STS_HOST_BUSY; + } else if (!read) { + s->smb_data[s->smb_index] = s->smb_blkdata; + s->smb_stat |= STS_BYTE_DONE; + } else if (s->smb_ctl & CTL_LAST_BYTE) { + s->op_done = true; + s->smb_blkdata = s->smb_data[s->smb_index]; + s->smb_index = 0; + s->smb_stat |= STS_INTR; + s->smb_stat &= ~STS_HOST_BUSY; + } else { + s->smb_blkdata = s->smb_data[s->smb_index]; + s->smb_stat |= STS_BYTE_DONE; + } + } break; case SMBHSTCNT: - s->smb_ctl = val; - if (s->smb_ctl & CTL_START) { + s->smb_ctl = val & ~CTL_START; /* CTL_START always reads 0 */ + if (val & CTL_START) { + if (!s->op_done) { + s->smb_index = 0; + s->op_done = true; + } smb_transaction(s); } + if (s->smb_ctl & CTL_KILL) { + s->op_done = true; + s->smb_index = 0; + s->smb_stat |= STS_FAILED; + s->smb_stat &= ~STS_HOST_BUSY; + } break; case SMBHSTCMD: s->smb_cmd = val; @@ -186,13 +283,24 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, s->smb_data1 = val; break; case SMBBLKDAT: - s->smb_data[s->smb_index++] = val; - if (s->smb_index > 31) + if (s->smb_index >= PM_SMBUS_MAX_MSG_SIZE) { s->smb_index = 0; + } + if (s->smb_auxctl & AUX_BLK) { + s->smb_data[s->smb_index++] = val; + } else { + s->smb_blkdata = val; + } + break; + case SMBAUXCTL: + s->smb_auxctl = val & AUX_MASK; break; default: break; } + + out: + return; } static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width) @@ -205,7 +313,6 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width) val = s->smb_stat; break; case SMBHSTCNT: - s->smb_index = 0; val = s->smb_ctl & CTL_RETURN_MASK; break; case SMBHSTCMD: @@ -221,9 +328,22 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width) val = s->smb_data1; break; case SMBBLKDAT: - val = s->smb_data[s->smb_index++]; - if (s->smb_index > 31) + if (s->smb_index >= PM_SMBUS_MAX_MSG_SIZE) { s->smb_index = 0; + } + if (s->smb_auxctl & AUX_BLK) { + val = s->smb_data[s->smb_index++]; + if (!s->op_done && s->smb_index == s->smb_data0) { + s->op_done = true; + s->smb_index = 0; + s->smb_stat &= ~STS_HOST_BUSY; + } + } else { + val = s->smb_blkdata; + } + break; + case SMBAUXCTL: + val = s->smb_auxctl; break; default: val = 0; @@ -235,6 +355,13 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width) return val; } +static void pm_smbus_reset(PMSMBus *s) +{ + s->op_done = true; + s->smb_index = 0; + s->smb_stat = 0; +} + static const MemoryRegionOps pm_smbus_ops = { .read = smb_ioport_readb, .write = smb_ioport_writeb, @@ -245,6 +372,8 @@ static const MemoryRegionOps pm_smbus_ops = { void pm_smbus_init(DeviceState *parent, PMSMBus *smb) { + smb->op_done = true; + smb->reset = pm_smbus_reset; smb->smbus = i2c_init_bus(parent, "i2c"); memory_region_init_io(&smb->io, OBJECT(parent), &pm_smbus_ops, smb, "pm-smbus", 64); diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c index e47556c..59e165a 100644 --- a/hw/i2c/smbus_ich9.c +++ b/hw/i2c/smbus_ich9.c @@ -62,12 +62,16 @@ static void ich9_smbus_write_config(PCIDevice *d, uint32_t address, pci_default_write_config(d, address, val, len); if (range_covers_byte(address, len, ICH9_SMB_HOSTC)) { uint8_t hostc = s->dev.config[ICH9_SMB_HOSTC]; - if ((hostc & ICH9_SMB_HOSTC_HST_EN) && - !(hostc & ICH9_SMB_HOSTC_I2C_EN)) { + if (hostc & ICH9_SMB_HOSTC_HST_EN) { memory_region_set_enabled(&s->smb.io, true); } else { memory_region_set_enabled(&s->smb.io, false); } + s->smb.i2c_enable = (hostc & ICH9_SMB_HOSTC_I2C_EN) != 0; + if (hostc & ICH9_SMB_HOSTC_SSRESET) { + s->smb.reset(&s->smb); + s->dev.config[ICH9_SMB_HOSTC] &= ~ICH9_SMB_HOSTC_SSRESET; + } } } diff --git a/include/hw/i2c/pm_smbus.h b/include/hw/i2c/pm_smbus.h index 2a837af..99d5489 100644 --- a/include/hw/i2c/pm_smbus.h +++ b/include/hw/i2c/pm_smbus.h @@ -1,6 +1,8 @@ #ifndef PM_SMBUS_H #define PM_SMBUS_H +#define PM_SMBUS_MAX_MSG_SIZE 32 + typedef struct PMSMBus { I2CBus *smbus; MemoryRegion io; @@ -11,8 +13,22 @@ typedef struct PMSMBus { uint8_t smb_addr; uint8_t smb_data0; uint8_t smb_data1; - uint8_t smb_data[32]; - uint8_t smb_index; + uint8_t smb_data[PM_SMBUS_MAX_MSG_SIZE]; + uint8_t smb_blkdata; + uint8_t smb_auxctl; + uint32_t smb_index; + + /* Set by pm_smbus.c */ + void (*reset)(struct PMSMBus *s); + + /* Set by the user. */ + bool i2c_enable; + + /* Internally used by pm_smbus. */ + + /* Set on block transfers after the last byte has been read, so the + INTR bit can be set at the right time. */ + bool op_done; } PMSMBus; void pm_smbus_init(DeviceState *parent, PMSMBus *smb); From patchwork Thu Dec 7 21:46:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121095 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8903382qgn; Thu, 7 Dec 2017 13:52:07 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ5eeNxG2ZjgokIfTTjgqNg7vW5i1UZrCXZOLGkiO3xJN3rNx8+INry5xRF1PHTAZvKGeWG X-Received: by 10.129.175.10 with SMTP id n10mr18988575ywh.263.1512683527709; Thu, 07 Dec 2017 13:52:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683527; cv=none; d=google.com; s=arc-20160816; b=xSCxPJzjchilrJXaaRdECflzMDzUebj+9/bFbqNeYsOaf8Roc9XuK3AM/APcT16JC1 3u1BNoyqZMqtDff61N01Ok1eqRKgzV+puU1t0tvK0yFLx9pCUaKcpPtHQY7fKXEDstJq Sooy4Ch/Osn6e3rXD0mmADZl3B3nh/h84URMySW31QPujk5AWt1HEwRk5HR9dOxFtV3z 67G75U0nJ8C0wgi0noGQIeWgMgDkSg+/pdLALw0nUbTaRVDXLX2z6lDgp9uCoaQQ38C5 ZG/TEMr+iRbsa1WG0UvVj1gEb6cjdkxr22qsDiie1UpOWV7SsG43X3q9wPupvSdvLXfx aTGg== 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=jpmK1Igkm3NFGVKTiC4/qQJV3D4/E8c+EEW3KID+uZQ=; b=gjiRUWjCG6jOFL+WKXQ4uLWjltaQZvZi0mR4SQCUNxR/4rjBA682IWI/+K5g3cN4uf 0DRUUo/fEC9etTKs/Epi5NWcbpcjpfYd8iQYajS3ZJ4jQyChZiZF4exb2sl3lQiH7bnM hYw/Bwp8ATtN3aPqJHjP03cbIwHEZz+ZoEzMdPAyJX6H+tWnFe7mC/2dxVpI/1ep4vgy n3UP5Pcz+qcqgJgT/ImNL9HFShbVM+U3cZfTPO67eIRurJ+PYYnCQaXdYLVb67V7XJYZ 8/4Qsv/2pelA2jFW4a7m0Dyb34EVhjQPEF9ytvS7gJOcy3qOZkH2wYtue7ZfaDVwCrVv zGcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=HcPhFbPU; 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 r4si1345838ywd.139.2017.12.07.13.52.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:52:07 -0800 (PST) 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=HcPhFbPU; 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]:34524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN45P-00008G-6p for patch@linaro.org; Thu, 07 Dec 2017 16:52:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN401-00041G-Cv for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN400-0006OP-8L for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:33 -0500 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:42451) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN400-0006Mp-1i for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:32 -0500 Received: by mail-pg0-x244.google.com with SMTP id e14so5385658pgr.9 for ; Thu, 07 Dec 2017 13:46:31 -0800 (PST) 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=jpmK1Igkm3NFGVKTiC4/qQJV3D4/E8c+EEW3KID+uZQ=; b=HcPhFbPUXF5lC1Covv19MvacrUpvuywwDs04akFru/rwMBHpHKpHMCjVIIA44rOFV1 s6b9HDwYAgGClQLRB2k/4M/KcVxTMQ35Q3XAKnC/9r+qajWHMar8nTnJMdaPU94uhsFF RLfFsBISK1Oajl2Cickly0GflUyz7yAxNzHoOj337FdJl4RbFjr9F+NieTRTRLdK3i8e hH/8523nvciyX2ALAThWZkURByhHpAqhWZtBmPtCH7Xq3tG9mUSeqUaCFooSciuuCytH KeE4yfBEVh9X2jaBQFn2EUjUy8EWzJkIaT5G+0m6HSqh1zbO/tT8pGh5s1d0jQdYWZvi fKNQ== 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=jpmK1Igkm3NFGVKTiC4/qQJV3D4/E8c+EEW3KID+uZQ=; b=RU7bBe39uwT74RXkHfezX93JOK60nrMy3EOXI+Qn0EeM4nUgTECoXGOSlYB2Qt61gM 0jb3JnqDjiIB8oQhZNyADMg37Tzy/TYGQ5CkGAKa9yhZPiUcrrpScBa3/oFY1vK0MqKK gD7iSvn8UQn5dTCC1wY7CGwdrQKNzg+Nze8h7ozSOabXRz6xFWTxl3hdsrgTTGQVKCJD rXI/NpGAlt+TyUEW248GMXyeJFtEEmwj0oGeBohuX3qEPLMbe75VK/U0MdRc7cM5bcw+ p1Up9oVeK0QnC90/6OZAEEe9b6dhVnC0s4RZqoyw8r31qQSOeYGXBXADbSpr3+z8npwZ xijA== X-Gm-Message-State: AJaThX5YT7KRFTJEZI+6ibOi32y7dOU+VMu0F6kO/AUOT0oXoZaOfYRY UBTZXF8i6tElPXhkZIztRw== X-Received: by 10.99.120.131 with SMTP id t125mr26147999pgc.83.1512683190991; Thu, 07 Dec 2017 13:46:30 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id u19sm10223959pfh.89.2017.12.07.13.46.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:29 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 3195FCF0; Thu, 7 Dec 2017 15:46:25 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 2A2EB302366; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:12 -0600 Message-Id: <1512683181-8420-6-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c05::244 Subject: [Qemu-devel] [PATCH 05/14] i2c:pm_smbus: Fix state transfer 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 , Paolo Bonzini , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Transfer the state information for the SMBus registers and internal data so it will work on a VM transfer. Signed-off-by: Corey Minyard Cc: Michael S. Tsirkin Cc: Paolo Bonzini --- hw/acpi/piix4.c | 1 + hw/i2c/pm_smbus.c | 19 +++++++++++++++++++ hw/i2c/smbus_ich9.c | 3 ++- include/hw/i2c/pm_smbus.h | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index a0fb1ce..18c1ffa 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -321,6 +321,7 @@ static const VMStateDescription vmstate_acpi = { VMSTATE_UINT16(ar.pm1.evt.en, PIIX4PMState), VMSTATE_UINT16(ar.pm1.cnt.cnt, PIIX4PMState), VMSTATE_STRUCT(apm, PIIX4PMState, 0, vmstate_apm, APMState), + VMSTATE_STRUCT(smb, PIIX4PMState, 1, pmsmb_vmstate, PMSMBus), VMSTATE_TIMER_PTR(ar.tmr.timer, PIIX4PMState), VMSTATE_INT64(ar.tmr.overflow_time, PIIX4PMState), VMSTATE_STRUCT(ar.gpe, PIIX4PMState, 2, vmstate_gpe, ACPIGPE), diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 686d411..eb2df4d 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -370,6 +370,25 @@ static const MemoryRegionOps pm_smbus_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; +const VMStateDescription pmsmb_vmstate = { + .name = "pmsmb", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT8(smb_stat, PMSMBus), + VMSTATE_UINT8(smb_ctl, PMSMBus), + VMSTATE_UINT8(smb_cmd, PMSMBus), + VMSTATE_UINT8(smb_addr, PMSMBus), + VMSTATE_UINT8(smb_data0, PMSMBus), + VMSTATE_UINT8(smb_data1, PMSMBus), + VMSTATE_VBUFFER_UINT32(smb_data, PMSMBus, 1, NULL, smb_index), + VMSTATE_UINT8(smb_auxctl, PMSMBus), + VMSTATE_BOOL(i2c_enable, PMSMBus), + VMSTATE_BOOL(op_done, PMSMBus), + VMSTATE_END_OF_LIST() + } +}; + void pm_smbus_init(DeviceState *parent, PMSMBus *smb) { smb->op_done = true; diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c index 59e165a..706b9ec 100644 --- a/hw/i2c/smbus_ich9.c +++ b/hw/i2c/smbus_ich9.c @@ -49,7 +49,8 @@ static const VMStateDescription vmstate_ich9_smbus = { .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField[]) { - VMSTATE_PCI_DEVICE(dev, struct ICH9SMBState), + VMSTATE_PCI_DEVICE(dev, ICH9SMBState), + VMSTATE_STRUCT(smb, ICH9SMBState, 1, pmsmb_vmstate, PMSMBus), VMSTATE_END_OF_LIST() } }; diff --git a/include/hw/i2c/pm_smbus.h b/include/hw/i2c/pm_smbus.h index 99d5489..b1e1970 100644 --- a/include/hw/i2c/pm_smbus.h +++ b/include/hw/i2c/pm_smbus.h @@ -33,4 +33,6 @@ typedef struct PMSMBus { void pm_smbus_init(DeviceState *parent, PMSMBus *smb); +extern const VMStateDescription pmsmb_vmstate; + #endif /* PM_SMBUS_H */ From patchwork Thu Dec 7 21:46:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121092 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8902532qgn; Thu, 7 Dec 2017 13:51:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMbwm0rQn4fcxbcTfrWI11r5F/+D2nHAKS+rzOIoDE0LGsTDR5eNRLxLLrjAk9rwr/V3unss X-Received: by 10.129.200.68 with SMTP id k4mr19434028ywl.130.1512683464585; Thu, 07 Dec 2017 13:51:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683464; cv=none; d=google.com; s=arc-20160816; b=UicgQFUXjsHqfCa++2lrW0RqIklbcOYmbkHWWbSIvyagVnwwOARUQWLYbr6Vd1R5yJ 0UbCBGQtnwaL0BZkLwYDwuAX7bEnLU2c9ErQan9O943T1tOWE4MqAJJI3czxFvhe9JUZ kg/b4hezFbnQyQGEXmtfTID6MWi0zj3EYplQp+MKe8r9p3706CFkGyiQ4NrKG7xUr314 nIliGENe6gmVo3jyR0GFfs/5iauT6li3TJx+7LZ6hwDFUYxLLFOBQWhHr1QzYHZuKpez Ppa2yZO4yZe0gcnwUU4jrNAg+4VvNms7naBE1b85nosOOnmJ+bPMGk79P6u3QLdASaCU 6dmg== 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=3lo9mOd7Qe/S5grO0QCpk+ZWH8dtXaq/JBE7TcbML0k=; b=pUAgyxVfXIj/ydOawCMCXYqULHyJEurUgv7Zxk1XJ/44iSUXuZtB+XkjzEWrFfCwjI A2eFjYrAwkjJLzD9FG2hcbl2JC5ZH0YwR0XDKWMo1OsAnhIZfHyrLo3H263HjMtI3i/t +d4ECfDv3+rvOVsMRXM32zXwm4QUbjQOQKaBDgKo7+rrhTZFOfn5x47kzQIL2JG+iAWm ZrBG+RGXQxLrM7Slj4rRFgKSHhnpTwTh/U6+g1cJJjzcchirVWhfxbFOEMMALmr+StGJ XKYlbuFVy2waK4xWNjqSIeF/RX2/w2x9yg9XIavMV2Vfp0BNhf7qxUxlmThAYOTpfYq7 XRtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=M43Golz6; 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 k6si1341876ywb.343.2017.12.07.13.51.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:51:04 -0800 (PST) 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=M43Golz6; 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]:34510 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN44N-0006oO-Sv for patch@linaro.org; Thu, 07 Dec 2017 16:51:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN402-000426-7K for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN401-0006QJ-7M for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:34 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:38375) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN401-0006P2-0a for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:33 -0500 Received: by mail-pf0-x244.google.com with SMTP id u25so5674745pfg.5 for ; Thu, 07 Dec 2017 13:46:32 -0800 (PST) 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=3lo9mOd7Qe/S5grO0QCpk+ZWH8dtXaq/JBE7TcbML0k=; b=M43Golz6DzC6On2kLpuoNBkRQuvzW2RGHlSicxd3Z+8YSqf5YJAtyyv3j/LNIvg5Ra USCQF4ItoPajhS7WtyezxRs2Wz5NaXYR80GEjnv7R9SoW+WLD/EOcd99UJcR/AbYtYne AI/2YSpeXH2ea5GfQwioJMR7QW2kFmuM0lEjCxQEO/eZ1hEkfCABxSLuVYZZYahBYZFL S68LJVnTmghPpyIOtvl9Oto6xe2CbHKZ/sOrxXZtvcuG7u33lSGqHwnQbcRx8YgwtPsr rweddtdiVbnqB4eF7iB0QZilw66wZiH78SMYHlOko91Rkxzy/cBqtgeZ/xx4qtWsxMYd +JTw== 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=3lo9mOd7Qe/S5grO0QCpk+ZWH8dtXaq/JBE7TcbML0k=; b=hSlGAIuvNzt5+HyOjvax21dpc+xWW8qOqPr2MZllCYsBoSsTLjjAPO6YFHQZrC6tn9 zVAEbnw4tT7tCdwfC3EL1IgxJcq/v8bUGFp65sRcdJwPfPeCokLWb1IOa2UQTX9gqSrP SlGoJExEJf8rF6nozGwEpdop7/3lYLytw3CCl4+dVDVxx3KdDD+OLqRzWGSzMB0n6LYY 55mgmh81ymdYVHIfrW3MHXIXVIhbI5JJNnqTzaT8JxxVXoaOUiXa8GZ2bUQntm40tCWI st2W+hc2x6fOhPeybOMb4hY5TouDha7ZOa99LWYLbnnsJHCmeo9WUVmL5nJnzF2ZUKAp oJHA== X-Gm-Message-State: AJaThX4vXiZNF+2s1WfHssHfDB4jUmEm2uv3gAN5TijVIrt2svOhU4Y2 gJBTLdrLtLbltxa0Et56wteh8KM= X-Received: by 10.99.112.89 with SMTP id a25mr26601135pgn.2.1512683191910; Thu, 07 Dec 2017 13:46:31 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id j62sm8796887pgc.35.2017.12.07.13.46.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:29 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 4A734DF0; Thu, 7 Dec 2017 15:46:25 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 367DE300092; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:13 -0600 Message-Id: <1512683181-8420-7-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c00::244 Subject: [Qemu-devel] [PATCH 06/14] 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 , Paolo Bonzini , "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 | 17 +++++++++++++++++ include/hw/i2c/pm_smbus.h | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index eb2df4d..2fb00d0 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -205,6 +205,12 @@ error: return; } +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) { @@ -300,7 +306,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) @@ -352,6 +360,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 706b9ec..d029816 100644 --- a/hw/i2c/smbus_ich9.c +++ b/hw/i2c/smbus_ich9.c @@ -41,6 +41,8 @@ typedef struct ICH9SMBState { PCIDevice dev; + bool irq_enabled; + PMSMBus smb; } ICH9SMBState; @@ -50,6 +52,7 @@ static const VMStateDescription vmstate_ich9_smbus = { .minimum_version_id = 1, .fields = (VMStateField[]) { VMSTATE_PCI_DEVICE(dev, ICH9SMBState), + VMSTATE_BOOL(irq_enabled, ICH9SMBState), VMSTATE_STRUCT(smb, ICH9SMBState, 1, pmsmb_vmstate, PMSMBus), VMSTATE_END_OF_LIST() } @@ -111,11 +114,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. */ From patchwork Thu Dec 7 21:46:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121098 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8904998qgn; Thu, 7 Dec 2017 13:54:08 -0800 (PST) X-Google-Smtp-Source: AGs4zMYMth47epGbCp1xxTXQE6D9A78hWNjbhyi2gyI+8Picm4MIrUZJB8pZA3t5zkCi0N3Q/pXU X-Received: by 10.37.71.85 with SMTP id u82mr18642811yba.190.1512683648512; Thu, 07 Dec 2017 13:54:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683648; cv=none; d=google.com; s=arc-20160816; b=iInaruh22CSf4954XHeCPnrSqiBTDyv9+lO39GlK0/c8xe0x16uyE6/4OJABPtQx+z XCAyPtQaEzBbRa5RSCzVSED49JLnBmg00UkvOGS9cqEBVCUYB62GKTxpfsdooI8imkec Oo1DF4pOaJbknKYKouM6X7HgpJbrOYYiUmkFSI+4ybPRnN+gfJ+hxkKXajQd8Kq1WEIE ugK63a6PQwZ/lQATu1kPSiMqhOIVMFP6aYnEqIZnCyl5mQsmH0yWIfvKv8u5H6gVZzQ3 k/9W9HT9SMyLao53h9rXjd0KCfycY2BpDoHt8bovuTqFBucrJjV/rD53MLj7VW79iZOq xE1A== 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=NMRMUm5UeM2JDN80N4IzI0fJqzhL0aokYDxbR03RGM4=; b=dT1OOHEh4fBliH0ck4R8dxcHIA7SSJhMDAAjMQpvpErW6ltGbjIazrF6V7DEQZhWiU tmez6E+T2AK1JV+yvIQp2VBIpjJOCvjtNwkWehyX/B1c2MQkm7ogsceomaiPbCKoEJ4h b/KtOYoWaGKiSzTINZ5YWEB2FJ2Df0vorhBip7oBjO5ExGT+bPq6TmqrDlZG73a8Ex0f /BogA1ScdOaMuJwSZC79YqUTAcHXTx+DSBPVTT+EhoWcmvrkXO05qjA/xbrh35tt6FVF Euf8YX52zoPIyaEeClRC7ZFdlRoccWH6H3jR2Qxh2oV3Thyd7v9TNqBLSg7h//uapdkD VYiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GuarLLxJ; 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 h1si447657ywm.264.2017.12.07.13.54.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:54:08 -0800 (PST) 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=GuarLLxJ; 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]:34535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN47M-0002vQ-24 for patch@linaro.org; Thu, 07 Dec 2017 16:54:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN405-00045Q-C3 for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN403-0006UT-VP for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:37 -0500 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:41102) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN403-0006Sp-OB for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:35 -0500 Received: by mail-pf0-x243.google.com with SMTP id j28so5666700pfk.8 for ; Thu, 07 Dec 2017 13:46:35 -0800 (PST) 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=NMRMUm5UeM2JDN80N4IzI0fJqzhL0aokYDxbR03RGM4=; b=GuarLLxJ5vOl6Ang8U//dXf7xpnOMSAU5csyYD+jt4RMSN+3D07p4/X2rdWPRjH4ss sEgZFk7Lz43Rt7jBhhqoSilV+Zs/DG5XaXhMLOTKTQtj+FnwqzdxHYrIUraQNzo5g35I aZsSMtc75QkGloEDKq1J0CIeBWM4kSBGEYu6n7kwGD1GkzOszhbgQz6MBDl1msrnVdfV UuVR6hu6zxZWhR4KHMcfhE7AyIOYOygDYk+xS53yooFI0B1I+3NMQNobj/9rVfKtYTSq aeRiFredRgrPH8NzGtATHGrStUHKRvSgGUxb3BY7vCVESozt6GFSxdecBXf+WBvFIT1l dQxQ== 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=NMRMUm5UeM2JDN80N4IzI0fJqzhL0aokYDxbR03RGM4=; b=KIU2j/ksIOXEVsszrVv4DA7xQVeN1jzOHXSpNj6MBM1Hs/RviypAU4TGb9KY4VoBt1 P4j52F1GCMqSu6z44S6/2Vo7EIbQw5rGUtedyeE+rPZZUNZqM0x5dQakMutn4HWEvF9P 2NXVD4fVnaR8Rcw0JSMw45PQXOflZi6nxGUUCGLylpMzweuBtBijz1hQekcm1Vratd+W mjKVPg9/s2ja0+lqHkmFFUSoJnl9HyyzatS8MQu2i7A+kVEGOZNIpMnVpQvSoHbrp+QR DFkaLpiDq7nurLtcpeVQcu6bsJZmGU+4nBK7KuvBFpiVW5brMdGLEOsuyJHWAKxBPRPQ 6n3w== X-Gm-Message-State: AJaThX4l5lrGqC+TMz683b078bHHK3FdKYYnSfvX8NHElL2ovyX8y3eh /pwp6g7OT8E+4ZPELNx/JA== X-Received: by 10.99.117.19 with SMTP id q19mr26286645pgc.94.1512683194588; Thu, 07 Dec 2017 13:46:34 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id i11sm9963116pfk.25.2017.12.07.13.46.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:30 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 9A4DDEE8; Thu, 7 Dec 2017 15:46:25 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 43072302367; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:14 -0600 Message-Id: <1512683181-8420-8-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c00::243 Subject: [Qemu-devel] [PATCH 07/14] i2c:pm_smbus: Add the ability to force block transfer enable 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 , Paolo Bonzini , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard The PIIX4 hardware has block transfer buffer always enabled in the hardware, but the i801 does not. Add a parameter to pm_smbus_init to force on the block transfer so the PIIX4 handler can enable this by default, as it was disabled by default before. Signed-off-by: Corey Minyard Cc: Michael S. Tsirkin Cc: Paolo Bonzini --- hw/acpi/piix4.c | 2 +- hw/i2c/pm_smbus.c | 5 ++++- hw/i2c/smbus_ich9.c | 2 +- hw/isa/vt82c686.c | 2 +- include/hw/i2c/pm_smbus.h | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 18c1ffa..7018235 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -514,7 +514,7 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp) pci_conf[0x90] = s->smb_io_base | 1; pci_conf[0x91] = s->smb_io_base >> 8; pci_conf[0xd2] = 0x09; - pm_smbus_init(DEVICE(dev), &s->smb); + pm_smbus_init(DEVICE(dev), &s->smb, true); memory_region_set_enabled(&s->smb.io, pci_conf[0xd2] & 1); memory_region_add_subregion(pci_address_space_io(dev), s->smb_io_base, &s->smb.io); diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 2fb00d0..2afc5e1 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -401,11 +401,14 @@ const VMStateDescription pmsmb_vmstate = { } }; -void pm_smbus_init(DeviceState *parent, PMSMBus *smb) +void pm_smbus_init(DeviceState *parent, PMSMBus *smb, bool force_aux_blk) { smb->op_done = true; smb->reset = pm_smbus_reset; smb->smbus = i2c_init_bus(parent, "i2c"); + if (force_aux_blk) { + smb->smb_auxctl |= AUX_BLK; + } memory_region_init_io(&smb->io, OBJECT(parent), &pm_smbus_ops, smb, "pm-smbus", 64); } diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c index d029816..ce5ea9e 100644 --- a/hw/i2c/smbus_ich9.c +++ b/hw/i2c/smbus_ich9.c @@ -89,7 +89,7 @@ static void ich9_smbus_realize(PCIDevice *d, Error **errp) pci_set_byte(d->config + ICH9_SMB_HOSTC, 0); /* TODO bar0, bar1: 64bit BAR support*/ - pm_smbus_init(&d->qdev, &s->smb); + pm_smbus_init(&d->qdev, &s->smb, false); pci_register_bar(d, ICH9_SMB_SMB_BASE_BAR, PCI_BASE_ADDRESS_SPACE_IO, &s->smb.io); } diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index c129985..78b7468 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -370,7 +370,7 @@ static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp) pci_conf[0x90] = s->smb_io_base | 1; pci_conf[0x91] = s->smb_io_base >> 8; pci_conf[0xd2] = 0x90; - pm_smbus_init(&s->dev.qdev, &s->smb); + pm_smbus_init(&s->dev.qdev, &s->smb, false); memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io); apm_init(dev, &s->apm, NULL, s); diff --git a/include/hw/i2c/pm_smbus.h b/include/hw/i2c/pm_smbus.h index cfe596f..471345e 100644 --- a/include/hw/i2c/pm_smbus.h +++ b/include/hw/i2c/pm_smbus.h @@ -33,7 +33,7 @@ typedef struct PMSMBus { bool op_done; } PMSMBus; -void pm_smbus_init(DeviceState *parent, PMSMBus *smb); +void pm_smbus_init(DeviceState *parent, PMSMBus *smb, bool force_aux_blk); extern const VMStateDescription pmsmb_vmstate; From patchwork Thu Dec 7 21:46:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121096 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8903493qgn; Thu, 7 Dec 2017 13:52:14 -0800 (PST) X-Google-Smtp-Source: AGs4zMZVRhO8t+ldLNan06Z5Btpy1rIXwM78L+ckFYNe2/2ObIgZmGwBrY0JtX9jUp+NbdxxwqiD X-Received: by 10.129.90.194 with SMTP id o185mr19843452ywb.274.1512683534391; Thu, 07 Dec 2017 13:52:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683534; cv=none; d=google.com; s=arc-20160816; b=fPdfYEngyQuhQfBeBZolgW/eioPa8FUk339rzEFt57aEUsdTce/QxsH3Muhfdkp3SZ 8iupgM8WGlXiwe7TAQzN6Ut/tWo1CSlmPvLbOEwIJveTfmAwrpbf20PyQiChLq4Aeje1 rummBRzT4XnmdaEPYMWeelim2YpmJ/TNoZxNY2T/Eg8+ULlH3femZbYixD1B0zFPRmd6 pwsiPtqe+lx9dEKJuBcrVz6dVuxnE5x1BS9/8rFGO+pHQWPJWF5s3oy6n/HEIFDGv2qx yYYopLiAoJUWIbAmJXKt++Ypq5sXAowMgq+XtrhqjGkLcBnZQWgT9z5IYrTItYXK5AEh 9ySQ== 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=NA08dy/kaR5uBsMTC17SfMbDCJfWDF1R8gD8SDh/I4A=; b=p1HtGzpIwosjdSkGaoSQYx/BOlZP6tSCnY1/VY8zLl9rRh4GgBMn/BMz2pRVqyjzZ0 i0xTZP8kCHGCMCizB3/0JuTTAcHTC4gqlClcSblwM8cmJ98/xpJFdntCXwywvKsH0g0x O1TmAabqxg+q7UfW7cXeVrGdRvM8tSJFg5FUanvZ/FsPAWHSi5cNd4h4QuVlMy9BDMds CwWLlSHOCWfjWUtJavi+CXLAGKkD23rIF3BO8pdmJUzXLNFfuR6jnCz4YQ8uXeNyCQUh BduB9WyTG9mkFzCLvmS/4tKcSSeNbyLILH3jBeI3btlqHrQNnDDqvqyqE5wwuvPfAo/7 93Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=exQRKH/4; 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 a184si1339555ywg.612.2017.12.07.13.52.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:52:14 -0800 (PST) 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=exQRKH/4; 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]:34520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN45V-0007vG-Tc for patch@linaro.org; Thu, 07 Dec 2017 16:52:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN403-00042v-0F for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN401-0006Rh-VK for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:35 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:36364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN401-0006Qe-Oq for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:33 -0500 Received: by mail-pf0-x244.google.com with SMTP id p84so5683269pfd.3 for ; Thu, 07 Dec 2017 13:46:33 -0800 (PST) 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=NA08dy/kaR5uBsMTC17SfMbDCJfWDF1R8gD8SDh/I4A=; b=exQRKH/4VTk3CVmB8L9pDj4zopS/+pI0cvuNF5X6CTC1to8rY7/ZXPyPowbg0TWk6l +Z8bSrOT8PFXnHVloyNHrxRN0cUDzskOFLa4WJFk96ym0WgoKUoz8PIljhT10SdvT5wf 0v7SRfliwecOhAdLKjNorIKBBXp+dh1kKT2YLTnp0q8QA2BjzsogafdL8q/NAFbLR/pf FyPjDHemHdGKRXGU+/aVZjvJGP4OSEIgL9bb2LcxfBQk1MnoHcIJpVMQoWnKZFN7PoZG 5m8zCddMF9+vJooJ2at3Sdwr6rSBI3e7VCJSdFvAfa8/41IhNcJtG+xu/dHcS4YO4HNC ZKtw== 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=NA08dy/kaR5uBsMTC17SfMbDCJfWDF1R8gD8SDh/I4A=; b=ksfKAeZ/sd1Yu78WcfuQK6lcp1/FeLagwWSz5Pi8UZa3md/K+twRPoE5ibH2nvv39g O9/sPFDBLsvUTdBqQmOfPodkvrvAf9mVoiOgVZpp8+mgsrf1+CNzZ9ZPYmCz/0xbqKbE 8fvkQjqBul5FDLdqvoHZapR55ss48vt9JY9mb1Y+E/jrogkAIIJPW4GjT/l44rADxqZG 51nbjtigCEza/m48PisfAJFxS9m1Wvpx6f5j9Iaqn1LGulZk6oAng//CLIjG5BrHCfCg vVi/aZtFcmitapnil5hUY68nc/FFCH0RfVuTUAoVeVb46J24UPXEiropPIr/XZ2ktwmH pawA== X-Gm-Message-State: AJaThX6Vo/FQl98Fx0gIZggy0yBPLj9WrSoLjnG5B6lDBakOjf4NCt1z VZWL3+huxBNTJ1YMvH4MDg== X-Received: by 10.101.64.130 with SMTP id t2mr26026925pgp.299.1512683192747; Thu, 07 Dec 2017 13:46:32 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id l21sm10936820pfg.156.2017.12.07.13.46.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:29 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 5D847EB7; Thu, 7 Dec 2017 15:46:25 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 51672302368; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:15 -0600 Message-Id: <1512683181-8420-9-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c00::244 Subject: [Qemu-devel] [PATCH 08/14] i2c: Add an SMBus vmstate structure 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Signed-off-by: Corey Minyard --- hw/i2c/smbus.c | 14 ++++++++++++++ include/hw/i2c/smbus.h | 18 +++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/hw/i2c/smbus.c b/hw/i2c/smbus.c index 4b0e264..e15f3f2 100644 --- a/hw/i2c/smbus.c +++ b/hw/i2c/smbus.c @@ -357,6 +357,20 @@ int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data, return 0; } +const VMStateDescription vmstate_smbus_device = { + .name = TYPE_SMBUS_DEVICE, + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_I2C_SLAVE(i2c, SMBusDevice), + VMSTATE_INT32(mode, SMBusDevice), + VMSTATE_INT32(data_len, SMBusDevice), + VMSTATE_UINT8_ARRAY(data_buf, SMBusDevice, SMBUS_DATA_MAX_LEN), + VMSTATE_UINT8(command, SMBusDevice), + VMSTATE_END_OF_LIST() + } +}; + static void smbus_device_class_init(ObjectClass *klass, void *data) { I2CSlaveClass *sc = I2C_SLAVE_CLASS(klass); diff --git a/include/hw/i2c/smbus.h b/include/hw/i2c/smbus.h index f1b8078..7794026 100644 --- a/include/hw/i2c/smbus.h +++ b/include/hw/i2c/smbus.h @@ -54,14 +54,16 @@ typedef struct SMBusDeviceClass uint8_t (*read_data)(SMBusDevice *dev, uint8_t cmd, int n); } SMBusDeviceClass; +#define SMBUS_DATA_MAX_LEN 34 /* command + len + 32 bytes of data. */ + struct SMBusDevice { /* The SMBus protocol is implemented on top of I2C. */ I2CSlave i2c; /* Remaining fields for internal use only. */ - int mode; - int data_len; - uint8_t data_buf[34]; /* command + len + 32 bytes of data. */ + int32_t mode; + int32_t data_len; + uint8_t data_buf[SMBUS_DATA_MAX_LEN]; uint8_t command; }; @@ -93,4 +95,14 @@ int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data, void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom, const uint8_t *eeprom_spd, int size); +extern const VMStateDescription vmstate_smbus_device; + +#define VMSTATE_SMBUS_DEVICE(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(SMBusDevice), \ + .vmsd = &vmstate_smbus_device, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, SMBusDevice), \ +} + #endif From patchwork Thu Dec 7 21:46:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121097 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8904671qgn; Thu, 7 Dec 2017 13:53:41 -0800 (PST) X-Google-Smtp-Source: AGs4zMYQ7TX0flJICtigtmaWcot+2K0N8lAiFItAFTKIqGE2/dAFkus1O6cdkQxJCHDOu7lBQ//B X-Received: by 10.129.154.9 with SMTP id r9mr20491447ywg.198.1512683621369; Thu, 07 Dec 2017 13:53:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683621; cv=none; d=google.com; s=arc-20160816; b=BhK2Gbne/n1c4eCs7kAl/pR9gCaUab0zq3NEBFgyZ7GtY8Mac0XZkjp2ydAt222YJ7 Y/EPYgMmf7xF53gWsdjrItXplEJu2g6KV+r5jcDukDPoe3GC6fKi3KTrmtZbwIog9twO j55HnhAPk9QrRfbNhrbhLCfPJp10Y3XESKL6WABZKJT16kKwA25gGfkN3StoIv3fUvVV bYw5HEpRM4dcnL9GN1JdCSA9m4PCf8O2sC+Hdpf6Vu0K0SmDT6t0Q3Vaq50C7sV39qFc zPUyPJ1i/8QTFMFRWA19xCBTwQ8EmErnmV20xxomdKlMcB+41EFLKkEhVuwandfrCctT QhYw== 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=qT2ZO1W2HJ1DqjfogKzmFB8W9vNRLNA69uvg/MjlRGI=; b=F7PhspSnevO2gNk7Gt5znKtl9wp9t9BX0fJv1Y9jIIs7voRFytp0WztFAARHtmJQDx SUwRDdNWpV38BHhcqTzGTxGuDKuI/Ls+Vm26g1JYYOC0VEq76Nyd0Pa6nefj98KVCv/a m1wAZomw04z9jxUA4E2TFe3oIhFaUe6g+mpakyI9M2SrlO2FyP/UJad18afIrXrXZmps zMdiDJmlPRsMoschEt/6EFuuVrWEyZ8KKBZ2Z2Xdgs2qHabq65TuIccXHknf10LhN20g dTqmnCXrfxTMnXMA3sF1nropiIoSAYpCEzW+XI0GQKAR5K0OFLOMUhbxvhlN2F9kD8JV yE+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=lKkml65F; 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 x190si336617ybc.828.2017.12.07.13.53.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:53:41 -0800 (PST) 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=lKkml65F; 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]:34529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN46u-0000vP-PY for patch@linaro.org; Thu, 07 Dec 2017 16:53:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN404-00043l-0i for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN403-0006Sa-1B for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:36 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:42325) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN402-0006S6-RU for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:34 -0500 Received: by mail-pf0-x242.google.com with SMTP id d23so5669990pfe.9 for ; Thu, 07 Dec 2017 13:46:34 -0800 (PST) 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=qT2ZO1W2HJ1DqjfogKzmFB8W9vNRLNA69uvg/MjlRGI=; b=lKkml65FfqekCxi2FY3zi0kFid6fHIZB4lgSIQ5US75UKK3EKA0l62qbQf73ipiyzf kp8SWuqd1LrtMeZtPk3/v/y7FnfyMAzeXxaC9ED+u/CrBQyYys2Y6xkFovnNDre/jOn5 Gmk1HDRNKlBBXMospmNi9TncOtOsHbgzGxgsRCKAWgKYS0P1CHbfkztz/y76be9uuuXC dMGQBMwc4t6OQSkF9DLipvaOnvu/IJAfoZ1mSxekJstSiS8vtmAv3p4CcAIE1ykLC1pM KueCQT7ar83xAMf5riRix4kyRhGfDw7qnbiQtbMO1G4rCouSZ2b6GcpXRqWPsrdw85GE +DPw== 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=qT2ZO1W2HJ1DqjfogKzmFB8W9vNRLNA69uvg/MjlRGI=; b=r0jAj8TlyuXx0UDVCfj4rzcyOa6tv8e9DePe1prsgFkw3i9jp9RR8+vVJxKP/ATmeM qAY3mp2pyA9Ko6rghxQf1A3VcIYetDA/XPPyJ8Hl826h7eAonaq3W0Dw5Bzd0L6cveBo vO/pmWXVAhFcQOWM3wkWVTCjjCcxJIpD+mDpmumMM4ToWGW3idLh9rQL3/yiCOxc0y0C xPi6oTmmQhw8gBBH9M1AM/6e6bbwJD2kX+kZFGjFdFP35D6hMyLymJVqFkgOSTF75nKX Ka05x4qjxSQFxKCyDLCBnzmJBcMRqnBmma3xRvfcN8hEHhx076eCo6ZXjIKhdiIVa2UU Kn1w== X-Gm-Message-State: AJaThX6UuojPuj8PkCYDP7FprdKOAqRbF+j4WB33/IlC3JL4oF1K2S21 OEBSsDLR8f1F7F4PEpqS7g== X-Received: by 10.101.88.76 with SMTP id s12mr27216612pgr.215.1512683193780; Thu, 07 Dec 2017 13:46:33 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id k2sm9780683pff.150.2017.12.07.13.46.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:29 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id BA03CF87; Thu, 7 Dec 2017 15:46:25 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 5FAD230007E; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:16 -0600 Message-Id: <1512683181-8420-10-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c00::242 Subject: [Qemu-devel] [PATCH 09/14] i2c: Add vmstate handling to the smbus eeprom 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Signed-off-by: Corey Minyard --- hw/i2c/smbus_eeprom.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index b13ec0f..089005d 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -29,6 +29,8 @@ //#define DEBUG +#define TYPE_SMBUS_EEPROM_DEVICE "smbus-eeprom" + typedef struct SMBusEEPROMDevice { SMBusDevice smbusdev; void *data; @@ -97,6 +99,17 @@ static uint8_t eeprom_read_data(SMBusDevice *dev, uint8_t cmd, int n) return eeprom_receive_byte(dev); } +static const VMStateDescription vmstate_smbus_eeprom = { + .name = TYPE_SMBUS_EEPROM_DEVICE, + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_SMBUS_DEVICE(smbusdev, SMBusEEPROMDevice), + VMSTATE_UINT8(offset, SMBusEEPROMDevice), + VMSTATE_END_OF_LIST() + } +}; + static int smbus_eeprom_initfn(SMBusDevice *dev) { SMBusEEPROMDevice *eeprom = (SMBusEEPROMDevice *)dev; @@ -122,12 +135,13 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data) sc->write_data = eeprom_write_data; sc->read_data = eeprom_read_data; dc->props = smbus_eeprom_properties; + dc->vmsd = &vmstate_smbus_eeprom; /* Reason: pointer property "data" */ dc->user_creatable = false; } static const TypeInfo smbus_eeprom_info = { - .name = "smbus-eeprom", + .name = TYPE_SMBUS_EEPROM_DEVICE, .parent = TYPE_SMBUS_DEVICE, .instance_size = sizeof(SMBusEEPROMDevice), .class_init = smbus_eeprom_class_initfn, From patchwork Thu Dec 7 21:46:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121099 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8906502qgn; Thu, 7 Dec 2017 13:55:55 -0800 (PST) X-Google-Smtp-Source: AGs4zMZkKt2eW0A6h1QvgULd+oB1o7c+9lBEX4JEL10yKSuhsIUHAwoXzIstc7Vt50Cnm3E1jv9f X-Received: by 10.37.104.17 with SMTP id d17mr3851790ybc.472.1512683755012; Thu, 07 Dec 2017 13:55:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683755; cv=none; d=google.com; s=arc-20160816; b=VbCwcqiNmpz4WUgBRzo8MfDmwCR3/vzdGJ66EC9xTnzcMQbOufs5ucIVvIDn++q/5V CRuGj0swU1ii6CTnjzaYeYPnsOY90bH8iSC7ntnL/lLJQ5cEz5x789ny91GOTZleQrm2 ERh32jHcJRIthnFXHNV1wD/3Aj1LRIiMNuZ7L8ZNmKutq9o2rjbxSDOP2saHiGhbMv8a LwpHSypDG9nLZ90TMJLLJ5/YYpX8/ZS0aLPAjQV0kEH2xVEA7+K7Fp4m0j+PdCfMUUc+ brx8uA5o86eIJBYWKobqntnm9JY397biNzSbgydaBNpT2Bk2b6N8qj2tr1rLXxACa0Nj HDxQ== 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=GRvNcf5leKS/bnrVzKE945pqiFpwfaJti4wxKVAS9dk=; b=qVQ6V5Wb9w688ZSt7ZuXR+tEDNk6f5+9FouqgY8i6BuF8GR4Un9z+lFyP0EyePjdHi v5X8UwJPD9k/lVmIuK27ZvwjmzNaeaUcmNfJvJqIj4aVsyBBTpnXBGbcC7leHj6UdmSK RzjerxvZRsj63pljcxlOfGiKevXrtNnlo9P2+5xQLl5dqEcLAy+6OqieulUstEni1lgG 1r04SS5hlFnRv86u/TMF02XLUvMNHmZuH0bdrTbrxSVLr5EmT3d7AEqivCGrLvZk9jEy zgFDYwgLm8YwebpY/ocC0hfimi0hoePzvw8hZ0BAtA6WvzvQvoDU/fIABNHEmAEiUr+E o1RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mJRbZJDg; 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 i15si1304690ywa.9.2017.12.07.13.55.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:55:54 -0800 (PST) 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=mJRbZJDg; 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]:34538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN494-0004j8-GG for patch@linaro.org; Thu, 07 Dec 2017 16:55:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN408-00049i-Lc for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN406-0006YU-0x for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:40 -0500 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:32902) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN405-0006Wm-Jb for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:37 -0500 Received: by mail-pg0-x241.google.com with SMTP id g7so5398122pgs.0 for ; Thu, 07 Dec 2017 13:46:37 -0800 (PST) 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=GRvNcf5leKS/bnrVzKE945pqiFpwfaJti4wxKVAS9dk=; b=mJRbZJDgVIvyArCHIYg877u6jm+pzIIIXWZy5DArHQMEUOQ8Xoc0cb90WxI2ac+Smv BnActi/OuvGBwzFhSsO8njRBDBb6dluHncSvwdch0C53qamYkc3TIpg6BiTGQyUNPOZm dSpdckTbuWS7/lxnLb1vKvLKZdavsitBrLMR0u7ANfCeTjfoi2Upo/Ka1x0ptk3hO9s/ DowOBQ/wVmcyC2SCzzgg7sZHvMOVLlr5+7jowBdU4Co8YinvBY1Saf1DpxC6/8d7SzzS 7SPoFKy4oe6Pg8pFmAuFK+NWCmyw2jNNv2GBHZFTLio28vUHie35U1ZFnsE5bwkPd0Fn /KLQ== 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=GRvNcf5leKS/bnrVzKE945pqiFpwfaJti4wxKVAS9dk=; b=pj8VTCtxBV6DJVbmgQhtiZ5rU2lGXieoect2QY7lkKjQpgMcPbd4YlqotoYITXamB5 ix6eKg9lNfM/Kt8ibGMx0M5KceuQaaYQhAIevcVBtCFxueDz0pCZkc8wRVLvVeVPqSfE /5ggnF2Z3+aJdUrFEBQP/KvgX28LUJAFphnerTMlOXxvIrVTuY1hD8xzqXfgN4AAj3Bb 0OoBmZ/t5myiNzGogHa2jdQZUnjRtTtUyvJgdsnwxA4cfNs6V2oqnzXzQTTD4QVyLEAy QPPYBNCr1u6bgLaNesQDsm2Gks8xgHM2nB894gUhee5t8aV/EObjCUuwero0uKTUAAUs FDjw== X-Gm-Message-State: AJaThX4Nxk3HuGWbK98VR7bkfpTXthK/MD+nM9B552V6aklQHpaoJvHA iRjqsF/l8SGKQHimqjCFoadBPUA= X-Received: by 10.101.69.68 with SMTP id x4mr24652818pgr.272.1512683196413; Thu, 07 Dec 2017 13:46:36 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id t4sm11918579pfj.56.2017.12.07.13.46.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:33 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id E9262F96; Thu, 7 Dec 2017 15:46:25 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 6E74C302369; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:17 -0600 Message-Id: <1512683181-8420-11-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c05::241 Subject: [Qemu-devel] [PATCH 10/14] ipmi: Add an SMBus IPMI interface 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Signed-off-by: Corey Minyard --- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/smbus_ipmi.c | 236 +++++++++++++++++++++++++++++++++++++ 4 files changed, 239 insertions(+) create mode 100644 hw/ipmi/smbus_ipmi.c -- 2.7.4 diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak index 07aaf77..7791418 100644 --- a/default-configs/i386-softmmu.mak +++ b/default-configs/i386-softmmu.mak @@ -17,6 +17,7 @@ CONFIG_ISA_IPMI_KCS=y CONFIG_PCI_IPMI_KCS=y CONFIG_ISA_IPMI_BT=y CONFIG_PCI_IPMI_BT=y +CONFIG_IPMI_SSIF=y CONFIG_SERIAL=y CONFIG_SERIAL_ISA=y CONFIG_PARALLEL=y diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak index 179ca35..7d8d673 100644 --- a/default-configs/x86_64-softmmu.mak +++ b/default-configs/x86_64-softmmu.mak @@ -17,6 +17,7 @@ CONFIG_ISA_IPMI_KCS=y CONFIG_PCI_IPMI_KCS=y CONFIG_ISA_IPMI_BT=y CONFIG_PCI_IPMI_BT=y +CONFIG_IPMI_SSIF=y CONFIG_SERIAL=y CONFIG_SERIAL_ISA=y CONFIG_PARALLEL=y diff --git a/hw/ipmi/Makefile.objs b/hw/ipmi/Makefile.objs index 2d7f080..3cca10b 100644 --- a/hw/ipmi/Makefile.objs +++ b/hw/ipmi/Makefile.objs @@ -5,3 +5,4 @@ common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o common-obj-$(CONFIG_PCI_IPMI_KCS) += pci_ipmi_kcs.o common-obj-$(CONFIG_ISA_IPMI_BT) += isa_ipmi_bt.o common-obj-$(CONFIG_PCI_IPMI_BT) += pci_ipmi_bt.o +common-obj-$(CONFIG_IPMI_SSIF) += smbus_ipmi.o diff --git a/hw/ipmi/smbus_ipmi.c b/hw/ipmi/smbus_ipmi.c new file mode 100644 index 0000000..75e26c8 --- /dev/null +++ b/hw/ipmi/smbus_ipmi.c @@ -0,0 +1,236 @@ +/* + * QEMU IPMI SMBus (SSIF) emulation + * + * Copyright (c) 2015,2016 Corey Minyard, MontaVista Software, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include "qemu/osdep.h" +#include "hw/hw.h" +#include "hw/i2c/smbus.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "hw/ipmi/ipmi.h" + +#define TYPE_SMBUS_IPMI "smbus-ipmi" +#define SMBUS_IPMI(obj) OBJECT_CHECK(SMBusIPMIDevice, (obj), TYPE_SMBUS_IPMI) + +#define SSIF_IPMI_REQUEST 2 +#define SSIF_IPMI_MULTI_PART_REQUEST_START 6 +#define SSIF_IPMI_MULTI_PART_REQUEST_MIDDLE 7 +#define SSIF_IPMI_RESPONSE 3 +#define SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE 9 + +typedef struct SMBusIPMIDevice { + SMBusDevice parent; + + IPMIBmc *bmc; + + uint8_t outmsg[MAX_IPMI_MSG_SIZE]; + uint32_t outpos; + uint32_t outlen; + + uint8_t inmsg[MAX_IPMI_MSG_SIZE]; + uint32_t inlen; + + /* + * This is a response number that we send with the command to make + * sure that the response matches the command. + */ + uint8_t waiting_rsp; + + uint32_t uuid; +} SMBusIPMIDevice; + +static void smbus_ipmi_handle_event(IPMIInterface *ii) +{ + /* No interrupts, so nothing to do here. */ +} + +static void smbus_ipmi_handle_rsp(IPMIInterface *ii, uint8_t msg_id, + unsigned char *rsp, unsigned int rsp_len) +{ + SMBusIPMIDevice *sid = SMBUS_IPMI(ii); + + if (sid->waiting_rsp == msg_id) { + sid->waiting_rsp++; + + memcpy(sid->outmsg, rsp, rsp_len); + sid->outlen = rsp_len; + sid->outpos = 0; + } +} + +static void smbus_ipmi_set_atn(IPMIInterface *ii, int val, int irq) +{ + /* This is where PEC would go. */ +} + +static void smbus_ipmi_set_irq_enable(IPMIInterface *ii, int val) +{ +} + +static void ipmi_quick_cmd(SMBusDevice *dev, uint8_t read) +{ +} + +static void ipmi_send_byte(SMBusDevice *dev, uint8_t val) +{ +} + +static uint8_t ipmi_receive_byte(SMBusDevice *dev) +{ + SMBusIPMIDevice *sid = SMBUS_IPMI(dev); + + if (sid->outpos >= sid->outlen) { + return 0; + } + + return sid->outmsg[sid->outpos++]; +} + +static void ipmi_write_data(SMBusDevice *dev, uint8_t cmd, uint8_t *buf, + int len) +{ + SMBusIPMIDevice *sid = SMBUS_IPMI(dev); + IPMIBmcClass *bk = IPMI_BMC_GET_CLASS(sid->bmc); + + if (cmd != SSIF_IPMI_REQUEST) { + return; + } + + if (len < 3 || len > MAX_IPMI_MSG_SIZE || buf[0] != len - 1) { + return; + } + + memcpy(sid->inmsg, buf + 1, len - 1); + sid->inlen = len; + + sid->outlen = 0; + sid->outpos = 0; + bk->handle_command(sid->bmc, sid->inmsg, sid->inlen, sizeof(sid->inmsg), + sid->waiting_rsp); +} + +static uint8_t ipmi_read_data(SMBusDevice *dev, uint8_t cmd, int n) +{ + SMBusIPMIDevice *sid = SMBUS_IPMI(dev); + + if (cmd != SSIF_IPMI_RESPONSE) { + return 0; + } + + if (n == 0) { + return sid->outlen; + } + + return ipmi_receive_byte(dev); +} + +static const VMStateDescription vmstate_smbus_ipmi = { + .name = TYPE_SMBUS_IPMI, + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_SMBUS_DEVICE(parent, SMBusIPMIDevice), + VMSTATE_UINT8(waiting_rsp, SMBusIPMIDevice), + VMSTATE_UINT32(outpos, SMBusIPMIDevice), + VMSTATE_UINT32(outlen, SMBusIPMIDevice), + VMSTATE_UINT8_ARRAY(outmsg, SMBusIPMIDevice, MAX_IPMI_MSG_SIZE), + VMSTATE_UINT32(inlen, SMBusIPMIDevice), + VMSTATE_UINT8_ARRAY(inmsg, SMBusIPMIDevice, MAX_IPMI_MSG_SIZE), + VMSTATE_END_OF_LIST() + } +}; + +static void smbus_ipmi_realize(DeviceState *dev, Error **errp) +{ + SMBusIPMIDevice *sid = SMBUS_IPMI(dev); + IPMIInterface *ii = IPMI_INTERFACE(dev); + + if (!sid->bmc) { + error_setg(errp, "IPMI device requires a bmc attribute to be set"); + return; + } + + sid->uuid = ipmi_next_uuid(); + + sid->bmc->intf = ii; +} + +static void smbus_ipmi_init(Object *obj) +{ + SMBusIPMIDevice *sid = SMBUS_IPMI(obj); + + ipmi_bmc_find_and_link(OBJECT(obj), (Object **) &sid->bmc); +} + +static void smbus_ipmi_get_fwinfo(struct IPMIInterface *ii, IPMIFwInfo *info) +{ + SMBusIPMIDevice *sid = SMBUS_IPMI(ii); + + info->interface_name = "smbus"; + info->interface_type = IPMI_SMBIOS_SSIF; + info->ipmi_spec_major_revision = 2; + info->ipmi_spec_minor_revision = 0; + info->i2c_slave_address = sid->bmc->slave_addr; + info->base_address = sid->parent.i2c.address; + info->memspace = IPMI_MEMSPACE_SMBUS; + info->register_spacing = 1; + info->uuid = sid->uuid; +} + +static void smbus_ipmi_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + IPMIInterfaceClass *iic = IPMI_INTERFACE_CLASS(oc); + SMBusDeviceClass *sc = SMBUS_DEVICE_CLASS(oc); + + sc->quick_cmd = ipmi_quick_cmd; + sc->send_byte = ipmi_send_byte; + sc->receive_byte = ipmi_receive_byte; + sc->write_data = ipmi_write_data; + sc->read_data = ipmi_read_data; + dc->vmsd = &vmstate_smbus_ipmi; + dc->realize = smbus_ipmi_realize; + iic->set_atn = smbus_ipmi_set_atn; + iic->handle_rsp = smbus_ipmi_handle_rsp; + iic->handle_if_event = smbus_ipmi_handle_event; + iic->set_irq_enable = smbus_ipmi_set_irq_enable; + iic->get_fwinfo = smbus_ipmi_get_fwinfo; +} + +static const TypeInfo smbus_ipmi_info = { + .name = TYPE_SMBUS_IPMI, + .parent = TYPE_SMBUS_DEVICE, + .instance_size = sizeof(SMBusIPMIDevice), + .instance_init = smbus_ipmi_init, + .class_init = smbus_ipmi_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_IPMI_INTERFACE }, + { } + } +}; + +static void smbus_ipmi_register_types(void) +{ + type_register_static(&smbus_ipmi_info); +} + +type_init(smbus_ipmi_register_types) From patchwork Thu Dec 7 21:46:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121103 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8907665qgn; Thu, 7 Dec 2017 13:57:17 -0800 (PST) X-Google-Smtp-Source: AGs4zMY02yRjUJuKcTPbYSrH1v/FGPhoMzDOGj6Rtse6TnzWBQtcJP++waOHlUQUjabJGVd4F6BF X-Received: by 10.129.70.138 with SMTP id t132mr20174741ywa.226.1512683837849; Thu, 07 Dec 2017 13:57:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683837; cv=none; d=google.com; s=arc-20160816; b=INZdxnMZ0DbiSa0BmxTB8oAXUw/hAxItp+WFI4IegdrLYtxNEZbBghhE24dj69ZJ+2 4ozIuqWwPaLEqITqwEBiFceHWw6Yi5xCF1M7sYuT0BwrIBxuFe/PMnxN1gBoI3ckOF+g 7sBGbLicUiRZ6HOiDlCjvle3F8pwRYpquIa9P4jXsbYgDfqmWlvPpcu02rXJqwmvftfg huBd6AA4uhdvtL5BtR4X3fwZDCNMKrvqrFBjjBsfprI1u45Js5hZil0FfiNq7kYqG3da NMd4iAPnZvhzDpQXEjn0mLr0i5TUB/fapTBG0PFebtHiHGIBVhhZ+NyFftV0uH1r8StE UL/g== 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=goAlaAucMUaF2YX8yWhx02RKfDukhVKEstj/kswfqj0=; b=vdlAwzhgUbU1uPzMok0wprltiozC5hV3E4kqxFCYJ+uaPCCvWJtg8QB7Pf2KhCQ0/g wheX1czPd6l1cvBuudoaa4hWO975s/ui8UzCALvnNvfPJowLXkkG8ZiZo1ikRdCZyKwf NP4qqtlQdTbKuR9S6wQxEIwvT4Cy5LFSgOMqvtaBrNjlGzRsqUQpAeYr3Nn3XZ7/0bEZ ltz0GriqGKb4y1b78jj2ciLF5aFOgDnp3zV1Qt7hlZrUjFqcwgxwmTMDEBcG0A3dowb2 fSdw6EIlSFt+MWahVVfhdCV2Qpy4I8XpjofuYP3qgg0w9KNcmqXT4in4f2yy8bN7vvWc CZlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=noa6+qIv; 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 z36si1388974ywj.123.2017.12.07.13.57.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:57:17 -0800 (PST) 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=noa6+qIv; 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]:34556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN4AP-0006yg-AN for patch@linaro.org; Thu, 07 Dec 2017 16:57:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN408-00049C-Iw for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN406-0006Ze-JY for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:40 -0500 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:39837) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN406-0006Y4-9N for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:38 -0500 Received: by mail-pg0-x243.google.com with SMTP id w7so5384351pgv.6 for ; Thu, 07 Dec 2017 13:46:38 -0800 (PST) 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=goAlaAucMUaF2YX8yWhx02RKfDukhVKEstj/kswfqj0=; b=noa6+qIvkVtTLJsy1Wd/wKUqldKyE30reQ90PUERgIca54HQ5Y/hwzwNVgOfkR0XYN glKAGKxfQtVnBKvlUyqazb8liAY558K+vXI54ehIfylf6yMZYE4quBvrb1E3GGTP5t99 kp7SLPMUXyTvD4Pd4dW67ig/dgIfkIP3Y4lJ81QjGwR5/mx8DPE6aKS3tCNmV+lCofYo UsfEXElouEEdJHloAHgpXHv3sFMRS2RBaiBOhFTqkwUlTvjqstVVYD/3BmBARtCUd8Ap FdEQ6G5WFXqV6FQY1gQQ7OdJ2c7e/bP+fJTa4DGO9hLMoPideTtg8m9Y0Md0BzC4Mf7X J+ag== 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=goAlaAucMUaF2YX8yWhx02RKfDukhVKEstj/kswfqj0=; b=TMQE1encdsDbCqumdfno8yYNZmaurjhNmbJC9DNQNUnFaHNuVL9Gi3c+neuAClSB1y j3u6cfM19Z3tVWtm0rCmPqNDJYooFJlCxjqJNLzCp9QYX28j6T4xhOmf7Po0IoGkOr57 soOAEK3lUJtM+rEkyzpsSAoLZZ+JNWItwG4mUCwfa+lFrfT1s+np4hCXa2TFhMdjxU6L CJv0rorIUBNEbQPjs+MO9QJmokbs+ZDySSvQTNghaJJscfkU4XZsUWMJMEvxx95J7fdv E+WsFgeOUSQdu84JF/xv7I7HgaxDqozyXsnw8rVU41yghQKH0pOzTff7wxiFB9SdgjGg 4izA== X-Gm-Message-State: AJaThX45YIvKHX6naRf5zpmXoNcDcJSmfJU4fmfdhp0DLC0Y5w25J9aY SwytwBUgWefEtvAtYHPq+4XSqSE= X-Received: by 10.99.106.67 with SMTP id f64mr25205322pgc.453.1512683197189; Thu, 07 Dec 2017 13:46:37 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id g2sm10630014pfc.130.2017.12.07.13.46.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:33 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 1DD3C1278; Thu, 7 Dec 2017 15:46:26 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 7AD9830236A; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:18 -0600 Message-Id: <1512683181-8420-12-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c05::243 Subject: [Qemu-devel] [PATCH 11/14] acpi: Add i2c serial bus CRS 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Signed-off-by: Corey Minyard --- hw/acpi/aml-build.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 18 ++++++++++++++++++ 2 files changed, 58 insertions(+) -- 2.7.4 diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 36a6cc4..36e2263 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1662,3 +1662,43 @@ void build_slit(GArray *table_data, BIOSLinker *linker) "SLIT", table_data->len - slit_start, 1, NULL, NULL); } + +/* ACPI 5.0: 6.4.3.8.2 Serial Bus Connection Descriptors */ +static Aml *aml_serial_bus_device(uint8_t serial_bus_type, uint8_t flags, + uint16_t type_flags, + uint8_t revid, uint16_t data_length, + uint16_t resource_source_len) +{ + Aml *var = aml_alloc(); + uint16_t length = data_length + resource_source_len + 9; + + build_append_byte(var->buf, 0x8e); /* Serial Bus Connection Descriptor */ + build_append_int_noprefix(var->buf, length, sizeof(length)); + build_append_byte(var->buf, 1); /* Revision ID */ + build_append_byte(var->buf, 0); /* Resource Source Index */ + build_append_byte(var->buf, serial_bus_type); /* Serial Bus Type */ + build_append_byte(var->buf, flags); /* General Flags */ + build_append_int_noprefix(var->buf, type_flags, /* Type Specific Flags */ + sizeof(type_flags)); + build_append_byte(var->buf, revid); /* Type Specification Revision ID */ + build_append_int_noprefix(var->buf, data_length, sizeof(data_length)); + + return var; +} + +/* ACPI 5.0: 6.4.3.8.2.1 I2C Serial Bus Connection Resource Descriptor */ +Aml *aml_i2c_serial_bus_device(uint16_t address, const char *resource_source) +{ + uint16_t resource_source_len = strlen(resource_source) + 1; + Aml *var = aml_serial_bus_device(AML_SERIAL_BUS_TYPE_I2C, 0, 0, 1, + 6, resource_source_len); + + /* Connection Speed. Just set to 100K for now, it doesn't really matter. */ + build_append_int_noprefix(var->buf, 100000, 4); + build_append_int_noprefix(var->buf, address, sizeof(address)); + + /* This is a string, not a name, so just copy it directly in. */ + g_array_append_vals(var->buf, resource_source, resource_source_len); + + return var; +} diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 88d0738..26fece8 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -214,6 +214,23 @@ struct AcpiBuildTables { BIOSLinker *linker; } AcpiBuildTables; +/* + * ACPI 5.0: 6.4.3.8.2 Serial Bus Connection Descriptors + * Serial Bus Type + */ +#define AML_SERIAL_BUS_TYPE_I2C 1 +#define AML_SERIAL_BUS_TYPE_SPI 2 +#define AML_SERIAL_BUS_TYPE_UART 3 + +/* + * ACPI 5.0: 6.4.3.8.2 Serial Bus Connection Descriptors + * General Flags + */ +/* Slave Mode */ +#define AML_SERIAL_BUS_FLAG_MASTER_DEVICE (1 << 0) +/* Consumer/Producer */ +#define AML_SERIAL_BUS_FLAG_CONSUME_ONLY (1 << 1) + /** * init_aml_allocator: * @@ -338,6 +355,7 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, Aml *aml_dma(AmlDmaType typ, AmlDmaBusMaster bm, AmlTransferSize sz, uint8_t channel); Aml *aml_sleep(uint64_t msec); +Aml *aml_i2c_serial_bus_device(uint16_t address, const char *resource_source); /* Block AML object primitives */ Aml *aml_scope(const char *name_format, ...) GCC_FMT_ATTR(1, 2); From patchwork Thu Dec 7 21:46:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121102 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8907284qgn; Thu, 7 Dec 2017 13:56:51 -0800 (PST) X-Google-Smtp-Source: AGs4zMawKygrxPkLINHDCXIXixlFIqhMvd0axVZW1bWvESSPCl0qDhZRhoUa0Va+Tb4z2s4HB05q X-Received: by 10.37.42.76 with SMTP id q73mr9444568ybq.477.1512683811017; Thu, 07 Dec 2017 13:56:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683811; cv=none; d=google.com; s=arc-20160816; b=fWxMQhEvaJ7L7kh/acEIUlZ5064S1X/vX4pRNFKxnaliIpxIjr2h2VdcgJuv6KbtGB /h6S6s5v1btC7UcDJepdhPHox20VHwLqGKryRjUbLYhK6hg1RcEkhFHOTlFg7b4+uQcc hZEz8WjvfCU4z3Bsp3HXb5vnufkgJIRF8X+4Vk5GStwBnUiJ6HYlNu/beoAQwf9lPrFY CKXHTzHUQALVYlXkVG65y3ycQDYN5Ihfdi90H/PDLZOx9pKo6ReCLbwuwPv+eiHwg20f QaW4V8Fgw92/xVkvY8+eXssNVwRLfXgF42bFgqPINEhvlFrcvINVysMxjtvHdAdfr8f/ 2QHw== 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=4T+FJAb63jD5LKjLngI1pzi9a7AFohSKn8NfMwnkyEU=; b=nyl728Cqm6HY2uVWZruVSFyicml8JWrqGBwBOZ/VVa7T3gpRWZCKsm7/2XxsiRvTCD 3om/dodgzhpdALpWztzqPbA+F7VW7bqgQR2H5TxWFHnyI7+EPqQeXpmGO27/RC6d0UnV 5JqLw3wRobQTN5FGfDbTJM1WFCG/jBG7PEkj8xtOmb7Bo8i9VkQqIb5n7UfxixVGTcXP R3jGWZ2MNRkCA5zCAQ7xZScglVBBSrU7b8pIQZS5me2znFz7Hdguk0EaRejjC1ub0FNj SPxo2/zl4wURcZervU+x7I3z8irjzkHY6sc0Os2PYzjyDbEIAsugBKt7QMcGgBKIrnGp isgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=fbRib1tB; 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 n7si1275055ybm.448.2017.12.07.13.56.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:56:51 -0800 (PST) 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=fbRib1tB; 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]:34546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN49y-0005pa-G5 for patch@linaro.org; Thu, 07 Dec 2017 16:56:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN405-000466-UV for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN404-0006Vh-In for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:37 -0500 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:44437) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN404-0006U1-AO for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:36 -0500 Received: by mail-pf0-x241.google.com with SMTP id m26so5668997pfj.11 for ; Thu, 07 Dec 2017 13:46:36 -0800 (PST) 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=4T+FJAb63jD5LKjLngI1pzi9a7AFohSKn8NfMwnkyEU=; b=fbRib1tBicj+ngpbhAXc05Ruj5Sies2qQQthJ4zNJFQbcBlyCkSXl8Di1CD8Ka8xmK R8sLMaRNLPS9bjTR3ikzcoo/t0VrTeg6NJ/bhqA6PEOsLPe8LqglIr3jnYJlx0ymIf7o 8BRzXR7WJv2aeBFrxVVP/BQlRACvjKqLoWd6/eq5jMDpoV6+u3XhHZby9udUqR0VkFvy D8oHcKSkU4yqsmQ3q4Xemn3tsE9XAvaGTDNzHWe4NG4qchtcA/lCtXUlsgW6UKQZTKuJ Vv1fM2BJZy1yE+Zit650edBh/RbUQMqb5wAr4mn22yWlUoovJD3kuL2XJVNq33bakmrH Dzjg== 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=4T+FJAb63jD5LKjLngI1pzi9a7AFohSKn8NfMwnkyEU=; b=fillmGmvXjdq7uaWrbwICs1X9whbd4/7zwi71t2weRKYUnvk+AoebcSCDg+WNBl4H5 /bICsma6L8jilR5q82jsKgOle4j1/uphjo0cBYlRP4DS54JI0006a5VyJurMCzaG6zU6 M99ZFGidH553zgbAVYzHWLWlf9/gkF3IkO1imYuQfeFLF3Mag9REaS7WVwXrUnH0v6Ak PwbCj606OzO7JJ9CulAQjxJMVLh4ThUiyq4Hs5L27drfUKzWSmgediYGpXyMGe+2LseU DP71uuk6QvczrZzK75NCaIUfHLF5oZ/snVSUln2lkhSpVBYPqWZrQ4osg71Hl2gZs5BF 3+Sw== X-Gm-Message-State: AJaThX6I2o+NO2f5fC1txFjg2lD7RbWV4FGUieHChTqB2755ZNN9xP5I QQudpCWmf3ojwxR3QHqaHGldZI0= X-Received: by 10.99.100.67 with SMTP id y64mr26639996pgb.19.1512683195209; Thu, 07 Dec 2017 13:46:35 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id k2sm9780688pff.150.2017.12.07.13.46.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:30 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id F3BC7FAA; Thu, 7 Dec 2017 15:46:25 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 872EE30236B; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:19 -0600 Message-Id: <1512683181-8420-13-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c00::241 Subject: [Qemu-devel] [PATCH 12/14] ipmi: Fix SSIF ACPI handling to use the right CRS 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Signed-off-by: Corey Minyard --- hw/acpi/ipmi-stub.c | 2 +- hw/acpi/ipmi.c | 13 +++++++------ hw/i386/acpi-build.c | 2 +- include/hw/acpi/ipmi.h | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/hw/acpi/ipmi-stub.c b/hw/acpi/ipmi-stub.c index 98b6dce..6c71d6c 100644 --- a/hw/acpi/ipmi-stub.c +++ b/hw/acpi/ipmi-stub.c @@ -9,6 +9,6 @@ #include "hw/acpi/ipmi.h" -void build_acpi_ipmi_devices(Aml *table, BusState *bus) +void build_acpi_ipmi_devices(Aml *table, BusState *bus, const char *resource) { } diff --git a/hw/acpi/ipmi.c b/hw/acpi/ipmi.c index 651e2e9..96e48eb 100644 --- a/hw/acpi/ipmi.c +++ b/hw/acpi/ipmi.c @@ -13,7 +13,7 @@ #include "hw/acpi/acpi.h" #include "hw/acpi/ipmi.h" -static Aml *aml_ipmi_crs(IPMIFwInfo *info) +static Aml *aml_ipmi_crs(IPMIFwInfo *info, const char *resource) { Aml *crs = aml_resource_template(); @@ -48,7 +48,8 @@ static Aml *aml_ipmi_crs(IPMIFwInfo *info) info->register_spacing, info->register_length)); break; case IPMI_MEMSPACE_SMBUS: - aml_append(crs, aml_return(aml_int(info->base_address))); + aml_append(crs, aml_i2c_serial_bus_device(info->base_address, + resource)); break; default: abort(); @@ -61,7 +62,7 @@ static Aml *aml_ipmi_crs(IPMIFwInfo *info) return crs; } -static Aml *aml_ipmi_device(IPMIFwInfo *info) +static Aml *aml_ipmi_device(IPMIFwInfo *info, const char *resource) { Aml *dev; uint16_t version = ((info->ipmi_spec_major_revision << 8) @@ -74,14 +75,14 @@ static Aml *aml_ipmi_device(IPMIFwInfo *info) aml_append(dev, aml_name_decl("_STR", aml_string("ipmi_%s", info->interface_name))); aml_append(dev, aml_name_decl("_UID", aml_int(info->uuid))); - aml_append(dev, aml_name_decl("_CRS", aml_ipmi_crs(info))); + aml_append(dev, aml_name_decl("_CRS", aml_ipmi_crs(info, resource))); aml_append(dev, aml_name_decl("_IFT", aml_int(info->interface_type))); aml_append(dev, aml_name_decl("_SRV", aml_int(version))); return dev; } -void build_acpi_ipmi_devices(Aml *scope, BusState *bus) +void build_acpi_ipmi_devices(Aml *scope, BusState *bus, const char *resource) { BusChild *kid; @@ -101,6 +102,6 @@ void build_acpi_ipmi_devices(Aml *scope, BusState *bus) iic = IPMI_INTERFACE_GET_CLASS(obj); memset(&info, 0, sizeof(info)); iic->get_fwinfo(ii, &info); - aml_append(scope, aml_ipmi_device(&info)); + aml_append(scope, aml_ipmi_device(&info, resource)); } } diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 73519ab..84d82bc 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1340,7 +1340,7 @@ static void build_isa_devices_aml(Aml *table) } else if (!obj) { error_report("No ISA bus, unable to define IPMI ACPI data"); } else { - build_acpi_ipmi_devices(scope, BUS(obj)); + build_acpi_ipmi_devices(scope, BUS(obj), "\\_SB.PCI0.ISA"); } aml_append(table, scope); diff --git a/include/hw/acpi/ipmi.h b/include/hw/acpi/ipmi.h index ab2bb29..d68bc85 100644 --- a/include/hw/acpi/ipmi.h +++ b/include/hw/acpi/ipmi.h @@ -17,6 +17,6 @@ * bus matches the given bus. The resource is the ACPI resource that * contains the IPMI device, this is required for the I2C CRS. */ -void build_acpi_ipmi_devices(Aml *table, BusState *bus); +void build_acpi_ipmi_devices(Aml *table, BusState *bus, const char *resource); #endif /* HW_ACPI_IPMI_H */ From patchwork Thu Dec 7 21:46:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121104 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8911618qgn; Thu, 7 Dec 2017 14:01:13 -0800 (PST) X-Google-Smtp-Source: AGs4zMZFAXP9hS7IQ4xjKgncdnL3gyfUzf8HLuBn4enAYlZmLf79PdutRSBp3GdMpCtdaOp2srlh X-Received: by 10.129.155.215 with SMTP id s206mr19002910ywg.278.1512684073558; Thu, 07 Dec 2017 14:01:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512684073; cv=none; d=google.com; s=arc-20160816; b=MazFzP6B6ggl5oqJPCffoZ+QDD/p2lsWNWL0WJGSQ11i6Ztxj4lJI02JNY8dUAuG56 Mv4KrHInpiJc87tqXsuvbdfqWou8hgZGf2UF/4eBJjiG7ADfA2wPv8nvdEKZ2HKTpzgP cJx3+pw5L2lFzpixenJDGyvK+044B+heBgnXCOUkPiLRMJBj0AuHqk2ONEXb/la7jcEp IDcTFgabAOQE3S3Fa6CBJOCa/HmuLUdfu5Y0BSkMXXks00QFanT3O8HBCZVv0VTmSyRr hepzPyhWSzPNA4SGdTXXVFz16W2S0aLoRkJVYrzMnvNJK8XP7vqZfjju6CEAgzF3AtWH sidQ== 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=drB4JsMJ5WldHw1ZoSBgm2HWNZvfE/7Be9hvXPqXCtQ=; b=TDj3mQcFZcDpUEIIsFhxiUDw03SX0ZjGN9MAG8ctaaWIs4/nW7KrQePJe4hRAWzBHi TUPMz1sCA0Ev825MoPmva78lGmd54AMRwhedMgC+B1HE1wS+lBc+QSSw1MLAxo12DKbg bYkthvo9vubJXdTY60Hl5ACqKdk5J2P70JFgZUwiB1gAtDLkfFWKyFgUQPYOepgQnT7g JgOWJYhMs7BRzjUK6buotJ7ehy1EWHO9uq17Da2eNsSSx5V0oKE0y3F0DjcmulGx1zWk p3IkuCvOlNA/M1RWCQrjc6c6qKiRQP+wu9d3sp+lWoOm6vPqh40wy2pfC5djoBfKPbIQ YCvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=juHG2Ah2; 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 m85si1367351ywd.666.2017.12.07.14.01.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 14:01:13 -0800 (PST) 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=juHG2Ah2; 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]:34580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN4ED-0002Vg-4s for patch@linaro.org; Thu, 07 Dec 2017 17:01:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN409-0004A7-2S for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN407-0006af-Ef for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:41 -0500 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:37821) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN407-0006Zo-4q for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:39 -0500 Received: by mail-pg0-x241.google.com with SMTP id y6so5387977pgp.4 for ; Thu, 07 Dec 2017 13:46:39 -0800 (PST) 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=drB4JsMJ5WldHw1ZoSBgm2HWNZvfE/7Be9hvXPqXCtQ=; b=juHG2Ah26RLVuFoyXSfPvytmxWcgj30egr0nmS1oai+t4lZqqIzwE6jm03P8B6IP/4 OC1sA3sCqUPS0deHcAVLagezpcZ9kY/PqhvLUOjVOiptQmv2V3om+kvXrUqZWNVJ5gIJ 2/BSqVu4+SiKBxDRNUi0KQEWSH8TNB5d9tHeuXJ9Iea89G8SI2hbLosd6IJIfvn9uwvn z2fJnmOzJ3s71u3QH41W/U+RD2+8OcdbkkskYWiCsSpPpopdJxANjNXxe59jfdDJI1+x pw0U6ZVzUqBCgO8ng6KWfdRvxn+EDFnJl9UCQMRVCLG57hfODaLFOLK5aDQjdPosJQDH zgFg== 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=drB4JsMJ5WldHw1ZoSBgm2HWNZvfE/7Be9hvXPqXCtQ=; b=iq0mEQ6YdnWCVfaSUQRW0fBdtTqIiszv5Vs1VMJoHgplyje6dNzTQ3CScNVBvwmx9I ao5gOg79h98MKIQd6zHWnXGmj7puTliZCmsC6BGkHTu+DKzp5YbvIEEmAgVmzcepIRZF tnU2Am1I25ninHj4MnSmVsll6t7xa9oKXb60Gy1P8wDNAqXR71+N3v4f0yTH2KANZdSb Qf+S67Oy13n/RO/hl4kOfOm2d1Feif3Q9YLhBbPewj0lyWwwLxh4md+Cfdu5JQxaD8wp frSEWAnBlmGogTLlyEmbKX7fEz/yR5+GwFJeNnThkf5EqWcmPclr8R3I9MfrggqhGJSp gfbA== X-Gm-Message-State: AJaThX62AE14fL8RjsredV8WXww2NSYwdpI02TLULxV1hltDve7UrLYY Qt++/qizGDYMoyvL8Q3a3tu99II= X-Received: by 10.101.80.1 with SMTP id f1mr26910667pgo.262.1512683198058; Thu, 07 Dec 2017 13:46:38 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id u90sm12063760pfg.106.2017.12.07.13.46.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:35 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 2C19112D6; Thu, 7 Dec 2017 15:46:26 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 9388430236C; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:20 -0600 Message-Id: <1512683181-8420-14-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c05::241 Subject: [Qemu-devel] [PATCH 13/14] i386: Rename bools in PCMachineState to end in _enabled 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard This makes their function more clear and prevents conflicts when adding the actual devices to the machine state, if necessary. Signed-off-by: Corey Minyard --- hw/i386/pc.c | 18 +++++++++--------- hw/i386/pc_piix.c | 3 ++- hw/i386/pc_q35.c | 6 +++--- include/hw/i386/pc.h | 6 +++--- 4 files changed, 17 insertions(+), 16 deletions(-) -- 2.7.4 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 186545d..51f38b8 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2184,42 +2184,42 @@ static bool pc_machine_get_smbus(Object *obj, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); - return pcms->smbus; + return pcms->smbus_enabled; } static void pc_machine_set_smbus(Object *obj, bool value, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); - pcms->smbus = value; + pcms->smbus_enabled = value; } static bool pc_machine_get_sata(Object *obj, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); - return pcms->sata; + return pcms->sata_enabled; } static void pc_machine_set_sata(Object *obj, bool value, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); - pcms->sata = value; + pcms->sata_enabled = value; } static bool pc_machine_get_pit(Object *obj, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); - return pcms->pit; + return pcms->pit_enabled; } static void pc_machine_set_pit(Object *obj, bool value, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); - pcms->pit = value; + pcms->pit_enabled = value; } static void pc_machine_initfn(Object *obj) @@ -2233,9 +2233,9 @@ static void pc_machine_initfn(Object *obj) pcms->acpi_nvdimm_state.is_enabled = false; /* acpi build is enabled by default if machine supports it */ pcms->acpi_build_enabled = PC_MACHINE_GET_CLASS(pcms)->has_acpi_build; - pcms->smbus = true; - pcms->sata = true; - pcms->pit = true; + pcms->smbus_enabled = true; + pcms->sata_enabled = true; + pcms->pit_enabled = true; } static void pc_machine_reset(void) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 5e47528..7e87ef0 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -237,7 +237,8 @@ static void pc_init1(MachineState *machine, /* init basic PC hardware */ pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, true, - (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit, 0x4); + (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled, + 0x4); pc_nic_init(isa_bus, pci_bus); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index d606004..6e4bf1a 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -230,13 +230,13 @@ static void pc_q35_init(MachineState *machine) /* init basic PC hardware */ pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, !mc->no_floppy, - (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit, + (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled, 0xff0104); /* connect pm stuff to lpc */ ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pcms)); - if (pcms->sata) { + if (pcms->sata_enabled) { /* ahci and SATA device, for q35 1 ahci controller is built-in */ ahci = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_SATA1_DEV, @@ -256,7 +256,7 @@ static void pc_q35_init(MachineState *machine) ehci_create_ich9_with_companions(host_bus, 0x1d); } - if (pcms->smbus) { + if (pcms->smbus_enabled) { /* TODO: Populate SPD eeprom data. */ smbus_eeprom_init(ich9_smb_init(host_bus, PCI_DEVFN(ICH9_SMB_DEV, ICH9_SMB_FUNC), diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index ef438bd..713aa33 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -50,9 +50,9 @@ struct PCMachineState { AcpiNVDIMMState acpi_nvdimm_state; bool acpi_build_enabled; - bool smbus; - bool sata; - bool pit; + bool smbus_enabled; + bool sata_enabled; + bool pit_enabled; /* RAM information (sizes, addresses, configuration): */ ram_addr_t below_4g_mem_size, above_4g_mem_size; From patchwork Thu Dec 7 21:46:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121101 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8907201qgn; Thu, 7 Dec 2017 13:56:45 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ79tSLtx4SS9cbYXRkw6H1oifrAcVJBSJS84tU5VodXYEvUs/z9gUWke7sazVIOoCmGA7C X-Received: by 10.37.134.14 with SMTP id y14mr20333128ybk.91.1512683805653; Thu, 07 Dec 2017 13:56:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683805; cv=none; d=google.com; s=arc-20160816; b=Qxz8Ga111bCVyE/mEIfrlKbFU0ZDNHlykhbmLxUe/t8PjLCprvmoOMUlbH3brUk/wN gNgHbE1tbB1BIiPMvHB67epQuer+NAjxsKpU0//M2HAYz1n+QeNbzEvkNY4UXDDjsZM1 i4Shq2SmYk/TPEaK9NdL6aQMXY6bN6AJg8RYjtNIvZDmvQG5Ed+1z/q1sUQP3Nt/TYDE 5MrGq0mZU7hsar+JNIXKW6AbOmHkgKT7XAI0SWXUendXEI3aqJFTjhS+LQYsABjMU+6R x8sFLL4ASzts0i70PUqMt0+G1yL9GsHVsZO6U8wrKlf1gMS0qjJ8oX/FFXbsTTQHMAit SXRg== 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=b/SjwiziciK3xBKOBXP6BKSXJTtK3jn/KJF345m5JTQ=; b=k/BZjXIJPjbeE95TaFrXOrYAV6iCxcnJLboOq6szZ8spqxlALP0lHV+j/1WJfhd5Bj 1bgDPC78iVmiB7YigZWuVsucgd8aSjKH6FUtLKdfqcyK9sihdknwl1CS3sVxYkZvgdiZ u5iphwaGSKOqdpceOQaU/TAWtHc6z/K7K8xgYwlWL36aaj69O+GHkXNieO61tOKXUx60 1ZXYYuktd0EfrF+F8bwOd7VoJ0Mlxv2i/R7MDwGN8uE3m3RjrpjIinkSS9GPC8XuFtzY tD+fArtCXStn/NMZLQPTYdkfMBGOQLf5PUhfqvxLl2AaSDMloOJxTkd57qh3+iRmskL3 nAGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZySqGI/y; 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 j9si450832ywk.517.2017.12.07.13.56.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:56:45 -0800 (PST) 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=ZySqGI/y; 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]:34554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN49t-0006VA-1q for patch@linaro.org; Thu, 07 Dec 2017 16:56:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN40A-0004Br-EV for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN408-0006bI-9X for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:42 -0500 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:37714) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN407-0006at-WD for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:40 -0500 Received: by mail-pf0-x241.google.com with SMTP id n6so5683043pfa.4 for ; Thu, 07 Dec 2017 13:46:39 -0800 (PST) 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=b/SjwiziciK3xBKOBXP6BKSXJTtK3jn/KJF345m5JTQ=; b=ZySqGI/yl47meSAxBDqCYopRomAmkTHb/P7v/deia/RyycL2XQswNnFoBX8VpUv0a2 S/GR8oCGR0Je5rXv2MqD3TFht+3oCu+eR9AEk0kPnFqsu3c7eLI7vc87ajHud9tsqGq/ IKNrfh2FzbHlxop2v2RjXJFpdI570Y3Oocd8e1ZPDsHSw+2tdbBHr5ltel8q53+Bfd+R gNuYYctM1kpK1FnxWqr927NYIu5ElA2vAxG4bgON/n6Yu+T3WP81djs8LXxkC7HpqrLw szeigLH4n2VKnxnkanDTSjZnuOhahLstL82dFGjooqNFhTauAxKfAqnofHjE9gOveDJZ xJug== 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=b/SjwiziciK3xBKOBXP6BKSXJTtK3jn/KJF345m5JTQ=; b=R2gUHM6Gv5AQvtufAh535/3a5AZRqYIeSCcozn115Vqy+DdzsYXGYobbLp2ux8TcPP uFjQqOtMPQvOe/NWXEe5YcR1e/vgNPqLn11xNDbfVZH84L6FhzkS6y80fIJQAsDXJH9W sKY0WE34+yj7LaoYDaoGUw+j8RVLULt0lw+0cW6b+LD7DsMXon0O36/TQBReoxfz7AZb iJ7VTpSrNFi/i2MRfyWsJxZ2esmKbsDGmD0tyaj9IS05BMrAv3MpONNqV+n75MSDM2Ea goAaHd3jQ6JxAVYiNQIqEbs2sl5wm/KkPuQWPMotUqm2TIjjiJOQSIu+wRucpIepY8Sx J1tA== X-Gm-Message-State: AJaThX6EfZps4SChdCoJA4MxLjQR7bNi2Sarq12W1P3uIeTfkhI+Du3Y i7XXGcDTG9vDf0vvc1lWYg== X-Received: by 10.101.101.216 with SMTP id y24mr27857827pgv.236.1512683198869; Thu, 07 Dec 2017 13:46:38 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id x4sm10391441pfk.51.2017.12.07.13.46.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:35 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 39EC91303; Thu, 7 Dec 2017 15:46:26 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 9FF8030236D; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:21 -0600 Message-Id: <1512683181-8420-15-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-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:400e:c00::241 Subject: [Qemu-devel] [PATCH 14/14] pc: Add an SMB0 ACPI device to q35 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard This is so I2C devices can be found in the ACPI namespace. Currently that's only IPMI, but devices can be easily added now. Adding the devices required some PCI information, and the bus itself to be added to the PCMachineState structure. Note that this only works on Q35, the ACPI for PIIX4 is not capable of handling an SMBus device. Signed-off-by: Corey Minyard --- hw/i386/acpi-build.c | 15 +++++++++++++++ hw/i386/pc_piix.c | 12 ++++++------ hw/i386/pc_q35.c | 9 +++++---- include/hw/i386/pc.h | 2 ++ tests/acpi-test-data/q35/DSDT | Bin 7828 -> 7866 bytes tests/acpi-test-data/q35/DSDT.bridge | Bin 7845 -> 7883 bytes tests/acpi-test-data/q35/DSDT.cphp | Bin 8291 -> 8329 bytes tests/acpi-test-data/q35/DSDT.ipmibt | Bin 7903 -> 7941 bytes tests/acpi-test-data/q35/DSDT.memhp | Bin 9193 -> 9231 bytes 9 files changed, 28 insertions(+), 10 deletions(-) diff --git a/tests/acpi-test-data/q35/DSDT b/tests/acpi-test-data/q35/DSDT index aa402cca667f82ed0a2dc4969508d8f6e38ad910..3d95d15cedc4727a07652b5055bb3fb6553e9521 100644 GIT binary patch delta 62 zcmbPYyUUi#CDXEiBl|`!V@Xw2z4&0K_yA{5gXkv7U|%N#j(87G7aleN23C%E RN0%TTW(IkN%{G#mtN`_@4nP0^ delta 24 fcmX?YyVRD;CD0XFFx2QKET=2Ai7C1*w@K`Bi_T)g@;Xmft4fP R(Itq7nL(ambGu{&D**Ah4tW3o delta 24 fcmZp*yKl?o66_LkUygx+(R(9To#f_qlHsfXV=o7a diff --git a/tests/acpi-test-data/q35/DSDT.memhp b/tests/acpi-test-data/q35/DSDT.memhp index f0a27e1a3093ff7525f62b7509ea44dfe9eb8908..eb08477a6b90726dd7722d095d0be548d913c4ac 100644 GIT binary patch delta 62 zcmaFq-tWQX66_Mfufo8smbus && !pcmc->do_not_add_smb_acpi) { + build_smb0(dsdt, pcms->smbus, ICH9_SMB_DEV, ICH9_SMB_FUNC); + } } if (pcmc->legacy_cpu_hotplug) { diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 7e87ef0..2a7ae72 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -276,15 +276,14 @@ static void pc_init1(MachineState *machine, if (pcmc->pci_enabled && acpi_enabled) { DeviceState *piix4_pm; - I2CBus *smbus; smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); /* TODO: Populate SPD eeprom data. */ - smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, - pcms->gsi[9], smi_irq, - pc_machine_is_smm_enabled(pcms), - &piix4_pm); - smbus_eeprom_init(smbus, 8, NULL, 0); + pcms->smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, + pcms->gsi[9], smi_irq, + pc_machine_is_smm_enabled(pcms), + &piix4_pm); + smbus_eeprom_init(pcms->smbus, 8, NULL, 0); object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, TYPE_HOTPLUG_HANDLER, @@ -489,6 +488,7 @@ static void pc_i440fx_2_6_machine_options(MachineClass *m) pc_i440fx_2_7_machine_options(m); pcmc->legacy_cpu_hotplug = true; pcmc->linuxboot_dma_enabled = false; + pcmc->do_not_add_smb_acpi = true; SET_MACHINE_COMPAT(m, PC_COMPAT_2_6); } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 6e4bf1a..0777bb3 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -258,10 +258,10 @@ static void pc_q35_init(MachineState *machine) if (pcms->smbus_enabled) { /* TODO: Populate SPD eeprom data. */ - smbus_eeprom_init(ich9_smb_init(host_bus, - PCI_DEVFN(ICH9_SMB_DEV, ICH9_SMB_FUNC), - 0xb100), - 8, NULL, 0); + pcms->smbus = ich9_smb_init(host_bus, + PCI_DEVFN(ICH9_SMB_DEV, ICH9_SMB_FUNC), + 0xb100); + smbus_eeprom_init(pcms->smbus, 8, NULL, 0); } pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); @@ -358,6 +358,7 @@ static void pc_q35_2_6_machine_options(MachineClass *m) pc_q35_2_7_machine_options(m); pcmc->legacy_cpu_hotplug = true; pcmc->linuxboot_dma_enabled = false; + pcmc->do_not_add_smb_acpi = true; SET_MACHINE_COMPAT(m, PC_COMPAT_2_6); } diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 713aa33..5b19d10 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -39,6 +39,7 @@ struct PCMachineState { HotplugHandler *acpi_dev; ISADevice *rtc; PCIBus *bus; + I2CBus *smbus; FWCfgState *fw_cfg; qemu_irq *gsi; @@ -122,6 +123,7 @@ struct PCMachineClass { bool rsdp_in_ram; int legacy_acpi_table_size; unsigned acpi_data_size; + bool do_not_add_smb_acpi; /* SMBIOS compat: */ bool smbios_defaults;