fb.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include <linux/config.h>
  2. #include <linux/module.h>
  3. #include <linux/kernel.h>
  4. #include <linux/init.h>
  5. #include <linux/platform_device.h>
  6. #include <linux/bootmem.h>
  7. #include <asm/hardware.h>
  8. #include <asm/io.h>
  9. #include <asm/mach-types.h>
  10. #include <asm/mach/map.h>
  11. #include <asm/arch/board.h>
  12. #include <asm/arch/sram.h>
  13. #include <asm/arch/omapfb.h>
  14. #if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE)
  15. static struct omapfb_platform_data omapfb_config;
  16. static u64 omap_fb_dma_mask = ~(u32)0;
  17. static struct platform_device omap_fb_device = {
  18. .name = "omapfb",
  19. .id = -1,
  20. .dev = {
  21. .dma_mask = &omap_fb_dma_mask,
  22. .coherent_dma_mask = ~(u32)0,
  23. .platform_data = &omapfb_config,
  24. },
  25. .num_resources = 0,
  26. };
  27. /* called from map_io */
  28. void omapfb_reserve_mem(void)
  29. {
  30. const struct omap_fbmem_config *fbmem_conf;
  31. omapfb_config.fbmem.fb_sram_start = omap_fb_sram_start;
  32. omapfb_config.fbmem.fb_sram_size = omap_fb_sram_size;
  33. fbmem_conf = omap_get_config(OMAP_TAG_FBMEM, struct omap_fbmem_config);
  34. if (fbmem_conf != NULL) {
  35. /* indicate that the bootloader already initialized the
  36. * fb device, so we'll skip that part in the fb driver
  37. */
  38. omapfb_config.fbmem.fb_sdram_start = fbmem_conf->fb_sdram_start;
  39. omapfb_config.fbmem.fb_sdram_size = fbmem_conf->fb_sdram_size;
  40. if (fbmem_conf->fb_sdram_size) {
  41. pr_info("Reserving %u bytes SDRAM for frame buffer\n",
  42. fbmem_conf->fb_sdram_size);
  43. reserve_bootmem(fbmem_conf->fb_sdram_start,
  44. fbmem_conf->fb_sdram_size);
  45. }
  46. }
  47. }
  48. static inline int omap_init_fb(void)
  49. {
  50. const struct omap_lcd_config *conf;
  51. conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
  52. if (conf == NULL)
  53. return 0;
  54. omapfb_config.lcd = *conf;
  55. return platform_device_register(&omap_fb_device);
  56. }
  57. arch_initcall(omap_init_fb);
  58. #else
  59. void omapfb_reserve_mem(void) {}
  60. #endif