Skip to content

Commit 0b4ff5b

Browse files
committed
Merge tag 'sunxi-clk-for-6.17' of https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux into clk-allwinner
Pull Allwinner clk driver updates from Chen-Yu Tsai: - Add Allwinner A523's missing PPU0 reset (both DT binding and driver) The binding change is shared with the soc tree. - Fix Allwinner V3s DE clock mux field width - Stop passing rate change requests to parent for Allwinner V3s DE clock - Force and lock Allwinner V3s DE and TCON clocks to the same parent, the video PLL * tag 'sunxi-clk-for-6.17' of https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux: clk: sunxi-ng: ccu_nm: convert from round_rate() to determine_rate() clk: sunxi-ng: ccu_nkmp: convert from round_rate() to determine_rate() clk: sunxi-ng: ccu_nk: convert from round_rate() to determine_rate() clk: sunxi-ng: ccu_gate: convert from round_rate() to determine_rate() clk: sunxi-ng: v3s: Assign the de and tcon clocks to the video pll clk: sunxi-ng: v3s: Fix de clock definition clk: sunxi-ng: sun55i-a523-r-ccu: Add missing PPU0 reset dt-bindings: reset: sun55i-a523-r-ccu: Add missing PPU0 reset
2 parents 19272b3 + 80395c3 commit 0b4ff5b

File tree

7 files changed

+70
-48
lines changed

7 files changed

+70
-48
lines changed

drivers/clk/sunxi-ng/ccu-sun55i-a523-r.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ static struct ccu_reset_map sun55i_a523_r_ccu_resets[] = {
204204
[RST_BUS_R_IR_RX] = { 0x1cc, BIT(16) },
205205
[RST_BUS_R_RTC] = { 0x20c, BIT(16) },
206206
[RST_BUS_R_CPUCFG] = { 0x22c, BIT(16) },
207+
[RST_BUS_R_PPU0] = { 0x1ac, BIT(16) },
207208
};
208209

209210
static const struct sunxi_ccu_desc sun55i_a523_r_ccu_desc = {

drivers/clk/sunxi-ng/ccu-sun8i-v3s.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,13 @@ static SUNXI_CCU_GATE(dram_ohci_clk, "dram-ohci", "dram",
347347

348348
static const char * const de_parents[] = { "pll-video", "pll-periph0" };
349349
static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents,
350-
0x104, 0, 4, 24, 2, BIT(31),
351-
CLK_SET_RATE_PARENT);
350+
0x104, 0, 4, 24, 3, BIT(31),
351+
CLK_SET_RATE_NO_REPARENT);
352352

353353
static const char * const tcon_parents[] = { "pll-video" };
354354
static SUNXI_CCU_M_WITH_MUX_GATE(tcon_clk, "tcon", tcon_parents,
355-
0x118, 0, 4, 24, 3, BIT(31), 0);
355+
0x118, 0, 4, 24, 3, BIT(31),
356+
CLK_SET_RATE_NO_REPARENT);
356357

357358
static SUNXI_CCU_GATE(csi_misc_clk, "csi-misc", "osc24M",
358359
0x130, BIT(31), 0);
@@ -754,6 +755,21 @@ static int sun8i_v3s_ccu_probe(struct platform_device *pdev)
754755
val &= ~GENMASK(19, 16);
755756
writel(val, reg + SUN8I_V3S_PLL_AUDIO_REG);
756757

758+
/*
759+
* Assign the DE and TCON clock to the video PLL. Both clocks need to
760+
* have the same parent for the units to work together.
761+
*/
762+
763+
val = readl(reg + de_clk.common.reg);
764+
val &= ~GENMASK(de_clk.mux.shift + de_clk.mux.width - 1,
765+
de_clk.mux.shift);
766+
writel(val, reg + de_clk.common.reg);
767+
768+
val = readl(reg + tcon_clk.common.reg);
769+
val &= ~GENMASK(tcon_clk.mux.shift + tcon_clk.mux.width - 1,
770+
tcon_clk.mux.shift);
771+
writel(val, reg + tcon_clk.common.reg);
772+
757773
return devm_sunxi_ccu_probe(&pdev->dev, reg, desc);
758774
}
759775

drivers/clk/sunxi-ng/ccu_gate.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ static unsigned long ccu_gate_recalc_rate(struct clk_hw *hw,
9191
return rate;
9292
}
9393

94-
static long ccu_gate_round_rate(struct clk_hw *hw, unsigned long rate,
95-
unsigned long *prate)
94+
static int ccu_gate_determine_rate(struct clk_hw *hw,
95+
struct clk_rate_request *req)
9696
{
9797
struct ccu_gate *cg = hw_to_ccu_gate(hw);
9898
int div = 1;
@@ -101,14 +101,16 @@ static long ccu_gate_round_rate(struct clk_hw *hw, unsigned long rate,
101101
div = cg->common.prediv;
102102

103103
if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) {
104-
unsigned long best_parent = rate;
104+
unsigned long best_parent = req->rate;
105105

106106
if (cg->common.features & CCU_FEATURE_ALL_PREDIV)
107107
best_parent *= div;
108-
*prate = clk_hw_round_rate(clk_hw_get_parent(hw), best_parent);
108+
req->best_parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw), best_parent);
109109
}
110110

111-
return *prate / div;
111+
req->rate = req->best_parent_rate / div;
112+
113+
return 0;
112114
}
113115

114116
static int ccu_gate_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -127,7 +129,7 @@ const struct clk_ops ccu_gate_ops = {
127129
.disable = ccu_gate_disable,
128130
.enable = ccu_gate_enable,
129131
.is_enabled = ccu_gate_is_enabled,
130-
.round_rate = ccu_gate_round_rate,
132+
.determine_rate = ccu_gate_determine_rate,
131133
.set_rate = ccu_gate_set_rate,
132134
.recalc_rate = ccu_gate_recalc_rate,
133135
};

drivers/clk/sunxi-ng/ccu_nk.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,26 @@ static unsigned long ccu_nk_recalc_rate(struct clk_hw *hw,
9292
return rate;
9393
}
9494

95-
static long ccu_nk_round_rate(struct clk_hw *hw, unsigned long rate,
96-
unsigned long *parent_rate)
95+
static int ccu_nk_determine_rate(struct clk_hw *hw,
96+
struct clk_rate_request *req)
9797
{
9898
struct ccu_nk *nk = hw_to_ccu_nk(hw);
9999
struct _ccu_nk _nk;
100100

101101
if (nk->common.features & CCU_FEATURE_FIXED_POSTDIV)
102-
rate *= nk->fixed_post_div;
102+
req->rate *= nk->fixed_post_div;
103103

104104
_nk.min_n = nk->n.min ?: 1;
105105
_nk.max_n = nk->n.max ?: 1 << nk->n.width;
106106
_nk.min_k = nk->k.min ?: 1;
107107
_nk.max_k = nk->k.max ?: 1 << nk->k.width;
108108

109-
rate = ccu_nk_find_best(*parent_rate, rate, &_nk);
109+
req->rate = ccu_nk_find_best(req->best_parent_rate, req->rate, &_nk);
110110

111111
if (nk->common.features & CCU_FEATURE_FIXED_POSTDIV)
112-
rate = rate / nk->fixed_post_div;
112+
req->rate = req->rate / nk->fixed_post_div;
113113

114-
return rate;
114+
return 0;
115115
}
116116

117117
static int ccu_nk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -155,7 +155,7 @@ const struct clk_ops ccu_nk_ops = {
155155
.is_enabled = ccu_nk_is_enabled,
156156

157157
.recalc_rate = ccu_nk_recalc_rate,
158-
.round_rate = ccu_nk_round_rate,
158+
.determine_rate = ccu_nk_determine_rate,
159159
.set_rate = ccu_nk_set_rate,
160160
};
161161
EXPORT_SYMBOL_NS_GPL(ccu_nk_ops, "SUNXI_CCU");

drivers/clk/sunxi-ng/ccu_nkmp.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,20 @@ static unsigned long ccu_nkmp_recalc_rate(struct clk_hw *hw,
127127
return rate;
128128
}
129129

130-
static long ccu_nkmp_round_rate(struct clk_hw *hw, unsigned long rate,
131-
unsigned long *parent_rate)
130+
static int ccu_nkmp_determine_rate(struct clk_hw *hw,
131+
struct clk_rate_request *req)
132132
{
133133
struct ccu_nkmp *nkmp = hw_to_ccu_nkmp(hw);
134134
struct _ccu_nkmp _nkmp;
135135

136136
if (nkmp->common.features & CCU_FEATURE_FIXED_POSTDIV)
137-
rate *= nkmp->fixed_post_div;
137+
req->rate *= nkmp->fixed_post_div;
138138

139-
if (nkmp->max_rate && rate > nkmp->max_rate) {
140-
rate = nkmp->max_rate;
139+
if (nkmp->max_rate && req->rate > nkmp->max_rate) {
140+
req->rate = nkmp->max_rate;
141141
if (nkmp->common.features & CCU_FEATURE_FIXED_POSTDIV)
142-
rate /= nkmp->fixed_post_div;
143-
return rate;
142+
req->rate /= nkmp->fixed_post_div;
143+
return 0;
144144
}
145145

146146
_nkmp.min_n = nkmp->n.min ?: 1;
@@ -152,12 +152,13 @@ static long ccu_nkmp_round_rate(struct clk_hw *hw, unsigned long rate,
152152
_nkmp.min_p = 1;
153153
_nkmp.max_p = nkmp->p.max ?: 1 << ((1 << nkmp->p.width) - 1);
154154

155-
rate = ccu_nkmp_find_best(*parent_rate, rate, &_nkmp);
155+
req->rate = ccu_nkmp_find_best(req->best_parent_rate, req->rate,
156+
&_nkmp);
156157

157158
if (nkmp->common.features & CCU_FEATURE_FIXED_POSTDIV)
158-
rate = rate / nkmp->fixed_post_div;
159+
req->rate = req->rate / nkmp->fixed_post_div;
159160

160-
return rate;
161+
return 0;
161162
}
162163

163164
static int ccu_nkmp_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -227,7 +228,7 @@ const struct clk_ops ccu_nkmp_ops = {
227228
.is_enabled = ccu_nkmp_is_enabled,
228229

229230
.recalc_rate = ccu_nkmp_recalc_rate,
230-
.round_rate = ccu_nkmp_round_rate,
231+
.determine_rate = ccu_nkmp_determine_rate,
231232
.set_rate = ccu_nkmp_set_rate,
232233
};
233234
EXPORT_SYMBOL_NS_GPL(ccu_nkmp_ops, "SUNXI_CCU");

drivers/clk/sunxi-ng/ccu_nm.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,52 +116,53 @@ static unsigned long ccu_nm_recalc_rate(struct clk_hw *hw,
116116
return rate;
117117
}
118118

119-
static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate,
120-
unsigned long *parent_rate)
119+
static int ccu_nm_determine_rate(struct clk_hw *hw,
120+
struct clk_rate_request *req)
121121
{
122122
struct ccu_nm *nm = hw_to_ccu_nm(hw);
123123
struct _ccu_nm _nm;
124124

125125
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
126-
rate *= nm->fixed_post_div;
126+
req->rate *= nm->fixed_post_div;
127127

128-
if (rate < nm->min_rate) {
129-
rate = nm->min_rate;
128+
if (req->rate < nm->min_rate) {
129+
req->rate = nm->min_rate;
130130
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
131-
rate /= nm->fixed_post_div;
132-
return rate;
131+
req->rate /= nm->fixed_post_div;
132+
return 0;
133133
}
134134

135-
if (nm->max_rate && rate > nm->max_rate) {
136-
rate = nm->max_rate;
135+
if (nm->max_rate && req->rate > nm->max_rate) {
136+
req->rate = nm->max_rate;
137137
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
138-
rate /= nm->fixed_post_div;
139-
return rate;
138+
req->rate /= nm->fixed_post_div;
139+
return 0;
140140
}
141141

142-
if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, rate)) {
142+
if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, req->rate)) {
143143
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
144-
rate /= nm->fixed_post_div;
145-
return rate;
144+
req->rate /= nm->fixed_post_div;
145+
return 0;
146146
}
147147

148-
if (ccu_sdm_helper_has_rate(&nm->common, &nm->sdm, rate)) {
148+
if (ccu_sdm_helper_has_rate(&nm->common, &nm->sdm, req->rate)) {
149149
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
150-
rate /= nm->fixed_post_div;
151-
return rate;
150+
req->rate /= nm->fixed_post_div;
151+
return 0;
152152
}
153153

154154
_nm.min_n = nm->n.min ?: 1;
155155
_nm.max_n = nm->n.max ?: 1 << nm->n.width;
156156
_nm.min_m = 1;
157157
_nm.max_m = nm->m.max ?: 1 << nm->m.width;
158158

159-
rate = ccu_nm_find_best(&nm->common, *parent_rate, rate, &_nm);
159+
req->rate = ccu_nm_find_best(&nm->common, req->best_parent_rate,
160+
req->rate, &_nm);
160161

161162
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
162-
rate /= nm->fixed_post_div;
163+
req->rate /= nm->fixed_post_div;
163164

164-
return rate;
165+
return 0;
165166
}
166167

167168
static int ccu_nm_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -233,7 +234,7 @@ const struct clk_ops ccu_nm_ops = {
233234
.is_enabled = ccu_nm_is_enabled,
234235

235236
.recalc_rate = ccu_nm_recalc_rate,
236-
.round_rate = ccu_nm_round_rate,
237+
.determine_rate = ccu_nm_determine_rate,
237238
.set_rate = ccu_nm_set_rate,
238239
};
239240
EXPORT_SYMBOL_NS_GPL(ccu_nm_ops, "SUNXI_CCU");

include/dt-bindings/reset/sun55i-a523-r-ccu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
#define RST_BUS_R_IR_RX 12
2222
#define RST_BUS_R_RTC 13
2323
#define RST_BUS_R_CPUCFG 14
24+
#define RST_BUS_R_PPU0 15
2425

2526
#endif /* _DT_BINDINGS_RST_SUN55I_A523_R_CCU_H_ */

0 commit comments

Comments
 (0)