pm_domains.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (C) 2014 Linaro Ltd.
  3. *
  4. * Author: Ulf Hansson <ulf.hansson@linaro.org>
  5. * License terms: GNU General Public License (GPL) version 2
  6. *
  7. * Implements PM domains using the generic PM domain for ux500.
  8. */
  9. #include <linux/printk.h>
  10. #include <linux/slab.h>
  11. #include <linux/err.h>
  12. #include <linux/of.h>
  13. #include <linux/pm_domain.h>
  14. #include <dt-bindings/arm/ux500_pm_domains.h>
  15. #include "pm_domains.h"
  16. static int pd_power_off(struct generic_pm_domain *domain)
  17. {
  18. /*
  19. * Handle the gating of the PM domain regulator here.
  20. *
  21. * Drivers/subsystems handling devices in the PM domain needs to perform
  22. * register context save/restore from their respective runtime PM
  23. * callbacks, to be able to enable PM domain gating/ungating.
  24. */
  25. return 0;
  26. }
  27. static int pd_power_on(struct generic_pm_domain *domain)
  28. {
  29. /*
  30. * Handle the ungating of the PM domain regulator here.
  31. *
  32. * Drivers/subsystems handling devices in the PM domain needs to perform
  33. * register context save/restore from their respective runtime PM
  34. * callbacks, to be able to enable PM domain gating/ungating.
  35. */
  36. return 0;
  37. }
  38. static struct generic_pm_domain ux500_pm_domain_vape = {
  39. .name = "VAPE",
  40. .power_off = pd_power_off,
  41. .power_on = pd_power_on,
  42. };
  43. static struct generic_pm_domain *ux500_pm_domains[NR_DOMAINS] = {
  44. [DOMAIN_VAPE] = &ux500_pm_domain_vape,
  45. };
  46. static const struct of_device_id ux500_pm_domain_matches[] __initconst = {
  47. { .compatible = "stericsson,ux500-pm-domains", },
  48. { },
  49. };
  50. int __init ux500_pm_domains_init(void)
  51. {
  52. struct device_node *np;
  53. struct genpd_onecell_data *genpd_data;
  54. int i;
  55. np = of_find_matching_node(NULL, ux500_pm_domain_matches);
  56. if (!np)
  57. return -ENODEV;
  58. genpd_data = kzalloc(sizeof(*genpd_data), GFP_KERNEL);
  59. if (!genpd_data)
  60. return -ENOMEM;
  61. genpd_data->domains = ux500_pm_domains;
  62. genpd_data->num_domains = ARRAY_SIZE(ux500_pm_domains);
  63. for (i = 0; i < ARRAY_SIZE(ux500_pm_domains); ++i)
  64. pm_genpd_init(ux500_pm_domains[i], NULL, false);
  65. of_genpd_add_provider_onecell(np, genpd_data);
  66. return 0;
  67. }