m54455evb.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. phys_size_t initdram(int board_type)
  37. {
  38. u32 dramsize;
  39. #ifdef CONFIG_CF_SBF
  40. /*
  41. * Serial Boot: The dram is already initialized in start.S
  42. * only require to return DRAM size
  43. */
  44. dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000 >> 1;
  45. #else
  46. volatile sdramc_t *sdram = (volatile sdramc_t *)(MMAP_SDRAM);
  47. volatile gpio_t *gpio = (volatile gpio_t *)(MMAP_GPIO);
  48. u32 i;
  49. dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000 >> 1;
  50. for (i = 0x13; i < 0x20; i++) {
  51. if (dramsize == (1 << i))
  52. break;
  53. }
  54. i--;
  55. gpio->mscr_sdram = CONFIG_SYS_SDRAM_DRV_STRENGTH;
  56. sdram->sdcs0 = (CONFIG_SYS_SDRAM_BASE | i);
  57. sdram->sdcs1 = (CONFIG_SYS_SDRAM_BASE1 | i);
  58. sdram->sdcfg1 = CONFIG_SYS_SDRAM_CFG1;
  59. sdram->sdcfg2 = CONFIG_SYS_SDRAM_CFG2;
  60. /* Issue PALL */
  61. sdram->sdcr = CONFIG_SYS_SDRAM_CTRL | 2;
  62. /* Issue LEMR */
  63. sdram->sdmr = CONFIG_SYS_SDRAM_EMOD | 0x408;
  64. sdram->sdmr = CONFIG_SYS_SDRAM_MODE | 0x300;
  65. udelay(500);
  66. /* Issue PALL */
  67. sdram->sdcr = CONFIG_SYS_SDRAM_CTRL | 2;
  68. /* Perform two refresh cycles */
  69. sdram->sdcr = CONFIG_SYS_SDRAM_CTRL | 4;
  70. sdram->sdcr = CONFIG_SYS_SDRAM_CTRL | 4;
  71. sdram->sdmr = CONFIG_SYS_SDRAM_MODE | 0x200;
  72. sdram->sdcr = (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00;
  73. udelay(100);
  74. #endif
  75. return (dramsize << 1);
  76. };
  77. int testdram(void)
  78. {
  79. /* TODO: XXX XXX XXX */
  80. printf("DRAM test not implemented!\n");
  81. return (0);
  82. }
  83. #if defined(CONFIG_CMD_IDE)
  84. #include <ata.h>
  85. int ide_preinit(void)
  86. {
  87. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  88. gpio->par_fec |= (gpio->par_fec & GPIO_PAR_FEC_FEC1_MASK) | 0x10;
  89. gpio->par_feci2c |=
  90. (gpio->par_feci2c & 0xF0FF) | (GPIO_PAR_FECI2C_MDC1_ATA_DIOR |
  91. GPIO_PAR_FECI2C_MDIO1_ATA_DIOW);
  92. gpio->par_ata |=
  93. (GPIO_PAR_ATA_BUFEN | GPIO_PAR_ATA_CS1 | GPIO_PAR_ATA_CS0 |
  94. GPIO_PAR_ATA_DA2 | GPIO_PAR_ATA_DA1 | GPIO_PAR_ATA_DA0
  95. | GPIO_PAR_ATA_RESET_RESET | GPIO_PAR_ATA_DMARQ_DMARQ |
  96. GPIO_PAR_ATA_IORDY_IORDY);
  97. gpio->par_pci |=
  98. (GPIO_PAR_PCI_GNT3_ATA_DMACK | GPIO_PAR_PCI_REQ3_ATA_INTRQ);
  99. return (0);
  100. }
  101. void ide_set_reset(int idereset)
  102. {
  103. volatile atac_t *ata = (atac_t *) MMAP_ATA;
  104. long period;
  105. /* t1, t2, t3, t4, t5, t6, t9, tRD, tA */
  106. int piotms[5][9] = {
  107. {70, 165, 60, 30, 50, 5, 20, 0, 35}, /* PIO 0 */
  108. {50, 125, 45, 20, 35, 5, 15, 0, 35}, /* PIO 1 */
  109. {30, 100, 30, 15, 20, 5, 10, 0, 35}, /* PIO 2 */
  110. {30, 80, 30, 10, 20, 5, 10, 0, 35}, /* PIO 3 */
  111. {25, 70, 20, 10, 20, 5, 10, 0, 35}
  112. }; /* PIO 4 */
  113. if (idereset) {
  114. ata->cr = 0; /* control reset */
  115. udelay(10000);
  116. } else {
  117. #define CALC_TIMING(t) (t + period - 1) / period
  118. period = 1000000000 / gd->bus_clk; /* period in ns */
  119. /*ata->ton = CALC_TIMING (180); */
  120. ata->t1 = CALC_TIMING(piotms[2][0]);
  121. ata->t2w = CALC_TIMING(piotms[2][1]);
  122. ata->t2r = CALC_TIMING(piotms[2][1]);
  123. ata->ta = CALC_TIMING(piotms[2][8]);
  124. ata->trd = CALC_TIMING(piotms[2][7]);
  125. ata->t4 = CALC_TIMING(piotms[2][3]);
  126. ata->t9 = CALC_TIMING(piotms[2][6]);
  127. ata->cr = 0x40; /* IORDY enable */
  128. udelay(200000);
  129. ata->cr |= 0x01; /* IORDY enable */
  130. }
  131. }
  132. #endif
  133. #if defined(CONFIG_PCI)
  134. /*
  135. * Initialize PCI devices, report devices found.
  136. */
  137. static struct pci_controller hose;
  138. extern void pci_mcf5445x_init(struct pci_controller *hose);
  139. void pci_init_board(void)
  140. {
  141. pci_mcf5445x_init(&hose);
  142. }
  143. #endif /* CONFIG_PCI */
  144. #if defined(CONFIG_FLASH_CFI_LEGACY)
  145. #include <flash.h>
  146. ulong board_flash_get_legacy (ulong base, int banknum, flash_info_t * info)
  147. {
  148. int sect[] = CONFIG_SYS_ATMEL_SECT;
  149. int sectsz[] = CONFIG_SYS_ATMEL_SECTSZ;
  150. int i, j, k;
  151. if (base != CONFIG_SYS_ATMEL_BASE)
  152. return 0;
  153. info->flash_id = 0x01000000;
  154. info->portwidth = 1;
  155. info->chipwidth = 1;
  156. info->buffer_size = 32;
  157. info->erase_blk_tout = 16384;
  158. info->write_tout = 2;
  159. info->buffer_write_tout = 5;
  160. info->vendor = 0xFFF0; /* CFI_CMDSET_AMD_LEGACY */
  161. info->cmd_reset = 0x00F0;
  162. info->interface = FLASH_CFI_X8;
  163. info->legacy_unlock = 0;
  164. info->manufacturer_id = (u16) ATM_MANUFACT;
  165. info->device_id = ATM_ID_LV040;
  166. info->device_id2 = 0;
  167. info->ext_addr = 0;
  168. info->cfi_version = 0x3133;
  169. info->cfi_offset = 0x0000;
  170. info->addr_unlock1 = 0x00000555;
  171. info->addr_unlock2 = 0x000002AA;
  172. info->name = "CFI conformant";
  173. info->size = 0;
  174. info->sector_count = CONFIG_SYS_ATMEL_TOTALSECT;
  175. info->start[0] = base;
  176. for (k = 0, i = 0; i < CONFIG_SYS_ATMEL_REGION; i++) {
  177. info->size += sect[i] * sectsz[i];
  178. for (j = 0; j < sect[i]; j++, k++) {
  179. info->start[k + 1] = info->start[k] + sectsz[i];
  180. info->protect[k] = 0;
  181. }
  182. }
  183. return 1;
  184. }
  185. #endif /* CONFIG_SYS_FLASH_CFI */