stamp.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /*
  2. * U-boot - stamp.c STAMP board specific routines
  3. *
  4. * Copyright (c) 2005 blackfin.uclinux.org
  5. *
  6. * (C) Copyright 2000-2004
  7. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <common.h>
  28. #include <asm/mem_init.h>
  29. #include "stamp.h"
  30. #define STATUS_LED_OFF 0
  31. #define STATUS_LED_ON 1
  32. #ifdef CONFIG_SHOW_BOOT_PROGRESS
  33. # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
  34. #else
  35. # define SHOW_BOOT_PROGRESS(arg)
  36. #endif
  37. int checkboard (void)
  38. {
  39. printf ("CPU: ADSP BF533 Rev.: 0.%d\n", *pCHIPID >> 28);
  40. printf ("Board: ADI BF533 Stamp board\n");
  41. printf (" Support: http://blackfin.uclinux.org/\n");
  42. printf (" Richard Klingler <richard@uclinux.net>\n");
  43. return 0;
  44. }
  45. long int initdram (int board_type)
  46. {
  47. DECLARE_GLOBAL_DATA_PTR;
  48. #ifdef DEBUG
  49. printf ("SDRAM attributes:\n");
  50. printf (" tRCD:%d Cycles; tRP:%d Cycles; tRAS:%d Cycles; tWR:%d Cycles; "
  51. "CAS Latency:%d cycles\n",
  52. (SDRAM_tRCD >> 15),
  53. (SDRAM_tRP >> 11),
  54. (SDRAM_tRAS >> 6),
  55. (SDRAM_tWR >> 19),
  56. (SDRAM_CL >> 2));
  57. printf ("SDRAM Begin: 0x%x\n", CFG_SDRAM_BASE);
  58. printf ("Bank size = %d MB\n", 128);
  59. #endif
  60. gd->bd->bi_memstart = CFG_SDRAM_BASE;
  61. gd->bd->bi_memsize = CFG_MAX_RAM_SIZE;
  62. return (gd->bd->bi_memsize);
  63. }
  64. void swap_to (int device_id)
  65. {
  66. if (device_id == ETHERNET) {
  67. *pFIO_DIR = PF0;
  68. asm ("ssync;");
  69. *pFIO_FLAG_S = PF0;
  70. asm ("ssync;");
  71. } else if (device_id == FLASH) {
  72. *pFIO_DIR = (PF4 | PF3 | PF2 | PF1 | PF0);
  73. *pFIO_FLAG_S = (PF4 | PF3 | PF2);
  74. *pFIO_MASKA_D = (PF8 | PF6 | PF5);
  75. *pFIO_MASKB_D = (PF7);
  76. *pFIO_POLAR = (PF8 | PF6 | PF5);
  77. *pFIO_EDGE = (PF8 | PF7 | PF6 | PF5);
  78. *pFIO_INEN = (PF8 | PF7 | PF6 | PF5);
  79. *pFIO_FLAG_D = (PF4 | PF3 | PF2);
  80. asm ("ssync;");
  81. } else {
  82. printf ("Unknown bank to switch\n");
  83. }
  84. return;
  85. }
  86. #if defined(CONFIG_MISC_INIT_R)
  87. /* miscellaneous platform dependent initialisations */
  88. int misc_init_r (void)
  89. {
  90. int i;
  91. int cf_stat = 0;
  92. /* Check whether CF card is inserted */
  93. *pFIO_EDGE = FIO_EDGE_CF_BITS;
  94. *pFIO_POLAR = FIO_POLAR_CF_BITS;
  95. for (i = 0; i < 0x300; i++)
  96. asm ("nop;");
  97. if ((*pFIO_FLAG_S) & CF_STAT_BITS) {
  98. cf_stat = 0;
  99. } else {
  100. cf_stat = 1;
  101. }
  102. *pFIO_EDGE = FIO_EDGE_BITS;
  103. *pFIO_POLAR = FIO_POLAR_BITS;
  104. if (cf_stat) {
  105. printf ("Booting from COMPACT flash\n");
  106. /* Set cycle time for CF */
  107. *(volatile unsigned long *) ambctl1 = CF_AMBCTL1VAL;
  108. for (i = 0; i < 0x1000; i++)
  109. asm ("nop;");
  110. for (i = 0; i < 0x1000; i++)
  111. asm ("nop;");
  112. for (i = 0; i < 0x1000; i++)
  113. asm ("nop;");
  114. serial_setbrg ();
  115. ide_init ();
  116. setenv ("bootargs", "");
  117. setenv ("bootcmd",
  118. "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000");
  119. } else {
  120. printf ("Booting from FLASH\n");
  121. }
  122. return 1;
  123. }
  124. #endif
  125. #ifdef CONFIG_STAMP_CF
  126. void cf_outb (unsigned char val, volatile unsigned char *addr)
  127. {
  128. /*
  129. * Set PF1 PF0 respectively to 0 1 to divert address
  130. * to the expansion memory banks
  131. */
  132. *pFIO_FLAG_S = CF_PF0;
  133. *pFIO_FLAG_C = CF_PF1;
  134. asm ("ssync;");
  135. *(addr) = val;
  136. asm ("ssync;");
  137. /* Setback PF1 PF0 to 0 0 to address external
  138. * memory banks */
  139. *(volatile unsigned short *) pFIO_FLAG_C = CF_PF1_PF0;
  140. asm ("ssync;");
  141. }
  142. unsigned char cf_inb (volatile unsigned char *addr)
  143. {
  144. volatile unsigned char c;
  145. *pFIO_FLAG_S = CF_PF0;
  146. *pFIO_FLAG_C = CF_PF1;
  147. asm ("ssync;");
  148. c = *(addr);
  149. asm ("ssync;");
  150. *pFIO_FLAG_C = CF_PF1_PF0;
  151. asm ("ssync;");
  152. return c;
  153. }
  154. void cf_insw (unsigned short *sect_buf, unsigned short *addr, int words)
  155. {
  156. int i;
  157. *pFIO_FLAG_S = CF_PF0;
  158. *pFIO_FLAG_C = CF_PF1;
  159. asm ("ssync;");
  160. for (i = 0; i < words; i++) {
  161. *(sect_buf + i) = *(addr);
  162. asm ("ssync;");
  163. }
  164. *pFIO_FLAG_C = CF_PF1_PF0;
  165. asm ("ssync;");
  166. }
  167. void cf_outsw (unsigned short *addr, unsigned short *sect_buf, int words)
  168. {
  169. int i;
  170. *pFIO_FLAG_S = CF_PF0;
  171. *pFIO_FLAG_C = CF_PF1;
  172. asm ("ssync;");
  173. for (i = 0; i < words; i++) {
  174. *(addr) = *(sect_buf + i);
  175. asm ("ssync;");
  176. }
  177. *pFIO_FLAG_C = CF_PF1_PF0;
  178. asm ("ssync;");
  179. }
  180. #endif
  181. void stamp_led_set (int LED1, int LED2, int LED3)
  182. {
  183. *pFIO_INEN &= ~(PF2 | PF3 | PF4);
  184. *pFIO_DIR |= (PF2 | PF3 | PF4);
  185. if (LED1 == STATUS_LED_OFF)
  186. *pFIO_FLAG_S = PF2;
  187. else
  188. *pFIO_FLAG_C = PF2;
  189. if (LED2 == STATUS_LED_OFF)
  190. *pFIO_FLAG_S = PF3;
  191. else
  192. *pFIO_FLAG_C = PF3;
  193. if (LED3 == STATUS_LED_OFF)
  194. *pFIO_FLAG_S = PF4;
  195. else
  196. *pFIO_FLAG_C = PF4;
  197. asm ("ssync;");
  198. }
  199. void show_boot_progress (int status)
  200. {
  201. switch (status) {
  202. case 1:
  203. stamp_led_set (STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
  204. break;
  205. case 2:
  206. stamp_led_set (STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
  207. break;
  208. case 3:
  209. stamp_led_set (STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
  210. break;
  211. case 4:
  212. stamp_led_set (STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
  213. break;
  214. case 5:
  215. case 6:
  216. stamp_led_set (STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
  217. break;
  218. case 7:
  219. case 8:
  220. stamp_led_set (STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
  221. break;
  222. case 9:
  223. case 10:
  224. case 11:
  225. case 12:
  226. case 13:
  227. case 14:
  228. case 15:
  229. stamp_led_set (STATUS_LED_OFF, STATUS_LED_OFF,
  230. STATUS_LED_OFF);
  231. break;
  232. default:
  233. stamp_led_set (STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);
  234. break;
  235. }
  236. }