2 * Copyright (C) 2017 Álvaro Fernández Rojas <noltari@gmail.com>
4 * Derived from linux/arch/mips/bcm63xx/clk.c:
5 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
7 * SPDX-License-Identifier: GPL-2.0+
11 #include <clk-uclass.h>
18 struct bcm6345_clk_priv {
22 static int bcm6345_clk_enable(struct clk *clk)
24 struct bcm6345_clk_priv *priv = dev_get_priv(clk->dev);
26 if (clk->id >= MAX_CLKS)
29 setbits_be32(priv->regs, BIT(clk->id));
34 static int bcm6345_clk_disable(struct clk *clk)
36 struct bcm6345_clk_priv *priv = dev_get_priv(clk->dev);
38 if (clk->id >= MAX_CLKS)
41 clrbits_be32(priv->regs, BIT(clk->id));
46 static struct clk_ops bcm6345_clk_ops = {
47 .disable = bcm6345_clk_disable,
48 .enable = bcm6345_clk_enable,
51 static const struct udevice_id bcm6345_clk_ids[] = {
52 { .compatible = "brcm,bcm6345-clk" },
56 static int bcm63xx_clk_probe(struct udevice *dev)
58 struct bcm6345_clk_priv *priv = dev_get_priv(dev);
62 addr = devfdt_get_addr_size_index(dev, 0, &size);
63 if (addr == FDT_ADDR_T_NONE)
66 priv->regs = ioremap(addr, size);
71 U_BOOT_DRIVER(clk_bcm6345) = {
72 .name = "clk_bcm6345",
74 .of_match = bcm6345_clk_ids,
75 .ops = &bcm6345_clk_ops,
76 .probe = bcm63xx_clk_probe,
77 .priv_auto_alloc_size = sizeof(struct bcm6345_clk_priv),