From patchwork Tue Mar 1 16:28:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 1607402 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=hzwg+PuD; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=m2aYUo2x; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=139.178.84.217; helo=dfw.source.kernel.org; envelope-from=wsa@kernel.org; receiver=) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KLbxC054Jz9sFN for ; Sun, 20 Mar 2022 10:02:06 +1100 (AEDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2CA8760F00 for ; Sat, 19 Mar 2022 22:55:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA457C340EC for ; Sat, 19 Mar 2022 22:55:01 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="hzwg+PuD"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="m2aYUo2x" Resent-From: Wolfram Sang Resent-Date: Sat, 19 Mar 2022 23:54:59 +0100 Resent-Message-ID: Resent-To: incoming@patchwork.ozlabs.org X-Original-To: wsa@the-dreams.de Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by pokefinder.org (Postfix) with ESMTPS id 9F5742C00BF for ; Tue, 1 Mar 2022 17:29:10 +0100 (CET) Received: (qmail 3932202 invoked by uid 997); 1 Mar 2022 17:29:10 +0100 Received: (qmail 3932196 invoked by uid 210); 1 Mar 2022 17:29:10 +0100 X-Qmail-Scanner-Diagnostics: from out1.vger.email by www.zeus03.de (envelope-from , uid 201) with qmail-scanner-2.11st (clamdscan: 0.104.2/26467. spamassassin: 3.4.6. Clear:RC:0(2620:137:e000::1:20):SA:0(-2.8/5.0):. Processed in 0.698381 secs); 01 Mar 2022 16:29:10 -0000 X-Virus-Status: clean X-Spam-Status: No, hits=-2.8 required=5.0 Received: from out1.vger.email (2620:137:e000::1:20) by mail.zeus03.de with SMTP; 1 Mar 2022 17:29:09 +0100 X-UD-Smtp-Session: e+0UqirZoOUmIAE34AAAAAAAAAAAAQAg Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235933AbiCAQ3o (ORCPT ); Tue, 1 Mar 2022 11:29:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236119AbiCAQ3o (ORCPT ); Tue, 1 Mar 2022 11:29:44 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E31119C25 for ; Tue, 1 Mar 2022 08:29:02 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 075182199B; Tue, 1 Mar 2022 16:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1646152141; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xgurX+Qdi/BztmyLZZtvR7Fa9fKdHl/VfnHY3j/j13M=; b=hzwg+PuD2mJl6FoRlk/svwbldd+1mub5oIN8PR34q93qfG2sE79rFSgbFWW59c5npzWhYb C/DQDXH8vZl9hl97iMS7MYzRxHGHzc7XaQIoSvwZ4nkz9gEFhh1kSEysRT560OtqQSyX24 UowbCWP26nbwWyZa2P0XoijCCdVd+MA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1646152141; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xgurX+Qdi/BztmyLZZtvR7Fa9fKdHl/VfnHY3j/j13M=; b=m2aYUo2xPIsS+bz4xaxq/k7m7fgViHUKOZfgZE9lGYpXWm6Xsfs5Huwnh9KRu6qedCJC52 PSuXk39bAX4TENDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D463313B83; Tue, 1 Mar 2022 16:29:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id FDKvMcxJHmKaIgAAMHmgww (envelope-from ); Tue, 01 Mar 2022 16:29:00 +0000 Date: Tue, 1 Mar 2022 17:28:59 +0100 From: Jean Delvare To: Linux I2C Cc: Heiner Kallweit , Jarkko Nikula Subject: [PATCH 1/2] i2c: i801: Drop useless masking in i801_access Message-ID: <20220301172859.5593309a@endymion.delvare> Organization: SUSE Linux X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 X-Qmail-Scanner-MOVED-X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org I went all the way back to kernel 2.6.12 and that masking was never needed. I suppose it was there in anticipation of software PEC support, but that was never added to the driver (and never will be, as this is made obsolete by hardware PEC). I'm also removing initialization to 0, which is not needed either, and would prevent the compiler from reporting an actual usage of uninitialized variables. Signed-off-by: Jean Delvare Reviewed-by: Jarkko Nikula --- drivers/i2c/busses/i2c-i801.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- linux-5.16.orig/drivers/i2c/busses/i2c-i801.c 2022-03-01 10:41:26.946201705 +0100 +++ linux-5.16/drivers/i2c/busses/i2c-i801.c 2022-03-01 10:52:45.376001496 +0100 @@ -792,7 +792,7 @@ static s32 i801_access(struct i2c_adapte { int hwpec; int block = 0; - int ret = 0, xact = 0; + int ret, xact; struct i801_priv *priv = i2c_get_adapdata(adap); mutex_lock(&priv->acpi_lock); @@ -904,7 +904,7 @@ static s32 i801_access(struct i2c_adapte if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK)) goto out; - switch (xact & 0x7f) { + switch (xact) { case I801_BYTE: /* Result put in SMBHSTDAT0 */ case I801_BYTE_DATA: data->byte = inb_p(SMBHSTDAT0(priv)); From patchwork Tue Mar 1 16:39:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 1607403 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ieYM0YuQ; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Vs5WVH0j; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2604:1380:4641:c500::1; helo=dfw.source.kernel.org; envelope-from=wsa@kernel.org; receiver=) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KLbxC0GPZz9sFh for ; Sun, 20 Mar 2022 10:02:06 +1100 (AEDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6C11660F0E for ; Sat, 19 Mar 2022 22:55:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58DD1C340ED for ; Sat, 19 Mar 2022 22:55:05 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="ieYM0YuQ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Vs5WVH0j" Resent-From: Wolfram Sang Resent-Date: Sat, 19 Mar 2022 23:55:03 +0100 Resent-Message-ID: Resent-To: incoming@patchwork.ozlabs.org X-Original-To: wsa@the-dreams.de Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by pokefinder.org (Postfix) with ESMTPS id C81A22C00BF for ; Tue, 1 Mar 2022 17:39:45 +0100 (CET) Received: (qmail 3935366 invoked by uid 997); 1 Mar 2022 17:39:45 +0100 Received: (qmail 3935360 invoked by uid 210); 1 Mar 2022 17:39:45 +0100 X-Qmail-Scanner-Diagnostics: from out1.vger.email by www.zeus03.de (envelope-from , uid 201) with qmail-scanner-2.11st (clamdscan: 0.104.2/26467. spamassassin: 3.4.6. Clear:RC:0(2620:137:e000::1:20):SA:0(-2.8/5.0):. Processed in 0.513143 secs); 01 Mar 2022 16:39:45 -0000 X-Virus-Status: clean X-Spam-Status: No, hits=-2.8 required=5.0 Received: from out1.vger.email (2620:137:e000::1:20) by mail.zeus03.de with SMTP; 1 Mar 2022 17:39:44 +0100 X-UD-Smtp-Session: zun1zyrZIuYmIAE34AAAAAAAAAAAAQAg Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235971AbiCAQkX (ORCPT ); Tue, 1 Mar 2022 11:40:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234452AbiCAQkW (ORCPT ); Tue, 1 Mar 2022 11:40:22 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B3321A816 for ; Tue, 1 Mar 2022 08:39:39 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AABD41F37E; Tue, 1 Mar 2022 16:39:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1646152778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uk/g7R9PmEKrG3mZ5dAdIV2arozQx3B1Zj1R0ONFHWU=; b=ieYM0YuQxQEPRxqUqv7IdI1NxouY6e/FtsDvzs9lxMKsF6vsmP30oimtA9Vzgh4RqpaS2M 64qpXUx2aZETwvElY5BdhlszZCPT2vvUJhyI9/6oD+Nx5qayPWkxcqKcHjzyl8o4tXoB6r 0OYtpYmJWLN1fi0EpsUYyk3Sfz9vJOA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1646152778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uk/g7R9PmEKrG3mZ5dAdIV2arozQx3B1Zj1R0ONFHWU=; b=Vs5WVH0jP8hZYOGcEcesML07CG/RnnntdTrANX3klOWQcplEMfFt51nhTCIcPOZTj2HSra UFrV+gYUjh7RV5Cw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8431813B83; Tue, 1 Mar 2022 16:39:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wgMWHkpMHmJCJwAAMHmgww (envelope-from ); Tue, 01 Mar 2022 16:39:38 +0000 Date: Tue, 1 Mar 2022 17:39:37 +0100 From: Jean Delvare To: Linux I2C Cc: Heiner Kallweit , Jarkko Nikula Subject: [PATCH 2/2] i2c: i801: Add support for the Process Call command Message-ID: <20220301173937.636a21ce@endymion.delvare> In-Reply-To: <20220301172859.5593309a@endymion.delvare> References: <20220301172859.5593309a@endymion.delvare> Organization: SUSE Linux X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 X-Qmail-Scanner-MOVED-X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The Process Call command is implemented by the hardware since the very first Intel 82801 chipset, and trivial to support. Oscar Romero Matamala from the Georgia Institute of Technology told me it is needed for an experiment his team is working on at the moment, so let's just add support for it. Signed-off-by: Jean Delvare Reviewed-by: Jarkko Nikula --- Disclaimer: untested code. I don't have any device at hand which supports the Process Call command so I just can't test it. If anyone has a chance, please test. If not, I hope Oscar will be able to test it soon. drivers/i2c/busses/i2c-i801.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- linux-5.16.orig/drivers/i2c/busses/i2c-i801.c 2022-03-01 17:06:42.685102412 +0100 +++ linux-5.16/drivers/i2c/busses/i2c-i801.c 2022-03-01 17:35:49.586064557 +0100 @@ -166,7 +166,7 @@ #define I801_BYTE 0x04 #define I801_BYTE_DATA 0x08 #define I801_WORD_DATA 0x0C -#define I801_PROC_CALL 0x10 /* unimplemented */ +#define I801_PROC_CALL 0x10 #define I801_BLOCK_DATA 0x14 #define I801_I2C_BLOCK_DATA 0x18 /* ICH5 and later */ #define I801_BLOCK_PROC_CALL 0x1C @@ -838,6 +838,14 @@ static s32 i801_access(struct i2c_adapte } xact = I801_WORD_DATA; break; + case I2C_SMBUS_PROC_CALL: + outb_p((addr & 0x7f) << 1, SMBHSTADD(priv)); + 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: outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); @@ -910,6 +918,7 @@ static s32 i801_access(struct i2c_adapte 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; @@ -935,6 +944,7 @@ static u32 i801_func(struct i2c_adapter return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | + I2C_FUNC_SMBUS_PROC_CALL | I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | ((priv->features & FEATURE_SMBUS_PEC) ? I2C_FUNC_SMBUS_PEC : 0) | ((priv->features & FEATURE_BLOCK_PROC) ?