pm.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 *iva_dev;
  21. static struct device *l3_dev;
  22. static struct device *dsp_dev;
  23. struct device *omap2_get_mpuss_device(void)
  24. {
  25. WARN_ON_ONCE(!mpu_dev);
  26. return mpu_dev;
  27. }
  28. struct device *omap2_get_iva_device(void)
  29. {
  30. WARN_ON_ONCE(!iva_dev);
  31. return iva_dev;
  32. }
  33. struct device *omap2_get_l3_device(void)
  34. {
  35. WARN_ON_ONCE(!l3_dev);
  36. return l3_dev;
  37. }
  38. struct device *omap4_get_dsp_device(void)
  39. {
  40. WARN_ON_ONCE(!dsp_dev);
  41. return dsp_dev;
  42. }
  43. EXPORT_SYMBOL(omap4_get_dsp_device);
  44. /* static int _init_omap_device(struct omap_hwmod *oh, void *user) */
  45. static int _init_omap_device(char *name, struct device **new_dev)
  46. {
  47. struct omap_hwmod *oh;
  48. struct omap_device *od;
  49. oh = omap_hwmod_lookup(name);
  50. if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
  51. __func__, name))
  52. return -ENODEV;
  53. od = omap_device_build(oh->name, 0, oh, NULL, 0, pm_lats, 0, false);
  54. if (WARN(IS_ERR(od), "%s: could not build omap_device for %s\n",
  55. __func__, name))
  56. return -ENODEV;
  57. *new_dev = &od->pdev.dev;
  58. return 0;
  59. }
  60. /*
  61. * Build omap_devices for processors and bus.
  62. */
  63. static void omap2_init_processor_devices(void)
  64. {
  65. _init_omap_device("mpu", &mpu_dev);
  66. _init_omap_device("iva", &iva_dev);
  67. if (cpu_is_omap44xx())
  68. _init_omap_device("dsp", &dsp_dev);
  69. _init_omap_device("l3_main", &l3_dev);
  70. }
  71. static int __init omap2_common_pm_init(void)
  72. {
  73. omap2_init_processor_devices();
  74. omap_pm_if_init();
  75. return 0;
  76. }
  77. device_initcall(omap2_common_pm_init);