1 /* Power off driver for i.mx6
2 * Copyright (c) 2014, FREESCALE CORPORATION. All rights reserved.
4 * based on msm-poweroff.c
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.
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.
17 #include <linux/err.h>
18 #include <linux/init.h>
20 #include <linux/kernel.h>
21 #include <linux/module.h>
23 #include <linux/of_address.h>
24 #include <linux/platform_device.h>
26 static void __iomem
*snvs_base
;
28 static void do_imx_poweroff(void)
30 u32 value
= readl(snvs_base
);
32 /* set TOP and DP_EN bit */
33 writel(value
| 0x60, snvs_base
);
36 static int imx_poweroff_probe(struct platform_device
*pdev
)
38 snvs_base
= of_iomap(pdev
->dev
.of_node
, 0);
40 dev_err(&pdev
->dev
, "failed to get memory\n");
44 pm_power_off
= do_imx_poweroff
;
48 static const struct of_device_id of_imx_poweroff_match
[] = {
49 { .compatible
= "fsl,sec-v4.0-poweroff", },
52 MODULE_DEVICE_TABLE(of
, of_imx_poweroff_match
);
54 static struct platform_driver imx_poweroff_driver
= {
55 .probe
= imx_poweroff_probe
,
57 .name
= "imx-snvs-poweroff",
58 .of_match_table
= of_match_ptr(of_imx_poweroff_match
),
62 static int __init
imx_poweroff_init(void)
64 return platform_driver_register(&imx_poweroff_driver
);
66 device_initcall(imx_poweroff_init
);