fb.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * File: arch/arm/plat-omap/fb.c
  3. *
  4. * Framebuffer device registration for TI OMAP platforms
  5. *
  6. * Copyright (C) 2006 Nokia Corporation
  7. * Author: Imre Deak <imre.deak@nokia.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. */
  23. #include <linux/module.h>
  24. #include <linux/kernel.h>
  25. #include <linux/mm.h>
  26. #include <linux/init.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/memblock.h>
  29. #include <linux/io.h>
  30. #include <linux/omapfb.h>
  31. #include <linux/dma-mapping.h>
  32. #include <mach/hardware.h>
  33. #include <asm/mach/map.h>
  34. #include <plat/cpu.h>
  35. #ifdef CONFIG_OMAP2_VRFB
  36. /*
  37. * The first memory resource is the register region for VRFB,
  38. * the rest are VRFB virtual memory areas for each VRFB context.
  39. */
  40. static const struct resource omap2_vrfb_resources[] = {
  41. DEFINE_RES_MEM_NAMED(0x68008000u, 0x40, "vrfb-regs"),
  42. DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"),
  43. DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"),
  44. DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"),
  45. DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"),
  46. };
  47. static const struct resource omap3_vrfb_resources[] = {
  48. DEFINE_RES_MEM_NAMED(0x6C000180u, 0xc0, "vrfb-regs"),
  49. DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"),
  50. DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"),
  51. DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"),
  52. DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"),
  53. DEFINE_RES_MEM_NAMED(0xe0000000u, 0x4000000, "vrfb-area-4"),
  54. DEFINE_RES_MEM_NAMED(0xe4000000u, 0x4000000, "vrfb-area-5"),
  55. DEFINE_RES_MEM_NAMED(0xe8000000u, 0x4000000, "vrfb-area-6"),
  56. DEFINE_RES_MEM_NAMED(0xec000000u, 0x4000000, "vrfb-area-7"),
  57. DEFINE_RES_MEM_NAMED(0xf0000000u, 0x4000000, "vrfb-area-8"),
  58. DEFINE_RES_MEM_NAMED(0xf4000000u, 0x4000000, "vrfb-area-9"),
  59. DEFINE_RES_MEM_NAMED(0xf8000000u, 0x4000000, "vrfb-area-10"),
  60. DEFINE_RES_MEM_NAMED(0xfc000000u, 0x4000000, "vrfb-area-11"),
  61. };
  62. static int __init omap_init_vrfb(void)
  63. {
  64. struct platform_device *pdev;
  65. const struct resource *res;
  66. unsigned int num_res;
  67. if (cpu_is_omap24xx()) {
  68. res = omap2_vrfb_resources;
  69. num_res = ARRAY_SIZE(omap2_vrfb_resources);
  70. } else if (cpu_is_omap34xx()) {
  71. res = omap3_vrfb_resources;
  72. num_res = ARRAY_SIZE(omap3_vrfb_resources);
  73. } else {
  74. return 0;
  75. }
  76. pdev = platform_device_register_resndata(NULL, "omapvrfb", -1,
  77. res, num_res, NULL, 0);
  78. if (IS_ERR(pdev))
  79. return PTR_ERR(pdev);
  80. else
  81. return 0;
  82. }
  83. arch_initcall(omap_init_vrfb);
  84. #endif
  85. #if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE)
  86. static bool omapfb_lcd_configured;
  87. static struct omapfb_platform_data omapfb_config;
  88. static u64 omap_fb_dma_mask = ~(u32)0;
  89. static struct platform_device omap_fb_device = {
  90. .name = "omapfb",
  91. .id = -1,
  92. .dev = {
  93. .dma_mask = &omap_fb_dma_mask,
  94. .coherent_dma_mask = DMA_BIT_MASK(32),
  95. .platform_data = &omapfb_config,
  96. },
  97. .num_resources = 0,
  98. };
  99. void __init omapfb_set_lcd_config(const struct omap_lcd_config *config)
  100. {
  101. omapfb_config.lcd = *config;
  102. omapfb_lcd_configured = true;
  103. }
  104. static int __init omap_init_fb(void)
  105. {
  106. /*
  107. * If the board file has not set the lcd config with
  108. * omapfb_set_lcd_config(), don't bother registering the omapfb device
  109. */
  110. if (!omapfb_lcd_configured)
  111. return 0;
  112. return platform_device_register(&omap_fb_device);
  113. }
  114. arch_initcall(omap_init_fb);
  115. #elif defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
  116. static u64 omap_fb_dma_mask = ~(u32)0;
  117. static struct omapfb_platform_data omapfb_config;
  118. static struct platform_device omap_fb_device = {
  119. .name = "omapfb",
  120. .id = -1,
  121. .dev = {
  122. .dma_mask = &omap_fb_dma_mask,
  123. .coherent_dma_mask = DMA_BIT_MASK(32),
  124. .platform_data = &omapfb_config,
  125. },
  126. .num_resources = 0,
  127. };
  128. static int __init omap_init_fb(void)
  129. {
  130. return platform_device_register(&omap_fb_device);
  131. }
  132. arch_initcall(omap_init_fb);
  133. #else
  134. void __init omapfb_set_lcd_config(const struct omap_lcd_config *config)
  135. {
  136. }
  137. #endif