From patchwork Mon Sep 2 07:42:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13786869 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 C13F7CD13CF for ; Mon, 2 Sep 2024 07:45:35 +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=ZpFUa0HNPaA1/z3K1YQrq6JjQoT/x4qwWIkq9q1c5wM=; b=bxNw26GEui4yY1RZf1wXEMWFbc ccGldnDhD/UCr1J2SGk6B3cLQizizR7OmleQrYJWlyij341oIpnSAQ879SlBzq7smlDSfCz2sYtIg Hthv3wE/p6KdpYBErH8y24rsbFyKNzC6+bOBaJbhTrAJMons68Xkd5VZMR87IQ5uZkXHdjjGKuQ8P dluJ+T6DgNOpEiwFCynMnqGXxxQaTT8pfacaaUYMYJxl/1mkZIXXcYCublMZqlCEbMjIfoNYrTFci k64VzHjvtj3/oGA+FU68a++pq5MykiF94LqcGT4/WDcaxhYaeVxecC81b1grVrN3q+m2hnBSIxhok Y6fuYrbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl1kZ-0000000DMLg-3zkw; Mon, 02 Sep 2024 07:45:24 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl1ir-0000000DLuh-09xq for linux-arm-kernel@lists.infradead.org; Mon, 02 Sep 2024 07:43:38 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-58ef19aa69dso3540519a12.3 for ; Mon, 02 Sep 2024 00:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725263015; x=1725867815; 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=ZpFUa0HNPaA1/z3K1YQrq6JjQoT/x4qwWIkq9q1c5wM=; b=mf90fLootqg6GqBw1+Ba2cQ29ylOlByaZeWz5954clwyV2PkWMRDDzmXLdsmoUYqQA OAVg0nAYG3nXAQtsR/VtypX4I3x0xJTYjomfLIGSuK2zzoGAarazT2zSpVUoGeNHK//i Ti7XRhhS/r+HhDSGvtC22r1cun6+QoxoZFswbV3RD8p07YUk/DssE0nWCfJZZRnWHP81 H3Ik1FcUUJwQv0zyfggCvrzUtLJIPwlJnNd2X/5tZEOm6jJ23rhKk1CzoRu6OhYsoa4z b6qNVHz9IBRRHruGa9xS+vkgkKEQ3o0JOV7NNeffSYTZF8naujbZr0mcS2BFVZUN2zOO N2TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725263015; x=1725867815; 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=ZpFUa0HNPaA1/z3K1YQrq6JjQoT/x4qwWIkq9q1c5wM=; b=b/WfDoFoOg40dfC9tQv8e4hv/1N1ujYS8hhedepLlHHfU9Iq0IBUNInNK7eJHqTQAb WhD//HhezAGZlyjjWfahcAFiQ4fRfTI29rL8FZ1nFNeTx4iKpxMxS2MW+yGkiAF6j2Oj txxqRYIxx4wqgqY6nnd1mIEIKxwCoemSuRsDQahUCt6NTFq/ZF1ojIl/rq4w/4ClkJ9C +vSIFNmEo4ykTkUGyLiJ45y5t+fhNRj4BNZayEbr2oDVQbly1XBjgRqnaZZeMzap35ZB vSeE/yb5rKdLZZTlxgn+R3v7HZoy+nBuWayxOhmjmOlCTxSxtVsuOlu5AvVmVpkE5bg8 vAXw== X-Forwarded-Encrypted: i=1; AJvYcCXBAk3AqeHy17b0lMTipWK+DBrblI9bAAm+GBHGiU30NpkXbzD3HL2gTPtbm0aLZ8W8iMArLX2/KJF6tRsKhiic@lists.infradead.org X-Gm-Message-State: AOJu0YyYsQES8Rr5LHTxSGzdAPSja8lk7s7ZSec/s7uQyaHq2qJh8Y2x S/xdrrf0wuv7hk7initJ8Bh3fl6gf13CZhF/LWHuQbV0qS1uEqrX X-Google-Smtp-Source: AGHT+IGXhpPe+w6G0FeAT/iHfSIhFVsjo1uLMmtN+ZLdNG28sLEI6fGLHqIbur3Zw3B584wVE2jslw== X-Received: by 2002:a05:6402:5215:b0:5c2:5620:f7c with SMTP id 4fb4d7f45d1cf-5c256201165mr2046949a12.18.1725263015146; Mon, 02 Sep 2024 00:43:35 -0700 (PDT) Received: from eichest-laptop.lan ([2a02:168:af72:0:3786:cf07:4865:dc9f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c24ff04551sm1975931a12.35.2024.09.02.00.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 00:43:34 -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, francesco.dolcini@toradex.com, Frank.Li@nxp.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 v3 1/4] i2c: imx: only poll for bus busy in multi master mode Date: Mon, 2 Sep 2024 09:42:01 +0200 Message-ID: <20240902074330.6349-2-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240902074330.6349-1-eichest@gmail.com> References: <20240902074330.6349-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240902_004337_100923_F2C150C9 X-CRM114-Status: GOOD ( 16.01 ) 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 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,