EB+MCF-EV123.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * (C) Copyright 2005-2009
  3. * BuS Elektronik GmbH & Co.KG <esw@bus-elektonik.de>
  4. *
  5. * (C) Copyright 2000-2003
  6. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <command.h>
  28. #include "asm/m5282.h"
  29. #include <bmp_layout.h>
  30. #include <status_led.h>
  31. #include <bus_vcxk.h>
  32. /*---------------------------------------------------------------------------*/
  33. DECLARE_GLOBAL_DATA_PTR;
  34. unsigned long display_width;
  35. unsigned long display_height;
  36. /*---------------------------------------------------------------------------*/
  37. int checkboard (void)
  38. {
  39. puts ("Board: MCF-EV1 + MCF-EV23 (BuS Elektronik GmbH & Co. KG)\n");
  40. #if (TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
  41. puts (" Boot from Internal FLASH\n");
  42. #endif
  43. return 0;
  44. }
  45. phys_size_t initdram (int board_type)
  46. {
  47. int size, i;
  48. size = 0;
  49. MCFSDRAMC_DCR = MCFSDRAMC_DCR_RTIM_6
  50. | MCFSDRAMC_DCR_RC ((15 * CONFIG_SYS_CLK) >> 4);
  51. #ifdef CONFIG_SYS_SDRAM_BASE0
  52. MCFSDRAMC_DACR0 = MCFSDRAMC_DACR_BASE (CONFIG_SYS_SDRAM_BASE0)
  53. | MCFSDRAMC_DACR_CASL (1)
  54. | MCFSDRAMC_DACR_CBM (3)
  55. | MCFSDRAMC_DACR_PS_16;
  56. MCFSDRAMC_DMR0 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V;
  57. MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP;
  58. *(unsigned short *) (CONFIG_SYS_SDRAM_BASE0) = 0xA5A5;
  59. MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_RE;
  60. for (i = 0; i < 2000; i++)
  61. asm (" nop");
  62. mbar_writeLong (MCFSDRAMC_DACR0,
  63. mbar_readLong (MCFSDRAMC_DACR0) | MCFSDRAMC_DACR_IMRS);
  64. *(unsigned int *) (CONFIG_SYS_SDRAM_BASE0 + 0x220) = 0xA5A5;
  65. size += CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  66. #endif
  67. #ifdef CONFIG_SYS_SDRAM_BASE1
  68. MCFSDRAMC_DACR1 = MCFSDRAMC_DACR_BASE (CONFIG_SYS_SDRAM_BASE1)
  69. | MCFSDRAMC_DACR_CASL (1)
  70. | MCFSDRAMC_DACR_CBM (3)
  71. | MCFSDRAMC_DACR_PS_16;
  72. MCFSDRAMC_DMR1 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V;
  73. MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IP;
  74. *(unsigned short *) (CONFIG_SYS_SDRAM_BASE1) = 0xA5A5;
  75. MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_RE;
  76. for (i = 0; i < 2000; i++)
  77. asm (" nop");
  78. MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IMRS;
  79. *(unsigned int *) (CONFIG_SYS_SDRAM_BASE1 + 0x220) = 0xA5A5;
  80. size += CONFIG_SYS_SDRAM_SIZE1 * 1024 * 1024;
  81. #endif
  82. return size;
  83. }
  84. #if defined(CONFIG_SYS_DRAM_TEST)
  85. int testdram (void)
  86. {
  87. uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
  88. uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
  89. uint *p;
  90. printf("SDRAM test phase 1:\n");
  91. for (p = pstart; p < pend; p++)
  92. *p = 0xaaaaaaaa;
  93. for (p = pstart; p < pend; p++) {
  94. if (*p != 0xaaaaaaaa) {
  95. printf ("SDRAM test fails at: %08x\n", (uint) p);
  96. return 1;
  97. }
  98. }
  99. printf("SDRAM test phase 2:\n");
  100. for (p = pstart; p < pend; p++)
  101. *p = 0x55555555;
  102. for (p = pstart; p < pend; p++) {
  103. if (*p != 0x55555555) {
  104. printf ("SDRAM test fails at: %08x\n", (uint) p);
  105. return 1;
  106. }
  107. }
  108. printf("SDRAM test passed.\n");
  109. return 0;
  110. }
  111. #endif
  112. int misc_init_r(void)
  113. {
  114. #ifdef CONFIG_HW_WATCHDOG
  115. hw_watchdog_init();
  116. #endif
  117. #ifndef CONFIG_VIDEO
  118. vcxk_init(16, 16);
  119. #endif
  120. return 1;
  121. }
  122. #if defined(CONFIG_VIDEO)
  123. /*
  124. ****h* EB+CPU5282-T1/drv_video_init
  125. * FUNCTION
  126. ***
  127. */
  128. int drv_video_init(void)
  129. {
  130. char *s;
  131. unsigned long splash;
  132. printf("Init Video as ");
  133. if ((s = getenv("displaywidth")) != NULL)
  134. display_width = simple_strtoul(s, NULL, 10);
  135. else
  136. display_width = 256;
  137. if ((s = getenv("displayheight")) != NULL)
  138. display_height = simple_strtoul(s, NULL, 10);
  139. else
  140. display_height = 256;
  141. printf("%lu x %lu pixel matrix\n", display_width, display_height);
  142. MCFCCM_CCR &= ~MCFCCM_CCR_SZEN;
  143. MCFGPIO_PEPAR &= ~MCFGPIO_PEPAR_PEPA2;
  144. vcxk_init(display_width, display_height);
  145. #ifdef CONFIG_SPLASH_SCREEN
  146. if ((s = getenv("splashimage")) != NULL) {
  147. debug("use splashimage: %s\n", s);
  148. splash = simple_strtoul(s, NULL, 16);
  149. debug("use splashimage: %x\n", splash);
  150. vcxk_acknowledge_wait();
  151. video_display_bitmap(splash, 0, 0);
  152. }
  153. #endif
  154. return 0;
  155. }
  156. #endif
  157. /*---------------------------------------------------------------------------*/
  158. #ifdef CONFIG_VIDEO
  159. int do_brightness(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  160. {
  161. int rcode = 0;
  162. ulong side;
  163. ulong bright;
  164. switch (argc) {
  165. case 3:
  166. side = simple_strtoul(argv[1], NULL, 10);
  167. bright = simple_strtoul(argv[2], NULL, 10);
  168. if ((side >= 0) && (side <= 3) &&
  169. (bright >= 0) && (bright <= 1000)) {
  170. vcxk_setbrightness(side, bright);
  171. rcode = 0;
  172. } else {
  173. printf("parameters out of range\n");
  174. printf("Usage:\n%s\n", cmdtp->usage);
  175. rcode = 1;
  176. }
  177. break;
  178. default:
  179. printf("Usage:\n%s\n", cmdtp->usage);
  180. rcode = 1;
  181. break;
  182. }
  183. return rcode;
  184. }
  185. /*---------------------------------------------------------------------------*/
  186. U_BOOT_CMD(
  187. bright, 3, 0, do_brightness,
  188. "sets the display brightness\n",
  189. " <side> <0..1000>\n side: 0/3=both; 1=first; 2=second\n"
  190. );
  191. #endif
  192. /* EOF EB+MCF-EV123.c */