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: 68327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp717340wrd; Sun, 12 Mar 2023 06:30:44 -0700 (PDT) X-Google-Smtp-Source: AK7set86aKl+A+v4OTbqsxomSPwhWWmXS4E8/aBUofRm+GoC6xTS3fFKRIKtiPcLAJqIih8w2TmW X-Received: by 2002:a17:902:ee46:b0:19e:3725:8fc6 with SMTP id 6-20020a170902ee4600b0019e37258fc6mr28006071plo.20.1678627844435; Sun, 12 Mar 2023 06:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678627844; cv=none; d=google.com; s=arc-20160816; b=S5+c1ZsifPWYQ13V2d9NBa8R3OxBi9FQ81r0/raUY6ihu/HIa20m5S9JKT873VKjth cdE7GXStIsyX3p75MuH4MsknvKFQ7LKZgrYnOgKXfO4kCLV2UYJ2dP7TdRQ/dNFKX6Xu KabgeMV0WdtyMS1rW5w/xLEmrDWrZzuYwSnw4Q3LpBvjzNkEQztOEGAD1sVnsWLJJp+S zRhJTwNG95CIjrhWzH3p4/UsbdkEuek7ZZBbO/+6jlWBB/p1LgG4xV16uAqwK9jHNe3+ AfJIpx3egu0tNh072rfUkYF/UZmkcC+uN4h/C96wEXTd2T8ItAAQYCTVayOHb1IP13gs 6eOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=W1QL8yxfrOIpsRQ9E83wBn7w/lbFzZM+ok8A5JN6MzE=; b=ZJcalRQ0pXohxUCgexS5ACvBPoNTxaHOtzYqvYzShnXttn4i9I8CVbHL4Fi1c22mO3 gpez7XDxPQBwUy4sSQes/rJSPxEDY1yaLEVAWmsRqx626MgSRyFmcMVcwP1Ymqog8Aqr ApNzZ4YulDjhiEd0rnBKVnsDOOYwQdjciHgC/Aw2Ru+33SmaEZpoM4rZXg2yoM4qvXhC AM4jJxDVicAg/auCcMNSktMBC9SG2++uG/SuO1vvAhDumVKn0WtguPIuHo6OuzX8dDRI X7yXw5gGvF1DBUvH4ZI47T28hISmq35JFFsNo0+H+EELj3SrWel3Sm9sGL3lchrSlz7o pu4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ImlVBCqA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lh15-20020a170903290f00b0019aba9c49a5si4260815plb.588.2023.03.12.06.30.29; Sun, 12 Mar 2023 06:30:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ImlVBCqA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230135AbjCLNWP (ORCPT + 99 others); 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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760168870265846164?= X-GMAIL-MSGID: =?utf-8?q?1760168870265846164?= 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: 68314 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp716245wrd; Sun, 12 Mar 2023 06:27:54 -0700 (PDT) X-Google-Smtp-Source: AK7set8GthG6Wy/JV3cCLRuKvlX95khoI1RvNMGe74KxJAVIEe+jU1vlie/0Y9TNv1dKxsRkK9ov X-Received: by 2002:a17:903:4cd:b0:19c:ed28:66ec with SMTP id jm13-20020a17090304cd00b0019ced2866ecmr26296725plb.21.1678627673880; Sun, 12 Mar 2023 06:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678627673; cv=none; d=google.com; s=arc-20160816; b=SgV5zt4HID+Nmw1RzE5xL6t+AKDCJ25Ds2KbCSBoFUTFb3e0kDgCK+3obpujCfLnAp Wt4K74lYAv19/xIVe7Q8RMirX9iuERyWXBt9SoFssFh9rD/RCHY4GA6IiM/Su51j2eS+ JvAIfrrRGdQ/sn3A97a6oecg8gV0cnsMQ08KuUXkk+T5AWLapordHJ3f2YyIEzCoKh8V S2kWRrwMuVHL5dcM5mIj4i3lDwIXQja3CPzwlQCSeIZmqBMKJg4bOtSuXEdstAB7iK+z /6L4kQyWasB6eynAyBzAeo83DfuRtYT9r29pMKIxC+8jdXviGqUiNF1Ff2bCKDpC9Amv KEZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=81Pbheh0kbERZv2zzlYDIDHZDoojS62z9r4Z5PQcNlc=; b=SNxhfTKvUXTekY22OmaKkdmjC1aktjpuBMOe4rX5NrFmBOtz2Ee2dv/W4w7xVJERqF JfnkRFx9b71ebDyX+hS88HBvSUG7CkpiTXOmJQyrubGh+KwesDVzOVEPCEu/XKTM6Cnr 9bOI+DfiwzbKSZDiEA/ili7jb+naBncihdXZXKpdz0WSq2rVXsUHXGdvUZsmqI23jWNV LfHVp/pPTqpZzCFoLZWYuuHTBqYfjaHzGiw4z4WEkZKOv/Fn9Va1QfePukq3ZMiPBT3V uEpdjWHD3whL88guSpI/I3TVn/tO4fqxXyCsO0f/SQzw1xrTe0yf4YnOPrijvvpitVe2 Jj4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GnFOWyE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o18-20020a170902779200b001a0433208easi704839pll.410.2023.03.12.06.27.39; Sun, 12 Mar 2023 06:27:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GnFOWyE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229897AbjCLNVp (ORCPT + 99 others); Sun, 12 Mar 2023 09:21:45 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760168691789208177?= X-GMAIL-MSGID: =?utf-8?q?1760168691789208177?= 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)