m54455evb.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * (C) Copyright 2000-2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
  6. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #include <common.h>
  11. #include <pci.h>
  12. #include <asm/immap.h>
  13. #include <asm/io.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. int checkboard(void)
  16. {
  17. puts("Board: ");
  18. puts("Freescale M54455 EVB\n");
  19. return 0;
  20. };
  21. phys_size_t initdram(int board_type)
  22. {
  23. u32 dramsize;
  24. #ifdef CONFIG_CF_SBF
  25. /*
  26. * Serial Boot: The dram is already initialized in start.S
  27. * only require to return DRAM size
  28. */
  29. dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000 >> 1;
  30. #else
  31. sdramc_t *sdram = (sdramc_t *)(MMAP_SDRAM);
  32. gpio_t *gpio = (gpio_t *)(MMAP_GPIO);
  33. u32 i;
  34. dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000 >> 1;
  35. for (i = 0x13; i < 0x20; i++) {
  36. if (dramsize == (1 << i))
  37. break;
  38. }
  39. i--;
  40. out_8(&gpio->mscr_sdram, CONFIG_SYS_SDRAM_DRV_STRENGTH);
  41. out_be32(&sdram->sdcs0, CONFIG_SYS_SDRAM_BASE | i);
  42. out_be32(&sdram->sdcs1, CONFIG_SYS_SDRAM_BASE1 | i);
  43. out_be32(&sdram->sdcfg1, CONFIG_SYS_SDRAM_CFG1);
  44. out_be32(&sdram->sdcfg2, CONFIG_SYS_SDRAM_CFG2);
  45. /* Issue PALL */
  46. out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
  47. /* Issue LEMR */
  48. out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_EMOD | 0x408);
  49. out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE | 0x300);
  50. udelay(500);
  51. /* Issue PALL */
  52. out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
  53. /* Perform two refresh cycles */
  54. out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
  55. out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
  56. out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE | 0x200);
  57. out_be32(&sdram->sdcr,
  58. (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00);
  59. udelay(100);
  60. #endif
  61. return (dramsize << 1);
  62. };
  63. int testdram(void)
  64. {
  65. /* TODO: XXX XXX XXX */
  66. printf("DRAM test not implemented!\n");
  67. return (0);
  68. }
  69. #if defined(CONFIG_CMD_IDE)
  70. #include <ata.h>
  71. int ide_preinit(void)
  72. {
  73. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  74. u32 tmp;
  75. tmp = (in_8(&gpio->par_fec) & GPIO_PAR_FEC_FEC1_UNMASK) | 0x10;
  76. setbits_8(&gpio->par_fec, tmp);
  77. tmp = ((in_be16(&gpio->par_feci2c) & 0xf0ff) |
  78. (GPIO_PAR_FECI2C_MDC1_ATA_DIOR | GPIO_PAR_FECI2C_MDIO1_ATA_DIOW));
  79. setbits_be16(&gpio->par_feci2c, tmp);
  80. setbits_be16(&gpio->par_ata,
  81. GPIO_PAR_ATA_BUFEN | GPIO_PAR_ATA_CS1 | GPIO_PAR_ATA_CS0 |
  82. GPIO_PAR_ATA_DA2 | GPIO_PAR_ATA_DA1 | GPIO_PAR_ATA_DA0 |
  83. GPIO_PAR_ATA_RESET_RESET | GPIO_PAR_ATA_DMARQ_DMARQ |
  84. GPIO_PAR_ATA_IORDY_IORDY);
  85. setbits_be16(&gpio->par_pci,
  86. GPIO_PAR_PCI_GNT3_ATA_DMACK | GPIO_PAR_PCI_REQ3_ATA_INTRQ);
  87. return (0);
  88. }
  89. void ide_set_reset(int idereset)
  90. {
  91. atac_t *ata = (atac_t *) MMAP_ATA;
  92. long period;
  93. /* t1, t2, t3, t4, t5, t6, t9, tRD, tA */
  94. int piotms[5][9] = {
  95. {70, 165, 60, 30, 50, 5, 20, 0, 35}, /* PIO 0 */
  96. {50, 125, 45, 20, 35, 5, 15, 0, 35}, /* PIO 1 */
  97. {30, 100, 30, 15, 20, 5, 10, 0, 35}, /* PIO 2 */
  98. {30, 80, 30, 10, 20, 5, 10, 0, 35}, /* PIO 3 */
  99. {25, 70, 20, 10, 20, 5, 10, 0, 35}
  100. }; /* PIO 4 */
  101. if (idereset) {
  102. /* control reset */
  103. out_8(&ata->cr, 0);
  104. udelay(10000);
  105. } else {
  106. #define CALC_TIMING(t) (t + period - 1) / period
  107. period = 1000000000 / gd->bus_clk; /* period in ns */
  108. /*ata->ton = CALC_TIMING (180); */
  109. out_8(&ata->t1, CALC_TIMING(piotms[2][0]));
  110. out_8(&ata->t2w, CALC_TIMING(piotms[2][1]));
  111. out_8(&ata->t2r, CALC_TIMING(piotms[2][1]));
  112. out_8(&ata->ta, CALC_TIMING(piotms[2][8]));
  113. out_8(&ata->trd, CALC_TIMING(piotms[2][7]));
  114. out_8(&ata->t4, CALC_TIMING(piotms[2][3]));
  115. out_8(&ata->t9, CALC_TIMING(piotms[2][6]));
  116. /* IORDY enable */
  117. out_8(&ata->cr, 0x40);
  118. udelay(200000);
  119. /* IORDY enable */
  120. setbits_8(&ata->cr, 0x01);
  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 */
  135. #if defined(CONFIG_FLASH_CFI_LEGACY)
  136. #include <flash.h>
  137. ulong board_flash_get_legacy (ulong base, int banknum, flash_info_t * info)
  138. {
  139. int sect[] = CONFIG_SYS_ATMEL_SECT;
  140. int sectsz[] = CONFIG_SYS_ATMEL_SECTSZ;
  141. int i, j, k;
  142. if (base != CONFIG_SYS_ATMEL_BASE)
  143. return 0;
  144. info->flash_id = 0x01000000;
  145. info->portwidth = 1;
  146. info->chipwidth = 1;
  147. info->buffer_size = 1;
  148. info->erase_blk_tout = 16384;
  149. info->write_tout = 2;
  150. info->buffer_write_tout = 5;
  151. info->vendor = 0xFFF0; /* CFI_CMDSET_AMD_LEGACY */
  152. info->cmd_reset = 0x00F0;
  153. info->interface = FLASH_CFI_X8;
  154. info->legacy_unlock = 0;
  155. info->manufacturer_id = (u16) ATM_MANUFACT;
  156. info->device_id = ATM_ID_LV040;
  157. info->device_id2 = 0;
  158. info->ext_addr = 0;
  159. info->cfi_version = 0x3133;
  160. info->cfi_offset = 0x0000;
  161. info->addr_unlock1 = 0x00000555;
  162. info->addr_unlock2 = 0x000002AA;
  163. info->name = "CFI conformant";
  164. info->size = 0;
  165. info->sector_count = CONFIG_SYS_ATMEL_TOTALSECT;
  166. info->start[0] = base;
  167. for (k = 0, i = 0; i < CONFIG_SYS_ATMEL_REGION; i++) {
  168. info->size += sect[i] * sectsz[i];
  169. for (j = 0; j < sect[i]; j++, k++) {
  170. info->start[k + 1] = info->start[k] + sectsz[i];
  171. info->protect[k] = 0;
  172. }
  173. }
  174. return 1;
  175. }
  176. #endif /* CONFIG_SYS_FLASH_CFI */