Lines Matching +full:syscon +full:- +full:clk

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
46 #include <dev/clk/clk.h>
49 #include <dev/syscon/syscon.h>
83 { "rockchip,rk3399-usb2phy", (uintptr_t)&rk3399_regs },
84 { "rockchip,rk3568-usb2phy", (uintptr_t)&rk3568_regs },
90 struct syscon *grf;
92 clk_t clk; member
132 if (sc->phy_supply) { in rk_usb2phy_enable()
134 error = regulator_enable(sc->phy_supply); in rk_usb2phy_enable()
136 error = regulator_disable(sc->phy_supply); in rk_usb2phy_enable()
163 *mode = sc->mode; in rk_usb2phy_get_mode()
182 sc->mode = mode; in rk_usb2phy_set_mode()
190 struct syscon *grf;
195 rk_usb2phy_clk_init(struct clknode *clk, device_t dev) in rk_usb2phy_clk_init() argument
198 clknode_init_parent_idx(clk, 0); in rk_usb2phy_clk_init()
203 rk_usb2phy_clk_set_gate(struct clknode *clk, bool enable) in rk_usb2phy_clk_set_gate() argument
207 sc = clknode_get_softc(clk); in rk_usb2phy_clk_set_gate()
210 SYSCON_WRITE_4(sc->grf, sc->regs->clk_ctl.offset, in rk_usb2phy_clk_set_gate()
211 sc->regs->clk_ctl.enable_mask); in rk_usb2phy_clk_set_gate()
213 SYSCON_WRITE_4(sc->grf, sc->regs->clk_ctl.offset, in rk_usb2phy_clk_set_gate()
214 sc->regs->clk_ctl.disable_mask); in rk_usb2phy_clk_set_gate()
219 rk_usb2phy_clk_recalc(struct clknode *clk, uint64_t *freq) in rk_usb2phy_clk_recalc() argument
242 phandle_t *cells, struct clknode **clk) in rk_usb2phy_clk_ofw_map() argument
248 *clk = clknode_find_by_id(clkdom, 0); in rk_usb2phy_clk_ofw_map()
250 if (*clk == NULL) in rk_usb2phy_clk_ofw_map()
262 struct clknode *clk; in rk_usb2phy_export_clock() local
268 node = ofw_bus_get_node(devsc->dev); in rk_usb2phy_export_clock()
271 "#clock-cells", &ncells); in rk_usb2phy_export_clock()
273 device_printf(devsc->dev, "couldn't find parent clock\n"); in rk_usb2phy_export_clock()
277 nclocks = ofw_bus_string_list_to_array(node, "clock-output-names", in rk_usb2phy_export_clock()
282 clkdom = clkdom_create(devsc->dev); in rk_usb2phy_export_clock()
290 error = clk_get_by_ofw_index(devsc->dev, 0, i, &clk_parent); in rk_usb2phy_export_clock()
292 device_printf(devsc->dev, "cannot get clock %d\n", error); in rk_usb2phy_export_clock()
300 clk = clknode_create(clkdom, &rk_usb2phy_clk_clknode_class, &def); in rk_usb2phy_export_clock()
301 if (clk == NULL) { in rk_usb2phy_export_clock()
302 device_printf(devsc->dev, "cannot create clknode\n"); in rk_usb2phy_export_clock()
306 sc = clknode_get_softc(clk); in rk_usb2phy_export_clock()
307 sc->clkdev = device_get_parent(devsc->dev); in rk_usb2phy_export_clock()
308 sc->grf = devsc->grf; in rk_usb2phy_export_clock()
309 sc->regs = (struct rk_usb2phy_regs *)ofw_bus_search_compatible(devsc->dev, compat_data)->ocd_data; in rk_usb2phy_export_clock()
310 if (sc->regs->clk_ctl.offset == 0) { in rk_usb2phy_export_clock()
312 sc->regs->clk_ctl.offset = regs[0]; in rk_usb2phy_export_clock()
314 clknode_register(clkdom, clk); in rk_usb2phy_export_clock()
317 device_printf(devsc->dev, "cannot finalize clkdom initialization\n"); in rk_usb2phy_export_clock()
334 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) in rk_usb2phy_probe()
351 sc->dev = dev; in rk_usb2phy_attach()
356 &sc->grf)) { in rk_usb2phy_attach()
357 device_printf(dev, "Cannot get syscon handle\n"); in rk_usb2phy_attach()
362 if (syscon_get_handle_default(dev, &sc->grf)) { in rk_usb2phy_attach()
363 device_printf(dev, "Cannot get syscon handle\n"); in rk_usb2phy_attach()
368 if (clk_get_by_ofw_name(dev, 0, "phyclk", &sc->clk) != 0) { in rk_usb2phy_attach()
372 err = clk_enable(sc->clk); in rk_usb2phy_attach()
375 clk_get_name(sc->clk)); in rk_usb2phy_attach()
385 host = ofw_bus_find_child(node, "host-port"); in rk_usb2phy_attach()
387 device_printf(dev, "Cannot find host-port child node\n"); in rk_usb2phy_attach()
392 device_printf(dev, "host-port isn't okay\n"); in rk_usb2phy_attach()
396 regulator_get_by_ofw_property(dev, host, "phy-supply", &sc->phy_supply); in rk_usb2phy_attach()