Padmarao Begari | 0c4ae80 | 2021-01-15 08:20:38 +0530 | [diff] [blame] | 1 | // 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 Begari | 0c4ae80 | 2021-01-15 08:20:38 +0530 | [diff] [blame] | 18 | static 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 Begari | 0c4ae80 | 2021-01-15 08:20:38 +0530 | [diff] [blame] | 46 | static const struct udevice_id mpfs_of_match[] = { |
| 47 | { .compatible = "microchip,mpfs-clkcfg" }, |
| 48 | { } |
| 49 | }; |
| 50 | |
| 51 | U_BOOT_DRIVER(mpfs_clk) = { |
| 52 | .name = "mpfs_clk", |
| 53 | .id = UCLASS_CLK, |
| 54 | .of_match = mpfs_of_match, |
Sean Anderson | 35c8464 | 2022-03-20 16:34:46 -0400 | [diff] [blame] | 55 | .ops = &ccf_clk_ops, |
Padmarao Begari | 0c4ae80 | 2021-01-15 08:20:38 +0530 | [diff] [blame] | 56 | .probe = mpfs_clk_probe, |
| 57 | .priv_auto = sizeof(struct clk), |
Bin Meng | 3ff5d69 | 2021-03-31 15:24:49 +0800 | [diff] [blame] | 58 | .flags = DM_FLAG_PRE_RELOC, |
Padmarao Begari | 0c4ae80 | 2021-01-15 08:20:38 +0530 | [diff] [blame] | 59 | }; |