1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com>
7 #include <clk-uclass.h>
9 #include <linux/clk-provider.h>
11 static ulong clk_fixed_rate_get_rate(struct clk *clk)
13 return to_clk_fixed_rate(clk->dev)->fixed_rate;
16 const struct clk_ops clk_fixed_rate_ops = {
17 .get_rate = clk_fixed_rate_get_rate,
20 static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev)
22 struct clk *clk = &to_clk_fixed_rate(dev)->clk;
23 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
24 to_clk_fixed_rate(dev)->fixed_rate =
25 dev_read_u32_default(dev, "clock-frequency", 0);
27 /* Make fixed rate clock accessible from higher level struct clk */
28 dev->uclass_priv = clk;
30 clk->enable_count = 0;
35 static const struct udevice_id clk_fixed_rate_match[] = {
37 .compatible = "fixed-clock",
42 U_BOOT_DRIVER(clk_fixed_rate) = {
43 .name = "fixed_rate_clock",
45 .of_match = clk_fixed_rate_match,
46 .ofdata_to_platdata = clk_fixed_rate_ofdata_to_platdata,
47 .platdata_auto_alloc_size = sizeof(struct clk_fixed_rate),
48 .ops = &clk_fixed_rate_ops,