Message ID | 20240215-mbly-i2c-v1-9-19a336e91dca@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-67341-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp3580dyb; Thu, 15 Feb 2024 09:34:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUOQagCezB8YvbPiujxHSToHBuroodsdL7XpT/n5SaFv6fqHmkD8mePBeFh+qK/qrmzJI3hde4RpYKg33w2ym5dNqNMGA== X-Google-Smtp-Source: AGHT+IHvi1oE22j85IKkDPrDo6uqjoJFGil1mag67Gmflp+ORqOJT/BqLo8zgGuW/pIZCJK4ZoNo X-Received: by 2002:a17:902:d48e:b0:1db:403c:68b5 with SMTP id c14-20020a170902d48e00b001db403c68b5mr2665479plg.12.1708018487648; Thu, 15 Feb 2024 09:34:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708018487; cv=pass; d=google.com; s=arc-20160816; b=Z2vWrxHi7wFhQFdOgTzR8jnCe/9YOq9RCGm+clJBj3uXLgDNznCD5rj+GwiJk0baIl VRS1D2WwFCSHr1INArt5XJoiw/uBDj7Zhc3GpaNy+QcN73OG0ioyFVXBUzcSdM9K7AAN soRfeVvgwZ4dWOd1bYfoNXbq4EGGtohp0yndj82Z2iVEfWxOzpR13PtVNqYLUk1ix/hS IOZnHcBD6R6oY8fZ1FPlutVv9C88ZEl68xgxn8csm1xvicqvIEF6UG1NoVx8E0Af3m1f WnaCgwNcDtOrqTbuarAT+XO5AGyH9TwDSOqpETwdgBOGFKBSxKEks3Kuoyh6XZ/cY+uw jpXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=UI781RDrcik2RYtu08sBCE4vst1s92iXfDeWJ+Uj5KU=; fh=5JSnMO1qLgeVtLVJilSQcFnAcZn2MWLSM3RnsAdOnEU=; b=zmb5UwoQhbAhkOMV8qCtfEWcQhkBgfllUsgnER0XhuDH1qU/X8BXumEBakSEYAjZOR pCGAxm7H6zStbnDEYnm9pGN0CzsI/ifcthIFqvI1nMpwahlqonTIEYnRDaMzpTqyddb1 I7PbVA0rj+bBdpd4ek1E7G/2HWpM8+vCyvIluKnTutTG7XecQYbpgp1nliyHdGQQP0a7 Q58ttxCrMn/Bn1cbjOa9ZZw0KVK8iq93S5X26SRy7eufoNvmsYAtpgExIGMDF5fyyLpr B6xgxEKTjEAYw3H7uOu0vsBxsWKFBb3IR05QjB2SOTG4bN65jesCeG+1vDSkiw0iB4+P Rd5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=X05Jz2dA; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-67341-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67341-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id lk8-20020a17090308c800b001db689196f2si1469806plb.212.2024.02.15.09.34.47 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 09:34:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67341-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=X05Jz2dA; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-67341-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67341-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id EA6B1B2631A for <ouuuleilei@gmail.com>; Thu, 15 Feb 2024 16:55:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EBE213AA21; Thu, 15 Feb 2024 16:52:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="X05Jz2dA" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 268A2137C59; Thu, 15 Feb 2024 16:52:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708015963; cv=none; b=LyJ7zafEJz/OHm6oTw2Mt/B/cDfXMNlIZXSZqKREtKo+cXBDSaGeAoJRuSmOSDmqF0R4krYT79oRbbRybiTfATHPjzXD2L3EVbWiFETIJ2SyDTlMBSpoIzq6fo3pXXly8L2G+7IFGCcq1TwYqumxj/tP4LO6ED3ON5lhz6EywOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708015963; c=relaxed/simple; bh=89bCy4HxE92AdAoVyq7hD/JI8ZtUqitna8+RsdSL2u4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IuniABeq+yALyEhmw5D5SdAL9Y7Mb45b3qtBBbyybbCIjNhbxtlGTVHqHl6eSTMKwbBuaDAo/SSzWJjc3sdfAfe7HxWqw6vQMJ/PgRk1XNtl/WRgRwWz4XiuYfd4dr4RAOnSDzy8XowG9faYPzbe9en1LVIRU/fqaa//a9kSeUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=X05Jz2dA; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 15314E001C; Thu, 15 Feb 2024 16:52:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708015959; 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=UI781RDrcik2RYtu08sBCE4vst1s92iXfDeWJ+Uj5KU=; b=X05Jz2dAVG/OH6mW1jIs5toXJymKoVNLKETT2ySNywm1E39ztnrDGFF0D8gM52fJK4ht8S GlsXS6EtRyAI8NqrY7PgfJyUBMVvBViA4JsdVZMN8W4ulmO2shWGGWJTXehc4x2dooC8NX RyILp5eN8NororpKPh7LTYt/9AsFMA78CfPfFEPhOA7YEiS4k1UBJrjJ2FYQJALUz5OCTO 106oqSyERyYZ3k+PHU2UTSe1t9JkdECSBZzOQtF/UYVaoB/j9Zsd90zu1q6phsU06un7z8 jWPCIyvX5HbtAgH44bQ3QaTbUckQBQRXspjG5PwyVBOkvn2LeXW5npVDH7SNYg== From: =?utf-8?q?Th=C3=A9o_Lebrun?= <theo.lebrun@bootlin.com> Date: Thu, 15 Feb 2024 17:52:16 +0100 Subject: [PATCH 09/13] i2c: nomadik: fetch timeout-usecs property from devicetree Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240215-mbly-i2c-v1-9-19a336e91dca@bootlin.com> References: <20240215-mbly-i2c-v1-0-19a336e91dca@bootlin.com> In-Reply-To: <20240215-mbly-i2c-v1-0-19a336e91dca@bootlin.com> To: Linus Walleij <linus.walleij@linaro.org>, Andi Shyti <andi.shyti@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Thomas Bogendoerfer <tsbogend@alpha.franken.de> 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 <gregory.clement@bootlin.com>, Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Tawfik Bayouk <tawfik.bayouk@mobileye.com>, =?utf-8?q?Th=C3=A9o_Lebrun?= <theo.lebrun@bootlin.com> X-Mailer: b4 0.12.4 X-GND-Sasl: theo.lebrun@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790987193727762147 X-GMAIL-MSGID: 1790987193727762147 |
Series |
Add Mobileye EyeQ5 support to the Nomadik I2C controller & use hrtimers for timeouts
|
|
Commit Message
Théo Lebrun
Feb. 15, 2024, 4:52 p.m. UTC
Allow overriding the default timeout value (200ms) from devicetree,
using the timeout-usecs 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 <theo.lebrun@bootlin.com>
---
drivers/i2c/busses/i2c-nomadik.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
Comments
On Thu, Feb 15, 2024 at 5:52 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote: > Allow overriding the default timeout value (200ms) from devicetree, > using the timeout-usecs 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 <theo.lebrun@bootlin.com> Once we agree on the binding name: Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij
> + /* Slave response timeout */ > + if (!of_property_read_u32(np, "timeout-usecs", &timeout_usecs)) > + priv->timeout_usecs = timeout_usecs; > + else > + priv->timeout_usecs = 200 * USEC_PER_MSEC; I could imagine to add 'transfer_timeout_us' to struct i2c_timings. Then, you could use 'i2c_parse_fw_timings' to obtain the value. What values/value range do you use here? I can't find them in the DTS additions.
Hello, On Tue Feb 27, 2024 at 1:14 PM CET, Wolfram Sang wrote: > > + /* Slave response timeout */ > > + if (!of_property_read_u32(np, "timeout-usecs", &timeout_usecs)) > > + priv->timeout_usecs = timeout_usecs; > > + else > > + priv->timeout_usecs = 200 * USEC_PER_MSEC; > > I could imagine to add 'transfer_timeout_us' to struct i2c_timings. > Then, you could use 'i2c_parse_fw_timings' to obtain the value. What > values/value range do you use here? I can't find them in the DTS > additions. That sounds good. I have not used this prop in the DTS as it does not make much sense for an eval board. The target is production boards. An order of magnitude is a few transfers every 15ms. It means a timeout of 15ms divided by "a few". I don't have more precise values, but I could if you consider it useful. I've done some testing at 50~100µs timeouts and it works as expected. At those values timerslack is important to consider (default of 50µs). This is at 400kHz clock frequency. Keep in mind the controllers support up to 3.4MHz (not yet upstreamed) so timeouts could in theory go lower if required by the usecase. My upcoming question is how to move forward on this series. I can do the patch to i2c_parse_fw_timings() in the next revision. That way it gets added alongside the first user of this feature. Would it work for you? Thanks, -- Théo Lebrun, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Hi Théo, > That sounds good. I have not used this prop in the DTS as it does not > make much sense for an eval board. The target is production boards. ... > My upcoming question is how to move forward on this series. I can do the > patch to i2c_parse_fw_timings() in the next revision. That way it gets > added alongside the first user of this feature. Would it work for you? Hmmm, to be honest I have a bit of an issue with the 'no user' problem. There is a driver which uses this feature, okay. But there is no upstream hardware which uses this driver with this new feature. This makes maintaining harder ("Who uses this feature?" - "Someone" - "How do they use it? Can we modify it?" - "Dunno"). Kind regards, Wolfram
Hello Wolfram, On Wed Feb 28, 2024 at 11:49 AM CET, Wolfram Sang wrote: > > That sounds good. I have not used this prop in the DTS as it does not > > make much sense for an eval board. The target is production boards. > > ... > > > My upcoming question is how to move forward on this series. I can do the > > patch to i2c_parse_fw_timings() in the next revision. That way it gets > > added alongside the first user of this feature. Would it work for you? > > Hmmm, to be honest I have a bit of an issue with the 'no user' problem. > There is a driver which uses this feature, okay. But there is no > upstream hardware which uses this driver with this new feature. This > makes maintaining harder ("Who uses this feature?" - "Someone" - "How do > they use it? Can we modify it?" - "Dunno"). The alternative is that I keep going with a new revision of i2c-nomadik that manually parses the prop. It'll be refactored if/when the I2C core provides a better way to access the value. Is that OK? Thanks, -- Théo Lebrun, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
> The alternative is that I keep going with a new revision of i2c-nomadik > that manually parses the prop. It'll be refactored if/when the I2C core > provides a better way to access the value. Is that OK? That wouldn't have helped because there is still no user in-kernel of that property, i.e. no DTS file with that property. But I just realized that I need to convert i2c-mpc to avoid a deprecated binding, so we have a user there. Lucky you ;) I'll try to get the series done today.
Hello, On Thu Feb 29, 2024 at 10:25 AM CET, Wolfram Sang wrote: > > The alternative is that I keep going with a new revision of i2c-nomadik > > that manually parses the prop. It'll be refactored if/when the I2C core > > provides a better way to access the value. Is that OK? > > That wouldn't have helped because there is still no user in-kernel of > that property, i.e. no DTS file with that property. But I just realized > that I need to convert i2c-mpc to avoid a deprecated binding, so we have > a user there. Lucky you ;) > > I'll try to get the series done today. Lucky me indeed! I just thought about it but I don't mind using the property in the eval board DTS. The default 200ms timeout makes no sense for us. Using a default of a few ms would be more sensible and make us the second user of the prop. Thanks, -- Théo Lebrun, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index afd54999bbbb..23e12c570457 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, "timeout-usecs", &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)