blob: 7cf98a203c2fc66154208645433967f04366b6b7 [file] [log] [blame]
Robert Markoe7a34f12020-07-06 10:37:54 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Clock drivers for Qualcomm IPQ40xx
4 *
5 * Copyright (c) 2019 Sartura Ltd.
6 *
7 * Author: Robert Marko <robert.marko@sartura.hr>
8 *
9 */
10
11#include <common.h>
12#include <clk-uclass.h>
13#include <dm.h>
14#include <errno.h>
15
16struct msm_clk_priv {
17 phys_addr_t base;
18};
19
20ulong msm_set_rate(struct clk *clk, ulong rate)
21{
22 switch (clk->id) {
23 case 26: /*UART1*/
24 /* This clock is already initialized by SBL1 */
25 return 0;
26 break;
27 default:
28 return 0;
29 }
30}
31
32static int msm_clk_probe(struct udevice *dev)
33{
34 struct msm_clk_priv *priv = dev_get_priv(dev);
35
36 priv->base = devfdt_get_addr(dev);
37 if (priv->base == FDT_ADDR_T_NONE)
38 return -EINVAL;
39
40 return 0;
41}
42
43static ulong msm_clk_set_rate(struct clk *clk, ulong rate)
44{
45 return msm_set_rate(clk, rate);
46}
47
48static struct clk_ops msm_clk_ops = {
49 .set_rate = msm_clk_set_rate,
50};
51
52static const struct udevice_id msm_clk_ids[] = {
53 { .compatible = "qcom,gcc-ipq4019" },
54 { }
55};
56
57U_BOOT_DRIVER(clk_msm) = {
58 .name = "clk_msm",
59 .id = UCLASS_CLK,
60 .of_match = msm_clk_ids,
61 .ops = &msm_clk_ops,
62 .priv_auto_alloc_size = sizeof(struct msm_clk_priv),
63 .probe = msm_clk_probe,
64};