Lines Matching +full:conf +full:- +full:clk

1 /*-
28 #include <sys/conf.h>
35 #include <dev/clk/clk_div.h>
50 static int clknode_div_init(struct clknode *clk, device_t dev);
51 static int clknode_div_recalc(struct clknode *clk, uint64_t *req);
86 if (!(sc->div_flags & CLK_DIV_WITH_TABLE)) in clknode_div_table_get_divider()
89 for (table = sc->div_table; table->divider != 0; table++) in clknode_div_table_get_divider()
90 if (table->value == sc->divider) in clknode_div_table_get_divider()
91 return (table->divider); in clknode_div_table_get_divider()
101 if (!(sc->div_flags & CLK_DIV_WITH_TABLE)) in clknode_div_table_get_value()
104 for (table = sc->div_table; table->divider != 0; table++) in clknode_div_table_get_value()
105 if (table->divider == *divider) { in clknode_div_table_get_value()
106 *divider = table->value; in clknode_div_table_get_value()
114 clknode_div_init(struct clknode *clk, device_t dev) in clknode_div_init() argument
121 sc = clknode_get_softc(clk); in clknode_div_init()
123 DEVICE_LOCK(clk); in clknode_div_init()
124 rv = RD4(clk, sc->offset, &reg); in clknode_div_init()
125 DEVICE_UNLOCK(clk); in clknode_div_init()
129 i_div = (reg >> sc->i_shift) & sc->i_mask; in clknode_div_init()
130 if (!(sc->div_flags & CLK_DIV_WITH_TABLE) && in clknode_div_init()
131 !(sc->div_flags & CLK_DIV_ZERO_BASED)) in clknode_div_init()
133 f_div = (reg >> sc->f_shift) & sc->f_mask; in clknode_div_init()
134 sc->divider = i_div << sc->f_width | f_div; in clknode_div_init()
136 sc->divider = clknode_div_table_get_divider(sc, sc->divider); in clknode_div_init()
137 if (sc->divider == 0) in clknode_div_init()
138 panic("%s: divider is zero!\n", clknode_get_name(clk)); in clknode_div_init()
140 clknode_init_parent_idx(clk, 0); in clknode_div_init()
145 clknode_div_recalc(struct clknode *clk, uint64_t *freq) in clknode_div_recalc() argument
149 sc = clknode_get_softc(clk); in clknode_div_recalc()
150 if (sc->divider == 0) { in clknode_div_recalc()
151 printf("%s: %s divider is zero!\n", clknode_get_name(clk), in clknode_div_recalc()
156 *freq = (*freq << sc->f_width) / sc->divider; in clknode_div_recalc()
161 clknode_div_set_freq(struct clknode *clk, uint64_t fin, uint64_t *fout, in clknode_div_set_freq() argument
169 sc = clknode_get_softc(clk); in clknode_div_set_freq()
172 _fin = fin << sc->f_width; in clknode_div_set_freq()
178 divider--; in clknode_div_set_freq()
183 i_div = divider >> sc->f_width; in clknode_div_set_freq()
184 f_div = divider & sc->f_mask; in clknode_div_set_freq()
188 clknode_get_name(clk), __func__); in clknode_div_set_freq()
194 if (sc->div_flags & CLK_DIV_WITH_TABLE) { in clknode_div_set_freq()
198 if (!(sc->div_flags & CLK_DIV_ZERO_BASED)) in clknode_div_set_freq()
199 hw_i_div--; in clknode_div_set_freq()
201 if (i_div > sc->i_mask) { in clknode_div_set_freq()
204 clknode_get_name(clk), __func__, i_div); in clknode_div_set_freq()
205 hw_i_div = sc->i_mask; in clknode_div_set_freq()
209 if (!(sc->div_flags & CLK_DIV_ZERO_BASED)) in clknode_div_set_freq()
213 divider = i_div << sc->f_width | f_div; in clknode_div_set_freq()
221 DEVICE_LOCK(clk); in clknode_div_set_freq()
222 rv = MD4(clk, sc->offset, in clknode_div_set_freq()
223 (sc->i_mask << sc->i_shift) | (sc->f_mask << sc->f_shift), in clknode_div_set_freq()
224 (hw_i_div << sc->i_shift) | (f_div << sc->f_shift)); in clknode_div_set_freq()
226 DEVICE_UNLOCK(clk); in clknode_div_set_freq()
229 RD4(clk, sc->offset, &reg); in clknode_div_set_freq()
230 DEVICE_UNLOCK(clk); in clknode_div_set_freq()
232 sc->divider = divider; in clknode_div_set_freq()
242 struct clknode *clk; in clknode_div_register() local
245 clk = clknode_create(clkdom, &clknode_div_class, &clkdef->clkdef); in clknode_div_register()
246 if (clk == NULL) in clknode_div_register()
249 sc = clknode_get_softc(clk); in clknode_div_register()
250 sc->offset = clkdef->offset; in clknode_div_register()
251 sc->i_shift = clkdef->i_shift; in clknode_div_register()
252 sc->i_width = clkdef->i_width; in clknode_div_register()
253 sc->i_mask = (1 << clkdef->i_width) - 1; in clknode_div_register()
254 sc->f_shift = clkdef->f_shift; in clknode_div_register()
255 sc->f_width = clkdef->f_width; in clknode_div_register()
256 sc->f_mask = (1 << clkdef->f_width) - 1; in clknode_div_register()
257 sc->div_flags = clkdef->div_flags; in clknode_div_register()
258 sc->div_table = clkdef->div_table; in clknode_div_register()
260 clknode_register(clkdom, clk); in clknode_div_register()