luan.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*
  2. * (C) Copyright 2005
  3. * John Otken, jotken@softadvances.com
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <command.h>
  25. #include <asm/ppc4xx.h>
  26. #include <asm/processor.h>
  27. #include <asm/ppc4xx-isram.h>
  28. #include <spd_sdram.h>
  29. #include "epld.h"
  30. DECLARE_GLOBAL_DATA_PTR;
  31. extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
  32. /*************************************************************************
  33. * int board_early_init_f()
  34. *
  35. ************************************************************************/
  36. int board_early_init_f(void)
  37. {
  38. u32 mfr;
  39. mtebc( PB0AP, 0x03800000 ); /* set chip selects */
  40. mtebc( PB0CR, 0xffc58000 ); /* ebc0_b0cr, 4MB at 0xffc00000 CS0 */
  41. mtebc( PB1AP, 0x03800000 );
  42. mtebc( PB1CR, 0xff018000 ); /* ebc0_b1cr, 1MB at 0xff000000 CS1 */
  43. mtebc( PB2AP, 0x03800000 );
  44. mtebc( PB2CR, 0xff838000 ); /* ebc0_b2cr, 2MB at 0xff800000 CS2 */
  45. mtdcr( UIC1SR, 0xffffffff ); /* Clear all interrupts */
  46. mtdcr( UIC1ER, 0x00000000 ); /* disable all interrupts */
  47. mtdcr( UIC1CR, 0x00000000 ); /* Set Critical / Non Critical interrupts */
  48. mtdcr( UIC1PR, 0x7fff83ff ); /* Set Interrupt Polarities */
  49. mtdcr( UIC1TR, 0x001f8000 ); /* Set Interrupt Trigger Levels */
  50. mtdcr( UIC1VR, 0x00000001 ); /* Set Vect base=0,INT31 Highest priority */
  51. mtdcr( UIC1SR, 0x00000000 ); /* clear all interrupts */
  52. mtdcr( UIC1SR, 0xffffffff );
  53. mtdcr( UIC0SR, 0xffffffff ); /* Clear all interrupts */
  54. mtdcr( UIC0ER, 0x00000000 ); /* disable all interrupts excepted cascade */
  55. mtdcr( UIC0CR, 0x00000001 ); /* Set Critical / Non Critical interrupts */
  56. mtdcr( UIC0PR, 0xffffffff ); /* Set Interrupt Polarities */
  57. mtdcr( UIC0TR, 0x01000004 ); /* Set Interrupt Trigger Levels */
  58. mtdcr( UIC0VR, 0x00000001 ); /* Set Vect base=0,INT31 Highest priority */
  59. mtdcr( UIC0SR, 0x00000000 ); /* clear all interrupts */
  60. mtdcr( UIC0SR, 0xffffffff );
  61. mfsdr(SDR0_MFR, mfr);
  62. mfr |= SDR0_MFR_FIXD; /* Workaround for PCI/DMA */
  63. mtsdr(SDR0_MFR, mfr);
  64. return 0;
  65. }
  66. /*************************************************************************
  67. * int misc_init_r()
  68. *
  69. ************************************************************************/
  70. int misc_init_r(void)
  71. {
  72. volatile epld_t *x = (epld_t *) CONFIG_SYS_EPLD_BASE;
  73. /* set modes of operation */
  74. x->ethuart |= EPLD2_ETH_MODE_10 | EPLD2_ETH_MODE_100 |
  75. EPLD2_ETH_MODE_1000 | EPLD2_ETH_DUPLEX_MODE;
  76. /* clear ETHERNET_AUTO_NEGO bit to turn on autonegotiation */
  77. x->ethuart &= ~EPLD2_ETH_AUTO_NEGO;
  78. /* put Ethernet+PHY in reset */
  79. x->ethuart &= ~EPLD2_RESET_ETH_N;
  80. udelay(10000);
  81. /* take Ethernet+PHY out of reset */
  82. x->ethuart |= EPLD2_RESET_ETH_N;
  83. return 0;
  84. }
  85. /*************************************************************************
  86. * int checkboard()
  87. *
  88. ************************************************************************/
  89. int checkboard(void)
  90. {
  91. char buf[64];
  92. int i = getenv_f("serial#", buf, sizeof(buf));
  93. printf("Board: Luan - AMCC PPC440SP Evaluation Board");
  94. if (i > 0) {
  95. puts(", serial# ");
  96. puts(buf);
  97. }
  98. putc('\n');
  99. return 0;
  100. }
  101. /*
  102. * Override the default functions in arch/powerpc/cpu/ppc4xx/44x_spd_ddr2.c with
  103. * board specific values.
  104. */
  105. u32 ddr_clktr(u32 default_val) {
  106. return (SDRAM_CLKTR_CLKP_180_DEG_ADV);
  107. }
  108. /*************************************************************************
  109. * hw_watchdog_reset
  110. *
  111. * This routine is called to reset (keep alive) the watchdog timer
  112. *
  113. ************************************************************************/
  114. #if defined(CONFIG_HW_WATCHDOG)
  115. void hw_watchdog_reset(void)
  116. {
  117. }
  118. #endif
  119. /*************************************************************************
  120. * int on_off()
  121. *
  122. ************************************************************************/
  123. static int on_off( const char *s )
  124. {
  125. if (strcmp(s, "on") == 0) {
  126. return 1;
  127. } else if (strcmp(s, "off") == 0) {
  128. return 0;
  129. }
  130. return -1;
  131. }
  132. /*************************************************************************
  133. * void l2cache_disable()
  134. *
  135. ************************************************************************/
  136. static void l2cache_disable(void)
  137. {
  138. mtdcr( L2_CACHE_CFG, 0 );
  139. }
  140. /*************************************************************************
  141. * void l2cache_enable()
  142. *
  143. ************************************************************************/
  144. static void l2cache_enable(void) /* see p258 7.4.1 Enabling L2 Cache */
  145. {
  146. mtdcr( L2_CACHE_CFG, 0x80000000 ); /* enable L2_MODE L2_CFG[L2M] */
  147. mtdcr( L2_CACHE_ADDR, 0 ); /* set L2_ADDR with all zeros */
  148. mtdcr( L2_CACHE_CMD, 0x80000000 ); /* issue HCLEAR command via L2_CMD */
  149. while (!(mfdcr( L2_CACHE_STAT ) & 0x80000000 )) ;; /* poll L2_SR for completion */
  150. mtdcr( L2_CACHE_CMD, 0x10000000 ); /* clear cache errors L2_CMD[CCP] */
  151. mtdcr( L2_CACHE_CMD, 0x08000000 ); /* clear tag errors L2_CMD[CTE] */
  152. mtdcr( L2_CACHE_SNP0, 0 ); /* snoop registers */
  153. mtdcr( L2_CACHE_SNP1, 0 );
  154. __asm__ volatile ("sync"); /* msync */
  155. mtdcr( L2_CACHE_CFG, 0xe0000000 ); /* inst and data use L2 */
  156. __asm__ volatile ("sync");
  157. }
  158. /*************************************************************************
  159. * int l2cache_status()
  160. *
  161. ************************************************************************/
  162. static int l2cache_status(void)
  163. {
  164. return (mfdcr( L2_CACHE_CFG ) & 0x60000000) != 0;
  165. }
  166. /*************************************************************************
  167. * int do_l2cache()
  168. *
  169. ************************************************************************/
  170. int do_l2cache( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] )
  171. {
  172. switch (argc) {
  173. case 2: /* on / off */
  174. switch (on_off(argv[1])) {
  175. case 0: l2cache_disable();
  176. break;
  177. case 1: l2cache_enable();
  178. break;
  179. }
  180. /* FALL TROUGH */
  181. case 1: /* get status */
  182. printf ("L2 Cache is %s\n",
  183. l2cache_status() ? "ON" : "OFF");
  184. return 0;
  185. default:
  186. return cmd_usage(cmdtp);
  187. }
  188. return 0;
  189. }
  190. U_BOOT_CMD(
  191. l2cache, 2, 1, do_l2cache,
  192. "enable or disable L2 cache",
  193. "[on, off]\n"
  194. " - enable or disable L2 cache"
  195. );