1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com>
7 #include <clk-uclass.h>
10 struct clk_fixed_rate {
11 unsigned long fixed_rate;
14 #define to_clk_fixed_rate(dev) ((struct clk_fixed_rate *)dev_get_platdata(dev))
16 static ulong clk_fixed_rate_get_rate(struct clk *clk)
21 return to_clk_fixed_rate(clk->dev)->fixed_rate;
24 const struct clk_ops clk_fixed_rate_ops = {
25 .get_rate = clk_fixed_rate_get_rate,
28 static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev)
30 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
31 to_clk_fixed_rate(dev)->fixed_rate =
32 dev_read_u32_default(dev, "clock-frequency", 0);
38 static const struct udevice_id clk_fixed_rate_match[] = {
40 .compatible = "fixed-clock",
45 U_BOOT_DRIVER(clk_fixed_rate) = {
46 .name = "fixed_rate_clock",
48 .of_match = clk_fixed_rate_match,
49 .ofdata_to_platdata = clk_fixed_rate_ofdata_to_platdata,
50 .platdata_auto_alloc_size = sizeof(struct clk_fixed_rate),
51 .ops = &clk_fixed_rate_ops,