From patchwork Sun Jul 7 23:13:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunyeal Hong X-Patchwork-Id: 13726096 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 91575C38150 for ; Sun, 7 Jul 2024 23:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:References:Content-Type: Content-Transfer-Encoding:MIME-Version:In-Reply-To:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kiPJQMbtI4tibVPY59mFXWyZ4lmoOE/X8MtEDbo9tak=; b=YnhA/X/2yBTxZj579scIz8VK6s NMr7PCj8jKkcT51Cs/M65zNUhrUtmS0/R0Nl5RQ8qL7MQBqn7VHkhn1EGeXKDD2txmvrGieu9yMdw Wh9IEjjC4x9ny2yNANc8FqHhFU0p+9h3cEBgQ2at/H3FtPN/ErZHg2JtwxuUMugwVxqWyBJNKaX6F gI0dGKVk82rk3HJAXzUEtO2Pw9KnSyZf5Ek8djec6FuOqhy61ZdEV+ih7TjNoAyz9hQRX+4P7E1sT DyWqLtE1jZ9gx0RfXWPTWc/dObHsJlmvLJ85e5mHDH8JXZhXMMO3nNdht9TD9hwwvuttqI9WfkDib tSQuKKZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQb66-00000002PVn-2rzE; Sun, 07 Jul 2024 23:15:10 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQb5q-00000002PSI-1gRW for linux-arm-kernel@lists.infradead.org; Sun, 07 Jul 2024 23:14:56 +0000 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240707231447epoutp027330b4b87f8722117a04fb320dcb99c9~gEU6gGCpF3261632616epoutp02i for ; Sun, 7 Jul 2024 23:14:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240707231447epoutp027330b4b87f8722117a04fb320dcb99c9~gEU6gGCpF3261632616epoutp02i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720394087; bh=kiPJQMbtI4tibVPY59mFXWyZ4lmoOE/X8MtEDbo9tak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BfGKa559T/ulHCuuJxCf3rxK8HzF2fCCsGQx0LQm4iq4Q+UxHH2nUW7EFobbCCYsM rbJxbrevtTRDtU6flDyLnqaruUzF/VP6wf267sNdVrvbF5KCVngCB/R9/xk5Naf7At Os9fGfQrqV/iG3mFPup90cN9Cg8laHoYPmvI9L28= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20240707231446epcas2p15670159116d8cea9bdd0b14e47d5a395~gEU50QTUt0164701647epcas2p1I; Sun, 7 Jul 2024 23:14:46 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.36.70]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4WHNPd6snzz4x9Q6; Sun, 7 Jul 2024 23:14:45 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id FB.35.09485.5612B866; Mon, 8 Jul 2024 08:14:45 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20240707231445epcas2p18815fee7d176f63619d244d836ab64fc~gEU4ygtJU0673306733epcas2p1D; Sun, 7 Jul 2024 23:14:45 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240707231445epsmtrp17c12ab5d6f31c32efb05834043a87d68~gEU4xvzk00845308453epsmtrp10; Sun, 7 Jul 2024 23:14:45 +0000 (GMT) X-AuditID: b6c32a46-19bfa7000000250d-f5-668b2165e872 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 20.B8.18846.4612B866; Mon, 8 Jul 2024 08:14:45 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.60]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240707231444epsmtip1efa3111d7418afcf4c03efe6521ff610~gEU4fVT-g2453524535epsmtip17; Sun, 7 Jul 2024 23:14:44 +0000 (GMT) From: Sunyeal Hong To: Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi , Alim Akhtar , Michael Turquette , Stephen Boyd , Rob Herring , Conor Dooley Cc: linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sunyeal Hong Subject: [PATCH v2 3/4] clk: samsung: clk-pll: Add support for pll_531x Date: Mon, 8 Jul 2024 08:13:30 +0900 Message-ID: <20240707231331.3433340-4-sunyeal.hong@samsung.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240707231331.3433340-1-sunyeal.hong@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLJsWRmVeSWpSXmKPExsWy7bCmhW6qYneawZFuZYsH87axWazZe47J 4vqX56wW84+cY7U4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0xYvHnhz/mWkiK3tLJ3mDE +KApXU9Y/rmX7N9K9/xjS3valViKMxINtZiLihMB0T+UWvcCAAA= X-CMS-MailID: 20240707231445epcas2p18815fee7d176f63619d244d836ab64fc X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240707231445epcas2p18815fee7d176f63619d244d836ab64fc References: <20240707231331.3433340-1-sunyeal.hong@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240707_161455_116445_8EA92892 X-CRM114-Status: GOOD ( 19.15 ) 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 pll531x PLL is used in Exynos Auto v920 SoC for shared pll. pll531x: Integer/fractional PLL with mid frequency FVCO (800 to 3120 MHz) PLL531x FOUT = (MDIV + F/2^32-F[31]) * FIN/(PDIV x 2^SDIV) Signed-off-by: Sunyeal Hong Reviewed-by: Alim Akhtar --- drivers/clk/samsung/clk-pll.c | 45 +++++++++++++++++++++++++++++++++++ drivers/clk/samsung/clk-pll.h | 1 + 2 files changed, 46 insertions(+) diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c index 4be879ab917e..b3bcef074ab7 100644 --- a/drivers/clk/samsung/clk-pll.c +++ b/drivers/clk/samsung/clk-pll.c @@ -1261,6 +1261,48 @@ static const struct clk_ops samsung_pll2650xx_clk_min_ops = { .recalc_rate = samsung_pll2650xx_recalc_rate, }; +/* + * PLL531X Clock Type + */ +/* Maximum lock time can be 500 * PDIV cycles */ +#define PLL531X_LOCK_FACTOR (500) +#define PLL531X_MDIV_MASK (0x3FF) +#define PLL531X_PDIV_MASK (0x3F) +#define PLL531X_SDIV_MASK (0x7) +#define PLL531X_FDIV_MASK (0xFFFF) +#define PLL531X_MDIV_SHIFT (16) +#define PLL531X_PDIV_SHIFT (8) +#define PLL531X_SDIV_SHIFT (0) + +static unsigned long samsung_pll531x_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct samsung_clk_pll *pll = to_clk_pll(hw); + u32 mdiv, pdiv, sdiv, pll_con0, pll_con8; + s32 fdiv; + u64 fout = parent_rate; + + pll_con0 = readl_relaxed(pll->con_reg); + pll_con8 = readl_relaxed(pll->con_reg + 20); + mdiv = (pll_con0 >> PLL531X_MDIV_SHIFT) & PLL531X_MDIV_MASK; + pdiv = (pll_con0 >> PLL531X_PDIV_SHIFT) & PLL531X_PDIV_MASK; + sdiv = (pll_con0 >> PLL531X_SDIV_SHIFT) & PLL531X_SDIV_MASK; + fdiv = (s32)(pll_con8 & PLL531X_FDIV_MASK); + + if (fdiv >> 31) + mdiv--; + + fout *= ((u64)mdiv << 24) + (fdiv >> 8); + do_div(fout, (pdiv << sdiv)); + fout >>= 24; + + return (unsigned long)fout; +} + +static const struct clk_ops samsung_pll531x_clk_ops = { + .recalc_rate = samsung_pll531x_recalc_rate, +}; + static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx, const struct samsung_pll_clock *pll_clk) { @@ -1394,6 +1436,9 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx, else init.ops = &samsung_pll2650xx_clk_ops; break; + case pll_531x: + init.ops = &samsung_pll531x_clk_ops; + break; default: pr_warn("%s: Unknown pll type for pll clk %s\n", __func__, pll_clk->name); diff --git a/drivers/clk/samsung/clk-pll.h b/drivers/clk/samsung/clk-pll.h index ffd3d52c0dec..ce9d6f21f993 100644 --- a/drivers/clk/samsung/clk-pll.h +++ b/drivers/clk/samsung/clk-pll.h @@ -41,6 +41,7 @@ enum samsung_pll_type { pll_0516x, pll_0517x, pll_0518x, + pll_531x, }; #define PLL_RATE(_fin, _m, _p, _s, _k, _ks) \