ep88x.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (C) 2005 Arabella Software Ltd.
  3. * Yuli Barcohen <yuli@arabellasw.com>
  4. *
  5. * Support for Embedded Planet EP88x boards.
  6. * Tested on EP88xC with MPC885 CPU, 64MB SDRAM and 16MB flash.
  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 <mpc8xx.h>
  28. /*
  29. * SDRAM uses two Micron chips.
  30. * Minimal CPU frequency is 40MHz.
  31. */
  32. static uint sdram_table[] = {
  33. /* Single read (offset 0x00 in UPM RAM) */
  34. 0xEFCBCC04, 0x0F37C804, 0x0EEEC004, 0x01B98404,
  35. 0x1FF74C00, 0xFFFFCC05, 0xFFFFCC05, 0xFFFFCC05,
  36. /* Burst read (offset 0x08 in UPM RAM) */
  37. 0xEFCBCC04, 0x0F37C804, 0x0EEEC004, 0x00BDC404,
  38. 0x00FFCC00, 0x00FFCC00, 0x01FB8C00, 0x1FF74C00,
  39. 0xFFFFCC05, 0xFFFFCC05, 0xFFFFCC05, 0xFFFFCC05,
  40. 0xFFFFCC05, 0xFFFFCC05, 0xFFFFCC05, 0xFFFFCC05,
  41. /* Single write (offset 0x18 in UPM RAM) */
  42. 0xEFCBCC04, 0x0F37C804, 0x0EEE8002, 0x01B90404,
  43. 0x1FF74C05, 0xFFFFCC05, 0xFFFFCC05, 0xFFFFCC05,
  44. /* Burst write (offset 0x20 in UPM RAM) */
  45. 0xEFCBCC04, 0x0F37C804, 0x0EEE8000, 0x00BD4400,
  46. 0x00FFCC00, 0x00FFCC02, 0x01FB8C04, 0x1FF74C05,
  47. 0xFFFFCC05, 0xFFFFCC05, 0xFFFFCC05, 0xFFFFCC05,
  48. 0xFFFFCC05, 0xFFFFCC05, 0xFFFFCC05, 0xFFFFCC05,
  49. /* Refresh (offset 0x30 in UPM RAM) */
  50. 0xEFFACC04, 0x0FF5CC04, 0x0FFFCC04, 0x1FFFCC04,
  51. 0xFFFFCC05, 0xFFFFCC05, 0xEFFB8C34, 0x0FF74C34,
  52. 0x0FFACCB4, 0x0FF5CC34, 0x0FFFC034, 0x0FFFC0B4,
  53. /* Exception (offset 0x3C in UPM RAM) */
  54. 0x0FEA8034, 0x1FB54034, 0xFFFFCC34, 0xFFFFCC05
  55. };
  56. int board_early_init_f (void)
  57. {
  58. vu_char *bcsr = (vu_char *)CFG_BCSR;
  59. bcsr[0] |= 0x0C; /* Turn the LEDs off */
  60. bcsr[2] |= 0x08; /* Enable flash WE# line - necessary for
  61. flash detection by CFI driver
  62. */
  63. #if defined(CONFIG_8xx_CONS_SMC1)
  64. bcsr[6] |= 0x10; /* Enables RS-232 transceiver */
  65. #endif
  66. #if defined(CONFIG_8xx_CONS_SCC2)
  67. bcsr[7] |= 0x10; /* Enables RS-232 transceiver */
  68. #endif
  69. #ifdef CONFIG_ETHER_ON_FEC1
  70. bcsr[8] |= 0xC0; /* Enable Ethernet 1 PHY */
  71. #endif
  72. #ifdef CONFIG_ETHER_ON_FEC2
  73. bcsr[8] |= 0x30; /* Enable Ethernet 2 PHY */
  74. #endif
  75. return 0;
  76. }
  77. phys_size_t initdram (int board_type)
  78. {
  79. long int msize;
  80. volatile immap_t *immap = (volatile immap_t *)CFG_IMMR;
  81. volatile memctl8xx_t *memctl = &immap->im_memctl;
  82. upmconfig(UPMA, sdram_table, sizeof(sdram_table) / sizeof(uint));
  83. /* Configure SDRAM refresh */
  84. memctl->memc_mptpr = MPTPR_PTP_DIV2; /* BRGCLK/2 */
  85. memctl->memc_mamr = (65 << 24) | CFG_MAMR; /* No refresh */
  86. udelay(100);
  87. /* Run MRS pattern from location 0x36 */
  88. memctl->memc_mar = 0x88;
  89. memctl->memc_mcr = 0x80002236;
  90. udelay(100);
  91. memctl->memc_mamr |= MAMR_PTAE; /* Enable refresh */
  92. memctl->memc_or1 = ~(CFG_SDRAM_MAX_SIZE - 1) | OR_CSNT_SAM;
  93. memctl->memc_br1 = CFG_SDRAM_BASE | BR_PS_32 | BR_MS_UPMA | BR_V;
  94. msize = get_ram_size(CFG_SDRAM_BASE, CFG_SDRAM_MAX_SIZE);
  95. memctl->memc_or1 |= ~(msize - 1);
  96. return msize;
  97. }
  98. int checkboard( void )
  99. {
  100. vu_char *bcsr = (vu_char *)CFG_BCSR;
  101. puts("Board: ");
  102. switch (bcsr[15]) {
  103. case 0xE7:
  104. puts("EP88xC 1.0");
  105. break;
  106. default:
  107. printf("unknown ID=%02X", bcsr[15]);
  108. }
  109. printf(" CPLD revision %d\n", bcsr[14]);
  110. return 0;
  111. }