blob: 7810010fd04297bf1f60607efd98e6a290197515 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Jon Loeliger77a4f6e2005-07-25 14:05:07 -05002/*
Zhao Chenhui2436cb12011-08-24 13:20:04 +08003 * Copyright 2004, 2007, 2009-2011 Freescale Semiconductor, Inc.
Jon Loeliger77a4f6e2005-07-25 14:05:07 -05004 *
5 * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
Jon Loeliger77a4f6e2005-07-25 14:05:07 -05006 */
7
Tom Rinidec7ea02024-05-20 13:35:03 -06008#include <config.h>
Simon Glass1ab16922022-07-31 12:28:48 -06009#include <display_options.h>
Simon Glass18afe102019-11-14 12:57:47 -070010#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -060011#include <net.h>
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050012#include <pci.h>
Simon Glassf5c208d2019-11-14 12:57:20 -070013#include <vsprintf.h>
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050014#include <asm/processor.h>
Jon Loeligerc378bae2008-03-18 13:51:06 -050015#include <asm/mmu.h>
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050016#include <asm/immap_85xx.h>
Kumar Gala9bbd6432009-04-02 13:22:48 -050017#include <asm/fsl_pci.h>
York Sunf0626592013-09-30 09:22:09 -070018#include <fsl_ddr_sdram.h>
Kumar Gala3d020382010-12-15 04:55:20 -060019#include <asm/fsl_serdes.h>
Andy Fleming239e75f2006-09-13 10:34:18 -050020#include <miiphy.h>
Simon Glassdbd79542020-05-10 11:40:11 -060021#include <linux/delay.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +090022#include <linux/libfdt.h>
Kumar Galad28ced32007-11-29 00:11:44 -060023#include <fdt_support.h>
chenhui zhaod1077b62011-09-06 16:41:18 +000024#include <tsec.h>
25#include <fsl_mdio.h>
26#include <netdev.h>
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050027
28#include "../common/cadmus.h"
29#include "../common/eeprom.h"
Matthew McClintockaa6dd062006-06-28 10:46:13 -050030#include "../common/via.h"
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050031
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050032void local_bus_init(void);
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050033
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050034int checkboard (void)
35{
Tom Rinid5c3bf22022-10-28 20:27:12 -040036 volatile ccsr_gur_t *gur = (void *)(CFG_SYS_MPC85xx_GUTS_ADDR);
37 volatile ccsr_local_ecm_t *ecm = (void *)(CFG_SYS_MPC85xx_ECM_ADDR);
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050038
39 /* PCI slot in USER bits CSR[6:7] by convention. */
40 uint pci_slot = get_pci_slot ();
41
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050042 uint cpu_board_rev = get_cpu_board_revision ();
43
chenhui zhaoe97171e2011-10-13 13:40:59 +080044 puts("Board: MPC8548CDS");
45 printf(" Carrier Rev: 0x%02x, PCI Slot %d\n",
46 get_board_version(), pci_slot);
47 printf(" Daughtercard Rev: %d.%d (0x%04x)\n",
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050048 MPC85XX_CPU_BOARD_MAJOR (cpu_board_rev),
49 MPC85XX_CPU_BOARD_MINOR (cpu_board_rev), cpu_board_rev);
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050050 /*
51 * Initialize local bus.
52 */
53 local_bus_init ();
54
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050055 /*
56 * Hack TSEC 3 and 4 IO voltages.
57 */
58 gur->tsec34ioovcr = 0xe7e0; /* 1110 0111 1110 0xxx */
59
Ed Swarthout95ae0a02007-07-27 01:50:52 -050060 ecm->eedr = 0xffffffff; /* clear ecm errors */
61 ecm->eeer = 0xffffffff; /* enable ecm errors */
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050062 return 0;
63}
64
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050065/*
66 * Initialize Local Bus
67 */
68void
69local_bus_init(void)
70{
Tom Rinid5c3bf22022-10-28 20:27:12 -040071 volatile ccsr_gur_t *gur = (void *)(CFG_SYS_MPC85xx_GUTS_ADDR);
Becky Bruce0d4cee12010-06-17 11:37:20 -050072 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050073
74 uint clkdiv;
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050075 sys_info_t sysinfo;
76
77 get_sys_info(&sysinfo);
Trent Piepho1b560ac2008-12-03 15:16:34 -080078 clkdiv = (lbc->lcrr & LCRR_CLKDIV) * 2;
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050079
80 gur->lbiuiplldcr1 = 0x00078080;
81 if (clkdiv == 16) {
82 gur->lbiuiplldcr0 = 0x7c0f1bf0;
83 } else if (clkdiv == 8) {
84 gur->lbiuiplldcr0 = 0x6c0f1bf0;
85 } else if (clkdiv == 4) {
86 gur->lbiuiplldcr0 = 0x5c0f1bf0;
87 }
88
89 lbc->lcrr |= 0x00030000;
90
91 asm("sync;isync;msync");
Ed Swarthout95ae0a02007-07-27 01:50:52 -050092
93 lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */
94 lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */
Jon Loeliger77a4f6e2005-07-25 14:05:07 -050095}
96
97/*
98 * Initialize SDRAM memory on the Local Bus.
99 */
Becky Bruceb88d3d02010-12-17 17:17:57 -0600100void lbc_sdram_init(void)
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500101{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200102#if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500103
104 uint idx;
Becky Bruce0d4cee12010-06-17 11:37:20 -0500105 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
Tom Rini6a5dccc2022-11-16 13:10:41 -0500106 uint *sdram_addr = (uint *)CFG_SYS_LBC_SDRAM_BASE;
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500107 uint lsdmr_common;
108
Becky Bruce2d8ecac2010-12-17 17:17:59 -0600109 puts("LBC SDRAM: ");
Tom Rini6a5dccc2022-11-16 13:10:41 -0500110 print_size(CFG_SYS_LBC_SDRAM_SIZE * 1024 * 1024,
chenhui zhao33b53e42011-09-06 16:41:14 +0000111 "\n");
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500112
113 /*
114 * Setup SDRAM Base and Option Registers
115 */
Becky Bruce0d4cee12010-06-17 11:37:20 -0500116 set_lbc_or(2, CONFIG_SYS_OR2_PRELIM);
117 set_lbc_br(2, CONFIG_SYS_BR2_PRELIM);
Tom Rini6a5dccc2022-11-16 13:10:41 -0500118 lbc->lbcr = CFG_SYS_LBC_LBCR;
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500119 asm("msync");
120
Tom Rini6a5dccc2022-11-16 13:10:41 -0500121 lbc->lsrt = CFG_SYS_LBC_LSRT;
122 lbc->mrtpr = CFG_SYS_LBC_MRTPR;
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500123 asm("msync");
124
125 /*
126 * MPC8548 uses "new" 15-16 style addressing.
127 */
Tom Rini6a5dccc2022-11-16 13:10:41 -0500128 lsdmr_common = CFG_SYS_LBC_LSDMR_COMMON;
Kumar Gala727c6a62009-03-26 01:34:38 -0500129 lsdmr_common |= LSDMR_BSMA1516;
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500130
131 /*
132 * Issue PRECHARGE ALL command.
133 */
Kumar Gala727c6a62009-03-26 01:34:38 -0500134 lbc->lsdmr = lsdmr_common | LSDMR_OP_PCHALL;
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500135 asm("sync;msync");
136 *sdram_addr = 0xff;
137 ppcDcbf((unsigned long) sdram_addr);
138 udelay(100);
139
140 /*
141 * Issue 8 AUTO REFRESH commands.
142 */
143 for (idx = 0; idx < 8; idx++) {
Kumar Gala727c6a62009-03-26 01:34:38 -0500144 lbc->lsdmr = lsdmr_common | LSDMR_OP_ARFRSH;
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500145 asm("sync;msync");
146 *sdram_addr = 0xff;
147 ppcDcbf((unsigned long) sdram_addr);
148 udelay(100);
149 }
150
151 /*
152 * Issue 8 MODE-set command.
153 */
Kumar Gala727c6a62009-03-26 01:34:38 -0500154 lbc->lsdmr = lsdmr_common | LSDMR_OP_MRW;
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500155 asm("sync;msync");
156 *sdram_addr = 0xff;
157 ppcDcbf((unsigned long) sdram_addr);
158 udelay(100);
159
160 /*
161 * Issue NORMAL OP command.
162 */
Kumar Gala727c6a62009-03-26 01:34:38 -0500163 lbc->lsdmr = lsdmr_common | LSDMR_OP_NORMAL;
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500164 asm("sync;msync");
165 *sdram_addr = 0xff;
166 ppcDcbf((unsigned long) sdram_addr);
167 udelay(200); /* Overkill. Must wait > 200 bus cycles */
168
169#endif /* enable SDRAM init */
170}