imx-snvs-poweroff.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include <linux/err.h>
  17. #include <linux/init.h>
  18. #include <linux/io.h>
  19. #include <linux/kernel.h>
  20. #include <linux/module.h>
  21. #include <linux/of.h>
  22. #include <linux/of_address.h>
  23. #include <linux/platform_device.h>
  24. static void __iomem *snvs_base;
  25. static void do_imx_poweroff(void)
  26. {
  27. u32 value = readl(snvs_base);
  28. /* set TOP and DP_EN bit */
  29. writel(value | 0x60, snvs_base);
  30. }
  31. static int imx_poweroff_probe(struct platform_device *pdev)
  32. {
  33. snvs_base = of_iomap(pdev->dev.of_node, 0);
  34. if (!snvs_base) {
  35. dev_err(&pdev->dev, "failed to get memory\n");
  36. return -ENODEV;
  37. }
  38. pm_power_off = do_imx_poweroff;
  39. return 0;
  40. }
  41. static const struct of_device_id of_imx_poweroff_match[] = {
  42. { .compatible = "fsl,sec-v4.0-poweroff", },
  43. {},
  44. };
  45. MODULE_DEVICE_TABLE(of, of_imx_poweroff_match);
  46. static struct platform_driver imx_poweroff_driver = {
  47. .probe = imx_poweroff_probe,
  48. .driver = {
  49. .name = "imx-snvs-poweroff",
  50. .of_match_table = of_match_ptr(of_imx_poweroff_match),
  51. },
  52. };
  53. static int __init imx_poweroff_init(void)
  54. {
  55. return platform_driver_register(&imx_poweroff_driver);
  56. }
  57. device_initcall(imx_poweroff_init);