1 // SPDX-License-Identifier: GPL-2.0
3 * Renesas R-Mobile Reset Driver
5 * Copyright (C) 2014 Glider bvba
9 #include <linux/module.h>
10 #include <linux/notifier.h>
11 #include <linux/of_address.h>
12 #include <linux/platform_device.h>
13 #include <linux/printk.h>
14 #include <linux/reboot.h>
16 /* SYSC Register Bank 2 */
17 #define RESCNT2 0x20 /* Reset Control Register 2 */
19 /* Reset Control Register 2 */
20 #define RESCNT2_PRES 0x80000000 /* Soft power-on reset */
22 static int rmobile_reset_handler(struct sys_off_data
*data
)
24 void __iomem
*sysc_base2
= (void __iomem
*)data
->cb_data
;
26 /* Let's assume we have acquired the HPB semaphore */
27 writel(RESCNT2_PRES
, sysc_base2
+ RESCNT2
);
32 static int rmobile_reset_probe(struct platform_device
*pdev
)
34 void __iomem
*sysc_base2
;
37 sysc_base2
= devm_platform_ioremap_resource(pdev
, 1);
38 if (IS_ERR(sysc_base2
))
39 return PTR_ERR(sysc_base2
);
41 error
= devm_register_sys_off_handler(&pdev
->dev
,
44 rmobile_reset_handler
,
45 (__force
void *)sysc_base2
);
48 "cannot register restart handler (err=%d)\n", error
);
55 static const struct of_device_id rmobile_reset_of_match
[] = {
56 { .compatible
= "renesas,sysc-rmobile", },
59 MODULE_DEVICE_TABLE(of
, rmobile_reset_of_match
);
61 static struct platform_driver rmobile_reset_driver
= {
62 .probe
= rmobile_reset_probe
,
64 .name
= "rmobile_reset",
65 .of_match_table
= rmobile_reset_of_match
,
69 module_platform_driver(rmobile_reset_driver
);
71 MODULE_DESCRIPTION("Renesas R-Mobile Reset Driver");
72 MODULE_AUTHOR("Geert Uytterhoeven <geert+renesas@glider.be>");
73 MODULE_LICENSE("GPL v2");