Skip to content

Commit 8b69ca3

Browse files
Wolfram Sanggeertu
authored andcommitted
clk: renesas: r9a06g032: Add restart handler
The SYSCTRL module also does reset handling. Start supporting that by allowing software resets which can then be utilized by a restart handler. Finally 'reboot' will do something useful on RZ/N1D. Watchdog support to be added later. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/20241128091113.24116-2-wsa+renesas@sang-engineering.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
1 parent b734350 commit 8b69ca3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

drivers/clk/renesas/r9a06g032-clocks.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/platform_device.h>
2121
#include <linux/pm_clock.h>
2222
#include <linux/pm_domain.h>
23+
#include <linux/reboot.h>
2324
#include <linux/slab.h>
2425
#include <linux/soc/renesas/r9a06g032-sysctrl.h>
2526
#include <linux/spinlock.h>
@@ -29,6 +30,14 @@
2930
#define R9A06G032_SYSCTRL_USB_H2MODE (1<<1)
3031
#define R9A06G032_SYSCTRL_DMAMUX 0xA0
3132

33+
#define R9A06G032_SYSCTRL_RSTEN 0x120
34+
#define R9A06G032_SYSCTRL_RSTEN_MRESET_EN BIT(0)
35+
#define R9A06G032_SYSCTRL_RSTCTRL 0x198
36+
/* These work for both reset registers */
37+
#define R9A06G032_SYSCTRL_SWRST BIT(6)
38+
#define R9A06G032_SYSCTRL_WDA7RST_1 BIT(2)
39+
#define R9A06G032_SYSCTRL_WDA7RST_0 BIT(1)
40+
3241
/**
3342
* struct regbit - describe one bit in a register
3443
* @reg: offset of register relative to base address,
@@ -1270,6 +1279,12 @@ static void r9a06g032_clocks_del_clk_provider(void *data)
12701279
of_clk_del_provider(data);
12711280
}
12721281

1282+
static int r9a06g032_restart_handler(struct sys_off_data *data)
1283+
{
1284+
writel(R9A06G032_SYSCTRL_SWRST, sysctrl_priv->reg + R9A06G032_SYSCTRL_RSTCTRL);
1285+
return NOTIFY_DONE;
1286+
}
1287+
12731288
static void __init r9a06g032_init_h2mode(struct r9a06g032_priv *clocks)
12741289
{
12751290
struct device_node *usbf_np;
@@ -1324,6 +1339,18 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev)
13241339

13251340
r9a06g032_init_h2mode(clocks);
13261341

1342+
/* Clear potentially pending resets */
1343+
writel(R9A06G032_SYSCTRL_WDA7RST_0 | R9A06G032_SYSCTRL_WDA7RST_1,
1344+
clocks->reg + R9A06G032_SYSCTRL_RSTCTRL);
1345+
/* Allow software reset */
1346+
writel(R9A06G032_SYSCTRL_SWRST | R9A06G032_SYSCTRL_RSTEN_MRESET_EN,
1347+
clocks->reg + R9A06G032_SYSCTRL_RSTEN);
1348+
1349+
error = devm_register_sys_off_handler(dev, SYS_OFF_MODE_RESTART, SYS_OFF_PRIO_HIGH,
1350+
r9a06g032_restart_handler, NULL);
1351+
if (error)
1352+
dev_warn(dev, "couldn't register restart handler (%d)\n", error);
1353+
13271354
for (i = 0; i < ARRAY_SIZE(r9a06g032_clocks); ++i) {
13281355
const struct r9a06g032_clkdesc *d = &r9a06g032_clocks[i];
13291356
const char *parent_name = d->source ?

0 commit comments

Comments
 (0)