cpu.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * U-boot - cpu.c CPU specific functions
  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/blackfin.h>
  29. #include <command.h>
  30. #include <asm/entry.h>
  31. #define SSYNC() asm("ssync;")
  32. #define CACHE_ON 1
  33. #define CACHE_OFF 0
  34. /* Data Attibutes*/
  35. #define SDRAM_IGENERIC (PAGE_SIZE_4MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID)
  36. #define SDRAM_IKERNEL (PAGE_SIZE_4MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | CPLB_LOCK)
  37. #define L1_IMEMORY (PAGE_SIZE_1MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | CPLB_LOCK)
  38. #define SDRAM_INON_CHBL (PAGE_SIZE_4MB | CPLB_USER_RD | CPLB_VALID)
  39. #define ANOMALY_05000158 0x200
  40. #define SDRAM_DGENERIC (PAGE_SIZE_4MB | CPLB_L1_CHBL | CPLB_WT | CPLB_L1_AOW | CPLB_SUPV_WR | CPLB_USER_RD | CPLB_USER_WR | CPLB_VALID | ANOMALY_05000158)
  41. #define SDRAM_DNON_CHBL (PAGE_SIZE_4MB | CPLB_WT | CPLB_L1_AOW | CPLB_SUPV_WR | CPLB_USER_WR | CPLB_USER_RD | CPLB_VALID | ANOMALY_05000158)
  42. #define SDRAM_DKERNEL (PAGE_SIZE_4MB | CPLB_L1_CHBL | CPLB_WT | CPLB_L1_AOW | CPLB_USER_RD | CPLB_SUPV_WR | CPLB_USER_WR | CPLB_VALID | CPLB_LOCK | ANOMALY_05000158)
  43. #define L1_DMEMORY (PAGE_SIZE_4KB | CPLB_L1_CHBL | CPLB_L1_AOW | CPLB_WT | CPLB_SUPV_WR | CPLB_USER_WR | CPLB_VALID | ANOMALY_05000158)
  44. #define SDRAM_EBIU (PAGE_SIZE_4MB | CPLB_WT | CPLB_L1_AOW | CPLB_USER_RD | CPLB_USER_WR | CPLB_SUPV_WR | CPLB_VALID | ANOMALY_05000158)
  45. static unsigned int icplb_table[16][2]={
  46. {0xFFA00000, L1_IMEMORY},
  47. {0x00000000, SDRAM_IKERNEL}, /*SDRAM_Page1*/
  48. {0x00400000, SDRAM_IKERNEL}, /*SDRAM_Page1*/
  49. {0x07C00000, SDRAM_IKERNEL}, /*SDRAM_Page14*/
  50. {0x00800000, SDRAM_IGENERIC}, /*SDRAM_Page2*/
  51. {0x00C00000, SDRAM_IGENERIC}, /*SDRAM_Page2*/
  52. {0x01000000, SDRAM_IGENERIC}, /*SDRAM_Page4*/
  53. {0x01400000, SDRAM_IGENERIC}, /*SDRAM_Page5*/
  54. {0x01800000, SDRAM_IGENERIC}, /*SDRAM_Page6*/
  55. {0x01C00000, SDRAM_IGENERIC}, /*SDRAM_Page7*/
  56. {0x02000000, SDRAM_IGENERIC}, /*SDRAM_Page8*/
  57. {0x02400000, SDRAM_IGENERIC}, /*SDRAM_Page9*/
  58. {0x02800000, SDRAM_IGENERIC}, /*SDRAM_Page10*/
  59. {0x02C00000, SDRAM_IGENERIC}, /*SDRAM_Page11*/
  60. {0x03000000, SDRAM_IGENERIC}, /*SDRAM_Page12*/
  61. {0x03400000, SDRAM_IGENERIC}, /*SDRAM_Page13*/
  62. };
  63. static unsigned int dcplb_table[16][2]={
  64. {0xFFA00000,L1_DMEMORY},
  65. {0x00000000,SDRAM_DKERNEL}, /*SDRAM_Page1*/
  66. {0x00400000,SDRAM_DKERNEL}, /*SDRAM_Page1*/
  67. {0x07C00000,SDRAM_DKERNEL}, /*SDRAM_Page15*/
  68. {0x00800000,SDRAM_DGENERIC}, /*SDRAM_Page2*/
  69. {0x00C00000,SDRAM_DGENERIC}, /*SDRAM_Page3*/
  70. {0x01000000,SDRAM_DGENERIC}, /*SDRAM_Page4*/
  71. {0x01400000,SDRAM_DGENERIC}, /*SDRAM_Page5*/
  72. {0x01800000,SDRAM_DGENERIC}, /*SDRAM_Page6*/
  73. {0x01C00000,SDRAM_DGENERIC}, /*SDRAM_Page7*/
  74. {0x02000000,SDRAM_DGENERIC}, /*SDRAM_Page8*/
  75. {0x02400000,SDRAM_DGENERIC}, /*SDRAM_Page9*/
  76. {0x02800000,SDRAM_DGENERIC}, /*SDRAM_Page10*/
  77. {0x02C00000,SDRAM_DGENERIC}, /*SDRAM_Page11*/
  78. {0x03000000,SDRAM_DGENERIC}, /*SDRAM_Page12*/
  79. {0x20000000,SDRAM_EBIU}, /*For Network */
  80. };
  81. int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  82. {
  83. __asm__ __volatile__
  84. ("cli r3;"
  85. "P0 = %0;"
  86. "JUMP (P0);"
  87. :
  88. : "r" (L1_ISRAM)
  89. );
  90. return 0;
  91. }
  92. /* These functions are just used to satisfy the linker */
  93. int cpu_init(void)
  94. {
  95. return 0;
  96. }
  97. int cleanup_before_linux(void)
  98. {
  99. return 0;
  100. }
  101. void icache_enable(void)
  102. {
  103. unsigned int *I0,*I1;
  104. int i;
  105. I0 = (unsigned int *)ICPLB_ADDR0;
  106. I1 = (unsigned int *)ICPLB_DATA0;
  107. for(i=0;i<16;i++){
  108. *I0++ = icplb_table[i][0];
  109. *I1++ = icplb_table[i][1];
  110. }
  111. cli();
  112. SSYNC();
  113. *(unsigned int *)IMEM_CONTROL = IMC | ENICPLB;
  114. SSYNC();
  115. sti();
  116. }
  117. void icache_disable(void)
  118. {
  119. cli();
  120. SSYNC();
  121. *(unsigned int *)IMEM_CONTROL &= ~(IMC | ENICPLB);
  122. SSYNC();
  123. sti();
  124. }
  125. int icache_status(void)
  126. {
  127. unsigned int value;
  128. value = *(unsigned int *)IMEM_CONTROL;
  129. if( value & (IMC|ENICPLB) )
  130. return CACHE_ON;
  131. else
  132. return CACHE_OFF;
  133. }
  134. void dcache_enable(void)
  135. {
  136. unsigned int *I0,*I1;
  137. unsigned int temp;
  138. int i;
  139. I0 = (unsigned int *)DCPLB_ADDR0;
  140. I1 = (unsigned int *)DCPLB_DATA0;
  141. for(i=0;i<16;i++){
  142. *I0++ = dcplb_table[i][0];
  143. *I1++ = dcplb_table[i][1];
  144. }
  145. cli();
  146. temp = *(unsigned int *)DMEM_CONTROL;
  147. SSYNC();
  148. *(unsigned int *)DMEM_CONTROL = ACACHE_BCACHE |ENDCPLB |PORT_PREF0|temp;
  149. SSYNC();
  150. sti();
  151. }
  152. void dcache_disable(void)
  153. {
  154. cli();
  155. SSYNC();
  156. *(unsigned int *)DMEM_CONTROL &= ~(ACACHE_BCACHE |ENDCPLB |PORT_PREF0);
  157. SSYNC();
  158. sti();
  159. }
  160. int dcache_status(void)
  161. {
  162. unsigned int value;
  163. value = *(unsigned int *)DMEM_CONTROL;
  164. if( value & (ENDCPLB))
  165. return CACHE_ON;
  166. else
  167. return CACHE_OFF;
  168. }