m54451evb.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * (C) Copyright 2000-2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * Copyright (C) 2004-2008, 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 <spi.h>
  12. #include <asm/immap.h>
  13. #include <asm/io.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. int checkboard(void)
  16. {
  17. /*
  18. * need to to:
  19. * Check serial flash size. if 2mb evb, else 8mb demo
  20. */
  21. puts("Board: ");
  22. puts("Freescale M54451 EVB\n");
  23. return 0;
  24. };
  25. phys_size_t initdram(int board_type)
  26. {
  27. u32 dramsize;
  28. #ifdef CONFIG_CF_SBF
  29. /*
  30. * Serial Boot: The dram is already initialized in start.S
  31. * only require to return DRAM size
  32. */
  33. dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
  34. #else
  35. sdramc_t *sdram = (sdramc_t *)(MMAP_SDRAM);
  36. gpio_t *gpio = (gpio_t *)(MMAP_GPIO);
  37. u32 i;
  38. dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
  39. if ((in_be32(&sdram->sdcfg1) == CONFIG_SYS_SDRAM_CFG1) &&
  40. (in_be32(&sdram->sdcfg2) == CONFIG_SYS_SDRAM_CFG2))
  41. return dramsize;
  42. for (i = 0x13; i < 0x20; i++) {
  43. if (dramsize == (1 << i))
  44. break;
  45. }
  46. i--;
  47. out_8(&gpio->mscr_sdram, CONFIG_SYS_SDRAM_DRV_STRENGTH);
  48. out_be32(&sdram->sdcs0, CONFIG_SYS_SDRAM_BASE | i);
  49. out_be32(&sdram->sdcfg1, CONFIG_SYS_SDRAM_CFG1);
  50. out_be32(&sdram->sdcfg2, CONFIG_SYS_SDRAM_CFG2);
  51. udelay(200);
  52. /* Issue PALL */
  53. out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
  54. __asm__("nop");
  55. /* Perform two refresh cycles */
  56. out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
  57. __asm__("nop");
  58. out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
  59. __asm__("nop");
  60. /* Issue LEMR */
  61. out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE);
  62. __asm__("nop");
  63. out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE);
  64. __asm__("nop");
  65. out_be32(&sdram->sdcr,
  66. (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000000);
  67. udelay(100);
  68. #endif
  69. return (dramsize);
  70. };
  71. int testdram(void)
  72. {
  73. /* TODO: XXX XXX XXX */
  74. printf("DRAM test not implemented!\n");
  75. return (0);
  76. }