From: Jesse Taube <mr.bossman075@gmail.com>
To: u-boot@lists.denx.de
Cc: sbabic@denx.de, festevam@gmail.com, festevam@denx.de,
uboot-imx@nxp.com, giulio.benetti@benettiengineering.com,
lukma@denx.de, seanga2@gmail.com, sjg@chromium.org,
jagan@amarulasolutions.com, kever.yang@rock-chips.com,
andre.przywara@arm.com, pbrobinson@gmail.com,
tharvey@gateworks.com, paul.liu@linaro.org,
christianshewitt@gmail.com, Mr.Bossman075@gmail.com,
samuel@sholland.org
Subject: [PATCH v2 4/8] clk: imx: Add i.MXRT11xx pllv3 variant
Date: Fri, 17 Jun 2022 12:42:33 -0400 [thread overview]
Message-ID: <20220617164237.1350241-5-Mr.Bossman075@gmail.com> (raw)
In-Reply-To: <20220617164237.1350241-1-Mr.Bossman075@gmail.com>
The i.MXRT11 series has two new pll types but are variants of existing.
This patch adds the ability to read one of the pll types' frequency
as it can't be changed unlike the generic pll it also has the
division factors swapped.
Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
---
V1 -> V2:
* Change BM_PLL_POWER and BM_PLL_LOCK bit to variable
* Use different lock and power bit for new pll
---
drivers/clk/imx/clk-pllv3.c | 56 +++++++++++++++++++++++++++++++++++--
drivers/clk/imx/clk.h | 1 +
2 files changed, 54 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c
index 077757efcb..fad306aeed 100644
--- a/drivers/clk/imx/clk-pllv3.c
+++ b/drivers/clk/imx/clk-pllv3.c
@@ -21,19 +21,23 @@
#define UBOOT_DM_CLK_IMX_PLLV3_USB "imx_clk_pllv3_usb"
#define UBOOT_DM_CLK_IMX_PLLV3_AV "imx_clk_pllv3_av"
#define UBOOT_DM_CLK_IMX_PLLV3_ENET "imx_clk_pllv3_enet"
+#define UBOOT_DM_CLK_IMX_PLLV3_GENV2 "imx_clk_pllv3_genericv2"
#define PLL_NUM_OFFSET 0x10
#define PLL_DENOM_OFFSET 0x20
#define BM_PLL_POWER (0x1 << 12)
+#define BM_PLL_POWER_V2 (0x1 << 21)
#define BM_PLL_ENABLE (0x1 << 13)
#define BM_PLL_LOCK (0x1 << 31)
+#define BM_PLL_LOCK_V2 (0x1 << 29)
struct clk_pllv3 {
struct clk clk;
void __iomem *base;
u32 power_bit;
bool powerup_set;
+ u32 lock_bit;
u32 enable_bit;
u32 div_mask;
u32 div_shift;
@@ -42,6 +46,30 @@ struct clk_pllv3 {
#define to_clk_pllv3(_clk) container_of(_clk, struct clk_pllv3, clk)
+static ulong clk_pllv3_genericv2_get_rate(struct clk *clk)
+{
+ struct clk_pllv3 *pll = to_clk_pllv3(dev_get_clk_ptr(clk->dev));
+ unsigned long parent_rate = clk_get_parent_rate(clk);
+
+ u32 div = (readl(pll->base) >> pll->div_shift) & pll->div_mask;
+
+ return (div == 0) ? parent_rate * 22 : parent_rate * 20;
+}
+
+static ulong clk_pllv3_genericv2_set_rate(struct clk *clk, ulong rate)
+{
+ struct clk_pllv3 *pll = to_clk_pllv3(clk);
+ unsigned long parent_rate = clk_get_parent_rate(clk);
+
+ u32 div = (readl(pll->base) >> pll->div_shift) & pll->div_mask;
+ u32 val = (div == 0) ? parent_rate * 22 : parent_rate * 20;
+
+ if (rate == val)
+ return 0;
+
+ return -EINVAL;
+}
+
static ulong clk_pllv3_generic_get_rate(struct clk *clk)
{
struct clk_pllv3 *pll = to_clk_pllv3(dev_get_clk_ptr(clk->dev));
@@ -71,7 +99,7 @@ static ulong clk_pllv3_generic_set_rate(struct clk *clk, ulong rate)
writel(val, pll->base);
/* Wait for PLL to lock */
- while (!(readl(pll->base) & BM_PLL_LOCK))
+ while (!(readl(pll->base) & pll->lock_bit))
;
return 0;
@@ -120,6 +148,13 @@ static const struct clk_ops clk_pllv3_generic_ops = {
.set_rate = clk_pllv3_generic_set_rate,
};
+static const struct clk_ops clk_pllv3_genericv2_ops = {
+ .get_rate = clk_pllv3_genericv2_get_rate,
+ .enable = clk_pllv3_generic_enable,
+ .disable = clk_pllv3_generic_disable,
+ .set_rate = clk_pllv3_genericv2_set_rate,
+};
+
static ulong clk_pllv3_sys_get_rate(struct clk *clk)
{
struct clk_pllv3 *pll = to_clk_pllv3(clk);
@@ -153,7 +188,7 @@ static ulong clk_pllv3_sys_set_rate(struct clk *clk, ulong rate)
writel(val, pll->base);
/* Wait for PLL to lock */
- while (!(readl(pll->base) & BM_PLL_LOCK))
+ while (!(readl(pll->base) & pll->lock_bit))
;
return 0;
@@ -221,7 +256,7 @@ static ulong clk_pllv3_av_set_rate(struct clk *clk, ulong rate)
writel(mfd, pll->base + PLL_DENOM_OFFSET);
/* Wait for PLL to lock */
- while (!(readl(pll->base) & BM_PLL_LOCK))
+ while (!(readl(pll->base) & pll->lock_bit))
;
return 0;
@@ -262,6 +297,7 @@ struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
pll->power_bit = BM_PLL_POWER;
pll->enable_bit = BM_PLL_ENABLE;
+ pll->lock_bit = BM_PLL_LOCK;
switch (type) {
case IMX_PLLV3_GENERIC:
@@ -269,6 +305,13 @@ struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
pll->div_shift = 0;
pll->powerup_set = false;
break;
+ case IMX_PLLV3_GENERICV2:
+ pll->power_bit = BM_PLL_POWER_V2;
+ pll->lock_bit = BM_PLL_LOCK_V2;
+ drv_name = UBOOT_DM_CLK_IMX_PLLV3_GENV2;
+ pll->div_shift = 0;
+ pll->powerup_set = false;
+ break;
case IMX_PLLV3_SYS:
drv_name = UBOOT_DM_CLK_IMX_PLLV3_SYS;
pll->div_shift = 0;
@@ -313,6 +356,13 @@ U_BOOT_DRIVER(clk_pllv3_generic) = {
.flags = DM_FLAG_PRE_RELOC,
};
+U_BOOT_DRIVER(clk_pllv3_genericv2) = {
+ .name = UBOOT_DM_CLK_IMX_PLLV3_GENV2,
+ .id = UCLASS_CLK,
+ .ops = &clk_pllv3_genericv2_ops,
+ .flags = DM_FLAG_PRE_RELOC,
+};
+
U_BOOT_DRIVER(clk_pllv3_sys) = {
.name = UBOOT_DM_CLK_IMX_PLLV3_SYS,
.id = UCLASS_CLK,
diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index 0e1eaf03d4..46dee35a67 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -10,6 +10,7 @@
enum imx_pllv3_type {
IMX_PLLV3_GENERIC,
+ IMX_PLLV3_GENERICV2,
IMX_PLLV3_SYS,
IMX_PLLV3_USB,
IMX_PLLV3_USB_VF610,
--
2.36.1
next prev parent reply other threads:[~2022-06-17 16:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-17 16:42 [PATCH v2 0/8] Add support for the i.MXRT1170 Jesse Taube
2022-06-17 16:42 ` [PATCH v2 1/8] imx: imxrt1170-evk: Add support for the NXP i.MXRT1170-EVK Jesse Taube
2022-06-17 16:42 ` [PATCH v2 2/8] ARM: dts: imxrt11170-pinfunc: Add pinctrl binding header Jesse Taube
2022-06-17 16:42 ` [PATCH v2 3/8] dt-bindings: imx: Add clock binding for i.MXRT1170 Jesse Taube
2022-06-17 16:42 ` Jesse Taube [this message]
2022-06-17 16:42 ` [PATCH v2 5/8] clk: imx: Add initial support for i.MXRT1170 clock driver Jesse Taube
2022-06-17 16:42 ` [PATCH v2 6/8] RAM: Add changes for i.MXRT11xx series Jesse Taube
2022-06-17 16:42 ` [PATCH v2 7/8] ARM: dts: imx: add i.MXRT1170-EVK support Jesse Taube
2022-06-17 16:42 ` [PATCH v2 8/8] ARM: imxrt1170_defconfig: Add i.MXRT1170 defconfig Jesse Taube
2022-06-18 0:43 ` Fabio Estevam
2022-06-18 14:32 ` Giulio Benetti
2022-06-21 14:52 ` Fabio Estevam
2022-07-25 13:34 ` [PATCH v2 0/8] Add support for the i.MXRT1170 Stefano Babic
2022-07-26 2:53 ` Jesse Taube
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220617164237.1350241-5-Mr.Bossman075@gmail.com \
--to=mr.bossman075@gmail.com \
--cc=andre.przywara@arm.com \
--cc=christianshewitt@gmail.com \
--cc=festevam@denx.de \
--cc=festevam@gmail.com \
--cc=giulio.benetti@benettiengineering.com \
--cc=jagan@amarulasolutions.com \
--cc=kever.yang@rock-chips.com \
--cc=lukma@denx.de \
--cc=paul.liu@linaro.org \
--cc=pbrobinson@gmail.com \
--cc=samuel@sholland.org \
--cc=sbabic@denx.de \
--cc=seanga2@gmail.com \
--cc=sjg@chromium.org \
--cc=tharvey@gateworks.com \
--cc=u-boot@lists.denx.de \
--cc=uboot-imx@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox