1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2019 DENX Software Engineering
4 * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
8 #include <clk-uclass.h>
10 #include <dm/device.h>
11 #include <dm/uclass.h>
13 #include <dm/device-internal.h>
16 int clk_register(struct clk *clk, const char *drv_name,
17 const char *name, const char *parent_name)
19 struct udevice *parent;
23 ret = uclass_get_device_by_name(UCLASS_CLK, parent_name, &parent);
25 printf("%s: failed to get %s device (parent of %s)\n",
26 __func__, parent_name, name);
28 debug("%s: name: %s parent: %s [0x%p]\n", __func__, name,
29 parent->name, parent);
32 drv = lists_driver_lookup_name(drv_name);
34 printf("%s: %s is not a valid driver name\n",
39 ret = device_bind(parent, drv, name, NULL, -1, &clk->dev);
41 printf("%s: CLK: %s driver bind error [%d]!\n", __func__, name,
46 clk->enable_count = 0;
47 /* Store back pointer to clk from udevice */
48 clk->dev->uclass_priv = clk;
53 ulong clk_generic_get_rate(struct clk *clk)
55 return clk_get_parent_rate(clk);
58 const char *clk_hw_get_name(const struct clk *hw)
63 bool clk_dev_binded(struct clk *clk)
65 if (clk->dev && (clk->dev->flags & DM_FLAG_BOUND))