.. | .. |
---|
4 | 4 | */ |
---|
5 | 5 | #include <linux/slab.h> |
---|
6 | 6 | #include <linux/clk-provider.h> |
---|
| 7 | +#include <linux/io.h> |
---|
7 | 8 | |
---|
8 | 9 | #include "stratix10-clk.h" |
---|
9 | 10 | #include "clk.h" |
---|
.. | .. |
---|
48 | 49 | { |
---|
49 | 50 | struct socfpga_periph_clk *socfpgaclk = to_periph_clk(hwclk); |
---|
50 | 51 | u32 clk_src, mask; |
---|
51 | | - u8 parent; |
---|
| 52 | + u8 parent = 0; |
---|
52 | 53 | |
---|
| 54 | + /* handle the bypass first */ |
---|
53 | 55 | if (socfpgaclk->bypass_reg) { |
---|
54 | 56 | mask = (0x1 << socfpgaclk->bypass_shift); |
---|
55 | 57 | parent = ((readl(socfpgaclk->bypass_reg) & mask) >> |
---|
56 | 58 | socfpgaclk->bypass_shift); |
---|
57 | | - } else { |
---|
| 59 | + if (parent) |
---|
| 60 | + return parent; |
---|
| 61 | + } |
---|
| 62 | + |
---|
| 63 | + if (socfpgaclk->hw.reg) { |
---|
58 | 64 | clk_src = readl(socfpgaclk->hw.reg); |
---|
59 | 65 | parent = (clk_src >> CLK_MGR_FREE_SHIFT) & |
---|
60 | | - CLK_MGR_FREE_MASK; |
---|
| 66 | + CLK_MGR_FREE_MASK; |
---|
61 | 67 | } |
---|
62 | 68 | return parent; |
---|
63 | 69 | } |
---|
.. | .. |
---|
72 | 78 | .get_parent = clk_periclk_get_parent, |
---|
73 | 79 | }; |
---|
74 | 80 | |
---|
75 | | -struct clk *s10_register_periph(const char *name, const char *parent_name, |
---|
76 | | - const char * const *parent_names, |
---|
77 | | - u8 num_parents, unsigned long flags, |
---|
78 | | - void __iomem *reg, unsigned long offset) |
---|
| 81 | +struct clk *s10_register_periph(const struct stratix10_perip_c_clock *clks, |
---|
| 82 | + void __iomem *reg) |
---|
79 | 83 | { |
---|
80 | 84 | struct clk *clk; |
---|
81 | 85 | struct socfpga_periph_clk *periph_clk; |
---|
82 | | - struct clk_init_data init = {}; |
---|
| 86 | + struct clk_init_data init; |
---|
| 87 | + const char *name = clks->name; |
---|
| 88 | + const char *parent_name = clks->parent_name; |
---|
83 | 89 | |
---|
84 | 90 | periph_clk = kzalloc(sizeof(*periph_clk), GFP_KERNEL); |
---|
85 | 91 | if (WARN_ON(!periph_clk)) |
---|
86 | 92 | return NULL; |
---|
87 | 93 | |
---|
88 | | - periph_clk->hw.reg = reg + offset; |
---|
| 94 | + periph_clk->hw.reg = reg + clks->offset; |
---|
89 | 95 | |
---|
90 | 96 | init.name = name; |
---|
91 | 97 | init.ops = &peri_c_clk_ops; |
---|
92 | | - init.flags = flags; |
---|
| 98 | + init.flags = clks->flags; |
---|
93 | 99 | |
---|
94 | | - init.num_parents = num_parents; |
---|
95 | | - init.parent_names = parent_names ? parent_names : &parent_name; |
---|
| 100 | + init.num_parents = clks->num_parents; |
---|
| 101 | + init.parent_names = parent_name ? &parent_name : NULL; |
---|
| 102 | + if (init.parent_names == NULL) |
---|
| 103 | + init.parent_data = clks->parent_data; |
---|
96 | 104 | |
---|
97 | 105 | periph_clk->hw.hw.init = &init; |
---|
98 | 106 | |
---|
.. | .. |
---|
104 | 112 | return clk; |
---|
105 | 113 | } |
---|
106 | 114 | |
---|
107 | | -struct clk *s10_register_cnt_periph(const char *name, const char *parent_name, |
---|
108 | | - const char * const *parent_names, |
---|
109 | | - u8 num_parents, unsigned long flags, |
---|
110 | | - void __iomem *regbase, unsigned long offset, |
---|
111 | | - u8 fixed_divider, unsigned long bypass_reg, |
---|
112 | | - unsigned long bypass_shift) |
---|
| 115 | +struct clk *s10_register_cnt_periph(const struct stratix10_perip_cnt_clock *clks, |
---|
| 116 | + void __iomem *regbase) |
---|
113 | 117 | { |
---|
114 | 118 | struct clk *clk; |
---|
115 | 119 | struct socfpga_periph_clk *periph_clk; |
---|
116 | | - struct clk_init_data init = {}; |
---|
| 120 | + struct clk_init_data init; |
---|
| 121 | + const char *name = clks->name; |
---|
| 122 | + const char *parent_name = clks->parent_name; |
---|
117 | 123 | |
---|
118 | 124 | periph_clk = kzalloc(sizeof(*periph_clk), GFP_KERNEL); |
---|
119 | 125 | if (WARN_ON(!periph_clk)) |
---|
120 | 126 | return NULL; |
---|
121 | 127 | |
---|
122 | | - if (offset) |
---|
123 | | - periph_clk->hw.reg = regbase + offset; |
---|
| 128 | + if (clks->offset) |
---|
| 129 | + periph_clk->hw.reg = regbase + clks->offset; |
---|
124 | 130 | else |
---|
125 | 131 | periph_clk->hw.reg = NULL; |
---|
126 | 132 | |
---|
127 | | - if (bypass_reg) |
---|
128 | | - periph_clk->bypass_reg = regbase + bypass_reg; |
---|
| 133 | + if (clks->bypass_reg) |
---|
| 134 | + periph_clk->bypass_reg = regbase + clks->bypass_reg; |
---|
129 | 135 | else |
---|
130 | 136 | periph_clk->bypass_reg = NULL; |
---|
131 | | - periph_clk->bypass_shift = bypass_shift; |
---|
132 | | - periph_clk->fixed_div = fixed_divider; |
---|
| 137 | + periph_clk->bypass_shift = clks->bypass_shift; |
---|
| 138 | + periph_clk->fixed_div = clks->fixed_divider; |
---|
133 | 139 | |
---|
134 | 140 | init.name = name; |
---|
135 | 141 | init.ops = &peri_cnt_clk_ops; |
---|
136 | | - init.flags = flags; |
---|
| 142 | + init.flags = clks->flags; |
---|
137 | 143 | |
---|
138 | | - init.num_parents = num_parents; |
---|
139 | | - init.parent_names = parent_names ? parent_names : &parent_name; |
---|
| 144 | + init.num_parents = clks->num_parents; |
---|
| 145 | + init.parent_names = parent_name ? &parent_name : NULL; |
---|
| 146 | + if (init.parent_names == NULL) |
---|
| 147 | + init.parent_data = clks->parent_data; |
---|
140 | 148 | |
---|
141 | 149 | periph_clk->hw.hw.init = &init; |
---|
142 | 150 | |
---|