From patchwork Tue Jul 30 07:12:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunyeal Hong X-Patchwork-Id: 13746782 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 52F8AC3DA49 for ; Tue, 30 Jul 2024 07:14:12 +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=hoicPC/VzmDis71v8IRNcpF+6JTBo0KNNr3/qD2gd+E=; b=tsILsb6OMhzrrIZG+iXsmwB+5w n8/mGLIxh4oj8kQQQ35iJ68oLr31uZXN4QFc+kD4Igro3UxfjaMzm/V0Li+sv9g0ZRZhMHleei9r+ T/awLfDVU/wlpqsnxjSyAJVg7DA5iYfFQCYY9yK+DYQAPwn5c7mmpknxwuSubZOK1kVA9LWnT9fZK Kb/I3CCEc0ceAo5c3ZwpGhfV6U5XHEfqwP4pwTZQOsZh79AflJtVqTyJq314De2fug1Qs7ouJZkY6 BrOpCMVmflLjBEfS4yeWMeZqA05YffNJlfHlSr/AL0Bi5wjozRf5s2VqHyfJFGVFG/aNEABbRtZHi ExD70lig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYh3W-0000000DxC1-2Atb; Tue, 30 Jul 2024 07:13:58 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYh2B-0000000Dwfs-2nw5 for linux-arm-kernel@lists.infradead.org; Tue, 30 Jul 2024 07:12:39 +0000 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240730071229epoutp045385a675888cfbe2d75656e8b647be70~m7CSZR6l30476604766epoutp042 for ; Tue, 30 Jul 2024 07:12:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240730071229epoutp045385a675888cfbe2d75656e8b647be70~m7CSZR6l30476604766epoutp042 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1722323549; bh=hoicPC/VzmDis71v8IRNcpF+6JTBo0KNNr3/qD2gd+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ptyK6prT9RRAWNv1w7yocRYj6vadTOD4p3VxA+zkvzkVObcakkKRbzeNOJKeNjlII bzyfBRL6BI/alqCfGb/8L0YIXqcxmutoIGyjpDFooF4wZomCPVyDi39t7+L5X/a2gk bRqeSu4nq3LwR0T1pQIrTi7ahyydNdpzEuu/hdQc= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20240730071228epcas2p399eb8d1654447762f3732e533287cff5~m7CRx5qJK0692706927epcas2p3C; Tue, 30 Jul 2024 07:12:28 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.102]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4WY5yh3HGPz4x9Q3; Tue, 30 Jul 2024 07:12:28 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 44.D5.10431.C5298A66; Tue, 30 Jul 2024 16:12:28 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20240730071227epcas2p356635cf71f4d652be2bfa733c8b5848e~m7CRA_RkY0692706927epcas2p3-; Tue, 30 Jul 2024 07:12:27 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240730071227epsmtrp1d8c50f25c45d41a272ddc0de2e5589ae~m7CRAMkSE1008010080epsmtrp1M; Tue, 30 Jul 2024 07:12:27 +0000 (GMT) X-AuditID: b6c32a45-ffffa700000028bf-c4-66a8925cb2cf Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A8.4B.08964.B5298A66; Tue, 30 Jul 2024 16:12:27 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.60]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240730071227epsmtip298183ce0431a94e4d92c1110c1aab7e5~m7CQx-izC0427904279epsmtip2V; Tue, 30 Jul 2024 07:12:27 +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 v5 3/4] clk: samsung: clk-pll: Add support for pll_531x Date: Tue, 30 Jul 2024 16:12:20 +0900 Message-ID: <20240730071221.2590284-4-sunyeal.hong@samsung.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730071221.2590284-1-sunyeal.hong@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFJsWRmVeSWpSXmKPExsWy7bCmmW7MpBVpBosOi1g8mLeNzWLN3nNM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PzdC4J rWTt7ed2sM0JqVb6+97bYv25o6+Zkk/+axdi1qq8LvOhkz/ErkZyUkHz3p/GIbqirL+zVn4P +9N2cd65F++YZh7qkajmMOB6r8RSnJFoqMVcVJwIAKHcaTb7AgAA X-CMS-MailID: 20240730071227epcas2p356635cf71f4d652be2bfa733c8b5848e X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240730071227epcas2p356635cf71f4d652be2bfa733c8b5848e References: <20240730071221.2590284-1-sunyeal.hong@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240730_001236_250690_64B5939E X-CRM114-Status: GOOD ( 18.78 ) 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 x FIN)/(PDIV x 2^SDIV) for integer PLL FOUT = (MDIV + F/2^32-F[31]) x FIN/(PDIV x 2^SDIV) for fractional PLL Signed-off-by: Sunyeal Hong Reviewed-by: Alim Akhtar --- drivers/clk/samsung/clk-pll.c | 44 +++++++++++++++++++++++++++++++++++ drivers/clk/samsung/clk-pll.h | 1 + 2 files changed, 45 insertions(+) diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c index 4be879ab917e..a6c81075417a 100644 --- a/drivers/clk/samsung/clk-pll.c +++ b/drivers/clk/samsung/clk-pll.c @@ -1261,6 +1261,47 @@ 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 (0xFFFFFFFF) +#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 pdiv, sdiv, fdiv, pll_con0, pll_con8; + u64 mdiv, 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 = (pll_con8 & PLL531X_FDIV_MASK); + + if (fdiv >> 31) + mdiv--; + + fout *= (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 +1435,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) \