From patchwork Wed Oct 2 11:19:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13819670 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 64E68CF31AF for ; Wed, 2 Oct 2024 11:23:26 +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=pWe1LOAQAUHDMm2EMz2P+3VNJFGofn6qsW8nJYyiXVM=; b=ZSElqr3Z5enzKF+2LKTHvK/24z rZrPypDwNes8cf1vEZ6XPyOn9QOr7iDbEwN5MmWlF89mXCPZdiBC4zLh/2Ea3tisu77M6Z/iRJoLb yN+hADizM/XLPjEhQ8kqIXxFdkDsooIQ8Ed2F+Sk0/o41U3uxUI7wjeGrWfmBUpwOoEla7y/v6WKt 7eayqPRLTGVh4fYTKHZJ3vDsSTf3fi0SYzy+eeay4shl6mVqhPTbZ/YD/sk0VPU0j0zPPawZb5vQ7 jeBEQHEVkmNkmJUNOWgcj1wkEbtuiIqNvWWuEMvCAcF8gFWCkqic0uqjw3Hn6wiv679DJgG0vI7rl mAMLWAzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svxRp-00000005dsM-0nX2; Wed, 02 Oct 2024 11:23:13 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svxPD-00000005d6y-00DB for linux-arm-kernel@lists.infradead.org; Wed, 02 Oct 2024 11:20:32 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42cae6bb895so60283025e9.1 for ; Wed, 02 Oct 2024 04:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727868029; x=1728472829; 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=pWe1LOAQAUHDMm2EMz2P+3VNJFGofn6qsW8nJYyiXVM=; b=kLFHV9AScygf+apLITxsFKu5RjhkC0cRmGZC48U8BcrtAjLZJH4KlLDmDQde9NzA33 lArMOv+kwZpTVVu3usxzL0jBruSE1fyty2GU46GLbLxy00OMibHU75HmyQdIkbgX8kG5 I4+s0tCyP67KR5Xs1BJMm78h27bihMpzxiECArekM88ykxHDtcJCu/B/5yklykYh2Ve8 bAINfYvwu5NDyCfp7LlUeeP03HyYtdA47PE2uxFbBxwdmciarvw6SJcBqpKTSttxdamE H2t3lXYnORYKfRkfehtVzpfamOC2zfH+gWHcTRpuJ2J0kZst4OTJL94PVkR0+PzLiSVO Zmvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727868029; x=1728472829; 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=pWe1LOAQAUHDMm2EMz2P+3VNJFGofn6qsW8nJYyiXVM=; b=btmYKE82QZt7TBQ2RtV/CzD2KOecfWnGffIGkypKuHxMa6VwlBCeXucqoWQWFBoKHg EjEilUjwBfbdFJAQk3m0BbUHc8p5pxY2irNcvBuRlSp+LwLdaep+mRx4QDleQ4I00R4j 1IIj6Z05lV91ZnH7O5o5LWVL3ax4FccjUFbF06v3P3iKhhJhfI/wDpjvk2TPosDe7YA9 CK+9FYATO1Awh/WrDxtx0Vrds9zjCLcWnyEGbN+e5B+8yPsnMFhiMXZV3T/6vJ9BOq8B GIKg58uzCtX+z4rYTIGNcLvz3yN9DbT6U9V8iz3PmBlsVTuMoTz9ERJ1C8f50GQVnSsP jCjQ== X-Forwarded-Encrypted: i=1; AJvYcCUicxWfaIRqGBOcmH1fq79qTW6mDFrVn9X8JY77oRba4Ru1TQISExm3tJX9NIGO0Aow4NLWug/ZnYf//fa23c8O@lists.infradead.org X-Gm-Message-State: AOJu0Yx8XeGG1pUK687SIHds56EP8vvw9ttzd9+Pdr4dcPfl3IrI9ot/ 4onn8mOq7PHMCkrL9+IeIfv5BpEYl2db1F+oQB3YYKOay4DtaJi8vgzf7+d7 X-Google-Smtp-Source: AGHT+IFGTSatLO1Ox4UQ8gJUxFQ+Sve6VZQyHmLuQ8fa68lXptO2HqFrHIWSzqjI6q344kc1YAHVhQ== X-Received: by 2002:a5d:6189:0:b0:374:cbc4:53b1 with SMTP id ffacd0b85a97d-37cfba0a641mr1674756f8f.40.1727868028950; Wed, 02 Oct 2024 04:20:28 -0700 (PDT) Received: from eichest-laptop.corp.toradex.com (31-10-206-125.static.upc.ch. [31.10.206.125]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f771a1209sm23530685e9.0.2024.10.02.04.20.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 04:20:28 -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 Cc: linux-i2c@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, francesco.dolcini@toradex.com, Stefan Eichenberger Subject: [PATCH v4 1/4] i2c: imx: only poll for bus busy in multi master mode Date: Wed, 2 Oct 2024 13:19:39 +0200 Message-ID: <20241002112020.23913-2-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241002112020.23913-1-eichest@gmail.com> References: <20241002112020.23913-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241002_042031_066560_3473FF79 X-CRM114-Status: GOOD ( 15.38 ) 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 98539313cbc97..fbacdfaf6b28e 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,