m5253demo.c 3.1 KB

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