Skip to content

Commit efb1e0b

Browse files
committed
Merge branches 'clk-ingenic', 'clk-mtk-mux', 'clk-qcom-sdm845-pcie', 'clk-mtk-crit' and 'clk-mtk' into clk-next
* clk-ingenic: clk: ingenic: Remove set but not used variable 'enable' clk: ingenic: Fix doc of ingenic_cgu_div_info clk: ingenic: Fix round_rate misbehaving with non-integer dividers clk: ingenic: jz4740: Fix gating of UDC clock * clk-mtk-mux: clk: mediatek: using CLK_MUX_ROUND_CLOSEST for the clock of dpi1_sel clk: mediatek: add MUX_GATE_FLAGS_2 * clk-qcom-sdm845-pcie: clk: qcom: gcc-sdm845: Define parent of PCIe PIPE clocks * clk-mtk-crit: clk: mediatek: Mark bus and DRAM related clocks as critical clk: mediatek: Add flags to mtk_gate clk: mediatek: Add MUX_FLAGS macro * clk-mtk: clk: mediatek: correct cpu clock name for MT8173 SoC
6 parents 75f486c + 635bd69 + d3174bc + 4b5a59a + b35656d + 64f4466 commit efb1e0b

File tree

12 files changed

+90
-51
lines changed

12 files changed

+90
-51
lines changed

drivers/clk/ingenic/cgu.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ ingenic_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
8383
const struct ingenic_cgu_clk_info *clk_info;
8484
const struct ingenic_cgu_pll_info *pll_info;
8585
unsigned m, n, od_enc, od;
86-
bool bypass, enable;
86+
bool bypass;
8787
unsigned long flags;
8888
u32 ctl;
8989

@@ -103,7 +103,6 @@ ingenic_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
103103
od_enc &= GENMASK(pll_info->od_bits - 1, 0);
104104
bypass = !pll_info->no_bypass_bit &&
105105
!!(ctl & BIT(pll_info->bypass_bit));
106-
enable = !!(ctl & BIT(pll_info->enable_bit));
107106

108107
if (bypass)
109108
return parent_rate;
@@ -426,16 +425,16 @@ ingenic_clk_round_rate(struct clk_hw *hw, unsigned long req_rate,
426425
struct ingenic_clk *ingenic_clk = to_ingenic_clk(hw);
427426
struct ingenic_cgu *cgu = ingenic_clk->cgu;
428427
const struct ingenic_cgu_clk_info *clk_info;
429-
long rate = *parent_rate;
428+
unsigned int div = 1;
430429

431430
clk_info = &cgu->clock_info[ingenic_clk->idx];
432431

433432
if (clk_info->type & CGU_CLK_DIV)
434-
rate /= ingenic_clk_calc_div(clk_info, *parent_rate, req_rate);
433+
div = ingenic_clk_calc_div(clk_info, *parent_rate, req_rate);
435434
else if (clk_info->type & CGU_CLK_FIXDIV)
436-
rate /= clk_info->fixdiv.div;
435+
div = clk_info->fixdiv.div;
437436

438-
return rate;
437+
return DIV_ROUND_UP(*parent_rate, div);
439438
}
440439

441440
static int
@@ -455,7 +454,7 @@ ingenic_clk_set_rate(struct clk_hw *hw, unsigned long req_rate,
455454

456455
if (clk_info->type & CGU_CLK_DIV) {
457456
div = ingenic_clk_calc_div(clk_info, parent_rate, req_rate);
458-
rate = parent_rate / div;
457+
rate = DIV_ROUND_UP(parent_rate, div);
459458

460459
if (rate != req_rate)
461460
return -EINVAL;

drivers/clk/ingenic/cgu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct ingenic_cgu_mux_info {
8080
* @reg: offset of the divider control register within the CGU
8181
* @shift: number of bits to left shift the divide value by (ie. the index of
8282
* the lowest bit of the divide value within its control register)
83-
* @div: number of bits to divide the divider value by (i.e. if the
83+
* @div: number to divide the divider value by (i.e. if the
8484
* effective divider value is the value written to the register
8585
* multiplied by some constant)
8686
* @bits: the size of the divide value in bits

drivers/clk/ingenic/jz4740-cgu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static const struct ingenic_cgu_clk_info jz4740_cgu_clocks[] = {
165165
.parents = { JZ4740_CLK_EXT, JZ4740_CLK_PLL_HALF, -1, -1 },
166166
.mux = { CGU_REG_CPCCR, 29, 1 },
167167
.div = { CGU_REG_CPCCR, 23, 1, 6, -1, -1, -1 },
168-
.gate = { CGU_REG_SCR, 6 },
168+
.gate = { CGU_REG_SCR, 6, true },
169169
},
170170

171171
/* Gate-only clocks */

drivers/clk/mediatek/clk-gate.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ struct clk *mtk_clk_register_gate(
157157
int clr_ofs,
158158
int sta_ofs,
159159
u8 bit,
160-
const struct clk_ops *ops)
160+
const struct clk_ops *ops,
161+
unsigned long flags)
161162
{
162163
struct mtk_clk_gate *cg;
163164
struct clk *clk;
@@ -172,6 +173,7 @@ struct clk *mtk_clk_register_gate(
172173
init.parent_names = parent_name ? &parent_name : NULL;
173174
init.num_parents = parent_name ? 1 : 0;
174175
init.ops = ops;
176+
init.flags = flags;
175177

176178
cg->regmap = regmap;
177179
cg->set_ofs = set_ofs;

drivers/clk/mediatek/clk-gate.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct clk *mtk_clk_register_gate(
4747
int clr_ofs,
4848
int sta_ofs,
4949
u8 bit,
50-
const struct clk_ops *ops);
50+
const struct clk_ops *ops,
51+
unsigned long flags);
5152

5253
#endif /* __DRV_CLK_GATE_H */

drivers/clk/mediatek/clk-mt2701.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,8 @@ static const struct mtk_composite top_muxes[] = {
535535
0x0080, 8, 2, 15),
536536
MUX_GATE(CLK_TOP_DPI0_SEL, "dpi0_sel", dpi0_parents,
537537
0x0080, 16, 3, 23),
538-
MUX_GATE(CLK_TOP_DPI1_SEL, "dpi1_sel", dpi1_parents,
539-
0x0080, 24, 2, 31),
538+
MUX_GATE_FLAGS_2(CLK_TOP_DPI1_SEL, "dpi1_sel", dpi1_parents,
539+
0x0080, 24, 2, 31, 0, CLK_MUX_ROUND_CLOSEST),
540540

541541
MUX_GATE(CLK_TOP_TVE_SEL, "tve_sel", tve_parents,
542542
0x0090, 0, 3, 7),

drivers/clk/mediatek/clk-mt6797.c

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,19 @@ static const char * const anc_md32_parents[] = {
324324
"univpll_d5",
325325
};
326326

327+
/*
328+
* Clock mux ddrphycfg is needed by the DRAM controller. We mark it as
329+
* critical as otherwise the system will hang after boot.
330+
*/
327331
static const struct mtk_composite top_muxes[] = {
328332
MUX(CLK_TOP_MUX_ULPOSC_AXI_CK_MUX_PRE, "ulposc_axi_ck_mux_pre",
329333
ulposc_axi_ck_mux_pre_parents, 0x0040, 3, 1),
330334
MUX(CLK_TOP_MUX_ULPOSC_AXI_CK_MUX, "ulposc_axi_ck_mux",
331335
ulposc_axi_ck_mux_parents, 0x0040, 2, 1),
332336
MUX(CLK_TOP_MUX_AXI, "axi_sel", axi_parents,
333337
0x0040, 0, 2),
334-
MUX(CLK_TOP_MUX_DDRPHYCFG, "ddrphycfg_sel", ddrphycfg_parents,
335-
0x0040, 16, 2),
338+
MUX_FLAGS(CLK_TOP_MUX_DDRPHYCFG, "ddrphycfg_sel", ddrphycfg_parents,
339+
0x0040, 16, 2, CLK_IS_CRITICAL | CLK_SET_RATE_PARENT),
336340
MUX(CLK_TOP_MUX_MM, "mm_sel", mm_parents,
337341
0x0040, 24, 2),
338342
MUX_GATE(CLK_TOP_MUX_PWM, "pwm_sel", pwm_parents, 0x0050, 0, 3, 7),
@@ -424,33 +428,45 @@ static const struct mtk_gate_regs infra2_cg_regs = {
424428
.sta_ofs = 0x00b0,
425429
};
426430

427-
#define GATE_ICG0(_id, _name, _parent, _shift) { \
428-
.id = _id, \
429-
.name = _name, \
430-
.parent_name = _parent, \
431-
.regs = &infra0_cg_regs, \
432-
.shift = _shift, \
433-
.ops = &mtk_clk_gate_ops_setclr, \
431+
#define GATE_ICG0(_id, _name, _parent, _shift) { \
432+
.id = _id, \
433+
.name = _name, \
434+
.parent_name = _parent, \
435+
.regs = &infra0_cg_regs, \
436+
.shift = _shift, \
437+
.ops = &mtk_clk_gate_ops_setclr, \
434438
}
435439

436-
#define GATE_ICG1(_id, _name, _parent, _shift) { \
437-
.id = _id, \
438-
.name = _name, \
439-
.parent_name = _parent, \
440-
.regs = &infra1_cg_regs, \
441-
.shift = _shift, \
442-
.ops = &mtk_clk_gate_ops_setclr, \
440+
#define GATE_ICG1(_id, _name, _parent, _shift) \
441+
GATE_ICG1_FLAGS(_id, _name, _parent, _shift, 0)
442+
443+
#define GATE_ICG1_FLAGS(_id, _name, _parent, _shift, _flags) { \
444+
.id = _id, \
445+
.name = _name, \
446+
.parent_name = _parent, \
447+
.regs = &infra1_cg_regs, \
448+
.shift = _shift, \
449+
.ops = &mtk_clk_gate_ops_setclr, \
450+
.flags = _flags, \
443451
}
444452

445-
#define GATE_ICG2(_id, _name, _parent, _shift) { \
446-
.id = _id, \
447-
.name = _name, \
448-
.parent_name = _parent, \
449-
.regs = &infra2_cg_regs, \
450-
.shift = _shift, \
451-
.ops = &mtk_clk_gate_ops_setclr, \
453+
#define GATE_ICG2(_id, _name, _parent, _shift) \
454+
GATE_ICG2_FLAGS(_id, _name, _parent, _shift, 0)
455+
456+
#define GATE_ICG2_FLAGS(_id, _name, _parent, _shift, _flags) { \
457+
.id = _id, \
458+
.name = _name, \
459+
.parent_name = _parent, \
460+
.regs = &infra2_cg_regs, \
461+
.shift = _shift, \
462+
.ops = &mtk_clk_gate_ops_setclr, \
463+
.flags = _flags, \
452464
}
453465

466+
/*
467+
* Clock gates dramc and dramc_b are needed by the DRAM controller.
468+
* We mark them as critical as otherwise the system will hang after boot.
469+
*/
454470
static const struct mtk_gate infra_clks[] = {
455471
GATE_ICG0(CLK_INFRA_PMIC_TMR, "infra_pmic_tmr", "ulposc", 0),
456472
GATE_ICG0(CLK_INFRA_PMIC_AP, "infra_pmic_ap", "pmicspi_sel", 1),
@@ -505,7 +521,8 @@ static const struct mtk_gate infra_clks[] = {
505521
GATE_ICG1(CLK_INFRA_CCIF_AP, "infra_ccif_ap", "axi_sel", 23),
506522
GATE_ICG1(CLK_INFRA_AUDIO, "infra_audio", "axi_sel", 25),
507523
GATE_ICG1(CLK_INFRA_CCIF_MD, "infra_ccif_md", "axi_sel", 26),
508-
GATE_ICG1(CLK_INFRA_DRAMC_F26M, "infra_dramc_f26m", "clk26m", 31),
524+
GATE_ICG1_FLAGS(CLK_INFRA_DRAMC_F26M, "infra_dramc_f26m",
525+
"clk26m", 31, CLK_IS_CRITICAL),
509526
GATE_ICG2(CLK_INFRA_I2C4, "infra_i2c4", "axi_sel", 0),
510527
GATE_ICG2(CLK_INFRA_I2C_APPM, "infra_i2c_appm", "axi_sel", 1),
511528
GATE_ICG2(CLK_INFRA_I2C_GPUPM, "infra_i2c_gpupm", "axi_sel", 2),
@@ -516,7 +533,8 @@ static const struct mtk_gate infra_clks[] = {
516533
GATE_ICG2(CLK_INFRA_I2C5, "infra_i2c5", "axi_sel", 7),
517534
GATE_ICG2(CLK_INFRA_SYS_CIRQ, "infra_sys_cirq", "axi_sel", 8),
518535
GATE_ICG2(CLK_INFRA_SPI1, "infra_spi1", "spi_sel", 10),
519-
GATE_ICG2(CLK_INFRA_DRAMC_B_F26M, "infra_dramc_b_f26m", "clk26m", 11),
536+
GATE_ICG2_FLAGS(CLK_INFRA_DRAMC_B_F26M, "infra_dramc_b_f26m",
537+
"clk26m", 11, CLK_IS_CRITICAL),
520538
GATE_ICG2(CLK_INFRA_ANC_MD32, "infra_anc_md32", "anc_md32_sel", 12),
521539
GATE_ICG2(CLK_INFRA_ANC_MD32_32K, "infra_anc_md32_32k", "clk26m", 13),
522540
GATE_ICG2(CLK_INFRA_DVFS_SPM1, "infra_dvfs_spm1", "axi_sel", 15),

drivers/clk/mediatek/clk-mt8173.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static const char * const ca53_parents[] __initconst = {
533533
"univpll"
534534
};
535535

536-
static const char * const ca57_parents[] __initconst = {
536+
static const char * const ca72_parents[] __initconst = {
537537
"clk26m",
538538
"armca15pll",
539539
"mainpll",
@@ -542,7 +542,7 @@ static const char * const ca57_parents[] __initconst = {
542542

543543
static const struct mtk_composite cpu_muxes[] __initconst = {
544544
MUX(CLK_INFRA_CA53SEL, "infra_ca53_sel", ca53_parents, 0x0000, 0, 2),
545-
MUX(CLK_INFRA_CA57SEL, "infra_ca57_sel", ca57_parents, 0x0000, 2, 2),
545+
MUX(CLK_INFRA_CA72SEL, "infra_ca72_sel", ca72_parents, 0x0000, 2, 2),
546546
};
547547

548548
static const struct mtk_composite top_muxes[] __initconst = {

drivers/clk/mediatek/clk-mtk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ int mtk_clk_register_gates(struct device_node *node,
130130
gate->regs->set_ofs,
131131
gate->regs->clr_ofs,
132132
gate->regs->sta_ofs,
133-
gate->shift, gate->ops);
133+
gate->shift, gate->ops, gate->flags);
134134

135135
if (IS_ERR(clk)) {
136136
pr_err("Failed to register clk %s: %ld\n",
@@ -167,7 +167,7 @@ struct clk *mtk_clk_register_composite(const struct mtk_composite *mc,
167167
mux->mask = BIT(mc->mux_width) - 1;
168168
mux->shift = mc->mux_shift;
169169
mux->lock = lock;
170-
170+
mux->flags = mc->mux_flags;
171171
mux_hw = &mux->hw;
172172
mux_ops = &clk_mux_ops;
173173

drivers/clk/mediatek/clk-mtk.h

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,13 @@ struct mtk_composite {
8181
signed char divider_shift;
8282
signed char divider_width;
8383

84+
u8 mux_flags;
85+
8486
signed char num_parents;
8587
};
8688

87-
/*
88-
* In case the rate change propagation to parent clocks is undesirable,
89-
* this macro allows to specify the clock flags manually.
90-
*/
91-
#define MUX_GATE_FLAGS(_id, _name, _parents, _reg, _shift, _width, \
92-
_gate, _flags) { \
89+
#define MUX_GATE_FLAGS_2(_id, _name, _parents, _reg, _shift, \
90+
_width, _gate, _flags, _muxflags) { \
9391
.id = _id, \
9492
.name = _name, \
9593
.mux_reg = _reg, \
@@ -101,8 +99,18 @@ struct mtk_composite {
10199
.parent_names = _parents, \
102100
.num_parents = ARRAY_SIZE(_parents), \
103101
.flags = _flags, \
102+
.mux_flags = _muxflags, \
104103
}
105104

105+
/*
106+
* In case the rate change propagation to parent clocks is undesirable,
107+
* this macro allows to specify the clock flags manually.
108+
*/
109+
#define MUX_GATE_FLAGS(_id, _name, _parents, _reg, _shift, _width, \
110+
_gate, _flags) \
111+
MUX_GATE_FLAGS_2(_id, _name, _parents, _reg, \
112+
_shift, _width, _gate, _flags, 0)
113+
106114
/*
107115
* Unless necessary, all MUX_GATE clocks propagate rate changes to their
108116
* parent clock by default.
@@ -111,7 +119,11 @@ struct mtk_composite {
111119
MUX_GATE_FLAGS(_id, _name, _parents, _reg, _shift, _width, \
112120
_gate, CLK_SET_RATE_PARENT)
113121

114-
#define MUX(_id, _name, _parents, _reg, _shift, _width) { \
122+
#define MUX(_id, _name, _parents, _reg, _shift, _width) \
123+
MUX_FLAGS(_id, _name, _parents, _reg, \
124+
_shift, _width, CLK_SET_RATE_PARENT)
125+
126+
#define MUX_FLAGS(_id, _name, _parents, _reg, _shift, _width, _flags) { \
115127
.id = _id, \
116128
.name = _name, \
117129
.mux_reg = _reg, \
@@ -121,7 +133,7 @@ struct mtk_composite {
121133
.divider_shift = -1, \
122134
.parent_names = _parents, \
123135
.num_parents = ARRAY_SIZE(_parents), \
124-
.flags = CLK_SET_RATE_PARENT, \
136+
.flags = _flags, \
125137
}
126138

127139
#define DIV_GATE(_id, _name, _parent, _gate_reg, _gate_shift, _div_reg, \
@@ -158,6 +170,7 @@ struct mtk_gate {
158170
const struct mtk_gate_regs *regs;
159171
int shift;
160172
const struct clk_ops *ops;
173+
unsigned long flags;
161174
};
162175

163176
int mtk_clk_register_gates(struct device_node *node,

drivers/clk/qcom/gcc-sdm845.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,9 @@ static struct clk_branch gcc_pcie_0_pipe_clk = {
17031703
.enable_mask = BIT(4),
17041704
.hw.init = &(struct clk_init_data){
17051705
.name = "gcc_pcie_0_pipe_clk",
1706+
.parent_names = (const char *[]){ "pcie_0_pipe_clk" },
1707+
.num_parents = 1,
1708+
.flags = CLK_SET_RATE_PARENT,
17061709
.ops = &clk_branch2_ops,
17071710
},
17081711
},
@@ -1802,6 +1805,8 @@ static struct clk_branch gcc_pcie_1_pipe_clk = {
18021805
.enable_mask = BIT(30),
18031806
.hw.init = &(struct clk_init_data){
18041807
.name = "gcc_pcie_1_pipe_clk",
1808+
.parent_names = (const char *[]){ "pcie_1_pipe_clk" },
1809+
.num_parents = 1,
18051810
.ops = &clk_branch2_ops,
18061811
},
18071812
},

include/dt-bindings/clock/mt8173-clk.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@
194194
#define CLK_INFRA_PMICWRAP 11
195195
#define CLK_INFRA_CLK_13M 12
196196
#define CLK_INFRA_CA53SEL 13
197-
#define CLK_INFRA_CA57SEL 14
197+
#define CLK_INFRA_CA57SEL 14 /* Deprecated. Don't use it. */
198+
#define CLK_INFRA_CA72SEL 14
198199
#define CLK_INFRA_NR_CLK 15
199200

200201
/* PERI_SYS */

0 commit comments

Comments
 (0)