2019-09-25 09:45:29 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 MediaTek Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Author: Weijie Gao <weijie.gao@mediatek.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <errno.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2020-02-03 14:36:16 +00:00
|
|
|
#include <malloc.h>
|
2019-09-25 09:45:29 +00:00
|
|
|
#include <reset-uclass.h>
|
2020-05-10 17:40:13 +00:00
|
|
|
#include <linux/bitops.h>
|
2019-09-25 09:45:29 +00:00
|
|
|
#include <linux/io.h>
|
|
|
|
|
|
|
|
struct mtmips_reset_priv {
|
|
|
|
void __iomem *base;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int mtmips_reset_assert(struct reset_ctl *reset_ctl)
|
|
|
|
{
|
|
|
|
struct mtmips_reset_priv *priv = dev_get_priv(reset_ctl->dev);
|
|
|
|
|
|
|
|
setbits_32(priv->base, BIT(reset_ctl->id));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mtmips_reset_deassert(struct reset_ctl *reset_ctl)
|
|
|
|
{
|
|
|
|
struct mtmips_reset_priv *priv = dev_get_priv(reset_ctl->dev);
|
|
|
|
|
|
|
|
clrbits_32(priv->base, BIT(reset_ctl->id));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct reset_ops mtmips_reset_ops = {
|
|
|
|
.rst_assert = mtmips_reset_assert,
|
|
|
|
.rst_deassert = mtmips_reset_deassert,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int mtmips_reset_probe(struct udevice *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-12-03 23:55:21 +00:00
|
|
|
static int mtmips_reset_of_to_plat(struct udevice *dev)
|
2019-09-25 09:45:29 +00:00
|
|
|
{
|
|
|
|
struct mtmips_reset_priv *priv = dev_get_priv(dev);
|
|
|
|
|
|
|
|
priv->base = (void __iomem *)dev_remap_addr_index(dev, 0);
|
|
|
|
if (!priv->base)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct udevice_id mtmips_reset_ids[] = {
|
|
|
|
{ .compatible = "mediatek,mtmips-reset" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(mtmips_reset) = {
|
|
|
|
.name = "mtmips-reset",
|
|
|
|
.id = UCLASS_RESET,
|
|
|
|
.of_match = mtmips_reset_ids,
|
2020-12-03 23:55:21 +00:00
|
|
|
.of_to_plat = mtmips_reset_of_to_plat,
|
2019-09-25 09:45:29 +00:00
|
|
|
.probe = mtmips_reset_probe,
|
2020-12-03 23:55:17 +00:00
|
|
|
.priv_auto = sizeof(struct mtmips_reset_priv),
|
2019-09-25 09:45:29 +00:00
|
|
|
.ops = &mtmips_reset_ops,
|
2020-11-12 08:37:14 +00:00
|
|
|
.flags = DM_FLAG_PRE_RELOC,
|
2019-09-25 09:45:29 +00:00
|
|
|
};
|