stamp.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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", (SDRAM_tRCD >> 15), (SDRAM_tRP >> 11),
  52. (SDRAM_tRAS >> 6), ( SDRAM_tWR >> 19), (SDRAM_CL >> 2 ));
  53. printf("SDRAM Begin: 0x%x\n", CFG_SDRAM_BASE);
  54. printf("Bank size = %d MB\n", 128);
  55. #endif
  56. gd->bd->bi_memstart = CFG_SDRAM_BASE;
  57. gd->bd->bi_memsize = CFG_MAX_RAM_SIZE;
  58. return (gd->bd->bi_memsize);
  59. }
  60. void swap_to(int device_id)
  61. {
  62. if (device_id == ETHERNET)
  63. {
  64. *pFIO_DIR = PF0;
  65. asm("ssync;");
  66. *pFIO_FLAG_S = PF0;
  67. asm("ssync;");
  68. }
  69. else if (device_id == FLASH)
  70. {
  71. *pFIO_DIR = (PF4 | PF3 | PF2 | PF1 | PF0);
  72. *pFIO_FLAG_S = (PF4 | PF3 | PF2 );
  73. *pFIO_MASKA_D = (PF8 | PF6 | PF5);
  74. *pFIO_MASKB_D = (PF7);
  75. *pFIO_POLAR = (PF8 | PF6 | PF5 );
  76. *pFIO_EDGE = (PF8 | PF7 | PF6 | PF5);
  77. *pFIO_INEN = (PF8 | PF7 | PF6 | PF5);
  78. *pFIO_FLAG_D = (PF4 | PF3 | PF2 );
  79. asm("ssync;");
  80. }
  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++) asm("nop;");
  96. if ( (*pFIO_FLAG_S) & CF_STAT_BITS)
  97. {
  98. cf_stat = 0;
  99. }
  100. else
  101. {
  102. cf_stat = 1;
  103. }
  104. *pFIO_EDGE = FIO_EDGE_BITS;
  105. *pFIO_POLAR = FIO_POLAR_BITS;
  106. if (cf_stat)
  107. {
  108. printf ("Booting from COMPACT flash\n");
  109. /* Set cycle time for CF */
  110. *(volatile unsigned long *) ambctl1 = CF_AMBCTL1VAL;
  111. for (i=0; i < 0x1000 ; i++) asm("nop;");
  112. for (i=0; i < 0x1000 ; i++) asm("nop;");
  113. for (i=0; i < 0x1000 ; i++) asm("nop;");
  114. serial_setbrg();
  115. ide_init();
  116. setenv ("bootargs", "");
  117. setenv ("bootcmd", "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000" );
  118. }
  119. else
  120. {
  121. printf ("Booting from FLASH\n");
  122. }
  123. return 1;
  124. }
  125. #endif
  126. #ifdef CONFIG_STAMP_CF
  127. void cf_outb(unsigned char val, volatile unsigned char* addr)
  128. {
  129. /*
  130. * Set PF1 PF0 respectively to 0 1 to divert address
  131. * to the expansion memory banks
  132. */
  133. *pFIO_FLAG_S = CF_PF0;
  134. *pFIO_FLAG_C = CF_PF1;
  135. asm("ssync;");
  136. *(addr) = val;
  137. asm("ssync;");
  138. /* Setback PF1 PF0 to 0 0 to address external
  139. * memory banks */
  140. *(volatile unsigned short *) pFIO_FLAG_C = CF_PF1_PF0;
  141. asm("ssync;");
  142. }
  143. unsigned char cf_inb(volatile unsigned char *addr)
  144. {
  145. volatile unsigned char c;
  146. *pFIO_FLAG_S = CF_PF0;
  147. *pFIO_FLAG_C = CF_PF1;
  148. asm("ssync;");
  149. c = *(addr);
  150. asm("ssync;");
  151. *pFIO_FLAG_C = CF_PF1_PF0;
  152. asm("ssync;");
  153. return c;
  154. }
  155. void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
  156. {
  157. int i;
  158. *pFIO_FLAG_S = CF_PF0;
  159. *pFIO_FLAG_C = CF_PF1;
  160. asm("ssync;");
  161. for (i = 0;i < words; i++)
  162. {
  163. *(sect_buf + i) = *(addr);
  164. asm("ssync;");
  165. }
  166. *pFIO_FLAG_C = CF_PF1_PF0;
  167. asm("ssync;");
  168. }
  169. void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
  170. {
  171. int i;
  172. *pFIO_FLAG_S = CF_PF0;
  173. *pFIO_FLAG_C = CF_PF1;
  174. asm("ssync;");
  175. for (i = 0;i < words; i++)
  176. {
  177. *(addr) = *(sect_buf + i);
  178. asm("ssync;");
  179. }
  180. *pFIO_FLAG_C = CF_PF1_PF0;
  181. asm("ssync;");
  182. }
  183. #endif
  184. void stamp_led_set(int LED1, int LED2, int LED3)
  185. {
  186. *pFIO_INEN &= ~( PF2 | PF3 | PF4);
  187. *pFIO_DIR |= ( PF2 | PF3 | PF4);
  188. if(LED1 == STATUS_LED_OFF)
  189. *pFIO_FLAG_S = PF2;
  190. else
  191. *pFIO_FLAG_C = PF2;
  192. if(LED2 == STATUS_LED_OFF)
  193. *pFIO_FLAG_S = PF3;
  194. else
  195. *pFIO_FLAG_C = PF3;
  196. if(LED3 == STATUS_LED_OFF)
  197. *pFIO_FLAG_S = PF4;
  198. else
  199. *pFIO_FLAG_C = PF4;
  200. asm("ssync;");
  201. }
  202. void show_boot_progress(int status)
  203. {
  204. switch(status){
  205. case 1:
  206. stamp_led_set(STATUS_LED_OFF,STATUS_LED_OFF,STATUS_LED_ON);
  207. break;
  208. case 2:
  209. stamp_led_set(STATUS_LED_OFF,STATUS_LED_ON,STATUS_LED_OFF);
  210. break;
  211. case 3:
  212. stamp_led_set(STATUS_LED_OFF,STATUS_LED_ON,STATUS_LED_ON);
  213. break;
  214. case 4:
  215. stamp_led_set(STATUS_LED_ON,STATUS_LED_OFF,STATUS_LED_OFF);
  216. break;
  217. case 5:
  218. case 6:
  219. stamp_led_set(STATUS_LED_ON,STATUS_LED_OFF,STATUS_LED_ON);
  220. break;
  221. case 7:
  222. case 8:
  223. stamp_led_set(STATUS_LED_ON,STATUS_LED_ON,STATUS_LED_OFF);
  224. break;
  225. case 9:
  226. case 10:
  227. case 11:
  228. case 12:
  229. case 13:
  230. case 14:
  231. case 15:
  232. stamp_led_set(STATUS_LED_OFF,STATUS_LED_OFF,STATUS_LED_OFF);
  233. break;
  234. default:
  235. stamp_led_set(STATUS_LED_ON,STATUS_LED_ON,STATUS_LED_ON);
  236. break;
  237. }
  238. }