From: Jesse Taube <mr.bossman075@gmail.com>
To: linux-imx@nxp.com
Cc: robh+dt@kernel.org, mturquette@baylibre.com, sboyd@kernel.org,
shawnguo@kernel.org, s.hauer@pengutronix.de,
kernel@pengutronix.de, festevam@gmail.com, aisheng.dong@nxp.com,
stefan@agner.ch, linus.walleij@linaro.org,
daniel.lezcano@linaro.org, tglx@linutronix.de, arnd@arndb.de,
olof@lixom.net, soc@kernel.org, linux@armlinux.org.uk,
abel.vesa@nxp.com, dev@lynxeye.de, marcel.ziswiler@toradex.com,
tharvey@gateworks.com, leoyang.li@nxp.com,
sebastian.reichel@collabora.com, cniedermaier@dh-electronics.com,
Mr.Bossman075@gmail.com, clin@suse.com,
giulio.benetti@benettiengineering.com,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-gpio@vger.kernel.org
Subject: [PATCH v2 09/15] ARM: clk: imx: Update pllv3 to support i.MXRT1170
Date: Thu, 28 Apr 2022 17:48:32 -0400 [thread overview]
Message-ID: <20220428214838.1040278-10-Mr.Bossman075@gmail.com> (raw)
In-Reply-To: <20220428214838.1040278-1-Mr.Bossman075@gmail.com>
The i.MXRT1170 has a pll that has the multiplier bits inverted and
cannot be changed add IMX_PLLV3_GENERICV2.
The i.MXRT1170 also has the lock bit moved as well as the
power bit inverted the power bit also is in different locations on each
pll control register.
Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
---
V1 -> V2:
- Nothing done
---
drivers/clk/imx/clk-pllv3.c | 57 +++++++++++++++++++++++++++++++++++--
drivers/clk/imx/clk.h | 4 +++
2 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c
index 20ee9611ba6e..a1dbc3a2e280 100644
--- a/drivers/clk/imx/clk-pllv3.c
+++ b/drivers/clk/imx/clk-pllv3.c
@@ -23,6 +23,7 @@
#define BM_PLL_POWER (0x1 << 12)
#define BM_PLL_LOCK (0x1 << 31)
+#define BM_PLL_LOCK_V2 (0x1 << 29)
#define IMX7_ENET_PLL_POWER (0x1 << 5)
#define IMX7_DDR_PLL_POWER (0x1 << 20)
@@ -34,6 +35,7 @@
* @base: base address of PLL registers
* @power_bit: pll power bit mask
* @powerup_set: set power_bit to power up the PLL
+ * @lock_bit: pll lock bit mask
* @div_mask: mask of divider bits
* @div_shift: shift of divider bits
* @ref_clock: reference clock rate
@@ -48,6 +50,7 @@ struct clk_pllv3 {
void __iomem *base;
u32 power_bit;
bool powerup_set;
+ u32 lock_bit;
u32 div_mask;
u32 div_shift;
unsigned long ref_clock;
@@ -65,7 +68,7 @@ static int clk_pllv3_wait_lock(struct clk_pllv3 *pll)
if ((pll->powerup_set && !val) || (!pll->powerup_set && val))
return 0;
- return readl_relaxed_poll_timeout(pll->base, val, val & BM_PLL_LOCK,
+ return readl_relaxed_poll_timeout(pll->base, val, val & pll->lock_bit,
500, PLL_LOCK_TIMEOUT);
}
@@ -101,7 +104,7 @@ static int clk_pllv3_is_prepared(struct clk_hw *hw)
{
struct clk_pllv3 *pll = to_clk_pllv3(hw);
- if (readl_relaxed(pll->base) & BM_PLL_LOCK)
+ if (readl_relaxed(pll->base) & pll->lock_bit)
return 1;
return 0;
@@ -155,6 +158,39 @@ static const struct clk_ops clk_pllv3_ops = {
.set_rate = clk_pllv3_set_rate,
};
+static int clk_pllv3_genericv2_set_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long parent_rate)
+{
+ struct clk_pllv3 *pll = to_clk_pllv3(hw);
+ u32 val, div;
+
+ div = (readl_relaxed(pll->base) >> pll->div_shift) & pll->div_mask;
+ val = (div == 0) ? parent_rate * 22 : parent_rate * 20;
+
+ if (rate == val)
+ return 0;
+
+ return -EINVAL;
+}
+
+static unsigned long clk_pllv3_genericv2_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+ struct clk_pllv3 *pll = to_clk_pllv3(hw);
+ u32 div = (readl_relaxed(pll->base) >> pll->div_shift) & pll->div_mask;
+
+ return (div == 0) ? parent_rate * 22 : parent_rate * 20;
+}
+
+static const struct clk_ops clk_pllv3_genericv2_ops = {
+ .prepare = clk_pllv3_prepare,
+ .unprepare = clk_pllv3_unprepare,
+ .is_prepared = clk_pllv3_is_prepared,
+ .recalc_rate = clk_pllv3_genericv2_recalc_rate,
+ .round_rate = clk_pllv3_round_rate,
+ .set_rate = clk_pllv3_genericv2_set_rate,
+};
+
static unsigned long clk_pllv3_sys_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
@@ -407,6 +443,13 @@ static const struct clk_ops clk_pllv3_enet_ops = {
.recalc_rate = clk_pllv3_enet_recalc_rate,
};
+void imx_clk_hw_pll3_powerbit(struct clk_hw *hw, u8 shift)
+{
+ struct clk_pllv3 *pll = to_clk_pllv3(hw);
+
+ pll->power_bit = shift;
+}
+
struct clk_hw *imx_clk_hw_pllv3(enum imx_pllv3_type type, const char *name,
const char *parent_name, void __iomem *base,
u32 div_mask)
@@ -422,10 +465,20 @@ struct clk_hw *imx_clk_hw_pllv3(enum imx_pllv3_type type, const char *name,
return ERR_PTR(-ENOMEM);
pll->power_bit = BM_PLL_POWER;
+ pll->lock_bit = BM_PLL_LOCK;
pll->num_offset = PLL_NUM_OFFSET;
pll->denom_offset = PLL_DENOM_OFFSET;
switch (type) {
+ case IMX_PLLV3_GENERICV2:
+ pll->lock_bit = BM_PLL_LOCK_V2;
+ pll->powerup_set = true;
+ ops = &clk_pllv3_genericv2_ops;
+ break;
+ case IMX_PLLV3_SYSV2:
+ pll->lock_bit = BM_PLL_LOCK_V2;
+ pll->powerup_set = true;
+ fallthrough;
case IMX_PLLV3_SYS:
ops = &clk_pllv3_sys_ops;
break;
diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index 7d220a01de1f..e70e985840a4 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -220,6 +220,8 @@ struct clk_hw *imx_clk_hw_sscg_pll(const char *name,
enum imx_pllv3_type {
IMX_PLLV3_GENERIC,
+ IMX_PLLV3_GENERICV2,
+ IMX_PLLV3_SYSV2,
IMX_PLLV3_SYS,
IMX_PLLV3_USB,
IMX_PLLV3_USB_VF610,
@@ -231,6 +233,8 @@ enum imx_pllv3_type {
IMX_PLLV3_AV_IMX7,
};
+void imx_clk_hw_pll3_powerbit(struct clk_hw *hw, u8 shift);
+
struct clk_hw *imx_clk_hw_pllv3(enum imx_pllv3_type type, const char *name,
const char *parent_name, void __iomem *base, u32 div_mask);
--
2.35.1
next prev parent reply other threads:[~2022-04-28 21:49 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-28 21:48 [PATCH v2 00/15] Add support for the i.MXRT1170-evk Jesse Taube
2022-04-28 21:48 ` [PATCH v2 01/15] dt-bindings: arm: imx: Add i.MXRT compatible Documentation Jesse Taube
2022-04-29 22:37 ` Rob Herring
2022-04-28 21:48 ` [PATCH v2 02/15] dt-bindings: timer: gpt: " Jesse Taube
2022-04-28 21:48 ` [PATCH v2 03/15] dt-bindings: gpio: fsl-imx-gpio: Add i.MXRT compatibles Jesse Taube
2022-05-03 21:42 ` Rob Herring
2022-04-28 21:48 ` [PATCH v2 04/15] dt-bindings: mmc: fsl-imx-esdhc: add i.MXRT1170 compatible Jesse Taube
2022-04-29 22:39 ` Rob Herring
2022-04-28 21:48 ` [PATCH v2 05/15] dt-bindings: serial: fsl-lpuart: " Jesse Taube
2022-04-29 22:40 ` Rob Herring
2022-04-28 21:48 ` [PATCH v2 06/15] dt-bindings: pinctrl: add i.MXRT1170 pinctrl Documentation Jesse Taube
2022-05-03 21:43 ` Rob Herring
2022-04-28 21:48 ` [PATCH v2 07/15] dt-bindings: clock: imx: Add documentation for i.MXRT1170 clock Jesse Taube
2022-04-29 15:53 ` Rob Herring
2022-04-28 21:48 ` [PATCH v2 08/15] ARM: mach-imx: Add support for i.MXRT1170 Jesse Taube
2022-04-28 21:48 ` Jesse Taube [this message]
2022-05-02 9:19 ` [PATCH v2 09/15] ARM: clk: imx: Update pllv3 to support i.MXRT1170 Abel Vesa
2022-04-28 21:48 ` [PATCH v2 10/15] dt-bindings: imx: Add clock binding for i.MXRT1170 Jesse Taube
2022-05-03 21:46 ` Rob Herring
2022-04-28 21:48 ` [PATCH v2 11/15] clk: imx: Add initial support for i.MXRT1170 clock driver Jesse Taube
2022-05-02 9:27 ` Abel Vesa
2022-04-28 21:48 ` [PATCH v2 12/15] pinctrl: freescale: Add i.MXRT1170 pinctrl driver support Jesse Taube
2022-05-04 21:38 ` Linus Walleij
2022-05-05 11:23 ` Jesse Taube
2022-05-05 14:48 ` Linus Walleij
2022-05-09 11:12 ` Aisheng Dong
2022-04-28 21:48 ` [PATCH v2 13/15] ARM: dts: imxrt1170-pinfunc: Add pinctrl binding header Jesse Taube
2022-05-03 21:47 ` Rob Herring
2022-04-28 21:48 ` [PATCH v2 14/15] ARM: dts: imx: Add i.MXRT1170-EVK support Jesse Taube
2022-04-28 21:48 ` [PATCH v2 15/15] ARM: imxrt_defconfig: Add i.MXRT1170 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=20220428214838.1040278-10-Mr.Bossman075@gmail.com \
--to=mr.bossman075@gmail.com \
--cc=abel.vesa@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=arnd@arndb.de \
--cc=clin@suse.com \
--cc=cniedermaier@dh-electronics.com \
--cc=daniel.lezcano@linaro.org \
--cc=dev@lynxeye.de \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=giulio.benetti@benettiengineering.com \
--cc=kernel@pengutronix.de \
--cc=leoyang.li@nxp.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=marcel.ziswiler@toradex.com \
--cc=mturquette@baylibre.com \
--cc=olof@lixom.net \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=sebastian.reichel@collabora.com \
--cc=shawnguo@kernel.org \
--cc=soc@kernel.org \
--cc=stefan@agner.ch \
--cc=tglx@linutronix.de \
--cc=tharvey@gateworks.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;
as well as URLs for NNTP newsgroup(s).