diu.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc.
  3. * York Sun <yorksun@freescale.com>
  4. *
  5. * FSL DIU Framebuffer driver
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <command.h>
  27. #include <asm/io.h>
  28. #include "../../../../board/freescale/common/fsl_diu_fb.h"
  29. #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
  30. #include <stdio_dev.h>
  31. #include <video_fb.h>
  32. #endif
  33. DECLARE_GLOBAL_DATA_PTR;
  34. static int xres, yres;
  35. void diu_set_pixel_clock(unsigned int pixclock)
  36. {
  37. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  38. volatile clk512x_t *clk = &immap->clk;
  39. volatile unsigned int *clkdvdr = &clk->scfr[0];
  40. unsigned long speed_ccb, temp, pixval;
  41. speed_ccb = get_bus_freq(0) * 4;
  42. temp = 1000000000/pixclock;
  43. temp *= 1000;
  44. pixval = speed_ccb / temp;
  45. debug("DIU pixval = %lu\n", pixval);
  46. /* Modify PXCLK in GUTS CLKDVDR */
  47. debug("DIU: Current value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr));
  48. temp = in_be32(clkdvdr) & 0xFFFFFF00;
  49. out_be32(clkdvdr, temp | (pixval & 0xFF));
  50. debug("DIU: Modified value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr));
  51. }
  52. int mpc5121_diu_init(void)
  53. {
  54. unsigned int pixel_format;
  55. #if defined(CONFIG_VIDEO_XRES) & defined(CONFIG_VIDEO_YRES)
  56. xres = CONFIG_VIDEO_XRES;
  57. yres = CONFIG_VIDEO_YRES;
  58. #else
  59. xres = 1024;
  60. yres = 768;
  61. #endif
  62. pixel_format = 0x88883316;
  63. debug("mpc5121_diu_init\n");
  64. return fsl_diu_init(xres, pixel_format, 0);
  65. }
  66. #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
  67. /*
  68. * The Graphic Device
  69. */
  70. GraphicDevice ctfb;
  71. void *video_hw_init(void)
  72. {
  73. GraphicDevice *pGD = (GraphicDevice *) &ctfb;
  74. struct fb_info *info;
  75. if (mpc5121_diu_init() < 0)
  76. return NULL;
  77. /* fill in Graphic device struct */
  78. sprintf(pGD->modeIdent, "%dx%dx%d %dkHz %dHz",
  79. xres, yres, 32, 64, 60);
  80. pGD->frameAdrs = (unsigned int)fsl_fb_open(&info);
  81. pGD->winSizeX = xres;
  82. pGD->winSizeY = yres;
  83. pGD->plnSizeX = pGD->winSizeX;
  84. pGD->plnSizeY = pGD->winSizeY;
  85. pGD->gdfBytesPP = 4;
  86. pGD->gdfIndex = GDF_32BIT_X888RGB;
  87. pGD->isaBase = 0;
  88. pGD->pciBase = 0;
  89. pGD->memSize = info->screen_size;
  90. /* Cursor Start Address */
  91. pGD->dprBase = 0;
  92. pGD->vprBase = 0;
  93. pGD->cprBase = 0;
  94. return (void *)pGD;
  95. }
  96. #endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */