From patchwork Mon May 30 01:08:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 68812 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1159465qge; Sun, 29 May 2016 18:09:29 -0700 (PDT) X-Received: by 10.66.168.109 with SMTP id zv13mr2628565pab.10.1464570568490; Sun, 29 May 2016 18:09:28 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sm1si8677079pac.12.2016.05.29.18.09.28; Sun, 29 May 2016 18:09:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753318AbcE3BJQ (ORCPT + 1 other); Sun, 29 May 2016 21:09:16 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35052 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752025AbcE3BJP (ORCPT ); Sun, 29 May 2016 21:09:15 -0400 Received: by mail-pf0-f195.google.com with SMTP id f144so13510364pfa.2; Sun, 29 May 2016 18:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=bF5W9yhuoaXnSTVW1l498TpwaI2L4GJodJ+YfirLrfY=; b=pBVMH2kgvCil+h9jUoWpeFZzvirwDny5WJ3U7dMBeXyfNXZfHO7YxyBnx0ar+/YnfJ 7tzdNFhiWbkHfyTL0l2Wxyj3OLFgdLJGX1hnHa9e3ZCC7KMxZ5QstzATmzCrSrAQwldL tLwUip8d28x/lvYE8/LVZj70iTaJZFz3AWcYdbMC66ZPGa9TBSQYWy6ntlAjCfqKl/Aj jC57d5pBFm7nQN7ieZ8M4ss+Prz+1D8DFGKYjRnyAaArlmOFKboDeLKIjb/BgF2OsPNw tzjPjcBmIC0flrLn8qp8+BOb6A6qpmdZ193gIemPlSBss2mIKEUuWyGhiyc5rWgZOg9n LLFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=bF5W9yhuoaXnSTVW1l498TpwaI2L4GJodJ+YfirLrfY=; b=A01qxezpxYhOyv1HTsk4QCY7tZwL6THZ9faNtcMlBqq2lQuwac/jQaBLelqbwCh46O LhdmL0GsIjMvD0+A0XUe1WYTVs43TGpmN5VDr5OFm8g3p/PIrwknLks8jjOrFjyLAIKY M1cSZZaDI8xTLOz5+LQ/B0USto/6niEYLvle/7KBOMMPS+xu/WLuhA5EzP3VOEjqYrHW BckxbcnTLBJ1648Aoldzhc6kiVn2Zx4k/Nmig9zTAgiRyOlsEaDoHMP/I5foNB2eiRdY t2cGkJaHvluDocG5Y7r58OI7F4wz5F2jh1Tl4zUsAmNMsSWRHareql23V+yI489++Z3W 1fuw== X-Gm-Message-State: ALyK8tJJaf4spAqaIN/A++JwuDBLvrw0bROrJpdq5/TJByWlySZJjXi5qljLm04pt2gh/A== X-Received: by 10.98.4.195 with SMTP id 186mr42299880pfe.154.1464570554392; Sun, 29 May 2016 18:09:14 -0700 (PDT) Received: from serve.minyard.net ([108.19.215.157]) by smtp.gmail.com with ESMTPSA id kb15sm42755729pad.28.2016.05.29.18.09.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 May 2016 18:09:13 -0700 (PDT) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 182AA930; Sun, 29 May 2016 20:09:10 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 86F97300515; Sun, 29 May 2016 20:09:08 -0500 (CDT) From: minyard@acm.org To: Jean Delvare , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, minyard@acm.org Cc: Corey Minyard Subject: [PATCH v2 03/10] i2c-i801: Move hwpec handling into block transaction Date: Sun, 29 May 2016 20:08:57 -0500 Message-Id: <1464570544-975-4-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1464570544-975-1-git-send-email-minyard@acm.org> References: <1464570544-975-1-git-send-email-minyard@acm.org> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Corey Minyard Since hwpec is only used for block transactions, move it out of i801_access() and into i801_block_transaction(). Signed-off-by: Corey Minyard --- drivers/i2c/busses/i2c-i801.c | 47 +++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 22 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 205f9d0..222be9c 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -656,11 +656,22 @@ static int i801_set_block_buffer_mode(struct i801_priv *priv) } /* Block transaction function */ -static int i801_block_transaction(struct i801_priv *priv, +static int i801_block_transaction(struct i801_priv *priv, unsigned short flags, union i2c_smbus_data *data, char read_write, - int command, int hwpec) + int command) { int result = 0; + int hwpec = (priv->features & FEATURE_SMBUS_PEC) + && (flags & I2C_CLIENT_PEC) + && command != I2C_SMBUS_QUICK + && command != I2C_SMBUS_I2C_BLOCK_DATA; + + if (hwpec) /* enable/disable hardware PEC */ + outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_CRC, + SMBAUXCTL(priv)); + else + outb_p(inb_p(SMBAUXCTL(priv)) & (~SMBAUXCTL_CRC), + SMBAUXCTL(priv)); if (read_write == I2C_SMBUS_WRITE || command == I2C_SMBUS_I2C_BLOCK_DATA) { @@ -685,6 +696,16 @@ static int i801_block_transaction(struct i801_priv *priv, read_write, command); + /* + * Some BIOSes don't like it when PEC is enabled at reboot or + * resume time, so we forcibly disable it after every + * transaction. Turn off E32B for the same reason. + */ + if (hwpec) + outb_p(inb_p(SMBAUXCTL(priv)) & + ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), + SMBAUXCTL(priv)); + return result; } @@ -693,7 +714,6 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data *data) { - int hwpec; int block = 0; int ret = 0, xact = 0; int hostc = -1; @@ -701,10 +721,6 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, pm_runtime_get_sync(&priv->pci_dev->dev); - hwpec = (priv->features & FEATURE_SMBUS_PEC) && (flags & I2C_CLIENT_PEC) - && size != I2C_SMBUS_QUICK - && size != I2C_SMBUS_I2C_BLOCK_DATA; - switch (size) { case I2C_SMBUS_QUICK: outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), @@ -773,25 +789,12 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, goto out; } - if (hwpec) /* enable/disable hardware PEC */ - outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_CRC, SMBAUXCTL(priv)); - else - outb_p(inb_p(SMBAUXCTL(priv)) & (~SMBAUXCTL_CRC), - SMBAUXCTL(priv)); - if (block) - ret = i801_block_transaction(priv, data, read_write, size, - hwpec); + ret = i801_block_transaction(priv, flags, data, read_write, + size); else ret = i801_transaction(priv, xact); - /* Some BIOSes don't like it when PEC is enabled at reboot or resume - time, so we forcibly disable it after every transaction. Turn off - E32B for the same reason. */ - if (hwpec || block) - outb_p(inb_p(SMBAUXCTL(priv)) & - ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), SMBAUXCTL(priv)); - if (hostc >= 0) pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc);