From patchwork Thu Jul 11 01:13:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunyeal Hong X-Patchwork-Id: 13729918 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACF6D79CC for ; Thu, 11 Jul 2024 01:13:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720660411; cv=none; b=JiI9Es3CrJEEby5aNZIjHR0tjgKv2Gpbw9NIq9ytKNWn6P1r8ovECpMcTDxEsJnFj4mSos5+Bo6AC8qvlbXPk/ribercWczHA0M5J6RADaEyrJFYQPhcoJ4iFrmcq8h1n0PgiI0gkodii3rBTvzZo3pM+sKNMGuPOTK9DkPJiVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720660411; c=relaxed/simple; bh=XGSxQ3pZwkEUe2zZU8xieqWWeu7ugX1Kzsyl73kXv1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:MIME-Version: Content-Type:References; b=sVI3SYjRRVQzJp+VF0rG/2iOkz7KnpBxIsV/p6IywJpC5N9IhMoDUfOFAIDYoclmkIhsOwgArZocFejQobNpijDJeTY6zsaQIYUdZGdCh0QT9ksA2QpzewAfQyuI7gVI/sl6CMSxHW5kMDEs8LOLch1NXnNvjgbWA8+Qp1V9yM8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=LGaeq+aS; arc=none smtp.client-ip=203.254.224.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="LGaeq+aS" Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240711011326epoutp03d32b30a70600d412253648d21c77c623~hA4XYb4qp1017810178epoutp03N for ; Thu, 11 Jul 2024 01:13:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240711011326epoutp03d32b30a70600d412253648d21c77c623~hA4XYb4qp1017810178epoutp03N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720660406; bh=EqOR8VNGXlKi9esLGoLJ/pwc0hcA7y72iJKk54dGE1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LGaeq+aStenSE8bAto60GJnroI1xtg8z91bf3gmrf95HUixBGpL4N4DB6j35Hp5YO KxCmG58FoGHKmDVaRWQvXDWxTXnXMueu6VRwFH5w8hPZUu6zUdfz8Ob9D1mH9GEM1A ytJWHKYTL5y/aFO2Qhy6ur+xuht4KaqciQH7zDbQ= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20240711011325epcas2p373bcee920e645985f1f0229af67490cc~hA4W2dGZF1932619326epcas2p3k; Thu, 11 Jul 2024 01:13:25 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.100]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4WKGv90kZ2z4x9Q0; Thu, 11 Jul 2024 01:13:25 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 2E.F6.09806.4B13F866; Thu, 11 Jul 2024 10:13:24 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20240711011324epcas2p1820b1d21b8aae26c6047ee07d23ce8fa~hA4WE5nOk3172531725epcas2p1F; Thu, 11 Jul 2024 01:13:24 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240711011324epsmtrp22ddc9ca951a28f09fb7fbdb3b1e3f080~hA4WEE3Vp0825708257epsmtrp2v; Thu, 11 Jul 2024 01:13:24 +0000 (GMT) X-AuditID: b6c32a47-c6bff7000000264e-ac-668f31b436cb Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id CD.65.29940.4B13F866; Thu, 11 Jul 2024 10:13:24 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.60]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240711011324epsmtip26b42092294c795729ddc6a1983b2472f~hA4VxKQXl0460704607epsmtip2K; Thu, 11 Jul 2024 01:13:24 +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 v3 3/4] clk: samsung: clk-pll: Add support for pll_531x Date: Thu, 11 Jul 2024 10:13:15 +0900 Message-ID: <20240711011316.2713270-4-sunyeal.hong@samsung.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711011316.2713270-1-sunyeal.hong@samsung.com> Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDJsWRmVeSWpSXmKPExsWy7bCmue4Ww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nezpCh06HtT/aWOcS6LdjoeKxp9F/btmpyee0GFYq+rfXJK35w1T04c9e Zg3huXPfyFRbmL/OlS+IaP/349QkJZbijERDLeai4kQAxs+SQPsCAAA= X-CMS-MailID: 20240711011324epcas2p1820b1d21b8aae26c6047ee07d23ce8fa X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240711011324epcas2p1820b1d21b8aae26c6047ee07d23ce8fa References: <20240711011316.2713270-1-sunyeal.hong@samsung.com> 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 | 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) \