display.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * OMAP2plus display device setup / initialization.
  3. *
  4. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
  5. * Senthilvadivu Guruswamy
  6. * Sumit Semwal
  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. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  13. * kind, whether express or implied; without even the implied warranty
  14. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/io.h>
  21. #include <linux/clk.h>
  22. #include <linux/err.h>
  23. #include <video/omapdss.h>
  24. #include <plat/omap_hwmod.h>
  25. #include <plat/omap_device.h>
  26. #include <plat/omap-pm.h>
  27. static struct platform_device omap_display_device = {
  28. .name = "omapdss",
  29. .id = -1,
  30. .dev = {
  31. .platform_data = NULL,
  32. },
  33. };
  34. struct omap_dss_hwmod_data {
  35. const char *oh_name;
  36. const char *dev_name;
  37. const int id;
  38. };
  39. static const struct omap_dss_hwmod_data omap2_dss_hwmod_data[] __initdata = {
  40. { "dss_core", "omapdss_dss", -1 },
  41. { "dss_dispc", "omapdss_dispc", -1 },
  42. { "dss_rfbi", "omapdss_rfbi", -1 },
  43. { "dss_venc", "omapdss_venc", -1 },
  44. };
  45. static const struct omap_dss_hwmod_data omap3_dss_hwmod_data[] __initdata = {
  46. { "dss_core", "omapdss_dss", -1 },
  47. { "dss_dispc", "omapdss_dispc", -1 },
  48. { "dss_rfbi", "omapdss_rfbi", -1 },
  49. { "dss_venc", "omapdss_venc", -1 },
  50. { "dss_dsi1", "omapdss_dsi1", -1 },
  51. };
  52. static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initdata = {
  53. { "dss_core", "omapdss_dss", -1 },
  54. { "dss_dispc", "omapdss_dispc", -1 },
  55. { "dss_rfbi", "omapdss_rfbi", -1 },
  56. { "dss_venc", "omapdss_venc", -1 },
  57. { "dss_dsi1", "omapdss_dsi1", -1 },
  58. { "dss_dsi2", "omapdss_dsi2", -1 },
  59. { "dss_hdmi", "omapdss_hdmi", -1 },
  60. };
  61. int __init omap_display_init(struct omap_dss_board_info *board_data)
  62. {
  63. int r = 0;
  64. struct omap_hwmod *oh;
  65. struct platform_device *pdev;
  66. int i, oh_count;
  67. struct omap_display_platform_data pdata;
  68. const struct omap_dss_hwmod_data *curr_dss_hwmod;
  69. memset(&pdata, 0, sizeof(pdata));
  70. if (cpu_is_omap24xx()) {
  71. curr_dss_hwmod = omap2_dss_hwmod_data;
  72. oh_count = ARRAY_SIZE(omap2_dss_hwmod_data);
  73. } else if (cpu_is_omap34xx()) {
  74. curr_dss_hwmod = omap3_dss_hwmod_data;
  75. oh_count = ARRAY_SIZE(omap3_dss_hwmod_data);
  76. } else {
  77. curr_dss_hwmod = omap4_dss_hwmod_data;
  78. oh_count = ARRAY_SIZE(omap4_dss_hwmod_data);
  79. }
  80. pdata.board_data = board_data;
  81. pdata.board_data->get_context_loss_count =
  82. omap_pm_get_dev_context_loss_count;
  83. for (i = 0; i < oh_count; i++) {
  84. oh = omap_hwmod_lookup(curr_dss_hwmod[i].oh_name);
  85. if (!oh) {
  86. pr_err("Could not look up %s\n",
  87. curr_dss_hwmod[i].oh_name);
  88. return -ENODEV;
  89. }
  90. pdev = omap_device_build(curr_dss_hwmod[i].dev_name,
  91. curr_dss_hwmod[i].id, oh, &pdata,
  92. sizeof(struct omap_display_platform_data),
  93. NULL, 0, 0);
  94. if (WARN((IS_ERR(pdev)), "Could not build omap_device for %s\n",
  95. curr_dss_hwmod[i].oh_name))
  96. return -ENODEV;
  97. }
  98. omap_display_device.dev.platform_data = board_data;
  99. r = platform_device_register(&omap_display_device);
  100. if (r < 0)
  101. printk(KERN_ERR "Unable to register OMAP-Display device\n");
  102. return r;
  103. }