Skip to content

Commit ae6040c

Browse files
claudiubezneabebarino
authored andcommitted
clk: versaclock3: Prepare for the addition of 5L35023 device
The 5P35023 and 5L35035 Versa 3 clock generator variants are different but the versaclock3 driver could be used with small adjustments. The features that are implemented in driver and differs b/w variants are the PLL2 Fvco and clock sel bit for SE2 clock. Adjust the driver to prepare for the addition of 5L35023 device. Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Link: https://lore.kernel.org/r/20241210170953.2936724-2-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 40384c8 commit ae6040c

File tree

1 file changed

+43
-18
lines changed

1 file changed

+43
-18
lines changed

drivers/clk/clk-versaclock3.c

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@
7878
#define VC3_PLL1_VCO_MIN 300000000UL
7979
#define VC3_PLL1_VCO_MAX 600000000UL
8080

81-
#define VC3_PLL2_VCO_MIN 400000000UL
82-
#define VC3_PLL2_VCO_MAX 1200000000UL
83-
8481
#define VC3_PLL3_VCO_MIN 300000000UL
8582
#define VC3_PLL3_VCO_MAX 800000000UL
8683

@@ -147,9 +144,13 @@ struct vc3_pfd_data {
147144
u8 mdiv2_bitmsk;
148145
};
149146

147+
struct vc3_vco {
148+
unsigned long min;
149+
unsigned long max;
150+
};
151+
150152
struct vc3_pll_data {
151-
unsigned long vco_min;
152-
unsigned long vco_max;
153+
struct vc3_vco vco;
153154
u8 num;
154155
u8 int_div_msb_offs;
155156
u8 int_div_lsb_offs;
@@ -166,12 +167,17 @@ struct vc3_div_data {
166167
struct vc3_hw_data {
167168
struct clk_hw hw;
168169
struct regmap *regmap;
169-
const void *data;
170+
void *data;
170171

171172
u32 div_int;
172173
u32 div_frc;
173174
};
174175

176+
struct vc3_hw_cfg {
177+
struct vc3_vco pll2_vco;
178+
u32 se2_clk_sel_msk;
179+
};
180+
175181
static const struct clk_div_table div1_divs[] = {
176182
{ .val = 0, .div = 1, }, { .val = 1, .div = 4, },
177183
{ .val = 2, .div = 5, }, { .val = 3, .div = 6, },
@@ -386,10 +392,10 @@ static long vc3_pll_round_rate(struct clk_hw *hw, unsigned long rate,
386392
const struct vc3_pll_data *pll = vc3->data;
387393
u64 div_frc;
388394

389-
if (rate < pll->vco_min)
390-
rate = pll->vco_min;
391-
if (rate > pll->vco_max)
392-
rate = pll->vco_max;
395+
if (rate < pll->vco.min)
396+
rate = pll->vco.min;
397+
if (rate > pll->vco.max)
398+
rate = pll->vco.max;
393399

394400
vc3->div_int = rate / *parent_rate;
395401

@@ -680,8 +686,10 @@ static struct vc3_hw_data clk_pll[] = {
680686
.num = VC3_PLL1,
681687
.int_div_msb_offs = VC3_PLL1_LOOP_FILTER_N_DIV_MSB,
682688
.int_div_lsb_offs = VC3_PLL1_VCO_N_DIVIDER,
683-
.vco_min = VC3_PLL1_VCO_MIN,
684-
.vco_max = VC3_PLL1_VCO_MAX
689+
.vco = {
690+
.min = VC3_PLL1_VCO_MIN,
691+
.max = VC3_PLL1_VCO_MAX
692+
}
685693
},
686694
.hw.init = &(struct clk_init_data) {
687695
.name = "pll1",
@@ -698,8 +706,6 @@ static struct vc3_hw_data clk_pll[] = {
698706
.num = VC3_PLL2,
699707
.int_div_msb_offs = VC3_PLL2_FB_INT_DIV_MSB,
700708
.int_div_lsb_offs = VC3_PLL2_FB_INT_DIV_LSB,
701-
.vco_min = VC3_PLL2_VCO_MIN,
702-
.vco_max = VC3_PLL2_VCO_MAX
703709
},
704710
.hw.init = &(struct clk_init_data) {
705711
.name = "pll2",
@@ -716,8 +722,10 @@ static struct vc3_hw_data clk_pll[] = {
716722
.num = VC3_PLL3,
717723
.int_div_msb_offs = VC3_PLL3_LOOP_FILTER_N_DIV_MSB,
718724
.int_div_lsb_offs = VC3_PLL3_N_DIVIDER,
719-
.vco_min = VC3_PLL3_VCO_MIN,
720-
.vco_max = VC3_PLL3_VCO_MAX
725+
.vco = {
726+
.min = VC3_PLL3_VCO_MIN,
727+
.max = VC3_PLL3_VCO_MAX
728+
}
721729
},
722730
.hw.init = &(struct clk_init_data) {
723731
.name = "pll3",
@@ -901,7 +909,6 @@ static struct vc3_hw_data clk_mux[] = {
901909
[VC3_SE2_MUX] = {
902910
.data = &(struct vc3_clk_data) {
903911
.offs = VC3_SE2_CTRL_REG0,
904-
.bitmsk = VC3_SE2_CTRL_REG0_SE2_CLK_SEL
905912
},
906913
.hw.init = &(struct clk_init_data) {
907914
.name = "se2_mux",
@@ -982,6 +989,7 @@ static int vc3_probe(struct i2c_client *client)
982989
{
983990
struct device *dev = &client->dev;
984991
u8 settings[NUM_CONFIG_REGISTERS];
992+
const struct vc3_hw_cfg *data;
985993
struct regmap *regmap;
986994
const char *name;
987995
int ret, i;
@@ -1029,9 +1037,16 @@ static int vc3_probe(struct i2c_client *client)
10291037
clk_pfd[i].hw.init->name);
10301038
}
10311039

1040+
data = i2c_get_match_data(client);
1041+
10321042
/* Register pll's */
10331043
for (i = 0; i < ARRAY_SIZE(clk_pll); i++) {
10341044
clk_pll[i].regmap = regmap;
1045+
if (i == VC3_PLL2) {
1046+
struct vc3_pll_data *pll_data = clk_pll[i].data;
1047+
1048+
pll_data->vco = data->pll2_vco;
1049+
}
10351050
ret = devm_clk_hw_register(dev, &clk_pll[i].hw);
10361051
if (ret)
10371052
return dev_err_probe(dev, ret, "%s failed\n",
@@ -1059,6 +1074,11 @@ static int vc3_probe(struct i2c_client *client)
10591074
/* Register clk muxes */
10601075
for (i = 0; i < ARRAY_SIZE(clk_mux); i++) {
10611076
clk_mux[i].regmap = regmap;
1077+
if (i == VC3_SE2_MUX) {
1078+
struct vc3_clk_data *clk_data = clk_mux[i].data;
1079+
1080+
clk_data->bitmsk = data->se2_clk_sel_msk;
1081+
}
10621082
ret = devm_clk_hw_register(dev, &clk_mux[i].hw);
10631083
if (ret)
10641084
return dev_err_probe(dev, ret, "%s failed\n",
@@ -1108,8 +1128,13 @@ static int vc3_probe(struct i2c_client *client)
11081128
return ret;
11091129
}
11101130

1131+
static const struct vc3_hw_cfg vc3_5p = {
1132+
.pll2_vco = { .min = 400000000UL, .max = 1200000000UL },
1133+
.se2_clk_sel_msk = BIT(6),
1134+
};
1135+
11111136
static const struct of_device_id dev_ids[] = {
1112-
{ .compatible = "renesas,5p35023" },
1137+
{ .compatible = "renesas,5p35023", .data = &vc3_5p },
11131138
{ /* Sentinel */ }
11141139
};
11151140
MODULE_DEVICE_TABLE(of, dev_ids);

0 commit comments

Comments
 (0)