mpc8548cds.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2004, 2007, 2009-2011 Freescale Semiconductor, Inc.
  4. *
  5. * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  6. */
  7. #include <common.h>
  8. #include <display_options.h>
  9. #include <init.h>
  10. #include <net.h>
  11. #include <pci.h>
  12. #include <vsprintf.h>
  13. #include <asm/processor.h>
  14. #include <asm/mmu.h>
  15. #include <asm/immap_85xx.h>
  16. #include <asm/fsl_pci.h>
  17. #include <fsl_ddr_sdram.h>
  18. #include <asm/fsl_serdes.h>
  19. #include <miiphy.h>
  20. #include <linux/delay.h>
  21. #include <linux/libfdt.h>
  22. #include <fdt_support.h>
  23. #include <tsec.h>
  24. #include <fsl_mdio.h>
  25. #include <netdev.h>
  26. #include "../common/cadmus.h"
  27. #include "../common/eeprom.h"
  28. #include "../common/via.h"
  29. void local_bus_init(void);
  30. int checkboard (void)
  31. {
  32. volatile ccsr_gur_t *gur = (void *)(CFG_SYS_MPC85xx_GUTS_ADDR);
  33. volatile ccsr_local_ecm_t *ecm = (void *)(CFG_SYS_MPC85xx_ECM_ADDR);
  34. /* PCI slot in USER bits CSR[6:7] by convention. */
  35. uint pci_slot = get_pci_slot ();
  36. uint cpu_board_rev = get_cpu_board_revision ();
  37. puts("Board: MPC8548CDS");
  38. printf(" Carrier Rev: 0x%02x, PCI Slot %d\n",
  39. get_board_version(), pci_slot);
  40. printf(" Daughtercard Rev: %d.%d (0x%04x)\n",
  41. MPC85XX_CPU_BOARD_MAJOR (cpu_board_rev),
  42. MPC85XX_CPU_BOARD_MINOR (cpu_board_rev), cpu_board_rev);
  43. /*
  44. * Initialize local bus.
  45. */
  46. local_bus_init ();
  47. /*
  48. * Hack TSEC 3 and 4 IO voltages.
  49. */
  50. gur->tsec34ioovcr = 0xe7e0; /* 1110 0111 1110 0xxx */
  51. ecm->eedr = 0xffffffff; /* clear ecm errors */
  52. ecm->eeer = 0xffffffff; /* enable ecm errors */
  53. return 0;
  54. }
  55. /*
  56. * Initialize Local Bus
  57. */
  58. void
  59. local_bus_init(void)
  60. {
  61. volatile ccsr_gur_t *gur = (void *)(CFG_SYS_MPC85xx_GUTS_ADDR);
  62. volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
  63. uint clkdiv;
  64. sys_info_t sysinfo;
  65. get_sys_info(&sysinfo);
  66. clkdiv = (lbc->lcrr & LCRR_CLKDIV) * 2;
  67. gur->lbiuiplldcr1 = 0x00078080;
  68. if (clkdiv == 16) {
  69. gur->lbiuiplldcr0 = 0x7c0f1bf0;
  70. } else if (clkdiv == 8) {
  71. gur->lbiuiplldcr0 = 0x6c0f1bf0;
  72. } else if (clkdiv == 4) {
  73. gur->lbiuiplldcr0 = 0x5c0f1bf0;
  74. }
  75. lbc->lcrr |= 0x00030000;
  76. asm("sync;isync;msync");
  77. lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */
  78. lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */
  79. }
  80. /*
  81. * Initialize SDRAM memory on the Local Bus.
  82. */
  83. void lbc_sdram_init(void)
  84. {
  85. #if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
  86. uint idx;
  87. volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
  88. uint *sdram_addr = (uint *)CFG_SYS_LBC_SDRAM_BASE;
  89. uint lsdmr_common;
  90. puts("LBC SDRAM: ");
  91. print_size(CFG_SYS_LBC_SDRAM_SIZE * 1024 * 1024,
  92. "\n");
  93. /*
  94. * Setup SDRAM Base and Option Registers
  95. */
  96. set_lbc_or(2, CONFIG_SYS_OR2_PRELIM);
  97. set_lbc_br(2, CONFIG_SYS_BR2_PRELIM);
  98. lbc->lbcr = CFG_SYS_LBC_LBCR;
  99. asm("msync");
  100. lbc->lsrt = CFG_SYS_LBC_LSRT;
  101. lbc->mrtpr = CFG_SYS_LBC_MRTPR;
  102. asm("msync");
  103. /*
  104. * MPC8548 uses "new" 15-16 style addressing.
  105. */
  106. lsdmr_common = CFG_SYS_LBC_LSDMR_COMMON;
  107. lsdmr_common |= LSDMR_BSMA1516;
  108. /*
  109. * Issue PRECHARGE ALL command.
  110. */
  111. lbc->lsdmr = lsdmr_common | LSDMR_OP_PCHALL;
  112. asm("sync;msync");
  113. *sdram_addr = 0xff;
  114. ppcDcbf((unsigned long) sdram_addr);
  115. udelay(100);
  116. /*
  117. * Issue 8 AUTO REFRESH commands.
  118. */
  119. for (idx = 0; idx < 8; idx++) {
  120. lbc->lsdmr = lsdmr_common | LSDMR_OP_ARFRSH;
  121. asm("sync;msync");
  122. *sdram_addr = 0xff;
  123. ppcDcbf((unsigned long) sdram_addr);
  124. udelay(100);
  125. }
  126. /*
  127. * Issue 8 MODE-set command.
  128. */
  129. lbc->lsdmr = lsdmr_common | LSDMR_OP_MRW;
  130. asm("sync;msync");
  131. *sdram_addr = 0xff;
  132. ppcDcbf((unsigned long) sdram_addr);
  133. udelay(100);
  134. /*
  135. * Issue NORMAL OP command.
  136. */
  137. lbc->lsdmr = lsdmr_common | LSDMR_OP_NORMAL;
  138. asm("sync;msync");
  139. *sdram_addr = 0xff;
  140. ppcDcbf((unsigned long) sdram_addr);
  141. udelay(200); /* Overkill. Must wait > 200 bus cycles */
  142. #endif /* enable SDRAM init */
  143. }