From patchwork Fri Apr 15 16:54:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 562033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6EF2C433EF for ; Fri, 15 Apr 2022 17:00:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356033AbiDORCc (ORCPT ); Fri, 15 Apr 2022 13:02:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356054AbiDORC3 (ORCPT ); Fri, 15 Apr 2022 13:02:29 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C648B3E5C9 for ; Fri, 15 Apr 2022 09:59:59 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id b15so10519294edn.4 for ; Fri, 15 Apr 2022 09:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=J0MymH7xtuu9E48UR9lg1o6xdrHIesht/4b5Wb50scs=; b=ChFHSrLLHfk+v+xhFOgz0Ou9lj2yJJPnZvBJTZS4hXK6BnWm8urfGusOKe8X6uP6vv OYBjb4TOpWkwDKCQpNti3z2aI3VY3xwapCtEI66T+5vF9orNkREca0xzmEddL1yAK62L P7WzJETBQePvFtc1iBmDWxMVgCt4auHjeHhu4/swWCNhgNQPobNK5+TgSXg/IXSPaoUt Fl9Zrtkl85GXyJV1dUSBOnDqvAEkYYeEEoaHARWY7hQLk7154xN2utnQsBfwHpQBHrN5 XI3+ezGDagGKDpW/dpZzSj+xnOvzki6b7OsWGL/Wi2cg41NVNjT4PiPOsuju6xZAa30J ak5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=J0MymH7xtuu9E48UR9lg1o6xdrHIesht/4b5Wb50scs=; b=rU4DlNVd6s0cyQJBhnizU3rlDuVa9NJvu5k85YJ5qM+ToQWkS9+4jLYIxlexI9R4Mm PHNL5y7wF17ep/OlnpMzhakkucjoxyZkWm8s6SENvUq1ic2linwOmk5bNeNxhUwNohr4 AtayzlBzwp1iZyulQwqWGURDvuuAgbDLzm/9S7j2YQpgvV8wzrD5HWQbgmjcMgJWMIPK SDq9n16cHU2G7grBBvNVIc4AHY9EDzSTygwzPl4ZdrlR92iAorpUkKmeO2tLWgHru0EV SFa5puCDKKuGYWIHYER8OmdnbJ4q3chpDjWafUk3P2vsFnmS9+z9DpLzZPib+iK1V8NL bPPg== X-Gm-Message-State: AOAM531kFT3Zlcmaosyzcy6YzcCDahuGL72Bhn5SOQcbR96EDNbZcXNz FMcpeSMjbjGKMspx4Ghlam8DmT8c9Qk= X-Google-Smtp-Source: ABdhPJwa0P0d7u/ram1ThJ5YXF2F281QeMBTG3sctlUeBBES5l36Oj7uZ5aN0kNhIVi1Uh7HIg6xDA== X-Received: by 2002:aa7:c793:0:b0:408:4a69:90b4 with SMTP id n19-20020aa7c793000000b004084a6990b4mr194081eds.58.1650041998274; Fri, 15 Apr 2022 09:59:58 -0700 (PDT) Received: from ?IPV6:2a01:c22:6faa:ed00:b906:e23f:946b:b9f7? (dynamic-2a01-0c22-6faa-ed00-b906-e23f-946b-b9f7.c22.pool.telefonica.de. [2a01:c22:6faa:ed00:b906:e23f:946b:b9f7]) by smtp.googlemail.com with ESMTPSA id 10-20020a170906310a00b006e834953b55sm1803245ejx.27.2022.04.15.09.59.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Apr 2022 09:59:57 -0700 (PDT) Message-ID: <05bec021-6958-0157-b825-619ac21ddd41@gmail.com> Date: Fri, 15 Apr 2022 18:54:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: [PATCH 1/8] i2c: i801: improve interrupt handler Content-Language: en-US From: Heiner Kallweit To: Jean Delvare Cc: "linux-i2c@vger.kernel.org" References: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> In-Reply-To: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Not sure if it can happen, but better play safe: If SMBHSTSTS_BYTE_DONE and an error flag is set, then don't trust the result and skip calling i801_isr_byte_done(). In addition clear status bit SMBHSTSTS_BYTE_DONE in the main interrupt handler, this allows to simplify the code a little. Signed-off-by: Heiner Kallweit --- drivers/i2c/busses/i2c-i801.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index ff706349b..c481f121d 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -556,9 +556,6 @@ static void i801_isr_byte_done(struct i801_priv *priv) /* Write next byte, except for IRQ after last byte */ outb_p(priv->data[++priv->count], SMBBLKDAT(priv)); } - - /* Clear BYTE_DONE to continue with next byte */ - outb_p(SMBHSTSTS_BYTE_DONE, SMBHSTSTS(priv)); } static irqreturn_t i801_host_notify_isr(struct i801_priv *priv) @@ -588,7 +585,6 @@ static irqreturn_t i801_host_notify_isr(struct i801_priv *priv) * BUS_ERR - SMI# transaction collision * FAILED - transaction was canceled due to a KILL request * When any of these occur, update ->status and signal completion. - * ->status must be cleared before kicking off the next transaction. * * 2) For byte-by-byte (I2C read/write) transactions, one BYTE_DONE interrupt * occurs for each byte of a byte-by-byte to prepare the next byte. @@ -613,23 +609,18 @@ static irqreturn_t i801_isr(int irq, void *dev_id) } status = inb_p(SMBHSTSTS(priv)); - if (status & SMBHSTSTS_BYTE_DONE) + if ((status & SMBHSTSTS_BYTE_DONE) && !(status & STATUS_ERROR_FLAGS)) i801_isr_byte_done(priv); /* - * Clear remaining IRQ sources: Completion of last command, errors - * and the SMB_ALERT signal. SMB_ALERT status is set after signal - * assertion independently of the interrupt generation being blocked - * or not so clear it always when the status is set. - */ - status &= SMBHSTSTS_INTR | STATUS_ERROR_FLAGS | SMBHSTSTS_SMBALERT_STS; - if (status) - outb_p(status, SMBHSTSTS(priv)); - status &= ~SMBHSTSTS_SMBALERT_STS; /* SMB_ALERT not reported */ - /* - * Report transaction result. - * ->status must be cleared before the next transaction is started. + * Clear IRQ sources: SMB_ALERT status is set after signal assertion + * independently of the interrupt generation being blocked or not + * so clear it always when the status is set. */ + status &= STATUS_FLAGS | SMBHSTSTS_SMBALERT_STS; + outb_p(status, SMBHSTSTS(priv)); + + status &= STATUS_ERROR_FLAGS | SMBHSTSTS_INTR; if (status) { priv->status = status; complete(&priv->done); From patchwork Fri Apr 15 16:55:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 562698 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43E01C433F5 for ; Fri, 15 Apr 2022 17:00:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356038AbiDORCd (ORCPT ); Fri, 15 Apr 2022 13:02:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356062AbiDORCb (ORCPT ); Fri, 15 Apr 2022 13:02:31 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAF8049F0C for ; Fri, 15 Apr 2022 10:00:00 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id u15so16214885ejf.11 for ; Fri, 15 Apr 2022 10:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=4EUc5eu3+xvolXArykyKoCVeF73qdK5q1IIqR9wkbGM=; b=k7Rn0Dh5HF/+ZQdbHoa4XeQB9O/ghHpSjNNhgFc5cjpqo43wM/5aAVUTQvS9tTKuTM 31sK/xO+xUrjYO5XUbAcBaFjV0aOF+zKGjCoALa5vML/jDZOgWDY/VAI7SzdbvOwzUkI 26Ds9E8QW8c/E4s9HrLq37m7LUwqRN9yFWV22y1Fg0k30CzBCA16SvvPbmu6lJtkMK5c OHJcg7FR4NIK0bI9mH/KpaIIbydchbGOuutbAQaFyXw/YIuTqljQTlw+68HMWbUgc/QX 3iz1rmEJuQJNp1L3Gn98QtTqdG6Y5t4pPgImXsWUJqePn5yX/a8LfC5/lW9JQRNwHVIV TFPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=4EUc5eu3+xvolXArykyKoCVeF73qdK5q1IIqR9wkbGM=; b=w4lQ12jqRL+IH1d8v6ZfHDXyHE0aTBflD2SIcpZRVTcwZ8AZtJYikZVWR97pffRqMT uB8ERfDtpFaDBh3jbcF6wslhlxr7R0GG0QWSldbY7Z/qeH4IJRQqZl210z44evAiCYQA KH6xphmq/8qheAm6aDvq3Mk6tuim0ZwziG4cAJ3UJIfh6Tit/r79kKr5wM/VT5dtvH2b z9vZa+azURLlcsvi3julmLvD4Feki5EKSQ3IiunrVq0ZmjeuKg/X0jQb7RBlDwKHUtUJ h44/Bf8pPfukV6t6YpPm/IByySQldw5Sk7e6QdwdEApyrtXzd4wIcVVCtw4K2o7SEOO6 534g== X-Gm-Message-State: AOAM532eosaY0z0xM58+638hWviTytvX68dZKrbw9dEum4hLA9j/b1F1 XtIjY0e2C63wY+eFEiM7KmlIBhfm9Is= X-Google-Smtp-Source: ABdhPJwejEF4sKkrfMsbiUcSh5Ix12v2AZF9My27cpvMnaBMqMA1eE1QPzhbdIfHxlmncgLuetkdyg== X-Received: by 2002:a17:906:944a:b0:6e8:ac79:2b6e with SMTP id z10-20020a170906944a00b006e8ac792b6emr35194ejx.377.1650041999539; Fri, 15 Apr 2022 09:59:59 -0700 (PDT) Received: from ?IPV6:2a01:c22:6faa:ed00:b906:e23f:946b:b9f7? (dynamic-2a01-0c22-6faa-ed00-b906-e23f-946b-b9f7.c22.pool.telefonica.de. [2a01:c22:6faa:ed00:b906:e23f:946b:b9f7]) by smtp.googlemail.com with ESMTPSA id oz20-20020a170906cd1400b006e872188edbsm1849621ejb.104.2022.04.15.09.59.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Apr 2022 09:59:58 -0700 (PDT) Message-ID: <08ccd96f-deca-72b9-e14e-917434736ca3@gmail.com> Date: Fri, 15 Apr 2022 18:55:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: [PATCH 2/8] i2c: i801: make FEATURE_HOST_NOTIFY dependent on FEATURE_IRQ Content-Language: en-US From: Heiner Kallweit To: Jean Delvare Cc: "linux-i2c@vger.kernel.org" References: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> In-Reply-To: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Host notification uses an interrupt, therefore it makes sense only if interrupts are enabled. Make this dependency explicit by removing FEATURE_HOST_NOTIFY if FEATURE_IRQ isn't set. Signed-off-by: Heiner Kallweit --- drivers/i2c/busses/i2c-i801.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index c481f121d..eccdc7035 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -1756,6 +1756,9 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) dev_info(&dev->dev, "SMBus using %s\n", priv->features & FEATURE_IRQ ? "PCI interrupt" : "polling"); + if (!(priv->features & FEATURE_IRQ)) + priv->features &= ~FEATURE_HOST_NOTIFY; + i801_add_tco(priv); snprintf(priv->adapter.name, sizeof(priv->adapter.name), From patchwork Fri Apr 15 16:55:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 562032 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26C17C433FE for ; Fri, 15 Apr 2022 17:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356039AbiDORCe (ORCPT ); Fri, 15 Apr 2022 13:02:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356070AbiDORCc (ORCPT ); Fri, 15 Apr 2022 13:02:32 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ADB0488B7 for ; Fri, 15 Apr 2022 10:00:02 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id k23so16289561ejd.3 for ; Fri, 15 Apr 2022 10:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=Z+tEIRxzosvV7SqajQEjAFtBxIP1vn138zIQHL73Ujc=; b=mWPqpudcZlNdomSwHm0BR4boe4TTvsGJvFMYKR+vawj3QOt4V3CZM78Qkptup5JRNZ ZKs+YWAxtgrTqyctdiOzM16TEG7ozgyOEJ5iFU3Mzo0nmkb1ljbCpW6YoZqlwm8vEylF BCs7j2YeI1EgBRojsnBb1FLMv7cq8KiOqusbbh8sReooDCg9/iEOA1JKsXuxg4ZLZJuO apD71ItiJShC3jQMIdROYidX8cFVLbi2IDoPSyQ70wxTsggbiFO2+68Jb97rPqhyzQBJ xYMk4uB3xoemi4QHkTFZok+Zc5lTN2fW67Pq7VuYiktl1Ig2VquUUipegR34/lbvyNsh 9HIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=Z+tEIRxzosvV7SqajQEjAFtBxIP1vn138zIQHL73Ujc=; b=cDI1dyPilUp+neZu1/EevnT2Vk3GZHI/5asyHxdRwrcUQOetFub9KGps9fnFNMiydJ XjfGbnWY8Utdrvxc+kzamckJlTwUXnOK6lY0Q89m7/6K3EqkRKGTClhnga6FCO9PsYVm SjsipCNs+bjk6PJ3t3gWpih9YHkd17fgJddrDf0VqJ/ttvegxV2clGxnQcEbIksjeMGi m0zVvl3mIES6hEa7Q5TVM7J2BXzwP4Z2iLqwZSM7m/zFDgh1t0LrM+SMuGsNStkf863h 87rqG5Ccc4nsQD3PD76T81YgAU7UOqUR5oFDnsjCGDirQ6DC2ZcVtcRMiBKOUKrEi/Wd 3Mgg== X-Gm-Message-State: AOAM532Na+HfdGZ1q26uwxRF6kgcl+7x0VyAzyFKOKMeD86VzosugTx9 7+58nAA4bDxhHPzwhP0DPlsDk4n7jB0= X-Google-Smtp-Source: ABdhPJx8DYj7GT1XHD70dnx/q0ztGvpn6qErie4APCETiygXgBFoSdcigmFi/gp3xP8p6z7vOoYnug== X-Received: by 2002:a17:907:1b25:b0:6da:8206:fc56 with SMTP id mp37-20020a1709071b2500b006da8206fc56mr46100ejc.81.1650042000655; Fri, 15 Apr 2022 10:00:00 -0700 (PDT) Received: from ?IPV6:2a01:c22:6faa:ed00:b906:e23f:946b:b9f7? (dynamic-2a01-0c22-6faa-ed00-b906-e23f-946b-b9f7.c22.pool.telefonica.de. [2a01:c22:6faa:ed00:b906:e23f:946b:b9f7]) by smtp.googlemail.com with ESMTPSA id gq5-20020a170906e24500b006e87644f2f7sm1832442ejb.38.2022.04.15.09.59.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Apr 2022 10:00:00 -0700 (PDT) Message-ID: <5e5774c2-26a2-dd4b-29ca-e1eca32ef889@gmail.com> Date: Fri, 15 Apr 2022 18:55:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: [PATCH 3/8] i2c: i801: make FEATURE_BLOCK_PROC dependent on FEATURE_BLOCK_BUFFER Content-Language: en-US From: Heiner Kallweit To: Jean Delvare Cc: "linux-i2c@vger.kernel.org" References: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> In-Reply-To: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org According to the datasheet the block process call requires block buffer mode. The user may disable block buffer mode by module parameter disable_features, in such a case we have to clear FEATURE_BLOCK_PROC. Signed-off-by: Heiner Kallweit --- drivers/i2c/busses/i2c-i801.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index eccdc7035..1d8182901 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -1675,6 +1675,9 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) } priv->features &= ~disable_features; + if (!(priv->features & FEATURE_BLOCK_BUFFER)) + priv->features &= ~FEATURE_BLOCK_PROC; + err = pcim_enable_device(dev); if (err) { dev_err(&dev->dev, "Failed to enable SMBus PCI device (%d)\n", From patchwork Fri Apr 15 16:56:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 562697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 577AFC433F5 for ; Fri, 15 Apr 2022 17:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356035AbiDORCf (ORCPT ); Fri, 15 Apr 2022 13:02:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356073AbiDORCc (ORCPT ); Fri, 15 Apr 2022 13:02:32 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E7073DA43 for ; Fri, 15 Apr 2022 10:00:03 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id b24so10488182edu.10 for ; Fri, 15 Apr 2022 10:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=GLRRJ2iaJwRECu/ap1UxHntOmtdYLUu5sPHYjcQwSIY=; b=oSkOUtVNkBqFLQ7DxKU2Z3YK4Zvcm2HPS0szIk35UGkqs68FhqcaEw5Cx1VuvQyyYJ dVfC6CqLhK4vP+BN6ZIeiGDELmkVqj6UXNG1nUwWjX3SPSWASJPeO9KqIaPEvuHHfX1r QlC6JrdNjcPLgYBnEPJ/l+eobymQr5mQCk6S/HNt9OOeEG6q5F19JRj36lSenjLZMGwE UPsPoXOE1N0sgtC/C3cEbfZYcsOPjqA3dbppEiJVGS8V3yXtB3SFIa5HOCV+dfNoyGHE leVws5C+mQQVT7kcWUGSQTAuUwTFKmCWvjXr1VJ1t9HpmrK8EkydKnPOLjdwVd2djCRv OrMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=GLRRJ2iaJwRECu/ap1UxHntOmtdYLUu5sPHYjcQwSIY=; b=ehClVIgqVV7lw8snlzefUr1MjySa0FDLxk2//hQyR3IvN/rsNuFW+F+YCMu2UF0sgz /Sv3NcYbt8Brk3/SoqflDIwURmGBstx4E/LfNLrH6aDrB58fitk+NXoIFhZHSWebX/Zy ivI/LzZzBktiGeFvhD+bc4OygDmW865M98Sa+02kHcOMp65hGYUIUAfzuF+6Stl0R6h+ Uev841v9qHFlhwCa11p6N/OpyZpN/sVEsUfO4KLYhkQM+4k3HozERjCBQeawiG7j0AjW ehJH74mjSsBTbfKvQaX7iE9ZkYTtnHCo+BlixJb0b40lYqvrYciMs8svZfC1lDaopgbo e9bQ== X-Gm-Message-State: AOAM531VuK8RKBeTgrxDleIRiruY3lJy1bj7j6khORoDQ9NbCIcSeJjQ 7ZsQbCpvS1aYGmf7lOak351HqsNqqbg= X-Google-Smtp-Source: ABdhPJwOYIvjiyNSTMNsNPLQ2XZh88cK6ousbzWsNYEGw9tS34/USZhc2T4zuHZQOlUTYRIWYdeIaA== X-Received: by 2002:a05:6402:42d4:b0:412:c26b:789 with SMTP id i20-20020a05640242d400b00412c26b0789mr183345edc.232.1650042001743; Fri, 15 Apr 2022 10:00:01 -0700 (PDT) Received: from ?IPV6:2a01:c22:6faa:ed00:b906:e23f:946b:b9f7? (dynamic-2a01-0c22-6faa-ed00-b906-e23f-946b-b9f7.c22.pool.telefonica.de. [2a01:c22:6faa:ed00:b906:e23f:946b:b9f7]) by smtp.googlemail.com with ESMTPSA id fq6-20020a1709069d8600b006e891c0b7e0sm1823468ejc.129.2022.04.15.10.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Apr 2022 10:00:01 -0700 (PDT) Message-ID: <1f81a126-11b4-aa22-1e2c-9824e0ad730c@gmail.com> Date: Fri, 15 Apr 2022 18:56:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: [PATCH 4/8] i2c: i801: enable FEATURE_IRQ and FEATURE_I2C_BLOCK_READ on all chip versions Content-Language: en-US From: Heiner Kallweit To: Jean Delvare Cc: "linux-i2c@vger.kernel.org" References: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> In-Reply-To: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org According to the datasheets interrupt mode and i2c block read are supported on all chip versions. Therefore set both feature flags for all chip versions. Note: Don't remove the two feature flags as such (at least for now), so that in case of a problem users can use the disable_features module parameter to disable a problematic feature. Patch is based solely on the datasheets. I don't have old enough test hw, therefore the patch is compile-tested only. Signed-off-by: Heiner Kallweit --- drivers/i2c/busses/i2c-i801.c | 140 +++++++++++++++++----------------- 1 file changed, 69 insertions(+), 71 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 1d8182901..a9737f14d 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -12,70 +12,70 @@ /* * Supports the following Intel I/O Controller Hubs (ICH): * - * I/O Block I2C - * region SMBus Block proc. block - * Chip name PCI ID size PEC buffer call read - * --------------------------------------------------------------------------- - * 82801AA (ICH) 0x2413 16 no no no no - * 82801AB (ICH0) 0x2423 16 no no no no - * 82801BA (ICH2) 0x2443 16 no no no no - * 82801CA (ICH3) 0x2483 32 soft no no no - * 82801DB (ICH4) 0x24c3 32 hard yes no no - * 82801E (ICH5) 0x24d3 32 hard yes yes yes - * 6300ESB 0x25a4 32 hard yes yes yes - * 82801F (ICH6) 0x266a 32 hard yes yes yes - * 6310ESB/6320ESB 0x269b 32 hard yes yes yes - * 82801G (ICH7) 0x27da 32 hard yes yes yes - * 82801H (ICH8) 0x283e 32 hard yes yes yes - * 82801I (ICH9) 0x2930 32 hard yes yes yes - * EP80579 (Tolapai) 0x5032 32 hard yes yes yes - * ICH10 0x3a30 32 hard yes yes yes - * ICH10 0x3a60 32 hard yes yes yes - * 5/3400 Series (PCH) 0x3b30 32 hard yes yes yes - * 6 Series (PCH) 0x1c22 32 hard yes yes yes - * Patsburg (PCH) 0x1d22 32 hard yes yes yes - * Patsburg (PCH) IDF 0x1d70 32 hard yes yes yes - * Patsburg (PCH) IDF 0x1d71 32 hard yes yes yes - * Patsburg (PCH) IDF 0x1d72 32 hard yes yes yes - * DH89xxCC (PCH) 0x2330 32 hard yes yes yes - * Panther Point (PCH) 0x1e22 32 hard yes yes yes - * Lynx Point (PCH) 0x8c22 32 hard yes yes yes - * Lynx Point-LP (PCH) 0x9c22 32 hard yes yes yes - * Avoton (SOC) 0x1f3c 32 hard yes yes yes - * Wellsburg (PCH) 0x8d22 32 hard yes yes yes - * Wellsburg (PCH) MS 0x8d7d 32 hard yes yes yes - * Wellsburg (PCH) MS 0x8d7e 32 hard yes yes yes - * Wellsburg (PCH) MS 0x8d7f 32 hard yes yes yes - * Coleto Creek (PCH) 0x23b0 32 hard yes yes yes - * Wildcat Point (PCH) 0x8ca2 32 hard yes yes yes - * Wildcat Point-LP (PCH) 0x9ca2 32 hard yes yes yes - * BayTrail (SOC) 0x0f12 32 hard yes yes yes - * Braswell (SOC) 0x2292 32 hard yes yes yes - * Sunrise Point-H (PCH) 0xa123 32 hard yes yes yes - * Sunrise Point-LP (PCH) 0x9d23 32 hard yes yes yes - * DNV (SOC) 0x19df 32 hard yes yes yes - * Emmitsburg (PCH) 0x1bc9 32 hard yes yes yes - * Broxton (SOC) 0x5ad4 32 hard yes yes yes - * Lewisburg (PCH) 0xa1a3 32 hard yes yes yes - * Lewisburg Supersku (PCH) 0xa223 32 hard yes yes yes - * Kaby Lake PCH-H (PCH) 0xa2a3 32 hard yes yes yes - * Gemini Lake (SOC) 0x31d4 32 hard yes yes yes - * Cannon Lake-H (PCH) 0xa323 32 hard yes yes yes - * Cannon Lake-LP (PCH) 0x9da3 32 hard yes yes yes - * Cedar Fork (PCH) 0x18df 32 hard yes yes yes - * Ice Lake-LP (PCH) 0x34a3 32 hard yes yes yes - * Ice Lake-N (PCH) 0x38a3 32 hard yes yes yes - * Comet Lake (PCH) 0x02a3 32 hard yes yes yes - * Comet Lake-H (PCH) 0x06a3 32 hard yes yes yes - * Elkhart Lake (PCH) 0x4b23 32 hard yes yes yes - * Tiger Lake-LP (PCH) 0xa0a3 32 hard yes yes yes - * Tiger Lake-H (PCH) 0x43a3 32 hard yes yes yes - * Jasper Lake (SOC) 0x4da3 32 hard yes yes yes - * Comet Lake-V (PCH) 0xa3a3 32 hard yes yes yes - * Alder Lake-S (PCH) 0x7aa3 32 hard yes yes yes - * Alder Lake-P (PCH) 0x51a3 32 hard yes yes yes - * Alder Lake-M (PCH) 0x54a3 32 hard yes yes yes - * Raptor Lake-S (PCH) 0x7a23 32 hard yes yes yes + * I/O Block + * region SMBus Block proc. + * Chip name PCI ID size PEC buffer call + * ------------------------------------------------------------------- + * 82801AA (ICH) 0x2413 16 no no no + * 82801AB (ICH0) 0x2423 16 no no no + * 82801BA (ICH2) 0x2443 16 no no no + * 82801CA (ICH3) 0x2483 32 soft no no + * 82801DB (ICH4) 0x24c3 32 hard yes no + * 82801E (ICH5) 0x24d3 32 hard yes yes + * 6300ESB 0x25a4 32 hard yes yes + * 82801F (ICH6) 0x266a 32 hard yes yes + * 6310ESB/6320ESB 0x269b 32 hard yes yes + * 82801G (ICH7) 0x27da 32 hard yes yes + * 82801H (ICH8) 0x283e 32 hard yes yes + * 82801I (ICH9) 0x2930 32 hard yes yes + * EP80579 (Tolapai) 0x5032 32 hard yes yes + * ICH10 0x3a30 32 hard yes yes + * ICH10 0x3a60 32 hard yes yes + * 5/3400 Series (PCH) 0x3b30 32 hard yes yes + * 6 Series (PCH) 0x1c22 32 hard yes yes + * Patsburg (PCH) 0x1d22 32 hard yes yes + * Patsburg (PCH) IDF 0x1d70 32 hard yes yes + * Patsburg (PCH) IDF 0x1d71 32 hard yes yes + * Patsburg (PCH) IDF 0x1d72 32 hard yes yes + * DH89xxCC (PCH) 0x2330 32 hard yes yes + * Panther Point (PCH) 0x1e22 32 hard yes yes + * Lynx Point (PCH) 0x8c22 32 hard yes yes + * Lynx Point-LP (PCH) 0x9c22 32 hard yes yes + * Avoton (SOC) 0x1f3c 32 hard yes yes + * Wellsburg (PCH) 0x8d22 32 hard yes yes + * Wellsburg (PCH) MS 0x8d7d 32 hard yes yes + * Wellsburg (PCH) MS 0x8d7e 32 hard yes yes + * Wellsburg (PCH) MS 0x8d7f 32 hard yes yes + * Coleto Creek (PCH) 0x23b0 32 hard yes yes + * Wildcat Point (PCH) 0x8ca2 32 hard yes yes + * Wildcat Point-LP (PCH) 0x9ca2 32 hard yes yes + * BayTrail (SOC) 0x0f12 32 hard yes yes + * Braswell (SOC) 0x2292 32 hard yes yes + * Sunrise Point-H (PCH) 0xa123 32 hard yes yes + * Sunrise Point-LP (PCH) 0x9d23 32 hard yes yes + * DNV (SOC) 0x19df 32 hard yes yes + * Emmitsburg (PCH) 0x1bc9 32 hard yes yes + * Broxton (SOC) 0x5ad4 32 hard yes yes + * Lewisburg (PCH) 0xa1a3 32 hard yes yes + * Lewisburg Supersku (PCH) 0xa223 32 hard yes yes + * Kaby Lake PCH-H (PCH) 0xa2a3 32 hard yes yes + * Gemini Lake (SOC) 0x31d4 32 hard yes yes + * Cannon Lake-H (PCH) 0xa323 32 hard yes yes + * Cannon Lake-LP (PCH) 0x9da3 32 hard yes yes + * Cedar Fork (PCH) 0x18df 32 hard yes yes + * Ice Lake-LP (PCH) 0x34a3 32 hard yes yes + * Ice Lake-N (PCH) 0x38a3 32 hard yes yes + * Comet Lake (PCH) 0x02a3 32 hard yes yes + * Comet Lake-H (PCH) 0x06a3 32 hard yes yes + * Elkhart Lake (PCH) 0x4b23 32 hard yes yes + * Tiger Lake-LP (PCH) 0xa0a3 32 hard yes yes + * Tiger Lake-H (PCH) 0x43a3 32 hard yes yes + * Jasper Lake (SOC) 0x4da3 32 hard yes yes + * Comet Lake-V (PCH) 0xa3a3 32 hard yes yes + * Alder Lake-S (PCH) 0x7aa3 32 hard yes yes + * Alder Lake-P (PCH) 0x51a3 32 hard yes yes + * Alder Lake-M (PCH) 0x54a3 32 hard yes yes + * Raptor Lake-S (PCH) 0x7a23 32 hard yes yes * * Features supported by this driver: * Software PEC no @@ -168,7 +168,7 @@ #define I801_WORD_DATA 0x0C #define I801_PROC_CALL 0x10 #define I801_BLOCK_DATA 0x14 -#define I801_I2C_BLOCK_DATA 0x18 /* ICH5 and later */ +#define I801_I2C_BLOCK_DATA 0x18 #define I801_BLOCK_PROC_CALL 0x1C /* I801 Host Control register bits */ @@ -973,11 +973,8 @@ static const struct i2c_algorithm smbus_algorithm = { .functionality = i801_func, }; -#define FEATURES_ICH5 (FEATURE_BLOCK_PROC | FEATURE_I2C_BLOCK_READ | \ - FEATURE_IRQ | FEATURE_SMBUS_PEC | \ - FEATURE_BLOCK_BUFFER | FEATURE_HOST_NOTIFY) -#define FEATURES_ICH4 (FEATURE_SMBUS_PEC | FEATURE_BLOCK_BUFFER | \ - FEATURE_HOST_NOTIFY) +#define FEATURES_ICH4 (FEATURE_SMBUS_PEC | FEATURE_BLOCK_BUFFER | FEATURE_HOST_NOTIFY) +#define FEATURES_ICH5 (FEATURES_ICH4 | FEATURE_BLOCK_PROC) static const struct pci_device_id i801_ids[] = { { PCI_DEVICE_DATA(INTEL, 82801AA_3, 0) }, @@ -1665,7 +1662,8 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) mutex_init(&priv->acpi_lock); priv->pci_dev = dev; - priv->features = id->driver_data; + priv->features = FEATURE_IRQ | FEATURE_I2C_BLOCK_READ; + priv->features |= id->driver_data; /* Disable features on user request */ for (i = 0; i < ARRAY_SIZE(i801_feature_names); i++) { From patchwork Fri Apr 15 16:57:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 562031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84CD5C433EF for ; Fri, 15 Apr 2022 17:00:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356040AbiDORCn (ORCPT ); Fri, 15 Apr 2022 13:02:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356037AbiDORCm (ORCPT ); Fri, 15 Apr 2022 13:02:42 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C17453E31 for ; Fri, 15 Apr 2022 10:00:13 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id v15so10483255edb.12 for ; Fri, 15 Apr 2022 10:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=0reQG7gMKan1Kr0GhCO377AwhypphpJo7jZUqRk4820=; b=bqxJaz4rQm7b6Tl2G5HjpBrKUxfuC25aRj24NY0CsPmk01+XMPXKGcWeqWe4jk7VCG rqMLEFisI62KfRZ7b5h6lsMFmdHkR8ngdMgoUWiQ03bu01/JnDbLGRMLTjG9QXbwdDh2 ZlyOETPvqsgqbxVkoAcDn5iImal6LH3/kBDKrasB4cibQF0o4K/963M33VEXIyoI8POq 816arSTrgEywI8hivMiHvBhpqlJXdYv13/LmLUvCuhHG78d6VBfozM3dnJLVuTs3SQte 9sM8p+O4WxcsxiwOHRQu4n5DBgGrxTIlsAGI11mtTzwxc1xlcTnLojVp+cgS8Z8SBxCJ kOZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=0reQG7gMKan1Kr0GhCO377AwhypphpJo7jZUqRk4820=; b=N+Ei3acWhMdsMGiU7pAm2cF8Mn0mjPBiqqqWaQjnKq+0f1htDrXC0MEWlefhA5lzL7 km4k685fap5P8dF1KUFywzu3oZ4X4+TBYrWF4aIfM5vLQ0IetiVenjGmC3WA1YAFu+BP 2YlL1fvVF1dYpAVvdugxd9+7NqRxVcCvuy0c0chHDHUtJIkHgSCurVTRKQbkuDOv1vYR qQFT4fXQT2RD/NtjxrLhBLnNHdI3ag9fAeRbP7kQ9K0S85TqWpcv8LGojQliaR/nsqU2 tcC2VUYZI4BtIGOU3P85xtHHVknB6ISmZuH+3fd8/3mFzyJHDr4ppnZ4TQ0DzUfKZd2G 3u0g== X-Gm-Message-State: AOAM532Oa/hF6D1GS6Zd4Bk5SNJIdjnJDTCZcDMESf/ENmuXKWQv5gX6 3mii+8GvaR96huU7UN9/n+7HsiuFI3Q= X-Google-Smtp-Source: ABdhPJwTeypJW8YmLM4zWF3GY9pt59E1lm/oQBusdlHlB+VYR/OWY7OGvblg/l61+81n9g2R1PZdbw== X-Received: by 2002:a05:6402:22b5:b0:41d:7637:98b8 with SMTP id cx21-20020a05640222b500b0041d763798b8mr158808edb.69.1650042002962; Fri, 15 Apr 2022 10:00:02 -0700 (PDT) Received: from ?IPV6:2a01:c22:6faa:ed00:b906:e23f:946b:b9f7? (dynamic-2a01-0c22-6faa-ed00-b906-e23f-946b-b9f7.c22.pool.telefonica.de. [2a01:c22:6faa:ed00:b906:e23f:946b:b9f7]) by smtp.googlemail.com with ESMTPSA id e9-20020a17090618e900b006e8669f3941sm1827069ejf.209.2022.04.15.10.00.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Apr 2022 10:00:02 -0700 (PDT) Message-ID: Date: Fri, 15 Apr 2022 18:57:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: [PATCH 5/8] i2c: i801: add helper i801_set_hstadd() Content-Language: en-US From: Heiner Kallweit To: Jean Delvare Cc: "linux-i2c@vger.kernel.org" References: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> In-Reply-To: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Factor out setting SMBHSTADD to a helper. The current code makes the assumption that constant I2C_SMBUS_READ has bit 0 set, that's not ideal. Therefore let the new helper explicitly check for I2C_SMBUS_READ. Signed-off-by: Heiner Kallweit --- drivers/i2c/busses/i2c-i801.c | 41 ++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index a9737f14d..bf77f8640 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -771,6 +771,14 @@ static int i801_block_transaction(struct i801_priv *priv, union i2c_smbus_data * return result; } +static void i801_set_hstadd(struct i801_priv *priv, u8 addr, char read_write) +{ + addr <<= 1; + if (read_write == I2C_SMBUS_READ) + addr |= 0x01; + outb_p(addr, SMBHSTADD(priv)); +} + /* Return negative errno on error. */ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, char read_write, u8 command, @@ -795,28 +803,24 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, switch (size) { case I2C_SMBUS_QUICK: - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), - SMBHSTADD(priv)); + i801_set_hstadd(priv, addr, read_write); xact = I801_QUICK; break; case I2C_SMBUS_BYTE: - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), - SMBHSTADD(priv)); + i801_set_hstadd(priv, addr, read_write); if (read_write == I2C_SMBUS_WRITE) outb_p(command, SMBHSTCMD(priv)); xact = I801_BYTE; break; case I2C_SMBUS_BYTE_DATA: - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), - SMBHSTADD(priv)); + i801_set_hstadd(priv, addr, read_write); outb_p(command, SMBHSTCMD(priv)); if (read_write == I2C_SMBUS_WRITE) outb_p(data->byte, SMBHSTDAT0(priv)); xact = I801_BYTE_DATA; break; case I2C_SMBUS_WORD_DATA: - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), - SMBHSTADD(priv)); + i801_set_hstadd(priv, addr, read_write); outb_p(command, SMBHSTCMD(priv)); if (read_write == I2C_SMBUS_WRITE) { outb_p(data->word & 0xff, SMBHSTDAT0(priv)); @@ -825,7 +829,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, xact = I801_WORD_DATA; break; case I2C_SMBUS_PROC_CALL: - outb_p((addr & 0x7f) << 1, SMBHSTADD(priv)); + i801_set_hstadd(priv, addr, I2C_SMBUS_WRITE); outb_p(command, SMBHSTCMD(priv)); outb_p(data->word & 0xff, SMBHSTDAT0(priv)); outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1(priv)); @@ -833,8 +837,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, read_write = I2C_SMBUS_READ; break; case I2C_SMBUS_BLOCK_DATA: - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), - SMBHSTADD(priv)); + i801_set_hstadd(priv, addr, read_write); outb_p(command, SMBHSTCMD(priv)); block = 1; break; @@ -845,10 +848,11 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, * However if SPD Write Disable is set (Lynx Point and later), * the read will fail if we don't set the R/#W bit. */ - outb_p(((addr & 0x7f) << 1) | - ((priv->original_hstcfg & SMBHSTCFG_SPD_WD) ? - (read_write & 0x01) : 0), - SMBHSTADD(priv)); + if (priv->original_hstcfg & SMBHSTCFG_SPD_WD) + i801_set_hstadd(priv, addr, read_write); + else + i801_set_hstadd(priv, addr, I2C_SMBUS_WRITE); + if (read_write == I2C_SMBUS_READ) { /* NB: page 240 of ICH5 datasheet also shows * that DATA1 is the cmd field when reading */ @@ -858,11 +862,8 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, block = 1; break; case I2C_SMBUS_BLOCK_PROC_CALL: - /* - * Bit 0 of the slave address register always indicate a write - * command. - */ - outb_p((addr & 0x7f) << 1, SMBHSTADD(priv)); + /* Needs to be flagged as write transaction */ + i801_set_hstadd(priv, addr, I2C_SMBUS_WRITE); outb_p(command, SMBHSTCMD(priv)); block = 1; break; From patchwork Fri Apr 15 16:58:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 562696 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6657C433EF for ; Fri, 15 Apr 2022 17:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356041AbiDORCq (ORCPT ); Fri, 15 Apr 2022 13:02:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356037AbiDORCo (ORCPT ); Fri, 15 Apr 2022 13:02:44 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 010AF532DF for ; Fri, 15 Apr 2022 10:00:15 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id k23so16290437ejd.3 for ; Fri, 15 Apr 2022 10:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=k29L/Xi7olDMt2fBZ4FbGuDNkL5mRiH9SqZXW9yPuGE=; b=Rb0+R5kdvxO2j7Kj6lI0Jmo75FnUCp+8tyoaB/rb4pdAFNcbxPtX39xLxy38FpHrfN cgzBbyJz/8tH/zBstFisA6u3WNZBB6UlQ/ZVe5YLDLXQJKKnMWG5S6hcHTDTA9Rm2G2a h+yqfLUPzb085yOYRY/mZqTGgIZKvKHihOGUe7Cz9vLzqo0BMA+rZZSPRd4jZEdAPEzd ZZI1Du/2seEp6dmMbd9yPzm+R6sCBbmKkeoC2DifHDtfwqHZnfOZs4fAVWkkTuo25xMT 9UQB/jzM093a2LH1F4Fmo72qCsFQg+ggR2dVEXnSyLw/pyvVNTzLjKLH9XWpxFrosPQm Yy3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=k29L/Xi7olDMt2fBZ4FbGuDNkL5mRiH9SqZXW9yPuGE=; b=5Cn40rOeWohgowzO/srvLYgA2jMqFQ9x5FL0o820W9NIGVjoHhJjoxAw2cL8z6jNrC PFeF+jaoJU1cYPnhevtBcF16b2fUSibCc7M8XgyGJHgPgHfivsRj+BfzLzfMTvT5lVRl 0p31cK0eAF4UtiVRsxJZfbanR8v3LI/rVnuseNLfvlBq7I9JWsb4f2PuyCHhEnEc0Wc8 FdTgTHbvgYMUwuob7ufP6X20s63gCHh4wHPleNkSUkY1MoYmPp/O7JmXq/5y2QamrZKL h/7UEJhX0HByvkTcA7A1Bjc4Sl5wtjB8ebx7hMcb5IvIh9096nW14nz1wuRUS0CMdMdy Jxow== X-Gm-Message-State: AOAM533BlwF7b3KtoJIii1dPpbVH9Nf3axF4sy6cKvzxHLoD9kpih71L Mg7BjBGHaWI2W6yWOYm9rSQ6AWjEm64= X-Google-Smtp-Source: ABdhPJwJtJGSwQRLecyfzhRQBTimQGEQI58I3+WEu4MyYceG+OSgR42i0H/i2VavqiVLhPKPnWhAgA== X-Received: by 2002:a17:907:724a:b0:6e8:4f12:b6fd with SMTP id ds10-20020a170907724a00b006e84f12b6fdmr70132ejc.198.1650042013451; Fri, 15 Apr 2022 10:00:13 -0700 (PDT) Received: from ?IPV6:2a01:c22:6faa:ed00:b906:e23f:946b:b9f7? (dynamic-2a01-0c22-6faa-ed00-b906-e23f-946b-b9f7.c22.pool.telefonica.de. [2a01:c22:6faa:ed00:b906:e23f:946b:b9f7]) by smtp.googlemail.com with ESMTPSA id b12-20020a056402278c00b004195a50759fsm3097849ede.84.2022.04.15.10.00.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Apr 2022 10:00:12 -0700 (PDT) Message-ID: Date: Fri, 15 Apr 2022 18:58:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: [PATCH 6/8] i2c: i801: add i801_single_transaction(), complementing i801_block_transaction() Content-Language: en-US From: Heiner Kallweit To: Jean Delvare Cc: "linux-i2c@vger.kernel.org" References: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> In-Reply-To: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This patch factors out non-block pre/post processing to a new function i801_single_transaction(), complementing existing function i801_block_transaction(). This makes i801_access() better readable. Signed-off-by: Heiner Kallweit --- drivers/i2c/busses/i2c-i801.c | 95 +++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 37 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index bf77f8640..8c2245f38 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -771,6 +771,62 @@ static int i801_block_transaction(struct i801_priv *priv, union i2c_smbus_data * return result; } +/* Single transaction function */ +static int i801_single_transaction(struct i801_priv *priv, union i2c_smbus_data *data, + char read_write, int command) +{ + int xact, ret; + + switch (command) { + case I2C_SMBUS_QUICK: + xact = I801_QUICK; + break; + case I2C_SMBUS_BYTE: + xact = I801_BYTE; + break; + case I2C_SMBUS_BYTE_DATA: + if (read_write == I2C_SMBUS_WRITE) + outb_p(data->byte, SMBHSTDAT0(priv)); + xact = I801_BYTE_DATA; + break; + case I2C_SMBUS_WORD_DATA: + if (read_write == I2C_SMBUS_WRITE) { + outb_p(data->word & 0xff, SMBHSTDAT0(priv)); + outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1(priv)); + } + xact = I801_WORD_DATA; + break; + case I2C_SMBUS_PROC_CALL: + outb_p(data->word & 0xff, SMBHSTDAT0(priv)); + outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1(priv)); + xact = I801_PROC_CALL; + break; + default: + return -EOPNOTSUPP; + } + + ret = i801_transaction(priv, xact); + + if (ret || read_write == I2C_SMBUS_WRITE) + return ret; + + switch (command) { + case I2C_SMBUS_BYTE: + case I2C_SMBUS_BYTE_DATA: + data->byte = inb_p(SMBHSTDAT0(priv)); + break; + case I2C_SMBUS_WORD_DATA: + case I2C_SMBUS_PROC_CALL: + data->word = inb_p(SMBHSTDAT0(priv)) + + (inb_p(SMBHSTDAT1(priv)) << 8); + break; + default: + break; + } + + return 0; +} + static void i801_set_hstadd(struct i801_priv *priv, u8 addr, char read_write) { addr <<= 1; @@ -784,9 +840,7 @@ 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, xact; + int hwpec, ret, block = 0; struct i801_priv *priv = i2c_get_adapdata(adap); mutex_lock(&priv->acpi_lock); @@ -804,36 +858,23 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, switch (size) { case I2C_SMBUS_QUICK: i801_set_hstadd(priv, addr, read_write); - xact = I801_QUICK; break; case I2C_SMBUS_BYTE: i801_set_hstadd(priv, addr, read_write); if (read_write == I2C_SMBUS_WRITE) outb_p(command, SMBHSTCMD(priv)); - xact = I801_BYTE; break; case I2C_SMBUS_BYTE_DATA: i801_set_hstadd(priv, addr, read_write); outb_p(command, SMBHSTCMD(priv)); - if (read_write == I2C_SMBUS_WRITE) - outb_p(data->byte, SMBHSTDAT0(priv)); - xact = I801_BYTE_DATA; break; case I2C_SMBUS_WORD_DATA: i801_set_hstadd(priv, addr, read_write); outb_p(command, SMBHSTCMD(priv)); - if (read_write == I2C_SMBUS_WRITE) { - outb_p(data->word & 0xff, SMBHSTDAT0(priv)); - outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1(priv)); - } - xact = I801_WORD_DATA; break; case I2C_SMBUS_PROC_CALL: i801_set_hstadd(priv, addr, I2C_SMBUS_WRITE); outb_p(command, SMBHSTCMD(priv)); - outb_p(data->word & 0xff, SMBHSTDAT0(priv)); - outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1(priv)); - xact = I801_PROC_CALL; read_write = I2C_SMBUS_READ; break; case I2C_SMBUS_BLOCK_DATA: @@ -883,7 +924,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, if (block) ret = i801_block_transaction(priv, data, read_write, size); else - ret = i801_transaction(priv, xact); + ret = i801_single_transaction(priv, data, read_write, size); /* 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 @@ -891,26 +932,6 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, if (hwpec || block) outb_p(inb_p(SMBAUXCTL(priv)) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), SMBAUXCTL(priv)); - - if (block) - goto out; - if (ret) - goto out; - if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK)) - goto out; - - switch (xact) { - case I801_BYTE: /* Result put in SMBHSTDAT0 */ - case I801_BYTE_DATA: - data->byte = inb_p(SMBHSTDAT0(priv)); - break; - case I801_WORD_DATA: - case I801_PROC_CALL: - data->word = inb_p(SMBHSTDAT0(priv)) + - (inb_p(SMBHSTDAT1(priv)) << 8); - break; - } - out: /* * Unlock the SMBus device for use by BIOS/ACPI, From patchwork Fri Apr 15 16:58:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 562030 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BE39C433F5 for ; Fri, 15 Apr 2022 17:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356051AbiDORCr (ORCPT ); Fri, 15 Apr 2022 13:02:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356046AbiDORCq (ORCPT ); Fri, 15 Apr 2022 13:02:46 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D7BE54187 for ; Fri, 15 Apr 2022 10:00:16 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id g20so10509440edw.6 for ; Fri, 15 Apr 2022 10:00:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=mSA7WCyLrRzQfIX93yIDBxzW5BL3jtV81phFmpM45Dk=; b=W5E/n88p+LJggtggfX2UhlsUV9p3mYQEDd0a7gznULM6bgtw3HbmmZDk1T0Ah37T3I 6GgO9hK+0d28eQzh4c/ZgcpdnKNjBfapQLoYTv4nhxA/4s5UvcOeyob/wFs9sj7wmE4M zuulKpleZpKgvQSG17ZHwdA5PE3hI0KTpIpujjRyWNIQBUXS2oEqbNy/f3GnRI+V/QKt MrNpZlaDBHJ/RCSqz+a9KXrhmAdcvG+HViqurst+1OFbGF3gvgHCZCksSUHNco3eO4Lm ef65aNzrIbMmkNfardsdxC1d43L5nlj9nNhLkiGBxNnoCAfeedxoieI7cdpsVJjpKmxF lW9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=mSA7WCyLrRzQfIX93yIDBxzW5BL3jtV81phFmpM45Dk=; b=H7ckSO9OuJc3EgiJk94h7XrPvGoA1FQlLlYq9JQ/iLJSYvv0RVb/lyNIItxo7r+bAO 9xN3EqIJNp58trm9lbKICmkjXQ69EZMOpDCbxdrWd9umU2DRCqz2A5bnmWs7VGfqDKRi moQqWMTZb23UM0nUbqNw843lN7w9D6j2zWIZwzol1ppNdJS0aUHDW7Gvg+wOmE2fe8gD rBmX5uGSwaPCBASOAm8rda9oG/jla0a40mSM3VuaMqKVfe6yj7h3gEpDFrVF8q5fdPnv delT2n/p1eA+zcDD8JhTFNNxNrl+6LXninw9jDUVAKVQmrPT+dzEuu1yVTpIH12rk3oi VDVw== X-Gm-Message-State: AOAM533HoBODQaSJS4unmcbHbHdTXh4cHvLNOnjcRYSSJZ+5WMY7ZhiF nbZkLW8sVvnPPuvwlq97e78= X-Google-Smtp-Source: ABdhPJwlvfQdhJC6owOVuY84kOO0/u65bca23UI6Bi/tCYWgY9aOS/NcCKzS2mtzS/vwDePCcTLj+A== X-Received: by 2002:a05:6402:2709:b0:422:adc9:bc39 with SMTP id y9-20020a056402270900b00422adc9bc39mr155962edd.111.1650042014643; Fri, 15 Apr 2022 10:00:14 -0700 (PDT) Received: from ?IPV6:2a01:c22:6faa:ed00:b906:e23f:946b:b9f7? (dynamic-2a01-0c22-6faa-ed00-b906-e23f-946b-b9f7.c22.pool.telefonica.de. [2a01:c22:6faa:ed00:b906:e23f:946b:b9f7]) by smtp.googlemail.com with ESMTPSA id i12-20020a05640200cc00b00421058b175esm2659969edu.53.2022.04.15.10.00.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Apr 2022 10:00:14 -0700 (PDT) Message-ID: <261bddb8-1a1e-13e9-8557-e4ad1c7f9826@gmail.com> Date: Fri, 15 Apr 2022 18:58:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: [PATCH 7/8] i2c: i801: call i801_check_pre() from i801_access() Content-Language: en-US From: Heiner Kallweit To: Jean Delvare Cc: "linux-i2c@vger.kernel.org" References: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> In-Reply-To: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This avoids code duplication, in a next step we'll call i801_check_post() from i801_access() as well. Signed-off-by: Heiner Kallweit Reviewed-by: Jean Delvare --- drivers/i2c/busses/i2c-i801.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 8c2245f38..9061333f2 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -460,10 +460,6 @@ static int i801_transaction(struct i801_priv *priv, int xact) unsigned long result; const struct i2c_adapter *adap = &priv->adapter; - status = i801_check_pre(priv); - if (status < 0) - return status; - if (priv->features & FEATURE_IRQ) { reinit_completion(&priv->done); outb_p(xact | SMBHSTCNT_INTREN | SMBHSTCNT_START, @@ -647,10 +643,6 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, if (command == I2C_SMBUS_BLOCK_PROC_CALL) return -EOPNOTSUPP; - status = i801_check_pre(priv); - if (status < 0) - return status; - len = data->block[0]; if (read_write == I2C_SMBUS_WRITE) { @@ -851,6 +843,10 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, pm_runtime_get_sync(&priv->pci_dev->dev); + ret = i801_check_pre(priv); + if (ret) + goto out; + hwpec = (priv->features & FEATURE_SMBUS_PEC) && (flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA; From patchwork Fri Apr 15 16:59:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 562695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62197C43219 for ; Fri, 15 Apr 2022 17:00:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356043AbiDORCr (ORCPT ); Fri, 15 Apr 2022 13:02:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356037AbiDORCq (ORCPT ); Fri, 15 Apr 2022 13:02:46 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70FD254BC5 for ; Fri, 15 Apr 2022 10:00:17 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id l7so16311546ejn.2 for ; Fri, 15 Apr 2022 10:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=ASk5uZk2fLWGA+NYzLU0luN5ZBTpjvEbcnbyw6pqzkg=; b=NmF1gfBuEWSPHJid0rX+RacmpMNnwKECJWmTVbJ70XTnVxUreHGXq7463L8DwPdiy6 TV28JGRgDjURZhntapTrP9CSa+bRmgbYKMnhB5n5kJ9Tpfh5vhTBmTqQXmR9KhN2LDi1 eYcfroHdMA3Z8UEc+603Grhzvhok1gsbtQ88w1jYWURBtmIVbrMKLuUikXId0GOyrKtz S6PflafmTbXOFgLswbS1E7Y0cOhhRdY+K23MrIf+ROw971TFrdcqX9U9/mY9FpyD49uW 694B26zJT0aT6btN0Wk4JDOvavzuKcY4n3qqKbD4u9YEtvRdSwMLgD+9FSnNSf1OLOad Xdig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=ASk5uZk2fLWGA+NYzLU0luN5ZBTpjvEbcnbyw6pqzkg=; b=5ITiB2lxCOya/K9ke0CJIMYjb/Xof+PFDwdPRV+DJevygw75tlJB5kTjo9y7Qig3SY CgqGqSp4LEqmLTfnPOVvQNAtLrnkj/8RYINfvUY7I4AKsmNv8+YADwnmZzKAH/ZTUOO9 b+f74gDZcOVZ6mTDZU4dHYxv7z6NPWCGhbJN0FhSnSTKvc+KvkAD5/ZxFlu5Kk7I43ZK jrZblUUFBQOzS92gvjpMLwAN0lEuoBcjeYHEZ3FStT9SeDJV1DsEowpypCmVw0xaPlrF sEOSsauKRYNDg9l2Or1+yGBg8KtwVqIHEJNUBKAk4p8I1swdR7JT4EV4sObhgbji+BXp UE5Q== X-Gm-Message-State: AOAM530cLM56rk1zUKXpFyBVB7fDB0u87KIeKI4oddwF+Hz81GNzd6vy jXge7sPrQXsbQpW64ygtodjTiF0CBzs= X-Google-Smtp-Source: ABdhPJx+XcEhmaPvic2CO771rKg5wOrCx6Qgs0nHjwchw24BL5njy317nF9ev0fldFF4Zeqw3pT/Ew== X-Received: by 2002:a17:907:6284:b0:6e0:f895:15a with SMTP id nd4-20020a170907628400b006e0f895015amr25680ejc.713.1650042015728; Fri, 15 Apr 2022 10:00:15 -0700 (PDT) Received: from ?IPV6:2a01:c22:6faa:ed00:b906:e23f:946b:b9f7? (dynamic-2a01-0c22-6faa-ed00-b906-e23f-946b-b9f7.c22.pool.telefonica.de. [2a01:c22:6faa:ed00:b906:e23f:946b:b9f7]) by smtp.googlemail.com with ESMTPSA id cq24-20020a056402221800b00420ad7d2dd0sm2888134edb.29.2022.04.15.10.00.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Apr 2022 10:00:15 -0700 (PDT) Message-ID: <9103e680-6436-42a3-d4be-39edf851aaf9@gmail.com> Date: Fri, 15 Apr 2022 18:59:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: [PATCH 8/8] i2c: i801: call i801_check_post() from i801_access() Content-Language: en-US From: Heiner Kallweit To: Jean Delvare Cc: "linux-i2c@vger.kernel.org" References: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> In-Reply-To: <4125f9ce-ce5f-fbcf-7d6f-9bc586ac43e0@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Avoid code duplication by calling i801_check_post() from i801_access(). Signed-off-by: Heiner Kallweit --- drivers/i2c/busses/i2c-i801.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 9061333f2..ecec7a3a8 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -432,7 +432,7 @@ static int i801_wait_intr(struct i801_priv *priv) busy = status & SMBHSTSTS_HOST_BUSY; status &= STATUS_ERROR_FLAGS | SMBHSTSTS_INTR; if (!busy && status) - return status; + return status & STATUS_ERROR_FLAGS; } while (time_is_after_eq_jiffies(timeout)); return -ETIMEDOUT; @@ -456,7 +456,6 @@ static int i801_wait_byte_done(struct i801_priv *priv) static int i801_transaction(struct i801_priv *priv, int xact) { - int status; unsigned long result; const struct i2c_adapter *adap = &priv->adapter; @@ -465,13 +464,12 @@ static int i801_transaction(struct i801_priv *priv, int xact) outb_p(xact | SMBHSTCNT_INTREN | SMBHSTCNT_START, SMBHSTCNT(priv)); result = wait_for_completion_timeout(&priv->done, adap->timeout); - return i801_check_post(priv, result ? priv->status : -ETIMEDOUT); + return result ? priv->status : -ETIMEDOUT; } outb_p(xact | SMBHSTCNT_START, SMBHSTCNT(priv)); - status = i801_wait_intr(priv); - return i801_check_post(priv, status); + return i801_wait_intr(priv); } static int i801_block_transaction_by_block(struct i801_priv *priv, @@ -618,7 +616,7 @@ static irqreturn_t i801_isr(int irq, void *dev_id) status &= STATUS_ERROR_FLAGS | SMBHSTSTS_INTR; if (status) { - priv->status = status; + priv->status = status & STATUS_ERROR_FLAGS; complete(&priv->done); } @@ -668,7 +666,7 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, reinit_completion(&priv->done); outb_p(priv->cmd | SMBHSTCNT_START, SMBHSTCNT(priv)); result = wait_for_completion_timeout(&priv->done, adap->timeout); - return i801_check_post(priv, result ? priv->status : -ETIMEDOUT); + return result ? priv->status : -ETIMEDOUT; } for (i = 1; i <= len; i++) { @@ -682,7 +680,7 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, status = i801_wait_byte_done(priv); if (status) - goto exit; + return status; if (i == 1 && read_write == I2C_SMBUS_READ && command != I2C_SMBUS_I2C_BLOCK_DATA) { @@ -712,9 +710,7 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, outb_p(SMBHSTSTS_BYTE_DONE, SMBHSTSTS(priv)); } - status = i801_wait_intr(priv); -exit: - return i801_check_post(priv, status); + return i801_wait_intr(priv); } /* Block transaction function */ @@ -922,6 +918,8 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, else ret = i801_single_transaction(priv, data, read_write, size); + ret = i801_check_post(priv, ret); + /* 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. */