2019-07-15 19:47:53 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Pepperl+Fuchs
|
|
|
|
* Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sysreset.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/reset_manager.h>
|
2020-05-10 17:40:13 +00:00
|
|
|
#include <linux/bitops.h>
|
2019-07-15 19:47:53 +00:00
|
|
|
|
|
|
|
struct socfpga_sysreset_data {
|
2019-11-08 02:38:19 +00:00
|
|
|
void __iomem *rstmgr_base;
|
2019-07-15 19:47:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int socfpga_sysreset_request(struct udevice *dev,
|
|
|
|
enum sysreset_t type)
|
|
|
|
{
|
|
|
|
struct socfpga_sysreset_data *data = dev_get_priv(dev);
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case SYSRESET_WARM:
|
|
|
|
writel(BIT(RSTMGR_CTRL_SWWARMRSTREQ_LSB),
|
2019-11-08 02:38:19 +00:00
|
|
|
data->rstmgr_base + RSTMGR_CTRL);
|
2019-07-15 19:47:53 +00:00
|
|
|
break;
|
|
|
|
case SYSRESET_COLD:
|
|
|
|
writel(BIT(RSTMGR_CTRL_SWCOLDRSTREQ_LSB),
|
2019-11-08 02:38:19 +00:00
|
|
|
data->rstmgr_base + RSTMGR_CTRL);
|
2019-07-15 19:47:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EPROTONOSUPPORT;
|
|
|
|
}
|
|
|
|
return -EINPROGRESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int socfpga_sysreset_probe(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct socfpga_sysreset_data *data = dev_get_priv(dev);
|
|
|
|
|
2020-08-04 05:14:43 +00:00
|
|
|
data->rstmgr_base = dev_read_addr_ptr(dev);
|
2019-07-15 19:47:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct sysreset_ops socfpga_sysreset = {
|
|
|
|
.request = socfpga_sysreset_request,
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(sysreset_socfpga) = {
|
|
|
|
.id = UCLASS_SYSRESET,
|
|
|
|
.name = "socfpga_sysreset",
|
2020-12-03 23:55:17 +00:00
|
|
|
.priv_auto = sizeof(struct socfpga_sysreset_data),
|
2019-07-15 19:47:53 +00:00
|
|
|
.ops = &socfpga_sysreset,
|
|
|
|
.probe = socfpga_sysreset_probe,
|
|
|
|
};
|