Skip to content

Commit 610a5d8

Browse files
rajanv-xilinxbebarino
authored andcommitted
clk: zynqmp: Use firmware specific common clock flags
Currently firmware passes CCF specific flags to ZynqMP clock driver. So firmware needs to be updated if CCF flags are changed. The firmware should have its own 'flag number space' that is distinct from the common clk framework's 'flag number space'. So define and use ZynqMP specific common clock flags instead of using CCF flags. Signed-off-by: Rajan Vaja <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent b9ec1c1 commit 610a5d8

File tree

6 files changed

+52
-6
lines changed

6 files changed

+52
-6
lines changed

drivers/clk/zynqmp/clk-gate-zynqmp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ struct clk_hw *zynqmp_clk_register_gate(const char *name, u32 clk_id,
121121

122122
init.name = name;
123123
init.ops = &zynqmp_clk_gate_ops;
124-
init.flags = nodes->flag;
124+
125+
init.flags = zynqmp_clk_map_common_ccf_flags(nodes->flag);
126+
125127
init.parent_names = parents;
126128
init.num_parents = 1;
127129

drivers/clk/zynqmp/clk-mux-zynqmp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ struct clk_hw *zynqmp_clk_register_mux(const char *name, u32 clk_id,
126126
init.ops = &zynqmp_clk_mux_ro_ops;
127127
else
128128
init.ops = &zynqmp_clk_mux_ops;
129-
init.flags = nodes->flag;
129+
130+
init.flags = zynqmp_clk_map_common_ccf_flags(nodes->flag);
131+
130132
init.parent_names = parents;
131133
init.num_parents = num_parents;
132134
mux->flags = nodes->type_flag;

drivers/clk/zynqmp/clk-zynqmp.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@
1010

1111
#include <linux/firmware/xlnx-zynqmp.h>
1212

13+
/* Common Flags */
14+
/* must be gated across rate change */
15+
#define ZYNQMP_CLK_SET_RATE_GATE BIT(0)
16+
/* must be gated across re-parent */
17+
#define ZYNQMP_CLK_SET_PARENT_GATE BIT(1)
18+
/* propagate rate change up one level */
19+
#define ZYNQMP_CLK_SET_RATE_PARENT BIT(2)
20+
/* do not gate even if unused */
21+
#define ZYNQMP_CLK_IGNORE_UNUSED BIT(3)
22+
/* don't re-parent on rate change */
23+
#define ZYNQMP_CLK_SET_RATE_NO_REPARENT BIT(7)
24+
/* do not gate, ever */
25+
#define ZYNQMP_CLK_IS_CRITICAL BIT(11)
26+
1327
enum topology_type {
1428
TYPE_INVALID,
1529
TYPE_MUX,
@@ -33,6 +47,8 @@ struct clock_topology {
3347
u8 custom_type_flag;
3448
};
3549

50+
unsigned long zynqmp_clk_map_common_ccf_flags(const u32 zynqmp_flag);
51+
3652
struct clk_hw *zynqmp_clk_register_pll(const char *name, u32 clk_id,
3753
const char * const *parents,
3854
u8 num_parents,

drivers/clk/zynqmp/clkc.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,26 @@ static int zynqmp_pm_clock_get_topology(u32 clock_id, u32 index,
271271
return ret;
272272
}
273273

274+
unsigned long zynqmp_clk_map_common_ccf_flags(const u32 zynqmp_flag)
275+
{
276+
unsigned long ccf_flag = 0;
277+
278+
if (zynqmp_flag & ZYNQMP_CLK_SET_RATE_GATE)
279+
ccf_flag |= CLK_SET_RATE_GATE;
280+
if (zynqmp_flag & ZYNQMP_CLK_SET_PARENT_GATE)
281+
ccf_flag |= CLK_SET_PARENT_GATE;
282+
if (zynqmp_flag & ZYNQMP_CLK_SET_RATE_PARENT)
283+
ccf_flag |= CLK_SET_RATE_PARENT;
284+
if (zynqmp_flag & ZYNQMP_CLK_IGNORE_UNUSED)
285+
ccf_flag |= CLK_IGNORE_UNUSED;
286+
if (zynqmp_flag & ZYNQMP_CLK_SET_RATE_NO_REPARENT)
287+
ccf_flag |= CLK_SET_RATE_NO_REPARENT;
288+
if (zynqmp_flag & ZYNQMP_CLK_IS_CRITICAL)
289+
ccf_flag |= CLK_IS_CRITICAL;
290+
291+
return ccf_flag;
292+
}
293+
274294
/**
275295
* zynqmp_clk_register_fixed_factor() - Register fixed factor with the
276296
* clock framework
@@ -292,6 +312,7 @@ struct clk_hw *zynqmp_clk_register_fixed_factor(const char *name, u32 clk_id,
292312
struct zynqmp_pm_query_data qdata = {0};
293313
u32 ret_payload[PAYLOAD_ARG_CNT];
294314
int ret;
315+
unsigned long flag;
295316

296317
qdata.qid = PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS;
297318
qdata.arg1 = clk_id;
@@ -303,9 +324,11 @@ struct clk_hw *zynqmp_clk_register_fixed_factor(const char *name, u32 clk_id,
303324
mult = ret_payload[1];
304325
div = ret_payload[2];
305326

327+
flag = zynqmp_clk_map_common_ccf_flags(nodes->flag);
328+
306329
hw = clk_hw_register_fixed_factor(NULL, name,
307330
parents[0],
308-
nodes->flag, mult,
331+
flag, mult,
309332
div);
310333

311334
return hw;

drivers/clk/zynqmp/divider.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,9 @@ struct clk_hw *zynqmp_clk_register_divider(const char *name,
312312

313313
init.name = name;
314314
init.ops = &zynqmp_clk_divider_ops;
315-
/* CLK_FRAC is not defined in the common clk framework */
316-
init.flags = nodes->flag & ~CLK_FRAC;
315+
316+
init.flags = zynqmp_clk_map_common_ccf_flags(nodes->flag);
317+
317318
init.parent_names = parents;
318319
init.num_parents = 1;
319320

drivers/clk/zynqmp/pll.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ struct clk_hw *zynqmp_clk_register_pll(const char *name, u32 clk_id,
322322

323323
init.name = name;
324324
init.ops = &zynqmp_pll_ops;
325-
init.flags = nodes->flag;
325+
326+
init.flags = zynqmp_clk_map_common_ccf_flags(nodes->flag);
327+
326328
init.parent_names = parents;
327329
init.num_parents = 1;
328330

0 commit comments

Comments
 (0)