2 * Copyright (C) 2016 Broadcom
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation version 2.
8 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 * kind, whether express or implied; without even the implied warranty
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #include <linux/of_address.h>
16 #include <linux/of_platform.h>
17 #include <linux/reboot.h>
19 #define RSTMGR_REG_WR_ACCESS_OFFSET 0
20 #define RSTMGR_REG_CHIP_SOFT_RST_OFFSET 4
22 #define RSTMGR_WR_PASSWORD 0xa5a5
23 #define RSTMGR_WR_PASSWORD_SHIFT 8
24 #define RSTMGR_WR_ACCESS_ENABLE 1
26 static void __iomem
*kona_reset_base
;
28 static int kona_reset_handler(struct notifier_block
*this,
29 unsigned long mode
, void *cmd
)
32 * A soft reset is triggered by writing a 0 to bit 0 of the soft reset
33 * register. To write to that register we must first write the password
34 * and the enable bit in the write access enable register.
36 writel((RSTMGR_WR_PASSWORD
<< RSTMGR_WR_PASSWORD_SHIFT
) |
37 RSTMGR_WR_ACCESS_ENABLE
,
38 kona_reset_base
+ RSTMGR_REG_WR_ACCESS_OFFSET
);
39 writel(0, kona_reset_base
+ RSTMGR_REG_CHIP_SOFT_RST_OFFSET
);
44 static struct notifier_block kona_reset_nb
= {
45 .notifier_call
= kona_reset_handler
,
49 static int kona_reset_probe(struct platform_device
*pdev
)
51 struct resource
*res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
53 kona_reset_base
= devm_ioremap_resource(&pdev
->dev
, res
);
54 if (IS_ERR(kona_reset_base
))
55 return PTR_ERR(kona_reset_base
);
57 return register_restart_handler(&kona_reset_nb
);
60 static const struct of_device_id of_match
[] = {
61 { .compatible
= "brcm,bcm21664-resetmgr" },
65 static struct platform_driver bcm_kona_reset_driver
= {
66 .probe
= kona_reset_probe
,
68 .name
= "brcm-kona-reset",
69 .of_match_table
= of_match
,
73 builtin_platform_driver(bcm_kona_reset_driver
);