Skip to content

Commit dc0f16c

Browse files
claudiubezneageertu
authored andcommitted
clk: renesas: r8a08g045: Check the source of the CPU PLL settings
On the RZ/G3S SoC, the CPU PLL settings can be set and retrieved through the CPG_PLL1_CLK1 and CPG_PLL1_CLK2 registers. However, these settings are applied only when CPG_PLL1_SETTING.SEL_PLL1 is set to 0. Otherwise, the CPU PLL operates at the default frequency of 1.1 GHz. Hence add support to the PLL driver for returning the 1.1 GHz frequency when the CPU PLL is configured with the default frequency. Fixes: 01eabef ("clk: renesas: rzg2l: Add support for RZ/G3S PLL") Fixes: de60a3e ("clk: renesas: Add minimal boot support for RZ/G3S SoC") Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/20250115142059.1833063-1-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
1 parent 3c437d9 commit dc0f16c

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

drivers/clk/renesas/r9a08g045-cpg.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#define G3S_SEL_SDHI2 SEL_PLL_PACK(G3S_CPG_SDHI_DSEL, 8, 2)
5252

5353
/* PLL 1/4/6 configuration registers macro. */
54-
#define G3S_PLL146_CONF(clk1, clk2) ((clk1) << 22 | (clk2) << 12)
54+
#define G3S_PLL146_CONF(clk1, clk2, setting) ((clk1) << 22 | (clk2) << 12 | (setting))
5555

5656
#define DEF_G3S_MUX(_name, _id, _conf, _parent_names, _mux_flags, _clk_flags) \
5757
DEF_TYPE(_name, _id, CLK_TYPE_MUX, .conf = (_conf), \
@@ -134,7 +134,8 @@ static const struct cpg_core_clk r9a08g045_core_clks[] __initconst = {
134134

135135
/* Internal Core Clocks */
136136
DEF_FIXED(".osc_div1000", CLK_OSC_DIV1000, CLK_EXTAL, 1, 1000),
137-
DEF_G3S_PLL(".pll1", CLK_PLL1, CLK_EXTAL, G3S_PLL146_CONF(0x4, 0x8)),
137+
DEF_G3S_PLL(".pll1", CLK_PLL1, CLK_EXTAL, G3S_PLL146_CONF(0x4, 0x8, 0x100),
138+
1100000000UL),
138139
DEF_FIXED(".pll2", CLK_PLL2, CLK_EXTAL, 200, 3),
139140
DEF_FIXED(".pll3", CLK_PLL3, CLK_EXTAL, 200, 3),
140141
DEF_FIXED(".pll4", CLK_PLL4, CLK_EXTAL, 100, 3),

drivers/clk/renesas/rzg2l-cpg.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#define RZG3S_DIV_M GENMASK(25, 22)
5252
#define RZG3S_DIV_NI GENMASK(21, 13)
5353
#define RZG3S_DIV_NF GENMASK(12, 1)
54+
#define RZG3S_SEL_PLL BIT(0)
5455

5556
#define CLK_ON_R(reg) (reg)
5657
#define CLK_MON_R(reg) (0x180 + (reg))
@@ -60,6 +61,7 @@
6061
#define GET_REG_OFFSET(val) ((val >> 20) & 0xfff)
6162
#define GET_REG_SAMPLL_CLK1(val) ((val >> 22) & 0xfff)
6263
#define GET_REG_SAMPLL_CLK2(val) ((val >> 12) & 0xfff)
64+
#define GET_REG_SAMPLL_SETTING(val) ((val) & 0xfff)
6365

6466
#define CPG_WEN_BIT BIT(16)
6567

@@ -943,6 +945,7 @@ rzg2l_cpg_sipll5_register(const struct cpg_core_clk *core,
943945

944946
struct pll_clk {
945947
struct clk_hw hw;
948+
unsigned long default_rate;
946949
unsigned int conf;
947950
unsigned int type;
948951
void __iomem *base;
@@ -980,12 +983,19 @@ static unsigned long rzg3s_cpg_pll_clk_recalc_rate(struct clk_hw *hw,
980983
{
981984
struct pll_clk *pll_clk = to_pll(hw);
982985
struct rzg2l_cpg_priv *priv = pll_clk->priv;
983-
u32 nir, nfr, mr, pr, val;
986+
u32 nir, nfr, mr, pr, val, setting;
984987
u64 rate;
985988

986989
if (pll_clk->type != CLK_TYPE_G3S_PLL)
987990
return parent_rate;
988991

992+
setting = GET_REG_SAMPLL_SETTING(pll_clk->conf);
993+
if (setting) {
994+
val = readl(priv->base + setting);
995+
if (val & RZG3S_SEL_PLL)
996+
return pll_clk->default_rate;
997+
}
998+
989999
val = readl(priv->base + GET_REG_SAMPLL_CLK1(pll_clk->conf));
9901000

9911001
pr = 1 << FIELD_GET(RZG3S_DIV_P, val);
@@ -1038,6 +1048,7 @@ rzg2l_cpg_pll_clk_register(const struct cpg_core_clk *core,
10381048
pll_clk->base = priv->base;
10391049
pll_clk->priv = priv;
10401050
pll_clk->type = core->type;
1051+
pll_clk->default_rate = core->default_rate;
10411052

10421053
ret = devm_clk_hw_register(dev, &pll_clk->hw);
10431054
if (ret)

drivers/clk/renesas/rzg2l-cpg.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ struct cpg_core_clk {
104104
const struct clk_div_table *dtable;
105105
const u32 *mtable;
106106
const unsigned long invalid_rate;
107-
const unsigned long max_rate;
107+
union {
108+
const unsigned long max_rate;
109+
const unsigned long default_rate;
110+
};
108111
const char * const *parent_names;
109112
notifier_fn_t notifier;
110113
u32 flag;
@@ -146,8 +149,9 @@ enum clk_types {
146149
DEF_TYPE(_name, _id, _type, .parent = _parent)
147150
#define DEF_SAMPLL(_name, _id, _parent, _conf) \
148151
DEF_TYPE(_name, _id, CLK_TYPE_SAM_PLL, .parent = _parent, .conf = _conf)
149-
#define DEF_G3S_PLL(_name, _id, _parent, _conf) \
150-
DEF_TYPE(_name, _id, CLK_TYPE_G3S_PLL, .parent = _parent, .conf = _conf)
152+
#define DEF_G3S_PLL(_name, _id, _parent, _conf, _default_rate) \
153+
DEF_TYPE(_name, _id, CLK_TYPE_G3S_PLL, .parent = _parent, .conf = _conf, \
154+
.default_rate = _default_rate)
151155
#define DEF_INPUT(_name, _id) \
152156
DEF_TYPE(_name, _id, CLK_TYPE_IN)
153157
#define DEF_FIXED(_name, _id, _parent, _mult, _div) \

0 commit comments

Comments
 (0)