Message ID | 20230312233613.303408-4-andi.shyti@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp921714wrd; Sun, 12 Mar 2023 16:39:51 -0700 (PDT) X-Google-Smtp-Source: AK7set/G4TL7gqdw2tjutXHPyaplEDNgFLunxr0UDV6K+78fzelNTx84a7Xskv/z9/+usHvTwneY X-Received: by 2002:a17:903:2290:b0:19e:25b4:7740 with SMTP id b16-20020a170903229000b0019e25b47740mr40448630plh.28.1678664390894; Sun, 12 Mar 2023 16:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678664390; cv=none; d=google.com; s=arc-20160816; b=EHD2g1lWrO3N2GOqAGhntlpyyX/GL2XOkLDoFeTcSWtOkTWdE5uzi1sEPDWcxPvm7B 2t+nt5/IU/MHwhf7kvIjsyAiiYS5vdVTT/poe8WgHqk16c8PRXqFLmRonTGQqb6MVa6R D2zmX9dvSwWM0mMgspXZq+W9d64p7y/Wk+sNl06GPoriTWhwyyePggYSGA+ZdeuUHj8/ 2OZMgvXSxoX+h5bEb+9RqmihG1eLJt4T6ZLQ8gcnWkkIOXoTMURM0yGE4abTJJ6ONmb+ mMwypA0yRnSPmDpFtd0g9UicTg5j3vjaXdStBKuculrZW2v+a9tr8Fz5tYRkhwa14f9w 53Fg== 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=/AMZ723bI4pq622sqrygb/LAn4fcOJDiPd3KIEfH7xU=; b=FqcpzILqPELboAbkdy1Q8ObO+9Ljbc0NeX5u/3zJ80JYfiZICS6T8M94PB0I/feuDB ZmsRJnoajXE8x01Ac8IsHAAtGdrglzOf5IaTBx52Fc8l/7jUf2DL4wpNWo75JFrwZpnr 2rpuYptdkz8h6xGTd5RVEhPcf9S+mVOVh0jT4eSvqjYRD+xf6D+PZ+p8qoBSdsFubl7b hEHj/fqil2lQ+ib0LSZmPRtM3sUxlg3FzHcELnetBPD+2d4m9J64oM2P5QhL/SngtAhO uY1DLPMFF5FsR5c1EXjgOXswFp2JJv4yqMrq+xM34Z07B0yemfS0gvoF3ZBpaBztw1KQ LhVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ldWOxo6n; 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 u1-20020a17090341c100b0019e6e5fc15dsi5558597ple.496.2023.03.12.16.39.36; Sun, 12 Mar 2023 16:39:50 -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=ldWOxo6n; 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 S229897AbjCLXhA (ORCPT <rfc822;realc9580@gmail.com> + 99 others); Sun, 12 Mar 2023 19:37:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229921AbjCLXgz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 12 Mar 2023 19:36:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CC663B0D4; Sun, 12 Mar 2023 16:36:52 -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 ams.source.kernel.org (Postfix) with ESMTPS id 14C89B80DC8; Sun, 12 Mar 2023 23:36:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41303C4339B; Sun, 12 Mar 2023 23:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678664209; bh=wfuc6Igk++l7xu4oCP46B+qUAYlG7dpvbl5q/Q6k7cM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ldWOxo6n5bPUwNKnDwJsuZaa/BXi1lBKwJBXWPOwzXhaDDjrwl9gvM6jSgXZJm/1C RYyuFjPNkBMKkEgBjRp36QFHIx5lewKSE63DDtESkWG/J60CAwvzPbaXRV+eBE3opr ceq6Gci51OUPia2VLZDmrRDu3iUq0tqAZmuMCFfXgFBwYamE5nzr99uPzWOpdQKDHQ oQ19//bhUr9+jo/IWK/VpgWCxAHRJ8Wl7SLuX6UK/P2dWGnOpf+sFfh8vQvULWUCC9 /MubxQpbAgsBsqXrxGMizTSmsytFnZzmZ7sCeQUyPgwSk9k10QzbFtpPKAWlMtPA/g DdqMV7H6ZJGow== From: Andi Shyti <andi.shyti@kernel.org> To: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wolfram Sang <wsa@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Chris Packham <chris.packham@alliedtelesis.co.nz>, Ryan Chen <ryan_chen@aspeedtech.com>, Andi Shyti <andi.shyti@kernel.org> Subject: [PATCH v3 3/3] i2c: mpc: Use i2c-scl-clk-low-timeout-ms i2c property Date: Mon, 13 Mar 2023 00:36:13 +0100 Message-Id: <20230312233613.303408-4-andi.shyti@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230312233613.303408-1-andi.shyti@kernel.org> References: <20230312233613.303408-1-andi.shyti@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760207192503089928?= X-GMAIL-MSGID: =?utf-8?q?1760207192503089928?= |
Series |
Add the clock stretching i2c property
|
|
Commit Message
Andi Shyti
March 12, 2023, 11:36 p.m. UTC
"fsl,timeout" is marked as deprecated and replaced by the "i2c-scl-clk-low-timeout-ms" i2c property. Use this latter and, in case it is missing, for back compatibility, check whether we still have "fsl,timeout" defined. Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> --- drivers/i2c/busses/i2c-mpc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Comments
On 13/03/23 12:36, Andi Shyti wrote: > "fsl,timeout" is marked as deprecated and replaced by the > "i2c-scl-clk-low-timeout-ms" i2c property. > > Use this latter and, in case it is missing, for back > compatibility, check whether we still have "fsl,timeout" defined. > > Signed-off-by: Andi Shyti <andi.shyti@kernel.org> > Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Gave the patches a spin on a P2041RDB so Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> > --- > drivers/i2c/busses/i2c-mpc.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c > index 87e5c1725750..28f11e30ac50 100644 > --- a/drivers/i2c/busses/i2c-mpc.c > +++ b/drivers/i2c/busses/i2c-mpc.c > @@ -843,8 +843,18 @@ static int fsl_i2c_probe(struct platform_device *op) > mpc_i2c_setup_8xxx(op->dev.of_node, i2c, clock); > } > > + /* > + * "fsl,timeout" has been marked as deprecated and, to maintain > + * backward compatibility, we will only look for it if > + * "i2c-scl-clk-low-timeout-ms" is not present. > + */ > result = of_property_read_u32(op->dev.of_node, > - "fsl,timeout", &mpc_ops.timeout); > + "i2c-scl-clk-low-timeout-ms", > + &mpc_ops.timeout); > + if (result == -EINVAL) > + result = of_property_read_u32(op->dev.of_node, > + "fsl,timeout", &mpc_ops.timeout); > + > if (!result) { > mpc_ops.timeout *= HZ / 1000000; > if (mpc_ops.timeout < 5)
> On 13/03/23 12:36, Andi Shyti wrote: > > "fsl,timeout" is marked as deprecated and replaced by the > > "i2c-scl-clk-low-timeout-ms" i2c property. > > > > Use this latter and, in case it is missing, for back > > compatibility, check whether we still have "fsl,timeout" defined. > > > > Signed-off-by: Andi Shyti <andi.shyti@kernel.org> > > Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> > Gave the patches a spin on a P2041RDB so > > Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Thanks, Chris! Andi
On 13/03/2023 00:36, Andi Shyti wrote: > "fsl,timeout" is marked as deprecated and replaced by the > "i2c-scl-clk-low-timeout-ms" i2c property. > > Use this latter and, in case it is missing, for back > compatibility, check whether we still have "fsl,timeout" defined. > > Signed-off-by: Andi Shyti <andi.shyti@kernel.org> > Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> > --- > drivers/i2c/busses/i2c-mpc.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c > index 87e5c1725750..28f11e30ac50 100644 > --- a/drivers/i2c/busses/i2c-mpc.c > +++ b/drivers/i2c/busses/i2c-mpc.c > @@ -843,8 +843,18 @@ static int fsl_i2c_probe(struct platform_device *op) > mpc_i2c_setup_8xxx(op->dev.of_node, i2c, clock); > } > > + /* > + * "fsl,timeout" has been marked as deprecated and, to maintain > + * backward compatibility, we will only look for it if > + * "i2c-scl-clk-low-timeout-ms" is not present. > + */ > result = of_property_read_u32(op->dev.of_node, > - "fsl,timeout", &mpc_ops.timeout); > + "i2c-scl-clk-low-timeout-ms", > + &mpc_ops.timeout); > + if (result == -EINVAL) > + result = of_property_read_u32(op->dev.of_node, > + "fsl,timeout", &mpc_ops.timeout); Wasn't old property in us and new one is in ms? Best regards, Krzysztof
Hi, On Tue, Mar 14, 2023 at 03:22:52PM +0100, Krzysztof Kozlowski wrote: > On 13/03/2023 00:36, Andi Shyti wrote: > > "fsl,timeout" is marked as deprecated and replaced by the > > "i2c-scl-clk-low-timeout-ms" i2c property. > > > > Use this latter and, in case it is missing, for back > > compatibility, check whether we still have "fsl,timeout" defined. > > > > Signed-off-by: Andi Shyti <andi.shyti@kernel.org> > > Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> > > --- > > drivers/i2c/busses/i2c-mpc.c | 12 +++++++++++- > > 1 file changed, 11 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c > > index 87e5c1725750..28f11e30ac50 100644 > > --- a/drivers/i2c/busses/i2c-mpc.c > > +++ b/drivers/i2c/busses/i2c-mpc.c > > @@ -843,8 +843,18 @@ static int fsl_i2c_probe(struct platform_device *op) > > mpc_i2c_setup_8xxx(op->dev.of_node, i2c, clock); > > } > > > > + /* > > + * "fsl,timeout" has been marked as deprecated and, to maintain > > + * backward compatibility, we will only look for it if > > + * "i2c-scl-clk-low-timeout-ms" is not present. > > + */ > > result = of_property_read_u32(op->dev.of_node, > > - "fsl,timeout", &mpc_ops.timeout); > > + "i2c-scl-clk-low-timeout-ms", > > + &mpc_ops.timeout); > > + if (result == -EINVAL) > > + result = of_property_read_u32(op->dev.of_node, > > + "fsl,timeout", &mpc_ops.timeout); > > Wasn't old property in us and new one is in ms? Thanks, Krzysztof! Good catch! Chris, you are the only user of this property, as of now. Is it OK if we keep it ms? I will send a proper patch to do the conversion. To me it doesn't make much sense to have the timeout defined in us as that's of the same order of the raising and falling time of the clock. Any opinion? Andi
Hi Andi, On 15/03/23 04:16, Andi Shyti wrote: > Hi, > > On Tue, Mar 14, 2023 at 03:22:52PM +0100, Krzysztof Kozlowski wrote: >> On 13/03/2023 00:36, Andi Shyti wrote: >>> "fsl,timeout" is marked as deprecated and replaced by the >>> "i2c-scl-clk-low-timeout-ms" i2c property. >>> >>> Use this latter and, in case it is missing, for back >>> compatibility, check whether we still have "fsl,timeout" defined. >>> >>> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> >>> Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> >>> --- >>> drivers/i2c/busses/i2c-mpc.c | 12 +++++++++++- >>> 1 file changed, 11 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c >>> index 87e5c1725750..28f11e30ac50 100644 >>> --- a/drivers/i2c/busses/i2c-mpc.c >>> +++ b/drivers/i2c/busses/i2c-mpc.c >>> @@ -843,8 +843,18 @@ static int fsl_i2c_probe(struct platform_device *op) >>> mpc_i2c_setup_8xxx(op->dev.of_node, i2c, clock); >>> } >>> >>> + /* >>> + * "fsl,timeout" has been marked as deprecated and, to maintain >>> + * backward compatibility, we will only look for it if >>> + * "i2c-scl-clk-low-timeout-ms" is not present. >>> + */ >>> result = of_property_read_u32(op->dev.of_node, >>> - "fsl,timeout", &mpc_ops.timeout); >>> + "i2c-scl-clk-low-timeout-ms", >>> + &mpc_ops.timeout); >>> + if (result == -EINVAL) >>> + result = of_property_read_u32(op->dev.of_node, >>> + "fsl,timeout", &mpc_ops.timeout); >> Wasn't old property in us and new one is in ms? > Thanks, Krzysztof! Good catch! > > Chris, you are the only user of this property, as of now. Is it > OK if we keep it ms? I will send a proper patch to do the > conversion. > > To me it doesn't make much sense to have the timeout defined in > us as that's of the same order of the raising and falling time > of the clock. Any opinion? I think it'd be easier to stick to us as then the same code can be used to probe both the old property and the new one. However I won't object if you adjust for the us to ms conversion between handling the new property vs the old one. > > Andi
Hi Chris, > >>> "fsl,timeout" is marked as deprecated and replaced by the > >>> "i2c-scl-clk-low-timeout-ms" i2c property. > >>> > >>> Use this latter and, in case it is missing, for back > >>> compatibility, check whether we still have "fsl,timeout" defined. > >>> > >>> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> > >>> Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> > >>> --- > >>> drivers/i2c/busses/i2c-mpc.c | 12 +++++++++++- > >>> 1 file changed, 11 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c > >>> index 87e5c1725750..28f11e30ac50 100644 > >>> --- a/drivers/i2c/busses/i2c-mpc.c > >>> +++ b/drivers/i2c/busses/i2c-mpc.c > >>> @@ -843,8 +843,18 @@ static int fsl_i2c_probe(struct platform_device *op) > >>> mpc_i2c_setup_8xxx(op->dev.of_node, i2c, clock); > >>> } > >>> > >>> + /* > >>> + * "fsl,timeout" has been marked as deprecated and, to maintain > >>> + * backward compatibility, we will only look for it if > >>> + * "i2c-scl-clk-low-timeout-ms" is not present. > >>> + */ > >>> result = of_property_read_u32(op->dev.of_node, > >>> - "fsl,timeout", &mpc_ops.timeout); > >>> + "i2c-scl-clk-low-timeout-ms", > >>> + &mpc_ops.timeout); > >>> + if (result == -EINVAL) > >>> + result = of_property_read_u32(op->dev.of_node, > >>> + "fsl,timeout", &mpc_ops.timeout); > >> Wasn't old property in us and new one is in ms? > > Thanks, Krzysztof! Good catch! > > > > Chris, you are the only user of this property, as of now. Is it > > OK if we keep it ms? I will send a proper patch to do the > > conversion. > > > > To me it doesn't make much sense to have the timeout defined in > > us as that's of the same order of the raising and falling time > > of the clock. Any opinion? > I think it'd be easier to stick to us as then the same code can be used > to probe both the old property and the new one. However I won't object > if you adjust for the us to ms conversion between handling the new > property vs the old one. yeah... indeed it became quite ugly. OK, I will just rename it from "i2c-scl-clk-low-timeout-ms" to "i2c-scl-clk-low-timeout-us", respin the schema pull request and leave everything as it is. Thanks for your input, Chris! Andi
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 87e5c1725750..28f11e30ac50 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c @@ -843,8 +843,18 @@ static int fsl_i2c_probe(struct platform_device *op) mpc_i2c_setup_8xxx(op->dev.of_node, i2c, clock); } + /* + * "fsl,timeout" has been marked as deprecated and, to maintain + * backward compatibility, we will only look for it if + * "i2c-scl-clk-low-timeout-ms" is not present. + */ result = of_property_read_u32(op->dev.of_node, - "fsl,timeout", &mpc_ops.timeout); + "i2c-scl-clk-low-timeout-ms", + &mpc_ops.timeout); + if (result == -EINVAL) + result = of_property_read_u32(op->dev.of_node, + "fsl,timeout", &mpc_ops.timeout); + if (!result) { mpc_ops.timeout *= HZ / 1000000; if (mpc_ops.timeout < 5)