pd.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* linux/arch/arm/plat-samsung/pd.c
  2. *
  3. * Copyright (c) 2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * Samsung Power domain support
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/module.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/err.h>
  16. #include <linux/pm_runtime.h>
  17. #include <plat/pd.h>
  18. static int samsung_pd_probe(struct platform_device *pdev)
  19. {
  20. struct samsung_pd_info *pdata = pdev->dev.platform_data;
  21. struct device *dev = &pdev->dev;
  22. if (!pdata) {
  23. dev_err(dev, "no device data specified\n");
  24. return -ENOENT;
  25. }
  26. pm_runtime_set_active(dev);
  27. pm_runtime_enable(dev);
  28. dev_info(dev, "power domain registered\n");
  29. return 0;
  30. }
  31. static int __devexit samsung_pd_remove(struct platform_device *pdev)
  32. {
  33. struct device *dev = &pdev->dev;
  34. pm_runtime_disable(dev);
  35. return 0;
  36. }
  37. static int samsung_pd_runtime_suspend(struct device *dev)
  38. {
  39. struct samsung_pd_info *pdata = dev->platform_data;
  40. int ret = 0;
  41. if (pdata->disable)
  42. ret = pdata->disable(dev);
  43. dev_dbg(dev, "suspended\n");
  44. return ret;
  45. }
  46. static int samsung_pd_runtime_resume(struct device *dev)
  47. {
  48. struct samsung_pd_info *pdata = dev->platform_data;
  49. int ret = 0;
  50. if (pdata->enable)
  51. ret = pdata->enable(dev);
  52. dev_dbg(dev, "resumed\n");
  53. return ret;
  54. }
  55. static const struct dev_pm_ops samsung_pd_pm_ops = {
  56. .runtime_suspend = samsung_pd_runtime_suspend,
  57. .runtime_resume = samsung_pd_runtime_resume,
  58. };
  59. static struct platform_driver samsung_pd_driver = {
  60. .driver = {
  61. .name = "samsung-pd",
  62. .owner = THIS_MODULE,
  63. .pm = &samsung_pd_pm_ops,
  64. },
  65. .probe = samsung_pd_probe,
  66. .remove = __devexit_p(samsung_pd_remove),
  67. };
  68. static int __init samsung_pd_init(void)
  69. {
  70. int ret;
  71. ret = platform_driver_register(&samsung_pd_driver);
  72. if (ret)
  73. printk(KERN_ERR "%s: failed to add PD driver\n", __func__);
  74. return ret;
  75. }
  76. arch_initcall(samsung_pd_init);