From patchwork Thu Feb 29 18:10:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 13577524 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 5FDA0C48BF6 for ; Thu, 29 Feb 2024 18:12:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5OoGb49h0tg4eERBRaID9nr+7hLVv6Y7+AiIpLbZNRk=; b=n/qwUtOWt4kJnk iWUxe2ax5YQE3rv7ULxPv4Mzuh/UQN/fhqrXBvOQeDQ6CyIpyZBow/j97QpDTM7KEakEIv0Sx+LJB OOg7wu3hDL2TASfu56TBbod9QuiDGqggJtUbSdniz508hnsk04bBWkFHfPlxlu66Hc6P9QVxlVi5j dV4dsE/ZtCYTgYEJ922Kyo0IeXRoCkTSgQriIftW4rkIS2mbTZT3MKpCd9XID2rUvieqUx6tQfI50 uGBrSRLtMP0YW2P4Xr46PFzbgOcLKgvzIbW0X7btsh93pUg6X22XVWlsNmyNbAe6EiSgwf6OQA4V5 pis+AsxbGGkVTUUa4VaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfkt8-0000000Edi0-1wDJ; Thu, 29 Feb 2024 18:12:10 +0000 Received: from relay3-d.mail.gandi.net ([2001:4b98:dc4:8::223]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfkrz-0000000Ed8c-3zcs for linux-arm-kernel@lists.infradead.org; Thu, 29 Feb 2024 18:11:02 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id C8B9D6000D; Thu, 29 Feb 2024 18:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709230258; h=from:from:reply-to:subject:subject: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=2KjP0tKD670ot1mY6zPPbSUpgJRRflTSHBgbfRubJdc=; b=OO3hwQ08HWAyapA/2XepbuagNM2zP1pxIlO8mrWqHd+LCRlzIUf0wbHfUQiX/H8vMQEJbM jiK4GuNALRnuV0HyyIj8DO298cKZV8OkaW+qpDWKncMDYFKX7sR6YxzcbOV3KDyBveLnRK OKpQ4huodC9QD68KyaUEAStQHGeJVkaThwKPZ8M6PQqNJOYTL4WEROfJ5wS7fr+npsb4i4 WHpe34vjgsngwacZrHY97OA8fz84MzK3GSdQY4PVImxhLpQSZ2KkKNjo9FnZB1SGCKsGJL kjQkFVkI2ya/cdaCZZEb70771Z8cTZznf1gL2fslCYnSxwzXduerUHyUZiPp2w== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Thu, 29 Feb 2024 19:10:56 +0100 Subject: [PATCH v2 08/11] i2c: nomadik: fetch i2c-transfer-timeout-us property from devicetree MIME-Version: 1.0 Message-Id: <20240229-mbly-i2c-v2-8-b32ed18c098c@bootlin.com> References: <20240229-mbly-i2c-v2-0-b32ed18c098c@bootlin.com> In-Reply-To: <20240229-mbly-i2c-v2-0-b32ed18c098c@bootlin.com> To: Linus Walleij , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thomas Bogendoerfer Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Gregory Clement , Vladimir Kondratiev , Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.13.0 X-GND-Sasl: theo.lebrun@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240229_101100_244842_36F9908D X-CRM114-Status: GOOD ( 11.90 ) 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 Allow overriding the default timeout value (200ms) from devicetree, using the generic i2c-transfer-timeout-us property. The i2c_adapter->timeout field is an unaccurate jiffies amount; i2c-nomadik uses hrtimers for timeouts below one jiffy. Signed-off-by: Théo Lebrun Reviewed-by: Linus Walleij Reviewed-by: Wolfram Sang Reviewed-by: Andi Shyti --- drivers/i2c/busses/i2c-nomadik.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index afd54999bbbb..2d3247979e45 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -964,6 +964,8 @@ static const struct i2c_algorithm nmk_i2c_algo = { static void nmk_i2c_of_probe(struct device_node *np, struct nmk_i2c_dev *priv) { + u32 timeout_usecs; + /* Default to 100 kHz if no frequency is given in the node */ if (of_property_read_u32(np, "clock-frequency", &priv->clk_freq)) priv->clk_freq = I2C_MAX_STANDARD_MODE_FREQ; @@ -975,7 +977,12 @@ static void nmk_i2c_of_probe(struct device_node *np, priv->sm = I2C_FREQ_MODE_FAST; priv->tft = 1; /* Tx FIFO threshold */ priv->rft = 8; /* Rx FIFO threshold */ - priv->timeout_usecs = 200 * USEC_PER_MSEC; /* Slave response timeout */ + + /* Slave response timeout */ + if (!of_property_read_u32(np, "i2c-transfer-timeout-us", &timeout_usecs)) + priv->timeout_usecs = timeout_usecs; + else + priv->timeout_usecs = 200 * USEC_PER_MSEC; } static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)