m5253demo.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2000-2003
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. *
  6. * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
  7. * Hayden Fraser (Hayden.Fraser@freescale.com)
  8. */
  9. #include <common.h>
  10. #include <asm/immap.h>
  11. #include <netdev.h>
  12. #include <asm/io.h>
  13. DECLARE_GLOBAL_DATA_PTR;
  14. int checkboard(void)
  15. {
  16. puts("Board: ");
  17. puts("Freescale MCF5253 DEMO\n");
  18. return 0;
  19. };
  20. int dram_init(void)
  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. gd->ram_size = dramsize;
  62. return 0;
  63. }
  64. int testdram(void)
  65. {
  66. /* TODO: XXX XXX XXX */
  67. printf("DRAM test not implemented!\n");
  68. return (0);
  69. }
  70. #ifdef CONFIG_IDE
  71. #include <ata.h>
  72. int ide_preinit(void)
  73. {
  74. return (0);
  75. }
  76. void ide_set_reset(int idereset)
  77. {
  78. atac_t *ata = (atac_t *) CONFIG_SYS_ATA_BASE_ADDR;
  79. long period;
  80. /* t1, t2, t3, t4, t5, t6, t9, tRD, tA */
  81. int piotms[5][9] = { {70, 165, 60, 30, 50, 5, 20, 0, 35}, /* PIO 0 */
  82. {50, 125, 45, 20, 35, 5, 15, 0, 35}, /* PIO 1 */
  83. {30, 100, 30, 15, 20, 5, 10, 0, 35}, /* PIO 2 */
  84. {30, 80, 30, 10, 20, 5, 10, 0, 35}, /* PIO 3 */
  85. {25, 70, 20, 10, 20, 5, 10, 0, 35} /* PIO 4 */
  86. };
  87. if (idereset) {
  88. /* control reset */
  89. out_8(&ata->cr, 0);
  90. udelay(100);
  91. } else {
  92. mbar2_writeLong(CIM_MISCCR, CIM_MISCCR_CPUEND);
  93. #define CALC_TIMING(t) (t + period - 1) / period
  94. period = 1000000000 / (CONFIG_SYS_CLK / 2); /* period in ns */
  95. /*ata->ton = CALC_TIMING (180); */
  96. out_8(&ata->t1, CALC_TIMING(piotms[2][0]));
  97. out_8(&ata->t2w, CALC_TIMING(piotms[2][1]));
  98. out_8(&ata->t2r, CALC_TIMING(piotms[2][1]));
  99. out_8(&ata->ta, CALC_TIMING(piotms[2][8]));
  100. out_8(&ata->trd, CALC_TIMING(piotms[2][7]));
  101. out_8(&ata->t4, CALC_TIMING(piotms[2][3]));
  102. out_8(&ata->t9, CALC_TIMING(piotms[2][6]));
  103. /* IORDY enable */
  104. out_8(&ata->cr, 0x40);
  105. udelay(2000);
  106. /* IORDY enable */
  107. setbits_8(&ata->cr, 0x01);
  108. }
  109. }
  110. #endif /* CONFIG_IDE */
  111. #ifdef CONFIG_DRIVER_DM9000
  112. int board_eth_init(bd_t *bis)
  113. {
  114. return dm9000_initialize(bis);
  115. }
  116. #endif