2 * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/kernel.h>
14 #include <linux/of_address.h>
15 #include <linux/platform_device.h>
16 #include <linux/reboot.h>
17 #include <linux/regmap.h>
18 #include <linux/mfd/syscon.h>
19 #include "reboot-mode.h"
21 static struct regmap *map;
23 static u32 mask = 0xffffffff;
25 static int syscon_reboot_mode_write(int magic)
27 regmap_update_bits(map, offset, mask, magic);
32 static int syscon_reboot_mode_probe(struct platform_device *pdev)
36 map = syscon_node_to_regmap(pdev->dev.parent->of_node);
39 if (of_property_read_u32(pdev->dev.of_node, "offset", &offset))
41 of_property_read_u32(pdev->dev.of_node, "mask", &mask);
42 ret = reboot_mode_register(&pdev->dev, syscon_reboot_mode_write);
44 dev_err(&pdev->dev, "can't register reboot mode\n");
49 static const struct of_device_id syscon_reboot_mode_of_match[] = {
50 { .compatible = "syscon-reboot-mode" },
54 static struct platform_driver syscon_reboot_mode_driver = {
55 .probe = syscon_reboot_mode_probe,
57 .name = "syscon-reboot-mode",
58 .of_match_table = syscon_reboot_mode_of_match,
61 module_platform_driver(syscon_reboot_mode_driver);
63 MODULE_AUTHOR("Andy Yan <andy.yan@rock-chips.com");
64 MODULE_DESCRIPTION("SYSCON reboot mode driver");
65 MODULE_LICENSE("GPL v2");