blob: 67828c9bf404deb426b70d7d7b1cf21f103165a6 [file] [log] [blame]
Padmarao Begari0c4ae802021-01-15 08:20:38 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2020 Microchip Technology Inc.
4 * Padmarao Begari <padmarao.begari@microchip.com>
5 */
6#include <common.h>
7#include <clk.h>
8#include <clk-uclass.h>
9#include <dm.h>
10#include <log.h>
11#include <dm/device.h>
12#include <dm/devres.h>
13#include <dm/uclass.h>
14#include <linux/err.h>
15
16#include "mpfs_clk.h"
17
Padmarao Begari0c4ae802021-01-15 08:20:38 +053018static int mpfs_clk_probe(struct udevice *dev)
19{
20 int ret;
21 void __iomem *base;
22 u32 clk_rate;
23 const char *parent_clk_name;
24 struct clk *clk = dev_get_priv(dev);
25
26 base = dev_read_addr_ptr(dev);
27 if (!base)
28 return -EINVAL;
29
30 ret = clk_get_by_index(dev, 0, clk);
31 if (ret)
32 return ret;
33
34 dev_read_u32(clk->dev, "clock-frequency", &clk_rate);
35 parent_clk_name = clk->dev->name;
36
37 ret = mpfs_clk_register_cfgs(base, clk_rate, parent_clk_name);
38 if (ret)
39 return ret;
40
41 ret = mpfs_clk_register_periphs(base, clk_rate, "clk_ahb");
42
43 return ret;
44}
45
Padmarao Begari0c4ae802021-01-15 08:20:38 +053046static const struct udevice_id mpfs_of_match[] = {
47 { .compatible = "microchip,mpfs-clkcfg" },
48 { }
49};
50
51U_BOOT_DRIVER(mpfs_clk) = {
52 .name = "mpfs_clk",
53 .id = UCLASS_CLK,
54 .of_match = mpfs_of_match,
Sean Anderson35c84642022-03-20 16:34:46 -040055 .ops = &ccf_clk_ops,
Padmarao Begari0c4ae802021-01-15 08:20:38 +053056 .probe = mpfs_clk_probe,
57 .priv_auto = sizeof(struct clk),
Bin Meng3ff5d692021-03-31 15:24:49 +080058 .flags = DM_FLAG_PRE_RELOC,
Padmarao Begari0c4ae802021-01-15 08:20:38 +053059};