]> Git Repo - u-boot.git/blame - drivers/clk/clk_fixed_rate.c
Merge tag 'dm-pull-14dec20' of git://git.denx.de/u-boot-dm into next
[u-boot.git] / drivers / clk / clk_fixed_rate.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
b21e20b2
MY
2/*
3 * Copyright (C) 2016 Masahiro Yamada <[email protected]>
b21e20b2
MY
4 */
5
6#include <common.h>
135aa950 7#include <clk-uclass.h>
9d922450 8#include <dm.h>
4f305bf1 9#include <linux/clk-provider.h>
b21e20b2 10
135aa950 11static ulong clk_fixed_rate_get_rate(struct clk *clk)
b21e20b2 12{
135aa950 13 return to_clk_fixed_rate(clk->dev)->fixed_rate;
b21e20b2
MY
14}
15
6bf6d81c
CY
16/* avoid clk_enable() return -ENOSYS */
17static int dummy_enable(struct clk *clk)
18{
19 return 0;
20}
21
b21e20b2
MY
22const struct clk_ops clk_fixed_rate_ops = {
23 .get_rate = clk_fixed_rate_get_rate,
6bf6d81c 24 .enable = dummy_enable,
b21e20b2
MY
25};
26
d1998a9f 27static int clk_fixed_rate_of_to_plat(struct udevice *dev)
b21e20b2 28{
36bac0a1 29 struct clk *clk = &to_clk_fixed_rate(dev)->clk;
7423daa6 30#if !CONFIG_IS_ENABLED(OF_PLATDATA)
e2db9e7a
MS
31 to_clk_fixed_rate(dev)->fixed_rate =
32 dev_read_u32_default(dev, "clock-frequency", 0);
7423daa6 33#endif
36bac0a1
LM
34 /* Make fixed rate clock accessible from higher level struct clk */
35 dev->uclass_priv = clk;
36 clk->dev = dev;
e6849e2f 37 clk->enable_count = 0;
b21e20b2
MY
38
39 return 0;
40}
41
42static const struct udevice_id clk_fixed_rate_match[] = {
43 {
44 .compatible = "fixed-clock",
45 },
46 { /* sentinel */ }
47};
48
88280529
SG
49U_BOOT_DRIVER(fixed_clock) = {
50 .name = "fixed_clock",
b21e20b2
MY
51 .id = UCLASS_CLK,
52 .of_match = clk_fixed_rate_match,
d1998a9f 53 .of_to_plat = clk_fixed_rate_of_to_plat,
caa4daa2 54 .plat_auto = sizeof(struct clk_fixed_rate),
b21e20b2 55 .ops = &clk_fixed_rate_ops,
4ab3817f 56 .flags = DM_FLAG_PRE_RELOC,
b21e20b2 57};
This page took 0.167649 seconds and 4 git commands to generate.