Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 // Copyright (C) 2016 Broadcom
0003 
0004 #include <linux/io.h>
0005 #include <linux/of_address.h>
0006 #include <linux/of_platform.h>
0007 #include <linux/reboot.h>
0008 
0009 #define RSTMGR_REG_WR_ACCESS_OFFSET 0
0010 #define RSTMGR_REG_CHIP_SOFT_RST_OFFSET 4
0011 
0012 #define RSTMGR_WR_PASSWORD      0xa5a5
0013 #define RSTMGR_WR_PASSWORD_SHIFT    8
0014 #define RSTMGR_WR_ACCESS_ENABLE     1
0015 
0016 static void __iomem *kona_reset_base;
0017 
0018 static int kona_reset_handler(struct notifier_block *this,
0019                 unsigned long mode, void *cmd)
0020 {
0021     /*
0022      * A soft reset is triggered by writing a 0 to bit 0 of the soft reset
0023      * register. To write to that register we must first write the password
0024      * and the enable bit in the write access enable register.
0025      */
0026     writel((RSTMGR_WR_PASSWORD << RSTMGR_WR_PASSWORD_SHIFT) |
0027         RSTMGR_WR_ACCESS_ENABLE,
0028         kona_reset_base + RSTMGR_REG_WR_ACCESS_OFFSET);
0029     writel(0, kona_reset_base + RSTMGR_REG_CHIP_SOFT_RST_OFFSET);
0030 
0031     return NOTIFY_DONE;
0032 }
0033 
0034 static struct notifier_block kona_reset_nb = {
0035     .notifier_call = kona_reset_handler,
0036     .priority = 128,
0037 };
0038 
0039 static int kona_reset_probe(struct platform_device *pdev)
0040 {
0041     struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
0042 
0043     kona_reset_base = devm_ioremap_resource(&pdev->dev, res);
0044     if (IS_ERR(kona_reset_base))
0045         return PTR_ERR(kona_reset_base);
0046 
0047     return register_restart_handler(&kona_reset_nb);
0048 }
0049 
0050 static const struct of_device_id of_match[] = {
0051     { .compatible = "brcm,bcm21664-resetmgr" },
0052     {},
0053 };
0054 
0055 static struct platform_driver bcm_kona_reset_driver = {
0056     .probe = kona_reset_probe,
0057     .driver = {
0058         .name = "brcm-kona-reset",
0059         .of_match_table = of_match,
0060     },
0061 };
0062 
0063 builtin_platform_driver(bcm_kona_reset_driver);