Message ID | 3bf827929a44c17bfb1bf1000b143c02ce26a929.1693102324.git.daniel@makrotopia.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp2653255vqm; Sat, 26 Aug 2023 20:58:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcAmmebUHOOaazw3v4E5SuJYRANTbca+lFiwX0JVUfUcJalU9sHifqGlDCKfxzeKcKom3h X-Received: by 2002:a17:906:dc91:b0:9a1:e0b1:e919 with SMTP id cs17-20020a170906dc9100b009a1e0b1e919mr12562623ejc.4.1693108704578; Sat, 26 Aug 2023 20:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693108704; cv=none; d=google.com; s=arc-20160816; b=U59v7NTWGHpx1M4DMeAW7MB4MGsPFNRdlK6irEQ1Md0psNvHGdT0TEz7uKwi0KlKNt Xa7+UnslSplhx7dq8UNBO09bZRj4N0TFFTj6SZ99bzXuNdMyh2S2sMsh3jyKwEBruLd4 afMjxk0/a57d5EUzhxsmTnB5ufA8FSZjLvBuxCHdfYq5rdI8jDsuW89utLzN99pDxEkz Fb3J49/BTmw18M5U+LvE5HcTUcCc+soY5UyIHk2weDug2rlQc1VAToGrtHIhNHmg0obd UQB01tRp5SKn0r/k+FP98h+2FHWS4w2Io47SaW5kpiWZj1rsFgaHymHNQDaFfcPOTQSy VT9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date; bh=23R9/SnCVkK3fwgyNcd20lLwdLOWAMKeg3/I51aC7Fc=; fh=AJluUE3g6N21uXjdw41zkQejfJ7db4/tQKroICszysk=; b=hOrUOUtBgfOXJu+Sh9Bwju9b26DmLiO/6MdxNuJmY86CDCwbdlewJrHCHzaWM5Jq3Q T1BzGprlWDCjUbWe8fBMYV345JRoQ3Q9Nya2/cOMWdl2/M2aOtsQNm2TVe3Szq9xvBkW YOpd+Oy/3D6IL4lK5J6mSlbwb1909/KAZcWH8FnUiR/pozayre8HRYY3TR/DAfhq/93S 1O1kJRhs92un4G9O3vI3GAnb097zbt1a/y/XejYQX2Wytlo8lYaDQ99w11oeV5dCvhIb 3tEiRkTHdgyEJSGHb2jwMKggb38SBPxvbfn+xH9LBRXXQbLDNu7+0BysY+Pjej1rhMBA Uz+w== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a1709061cc900b0099e09f0a544si889027ejh.871.2023.08.26.20.57.51; Sat, 26 Aug 2023 20:58:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229617AbjH0COn (ORCPT <rfc822;kiss.andras.p@gmail.com> + 99 others); Sat, 26 Aug 2023 22:14:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbjH0CO2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 26 Aug 2023 22:14:28 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8B48122; Sat, 26 Aug 2023 19:14:26 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from <daniel@makrotopia.org>) id 1qa5I6-0004yC-0s; Sun, 27 Aug 2023 02:14:14 +0000 Date: Sun, 27 Aug 2023 03:13:30 +0100 From: Daniel Golle <daniel@makrotopia.org> To: Qii Wang <qii.wang@mediatek.com>, Andi Shyti <andi.shyti@kernel.org>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: =?utf-8?b?6YOt5bCP5qGl?= <joe@gainstrong.cn> Subject: [PATCH] i2c: mt65xx: allow optional pmic clock Message-ID: <3bf827929a44c17bfb1bf1000b143c02ce26a929.1693102324.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: INBOX X-GMAIL-THRID: 1775353152886911210 X-GMAIL-MSGID: 1775353152886911210 |
Series |
i2c: mt65xx: allow optional pmic clock
|
|
Commit Message
Daniel Golle
Aug. 27, 2023, 2:13 a.m. UTC
Using the I2C host controller on the MT7981 SoC requires 4 clocks to
be enabled. One of them, the pmic clk, is only enabled in case
'mediatek,have-pmic' is also set which has other consequences which
are not desired in this case.
Allow defining a pmic clk even in case the 'mediatek,have-pmic' propterty
is not present and the bus is not used to connect to a pmic, but may
still require to enable the pmic clock.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/i2c/busses/i2c-mt65xx.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
Comments
Il 27/08/23 04:13, Daniel Golle ha scritto: > Using the I2C host controller on the MT7981 SoC requires 4 clocks to > be enabled. One of them, the pmic clk, is only enabled in case > 'mediatek,have-pmic' is also set which has other consequences which > are not desired in this case. > > Allow defining a pmic clk even in case the 'mediatek,have-pmic' propterty > is not present and the bus is not used to connect to a pmic, but may > still require to enable the pmic clock. > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > drivers/i2c/busses/i2c-mt65xx.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c > index 1a9b5a068ef1b..a8b5719c33729 100644 > --- a/drivers/i2c/busses/i2c-mt65xx.c > +++ b/drivers/i2c/busses/i2c-mt65xx.c > @@ -1442,15 +1442,19 @@ static int mtk_i2c_probe(struct platform_device *pdev) > if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk)) > return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk); > > + i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get_optional(&pdev->dev, "pmic"); > + if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) { > + dev_err(&pdev->dev, "cannot get pmic clock\n"); > + return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk); > + } > + > if (i2c->have_pmic) { ...but you're not changing speed_clk if !i2c->have_pmic, I'm not sure that this will work correctly. Perhaps you wanted to also set speed_clk if the clock is present? if (IS_ERR...) { error handling } else if (clk is present) speed_clk = I2C_MT65XX_CLK_PMIC; if (have_pmic && !clk_is_present) error Regards, Angelo > - i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get(&pdev->dev, "pmic"); > - if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) { > + if (!i2c->clocks[I2C_MT65XX_CLK_PMIC].clk) { > dev_err(&pdev->dev, "cannot get pmic clock\n"); > - return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk); > + return -ENODEV; > } > speed_clk = I2C_MT65XX_CLK_PMIC; > } else { > - i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = NULL; > speed_clk = I2C_MT65XX_CLK_MAIN; > } >
On Wed, Sep 13, 2023 at 04:00:53PM +0200, AngeloGioacchino Del Regno wrote: > Il 27/08/23 04:13, Daniel Golle ha scritto: > > Using the I2C host controller on the MT7981 SoC requires 4 clocks to > > be enabled. One of them, the pmic clk, is only enabled in case > > 'mediatek,have-pmic' is also set which has other consequences which > > are not desired in this case. > > > > Allow defining a pmic clk even in case the 'mediatek,have-pmic' propterty > > is not present and the bus is not used to connect to a pmic, but may > > still require to enable the pmic clock. > > > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > --- > > drivers/i2c/busses/i2c-mt65xx.c | 12 ++++++++---- > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c > > index 1a9b5a068ef1b..a8b5719c33729 100644 > > --- a/drivers/i2c/busses/i2c-mt65xx.c > > +++ b/drivers/i2c/busses/i2c-mt65xx.c > > @@ -1442,15 +1442,19 @@ static int mtk_i2c_probe(struct platform_device *pdev) > > if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk)) > > return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk); > > + i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get_optional(&pdev->dev, "pmic"); > > + if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) { > > + dev_err(&pdev->dev, "cannot get pmic clock\n"); > > + return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk); > > + } > > + > > if (i2c->have_pmic) { > > ...but you're not changing speed_clk if !i2c->have_pmic, I'm not sure that > this will work correctly. Perhaps you wanted to also set speed_clk if the > clock is present? No, if I wanted that I could have used the existing 'mediatek,have-pmic' property -- however, all needed e.g. on MT7981 is to make sure the clock is enabled, but still use I2C_MT65XX_CLK_MAIN as speed_clk. > > if (IS_ERR...) { > error handling > } else if (clk is present) > speed_clk = I2C_MT65XX_CLK_PMIC; > > if (have_pmic && !clk_is_present) > error > > Regards, > Angelo > > > - i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get(&pdev->dev, "pmic"); > > - if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) { > > + if (!i2c->clocks[I2C_MT65XX_CLK_PMIC].clk) { > > dev_err(&pdev->dev, "cannot get pmic clock\n"); > > - return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk); > > + return -ENODEV; > > } > > speed_clk = I2C_MT65XX_CLK_PMIC; > > } else { > > - i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = NULL; > > speed_clk = I2C_MT65XX_CLK_MAIN; > > } > >
Il 14/09/23 11:07, Daniel Golle ha scritto: > On Wed, Sep 13, 2023 at 04:00:53PM +0200, AngeloGioacchino Del Regno wrote: >> Il 27/08/23 04:13, Daniel Golle ha scritto: >>> Using the I2C host controller on the MT7981 SoC requires 4 clocks to >>> be enabled. One of them, the pmic clk, is only enabled in case >>> 'mediatek,have-pmic' is also set which has other consequences which >>> are not desired in this case. >>> >>> Allow defining a pmic clk even in case the 'mediatek,have-pmic' propterty >>> is not present and the bus is not used to connect to a pmic, but may >>> still require to enable the pmic clock. >>> >>> Signed-off-by: Daniel Golle <daniel@makrotopia.org> >>> --- >>> drivers/i2c/busses/i2c-mt65xx.c | 12 ++++++++---- >>> 1 file changed, 8 insertions(+), 4 deletions(-) >>> >>> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c >>> index 1a9b5a068ef1b..a8b5719c33729 100644 >>> --- a/drivers/i2c/busses/i2c-mt65xx.c >>> +++ b/drivers/i2c/busses/i2c-mt65xx.c >>> @@ -1442,15 +1442,19 @@ static int mtk_i2c_probe(struct platform_device *pdev) >>> if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk)) >>> return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk); >>> + i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get_optional(&pdev->dev, "pmic"); >>> + if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) { >>> + dev_err(&pdev->dev, "cannot get pmic clock\n"); >>> + return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk); >>> + } >>> + >>> if (i2c->have_pmic) { >> >> ...but you're not changing speed_clk if !i2c->have_pmic, I'm not sure that >> this will work correctly. Perhaps you wanted to also set speed_clk if the >> clock is present? > > No, if I wanted that I could have used the existing 'mediatek,have-pmic' > property -- however, all needed e.g. on MT7981 is to make sure the > clock is enabled, but still use I2C_MT65XX_CLK_MAIN as speed_clk. > Sorry, I've misunderstood the intention and yes, I understand now. Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
On Sun, Aug 27, 2023 at 03:13:30AM +0100, Daniel Golle wrote: > Using the I2C host controller on the MT7981 SoC requires 4 clocks to > be enabled. One of them, the pmic clk, is only enabled in case > 'mediatek,have-pmic' is also set which has other consequences which > are not desired in this case. > > Allow defining a pmic clk even in case the 'mediatek,have-pmic' propterty > is not present and the bus is not used to connect to a pmic, but may > still require to enable the pmic clock. > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> Applied to for-next, thanks!
diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 1a9b5a068ef1b..a8b5719c33729 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -1442,15 +1442,19 @@ static int mtk_i2c_probe(struct platform_device *pdev) if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk)) return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk); + i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get_optional(&pdev->dev, "pmic"); + if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) { + dev_err(&pdev->dev, "cannot get pmic clock\n"); + return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk); + } + if (i2c->have_pmic) { - i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get(&pdev->dev, "pmic"); - if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) { + if (!i2c->clocks[I2C_MT65XX_CLK_PMIC].clk) { dev_err(&pdev->dev, "cannot get pmic clock\n"); - return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk); + return -ENODEV; } speed_clk = I2C_MT65XX_CLK_PMIC; } else { - i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = NULL; speed_clk = I2C_MT65XX_CLK_MAIN; }