From: Manikandan Muralidharan <manikandan.m@microchip.com>
To: Eugen Hristev <eugen.hristev@linaro.org>,
Lukasz Majewski <lukma@denx.de>, <seanga2@gmail.com>,
<sjg@chromium.org>, <mkorpershoek@baylibre.com>,
<nathan.morrison@timesys.com>, <ilias.apalodimas@linaro.org>,
<greg.malysa@timesys.com>, <caleb.connolly@linaro.org>,
<Oliver.Gaskell@analog.com>, <robert.marko@sartura.hr>,
<igor.opaniuk@gmail.com>, <semen.protsenko@linaro.org>,
<william.zhang@broadcom.com>, <nicolas.ferre@microchip.com>,
<u-boot@lists.denx.de>
Cc: <manikandan.m@microchip.com>,
Varshini Rajendran <varshini.rajendran@microchip.com>
Subject: [PATCH v5 2/8] clk: at91: sam9x60-pll: add support for core clock frequency inputs
Date: Thu, 27 Mar 2025 12:36:09 +0530 [thread overview]
Message-ID: <20250327070615.334551-3-manikandan.m@microchip.com> (raw)
In-Reply-To: <20250327070615.334551-1-manikandan.m@microchip.com>
From: Varshini Rajendran <varshini.rajendran@microchip.com>
Add support for different core clock frequency input ranges
for different PLL IDs in the PLL driver and align sam9x60, sama7g5 SOC
platforms.
Signed-off-by: Varshini Rajendran <varshini.rajendran@microchip.com>
---
drivers/clk/at91/clk-sam9x60-pll.c | 17 ++++++++---------
drivers/clk/at91/pmc.h | 1 +
drivers/clk/at91/sam9x60.c | 7 +++++++
drivers/clk/at91/sama7g5.c | 6 ++++++
4 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/drivers/clk/at91/clk-sam9x60-pll.c b/drivers/clk/at91/clk-sam9x60-pll.c
index a30035eb8ce..676ad8294a6 100644
--- a/drivers/clk/at91/clk-sam9x60-pll.c
+++ b/drivers/clk/at91/clk-sam9x60-pll.c
@@ -31,9 +31,6 @@
#define UPLL_DIV 2
#define PLL_MUL_MAX (FIELD_GET(PMC_PLL_CTRL1_MUL_MSK, UINT_MAX) + 1)
-#define FCORE_MIN (600000000)
-#define FCORE_MAX (1200000000)
-
#define PLL_MAX_ID 7
struct sam9x60_pll {
@@ -55,14 +52,15 @@ static inline bool sam9x60_pll_ready(void __iomem *base, int id)
return !!(status & BIT(id));
}
-static long sam9x60_frac_pll_compute_mul_frac(u32 *mul, u32 *frac, ulong rate,
+static long sam9x60_frac_pll_compute_mul_frac(const struct clk_range *core_clk,
+ u32 *mul, u32 *frac, ulong rate,
ulong parent_rate)
{
unsigned long tmprate, remainder;
unsigned long nmul = 0;
unsigned long nfrac = 0;
- if (rate < FCORE_MIN || rate > FCORE_MAX)
+ if (rate < core_clk->min || rate > core_clk->max)
return -ERANGE;
/*
@@ -82,7 +80,7 @@ static long sam9x60_frac_pll_compute_mul_frac(u32 *mul, u32 *frac, ulong rate,
}
/* Check if resulted rate is valid. */
- if (tmprate < FCORE_MIN || tmprate > FCORE_MAX)
+ if (tmprate < core_clk[0].min || tmprate > core_clk[0].max)
return -ERANGE;
*mul = nmul - 1;
@@ -103,8 +101,8 @@ static ulong sam9x60_frac_pll_set_rate(struct clk *clk, ulong rate)
if (!parent_rate)
return 0;
- ret = sam9x60_frac_pll_compute_mul_frac(&nmul, &nfrac, rate,
- parent_rate);
+ ret = sam9x60_frac_pll_compute_mul_frac(pll->characteristics->core_output,
+ &nmul, &nfrac, rate, parent_rate);
if (ret < 0)
return 0;
@@ -163,7 +161,8 @@ static int sam9x60_frac_pll_enable(struct clk *clk)
ulong crate;
crate = sam9x60_frac_pll_get_rate(clk);
- if (crate < FCORE_MIN || crate > FCORE_MAX)
+ if (crate < pll->characteristics->core_output[0].min ||
+ crate > pll->characteristics->core_output[0].max)
return -ERANGE;
pmc_update_bits(base, AT91_PMC_PLL_UPDT, AT91_PMC_PLL_UPDT_ID_MSK,
diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
index ff464522aa0..49134531564 100644
--- a/drivers/clk/at91/pmc.h
+++ b/drivers/clk/at91/pmc.h
@@ -38,6 +38,7 @@ struct clk_pll_characteristics {
struct clk_range input;
int num_output;
const struct clk_range *output;
+ const struct clk_range *core_output;
u16 *icpll;
u8 *out;
u8 upll : 1;
diff --git a/drivers/clk/at91/sam9x60.c b/drivers/clk/at91/sam9x60.c
index b7d64bdbb3d..e04266a2be2 100644
--- a/drivers/clk/at91/sam9x60.c
+++ b/drivers/clk/at91/sam9x60.c
@@ -112,17 +112,24 @@ static const struct clk_range upll_outputs[] = {
{ .min = 300000000, .max = 500000000 },
};
+/* Fractional PLL core output range. */
+static const struct clk_range core_outputs[] = {
+ { .min = 600000000, .max = 1200000000 },
+};
+
/* PLL characteristics. */
static const struct clk_pll_characteristics apll_characteristics = {
.input = { .min = 12000000, .max = 48000000 },
.num_output = ARRAY_SIZE(plla_outputs),
.output = plla_outputs,
+ .core_output = core_outputs,
};
static const struct clk_pll_characteristics upll_characteristics = {
.input = { .min = 12000000, .max = 48000000 },
.num_output = ARRAY_SIZE(upll_outputs),
.output = upll_outputs,
+ .core_output = core_outputs,
.upll = true,
};
diff --git a/drivers/clk/at91/sama7g5.c b/drivers/clk/at91/sama7g5.c
index 63b2c647467..c0e27828b1a 100644
--- a/drivers/clk/at91/sama7g5.c
+++ b/drivers/clk/at91/sama7g5.c
@@ -158,11 +158,17 @@ static const struct clk_range pll_outputs[] = {
{ .min = 2343750, .max = 1200000000 },
};
+/* Fractional PLL core output range. */
+static const struct clk_range core_outputs[] = {
+ { .min = 600000000, .max = 1200000000 },
+};
+
/* PLL characteristics. */
static const struct clk_pll_characteristics pll_characteristics = {
.input = { .min = 12000000, .max = 50000000 },
.num_output = ARRAY_SIZE(pll_outputs),
.output = pll_outputs,
+ .core_output = core_outputs,
};
/* Layout for fractional PLLs. */
--
2.25.1
next prev parent reply other threads:[~2025-03-27 7:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-27 7:06 [PATCH v5 0/8] Add support for sam9x7 SoC and SAM9X75 Curiosity board Manikandan Muralidharan
2025-03-27 7:06 ` [PATCH v5 1/8] dt-bindings: drop at91.h from clock includes Manikandan Muralidharan
2025-03-27 7:06 ` Manikandan Muralidharan [this message]
2025-03-27 7:06 ` [PATCH v5 3/8] clk: at91: sam9x60-pll: add support for HW PLL freq dividers Manikandan Muralidharan
2025-03-27 7:06 ` [PATCH v5 4/8] clk: at91: sam9x7: add pmc driver for sam9x7 SoC family Manikandan Muralidharan
2025-03-27 7:06 ` [PATCH v5 5/8] ARM: at91: Add sam9x7 soc Manikandan Muralidharan
2025-03-27 7:06 ` [PATCH v5 6/8] ARM: dts: at91: sam9x75_curiosity: add tweaks for sam9x75 curiosity board Manikandan Muralidharan
2025-03-27 7:41 ` Eugen Hristev
2025-03-27 8:29 ` Manikandan.M
2025-03-27 7:06 ` [PATCH v5 7/8] board: sam9x75_curiosity: Add support for sam9x75 curiosity Manikandan Muralidharan
2025-03-27 7:06 ` [PATCH v5 8/8] configs: sam9x75_curiosity: Add initial mmc default config Manikandan Muralidharan
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=20250327070615.334551-3-manikandan.m@microchip.com \
--to=manikandan.m@microchip.com \
--cc=Oliver.Gaskell@analog.com \
--cc=caleb.connolly@linaro.org \
--cc=eugen.hristev@linaro.org \
--cc=greg.malysa@timesys.com \
--cc=igor.opaniuk@gmail.com \
--cc=ilias.apalodimas@linaro.org \
--cc=lukma@denx.de \
--cc=mkorpershoek@baylibre.com \
--cc=nathan.morrison@timesys.com \
--cc=nicolas.ferre@microchip.com \
--cc=robert.marko@sartura.hr \
--cc=seanga2@gmail.com \
--cc=semen.protsenko@linaro.org \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
--cc=varshini.rajendran@microchip.com \
--cc=william.zhang@broadcom.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