m5253evbe.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. * Hayden Fraser (Hayden.Fraser@freescale.com)
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #include <common.h>
  11. #include <asm/immap.h>
  12. #include <asm/io.h>
  13. int checkboard(void)
  14. {
  15. puts("Board: ");
  16. puts("Freescale MCF5253 EVBE\n");
  17. return 0;
  18. };
  19. phys_size_t initdram(int board_type)
  20. {
  21. /*
  22. * Check to see if the SDRAM has already been initialized
  23. * by a run control tool
  24. */
  25. if (!(mbar_readLong(MCFSIM_DCR) & 0x8000)) {
  26. u32 RC, dramsize;
  27. RC = (CONFIG_SYS_CLK / 1000000) >> 1;
  28. RC = (RC * 15) >> 4;
  29. /* Initialize DRAM Control Register: DCR */
  30. mbar_writeShort(MCFSIM_DCR, (0x8400 | RC));
  31. asm("nop");
  32. mbar_writeLong(MCFSIM_DACR0, 0x00002320);
  33. asm("nop");
  34. /* Initialize DMR0 */
  35. dramsize = ((CONFIG_SYS_SDRAM_SIZE << 20) - 1) & 0xFFFC0000;
  36. mbar_writeLong(MCFSIM_DMR0, dramsize | 1);
  37. asm("nop");
  38. mbar_writeLong(MCFSIM_DACR0, 0x00002328);
  39. asm("nop");
  40. /* Write to this block to initiate precharge */
  41. *(u32 *) (CONFIG_SYS_SDRAM_BASE) = 0xa5a5a5a5;
  42. asm("nop");
  43. /* Set RE bit in DACR */
  44. mbar_writeLong(MCFSIM_DACR0,
  45. mbar_readLong(MCFSIM_DACR0) | 0x8000);
  46. asm("nop");
  47. /* Wait for at least 8 auto refresh cycles to occur */
  48. udelay(500);
  49. /* Finish the configuration by issuing the MRS */
  50. mbar_writeLong(MCFSIM_DACR0,
  51. mbar_readLong(MCFSIM_DACR0) | 0x0040);
  52. asm("nop");
  53. *(u32 *) (CONFIG_SYS_SDRAM_BASE + 0x800) = 0xa5a5a5a5;
  54. }
  55. return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  56. }
  57. int testdram(void)
  58. {
  59. /* TODO: XXX XXX XXX */
  60. printf("DRAM test not implemented!\n");
  61. return (0);
  62. }
  63. #ifdef CONFIG_CMD_IDE
  64. #include <ata.h>
  65. int ide_preinit(void)
  66. {
  67. return (0);
  68. }
  69. void ide_set_reset(int idereset)
  70. {
  71. atac_t *ata = (atac_t *) CONFIG_SYS_ATA_BASE_ADDR;
  72. long period;
  73. /* t1, t2, t3, t4, t5, t6, t9, tRD, tA */
  74. int piotms[5][9] = { {70, 165, 60, 30, 50, 5, 20, 0, 35}, /* PIO 0 */
  75. {50, 125, 45, 20, 35, 5, 15, 0, 35}, /* PIO 1 */
  76. {30, 100, 30, 15, 20, 5, 10, 0, 35}, /* PIO 2 */
  77. {30, 80, 30, 10, 20, 5, 10, 0, 35}, /* PIO 3 */
  78. {25, 70, 20, 10, 20, 5, 10, 0, 35} /* PIO 4 */
  79. };
  80. if (idereset) {
  81. /* control reset */
  82. out_8(&ata->cr, 0);
  83. udelay(100);
  84. } else {
  85. mbar2_writeLong(CIM_MISCCR, CIM_MISCCR_CPUEND);
  86. #define CALC_TIMING(t) (t + period - 1) / period
  87. period = 1000000000 / (CONFIG_SYS_CLK / 2); /* period in ns */
  88. /*ata->ton = CALC_TIMING (180); */
  89. out_8(&ata->t1, CALC_TIMING(piotms[2][0]));
  90. out_8(&ata->t2w, CALC_TIMING(piotms[2][1]));
  91. out_8(&ata->t2r, CALC_TIMING(piotms[2][1]));
  92. out_8(&ata->ta, CALC_TIMING(piotms[2][8]));
  93. out_8(&ata->trd, CALC_TIMING(piotms[2][7]));
  94. out_8(&ata->t4, CALC_TIMING(piotms[2][3]));
  95. out_8(&ata->t9, CALC_TIMING(piotms[2][6]));
  96. /* IORDY enable */
  97. out_8(&ata->cr, 0x40);
  98. udelay(2000);
  99. /* IORDY enable */
  100. setbits_8(&ata->cr, 0x01);
  101. }
  102. }
  103. #endif /* CONFIG_CMD_IDE */