2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
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>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2022-07-31 18:28:48 +00:00
|
|
|
#include <display_options.h>
|
2019-11-14 19:57:47 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <net.h>
|
2005-07-25 19:05:07 +00:00
|
|
|
#include <pci.h>
|
2019-11-14 19:57:20 +00:00
|
|
|
#include <vsprintf.h>
|
2005-07-25 19:05:07 +00:00
|
|
|
#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>
|
2013-09-30 16:22:09 +00:00
|
|
|
#include <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>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2018-03-04 16:20:11 +00:00
|
|
|
#include <linux/libfdt.h>
|
2007-11-29 06:11:44 +00:00
|
|
|
#include <fdt_support.h>
|
2011-09-06 16:41:18 +00:00
|
|
|
#include <tsec.h>
|
|
|
|
#include <fsl_mdio.h>
|
|
|
|
#include <netdev.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)
|
|
|
|
{
|
2022-10-29 00:27:12 +00:00
|
|
|
volatile ccsr_gur_t *gur = (void *)(CFG_SYS_MPC85xx_GUTS_ADDR);
|
|
|
|
volatile ccsr_local_ecm_t *ecm = (void *)(CFG_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)
|
|
|
|
{
|
2022-10-29 00:27:12 +00:00
|
|
|
volatile ccsr_gur_t *gur = (void *)(CFG_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;
|
|
|
|
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
|
|
|
|
|
|
|
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 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.
|
|
|
|
*/
|
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 */
|
|
|
|
}
|
|
|
|
|
2022-08-02 11:33:39 +00:00
|
|
|
#ifndef CONFIG_DM_ETH
|
|
|
|
static void configure_rgmii(void)
|
2006-09-13 15:34:18 +00:00
|
|
|
{
|
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) {
|
2011-09-06 16:41:18 +00:00
|
|
|
miiphy_write(DEFAULT_MII_NAME,
|
2006-09-13 15:34:18 +00:00
|
|
|
TSEC1_PHY_ADDR, 29, 18);
|
|
|
|
|
2011-09-06 16:41:18 +00:00
|
|
|
miiphy_read(DEFAULT_MII_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 */
|
|
|
|
|
2011-09-06 16:41:18 +00:00
|
|
|
miiphy_write(DEFAULT_MII_NAME,
|
2006-09-13 15:34:18 +00:00
|
|
|
TSEC1_PHY_ADDR, 30, temp);
|
|
|
|
|
2011-09-06 16:41:18 +00:00
|
|
|
miiphy_write(DEFAULT_MII_NAME,
|
2006-09-13 15:34:18 +00:00
|
|
|
TSEC1_PHY_ADDR, 29, 3);
|
|
|
|
|
2011-09-06 16:41:18 +00:00
|
|
|
miiphy_write(DEFAULT_MII_NAME,
|
2006-09-13 15:34:18 +00:00
|
|
|
TSEC1_PHY_ADDR, 30, 0x8000);
|
|
|
|
}
|
|
|
|
|
2011-09-06 16:41:18 +00:00
|
|
|
return;
|
2006-09-13 15:34:18 +00:00
|
|
|
}
|
2007-07-27 06:50:52 +00:00
|
|
|
|
2020-06-26 06:13:33 +00:00
|
|
|
int board_eth_init(struct bd_info *bis)
|
2011-09-06 16:41:18 +00:00
|
|
|
{
|
2016-01-12 06:41:15 +00:00
|
|
|
#ifdef CONFIG_TSEC_ENET
|
2011-09-06 16:41:18 +00:00
|
|
|
struct fsl_pq_mdio_info mdio_info;
|
|
|
|
struct tsec_info_struct tsec_info[4];
|
|
|
|
int num = 0;
|
|
|
|
|
|
|
|
#ifdef CONFIG_TSEC1
|
|
|
|
SET_STD_TSEC_INFO(tsec_info[num], 1);
|
|
|
|
num++;
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_TSEC2
|
|
|
|
SET_STD_TSEC_INFO(tsec_info[num], 2);
|
|
|
|
num++;
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_TSEC3
|
|
|
|
/* initialize TSEC3 only if Carrier is 1.3 or above on CDS */
|
|
|
|
if (get_board_version() >= 0x13) {
|
|
|
|
SET_STD_TSEC_INFO(tsec_info[num], 3);
|
|
|
|
tsec_info[num].interface = PHY_INTERFACE_MODE_RGMII_ID;
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_TSEC4
|
|
|
|
/* initialize TSEC4 only if Carrier is 1.3 or above on CDS */
|
|
|
|
if (get_board_version() >= 0x13) {
|
|
|
|
SET_STD_TSEC_INFO(tsec_info[num], 4);
|
|
|
|
tsec_info[num].interface = PHY_INTERFACE_MODE_RGMII_ID;
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!num) {
|
|
|
|
printf("No TSECs initialized\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
|
|
|
|
mdio_info.name = DEFAULT_MII_NAME;
|
|
|
|
fsl_pq_mdio_init(bis, &mdio_info);
|
|
|
|
|
|
|
|
tsec_eth_init(bis, tsec_info, num);
|
|
|
|
configure_rgmii();
|
2016-01-12 06:41:15 +00:00
|
|
|
#endif
|
2011-09-06 16:41:18 +00:00
|
|
|
|
|
|
|
return pci_eth_init(bis);
|
|
|
|
}
|
2022-08-02 11:33:39 +00:00
|
|
|
#endif
|