mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-27 07:01:24 +00:00
b2424cd2f4
1. Rename AST2500 reset driver from ast2500-reset.c to reset-ast2500.c 2. Rename AST2500 reset kconfig option from AST2500_RESET to RESET_AST2500 Signed-off-by: Chia-Wei, Wang <chiawei_wang@aspeedtech.com> Reviewed-by: Ryan Chen <ryan_chen@aspeedtech.com>
109 lines
2.5 KiB
C
109 lines
2.5 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright 2017 Google, Inc
|
|
* Copyright 2020 ASPEED Technology Inc.
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <log.h>
|
|
#include <misc.h>
|
|
#include <reset.h>
|
|
#include <reset-uclass.h>
|
|
#include <linux/err.h>
|
|
#include <asm/io.h>
|
|
#include <asm/arch/scu_ast2500.h>
|
|
|
|
struct ast2500_reset_priv {
|
|
struct ast2500_scu *scu;
|
|
};
|
|
|
|
static int ast2500_reset_request(struct reset_ctl *reset_ctl)
|
|
{
|
|
debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
|
|
reset_ctl->dev, reset_ctl->id);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ast2500_reset_free(struct reset_ctl *reset_ctl)
|
|
{
|
|
debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
|
|
reset_ctl->dev, reset_ctl->id);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ast2500_reset_assert(struct reset_ctl *reset_ctl)
|
|
{
|
|
struct ast2500_reset_priv *priv = dev_get_priv(reset_ctl->dev);
|
|
struct ast2500_scu *scu = priv->scu;
|
|
|
|
debug("%s: reset_ctl->id: %lu\n", __func__, reset_ctl->id);
|
|
|
|
if (reset_ctl->id < 32)
|
|
setbits_le32(&scu->sysreset_ctrl1, BIT(reset_ctl->id));
|
|
else
|
|
setbits_le32(&scu->sysreset_ctrl2, BIT(reset_ctl->id - 32));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ast2500_reset_deassert(struct reset_ctl *reset_ctl)
|
|
{
|
|
struct ast2500_reset_priv *priv = dev_get_priv(reset_ctl->dev);
|
|
struct ast2500_scu *scu = priv->scu;
|
|
|
|
debug("%s: reset_ctl->id: %lu\n", __func__, reset_ctl->id);
|
|
|
|
if (reset_ctl->id < 32)
|
|
clrbits_le32(&scu->sysreset_ctrl1, BIT(reset_ctl->id));
|
|
else
|
|
clrbits_le32(&scu->sysreset_ctrl2, BIT(reset_ctl->id - 32));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ast2500_reset_probe(struct udevice *dev)
|
|
{
|
|
int rc;
|
|
struct ast2500_reset_priv *priv = dev_get_priv(dev);
|
|
struct udevice *scu_dev;
|
|
|
|
/* get SCU base from clock device */
|
|
rc = uclass_get_device_by_driver(UCLASS_CLK,
|
|
DM_GET_DRIVER(aspeed_ast2500_scu), &scu_dev);
|
|
if (rc) {
|
|
debug("%s: clock device not found, rc=%d\n", __func__, rc);
|
|
return rc;
|
|
}
|
|
|
|
priv->scu = devfdt_get_addr_ptr(scu_dev);
|
|
if (IS_ERR_OR_NULL(priv->scu)) {
|
|
debug("%s: invalid SCU base pointer\n", __func__);
|
|
return PTR_ERR(priv->scu);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct udevice_id ast2500_reset_ids[] = {
|
|
{ .compatible = "aspeed,ast2500-reset" },
|
|
{ }
|
|
};
|
|
|
|
struct reset_ops ast2500_reset_ops = {
|
|
.request = ast2500_reset_request,
|
|
.rfree = ast2500_reset_free,
|
|
.rst_assert = ast2500_reset_assert,
|
|
.rst_deassert = ast2500_reset_deassert,
|
|
};
|
|
|
|
U_BOOT_DRIVER(ast2500_reset) = {
|
|
.name = "ast2500_reset",
|
|
.id = UCLASS_RESET,
|
|
.of_match = ast2500_reset_ids,
|
|
.probe = ast2500_reset_probe,
|
|
.ops = &ast2500_reset_ops,
|
|
.priv_auto_alloc_size = sizeof(struct ast2500_reset_priv),
|
|
};
|