fb.c 1.9 KB

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