blob: f88167ba4cbae9a9face8b3146841015e89ad4c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2013 Oleksij Rempel <linux@rempel-privat.de>
*/
#include <common.h>
#include <init.h>
#include <io.h>
#include <restart.h>
#include <linux/err.h>
#include <mach/ar2312_regs.h>
#include <mach/ar231x_platform.h>
static void __iomem *reset_base;
static void __noreturn ar2312x_restart_soc(struct restart_handler *rst)
{
printf("reseting cpu\n");
__raw_writel(0x10000,
(char *)KSEG1ADDR(AR2312_WD_TIMER));
__raw_writel(AR2312_WD_CTRL_RESET,
(char *)KSEG1ADDR(AR2312_WD_CTRL));
hang();
}
static u32 ar231x_reset_readl(void)
{
return __raw_readl(reset_base);
}
static void ar231x_reset_writel(u32 val)
{
__raw_writel(val, reset_base);
}
void ar231x_reset_bit(u32 val, enum reset_state state)
{
u32 tmp;
tmp = ar231x_reset_readl();
if (state == REMOVE)
ar231x_reset_writel(tmp & ~val);
else
ar231x_reset_writel(tmp | val);
}
EXPORT_SYMBOL(ar231x_reset_bit);
static int ar231x_reset_probe(struct device_d *dev)
{
struct resource *iores;
iores = dev_request_mem_resource(dev, 0);
if (IS_ERR(iores)) {
dev_err(dev, "could not get memory region\n");
return PTR_ERR(iores);
}
reset_base = IOMEM(iores->start);
return 0;
}
static struct driver_d ar231x_reset_driver = {
.probe = ar231x_reset_probe,
.name = "ar231x_reset",
};
static int ar231x_reset_init(void)
{
restart_handler_register_fn(ar2312x_restart_soc);
return platform_driver_register(&ar231x_reset_driver);
}
coredevice_initcall(ar231x_reset_init);
|