fb.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Framebuffer device registration for TI OMAP platforms
  3. *
  4. * Copyright (C) 2006 Nokia Corporation
  5. * Author: Imre Deak <imre.deak@nokia.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program; if not, write to the Free Software Foundation, Inc.,
  19. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. #include <linux/module.h>
  22. #include <linux/kernel.h>
  23. #include <linux/mm.h>
  24. #include <linux/init.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/memblock.h>
  27. #include <linux/io.h>
  28. #include <linux/omapfb.h>
  29. #include <linux/dma-mapping.h>
  30. #include <asm/mach/map.h>
  31. #include "soc.h"
  32. #include "display.h"
  33. #ifdef CONFIG_OMAP2_VRFB
  34. /*
  35. * The first memory resource is the register region for VRFB,
  36. * the rest are VRFB virtual memory areas for each VRFB context.
  37. */
  38. static const struct resource omap2_vrfb_resources[] = {
  39. DEFINE_RES_MEM_NAMED(0x68008000u, 0x40, "vrfb-regs"),
  40. DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"),
  41. DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"),
  42. DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"),
  43. DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"),
  44. };
  45. static const struct resource omap3_vrfb_resources[] = {
  46. DEFINE_RES_MEM_NAMED(0x6C000180u, 0xc0, "vrfb-regs"),
  47. DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"),
  48. DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"),
  49. DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"),
  50. DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"),
  51. DEFINE_RES_MEM_NAMED(0xe0000000u, 0x4000000, "vrfb-area-4"),
  52. DEFINE_RES_MEM_NAMED(0xe4000000u, 0x4000000, "vrfb-area-5"),
  53. DEFINE_RES_MEM_NAMED(0xe8000000u, 0x4000000, "vrfb-area-6"),
  54. DEFINE_RES_MEM_NAMED(0xec000000u, 0x4000000, "vrfb-area-7"),
  55. DEFINE_RES_MEM_NAMED(0xf0000000u, 0x4000000, "vrfb-area-8"),
  56. DEFINE_RES_MEM_NAMED(0xf4000000u, 0x4000000, "vrfb-area-9"),
  57. DEFINE_RES_MEM_NAMED(0xf8000000u, 0x4000000, "vrfb-area-10"),
  58. DEFINE_RES_MEM_NAMED(0xfc000000u, 0x4000000, "vrfb-area-11"),
  59. };
  60. int __init omap_init_vrfb(void)
  61. {
  62. struct platform_device *pdev;
  63. const struct resource *res;
  64. unsigned int num_res;
  65. if (cpu_is_omap24xx()) {
  66. res = omap2_vrfb_resources;
  67. num_res = ARRAY_SIZE(omap2_vrfb_resources);
  68. } else if (cpu_is_omap34xx()) {
  69. res = omap3_vrfb_resources;
  70. num_res = ARRAY_SIZE(omap3_vrfb_resources);
  71. } else {
  72. return 0;
  73. }
  74. pdev = platform_device_register_resndata(NULL, "omapvrfb", -1,
  75. res, num_res, NULL, 0);
  76. return PTR_ERR_OR_ZERO(pdev);
  77. }
  78. #else
  79. int __init omap_init_vrfb(void) { return 0; }
  80. #endif
  81. #if IS_ENABLED(CONFIG_FB_OMAP2)
  82. static u64 omap_fb_dma_mask = ~(u32)0;
  83. static struct omapfb_platform_data omapfb_config;
  84. static struct platform_device omap_fb_device = {
  85. .name = "omapfb",
  86. .id = -1,
  87. .dev = {
  88. .dma_mask = &omap_fb_dma_mask,
  89. .coherent_dma_mask = DMA_BIT_MASK(32),
  90. .platform_data = &omapfb_config,
  91. },
  92. .num_resources = 0,
  93. };
  94. int __init omap_init_fb(void)
  95. {
  96. return platform_device_register(&omap_fb_device);
  97. }
  98. #else
  99. int __init omap_init_fb(void) { return 0; }
  100. #endif