amcore.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Board functions for Sysam AMCORE (MCF5307 based) board
  4. *
  5. * (C) Copyright 2016 Angelo Dureghello <angelo@sysam.it>
  6. *
  7. * This file copies memory testdram() from sandburst/common/sb_common.c
  8. */
  9. #include <common.h>
  10. #include <init.h>
  11. #include <asm/global_data.h>
  12. #include <asm/immap.h>
  13. #include <asm/io.h>
  14. #include <dm.h>
  15. #include <dm/platform_data/serial_coldfire.h>
  16. DECLARE_GLOBAL_DATA_PTR;
  17. void init_lcd(void)
  18. {
  19. /* setup for possible K0108 lcd connected on the parallel port */
  20. sim_t *sim = (sim_t *)(MMAP_SIM);
  21. out_be16(&sim->par, 0x300);
  22. gpio_t *gpio = (gpio_t *)(MMAP_GPIO);
  23. out_be16(&gpio->paddr, 0xfcff);
  24. out_be16(&gpio->padat, 0x0c00);
  25. }
  26. int checkboard(void)
  27. {
  28. puts("Board: ");
  29. puts("AMCORE v.001(alpha)\n");
  30. init_lcd();
  31. return 0;
  32. }
  33. /*
  34. * in dram_init we are here executing from flash
  35. * case 1:
  36. * is with no ACR/flash cache enabled
  37. * nop = 40ns (scope measured)
  38. */
  39. void fudelay(int usec)
  40. {
  41. while (usec--)
  42. asm volatile ("nop");
  43. }
  44. int dram_init(void)
  45. {
  46. u32 dramsize, RC;
  47. sdramctrl_t *dc = (sdramctrl_t *)(MMAP_DRAMC);
  48. /*
  49. * SDRAM MT48LC4M32B2 details
  50. * Memory block 0: 16 MB of SDRAM at address $00000000
  51. * Port size: 32-bit port
  52. *
  53. * Memory block 0 wired as follows:
  54. * CPU : A15 A14 A13 A12 A11 A10 A9 A17 A18 A19 A20 A21 A22 A23
  55. * SDRAM : A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 BA0 BA1
  56. *
  57. * Ensure that there is a delay of at least 100 microseconds from
  58. * processor reset to the following code so that the SDRAM is ready
  59. * for commands.
  60. */
  61. fudelay(100);
  62. /*
  63. * DCR
  64. * set proper RC as per specification
  65. */
  66. RC = (CFG_SYS_CPU_CLK / 1000000) >> 1;
  67. RC = (RC * 15) >> 4;
  68. /* 0x8000 is the faster option */
  69. out_be16(&dc->dcr, 0x8200 | RC);
  70. /*
  71. * DACR0, page mode continuous, CMD on A20 0x0300
  72. */
  73. out_be32(&dc->dacr0, 0x00003304);
  74. dramsize = ((CFG_SYS_SDRAM_SIZE)-1) & 0xfffc0000;
  75. out_be32(&dc->dmr0, dramsize|1);
  76. /* issue a PRECHARGE ALL */
  77. out_be32(&dc->dacr0, 0x0000330c);
  78. out_be32((u32 *)0x00000004, 0xbeaddeed);
  79. /* issue AUTOREFRESH */
  80. out_be32(&dc->dacr0, 0x0000b304);
  81. /* let refresh occur */
  82. fudelay(1);
  83. out_be32(&dc->dacr0, 0x0000b344);
  84. out_be32((u32 *)0x00000c00, 0xbeaddeed);
  85. gd->ram_size = get_ram_size(CFG_SYS_SDRAM_BASE,
  86. CFG_SYS_SDRAM_SIZE);
  87. return 0;
  88. }
  89. static struct coldfire_serial_plat mcf5307_serial_plat = {
  90. .base = CFG_SYS_UART_BASE,
  91. .port = 0,
  92. .baudrate = CONFIG_BAUDRATE,
  93. };
  94. U_BOOT_DRVINFO(coldfire_serial) = {
  95. .name = "serial_coldfire",
  96. .plat = &mcf5307_serial_plat,
  97. };