m5253demo.c 3.1 KB

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