2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2008-04-30 09:42:50 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2008
|
|
|
|
* Sergei Poselenov, Emcraft Systems, sposelenov@emcraft.com.
|
|
|
|
*
|
|
|
|
* Copyright 2004 Freescale Semiconductor.
|
|
|
|
* (C) Copyright 2002,2003, Motorola Inc.
|
|
|
|
* Xianghua Xiao, (X.Xiao@motorola.com)
|
|
|
|
*
|
|
|
|
* (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-12-28 17:44:58 +00:00
|
|
|
#include <clock_legacy.h>
|
2019-08-01 15:46:42 +00:00
|
|
|
#include <env.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2008-04-30 09:42:50 +00:00
|
|
|
#include <pci.h>
|
2020-05-10 17:39:54 +00:00
|
|
|
#include <uuid.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2008-04-30 09:42:50 +00:00
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/immap_85xx.h>
|
|
|
|
#include <ioports.h>
|
|
|
|
#include <flash.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>
|
2008-05-07 13:10:49 +00:00
|
|
|
#include <fdt_support.h>
|
2008-06-10 23:49:34 +00:00
|
|
|
#include <asm/io.h>
|
2008-09-11 13:40:01 +00:00
|
|
|
#include <i2c.h>
|
2008-06-06 13:42:41 +00:00
|
|
|
#include "upm_table.h"
|
2008-08-15 13:42:12 +00:00
|
|
|
|
2008-04-30 09:42:50 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
void local_bus_init (void);
|
|
|
|
ulong flash_get_size (ulong base, int banknum);
|
|
|
|
|
|
|
|
int checkboard (void)
|
|
|
|
{
|
2022-10-29 00:27:12 +00:00
|
|
|
volatile ccsr_gur_t *gur = (void *)(CFG_SYS_MPC85xx_GUTS_ADDR);
|
2011-05-04 10:32:28 +00:00
|
|
|
char buf[64];
|
2008-05-27 11:47:00 +00:00
|
|
|
int f;
|
2017-08-03 18:22:12 +00:00
|
|
|
int i = env_get_f("serial#", buf, sizeof(buf));
|
2011-05-04 10:32:28 +00:00
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
char *src;
|
|
|
|
#endif
|
2008-04-30 09:42:50 +00:00
|
|
|
|
|
|
|
puts("Board: Socrates");
|
2011-05-04 10:32:28 +00:00
|
|
|
if (i > 0) {
|
2008-04-30 09:42:50 +00:00
|
|
|
puts(", serial# ");
|
2011-05-04 10:32:28 +00:00
|
|
|
puts(buf);
|
2008-04-30 09:42:50 +00:00
|
|
|
}
|
|
|
|
putc('\n');
|
|
|
|
|
2021-08-02 00:54:28 +00:00
|
|
|
#if defined(CONFIG_PCI)
|
2008-06-10 23:49:34 +00:00
|
|
|
/* Check the PCI_clk sel bit */
|
|
|
|
if (in_be32(&gur->porpllsr) & (1<<15)) {
|
2008-05-27 11:47:00 +00:00
|
|
|
src = "SYSCLK";
|
2021-12-14 18:36:40 +00:00
|
|
|
f = get_board_sys_clk();
|
2008-05-27 11:47:00 +00:00
|
|
|
} else {
|
|
|
|
src = "PCI_CLK";
|
2022-06-20 12:07:54 +00:00
|
|
|
/* PCI is clocked by the external source at 33 MHz */
|
|
|
|
f = 33000000;
|
2008-05-27 11:47:00 +00:00
|
|
|
}
|
|
|
|
printf ("PCI1: 32 bit, %d MHz (%s)\n", f/1000000, src);
|
2008-04-30 09:42:50 +00:00
|
|
|
#else
|
|
|
|
printf ("PCI1: disabled\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize local bus.
|
|
|
|
*/
|
|
|
|
local_bus_init ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int misc_init_r (void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Adjust flash start and offset to detected values
|
|
|
|
*/
|
|
|
|
gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
|
|
|
|
gd->bd->bi_flashoffset = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if boot FLASH isn't max size
|
|
|
|
*/
|
2022-11-16 18:10:41 +00:00
|
|
|
if (gd->bd->bi_flashsize < (0 - CFG_SYS_FLASH0)) {
|
2010-06-17 16:37:20 +00:00
|
|
|
set_lbc_or(0, gd->bd->bi_flashstart |
|
|
|
|
(CONFIG_SYS_OR0_PRELIM & 0x00007fff));
|
|
|
|
set_lbc_br(0, gd->bd->bi_flashstart |
|
|
|
|
(CONFIG_SYS_BR0_PRELIM & 0x00007fff));
|
2008-04-30 09:42:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Re-check to get correct base address
|
|
|
|
*/
|
2008-10-16 13:01:15 +00:00
|
|
|
flash_get_size(gd->bd->bi_flashstart, CONFIG_SYS_MAX_FLASH_BANKS - 1);
|
2008-04-30 09:42:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if only one FLASH bank is available
|
|
|
|
*/
|
2022-11-16 18:10:41 +00:00
|
|
|
if (gd->bd->bi_flashsize != CONFIG_SYS_MAX_FLASH_BANKS * (0 - CFG_SYS_FLASH0)) {
|
2010-06-17 16:37:20 +00:00
|
|
|
set_lbc_or(1, 0);
|
|
|
|
set_lbc_br(1, 0);
|
2008-04-30 09:42:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Re-do flash protection upon new addresses
|
|
|
|
*/
|
2020-05-10 17:39:53 +00:00
|
|
|
flash_protect(FLAG_PROTECT_CLEAR,
|
|
|
|
gd->bd->bi_flashstart, 0xffffffff,
|
|
|
|
&flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
|
2008-04-30 09:42:50 +00:00
|
|
|
|
|
|
|
/* Monitor protection ON by default */
|
2020-05-10 17:39:53 +00:00
|
|
|
flash_protect(FLAG_PROTECT_SET,
|
|
|
|
CONFIG_SYS_MONITOR_BASE, CONFIG_SYS_MONITOR_BASE +
|
|
|
|
monitor_flash_len - 1,
|
|
|
|
&flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
|
2008-04-30 09:42:50 +00:00
|
|
|
|
|
|
|
/* Environment protection ON by default */
|
2020-05-10 17:39:53 +00:00
|
|
|
flash_protect(FLAG_PROTECT_SET,
|
|
|
|
CONFIG_ENV_ADDR,
|
|
|
|
CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
|
|
|
|
&flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
|
2008-04-30 09:42:50 +00:00
|
|
|
|
|
|
|
/* Redundant environment protection ON by default */
|
2020-05-10 17:39:53 +00:00
|
|
|
flash_protect(FLAG_PROTECT_SET,
|
|
|
|
CONFIG_ENV_ADDR_REDUND,
|
|
|
|
CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
|
2008-10-16 13:01:15 +00:00
|
|
|
&flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
|
2008-04-30 09:42:50 +00:00
|
|
|
}
|
|
|
|
|
2019-10-16 03:55:54 +00:00
|
|
|
pci_init();
|
|
|
|
|
2008-04-30 09:42:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize Local Bus
|
|
|
|
*/
|
|
|
|
void local_bus_init (void)
|
|
|
|
{
|
2010-06-17 16:37:20 +00:00
|
|
|
volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
|
2022-10-29 00:27:12 +00:00
|
|
|
volatile ccsr_local_ecm_t *ecm = (void *)(CFG_SYS_MPC85xx_ECM_ADDR);
|
2008-08-15 13:42:12 +00:00
|
|
|
sys_info_t sysinfo;
|
|
|
|
uint clkdiv;
|
|
|
|
uint lbc_mhz;
|
2022-11-16 18:10:41 +00:00
|
|
|
uint lcrr = CFG_SYS_LBC_LCRR;
|
2008-08-15 13:42:12 +00:00
|
|
|
|
|
|
|
get_sys_info (&sysinfo);
|
2008-12-03 23:16:34 +00:00
|
|
|
clkdiv = lbc->lcrr & LCRR_CLKDIV;
|
2013-08-16 09:22:26 +00:00
|
|
|
lbc_mhz = sysinfo.freq_systembus / 1000000 / clkdiv;
|
2008-08-15 13:42:12 +00:00
|
|
|
|
|
|
|
/* Disable PLL bypass for Local Bus Clock >= 66 MHz */
|
|
|
|
if (lbc_mhz >= 66)
|
|
|
|
lcrr &= ~LCRR_DBYP; /* DLL Enabled */
|
|
|
|
else
|
|
|
|
lcrr |= LCRR_DBYP; /* DLL Bypass */
|
|
|
|
|
|
|
|
out_be32 (&lbc->lcrr, lcrr);
|
|
|
|
asm ("sync;isync;msync");
|
2008-04-30 09:42:50 +00:00
|
|
|
|
2008-08-15 13:42:12 +00:00
|
|
|
out_be32 (&lbc->ltesr, 0xffffffff); /* Clear LBC error interrupts */
|
|
|
|
out_be32 (&lbc->lteir, 0xffffffff); /* Enable LBC error interrupts */
|
|
|
|
out_be32 (&ecm->eedr, 0xffffffff); /* Clear ecm errors */
|
|
|
|
out_be32 (&ecm->eeer, 0xffffffff); /* Enable ecm errors */
|
2008-04-30 09:42:50 +00:00
|
|
|
|
2008-08-15 13:42:12 +00:00
|
|
|
/* Init UPMA for FPGA access */
|
|
|
|
out_be32 (&lbc->mamr, 0x44440); /* Use a customer-supplied value */
|
2019-12-28 17:44:57 +00:00
|
|
|
upmconfig(UPMA, (uint *)UPMTableA, sizeof(UPMTableA) / sizeof(int));
|
2008-08-15 13:42:13 +00:00
|
|
|
|
2008-09-11 13:40:01 +00:00
|
|
|
/* Init UPMB for Lime controller access */
|
|
|
|
out_be32 (&lbc->mbmr, 0x444440); /* Use a customer-supplied value */
|
2019-12-28 17:44:57 +00:00
|
|
|
upmconfig(UPMB, (uint *)UPMTableB, sizeof(UPMTableB) / sizeof(int));
|
2008-04-30 09:42:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_BOARD_EARLY_INIT_R
|
|
|
|
int board_early_init_r (void)
|
|
|
|
{
|
2022-10-29 00:27:12 +00:00
|
|
|
volatile ccsr_gur_t *gur = (void *)(CFG_SYS_MPC85xx_GUTS_ADDR);
|
2008-08-15 13:42:12 +00:00
|
|
|
|
|
|
|
/* set and reset the GPIO pin 2 which will reset the W83782G chip */
|
|
|
|
out_8((unsigned char*)&gur->gpoutdr, 0x3F );
|
|
|
|
out_be32((unsigned int*)&gur->gpiocr, 0x200 ); /* enable GPOut */
|
|
|
|
udelay(200);
|
|
|
|
out_8( (unsigned char*)&gur->gpoutdr, 0x1F );
|
|
|
|
|
2008-04-30 09:42:50 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_BOARD_EARLY_INIT_R */
|
2008-05-07 13:10:49 +00:00
|
|
|
|
2016-05-19 19:23:12 +00:00
|
|
|
#ifdef CONFIG_OF_BOARD_SETUP
|
2020-06-26 06:13:33 +00:00
|
|
|
int ft_board_setup(void *blob, struct bd_info *bd)
|
2008-05-07 13:10:49 +00:00
|
|
|
{
|
2008-08-15 13:42:12 +00:00
|
|
|
u32 val[12];
|
|
|
|
int rc, i = 0;
|
2008-05-07 13:10:49 +00:00
|
|
|
|
|
|
|
ft_cpu_setup(blob, bd);
|
|
|
|
|
2008-08-15 13:42:12 +00:00
|
|
|
/* Fixup NOR FLASH mapping */
|
|
|
|
val[i++] = 0; /* chip select number */
|
|
|
|
val[i++] = 0; /* always 0 */
|
|
|
|
val[i++] = gd->bd->bi_flashstart;
|
|
|
|
val[i++] = gd->bd->bi_flashsize;
|
2008-05-07 13:10:49 +00:00
|
|
|
|
2008-08-15 13:42:12 +00:00
|
|
|
/* Fixup FPGA mapping */
|
|
|
|
val[i++] = 3; /* chip select number */
|
|
|
|
val[i++] = 0; /* always 0 */
|
2022-11-16 18:10:41 +00:00
|
|
|
val[i++] = CFG_SYS_FPGA_BASE;
|
|
|
|
val[i++] = CFG_SYS_FPGA_SIZE;
|
2008-06-06 13:42:45 +00:00
|
|
|
|
2008-08-15 13:42:12 +00:00
|
|
|
rc = fdt_find_and_setprop(blob, "/localbus", "ranges",
|
|
|
|
val, i * sizeof(u32), 1);
|
2008-06-06 13:42:45 +00:00
|
|
|
if (rc)
|
2008-08-15 13:42:12 +00:00
|
|
|
printf("Unable to update localbus ranges, err=%s\n",
|
2008-06-06 13:42:45 +00:00
|
|
|
fdt_strerror(rc));
|
2014-10-24 00:58:47 +00:00
|
|
|
|
|
|
|
return 0;
|
2008-05-07 13:10:49 +00:00
|
|
|
}
|
2016-05-19 19:23:12 +00:00
|
|
|
#endif /* CONFIG_OF_BOARD_SETUP */
|
2008-08-15 13:42:13 +00:00
|
|
|
|
2019-10-16 03:55:53 +00:00
|
|
|
int get_serial_clock(void)
|
|
|
|
{
|
|
|
|
return 333333330;
|
|
|
|
}
|