mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-11 05:42:58 +00:00
41575d8e4c
This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <sjg@chromium.org>
74 lines
1.4 KiB
C
74 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2017 Álvaro Fernández Rojas <noltari@gmail.com>
|
|
*
|
|
* Derived from linux/arch/mips/bcm63xx/clk.c:
|
|
* Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <clk-uclass.h>
|
|
#include <dm.h>
|
|
#include <errno.h>
|
|
#include <asm/io.h>
|
|
#include <linux/bitops.h>
|
|
|
|
#define MAX_CLKS 32
|
|
|
|
struct bcm6345_clk_priv {
|
|
void __iomem *regs;
|
|
};
|
|
|
|
static int bcm6345_clk_enable(struct clk *clk)
|
|
{
|
|
struct bcm6345_clk_priv *priv = dev_get_priv(clk->dev);
|
|
|
|
if (clk->id >= MAX_CLKS)
|
|
return -EINVAL;
|
|
|
|
setbits_be32(priv->regs, BIT(clk->id));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int bcm6345_clk_disable(struct clk *clk)
|
|
{
|
|
struct bcm6345_clk_priv *priv = dev_get_priv(clk->dev);
|
|
|
|
if (clk->id >= MAX_CLKS)
|
|
return -EINVAL;
|
|
|
|
clrbits_be32(priv->regs, BIT(clk->id));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct clk_ops bcm6345_clk_ops = {
|
|
.disable = bcm6345_clk_disable,
|
|
.enable = bcm6345_clk_enable,
|
|
};
|
|
|
|
static const struct udevice_id bcm6345_clk_ids[] = {
|
|
{ .compatible = "brcm,bcm6345-clk" },
|
|
{ /* sentinel */ }
|
|
};
|
|
|
|
static int bcm63xx_clk_probe(struct udevice *dev)
|
|
{
|
|
struct bcm6345_clk_priv *priv = dev_get_priv(dev);
|
|
|
|
priv->regs = dev_remap_addr(dev);
|
|
if (!priv->regs)
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
U_BOOT_DRIVER(clk_bcm6345) = {
|
|
.name = "clk_bcm6345",
|
|
.id = UCLASS_CLK,
|
|
.of_match = bcm6345_clk_ids,
|
|
.ops = &bcm6345_clk_ops,
|
|
.probe = bcm63xx_clk_probe,
|
|
.priv_auto = sizeof(struct bcm6345_clk_priv),
|
|
};
|