upstream u-boot with additional patches for our devices/boards:
https://lists.denx.de/pipermail/u-boot/2017-March/282789.html (AXP crashes) ;
Gbit ethernet patch for some LIME2 revisions ;
with SPI flash support
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
234 lines
7.1 KiB
234 lines
7.1 KiB
22 years ago
|
/*
|
||
15 years ago
|
* (C) Copyright 2000-2010
|
||
22 years ago
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||
|
*
|
||
|
* 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 <mpc5xxx.h>
|
||
15 years ago
|
#include <asm/io.h>
|
||
15 years ago
|
#include <watchdog.h>
|
||
22 years ago
|
|
||
19 years ago
|
DECLARE_GLOBAL_DATA_PTR;
|
||
|
|
||
22 years ago
|
/*
|
||
|
* Breath some life into the CPU...
|
||
|
*
|
||
|
* Set up the memory map,
|
||
|
* initialize a bunch of registers.
|
||
|
*/
|
||
|
void cpu_init_f (void)
|
||
|
{
|
||
15 years ago
|
volatile struct mpc5xxx_mmap_ctl *mm =
|
||
|
(struct mpc5xxx_mmap_ctl *) CONFIG_SYS_MBAR;
|
||
|
volatile struct mpc5xxx_lpb *lpb =
|
||
|
(struct mpc5xxx_lpb *) MPC5XXX_LPB;
|
||
|
volatile struct mpc5xxx_gpio *gpio =
|
||
|
(struct mpc5xxx_gpio *) MPC5XXX_GPIO;
|
||
|
volatile struct mpc5xxx_xlb *xlb =
|
||
|
(struct mpc5xxx_xlb *) MPC5XXX_XLBARB;
|
||
15 years ago
|
#if defined(CONFIG_SYS_IPBCLK_EQUALS_XLBCLK)
|
||
|
volatile struct mpc5xxx_cdm *cdm =
|
||
|
(struct mpc5xxx_cdm *) MPC5XXX_CDM;
|
||
|
#endif /* CONFIG_SYS_IPBCLK_EQUALS_XLBCLK */
|
||
15 years ago
|
#if defined(CONFIG_WATCHDOG)
|
||
15 years ago
|
volatile struct mpc5xxx_gpt *gpt0 =
|
||
|
(struct mpc5xxx_gpt *) MPC5XXX_GPT;
|
||
15 years ago
|
#endif /* CONFIG_WATCHDOG */
|
||
22 years ago
|
unsigned long addecr = (1 << 25); /* Boot_CS */
|
||
|
/* Pointer is writable since we allocated a register for it */
|
||
16 years ago
|
gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
|
||
22 years ago
|
|
||
|
/* Clear initial global data */
|
||
|
memset ((void *) gd, 0, sizeof (gd_t));
|
||
|
|
||
|
/*
|
||
|
* Memory Controller: configure chip selects and enable them
|
||
|
*/
|
||
16 years ago
|
#if defined(CONFIG_SYS_BOOTCS_START) && defined(CONFIG_SYS_BOOTCS_SIZE)
|
||
15 years ago
|
out_be32(&mm->boot_start, START_REG(CONFIG_SYS_BOOTCS_START));
|
||
|
out_be32(&mm->boot_stop, STOP_REG(CONFIG_SYS_BOOTCS_START,
|
||
|
CONFIG_SYS_BOOTCS_SIZE));
|
||
22 years ago
|
#endif
|
||
16 years ago
|
#if defined(CONFIG_SYS_BOOTCS_CFG)
|
||
15 years ago
|
out_be32(&lpb->cs0_cfg, CONFIG_SYS_BOOTCS_CFG);
|
||
22 years ago
|
#endif
|
||
|
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS0_START) && defined(CONFIG_SYS_CS0_SIZE)
|
||
15 years ago
|
out_be32(&mm->cs0_start, START_REG(CONFIG_SYS_CS0_START));
|
||
|
out_be32(&mm->cs0_stop, STOP_REG(CONFIG_SYS_CS0_START,
|
||
|
CONFIG_SYS_CS0_SIZE));
|
||
22 years ago
|
/* CS0 and BOOT_CS cannot be enabled at once. */
|
||
|
/* addecr |= (1 << 16); */
|
||
|
#endif
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS0_CFG)
|
||
15 years ago
|
out_be32(&lpb->cs0_cfg, CONFIG_SYS_CS0_CFG);
|
||
22 years ago
|
#endif
|
||
|
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS1_START) && defined(CONFIG_SYS_CS1_SIZE)
|
||
15 years ago
|
out_be32(&mm->cs1_start, START_REG(CONFIG_SYS_CS1_START));
|
||
|
out_be32(&mm->cs1_stop, STOP_REG(CONFIG_SYS_CS1_START,
|
||
|
CONFIG_SYS_CS1_SIZE));
|
||
22 years ago
|
addecr |= (1 << 17);
|
||
|
#endif
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS1_CFG)
|
||
15 years ago
|
out_be32(&lpb->cs1_cfg, CONFIG_SYS_CS1_CFG);
|
||
22 years ago
|
#endif
|
||
|
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS2_START) && defined(CONFIG_SYS_CS2_SIZE)
|
||
15 years ago
|
out_be32(&mm->cs2_start, START_REG(CONFIG_SYS_CS2_START));
|
||
|
out_be32(&mm->cs2_stop, STOP_REG(CONFIG_SYS_CS2_START,
|
||
|
CONFIG_SYS_CS2_SIZE));
|
||
22 years ago
|
addecr |= (1 << 18);
|
||
|
#endif
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS2_CFG)
|
||
15 years ago
|
out_be32(&lpb->cs2_cfg, CONFIG_SYS_CS2_CFG);
|
||
22 years ago
|
#endif
|
||
|
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS3_START) && defined(CONFIG_SYS_CS3_SIZE)
|
||
15 years ago
|
out_be32(&mm->cs3_start, START_REG(CONFIG_SYS_CS3_START));
|
||
|
out_be32(&mm->cs3_stop, STOP_REG(CONFIG_SYS_CS3_START,
|
||
|
CONFIG_SYS_CS3_SIZE));
|
||
22 years ago
|
addecr |= (1 << 19);
|
||
|
#endif
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS3_CFG)
|
||
15 years ago
|
out_be32(&lpb->cs3_cfg, CONFIG_SYS_CS3_CFG);
|
||
22 years ago
|
#endif
|
||
|
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS4_START) && defined(CONFIG_SYS_CS4_SIZE)
|
||
15 years ago
|
out_be32(&mm->cs4_start, START_REG(CONFIG_SYS_CS4_START));
|
||
|
out_be32(&mm->cs4_stop, STOP_REG(CONFIG_SYS_CS4_START,
|
||
|
CONFIG_SYS_CS4_SIZE));
|
||
22 years ago
|
addecr |= (1 << 20);
|
||
|
#endif
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS4_CFG)
|
||
15 years ago
|
out_be32(&lpb->cs4_cfg, CONFIG_SYS_CS4_CFG);
|
||
22 years ago
|
#endif
|
||
|
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS5_START) && defined(CONFIG_SYS_CS5_SIZE)
|
||
15 years ago
|
out_be32(&mm->cs5_start, START_REG(CONFIG_SYS_CS5_START));
|
||
|
out_be32(&mm->cs5_stop, STOP_REG(CONFIG_SYS_CS5_START,
|
||
|
CONFIG_SYS_CS5_SIZE));
|
||
22 years ago
|
addecr |= (1 << 21);
|
||
|
#endif
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS5_CFG)
|
||
15 years ago
|
out_be32(&lpb->cs5_cfg, CONFIG_SYS_CS5_CFG);
|
||
22 years ago
|
#endif
|
||
|
|
||
|
addecr |= 1;
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS6_START) && defined(CONFIG_SYS_CS6_SIZE)
|
||
15 years ago
|
out_be32(&mm->cs6_start, START_REG(CONFIG_SYS_CS6_START));
|
||
|
out_be32(&mm->cs6_stop, STOP_REG(CONFIG_SYS_CS6_START,
|
||
|
CONFIG_SYS_CS6_SIZE));
|
||
22 years ago
|
addecr |= (1 << 26);
|
||
|
#endif
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS6_CFG)
|
||
15 years ago
|
out_be32(&lpb->cs6_cfg, CONFIG_SYS_CS6_CFG);
|
||
22 years ago
|
#endif
|
||
|
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS7_START) && defined(CONFIG_SYS_CS7_SIZE)
|
||
15 years ago
|
out_be32(&mm->cs7_start, START_REG(CONFIG_SYS_CS7_START));
|
||
|
out_be32(&mm->cs7_stop, STOP_REG(CONFIG_SYS_CS7_START,
|
||
|
CONFIG_SYS_CS7_SIZE));
|
||
22 years ago
|
addecr |= (1 << 27);
|
||
|
#endif
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS7_CFG)
|
||
15 years ago
|
out_be32(&lpb->cs7_cfg, CONFIG_SYS_CS7_CFG);
|
||
22 years ago
|
#endif
|
||
|
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS_BURST)
|
||
15 years ago
|
out_be32(&lpb->cs_burst, CONFIG_SYS_CS_BURST);
|
||
22 years ago
|
#endif
|
||
16 years ago
|
#if defined(CONFIG_SYS_CS_DEADCYCLE)
|
||
15 years ago
|
out_be32(&lpb->cs_deadcycle, CONFIG_SYS_CS_DEADCYCLE);
|
||
22 years ago
|
#endif
|
||
|
|
||
|
/* Enable chip selects */
|
||
15 years ago
|
out_be32(&mm->ipbi_ws_ctrl, addecr);
|
||
|
out_be32(&lpb->cs_ctrl, (1 << 24));
|
||
22 years ago
|
|
||
|
/* Setup pin multiplexing */
|
||
16 years ago
|
#if defined(CONFIG_SYS_GPS_PORT_CONFIG)
|
||
15 years ago
|
out_be32(&gpio->port_config, CONFIG_SYS_GPS_PORT_CONFIG);
|
||
22 years ago
|
#endif
|
||
22 years ago
|
|
||
|
/* enable timebase */
|
||
15 years ago
|
setbits_be32(&xlb->config, (1 << 13));
|
||
22 years ago
|
|
||
19 years ago
|
/* Enable snooping for RAM */
|
||
15 years ago
|
setbits_be32(&xlb->config, (1 << 15));
|
||
|
out_be32(&xlb->snoop_window, CONFIG_SYS_SDRAM_BASE | 0x1d);
|
||
19 years ago
|
|
||
15 years ago
|
#if defined(CONFIG_SYS_IPBCLK_EQUALS_XLBCLK)
|
||
22 years ago
|
/* Motorola reports IPB should better run at 133 MHz. */
|
||
15 years ago
|
setbits_be32(&mm->ipbi_ws_ctrl, 1);
|
||
22 years ago
|
/* pci_clk_sel = 0x02, ipb_clk_sel = 0x00; */
|
||
15 years ago
|
addecr = in_be32(&cdm->cfg);
|
||
22 years ago
|
addecr &= ~0x103;
|
||
15 years ago
|
# if defined(CONFIG_SYS_PCICLK_EQUALS_IPBCLK_DIV2)
|
||
21 years ago
|
/* pci_clk_sel = 0x01 -> IPB_CLK/2 */
|
||
|
addecr |= 0x01;
|
||
15 years ago
|
# else
|
||
21 years ago
|
/* pci_clk_sel = 0x02 -> XLB_CLK/4 = IPB_CLK/4 */
|
||
22 years ago
|
addecr |= 0x02;
|
||
15 years ago
|
# endif /* CONFIG_SYS_PCICLK_EQUALS_IPBCLK_DIV2 */
|
||
15 years ago
|
out_be32(&cdm->cfg, addecr);
|
||
15 years ago
|
#endif /* CONFIG_SYS_IPBCLK_EQUALS_XLBCLK */
|
||
22 years ago
|
/* Configure the XLB Arbiter */
|
||
15 years ago
|
out_be32(&xlb->master_pri_enable, 0xff);
|
||
|
out_be32(&xlb->master_priority, 0x11111111);
|
||
20 years ago
|
|
||
15 years ago
|
#if defined(CONFIG_SYS_XLB_PIPELINING)
|
||
20 years ago
|
/* Enable piplining */
|
||
15 years ago
|
clrbits_be32(&xlb->config, (1 << 31));
|
||
15 years ago
|
#endif
|
||
15 years ago
|
|
||
|
#if defined(CONFIG_WATCHDOG)
|
||
|
/* Charge the watchdog timer - prescaler = 64k, count = 64k*/
|
||
|
out_be32(&gpt0->cir, 0x0000ffff);
|
||
|
out_be32(&gpt0->emsr, 0x9004); /* wden|ce|timer_ms */
|
||
|
|
||
|
reset_5xxx_watchdog();
|
||
|
#endif /* CONFIG_WATCHDOG */
|
||
22 years ago
|
}
|
||
|
|
||
|
/*
|
||
|
* initialize higher level parts of CPU like time base and timers
|
||
|
*/
|
||
|
int cpu_init_r (void)
|
||
|
{
|
||
15 years ago
|
volatile struct mpc5xxx_intr *intr =
|
||
|
(struct mpc5xxx_intr *) MPC5XXX_ICTL;
|
||
|
|
||
22 years ago
|
/* mask all interrupts */
|
||
15 years ago
|
out_be32(&intr->per_mask, 0xffffff00);
|
||
|
setbits_be32(&intr->main_mask, 0x0001ffff);
|
||
|
clrbits_be32(&intr->ctrl, 0x00000f00);
|
||
22 years ago
|
/* route critical ints to normal ints */
|
||
15 years ago
|
setbits_be32(&intr->ctrl, 0x00000001);
|
||
22 years ago
|
|
||
18 years ago
|
#if defined(CONFIG_CMD_NET) && defined(CONFIG_MPC5xxx_FEC)
|
||
22 years ago
|
/* load FEC microcode */
|
||
|
loadtask(0, 2);
|
||
|
#endif
|
||
|
|
||
|
return (0);
|
||
|
}
|