2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-05-07 18:28:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Álvaro Fernández Rojas <noltari@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
2020-02-03 14:36:16 +00:00
|
|
|
#include <malloc.h>
|
2017-05-07 18:28:36 +00:00
|
|
|
#include <power-domain-uclass.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
#define MAX_DOMAINS 32
|
|
|
|
|
|
|
|
struct bcm6328_power_domain {
|
|
|
|
void __iomem *regs;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int bcm6328_power_domain_request(struct power_domain *power_domain)
|
|
|
|
{
|
|
|
|
if (power_domain->id >= MAX_DOMAINS)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bcm6328_power_domain_free(struct power_domain *power_domain)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bcm6328_power_domain_on(struct power_domain *power_domain)
|
|
|
|
{
|
|
|
|
struct bcm6328_power_domain *priv = dev_get_priv(power_domain->dev);
|
|
|
|
|
|
|
|
clrbits_be32(priv->regs, BIT(power_domain->id));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bcm6328_power_domain_off(struct power_domain *power_domain)
|
|
|
|
{
|
|
|
|
struct bcm6328_power_domain *priv = dev_get_priv(power_domain->dev);
|
|
|
|
|
|
|
|
setbits_be32(priv->regs, BIT(power_domain->id));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bcm6328_power_domain_probe(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct bcm6328_power_domain *priv = dev_get_priv(dev);
|
|
|
|
|
2018-03-22 18:39:35 +00:00
|
|
|
priv->regs = dev_remap_addr(dev);
|
|
|
|
if (!priv->regs)
|
2017-05-07 18:28:36 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct udevice_id bcm6328_power_domain_ids[] = {
|
|
|
|
{ .compatible = "brcm,bcm6328-power-domain" },
|
|
|
|
{ /* sentinel */ }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct power_domain_ops bcm6328_power_domain_ops = {
|
2020-02-03 14:35:51 +00:00
|
|
|
.rfree = bcm6328_power_domain_free,
|
2017-05-07 18:28:36 +00:00
|
|
|
.off = bcm6328_power_domain_off,
|
|
|
|
.on = bcm6328_power_domain_on,
|
|
|
|
.request = bcm6328_power_domain_request,
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(bcm6328_power_domain) = {
|
|
|
|
.name = "bcm6328_power_domain",
|
|
|
|
.id = UCLASS_POWER_DOMAIN,
|
|
|
|
.of_match = bcm6328_power_domain_ids,
|
|
|
|
.ops = &bcm6328_power_domain_ops,
|
|
|
|
.priv_auto_alloc_size = sizeof(struct bcm6328_power_domain),
|
|
|
|
.probe = bcm6328_power_domain_probe,
|
|
|
|
};
|