Skip to content

Commit 9edc5c2

Browse files
committed
clk: renesas: rcar-gen4: Clarify custom PLL clock support
The custom clock driver that models the PLL clocks on R-Car Gen4 assumes the integer and fractional[*] multiplication field sizes as used on R-Car V4H and V4M, representing a fractional 8.25 number. Rename the related definitions, functions, and structures to clarify this, and to prepare for the advent of support for the different field sizes on R-Car S4-8. [*] The fractional part is not yet supported. Signed-off-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Yoshihiro Shimoda <[email protected]> Link: https://lore.kernel.org/2ce9f9c75bfb6312129d416672f9691bbd11c0e7.1721648548.git.geert+renesas@glider.be
1 parent 4897930 commit 9edc5c2

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

drivers/clk/renesas/rcar-gen4-cpg.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ static u32 cpg_mode __initdata;
4545
#define CPG_PLL6CR1 0x8d8
4646

4747
#define CPG_PLLxCR0_KICK BIT(31)
48-
#define CPG_PLLxCR0_NI GENMASK(27, 20) /* Integer mult. factor */
4948
#define CPG_PLLxCR0_SSMODE GENMASK(18, 16) /* PLL mode */
5049
#define CPG_PLLxCR0_SSMODE_FM BIT(18) /* Fractional Multiplication */
5150
#define CPG_PLLxCR0_SSMODE_DITH BIT(17) /* Frequency Dithering */
5251
#define CPG_PLLxCR0_SSMODE_CENT BIT(16) /* Center (vs. Down) Spread Dithering */
5352
#define CPG_PLLxCR0_SSFREQ GENMASK(14, 8) /* SSCG Modulation Frequency */
5453
#define CPG_PLLxCR0_SSDEPT GENMASK(6, 0) /* SSCG Modulation Depth */
5554

55+
/* Fractional 8.25 PLL */
56+
#define CPG_PLLxCR0_NI8 GENMASK(27, 20) /* Integer mult. factor */
57+
5658
/* PLL Clocks */
5759
struct cpg_pll_clk {
5860
struct clk_hw hw;
@@ -63,19 +65,19 @@ struct cpg_pll_clk {
6365

6466
#define to_pll_clk(_hw) container_of(_hw, struct cpg_pll_clk, hw)
6567

66-
static unsigned long cpg_pll_clk_recalc_rate(struct clk_hw *hw,
67-
unsigned long parent_rate)
68+
static unsigned long cpg_pll_8_25_clk_recalc_rate(struct clk_hw *hw,
69+
unsigned long parent_rate)
6870
{
6971
struct cpg_pll_clk *pll_clk = to_pll_clk(hw);
7072
unsigned int mult;
7173

72-
mult = FIELD_GET(CPG_PLLxCR0_NI, readl(pll_clk->pllcr0_reg)) + 1;
74+
mult = FIELD_GET(CPG_PLLxCR0_NI8, readl(pll_clk->pllcr0_reg)) + 1;
7375

7476
return parent_rate * mult * 2;
7577
}
7678

77-
static int cpg_pll_clk_determine_rate(struct clk_hw *hw,
78-
struct clk_rate_request *req)
79+
static int cpg_pll_8_25_clk_determine_rate(struct clk_hw *hw,
80+
struct clk_rate_request *req)
7981
{
8082
unsigned int min_mult, max_mult, mult;
8183
unsigned long prate;
@@ -93,8 +95,8 @@ static int cpg_pll_clk_determine_rate(struct clk_hw *hw,
9395
return 0;
9496
}
9597

96-
static int cpg_pll_clk_set_rate(struct clk_hw *hw, unsigned long rate,
97-
unsigned long parent_rate)
98+
static int cpg_pll_8_25_clk_set_rate(struct clk_hw *hw, unsigned long rate,
99+
unsigned long parent_rate)
98100
{
99101
struct cpg_pll_clk *pll_clk = to_pll_clk(hw);
100102
unsigned int mult;
@@ -106,8 +108,8 @@ static int cpg_pll_clk_set_rate(struct clk_hw *hw, unsigned long rate,
106108
if (readl(pll_clk->pllcr0_reg) & CPG_PLLxCR0_KICK)
107109
return -EBUSY;
108110

109-
cpg_reg_modify(pll_clk->pllcr0_reg, CPG_PLLxCR0_NI,
110-
FIELD_PREP(CPG_PLLxCR0_NI, mult - 1));
111+
cpg_reg_modify(pll_clk->pllcr0_reg, CPG_PLLxCR0_NI8,
112+
FIELD_PREP(CPG_PLLxCR0_NI8, mult - 1));
111113

112114
/*
113115
* Set KICK bit in PLLxCR0 to update hardware setting and wait for
@@ -128,10 +130,10 @@ static int cpg_pll_clk_set_rate(struct clk_hw *hw, unsigned long rate,
128130
val & pll_clk->pllecr_pllst_mask, 0, 1000);
129131
}
130132

131-
static const struct clk_ops cpg_pll_clk_ops = {
132-
.recalc_rate = cpg_pll_clk_recalc_rate,
133-
.determine_rate = cpg_pll_clk_determine_rate,
134-
.set_rate = cpg_pll_clk_set_rate,
133+
static const struct clk_ops cpg_pll_v8_25_clk_ops = {
134+
.recalc_rate = cpg_pll_8_25_clk_recalc_rate,
135+
.determine_rate = cpg_pll_8_25_clk_determine_rate,
136+
.set_rate = cpg_pll_8_25_clk_set_rate,
135137
};
136138

137139
static struct clk * __init cpg_pll_clk_register(const char *name,
@@ -151,7 +153,7 @@ static struct clk * __init cpg_pll_clk_register(const char *name,
151153
return ERR_PTR(-ENOMEM);
152154

153155
init.name = name;
154-
init.ops = &cpg_pll_clk_ops;
156+
init.ops = &cpg_pll_v8_25_clk_ops;
155157
init.parent_names = &parent_name;
156158
init.num_parents = 1;
157159

0 commit comments

Comments
 (0)