display.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 <plat/display.h>
  24. #include <plat/omap_hwmod.h>
  25. #include <plat/omap_device.h>
  26. static struct platform_device omap_display_device = {
  27. .name = "omapdss",
  28. .id = -1,
  29. .dev = {
  30. .platform_data = NULL,
  31. },
  32. };
  33. static struct omap_device_pm_latency omap_dss_latency[] = {
  34. [0] = {
  35. .deactivate_func = omap_device_idle_hwmods,
  36. .activate_func = omap_device_enable_hwmods,
  37. .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
  38. },
  39. };
  40. /* oh_core is used for getting opt-clocks */
  41. static struct omap_hwmod *oh_core;
  42. static bool opt_clock_available(const char *clk_role)
  43. {
  44. int i;
  45. for (i = 0; i < oh_core->opt_clks_cnt; i++) {
  46. if (!strcmp(oh_core->opt_clks[i].role, clk_role))
  47. return true;
  48. }
  49. return false;
  50. }
  51. int __init omap_display_init(struct omap_dss_board_info *board_data)
  52. {
  53. int r = 0;
  54. struct omap_hwmod *oh;
  55. struct omap_device *od;
  56. int i;
  57. struct omap_display_platform_data pdata;
  58. /*
  59. * omap: valid DSS hwmod names
  60. * omap2,3,4: dss_core, dss_dispc, dss_rfbi, dss_venc
  61. * omap3,4: dss_dsi1
  62. * omap4: dss_dsi2, dss_hdmi
  63. */
  64. char *oh_name[] = { "dss_core", "dss_dispc", "dss_rfbi", "dss_venc",
  65. "dss_dsi1", "dss_dsi2", "dss_hdmi" };
  66. char *dev_name[] = { "omapdss_dss", "omapdss_dispc", "omapdss_rfbi",
  67. "omapdss_venc", "omapdss_dsi1", "omapdss_dsi2",
  68. "omapdss_hdmi" };
  69. int oh_count;
  70. memset(&pdata, 0, sizeof(pdata));
  71. if (cpu_is_omap24xx())
  72. oh_count = ARRAY_SIZE(oh_name) - 3;
  73. /* last 3 hwmod dev in oh_name are not available for omap2 */
  74. else if (cpu_is_omap44xx())
  75. oh_count = ARRAY_SIZE(oh_name);
  76. else
  77. oh_count = ARRAY_SIZE(oh_name) - 2;
  78. /* last 2 hwmod dev in oh_name are not available for omap3 */
  79. /* opt_clks are always associated with dss hwmod */
  80. oh_core = omap_hwmod_lookup("dss_core");
  81. if (!oh_core) {
  82. pr_err("Could not look up dss_core.\n");
  83. return -ENODEV;
  84. }
  85. pdata.board_data = board_data;
  86. pdata.board_data->get_last_off_on_transaction_id = NULL;
  87. pdata.opt_clock_available = opt_clock_available;
  88. for (i = 0; i < oh_count; i++) {
  89. oh = omap_hwmod_lookup(oh_name[i]);
  90. if (!oh) {
  91. pr_err("Could not look up %s\n", oh_name[i]);
  92. return -ENODEV;
  93. }
  94. od = omap_device_build(dev_name[i], -1, oh, &pdata,
  95. sizeof(struct omap_display_platform_data),
  96. omap_dss_latency,
  97. ARRAY_SIZE(omap_dss_latency), 0);
  98. if (WARN((IS_ERR(od)), "Could not build omap_device for %s\n",
  99. oh_name[i]))
  100. return -ENODEV;
  101. }
  102. omap_display_device.dev.platform_data = board_data;
  103. r = platform_device_register(&omap_display_device);
  104. if (r < 0)
  105. printk(KERN_ERR "Unable to register OMAP-Display device\n");
  106. return r;
  107. }