1 // SPDX-License-Identifier: GPL-2.0
4 * Peng Fan <peng.fan@nxp.com>
8 #include <clk-uclass.h>
10 #include <asm/arch/sci/sci.h>
11 #include <asm/arch/clock.h>
12 #include <dt-bindings/clock/imx8qxp-clock.h>
13 #include <dt-bindings/soc/imx_rsrc.h>
18 __weak ulong imx8_clk_get_rate(struct clk *clk)
23 __weak ulong imx8_clk_set_rate(struct clk *clk, unsigned long rate)
28 __weak int __imx8_clk_enable(struct clk *clk, bool enable)
33 static int imx8_clk_disable(struct clk *clk)
35 return __imx8_clk_enable(clk, 0);
38 static int imx8_clk_enable(struct clk *clk)
40 return __imx8_clk_enable(clk, 1);
43 #if CONFIG_IS_ENABLED(CMD_CLK)
44 int soc_clk_dump(void)
51 ret = uclass_get_device_by_driver(UCLASS_CLK,
52 DM_GET_DRIVER(imx8_clk), &dev);
56 printf("Clk\t\tHz\n");
58 for (i = 0; i < num_clks; i++) {
59 clk.id = imx8_clk_names[i].id;
60 ret = clk_request(dev, &clk);
62 debug("%s clk_request() failed: %d\n", __func__, ret);
66 ret = clk_get_rate(&clk);
71 if (ret == -ENOTSUPP) {
72 printf("clk ID %lu not supported yet\n",
73 imx8_clk_names[i].id);
77 printf("%s %lu: get_rate err: %d\n",
78 __func__, imx8_clk_names[i].id, ret);
82 printf("%s(%3lu):\t%lu\n",
83 imx8_clk_names[i].name, imx8_clk_names[i].id, rate);
90 static struct clk_ops imx8_clk_ops = {
91 .set_rate = imx8_clk_set_rate,
92 .get_rate = imx8_clk_get_rate,
93 .enable = imx8_clk_enable,
94 .disable = imx8_clk_disable,
97 static int imx8_clk_probe(struct udevice *dev)
102 static const struct udevice_id imx8_clk_ids[] = {
103 { .compatible = "fsl,imx8qxp-clk" },
104 { .compatible = "fsl,imx8qm-clk" },
108 U_BOOT_DRIVER(imx8_clk) = {
111 .of_match = imx8_clk_ids,
112 .ops = &imx8_clk_ops,
113 .probe = imx8_clk_probe,
114 .flags = DM_FLAG_PRE_RELOC,