From patchwork Sun Mar 12 13:19:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 662570 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0666BC6FA99 for ; Sun, 12 Mar 2023 13:22:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229502AbjCLNWP (ORCPT ); Sun, 12 Mar 2023 09:22:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230101AbjCLNWO (ORCPT ); Sun, 12 Mar 2023 09:22:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1B50974A; Sun, 12 Mar 2023 06:21:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C7DC360EBA; Sun, 12 Mar 2023 13:19:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9070C433EF; Sun, 12 Mar 2023 13:19:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678627191; bh=FqCJ2YcWNJ19nY3MTswZdQnYgovepeDjwKAJl8ifYG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ImlVBCqAA3koQAyaeTLiD70vTyDpyN2uEKpbLRl44nvbK43xDNAKd0gj+HWAew0yd 9dOXwsPcgP4gaoXTnPFDN0pfdp4NljKTDZ08AQl9UdyE845IEeQswEuRlN4uj8RneG CgCh1/FFJQWMOMWtp2yBvosv9xLgrrPhk1Xw4cOiQ83H39nLCZ7yKghxjPavzJSJU5 RamnaPfujM6I0lVQRCrSSgSZR0Isx5c1yoQbW8jDWohLhSIAsOfim/JXNspDtGyb2q RWpOehA7fiX8Sle5tak5RDzliCH8UmMyu1xW0qq/c5iZ4ZDACF+StNmomEcmDyFgoG 3C/uGaXPZr/ew== From: Andi Shyti To: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wolfram Sang , Rob Herring , Krzysztof Kozlowski , Chris Packham , Ryan Chen , Andi Shyti Subject: [PATCH 1/2] dt-bindings: i2c: Add the clock stretching property Date: Sun, 12 Mar 2023 14:19:32 +0100 Message-Id: <20230312131933.248715-2-andi.shyti@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230312131933.248715-1-andi.shyti@kernel.org> References: <20230312131933.248715-1-andi.shyti@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The I2C specification allows for the clock line to be held low for a specified timeout to force the slave device into a 'wait' mode. This feature is known as 'Clock stretching' and is optional. In the NXP I2C specification, clock stretching is described as the process of pausing a transaction by holding the SCL line LOW. The transaction can only continue when the line is released HIGH again.[*] However, most target devices do not include an SCL driver and are therefore unable to stretch the clock. Add the following properties: - i2c-scl-clk-low-timeout-ms: This property specifies the duration, in milliseconds, for which the clock is kept low and a client needs to detect a forced waiting state. - i2c-scl-has-clk-low-timeout: This property specifies whether the I2C controller implements the clock stretching property. It's important to note that this feature should not be confused with the SMBUS clock timeout, which serves a similar function but specifies a timeout of 25-35ms. The I2C specification does not recommend any specific timeout. [*] NXP, UM10204 - I2C-bus specification and user manual Rev. 7.0, 1 October 2021, chapter 3.1.9. Signed-off-by: Andi Shyti --- Documentation/devicetree/bindings/i2c/i2c.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c.txt b/Documentation/devicetree/bindings/i2c/i2c.txt index fc3dd7ec0445..12c311f0e831 100644 --- a/Documentation/devicetree/bindings/i2c/i2c.txt +++ b/Documentation/devicetree/bindings/i2c/i2c.txt @@ -45,6 +45,15 @@ wants to support one of the below features, it should adapt these bindings. Number of nanoseconds the SCL signal takes to rise; t(r) in the I2C specification. +- i2c-scl-clk-low-timeout-ms + Number of miliseconds the clock line needs to be pulled down in order + to force a waiting state. + +- i2c-scl-has-clk-low-timeout + Boolean value that indicates whether the controller implements the + feature of wait induction through SCL low, with the timeout being + implemented internally by the controller. + - i2c-sda-falling-time-ns Number of nanoseconds the SDA signal takes to fall; t(f) in the I2C specification. From patchwork Sun Mar 12 13:19:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 662571 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06F5BC6FA99 for ; Sun, 12 Mar 2023 13:21:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229740AbjCLNVo (ORCPT ); Sun, 12 Mar 2023 09:21:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbjCLNVn (ORCPT ); Sun, 12 Mar 2023 09:21:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11F6C2B2B5; Sun, 12 Mar 2023 06:21:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A60C260F14; Sun, 12 Mar 2023 13:19:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F92AC433EF; Sun, 12 Mar 2023 13:19:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678627194; bh=YpVG7djRZHe3zyr0hDaeowF//XjwA7OjIrOeWhOC/80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GnFOWyE1jG9bk/f+fQQlh9D79UMaw0y5fmirNBHmgHz39L4wVnIO6beu7RXTFuMCo SjOgh6Qo35FiwXj6LTcUSoy5WeGerHyAjx/D5HAH6B3mKbTeP/dQw9Kx1QWOHrAHCA AhsiMzhHnG8uyjJvG7O9q1PDR2ALnup1pU9GMhnApX16HpR+1vFoNbJJ6Ni09smmNu Anc2flf+alDgYlGrDpIecM7hL0TAgTzRWjz7Ts4hsNSpgSpi7hCabw+BE4syEzZ+9J pnTrMSM+MMoKqOXWuaYJ0ZiL3SMHpD+7aanwHTGQXA39fPwj8vrs3T5SpCq106QLoT hOBd+MrGtw1ig== From: Andi Shyti To: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wolfram Sang , Rob Herring , Krzysztof Kozlowski , Chris Packham , Ryan Chen , Andi Shyti Subject: [PATCH 2/2] i2c: mpc: Use the i2c-scl-clk-low-timeout-ms property Date: Sun, 12 Mar 2023 14:19:33 +0100 Message-Id: <20230312131933.248715-3-andi.shyti@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230312131933.248715-1-andi.shyti@kernel.org> References: <20230312131933.248715-1-andi.shyti@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Now we have the i2c-scl-clk-low-timeout-ms property defined in the binding. Use it and remove the previous "fsl,timeout". Signed-off-by: Andi Shyti Cc: Chris Packham --- Documentation/devicetree/bindings/i2c/i2c-mpc.yaml | 12 ++++++------ drivers/i2c/busses/i2c-mpc.c | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mpc.yaml b/Documentation/devicetree/bindings/i2c/i2c-mpc.yaml index 018e1b944424..c01547585456 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mpc.yaml +++ b/Documentation/devicetree/bindings/i2c/i2c-mpc.yaml @@ -41,11 +41,6 @@ properties: if defined, the clock settings from the bootloader are preserved (not touched) - fsl,timeout: - $ref: /schemas/types.yaml#/definitions/uint32 - description: | - I2C bus timeout in microseconds - fsl,i2c-erratum-a004447: $ref: /schemas/types.yaml#/definitions/flag description: | @@ -53,6 +48,11 @@ properties: says that the standard i2c recovery scheme mechanism does not work and an alternate implementation is needed. + i2c-scl-clk-low-timeout-ms: + description: + Indicates the SCL timeouts which used to force the client + into a waiting state + required: - compatible - reg @@ -95,6 +95,6 @@ examples: interrupts = <43 2>; interrupt-parent = <&mpic>; clock-frequency = <400000>; - fsl,timeout = <10000>; + i2c-scl-clk-low-timeout-ms = <10000>; }; ... diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 81ac92bb4f6f..93c484efc3f3 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c @@ -846,7 +846,8 @@ static int fsl_i2c_probe(struct platform_device *op) mpc_i2c_setup_8xxx(op->dev.of_node, i2c, clock); } - prop = of_get_property(op->dev.of_node, "fsl,timeout", &plen); + prop = of_get_property(op->dev.of_node, + "i2c-scl-clk-low-timeout-ms", &plen); if (prop && plen == sizeof(u32)) { mpc_ops.timeout = *prop * HZ / 1000000; if (mpc_ops.timeout < 5)