blob: 1f385665ccbbde9a326eaa0f340d9a60607b3f83 [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 *
Robert Markoda344232020-10-08 22:05:10 +02005 * Copyright (c) 2020 Sartura Ltd.
Robert Markoe7a34f12020-07-06 10:37:54 +02006 *
7 * Author: Robert Marko <robert.marko@sartura.hr>
8 *
9 */
10
Robert Markoe7a34f12020-07-06 10:37:54 +020011#include <clk-uclass.h>
Robert Marko0260c082020-10-28 13:56:23 +010012#include <common.h>
Robert Markoe7a34f12020-07-06 10:37:54 +020013#include <dm.h>
14#include <errno.h>
15
Robert Marko06d29002020-09-10 16:00:00 +020016#include <dt-bindings/clock/qcom,ipq4019-gcc.h>
17
Robert Markoe7a34f12020-07-06 10:37:54 +020018struct msm_clk_priv {
19 phys_addr_t base;
20};
21
22ulong msm_set_rate(struct clk *clk, ulong rate)
23{
24 switch (clk->id) {
Robert Marko06d29002020-09-10 16:00:00 +020025 case GCC_BLSP1_UART1_APPS_CLK: /*UART1*/
Robert Markoe7a34f12020-07-06 10:37:54 +020026 /* This clock is already initialized by SBL1 */
Robert Markoda344232020-10-08 22:05:10 +020027 return 0;
Robert Markoe7a34f12020-07-06 10:37:54 +020028 break;
29 default:
30 return 0;
31 }
32}
33
34static int msm_clk_probe(struct udevice *dev)
35{
36 struct msm_clk_priv *priv = dev_get_priv(dev);
37
Robert Marko0260c082020-10-28 13:56:23 +010038 priv->base = dev_read_addr(dev);
Robert Markoe7a34f12020-07-06 10:37:54 +020039 if (priv->base == FDT_ADDR_T_NONE)
40 return -EINVAL;
41
42 return 0;
43}
44
45static ulong msm_clk_set_rate(struct clk *clk, ulong rate)
46{
47 return msm_set_rate(clk, rate);
48}
49
Robert Markoda344232020-10-08 22:05:10 +020050static int msm_enable(struct clk *clk)
51{
52 switch (clk->id) {
53 case GCC_BLSP1_QUP1_SPI_APPS_CLK: /*SPI1*/
54 /* This clock is already initialized by SBL1 */
55 return 0;
56 break;
Robert Marko16b5a962020-10-08 22:05:14 +020057 case GCC_PRNG_AHB_CLK: /*PRNG*/
58 /* This clock is already initialized by SBL1 */
59 return 0;
60 break;
Robert Markoda344232020-10-08 22:05:10 +020061 default:
62 return 0;
63 }
64}
65
Robert Markoe7a34f12020-07-06 10:37:54 +020066static struct clk_ops msm_clk_ops = {
67 .set_rate = msm_clk_set_rate,
Robert Markoda344232020-10-08 22:05:10 +020068 .enable = msm_enable,
Robert Markoe7a34f12020-07-06 10:37:54 +020069};
70
71static const struct udevice_id msm_clk_ids[] = {
72 { .compatible = "qcom,gcc-ipq4019" },
73 { }
74};
75
76U_BOOT_DRIVER(clk_msm) = {
77 .name = "clk_msm",
78 .id = UCLASS_CLK,
79 .of_match = msm_clk_ids,
80 .ops = &msm_clk_ops,
81 .priv_auto_alloc_size = sizeof(struct msm_clk_priv),
82 .probe = msm_clk_probe,
83};