From patchwork Mon Aug 19 07:19:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13768007 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 46D8DC52D7C for ; Mon, 19 Aug 2024 07:22:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GsPA5mclXdisvKKaTQ02gNCQ1XXrITHCNqT/Xgg4pnY=; b=Hk+9fvEI1KCtxfPvAdigXTq3Sf wTDatTP4b3F7qCCVg/kp1VQtwmvQqIEQ1rsyq/zDKIF5KXGkdCDMi56sznE7367hccM+u2l98TJ3M 84c2dJB+B8j/9WIeJwLj15x7zGimtCxDBpEyPAH67lNM8frfkpiJWd+ehsvdW3p2H2arnxLQiWlb8 SoE89wsiIaEJ0CSVEkUhKsCCe+k+cBYGKzAr226kbj2Sfd//wct2+sSmAqBWGhERmC4PdT5Lw0SAB noBdTdom5B5OiNADKThqCqaxSJcWW1r3GNwygElsD/Ns5ji4ka4VnUc0MDkh6+3fh4ti8gGIDd6Nw 4LfjaiVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfwia-00000000cFC-28jx; Mon, 19 Aug 2024 07:22:20 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfwhH-00000000bqA-2GKO for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 07:21:00 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-371936541caso1735566f8f.0 for ; Mon, 19 Aug 2024 00:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724052058; x=1724656858; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GsPA5mclXdisvKKaTQ02gNCQ1XXrITHCNqT/Xgg4pnY=; b=G/QutL1sAaNo7Cu9J2fsgil59e2bzqOMuKxNP5/zR1AZxyxKXaH+K94vU6qEL4VSKS AWVJA+6ZwEngGRIpCCyBasvT/0WwPVhTsWlPTalXLZayWWoyr3nCsGHxYO+Le9N8B5k+ ibRvuQCKZJ5351qOF5xXtpRB8Jaxqo3qYNyoCXFbFWFaUIMzd+gJCE7BRCnMv1Ksztkj 8fxEF77RgqUs0cEbxTaYGPL7/JCPC/CWMdhbQULTDYIPGJTMyylRYDUlxH0OcP0eUqAS p2qRtI2t3KJbqoPDedQd5ngGzeZ0PV1PA4g4P3bcU6JxdI72qLDwFTyenSTuj8+/uLV+ lWgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724052058; x=1724656858; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GsPA5mclXdisvKKaTQ02gNCQ1XXrITHCNqT/Xgg4pnY=; b=u/IQg9u/HXxlfMqnOUZkzjnVn8sy9epUOo+39S/2Hb9dgLwkjSRq1yQ5Qdntoehbd/ +Jp5jNVl3a54hrH+QQA5P+JUIY2irN50vPlnJoeQ9A9purGDKtGwbxA3bRrLBqdmjceq KpIUvFNbQVgWp79976efNBnkbW8x3Q/gLwPVo7plp8GyvnQ8vSu/vH2DOJuNCale6D5u CYpNMkcnjt5GkxIJ4ZOEo5QFvd2tNrAMYeAQtTTFdEASpfcXxJpKE/rGeteg7FTG9Rur RGbqlpYbZXUHy2CjZ15R1gmu3UYRv3paowDygF/K2B6CX9MA0hjS4D/UO1MYAgQO9MHM Fitw== X-Forwarded-Encrypted: i=1; AJvYcCXp6U6Il3MdoXyR8kSAXK3ifL24zgVIilO756DIEcN402zMb+aNqpL28nGELwkCHsx56YWhkTeiTveFCX4llvpLLyWRgZtvCV/s62fq6fhwY4bcjvA= X-Gm-Message-State: AOJu0YxMioQawB2QluRBkweyJIV/l4qokMLHPe9rk3uS4oUgG1r/OIK8 p1C5wNIpuBQlYydypv38rwROtcFIHGcry2XvYJRaPWKawl0ZhgCo X-Google-Smtp-Source: AGHT+IEUwcTEkZfbBy8umdlK7hlL1JY0T3hwRz7NQ1Yzdd8B4npZGPeuvqx+Sh7ON7/mAc5VseEm9A== X-Received: by 2002:adf:f5c4:0:b0:371:937a:3276 with SMTP id ffacd0b85a97d-371a747839bmr3485924f8f.57.1724052057345; Mon, 19 Aug 2024 00:20:57 -0700 (PDT) Received: from eichest-laptop.toradex.int ([2a02:168:af72:0:a64c:8731:e4fb:38f1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37189896a9csm9683734f8f.79.2024.08.19.00.20.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 00:20:57 -0700 (PDT) From: Stefan Eichenberger To: o.rempel@pengutronix.de, kernel@pengutronix.de, andi.shyti@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, Frank.Li@nxp.com, francesco.dolcini@toradex.com Cc: linux-i2c@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Stefan Eichenberger Subject: [PATCH v2 1/4] i2c: imx: only poll for bus busy in multi master mode Date: Mon, 19 Aug 2024 09:19:07 +0200 Message-ID: <20240819072052.8722-2-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240819072052.8722-1-eichest@gmail.com> References: <20240819072052.8722-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240819_002059_615793_F1297A2A X-CRM114-Status: GOOD ( 15.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Stefan Eichenberger According to the i.MX8M Mini reference manual chapter "16.1.4.2 Generation of Start" it is only necessary to poll for bus busy and arbitration lost in multi master mode. This helps to avoid rescheduling while the i2c bus is busy and avoids SMBus devices to timeout. Signed-off-by: Stefan Eichenberger Reviewed-by: Frank Li Tested-by: Fabio Estevam Acked-by: Oleksij Rempel --- drivers/i2c/busses/i2c-imx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 3842e527116b7..1add946e3bc20 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -216,6 +216,8 @@ struct imx_i2c_struct { struct i2c_client *slave; enum i2c_slave_event last_slave_event; + bool multi_master; + /* For checking slave events. */ spinlock_t slave_lock; struct hrtimer slave_timer; @@ -481,6 +483,9 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy, bool a unsigned long orig_jiffies = jiffies; unsigned int temp; + if (!i2c_imx->multi_master) + return 0; + while (1) { temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR); @@ -540,8 +545,8 @@ static int i2c_imx_trx_complete(struct imx_i2c_struct *i2c_imx, bool atomic) return -ETIMEDOUT; } - /* check for arbitration lost */ - if (i2c_imx->i2csr & I2SR_IAL) { + /* In multi-master mode check for arbitration lost */ + if (i2c_imx->multi_master && (i2c_imx->i2csr & I2SR_IAL)) { dev_dbg(&i2c_imx->adapter.dev, "<%s> Arbitration lost\n", __func__); i2c_imx_clear_irq(i2c_imx, I2SR_IAL); @@ -1468,6 +1473,8 @@ static int i2c_imx_probe(struct platform_device *pdev) goto rpm_disable; } + i2c_imx->multi_master = of_property_read_bool(pdev->dev.of_node, "multi-master"); + /* Set up clock divider */ i2c_imx->bitrate = I2C_MAX_STANDARD_MODE_FREQ; ret = of_property_read_u32(pdev->dev.of_node,