Commit | Line | Data |
---|---|---|
3db47dc0 RG |
1 | /* Power off driver for i.mx6 |
2 | * Copyright (c) 2014, FREESCALE CORPORATION. All rights reserved. | |
3 | * | |
4 | * based on msm-poweroff.c | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 and | |
8 | * only version 2 as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | */ | |
16 | ||
17 | #include <linux/err.h> | |
18 | #include <linux/init.h> | |
19 | #include <linux/io.h> | |
20 | #include <linux/kernel.h> | |
21 | #include <linux/module.h> | |
22 | #include <linux/of.h> | |
23 | #include <linux/of_address.h> | |
24 | #include <linux/platform_device.h> | |
25 | ||
26 | static void __iomem *snvs_base; | |
27 | ||
28 | static void do_imx_poweroff(void) | |
29 | { | |
30 | u32 value = readl(snvs_base); | |
31 | ||
32 | /* set TOP and DP_EN bit */ | |
33 | writel(value | 0x60, snvs_base); | |
34 | } | |
35 | ||
36 | static int imx_poweroff_probe(struct platform_device *pdev) | |
37 | { | |
38 | snvs_base = of_iomap(pdev->dev.of_node, 0); | |
39 | if (!snvs_base) { | |
40 | dev_err(&pdev->dev, "failed to get memory\n"); | |
41 | return -ENODEV; | |
42 | } | |
43 | ||
44 | pm_power_off = do_imx_poweroff; | |
45 | return 0; | |
46 | } | |
47 | ||
48 | static const struct of_device_id of_imx_poweroff_match[] = { | |
49 | { .compatible = "fsl,sec-v4.0-poweroff", }, | |
50 | {}, | |
51 | }; | |
52 | MODULE_DEVICE_TABLE(of, of_imx_poweroff_match); | |
53 | ||
54 | static struct platform_driver imx_poweroff_driver = { | |
55 | .probe = imx_poweroff_probe, | |
56 | .driver = { | |
57 | .name = "imx-snvs-poweroff", | |
58 | .of_match_table = of_match_ptr(of_imx_poweroff_match), | |
59 | }, | |
60 | }; | |
61 | ||
62 | static int __init imx_poweroff_init(void) | |
63 | { | |
64 | return platform_driver_register(&imx_poweroff_driver); | |
65 | } | |
66 | device_initcall(imx_poweroff_init); |