eb_cpu5282.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. #ifdef CONFIG_VIDEO
  35. unsigned long display_width;
  36. unsigned long display_height;
  37. #endif
  38. /*---------------------------------------------------------------------------*/
  39. int checkboard (void)
  40. {
  41. puts("Board: EB+CPU5282 (BuS Elektronik GmbH & Co. KG)\n");
  42. #if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
  43. puts(" Boot from Internal FLASH\n");
  44. #endif
  45. return 0;
  46. }
  47. phys_size_t initdram (int board_type)
  48. {
  49. int size, i;
  50. size = 0;
  51. MCFSDRAMC_DCR = MCFSDRAMC_DCR_RTIM_6 |
  52. MCFSDRAMC_DCR_RC((15 * CONFIG_SYS_CLK / 1000000) >> 4);
  53. asm (" nop");
  54. #ifdef CONFIG_SYS_SDRAM_BASE0
  55. MCFSDRAMC_DACR0 = MCFSDRAMC_DACR_BASE(CONFIG_SYS_SDRAM_BASE0)|
  56. MCFSDRAMC_DACR_CASL(1) | MCFSDRAMC_DACR_CBM(3) |
  57. MCFSDRAMC_DACR_PS_32;
  58. asm (" nop");
  59. MCFSDRAMC_DMR0 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V;
  60. asm (" nop");
  61. MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP;
  62. asm (" nop");
  63. for (i = 0; i < 10; i++)
  64. asm (" nop");
  65. *(unsigned long *)(CONFIG_SYS_SDRAM_BASE0) = 0xA5A5A5A5;
  66. asm (" nop");
  67. MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_RE;
  68. asm (" nop");
  69. for (i = 0; i < 2000; i++)
  70. asm (" nop");
  71. MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IMRS;
  72. asm (" nop");
  73. /* write SDRAM mode register */
  74. *(unsigned long *)(CONFIG_SYS_SDRAM_BASE0 + 0x80440) = 0xA5A5A5A5;
  75. asm (" nop");
  76. size += CONFIG_SYS_SDRAM_SIZE0 * 1024 * 1024;
  77. #endif
  78. #ifdef CONFIG_SYS_SDRAM_BASE1xx
  79. MCFSDRAMC_DACR1 = MCFSDRAMC_DACR_BASE (CONFIG_SYS_SDRAM_BASE1)
  80. | MCFSDRAMC_DACR_CASL (1)
  81. | MCFSDRAMC_DACR_CBM (3)
  82. | MCFSDRAMC_DACR_PS_16;
  83. MCFSDRAMC_DMR1 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V;
  84. MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IP;
  85. *(unsigned short *) (CONFIG_SYS_SDRAM_BASE1) = 0xA5A5;
  86. MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_RE;
  87. for (i = 0; i < 2000; i++)
  88. asm (" nop");
  89. MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IMRS;
  90. *(unsigned int *) (CONFIG_SYS_SDRAM_BASE1 + 0x220) = 0xA5A5;
  91. size += CONFIG_SYS_SDRAM_SIZE1 * 1024 * 1024;
  92. #endif
  93. return size;
  94. }
  95. #if defined(CONFIG_SYS_DRAM_TEST)
  96. int testdram (void)
  97. {
  98. uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
  99. uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
  100. uint *p;
  101. printf("SDRAM test phase 1:\n");
  102. for (p = pstart; p < pend; p++)
  103. *p = 0xaaaaaaaa;
  104. for (p = pstart; p < pend; p++) {
  105. if (*p != 0xaaaaaaaa) {
  106. printf ("SDRAM test fails at: %08x\n", (uint) p);
  107. return 1;
  108. }
  109. }
  110. printf("SDRAM test phase 2:\n");
  111. for (p = pstart; p < pend; p++)
  112. *p = 0x55555555;
  113. for (p = pstart; p < pend; p++) {
  114. if (*p != 0x55555555) {
  115. printf ("SDRAM test fails at: %08x\n", (uint) p);
  116. return 1;
  117. }
  118. }
  119. printf("SDRAM test passed.\n");
  120. return 0;
  121. }
  122. #endif
  123. #if defined(CONFIG_HW_WATCHDOG)
  124. void hw_watchdog_init(void)
  125. {
  126. char *s;
  127. int enable;
  128. enable = 1;
  129. s = getenv("watchdog");
  130. if (s != NULL)
  131. if ((strncmp(s, "off", 3) == 0) || (strncmp(s, "0", 1) == 0))
  132. enable = 0;
  133. if (enable)
  134. MCFGPTA_GPTDDR |= (1<<2);
  135. else
  136. MCFGPTA_GPTDDR &= ~(1<<2);
  137. }
  138. void hw_watchdog_reset(void)
  139. {
  140. MCFGPTA_GPTPORT ^= (1<<2);
  141. }
  142. #endif
  143. int misc_init_r(void)
  144. {
  145. #ifdef CONFIG_HW_WATCHDOG
  146. hw_watchdog_init();
  147. #endif
  148. return 1;
  149. }
  150. void __led_toggle(led_id_t mask)
  151. {
  152. MCFGPTA_GPTPORT ^= (1 << 3);
  153. }
  154. void __led_init(led_id_t mask, int state)
  155. {
  156. __led_set(mask, state);
  157. MCFGPTA_GPTDDR |= (1 << 3);
  158. }
  159. void __led_set(led_id_t mask, int state)
  160. {
  161. if (state == STATUS_LED_ON)
  162. MCFGPTA_GPTPORT |= (1 << 3);
  163. else
  164. MCFGPTA_GPTPORT &= ~(1 << 3);
  165. }
  166. #if defined(CONFIG_VIDEO)
  167. int drv_video_init(void)
  168. {
  169. char *s;
  170. #ifdef CONFIG_SPLASH_SCREEN
  171. unsigned long splash;
  172. #endif
  173. printf("Init Video as ");
  174. s = getenv("displaywidth");
  175. if (s != NULL)
  176. display_width = simple_strtoul(s, NULL, 10);
  177. else
  178. display_width = 256;
  179. s = getenv("displayheight");
  180. if (s != NULL)
  181. display_height = simple_strtoul(s, NULL, 10);
  182. else
  183. display_height = 256;
  184. printf("%lu x %lu pixel matrix\n", display_width, display_height);
  185. MCFCCM_CCR &= ~MCFCCM_CCR_SZEN;
  186. MCFGPIO_PEPAR &= ~MCFGPIO_PEPAR_PEPA2;
  187. vcxk_init(display_width, display_height);
  188. #ifdef CONFIG_SPLASH_SCREEN
  189. s = getenv("splashimage");
  190. if (s != NULL) {
  191. splash = simple_strtoul(s, NULL, 16);
  192. vcxk_acknowledge_wait();
  193. video_display_bitmap(splash, 0, 0);
  194. }
  195. #endif
  196. return 0;
  197. }
  198. #endif
  199. /*---------------------------------------------------------------------------*/
  200. #ifdef CONFIG_VIDEO
  201. int do_brightness(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  202. {
  203. int rcode = 0;
  204. ulong side;
  205. ulong bright;
  206. switch (argc) {
  207. case 3:
  208. side = simple_strtoul(argv[1], NULL, 10);
  209. bright = simple_strtoul(argv[2], NULL, 10);
  210. if ((side >= 0) && (side <= 3) &&
  211. (bright >= 0) && (bright <= 1000)) {
  212. vcxk_setbrightness(side, bright);
  213. rcode = 0;
  214. } else {
  215. printf("parameters out of range\n");
  216. printf("Usage:\n%s\n", cmdtp->usage);
  217. rcode = 1;
  218. }
  219. break;
  220. default:
  221. printf("Usage:\n%s\n", cmdtp->usage);
  222. rcode = 1;
  223. break;
  224. }
  225. return rcode;
  226. }
  227. /*---------------------------------------------------------------------------*/
  228. U_BOOT_CMD(
  229. bright, 3, 0, do_brightness,
  230. "sets the display brightness\n",
  231. " <side> <0..1000>\n side: 0/3=both; 1=first; 2=second\n"
  232. );
  233. #endif
  234. /* EOF EB+MCF-EV123.c */