]> git.ipfire.org Git - thirdparty/u-boot.git/blame - drivers/clk/imx/clk-imx8.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[thirdparty/u-boot.git] / drivers / clk / imx / clk-imx8.c
CommitLineData
f77d4410
PF
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright 2018 NXP
4 * Peng Fan <peng.fan@nxp.com>
5 */
6
d678a59d 7#include <common.h>
f77d4410
PF
8#include <clk-uclass.h>
9#include <dm.h>
f7ae49fc 10#include <log.h>
336d4615 11#include <malloc.h>
99ac6c76 12#include <firmware/imx/sci/sci.h>
f77d4410
PF
13#include <asm/arch/clock.h>
14#include <dt-bindings/clock/imx8qxp-clock.h>
15#include <dt-bindings/soc/imx_rsrc.h>
16#include <misc.h>
17
98c63a78 18#include "clk-imx8.h"
f77d4410 19
98c63a78 20__weak ulong imx8_clk_get_rate(struct clk *clk)
f77d4410 21{
98c63a78 22 return 0;
f77d4410
PF
23}
24
98c63a78 25__weak ulong imx8_clk_set_rate(struct clk *clk, unsigned long rate)
f77d4410 26{
98c63a78 27 return 0;
f77d4410
PF
28}
29
98c63a78 30__weak int __imx8_clk_enable(struct clk *clk, bool enable)
f77d4410 31{
9042bf6f 32 return -EINVAL;
f77d4410
PF
33}
34
35static int imx8_clk_disable(struct clk *clk)
36{
37 return __imx8_clk_enable(clk, 0);
38}
39
40static int imx8_clk_enable(struct clk *clk)
41{
42 return __imx8_clk_enable(clk, 1);
43}
44
8dd86205 45#if IS_ENABLED(CONFIG_CMD_CLK)
bc3e313f 46static void imx8_clk_dump(struct udevice *dev)
f77d4410 47{
f77d4410
PF
48 struct clk clk;
49 unsigned long rate;
50 int i, ret;
51
f77d4410
PF
52 printf("Clk\t\tHz\n");
53
98c63a78 54 for (i = 0; i < num_clks; i++) {
f77d4410
PF
55 clk.id = imx8_clk_names[i].id;
56 ret = clk_request(dev, &clk);
57 if (ret < 0) {
58 debug("%s clk_request() failed: %d\n", __func__, ret);
59 continue;
60 }
61
62 ret = clk_get_rate(&clk);
63 rate = ret;
64
9042bf6f 65 if (ret == -EINVAL) {
f77d4410
PF
66 printf("clk ID %lu not supported yet\n",
67 imx8_clk_names[i].id);
68 continue;
69 }
70 if (ret < 0) {
71 printf("%s %lu: get_rate err: %d\n",
72 __func__, imx8_clk_names[i].id, ret);
73 continue;
74 }
75
76 printf("%s(%3lu):\t%lu\n",
77 imx8_clk_names[i].name, imx8_clk_names[i].id, rate);
78 }
f77d4410
PF
79}
80#endif
81
82static struct clk_ops imx8_clk_ops = {
83 .set_rate = imx8_clk_set_rate,
84 .get_rate = imx8_clk_get_rate,
85 .enable = imx8_clk_enable,
86 .disable = imx8_clk_disable,
bc3e313f
IP
87#if IS_ENABLED(CONFIG_CMD_CLK)
88 .dump = imx8_clk_dump,
89#endif
f77d4410
PF
90};
91
92static int imx8_clk_probe(struct udevice *dev)
93{
94 return 0;
95}
96
97static const struct udevice_id imx8_clk_ids[] = {
98 { .compatible = "fsl,imx8qxp-clk" },
e45efe90 99 { .compatible = "fsl,imx8qm-clk" },
f77d4410
PF
100 { },
101};
102
103U_BOOT_DRIVER(imx8_clk) = {
104 .name = "clk_imx8",
105 .id = UCLASS_CLK,
106 .of_match = imx8_clk_ids,
107 .ops = &imx8_clk_ops,
108 .probe = imx8_clk_probe,
109 .flags = DM_FLAG_PRE_RELOC,
110};