2 * (C) Copyright 2015 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0
13 struct sandbox_clk_priv {
15 ulong periph_rate[PERIPH_ID_COUNT];
18 static ulong sandbox_clk_get_rate(struct udevice *dev)
20 struct sandbox_clk_priv *priv = dev_get_priv(dev);
25 static ulong sandbox_clk_set_rate(struct udevice *dev, ulong rate)
27 struct sandbox_clk_priv *priv = dev_get_priv(dev);
35 static ulong sandbox_get_periph_rate(struct udevice *dev, int periph)
37 struct sandbox_clk_priv *priv = dev_get_priv(dev);
39 if (periph < PERIPH_ID_FIRST || periph >= PERIPH_ID_COUNT)
41 return priv->periph_rate[periph];
44 static ulong sandbox_set_periph_rate(struct udevice *dev, int periph,
47 struct sandbox_clk_priv *priv = dev_get_priv(dev);
50 if (periph < PERIPH_ID_FIRST || periph >= PERIPH_ID_COUNT)
52 old_rate = priv->periph_rate[periph];
53 priv->periph_rate[periph] = rate;
58 static int sandbox_clk_probe(struct udevice *dev)
60 struct sandbox_clk_priv *priv = dev_get_priv(dev);
62 priv->rate = SANDBOX_CLK_RATE;
67 static struct clk_ops sandbox_clk_ops = {
68 .get_rate = sandbox_clk_get_rate,
69 .set_rate = sandbox_clk_set_rate,
70 .get_periph_rate = sandbox_get_periph_rate,
71 .set_periph_rate = sandbox_set_periph_rate,
74 static const struct udevice_id sandbox_clk_ids[] = {
75 { .compatible = "sandbox,clk" },
79 U_BOOT_DRIVER(clk_sandbox) = {
80 .name = "clk_sandbox",
82 .of_match = sandbox_clk_ids,
83 .ops = &sandbox_clk_ops,
84 .priv_auto_alloc_size = sizeof(struct sandbox_clk_priv),
85 .probe = sandbox_clk_probe,