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