Lines Matching +full:conf +full:- +full:clk
1 /*-
30 #include <sys/conf.h>
47 #include <dev/clk/clk_fixed.h>
52 static int clknode_fixed_init(struct clknode *clk, device_t dev);
53 static int clknode_fixed_recalc(struct clknode *clk, uint64_t *freq);
54 static int clknode_fixed_set_freq(struct clknode *clk, uint64_t fin,
75 clknode_fixed_init(struct clknode *clk, device_t dev) in clknode_fixed_init() argument
79 sc = clknode_get_softc(clk); in clknode_fixed_init()
80 if (sc->freq == 0) in clknode_fixed_init()
81 clknode_init_parent_idx(clk, 0); in clknode_fixed_init()
86 clknode_fixed_recalc(struct clknode *clk, uint64_t *freq) in clknode_fixed_recalc() argument
90 sc = clknode_get_softc(clk); in clknode_fixed_recalc()
92 if ((sc->mult != 0) && (sc->div != 0)) in clknode_fixed_recalc()
93 *freq = (*freq / sc->div) * sc->mult; in clknode_fixed_recalc()
95 *freq = sc->freq; in clknode_fixed_recalc()
100 clknode_fixed_set_freq(struct clknode *clk, uint64_t fin, uint64_t *fout, in clknode_fixed_set_freq() argument
105 sc = clknode_get_softc(clk); in clknode_fixed_set_freq()
106 if (sc->mult == 0 || sc->div == 0) { in clknode_fixed_set_freq()
109 if (*fout != sc->freq) in clknode_fixed_set_freq()
115 *fout = (*fout / sc->mult) * sc->div; in clknode_fixed_set_freq()
122 struct clknode *clk; in clknode_fixed_register() local
125 clk = clknode_create(clkdom, &clknode_fixed_class, &clkdef->clkdef); in clknode_fixed_register()
126 if (clk == NULL) in clknode_fixed_register()
129 sc = clknode_get_softc(clk); in clknode_fixed_register()
130 sc->fixed_flags = clkdef->fixed_flags; in clknode_fixed_register()
131 sc->freq = clkdef->freq; in clknode_fixed_register()
132 sc->mult = clkdef->mult; in clknode_fixed_register()
133 sc->div = clkdef->div; in clknode_fixed_register()
135 clknode_register(clkdom, clk); in clknode_fixed_register()
142 {"fixed-clock", CLK_TYPE_FIXED},
143 {"fixed-factor-clock", CLK_TYPE_FIXED_FACTOR},
157 clk_type = ofw_bus_search_compatible(dev, compat_data)->ocd_data; in clk_fixed_probe()
160 if (OF_hasprop(ofw_bus_get_node(dev), "clock-frequency") == 0) { in clk_fixed_probe()
162 "clock-fixed has no clock-frequency\n"); in clk_fixed_probe()
187 def->clkdef.id = 1; in clk_fixed_init_fixed()
188 rv = OF_getencprop(node, "clock-frequency", &freq, sizeof(freq)); in clk_fixed_init_fixed()
191 def->freq = freq; in clk_fixed_init_fixed()
202 def->clkdef.id = 1; in clk_fixed_init_fixed_factor()
203 rv = OF_getencprop(node, "clock-mult", &def->mult, sizeof(def->mult)); in clk_fixed_init_fixed_factor()
206 rv = OF_getencprop(node, "clock-div", &def->div, sizeof(def->div)); in clk_fixed_init_fixed_factor()
210 rv = clk_get_by_ofw_index(sc->dev, 0, 0, &parent); in clk_fixed_init_fixed_factor()
213 def->clkdef.parent_names = malloc(sizeof(char *), M_OFWPROP, M_WAITOK); in clk_fixed_init_fixed_factor()
214 def->clkdef.parent_names[0] = clk_get_name(parent); in clk_fixed_init_fixed_factor()
215 def->clkdef.parent_cnt = 1; in clk_fixed_init_fixed_factor()
230 sc->dev = dev; in clk_fixed_attach()
232 clk_type = ofw_bus_search_compatible(dev, compat_data)->ocd_data; in clk_fixed_attach()
242 device_printf(sc->dev, "Cannot FDT parameters.\n"); in clk_fixed_attach()
247 device_printf(sc->dev, "Cannot parse clock name.\n"); in clk_fixed_attach()
250 sc->clkdom = clkdom_create(dev); in clk_fixed_attach()
251 KASSERT(sc->clkdom != NULL, ("Clock domain is NULL")); in clk_fixed_attach()
253 rv = clknode_fixed_register(sc->clkdom, &def); in clk_fixed_attach()
255 device_printf(sc->dev, "Cannot register fixed clock.\n"); in clk_fixed_attach()
260 rv = clkdom_finit(sc->clkdom); in clk_fixed_attach()
262 device_printf(sc->dev, "Clk domain finit fails.\n"); in clk_fixed_attach()
268 clkdom_dump(sc->clkdom); in clk_fixed_attach()