forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/clk/socfpga/clk-gate-s10.c
....@@ -3,6 +3,7 @@
33 * Copyright (C) 2017, Intel Corporation
44 */
55 #include <linux/clk-provider.h>
6
+#include <linux/io.h>
67 #include <linux/slab.h>
78 #include "stratix10-clk.h"
89 #include "clk.h"
....@@ -64,55 +65,51 @@
6465 .get_parent = socfpga_gate_get_parent,
6566 };
6667
67
-struct clk *s10_register_gate(const char *name, const char *parent_name,
68
- const char * const *parent_names,
69
- u8 num_parents, unsigned long flags,
70
- void __iomem *regbase, unsigned long gate_reg,
71
- unsigned long gate_idx, unsigned long div_reg,
72
- unsigned long div_offset, u8 div_width,
73
- unsigned long bypass_reg, u8 bypass_shift,
74
- u8 fixed_div)
68
+struct clk *s10_register_gate(const struct stratix10_gate_clock *clks, void __iomem *regbase)
7569 {
7670 struct clk *clk;
7771 struct socfpga_gate_clk *socfpga_clk;
78
- struct clk_init_data init = {};
72
+ struct clk_init_data init;
73
+ const char *parent_name = clks->parent_name;
7974
8075 socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
8176 if (!socfpga_clk)
8277 return NULL;
8378
84
- socfpga_clk->hw.reg = regbase + gate_reg;
85
- socfpga_clk->hw.bit_idx = gate_idx;
79
+ socfpga_clk->hw.reg = regbase + clks->gate_reg;
80
+ socfpga_clk->hw.bit_idx = clks->gate_idx;
8681
8782 gateclk_ops.enable = clk_gate_ops.enable;
8883 gateclk_ops.disable = clk_gate_ops.disable;
8984
90
- socfpga_clk->fixed_div = fixed_div;
85
+ socfpga_clk->fixed_div = clks->fixed_div;
9186
92
- if (div_reg)
93
- socfpga_clk->div_reg = regbase + div_reg;
87
+ if (clks->div_reg)
88
+ socfpga_clk->div_reg = regbase + clks->div_reg;
9489 else
9590 socfpga_clk->div_reg = NULL;
9691
97
- socfpga_clk->width = div_width;
98
- socfpga_clk->shift = div_offset;
92
+ socfpga_clk->width = clks->div_width;
93
+ socfpga_clk->shift = clks->div_offset;
9994
100
- if (bypass_reg)
101
- socfpga_clk->bypass_reg = regbase + bypass_reg;
95
+ if (clks->bypass_reg)
96
+ socfpga_clk->bypass_reg = regbase + clks->bypass_reg;
10297 else
10398 socfpga_clk->bypass_reg = NULL;
104
- socfpga_clk->bypass_shift = bypass_shift;
99
+ socfpga_clk->bypass_shift = clks->bypass_shift;
105100
106
- if (streq(name, "cs_pdbg_clk"))
101
+ if (streq(clks->name, "cs_pdbg_clk"))
107102 init.ops = &dbgclk_ops;
108103 else
109104 init.ops = &gateclk_ops;
110105
111
- init.name = name;
112
- init.flags = flags;
106
+ init.name = clks->name;
107
+ init.flags = clks->flags;
113108
114
- init.num_parents = num_parents;
115
- init.parent_names = parent_names ? parent_names : &parent_name;
109
+ init.num_parents = clks->num_parents;
110
+ init.parent_names = parent_name ? &parent_name : NULL;
111
+ if (init.parent_names == NULL)
112
+ init.parent_data = clks->parent_data;
116113 socfpga_clk->hw.hw.init = &init;
117114
118115 clk = clk_register(NULL, &socfpga_clk->hw.hw);
....@@ -120,6 +117,5 @@
120117 kfree(socfpga_clk);
121118 return NULL;
122119 }
123
-
124120 return clk;
125121 }