2005-07-25 19:05:07 +00:00
|
|
|
/*
|
2011-08-24 05:20:04 +00:00
|
|
|
* Copyright 2004, 2007, 2009-2011 Freescale Semiconductor, Inc.
|
2005-07-25 19:05:07 +00:00
|
|
|
*
|
|
|
|
* (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <pci.h>
|
|
|
|
#include <asm/processor.h>
|
2008-03-18 18:51:06 +00:00
|
|
|
#include <asm/mmu.h>
|
2005-07-25 19:05:07 +00:00
|
|
|
#include <asm/immap_85xx.h>
|
2009-04-02 18:22:48 +00:00
|
|
|
#include <asm/fsl_pci.h>
|
2008-03-18 18:51:06 +00:00
|
|
|
#include <asm/fsl_ddr_sdram.h>
|
2010-12-15 10:55:20 +00:00
|
|
|
#include <asm/fsl_serdes.h>
|
2006-09-13 15:34:18 +00:00
|
|
|
#include <miiphy.h>
|
2007-11-29 06:11:44 +00:00
|
|
|
#include <libfdt.h>
|
|
|
|
#include <fdt_support.h>
|
2005-07-25 19:05:07 +00:00
|
|
|
|
|
|
|
#include "../common/cadmus.h"
|
|
|
|
#include "../common/eeprom.h"
|
2006-06-28 15:46:13 +00:00
|
|
|
#include "../common/via.h"
|
2005-07-25 19:05:07 +00:00
|
|
|
|
|
|
|
void local_bus_init(void);
|
|
|
|
|
|
|
|
int checkboard (void)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
|
|
|
|
volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
|
2005-07-25 19:05:07 +00:00
|
|
|
|
|
|
|
/* PCI slot in USER bits CSR[6:7] by convention. */
|
|
|
|
uint pci_slot = get_pci_slot ();
|
|
|
|
|
|
|
|
uint cpu_board_rev = get_cpu_board_revision ();
|
|
|
|
|
2011-10-13 05:40:59 +00:00
|
|
|
puts("Board: MPC8548CDS");
|
|
|
|
printf(" Carrier Rev: 0x%02x, PCI Slot %d\n",
|
|
|
|
get_board_version(), pci_slot);
|
|
|
|
printf(" Daughtercard Rev: %d.%d (0x%04x)\n",
|
2005-07-25 19:05:07 +00:00
|
|
|
MPC85XX_CPU_BOARD_MAJOR (cpu_board_rev),
|
|
|
|
MPC85XX_CPU_BOARD_MINOR (cpu_board_rev), cpu_board_rev);
|
|
|
|
/*
|
|
|
|
* Initialize local bus.
|
|
|
|
*/
|
|
|
|
local_bus_init ();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hack TSEC 3 and 4 IO voltages.
|
|
|
|
*/
|
|
|
|
gur->tsec34ioovcr = 0xe7e0; /* 1110 0111 1110 0xxx */
|
|
|
|
|
2007-07-27 06:50:52 +00:00
|
|
|
ecm->eedr = 0xffffffff; /* clear ecm errors */
|
|
|
|
ecm->eeer = 0xffffffff; /* enable ecm errors */
|
2005-07-25 19:05:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize Local Bus
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
local_bus_init(void)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
|
2010-06-17 16:37:20 +00:00
|
|
|
volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
|
2005-07-25 19:05:07 +00:00
|
|
|
|
|
|
|
uint clkdiv;
|
|
|
|
uint lbc_hz;
|
|
|
|
sys_info_t sysinfo;
|
|
|
|
|
|
|
|
get_sys_info(&sysinfo);
|
2008-12-03 23:16:34 +00:00
|
|
|
clkdiv = (lbc->lcrr & LCRR_CLKDIV) * 2;
|
2005-07-25 19:05:07 +00:00
|
|
|
lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
|
|
|
|
|
|
|
|
gur->lbiuiplldcr1 = 0x00078080;
|
|
|
|
if (clkdiv == 16) {
|
|
|
|
gur->lbiuiplldcr0 = 0x7c0f1bf0;
|
|
|
|
} else if (clkdiv == 8) {
|
|
|
|
gur->lbiuiplldcr0 = 0x6c0f1bf0;
|
|
|
|
} else if (clkdiv == 4) {
|
|
|
|
gur->lbiuiplldcr0 = 0x5c0f1bf0;
|
|
|
|
}
|
|
|
|
|
|
|
|
lbc->lcrr |= 0x00030000;
|
|
|
|
|
|
|
|
asm("sync;isync;msync");
|
2007-07-27 06:50:52 +00:00
|
|
|
|
|
|
|
lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */
|
|
|
|
lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */
|
2005-07-25 19:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize SDRAM memory on the Local Bus.
|
|
|
|
*/
|
2010-12-17 23:17:57 +00:00
|
|
|
void lbc_sdram_init(void)
|
2005-07-25 19:05:07 +00:00
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
|
2005-07-25 19:05:07 +00:00
|
|
|
|
|
|
|
uint idx;
|
2010-06-17 16:37:20 +00:00
|
|
|
volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
|
2008-10-16 13:01:15 +00:00
|
|
|
uint *sdram_addr = (uint *)CONFIG_SYS_LBC_SDRAM_BASE;
|
2005-07-25 19:05:07 +00:00
|
|
|
uint cpu_board_rev;
|
|
|
|
uint lsdmr_common;
|
|
|
|
|
2010-12-17 23:17:59 +00:00
|
|
|
puts("LBC SDRAM: ");
|
|
|
|
print_size(CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024,
|
2011-09-06 16:41:14 +00:00
|
|
|
"\n");
|
2005-07-25 19:05:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup SDRAM Base and Option Registers
|
|
|
|
*/
|
2010-06-17 16:37:20 +00:00
|
|
|
set_lbc_or(2, CONFIG_SYS_OR2_PRELIM);
|
|
|
|
set_lbc_br(2, CONFIG_SYS_BR2_PRELIM);
|
2008-10-16 13:01:15 +00:00
|
|
|
lbc->lbcr = CONFIG_SYS_LBC_LBCR;
|
2005-07-25 19:05:07 +00:00
|
|
|
asm("msync");
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
lbc->lsrt = CONFIG_SYS_LBC_LSRT;
|
|
|
|
lbc->mrtpr = CONFIG_SYS_LBC_MRTPR;
|
2005-07-25 19:05:07 +00:00
|
|
|
asm("msync");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MPC8548 uses "new" 15-16 style addressing.
|
|
|
|
*/
|
|
|
|
cpu_board_rev = get_cpu_board_revision();
|
2008-10-16 13:01:15 +00:00
|
|
|
lsdmr_common = CONFIG_SYS_LBC_LSDMR_COMMON;
|
2009-03-26 06:34:38 +00:00
|
|
|
lsdmr_common |= LSDMR_BSMA1516;
|
2005-07-25 19:05:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Issue PRECHARGE ALL command.
|
|
|
|
*/
|
2009-03-26 06:34:38 +00:00
|
|
|
lbc->lsdmr = lsdmr_common | LSDMR_OP_PCHALL;
|
2005-07-25 19:05:07 +00:00
|
|
|
asm("sync;msync");
|
|
|
|
*sdram_addr = 0xff;
|
|
|
|
ppcDcbf((unsigned long) sdram_addr);
|
|
|
|
udelay(100);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Issue 8 AUTO REFRESH commands.
|
|
|
|
*/
|
|
|
|
for (idx = 0; idx < 8; idx++) {
|
2009-03-26 06:34:38 +00:00
|
|
|
lbc->lsdmr = lsdmr_common | LSDMR_OP_ARFRSH;
|
2005-07-25 19:05:07 +00:00
|
|
|
asm("sync;msync");
|
|
|
|
*sdram_addr = 0xff;
|
|
|
|
ppcDcbf((unsigned long) sdram_addr);
|
|
|
|
udelay(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Issue 8 MODE-set command.
|
|
|
|
*/
|
2009-03-26 06:34:38 +00:00
|
|
|
lbc->lsdmr = lsdmr_common | LSDMR_OP_MRW;
|
2005-07-25 19:05:07 +00:00
|
|
|
asm("sync;msync");
|
|
|
|
*sdram_addr = 0xff;
|
|
|
|
ppcDcbf((unsigned long) sdram_addr);
|
|
|
|
udelay(100);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Issue NORMAL OP command.
|
|
|
|
*/
|
2009-03-26 06:34:38 +00:00
|
|
|
lbc->lsdmr = lsdmr_common | LSDMR_OP_NORMAL;
|
2005-07-25 19:05:07 +00:00
|
|
|
asm("sync;msync");
|
|
|
|
*sdram_addr = 0xff;
|
|
|
|
ppcDcbf((unsigned long) sdram_addr);
|
|
|
|
udelay(200); /* Overkill. Must wait > 200 bus cycles */
|
|
|
|
|
|
|
|
#endif /* enable SDRAM init */
|
|
|
|
}
|
|
|
|
|
2007-07-27 06:50:52 +00:00
|
|
|
#if defined(CONFIG_PCI) || defined(CONFIG_PCI1)
|
2006-06-28 15:46:13 +00:00
|
|
|
/* For some reason the Tundra PCI bridge shows up on itself as a
|
|
|
|
* different device. Work around that by refusing to configure it.
|
2005-07-25 19:05:07 +00:00
|
|
|
*/
|
2006-06-28 15:46:13 +00:00
|
|
|
void dummy_func(struct pci_controller* hose, pci_dev_t dev, struct pci_config_table *tab) { }
|
2005-07-25 19:05:07 +00:00
|
|
|
|
|
|
|
static struct pci_config_table pci_mpc85xxcds_config_table[] = {
|
2006-06-28 15:46:13 +00:00
|
|
|
{0x10e3, 0x0513, PCI_ANY_ID, 1, 3, PCI_ANY_ID, dummy_func, {0,0,0}},
|
2007-02-28 02:42:22 +00:00
|
|
|
{0x1106, 0x0686, PCI_ANY_ID, 1, VIA_ID, 0, mpc85xx_config_via, {0,0,0}},
|
|
|
|
{0x1106, 0x0571, PCI_ANY_ID, 1, VIA_ID, 1,
|
2007-02-24 07:08:13 +00:00
|
|
|
mpc85xx_config_via_usbide, {0,0,0}},
|
2007-02-28 02:42:22 +00:00
|
|
|
{0x1105, 0x3038, PCI_ANY_ID, 1, VIA_ID, 2,
|
|
|
|
mpc85xx_config_via_usb, {0,0,0}},
|
|
|
|
{0x1106, 0x3038, PCI_ANY_ID, 1, VIA_ID, 3,
|
|
|
|
mpc85xx_config_via_usb2, {0,0,0}},
|
|
|
|
{0x1106, 0x3058, PCI_ANY_ID, 1, VIA_ID, 5,
|
2007-02-24 07:08:13 +00:00
|
|
|
mpc85xx_config_via_power, {0,0,0}},
|
2007-02-28 02:42:22 +00:00
|
|
|
{0x1106, 0x3068, PCI_ANY_ID, 1, VIA_ID, 6,
|
|
|
|
mpc85xx_config_via_ac97, {0,0,0}},
|
2007-02-24 07:08:13 +00:00
|
|
|
{},
|
2005-07-25 19:05:07 +00:00
|
|
|
};
|
|
|
|
|
2011-08-24 05:20:04 +00:00
|
|
|
static struct pci_controller pci1_hose;
|
2005-07-25 19:05:07 +00:00
|
|
|
#endif /* CONFIG_PCI */
|
|
|
|
|
2009-11-04 17:15:29 +00:00
|
|
|
void pci_init_board(void)
|
2005-07-25 19:05:07 +00:00
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
|
2010-12-17 16:21:22 +00:00
|
|
|
struct fsl_pci_info pci_info;
|
2009-11-04 17:15:29 +00:00
|
|
|
u32 devdisr, pordevsr, io_sel;
|
|
|
|
u32 porpllsr, pci_agent, pci_speed, pci_32, pci_arb, pci_clk_sel;
|
|
|
|
int first_free_busno = 0;
|
2011-09-15 06:52:34 +00:00
|
|
|
char buf[32];
|
2007-07-27 06:50:52 +00:00
|
|
|
|
2009-11-04 17:15:29 +00:00
|
|
|
devdisr = in_be32(&gur->devdisr);
|
|
|
|
pordevsr = in_be32(&gur->pordevsr);
|
|
|
|
porpllsr = in_be32(&gur->porpllsr);
|
|
|
|
io_sel = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
|
2007-07-27 06:50:52 +00:00
|
|
|
|
2009-11-04 17:15:29 +00:00
|
|
|
debug (" pci_init_board: devdisr=%x, io_sel=%x\n", devdisr, io_sel);
|
2007-07-27 06:50:52 +00:00
|
|
|
|
2009-11-04 17:15:29 +00:00
|
|
|
#ifdef CONFIG_PCI1
|
|
|
|
pci_speed = get_clock_freq (); /* PCI PSPEED in [4:5] */
|
|
|
|
pci_32 = pordevsr & MPC85xx_PORDEVSR_PCI1_PCI32; /* PORDEVSR[15] */
|
|
|
|
pci_arb = pordevsr & MPC85xx_PORDEVSR_PCI1_ARB;
|
|
|
|
pci_clk_sel = porpllsr & MPC85xx_PORDEVSR_PCI1_SPD;
|
|
|
|
|
|
|
|
if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
|
2010-12-17 16:21:22 +00:00
|
|
|
SET_STD_PCI_INFO(pci_info, 1);
|
|
|
|
set_next_law(pci_info.mem_phys,
|
|
|
|
law_size_bits(pci_info.mem_size), pci_info.law);
|
|
|
|
set_next_law(pci_info.io_phys,
|
|
|
|
law_size_bits(pci_info.io_size), pci_info.law);
|
|
|
|
|
|
|
|
pci_agent = fsl_setup_hose(&pci1_hose, pci_info.regs);
|
2011-09-06 16:41:14 +00:00
|
|
|
printf("PCI1: %d bit, %s MHz, %s, %s, %s (base address %lx)\n",
|
2007-07-27 06:50:52 +00:00
|
|
|
(pci_32) ? 32 : 64,
|
2011-09-15 06:52:34 +00:00
|
|
|
strmhz(buf, pci_speed),
|
2007-07-27 06:50:52 +00:00
|
|
|
pci_clk_sel ? "sync" : "async",
|
|
|
|
pci_agent ? "agent" : "host",
|
2009-11-04 17:15:29 +00:00
|
|
|
pci_arb ? "arbiter" : "external-arbiter",
|
2010-12-17 16:21:22 +00:00
|
|
|
pci_info.regs);
|
2009-11-04 17:15:29 +00:00
|
|
|
|
2011-08-24 05:20:04 +00:00
|
|
|
pci1_hose.config_table = pci_mpc85xxcds_config_table;
|
2010-12-17 16:21:22 +00:00
|
|
|
first_free_busno = fsl_pci_init_port(&pci_info,
|
2009-11-04 17:15:29 +00:00
|
|
|
&pci1_hose, first_free_busno);
|
|
|
|
|
2007-07-27 06:50:52 +00:00
|
|
|
#ifdef CONFIG_PCIX_CHECK
|
2009-11-04 17:15:29 +00:00
|
|
|
if (!(pordevsr & MPC85xx_PORDEVSR_PCI1)) {
|
2007-07-27 06:50:52 +00:00
|
|
|
/* PCI-X init */
|
|
|
|
if (CONFIG_SYS_CLK_FREQ < 66000000)
|
|
|
|
printf("PCI-X will only work at 66 MHz\n");
|
|
|
|
|
|
|
|
reg16 = PCI_X_CMD_MAX_SPLIT | PCI_X_CMD_MAX_READ
|
|
|
|
| PCI_X_CMD_ERO | PCI_X_CMD_DPERR_E;
|
|
|
|
pci_hose_write_config_word(hose, bus, PCIX_COMMAND, reg16);
|
|
|
|
}
|
2005-07-25 19:05:07 +00:00
|
|
|
#endif
|
2007-07-27 06:50:52 +00:00
|
|
|
} else {
|
2011-09-06 16:41:14 +00:00
|
|
|
printf("PCI1: disabled\n");
|
2007-07-27 06:50:52 +00:00
|
|
|
}
|
2009-11-04 17:15:29 +00:00
|
|
|
|
|
|
|
puts("\n");
|
2007-07-27 06:50:52 +00:00
|
|
|
#else
|
2009-11-04 17:15:29 +00:00
|
|
|
setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1); /* disable */
|
2007-07-27 06:50:52 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_PCI2
|
|
|
|
{
|
2009-11-04 17:15:29 +00:00
|
|
|
uint pci2_clk_sel = porpllsr & 0x4000; /* PORPLLSR[17] */
|
2007-07-27 06:50:52 +00:00
|
|
|
uint pci_dual = get_pci_dual (); /* PCI DUAL in CM_PCI[3] */
|
|
|
|
if (pci_dual) {
|
2010-10-29 22:59:24 +00:00
|
|
|
printf("PCI2: 32 bit, 66 MHz, %s\n",
|
2007-07-27 06:50:52 +00:00
|
|
|
pci2_clk_sel ? "sync" : "async");
|
|
|
|
} else {
|
2010-10-29 22:59:24 +00:00
|
|
|
printf("PCI2: disabled\n");
|
2007-07-27 06:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2009-11-04 17:15:29 +00:00
|
|
|
setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI2); /* disable */
|
2007-07-27 06:50:52 +00:00
|
|
|
#endif /* CONFIG_PCI2 */
|
|
|
|
|
2010-12-17 16:21:22 +00:00
|
|
|
fsl_pcie_init_board(first_free_busno);
|
2005-07-25 19:05:07 +00:00
|
|
|
}
|
2006-09-13 15:34:18 +00:00
|
|
|
|
|
|
|
int last_stage_init(void)
|
|
|
|
{
|
2006-10-20 20:54:34 +00:00
|
|
|
unsigned short temp;
|
2006-09-13 15:34:18 +00:00
|
|
|
|
|
|
|
/* Change the resistors for the PHY */
|
|
|
|
/* This is needed to get the RGMII working for the 1.3+
|
|
|
|
* CDS cards */
|
|
|
|
if (get_board_version() == 0x13) {
|
2007-05-16 21:52:19 +00:00
|
|
|
miiphy_write(CONFIG_TSEC1_NAME,
|
2006-09-13 15:34:18 +00:00
|
|
|
TSEC1_PHY_ADDR, 29, 18);
|
|
|
|
|
2007-05-16 21:52:19 +00:00
|
|
|
miiphy_read(CONFIG_TSEC1_NAME,
|
2006-09-13 15:34:18 +00:00
|
|
|
TSEC1_PHY_ADDR, 30, &temp);
|
|
|
|
|
|
|
|
temp = (temp & 0xf03f);
|
|
|
|
temp |= 2 << 9; /* 36 ohm */
|
|
|
|
temp |= 2 << 6; /* 39 ohm */
|
|
|
|
|
2007-05-16 21:52:19 +00:00
|
|
|
miiphy_write(CONFIG_TSEC1_NAME,
|
2006-09-13 15:34:18 +00:00
|
|
|
TSEC1_PHY_ADDR, 30, temp);
|
|
|
|
|
2007-05-16 21:52:19 +00:00
|
|
|
miiphy_write(CONFIG_TSEC1_NAME,
|
2006-09-13 15:34:18 +00:00
|
|
|
TSEC1_PHY_ADDR, 29, 3);
|
|
|
|
|
2007-05-16 21:52:19 +00:00
|
|
|
miiphy_write(CONFIG_TSEC1_NAME,
|
2006-09-13 15:34:18 +00:00
|
|
|
TSEC1_PHY_ADDR, 30, 0x8000);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-07-27 06:50:52 +00:00
|
|
|
|
|
|
|
|
2007-11-29 06:11:44 +00:00
|
|
|
#if defined(CONFIG_OF_BOARD_SETUP)
|
2008-10-21 13:28:33 +00:00
|
|
|
void ft_pci_setup(void *blob, bd_t *bd)
|
|
|
|
{
|
2010-07-09 03:37:44 +00:00
|
|
|
FT_FSL_PCI_SETUP;
|
2007-07-27 06:50:52 +00:00
|
|
|
}
|
|
|
|
#endif
|