Lines Matching +full:conf +full:- +full:clk
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
30 #include <sys/conf.h>
37 #include <dev/clk/clk.h>
40 #include <dev/clk/rockchip/rk_cru.h>
41 #include <dev/clk/rockchip/rk_clk_mux.h>
59 printf("%s:(%s)" format, __func__, clknode_get_name(clk), arg)
64 static int rk_clk_mux_init(struct clknode *clk, device_t dev);
65 static int rk_clk_mux_set_mux(struct clknode *clk, int idx);
66 static int rk_clk_mux_set_freq(struct clknode *clk, uint64_t fparent,
88 rk_clk_mux_get_grf(struct clknode *clk) in rk_clk_mux_get_grf() argument
95 dev = clknode_get_device(clk); in rk_clk_mux_get_grf()
107 rk_clk_mux_init(struct clknode *clk, device_t dev) in rk_clk_mux_init() argument
113 sc = clknode_get_softc(clk); in rk_clk_mux_init()
115 if ((sc->mux_flags & RK_CLK_MUX_GRF) != 0) { in rk_clk_mux_init()
116 sc->grf = rk_clk_mux_get_grf(clk); in rk_clk_mux_init()
117 if (sc->grf == NULL) in rk_clk_mux_init()
119 clknode_get_name(clk)); in rk_clk_mux_init()
122 DEVICE_LOCK(clk); in rk_clk_mux_init()
123 if (sc->grf) { in rk_clk_mux_init()
124 reg = SYSCON_READ_4(sc->grf, sc->offset); in rk_clk_mux_init()
127 rv = RD4(clk, sc->offset, ®); in rk_clk_mux_init()
128 DEVICE_UNLOCK(clk); in rk_clk_mux_init()
132 reg = (reg >> sc->shift) & sc->mask; in rk_clk_mux_init()
133 clknode_init_parent_idx(clk, reg); in rk_clk_mux_init()
138 rk_clk_mux_set_mux(struct clknode *clk, int idx) in rk_clk_mux_set_mux() argument
144 sc = clknode_get_softc(clk); in rk_clk_mux_set_mux()
146 DEVICE_LOCK(clk); in rk_clk_mux_set_mux()
147 if (sc->grf) in rk_clk_mux_set_mux()
148 rv = SYSCON_MODIFY_4(sc->grf, sc->offset, sc->mask << sc->shift, in rk_clk_mux_set_mux()
149 ((idx & sc->mask) << sc->shift) | RK_CLK_MUX_MASK); in rk_clk_mux_set_mux()
151 rv = MD4(clk, sc->offset, sc->mask << sc->shift, in rk_clk_mux_set_mux()
152 ((idx & sc->mask) << sc->shift) | RK_CLK_MUX_MASK); in rk_clk_mux_set_mux()
154 DEVICE_UNLOCK(clk); in rk_clk_mux_set_mux()
157 if (sc->grf == NULL) in rk_clk_mux_set_mux()
158 RD4(clk, sc->offset, ®); in rk_clk_mux_set_mux()
159 DEVICE_UNLOCK(clk); in rk_clk_mux_set_mux()
165 rk_clk_mux_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout, in rk_clk_mux_set_freq() argument
174 sc = clknode_get_softc(clk); in rk_clk_mux_set_freq()
176 if ((sc->mux_flags & RK_CLK_MUX_GRF) != 0) { in rk_clk_mux_set_freq()
180 if ((sc->mux_flags & RK_CLK_MUX_REPARENT) == 0) { in rk_clk_mux_set_freq()
186 p_names = clknode_get_parent_names(clk); in rk_clk_mux_set_freq()
187 for (p_idx = 0; p_idx != clknode_get_parents_num(clk); p_idx++) { in rk_clk_mux_set_freq()
208 p_idx = clknode_get_parent_idx(clk); in rk_clk_mux_set_freq()
212 clknode_set_parent_by_idx(clk, best_parent); in rk_clk_mux_set_freq()
224 struct clknode *clk; in rk_clk_mux_register() local
227 clk = clknode_create(clkdom, &rk_clk_mux_class, &clkdef->clkdef); in rk_clk_mux_register()
228 if (clk == NULL) in rk_clk_mux_register()
231 sc = clknode_get_softc(clk); in rk_clk_mux_register()
232 sc->offset = clkdef->offset; in rk_clk_mux_register()
233 sc->shift = clkdef->shift; in rk_clk_mux_register()
234 sc->mask = (1 << clkdef->width) - 1; in rk_clk_mux_register()
235 sc->mux_flags = clkdef->mux_flags; in rk_clk_mux_register()
237 clknode_register(clkdom, clk); in rk_clk_mux_register()