video: rockchip: vcodec: add log message in iommu drm
[firefly-linux-kernel-4.4.55.git] / drivers / power / reset / syscon-reboot-mode.c
1 /*
2  * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
3  *
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.
8  */
9
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/kernel.h>
13 #include <linux/of.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"
20
21 static struct regmap *map;
22 static u32 offset;
23 static u32 mask = 0xffffffff;
24
25 static int syscon_reboot_mode_write(int magic)
26 {
27         regmap_update_bits(map, offset, mask, magic);
28
29         return 0;
30 }
31
32 static int syscon_reboot_mode_probe(struct platform_device *pdev)
33 {
34         int ret;
35
36         map = syscon_node_to_regmap(pdev->dev.parent->of_node);
37         if (IS_ERR(map))
38                 return PTR_ERR(map);
39         if (of_property_read_u32(pdev->dev.of_node, "offset", &offset))
40                 return -EINVAL;
41         of_property_read_u32(pdev->dev.of_node, "mask", &mask);
42         ret = reboot_mode_register(&pdev->dev, syscon_reboot_mode_write);
43         if (ret)
44                 dev_err(&pdev->dev, "can't register reboot mode\n");
45
46         return ret;
47 }
48
49 static const struct of_device_id syscon_reboot_mode_of_match[] = {
50         { .compatible = "syscon-reboot-mode" },
51         {}
52 };
53
54 static struct platform_driver syscon_reboot_mode_driver = {
55         .probe = syscon_reboot_mode_probe,
56         .driver = {
57                 .name = "syscon-reboot-mode",
58                 .of_match_table = syscon_reboot_mode_of_match,
59         },
60 };
61 module_platform_driver(syscon_reboot_mode_driver);
62
63 MODULE_AUTHOR("Andy Yan <andy.yan@rock-chips.com");
64 MODULE_DESCRIPTION("SYSCON reboot mode driver");
65 MODULE_LICENSE("GPL v2");