From patchwork Sun Aug 27 02:13:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 13366816 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87517C71153 for ; Sun, 27 Aug 2023 02:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=jBP/rLhLs871mswl2dkEkzrBmW9TAQHlRDYswSAXZaA=; b=o0sCJJewsKpJz5 B0zQFL4tz8ChWPSkU6/FRmuvDM+QP4VpdN7WELI6RhVZ3xED/4O+RcLnQ0xlftb8v8WkRztFuX8V+ EecmWzzyHPPBac+9OvsdUyJu5rQkeP9lvXSwEqzC0nxlXV59GwVxaQbSPf0bG9+kOqpfqmv5mnMCD 3fE9R+dMYPMVgNPKheZPxXBR5GKBOk3DM+Q5GKIPr7iC7oi6DyM1ORpUP3IipxhIv92Cc+5GdcYe5 Uhc+V9VOEh7CJDtmJNA7WaFmX1YJM2L3u0P4r04c8lsieZ7kFPPU/ctTQ1hWpw7rAXVDQ5/KbNkmq DmOMbYqHPdBQuSIpdCog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qa5IR-007OrH-0z; Sun, 27 Aug 2023 02:14:35 +0000 Received: from pidgin.makrotopia.org ([185.142.180.65]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qa5IN-007Oqp-0z; Sun, 27 Aug 2023 02:14:33 +0000 Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1qa5I6-0004yC-0s; Sun, 27 Aug 2023 02:14:14 +0000 Date: Sun, 27 Aug 2023 03:13:30 +0100 From: Daniel Golle To: Qii Wang , Andi Shyti , Matthias Brugger , AngeloGioacchino Del Regno , 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?= Subject: [PATCH] i2c: mt65xx: allow optional pmic clock Message-ID: <3bf827929a44c17bfb1bf1000b143c02ce26a929.1693102324.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230826_191431_355601_B90B690B X-CRM114-Status: GOOD ( 15.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Andi Shyti Reviewed-by: AngeloGioacchino Del Regno --- 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) { - 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; }