m54455evb.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * (C) Copyright 2000-2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
  6. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  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 <pci.h>
  28. #include <asm/immap.h>
  29. DECLARE_GLOBAL_DATA_PTR;
  30. int checkboard(void)
  31. {
  32. puts("Board: ");
  33. puts("Freescale M54455 EVB\n");
  34. return 0;
  35. };
  36. long int initdram(int board_type)
  37. {
  38. volatile sdramc_t *sdram = (volatile sdramc_t *)(MMAP_SDRAM);
  39. volatile gpio_t *gpio = (volatile gpio_t *)(MMAP_GPIO);
  40. u32 dramsize, i;
  41. dramsize = CFG_SDRAM_SIZE * 0x100000 >> 1;
  42. for (i = 0x13; i < 0x20; i++) {
  43. if (dramsize == (1 << i))
  44. break;
  45. }
  46. i--;
  47. gpio->mscr_sdram = 0xAA;
  48. sdram->sdcs0 = (CFG_SDRAM_BASE | i);
  49. sdram->sdcs1 = (CFG_SDRAM_BASE1 | i);
  50. sdram->sdcfg1 = CFG_SDRAM_CFG1;
  51. sdram->sdcfg2 = CFG_SDRAM_CFG2;
  52. /* Issue PALL */
  53. sdram->sdcr = CFG_SDRAM_CTRL | 2;
  54. /* Issue LEMR */
  55. sdram->sdmr = CFG_SDRAM_EMOD | 0x408;
  56. sdram->sdmr = CFG_SDRAM_MODE | 0x300;
  57. udelay(500);
  58. /* Issue PALL */
  59. sdram->sdcr = CFG_SDRAM_CTRL | 2;
  60. /* Perform two refresh cycles */
  61. sdram->sdcr = CFG_SDRAM_CTRL | 4;
  62. sdram->sdcr = CFG_SDRAM_CTRL | 4;
  63. sdram->sdmr = CFG_SDRAM_MODE | 0x200;
  64. sdram->sdcr = (CFG_SDRAM_CTRL & ~0x80000000) | 0x10000c00;
  65. udelay(100);
  66. return (dramsize << 1);
  67. };
  68. int testdram(void)
  69. {
  70. /* TODO: XXX XXX XXX */
  71. printf("DRAM test not implemented!\n");
  72. return (0);
  73. }
  74. #if defined(CONFIG_CMD_IDE)
  75. #include <ata.h>
  76. int ide_preinit(void)
  77. {
  78. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  79. gpio->par_fec |= (gpio->par_fec & GPIO_PAR_FEC_FEC1_MASK) | 0x10;
  80. gpio->par_feci2c |=
  81. (gpio->par_feci2c & 0xF0FF) | (GPIO_PAR_FECI2C_MDC1_ATA_DIOR |
  82. GPIO_PAR_FECI2C_MDIO1_ATA_DIOW);
  83. gpio->par_ata |=
  84. (GPIO_PAR_ATA_BUFEN | GPIO_PAR_ATA_CS1 | GPIO_PAR_ATA_CS0 |
  85. GPIO_PAR_ATA_DA2 | GPIO_PAR_ATA_DA1 | GPIO_PAR_ATA_DA0
  86. | GPIO_PAR_ATA_RESET_RESET | GPIO_PAR_ATA_DMARQ_DMARQ |
  87. GPIO_PAR_ATA_IORDY_IORDY);
  88. gpio->par_pci |=
  89. (GPIO_PAR_PCI_GNT3_ATA_DMACK | GPIO_PAR_PCI_REQ3_ATA_INTRQ);
  90. return (0);
  91. }
  92. void ide_set_reset(int idereset)
  93. {
  94. volatile atac_t *ata = (atac_t *) MMAP_ATA;
  95. long period;
  96. /* t1, t2, t3, t4, t5, t6, t9, tRD, tA */
  97. int piotms[5][9] = {
  98. {70, 165, 60, 30, 50, 5, 20, 0, 35}, /* PIO 0 */
  99. {50, 125, 45, 20, 35, 5, 15, 0, 35}, /* PIO 1 */
  100. {30, 100, 30, 15, 20, 5, 10, 0, 35}, /* PIO 2 */
  101. {30, 80, 30, 10, 20, 5, 10, 0, 35}, /* PIO 3 */
  102. {25, 70, 20, 10, 20, 5, 10, 0, 35}
  103. }; /* PIO 4 */
  104. if (idereset) {
  105. ata->cr = 0; /* control reset */
  106. udelay(10000);
  107. } else {
  108. #define CALC_TIMING(t) (t + period - 1) / period
  109. period = 1000000000 / gd->bus_clk; /* period in ns */
  110. /*ata->ton = CALC_TIMING (180); */
  111. ata->t1 = CALC_TIMING(piotms[2][0]);
  112. ata->t2w = CALC_TIMING(piotms[2][1]);
  113. ata->t2r = CALC_TIMING(piotms[2][1]);
  114. ata->ta = CALC_TIMING(piotms[2][8]);
  115. ata->trd = CALC_TIMING(piotms[2][7]);
  116. ata->t4 = CALC_TIMING(piotms[2][3]);
  117. ata->t9 = CALC_TIMING(piotms[2][6]);
  118. ata->cr = 0x40; /* IORDY enable */
  119. udelay(200000);
  120. ata->cr |= 0x01; /* IORDY enable */
  121. }
  122. }
  123. #endif
  124. #if defined(CONFIG_PCI)
  125. /*
  126. * Initialize PCI devices, report devices found.
  127. */
  128. static struct pci_controller hose;
  129. extern void pci_mcf5445x_init(struct pci_controller *hose);
  130. void pci_init_board(void)
  131. {
  132. pci_mcf5445x_init(&hose);
  133. }
  134. #endif /* CONFIG_PCI */