m52277evb.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  8. */
  9. #include <common.h>
  10. #include <init.h>
  11. #include <asm/immap.h>
  12. #include <asm/io.h>
  13. #include <linux/delay.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. int checkboard(void)
  16. {
  17. puts("Board: ");
  18. puts("Freescale M52277 EVB\n");
  19. return 0;
  20. };
  21. int dram_init(void)
  22. {
  23. u32 dramsize;
  24. #ifdef CONFIG_CF_SBF
  25. /*
  26. * Serial Boot: The dram is already initialized in start.S
  27. * only require to return DRAM size
  28. */
  29. dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
  30. #else
  31. sdramc_t *sdram = (sdramc_t *)(MMAP_SDRAM);
  32. gpio_t *gpio = (gpio_t *)(MMAP_GPIO);
  33. u32 i;
  34. dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
  35. for (i = 0x13; i < 0x20; i++) {
  36. if (dramsize == (1 << i))
  37. break;
  38. }
  39. i--;
  40. out_8(&gpio->mscr_sdram, CONFIG_SYS_SDRAM_DRV_STRENGTH);
  41. out_be32(&sdram->sdcs0, CONFIG_SYS_SDRAM_BASE | i);
  42. out_be32(&sdram->sdcfg1, CONFIG_SYS_SDRAM_CFG1);
  43. out_be32(&sdram->sdcfg2, CONFIG_SYS_SDRAM_CFG2);
  44. /* Issue PALL */
  45. out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
  46. __asm__("nop");
  47. /* Issue LEMR */
  48. out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE);
  49. __asm__("nop");
  50. out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_EMOD);
  51. __asm__("nop");
  52. udelay(1000);
  53. /* Issue PALL */
  54. out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
  55. __asm__("nop");
  56. /* Perform two refresh cycles */
  57. out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
  58. __asm__("nop");
  59. out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
  60. __asm__("nop");
  61. out_be32(&sdram->sdcr,
  62. (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00);
  63. udelay(100);
  64. #endif
  65. gd->ram_size = dramsize;
  66. return 0;
  67. };
  68. int testdram(void)
  69. {
  70. /* TODO: XXX XXX XXX */
  71. printf("DRAM test not implemented!\n");
  72. return (0);
  73. }