13
13
#define WDTRSTCR_RESET 0xA55A0002
14
14
#define WDTRSTCR 0x0054
15
15
16
+ #define CR7BAR 0x0070
17
+ #define CR7BAREN BIT(4)
18
+ #define CR7BAR_MASK 0xFFFC0000
19
+
20
+ static void __iomem * rcar_rst_base ;
21
+ static u32 saved_mode __initdata ;
22
+ static int (* rcar_rst_set_rproc_boot_addr_func )(u64 boot_addr );
23
+
16
24
static int rcar_rst_enable_wdt_reset (void __iomem * base )
17
25
{
18
26
iowrite32 (WDTRSTCR_RESET , base + WDTRSTCR );
19
27
return 0 ;
20
28
}
21
29
30
+ /*
31
+ * Most of the R-Car Gen3 SoCs have an ARM Realtime Core.
32
+ * Firmware boot address has to be set in CR7BAR before
33
+ * starting the realtime core.
34
+ * Boot address must be aligned on a 256k boundary.
35
+ */
36
+ static int rcar_rst_set_gen3_rproc_boot_addr (u64 boot_addr )
37
+ {
38
+ if (boot_addr & ~(u64 )CR7BAR_MASK ) {
39
+ pr_err ("Invalid boot address got %llx\n" , boot_addr );
40
+ return - EINVAL ;
41
+ }
42
+
43
+ iowrite32 (boot_addr , rcar_rst_base + CR7BAR );
44
+ iowrite32 (boot_addr | CR7BAREN , rcar_rst_base + CR7BAR );
45
+
46
+ return 0 ;
47
+ }
48
+
22
49
struct rst_config {
23
50
unsigned int modemr ; /* Mode Monitoring Register Offset */
24
51
int (* configure )(void __iomem * base ); /* Platform specific config */
52
+ int (* set_rproc_boot_addr )(u64 boot_addr );
25
53
};
26
54
27
55
static const struct rst_config rcar_rst_gen1 __initconst = {
@@ -35,6 +63,7 @@ static const struct rst_config rcar_rst_gen2 __initconst = {
35
63
36
64
static const struct rst_config rcar_rst_gen3 __initconst = {
37
65
.modemr = 0x60 ,
66
+ .set_rproc_boot_addr = rcar_rst_set_gen3_rproc_boot_addr ,
38
67
};
39
68
40
69
static const struct rst_config rcar_rst_r8a779a0 __initconst = {
@@ -76,9 +105,6 @@ static const struct of_device_id rcar_rst_matches[] __initconst = {
76
105
{ /* sentinel */ }
77
106
};
78
107
79
- static void __iomem * rcar_rst_base __initdata ;
80
- static u32 saved_mode __initdata ;
81
-
82
108
static int __init rcar_rst_init (void )
83
109
{
84
110
const struct of_device_id * match ;
@@ -100,6 +126,8 @@ static int __init rcar_rst_init(void)
100
126
101
127
rcar_rst_base = base ;
102
128
cfg = match -> data ;
129
+ rcar_rst_set_rproc_boot_addr_func = cfg -> set_rproc_boot_addr ;
130
+
103
131
saved_mode = ioread32 (base + cfg -> modemr );
104
132
if (cfg -> configure ) {
105
133
error = cfg -> configure (base );
@@ -130,3 +158,12 @@ int __init rcar_rst_read_mode_pins(u32 *mode)
130
158
* mode = saved_mode ;
131
159
return 0 ;
132
160
}
161
+
162
+ int rcar_rst_set_rproc_boot_addr (u64 boot_addr )
163
+ {
164
+ if (!rcar_rst_set_rproc_boot_addr_func )
165
+ return - EIO ;
166
+
167
+ return rcar_rst_set_rproc_boot_addr_func (boot_addr );
168
+ }
169
+ EXPORT_SYMBOL_GPL (rcar_rst_set_rproc_boot_addr );
0 commit comments