pm.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * pm.c - Common OMAP2+ power management-related code
  3. *
  4. * Copyright (C) 2010 Texas Instruments, Inc.
  5. * Copyright (C) 2010 Nokia Corporation
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <linux/err.h>
  15. #include <plat/omap-pm.h>
  16. #include <plat/omap_device.h>
  17. #include <plat/common.h>
  18. static struct omap_device_pm_latency *pm_lats;
  19. static struct device *mpu_dev;
  20. static struct device *dsp_dev;
  21. static struct device *l3_dev;
  22. struct device *omap2_get_mpuss_device(void)
  23. {
  24. WARN_ON_ONCE(!mpu_dev);
  25. return mpu_dev;
  26. }
  27. struct device *omap2_get_dsp_device(void)
  28. {
  29. WARN_ON_ONCE(!dsp_dev);
  30. return dsp_dev;
  31. }
  32. struct device *omap2_get_l3_device(void)
  33. {
  34. WARN_ON_ONCE(!l3_dev);
  35. return l3_dev;
  36. }
  37. /* static int _init_omap_device(struct omap_hwmod *oh, void *user) */
  38. static int _init_omap_device(char *name, struct device **new_dev)
  39. {
  40. struct omap_hwmod *oh;
  41. struct omap_device *od;
  42. oh = omap_hwmod_lookup(name);
  43. if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
  44. __func__, name))
  45. return -ENODEV;
  46. od = omap_device_build(oh->name, 0, oh, NULL, 0, pm_lats, 0, false);
  47. if (WARN(IS_ERR(od), "%s: could not build omap_device for %s\n",
  48. __func__, name))
  49. return -ENODEV;
  50. *new_dev = &od->pdev.dev;
  51. return 0;
  52. }
  53. /*
  54. * Build omap_devices for processors and bus.
  55. */
  56. static void omap2_init_processor_devices(void)
  57. {
  58. _init_omap_device("mpu", &mpu_dev);
  59. _init_omap_device("iva", &dsp_dev);
  60. _init_omap_device("l3_main", &l3_dev);
  61. }
  62. static int __init omap2_common_pm_init(void)
  63. {
  64. omap2_init_processor_devices();
  65. omap_pm_if_init();
  66. return 0;
  67. }
  68. device_initcall(omap2_common_pm_init);