diff options
Diffstat (limited to 'arch/arm/cpu')
50 files changed, 589 insertions, 1046 deletions
| diff --git a/arch/arm/cpu/arm1136/config.mk b/arch/arm/cpu/arm1136/config.mk index 9092d914f..797d1229f 100644 --- a/arch/arm/cpu/arm1136/config.mk +++ b/arch/arm/cpu/arm1136/config.mk @@ -31,6 +31,13 @@ PLATFORM_CPPFLAGS += -march=armv5  # =========================================================================  PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))  PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT) + +ifneq ($(CONFIG_IMX_CONFIG),) +ifdef CONFIG_SPL  ifdef CONFIG_SPL_BUILD  ALL-y	+= $(OBJTREE)/SPL  endif +else +ALL-y	+= $(obj)u-boot.imx +endif +endif diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c index 53015cb77..3b6666b79 100644 --- a/arch/arm/cpu/arm1136/omap24xx/timer.c +++ b/arch/arm/cpu/arm1136/omap24xx/timer.c @@ -31,13 +31,16 @@   */  #include <common.h> +#include <asm/io.h>  #include <asm/arch/bits.h>  #include <asm/arch/omap2420.h> +#define TIMER_CLOCK	(CONFIG_SYS_CLK_FREQ / (2 << CONFIG_SYS_PTV))  #define TIMER_LOAD_VAL 0  /* macro to read the 32 bit timer */ -#define READ_TIMER (*((volatile ulong *)(CONFIG_SYS_TIMERBASE+TCRR))) +#define READ_TIMER	readl(CONFIG_SYS_TIMERBASE+TCRR) \ +			/ (TIMER_CLOCK / CONFIG_SYS_HZ)  DECLARE_GLOBAL_DATA_PTR; @@ -99,7 +102,8 @@ ulong get_timer_masked (void)  		gd->arch.tbl += (now - gd->arch.lastinc);  	} else {  		/* we have rollover of incrementer */ -		gd->arch.tbl += (0xFFFFFFFF - gd->arch.lastinc) + now; +		gd->arch.tbl += ((0xFFFFFFFF / (TIMER_CLOCK / CONFIG_SYS_HZ)) +				 - gd->arch.lastinc) + now;  	}  	gd->arch.lastinc = now;  	return gd->arch.tbl; diff --git a/arch/arm/cpu/arm1136/start.S b/arch/arm/cpu/arm1136/start.S index eba23248d..ad24b8064 100644 --- a/arch/arm/cpu/arm1136/start.S +++ b/arch/arm/cpu/arm1136/start.S @@ -88,7 +88,11 @@ _end_vect:  .globl _TEXT_BASE  _TEXT_BASE: +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE) +	.word	CONFIG_SPL_TEXT_BASE +#else  	.word	CONFIG_SYS_TEXT_BASE +#endif  /*   * These are defined in the board-specific linker script. @@ -100,9 +104,9 @@ _TEXT_BASE:  _bss_start_ofs:  	.word __bss_start - _start -.global	_image_copy_end_ofs +.globl _image_copy_end_ofs  _image_copy_end_ofs: -	.word 	__image_copy_end - _start +	.word __image_copy_end - _start  .globl _bss_end_ofs  _bss_end_ofs: @@ -170,29 +174,24 @@ next:  /*------------------------------------------------------------------------------*/  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  	.globl	relocate_code  relocate_code: -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  	adr	r0, _start -	cmp	r0, r6 -	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy_loop */  	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -201,7 +200,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ @@ -235,8 +233,6 @@ fixnext:  	add	r2, r2, #8		/* each rel.dyn entry is 8 bytes */  	cmp	r2, r3  	blo	fixloop -	bx	lr -  #endif  relocate_done: diff --git a/arch/arm/cpu/arm1136/u-boot-spl.lds b/arch/arm/cpu/arm1136/u-boot-spl.lds index b09b4ebfa..8296e5db5 100644 --- a/arch/arm/cpu/arm1136/u-boot-spl.lds +++ b/arch/arm/cpu/arm1136/u-boot-spl.lds @@ -38,7 +38,7 @@ SECTIONS  	.text      :  	{  	__start = .; -	  arch/arm/cpu/arm1136/start.o	(.text) +	  arch/arm/cpu/arm1136/start.o	(.text*)  	  *(.text*)  	} >.sram diff --git a/arch/arm/cpu/arm1176/bcm2835/timer.c b/arch/arm/cpu/arm1176/bcm2835/timer.c index d232d7e06..2edd6711d 100644 --- a/arch/arm/cpu/arm1176/bcm2835/timer.c +++ b/arch/arm/cpu/arm1176/bcm2835/timer.c @@ -23,7 +23,7 @@ int timer_init(void)  	return 0;  } -ulong get_timer(ulong base) +ulong get_timer_us(ulong base)  {  	struct bcm2835_timer_regs *regs =  		(struct bcm2835_timer_regs *)BCM2835_TIMER_PHYSADDR; @@ -31,6 +31,14 @@ ulong get_timer(ulong base)  	return readl(®s->clo) - base;  } +ulong get_timer(ulong base) +{ +	ulong us = get_timer_us(0); +	us /= (1000000 / CONFIG_SYS_HZ); +	us -= base; +	return us; +} +  unsigned long long get_ticks(void)  {  	return get_timer(0); @@ -46,10 +54,10 @@ void __udelay(unsigned long usec)  	ulong endtime;  	signed long diff; -	endtime = get_timer(0) + usec; +	endtime = get_timer_us(0) + usec;  	do { -		ulong now = get_timer(0); +		ulong now = get_timer_us(0);  		diff = endtime - now;  	} while (diff >= 0);  } diff --git a/arch/arm/cpu/arm1176/s3c64xx/Makefile b/arch/arm/cpu/arm1176/s3c64xx/Makefile deleted file mode 100644 index 266a0739c..000000000 --- a/arch/arm/cpu/arm1176/s3c64xx/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# -# (C) Copyright 2000-2003 -# Wolfgang Denk, DENX Software Engineering, wd@denx.de. -# -# (C) Copyright 2008 -# Guennadi Liakhovetki, DENX Software Engineering, <lg@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 $(TOPDIR)/config.mk - -LIB	= $(obj)lib$(SOC).o - -SOBJS	= reset.o - -COBJS-$(CONFIG_S3C6400)	+= cpu_init.o speed.o -COBJS-y	+= timer.o init.o - -OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS-y)) - -all:	$(obj).depend $(START) $(LIB) - -$(LIB):	$(OBJS) -	$(call cmd_link_o_target, $(OBJS)) - -######################################################################### - -# defines $(obj).depend target -include $(SRCTREE)/rules.mk - -sinclude $(obj).depend - -######################################################################### diff --git a/arch/arm/cpu/arm1176/s3c64xx/config.mk b/arch/arm/cpu/arm1176/s3c64xx/config.mk deleted file mode 100644 index 222d352b3..000000000 --- a/arch/arm/cpu/arm1176/s3c64xx/config.mk +++ /dev/null @@ -1,34 +0,0 @@ -# -# (C) Copyright 2002 -# Gary Jennejohn, DENX Software Engineering, <garyj@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 -# -PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float - -# Make ARMv5 to allow more compilers to work, even though its v6. -PLATFORM_CPPFLAGS += -march=armv5t -# ========================================================================= -# -# Supply options according to compiler version -# -# ========================================================================= -PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,\ -			$(call cc-option,-malignment-traps,)) -PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT) diff --git a/arch/arm/cpu/arm1176/s3c64xx/cpu_init.S b/arch/arm/cpu/arm1176/s3c64xx/cpu_init.S deleted file mode 100644 index df88cba34..000000000 --- a/arch/arm/cpu/arm1176/s3c64xx/cpu_init.S +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Originates from Samsung's u-boot 1.1.6 port to S3C6400 / SMDK6400 - * - * Copyright (C) 2008 - * Guennadi Liakhovetki, DENX Software Engineering, <lg@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 <config.h> -#include <asm/arch/s3c6400.h> - -	.globl mem_ctrl_asm_init -mem_ctrl_asm_init: -	/* DMC1 base address 0x7e001000 */ -	ldr	r0, =ELFIN_DMC1_BASE - -	ldr	r1, =0x4 -	str	r1, [r0, #INDEX_DMC_MEMC_CMD] - -	ldr	r1, =DMC_DDR_REFRESH_PRD -	str	r1, [r0, #INDEX_DMC_REFRESH_PRD] - -	ldr	r1, =DMC_DDR_CAS_LATENCY -	str	r1, [r0, #INDEX_DMC_CAS_LATENCY] - -	ldr	r1, =DMC_DDR_t_DQSS -	str	r1, [r0, #INDEX_DMC_T_DQSS] - -	ldr	r1, =DMC_DDR_t_MRD -	str	r1, [r0, #INDEX_DMC_T_MRD] - -	ldr	r1, =DMC_DDR_t_RAS -	str	r1, [r0, #INDEX_DMC_T_RAS] - -	ldr	r1, =DMC_DDR_t_RC -	str	r1, [r0, #INDEX_DMC_T_RC] - -	ldr	r1, =DMC_DDR_t_RCD -	ldr	r2, =DMC_DDR_schedule_RCD -	orr	r1, r1, r2 -	str	r1, [r0, #INDEX_DMC_T_RCD] - -	ldr	r1, =DMC_DDR_t_RFC -	ldr	r2, =DMC_DDR_schedule_RFC -	orr	r1, r1, r2 -	str	r1, [r0, #INDEX_DMC_T_RFC] - -	ldr	r1, =DMC_DDR_t_RP -	ldr	r2, =DMC_DDR_schedule_RP -	orr	r1, r1, r2 -	str	r1, [r0, #INDEX_DMC_T_RP] - -	ldr	r1, =DMC_DDR_t_RRD -	str	r1, [r0, #INDEX_DMC_T_RRD] - -	ldr	r1, =DMC_DDR_t_WR -	str	r1, [r0, #INDEX_DMC_T_WR] - -	ldr	r1, =DMC_DDR_t_WTR -	str	r1, [r0, #INDEX_DMC_T_WTR] - -	ldr	r1, =DMC_DDR_t_XP -	str	r1, [r0, #INDEX_DMC_T_XP] - -	ldr	r1, =DMC_DDR_t_XSR -	str	r1, [r0, #INDEX_DMC_T_XSR] - -	ldr	r1, =DMC_DDR_t_ESR -	str	r1, [r0, #INDEX_DMC_T_ESR] - -	ldr	r1, =DMC1_MEM_CFG -	str	r1, [r0, #INDEX_DMC_MEMORY_CFG] - -	ldr	r1, =DMC1_MEM_CFG2 -	str	r1, [r0, #INDEX_DMC_MEMORY_CFG2] - -	ldr	r1, =DMC1_CHIP0_CFG -	str	r1, [r0, #INDEX_DMC_CHIP_0_CFG] - -	ldr	r1, =DMC_DDR_32_CFG -	str	r1, [r0, #INDEX_DMC_USER_CONFIG] - -	/* DMC0 DDR Chip 0 configuration direct command reg */ -	ldr	r1, =DMC_NOP0 -	str	r1, [r0, #INDEX_DMC_DIRECT_CMD] - -	/* Precharge All */ -	ldr	r1, =DMC_PA0 -	str	r1, [r0, #INDEX_DMC_DIRECT_CMD] - -	/* Auto Refresh 2 time */ -	ldr	r1, =DMC_AR0 -	str	r1, [r0, #INDEX_DMC_DIRECT_CMD] -	str	r1, [r0, #INDEX_DMC_DIRECT_CMD] - -	/* MRS */ -	ldr	r1, =DMC_mDDR_EMR0 -	str	r1, [r0, #INDEX_DMC_DIRECT_CMD] - -	/* Mode Reg */ -	ldr	r1, =DMC_mDDR_MR0 -	str	r1, [r0, #INDEX_DMC_DIRECT_CMD] - -	/* Enable DMC1 */ -	mov	r1, #0x0 -	str	r1, [r0, #INDEX_DMC_MEMC_CMD] - -check_dmc1_ready: -	ldr	r1, [r0, #INDEX_DMC_MEMC_STATUS] -	mov	r2, #0x3 -	and	r1, r1, r2 -	cmp	r1, #0x1 -	bne	check_dmc1_ready -	nop - -	mov	pc, lr - -	.ltorg diff --git a/arch/arm/cpu/arm1176/s3c64xx/init.c b/arch/arm/cpu/arm1176/s3c64xx/init.c deleted file mode 100644 index f113d8ed4..000000000 --- a/arch/arm/cpu/arm1176/s3c64xx/init.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * (C) Copyright 2012 Ashok Kumar Reddy Kourla - * ashokkourla2000@gmail.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. - */ - -#include<common.h> - -int arch_cpu_init(void) -{ -	icache_enable(); - -	return 0; -} diff --git a/arch/arm/cpu/arm1176/s3c64xx/reset.S b/arch/arm/cpu/arm1176/s3c64xx/reset.S deleted file mode 100644 index eae572e4f..000000000 --- a/arch/arm/cpu/arm1176/s3c64xx/reset.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2009 Samsung Electronics. - * Minkyu Kang <mk7.kang@samsung.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 <asm/arch/s3c6400.h> - -.globl reset_cpu -reset_cpu: -	ldr	r1, =ELFIN_CLOCK_POWER_BASE -	ldr	r2, [r1, #SYS_ID_OFFSET] -	ldr	r3, =0xffff -	and	r2, r3, r2, lsr #12 -	str	r2, [r1, #SW_RST_OFFSET] -_loop_forever: -	b	_loop_forever diff --git a/arch/arm/cpu/arm1176/s3c64xx/speed.c b/arch/arm/cpu/arm1176/s3c64xx/speed.c deleted file mode 100644 index 11962acad..000000000 --- a/arch/arm/cpu/arm1176/s3c64xx/speed.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * (C) Copyright 2001-2004 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * (C) Copyright 2002 - * David Mueller, ELSOFT AG, d.mueller@elsoft.ch - * - * 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 - */ - -/* - * This code should work for both the S3C2400 and the S3C2410 - * as they seem to have the same PLL and clock machinery inside. - * The different address mapping is handled by the s3c24xx.h files below. - */ - -#include <common.h> -#include <asm/arch/s3c6400.h> - -#define APLL 0 -#define MPLL 1 -#define EPLL 2 - -/* ------------------------------------------------------------------------- */ -/* - * NOTE: This describes the proper use of this file. - * - * CONFIG_SYS_CLK_FREQ should be defined as the input frequency of the PLL. - * - * get_FCLK(), get_HCLK(), get_PCLK() and get_UCLK() return the clock of - * the specified bus in HZ. - */ -/* ------------------------------------------------------------------------- */ - -static ulong get_PLLCLK(int pllreg) -{ -	ulong r, m, p, s; - -	switch (pllreg) { -	case APLL: -		r = APLL_CON_REG; -		break; -	case MPLL: -		r = MPLL_CON_REG; -		break; -	case EPLL: -		r = EPLL_CON0_REG; -		break; -	default: -		hang(); -	} - -	m = (r >> 16) & 0x3ff; -	p = (r >> 8) & 0x3f; -	s = r & 0x7; - -	return m * (CONFIG_SYS_CLK_FREQ / (p * (1 << s))); -} - -/* return ARMCORE frequency */ -ulong get_ARMCLK(void) -{ -	ulong div; - -	div = CLK_DIV0_REG; - -	return get_PLLCLK(APLL) / ((div & 0x7) + 1); -} - -/* return FCLK frequency */ -ulong get_FCLK(void) -{ -	return get_PLLCLK(APLL); -} - -/* return HCLK frequency */ -ulong get_HCLK(void) -{ -	ulong fclk; - -	uint hclkx2_div = ((CLK_DIV0_REG >> 9) & 0x7) + 1; -	uint hclk_div = ((CLK_DIV0_REG >> 8) & 0x1) + 1; - -	/* -	 * Bit 7 exists on s3c6410, and not on s3c6400, it is reserved on -	 * s3c6400 and is always 0, and it is indeed running in ASYNC mode -	 */ -	if (OTHERS_REG & 0x80) -		fclk = get_FCLK();		/* SYNC Mode	*/ -	else -		fclk = get_PLLCLK(MPLL);	/* ASYNC Mode	*/ - -	return fclk / (hclk_div * hclkx2_div); -} - -/* return PCLK frequency */ -ulong get_PCLK(void) -{ -	ulong fclk; -	uint hclkx2_div = ((CLK_DIV0_REG >> 9) & 0x7) + 1; -	uint pre_div = ((CLK_DIV0_REG >> 12) & 0xf) + 1; - -	if (OTHERS_REG & 0x80) -		fclk = get_FCLK();		/* SYNC Mode	*/ -	else -		fclk = get_PLLCLK(MPLL);	/* ASYNC Mode	*/ - -	return fclk / (hclkx2_div * pre_div); -} - -/* return UCLK frequency */ -ulong get_UCLK(void) -{ -	return get_PLLCLK(EPLL); -} - -int print_cpuinfo(void) -{ -	printf("\nCPU:     S3C6400@%luMHz\n", get_ARMCLK() / 1000000); -	printf("         Fclk = %luMHz, Hclk = %luMHz, Pclk = %luMHz ", -	       get_FCLK() / 1000000, get_HCLK() / 1000000, -	       get_PCLK() / 1000000); - -	if (OTHERS_REG & 0x80) -		printf("(SYNC Mode) \n"); -	else -		printf("(ASYNC Mode) \n"); -	return 0; -} diff --git a/arch/arm/cpu/arm1176/s3c64xx/timer.c b/arch/arm/cpu/arm1176/s3c64xx/timer.c deleted file mode 100644 index f16a37b53..000000000 --- a/arch/arm/cpu/arm1176/s3c64xx/timer.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * (C) Copyright 2003 - * Texas Instruments <www.ti.com> - * - * (C) Copyright 2002 - * Sysgo Real-Time Solutions, GmbH <www.elinos.com> - * Marius Groeger <mgroeger@sysgo.de> - * - * (C) Copyright 2002 - * Sysgo Real-Time Solutions, GmbH <www.elinos.com> - * Alex Zuepke <azu@sysgo.de> - * - * (C) Copyright 2002-2004 - * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> - * - * (C) Copyright 2004 - * Philippe Robin, ARM Ltd. <philippe.robin@arm.com> - * - * (C) Copyright 2008 - * Guennadi Liakhovetki, DENX Software Engineering, <lg@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 <asm/proc-armv/ptrace.h> -#include <asm/arch/s3c6400.h> -#include <div64.h> - -static ulong timer_load_val; - -#define PRESCALER	167 - -static s3c64xx_timers *s3c64xx_get_base_timers(void) -{ -	return (s3c64xx_timers *)ELFIN_TIMER_BASE; -} - -/* macro to read the 16 bit timer */ -static inline ulong read_timer(void) -{ -	s3c64xx_timers *const timers = s3c64xx_get_base_timers(); - -	return timers->TCNTO4; -} - -/* Internal tick units */ -/* Last decremneter snapshot */ -static unsigned long lastdec; -/* Monotonic incrementing timer */ -static unsigned long long timestamp; - -int timer_init(void) -{ -	s3c64xx_timers *const timers = s3c64xx_get_base_timers(); - -	/* use PWM Timer 4 because it has no output */ -	/* -	 * We use the following scheme for the timer: -	 * Prescaler is hard fixed at 167, divider at 1/4. -	 * This gives at PCLK frequency 66MHz approx. 10us ticks -	 * The timer is set to wrap after 100s, at 66MHz this obviously -	 * happens after 10,000,000 ticks. A long variable can thus -	 * keep values up to 40,000s, i.e., 11 hours. This should be -	 * enough for most uses:-) Possible optimizations: select a -	 * binary-friendly frequency, e.g., 1ms / 128. Also calculate -	 * the prescaler automatically for other PCLK frequencies. -	 */ -	timers->TCFG0 = PRESCALER << 8; -	if (timer_load_val == 0) { -		timer_load_val = get_PCLK() / PRESCALER * (100 / 4); /* 100s */ -		timers->TCFG1 = (timers->TCFG1 & ~0xf0000) | 0x20000; -	} - -	/* load value for 10 ms timeout */ -	lastdec = timers->TCNTB4 = timer_load_val; -	/* auto load, manual update of Timer 4 */ -	timers->TCON = (timers->TCON & ~0x00700000) | TCON_4_AUTO | -		TCON_4_UPDATE; - -	/* auto load, start Timer 4 */ -	timers->TCON = (timers->TCON & ~0x00700000) | TCON_4_AUTO | COUNT_4_ON; -	timestamp = 0; - -	return 0; -} - -/* - * timer without interrupts - */ - -/* - * This function is derived from PowerPC code (read timebase as long long). - * On ARM it just returns the timer value. - */ -unsigned long long get_ticks(void) -{ -	ulong now = read_timer(); - -	if (lastdec >= now) { -		/* normal mode */ -		timestamp += lastdec - now; -	} else { -		/* we have an overflow ... */ -		timestamp += lastdec + timer_load_val - now; -	} -	lastdec = now; - -	return timestamp; -} - -/* - * This function is derived from PowerPC code (timebase clock frequency). - * On ARM it returns the number of timer ticks per second. - */ -ulong get_tbclk(void) -{ -	/* We overrun in 100s */ -	return (ulong)(timer_load_val / 100); -} - -ulong get_timer_masked(void) -{ -	unsigned long long res = get_ticks(); -	do_div (res, (timer_load_val / (100 * CONFIG_SYS_HZ))); -	return res; -} - -ulong get_timer(ulong base) -{ -	return get_timer_masked() - base; -} - -void __udelay(unsigned long usec) -{ -	unsigned long long tmp; -	ulong tmo; - -	tmo = (usec + 9) / 10; -	tmp = get_ticks() + tmo;	/* get current timestamp */ - -	while (get_ticks() < tmp)/* loop till event */ -		 /*NOP*/; -} diff --git a/arch/arm/cpu/arm1176/start.S b/arch/arm/cpu/arm1176/start.S index 3c291fbe4..1fc1da071 100644 --- a/arch/arm/cpu/arm1176/start.S +++ b/arch/arm/cpu/arm1176/start.S @@ -33,11 +33,8 @@  #include <asm-offsets.h>  #include <config.h>  #include <version.h> -#ifdef CONFIG_ENABLE_MMU -#include <asm/proc/domain.h> -#endif -#if !defined(CONFIG_ENABLE_MMU) && !defined(CONFIG_SYS_PHY_UBOOT_BASE) +#ifndef CONFIG_SYS_PHY_UBOOT_BASE  #define CONFIG_SYS_PHY_UBOOT_BASE	CONFIG_SYS_UBOOT_BASE  #endif @@ -51,7 +48,7 @@  .globl _start  _start: b	reset -#ifndef CONFIG_NAND_SPL +#ifndef CONFIG_SPL_BUILD  	ldr	pc, _undefined_instruction  	ldr	pc, _software_interrupt  	ldr	pc, _prefetch_abort @@ -98,15 +95,11 @@ _end_vect:  .globl _TEXT_BASE  _TEXT_BASE: +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE) +	.word	CONFIG_SPL_TEXT_BASE +#else  	.word	CONFIG_SYS_TEXT_BASE - -/* - * Below variable is very important because we use MMU in U-Boot. - * Without it, we cannot run code correctly before MMU is ON. - * by scsuh. - */ -_TEXT_PHY_BASE: -	.word	CONFIG_SYS_PHY_UBOOT_BASE +#endif  /*   * These are defined in the board-specific linker script. @@ -119,6 +112,10 @@ _TEXT_PHY_BASE:  _bss_start_ofs:  	.word __bss_start - _start +.globl _image_copy_end_ofs +_image_copy_end_ofs: +	.word __image_copy_end - _start +  .globl _bss_end_ofs  _bss_end_ofs:  	.word __bss_end - _start @@ -164,7 +161,7 @@ cpu_init_crit:  	 * When booting from NAND - it has definitely been a reset, so, no need  	 * to flush caches and disable the MMU  	 */ -#ifndef CONFIG_NAND_SPL +#ifndef CONFIG_SPL_BUILD  	/*  	 * flush v4 I/D caches  	 */ @@ -229,29 +226,24 @@ skip_tcmdisable:  /*------------------------------------------------------------------------------*/  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  	.globl	relocate_code  relocate_code: -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  	adr	r0, _start -	cmp	r0, r6 -	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy_loop */ -	ldr	r3, _bss_start_ofs +	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -260,7 +252,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ @@ -296,44 +287,6 @@ fixnext:  	blo	fixloop  #endif -#ifdef CONFIG_ENABLE_MMU -enable_mmu: -	/* enable domain access */ -	ldr	r5, =0x0000ffff -	mcr	p15, 0, r5, c3, c0, 0	/* load domain access register */ - -	/* Set the TTB register */ -	ldr	r0, _mmu_table_base -	ldr	r1, =CONFIG_SYS_PHY_UBOOT_BASE -	ldr	r2, =0xfff00000 -	bic	r0, r0, r2 -	orr	r1, r0, r1 -	mcr	p15, 0, r1, c2, c0, 0 - -	/* Enable the MMU */ -	mrc	p15, 0, r0, c1, c0, 0 -	orr	r0, r0, #1		/* Set CR_M to enable MMU */ - -	/* Prepare to enable the MMU */ -	adr	r1, skip_hw_init -	and	r1, r1, #0x3fc -	ldr	r2, _TEXT_BASE -	ldr	r3, =0xfff00000 -	and	r2, r2, r3 -	orr	r2, r2, r1 -	b	mmu_enable - -	.align 5 -	/* Run in a single cache-line */ -mmu_enable: - -	mcr	p15, 0, r0, c1, c0, 0 -	nop -	nop -	mov	pc, r2 -skip_hw_init: -#endif -  relocate_done:  	bx	lr @@ -345,52 +298,12 @@ _rel_dyn_end_ofs:  _dynsym_start_ofs:  	.word __dynsym_start - _start -#ifdef CONFIG_ENABLE_MMU -_mmu_table_base: -	.word mmu_table -#endif -  	.globl	c_runtime_cpu_setup  c_runtime_cpu_setup:  	mov	pc, lr -#ifndef CONFIG_NAND_SPL -/* - * we assume that cache operation is done before. (eg. cleanup_before_linux()) - * actually, we don't need to do anything about cache if not use d-cache in - * U-Boot. So, in this function we clean only MMU. by scsuh - * - * void	theLastJump(void *kernel, int arch_num, uint boot_params); - */ -#ifdef CONFIG_ENABLE_MMU -	.globl theLastJump -theLastJump: -	mov	r9, r0 -	ldr	r3, =0xfff00000 -	ldr	r4, _TEXT_PHY_BASE -	adr	r5, phy_last_jump -	bic	r5, r5, r3 -	orr	r5, r5, r4 -	mov	pc, r5 -phy_last_jump: -	/* -	 * disable MMU stuff -	 */ -	mrc	p15, 0, r0, c1, c0, 0 -	bic	r0, r0, #0x00002300	/* clear bits 13, 9:8 (--V- --RS) */ -	bic	r0, r0, #0x00000087	/* clear bits 7, 2:0 (B--- -CAM) */ -	orr	r0, r0, #0x00000002	/* set bit 2 (A) Align */ -	orr	r0, r0, #0x00001000	/* set bit 12 (I) I-Cache */ -	mcr	p15, 0, r0, c1, c0, 0 - -	mcr	p15, 0, r0, c8, c7, 0	/* flush v4 TLB */ - -	mov	r0, #0 -	mov	pc, r9 -#endif - - +#ifndef CONFIG_SPL_BUILD  /*   *************************************************************************   * @@ -533,4 +446,4 @@ fiq:  	get_bad_stack  	bad_save_user_regs  	bl	do_fiq -#endif /* CONFIG_NAND_SPL */ +#endif /* CONFIG_SPL_BUILD */ diff --git a/arch/arm/cpu/arm720t/start.S b/arch/arm/cpu/arm720t/start.S index 43bd6edd2..9facc7e69 100644 --- a/arch/arm/cpu/arm720t/start.S +++ b/arch/arm/cpu/arm720t/start.S @@ -85,7 +85,7 @@ _pad:			.word 0x12345678 /* now 16*4=64 */  .globl _TEXT_BASE  _TEXT_BASE: -#ifdef CONFIG_SPL_BUILD +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)  	.word	CONFIG_SPL_TEXT_BASE  #else  	.word	CONFIG_SYS_TEXT_BASE @@ -101,6 +101,10 @@ _TEXT_BASE:  _bss_start_ofs:  	.word __bss_start - _start +.globl _image_copy_end_ofs +_image_copy_end_ofs: +	.word __image_copy_end - _start +  .globl _bss_end_ofs  _bss_end_ofs:  	.word __bss_end - _start @@ -152,29 +156,24 @@ reset:  /*------------------------------------------------------------------------------*/  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  	.globl	relocate_code  relocate_code: -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  	adr	r0, _start -	cmp	r0, r6 -	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy_loop */ -	ldr	r3, _bss_start_ofs +	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -183,7 +182,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ diff --git a/arch/arm/cpu/arm920t/ep93xx/u-boot.lds b/arch/arm/cpu/arm920t/ep93xx/u-boot.lds index e483820f3..cf55bf7d4 100644 --- a/arch/arm/cpu/arm920t/ep93xx/u-boot.lds +++ b/arch/arm/cpu/arm920t/ep93xx/u-boot.lds @@ -31,18 +31,18 @@ SECTIONS  	. = ALIGN(4);  	.text      :  	{ -	  arch/arm/cpu/arm920t/start.o	(.text) +	  arch/arm/cpu/arm920t/start.o	(.text*)  		/* the EP93xx expects to find the pattern 'CRUS' at 0x1000 */  	  . = 0x1000;  	  LONG(0x53555243) -	  *(.text) +	  *(.text*)  	}  	. = ALIGN(4); -	.rodata : { *(.rodata) } +	.rodata : { *(.rodata*) }  	. = ALIGN(4); -	.data : { *(.data) } +	.data : { *(.data*) }  	. = ALIGN(4);  	.got : { *(.got) } @@ -55,8 +55,11 @@ SECTIONS  	}  	. = ALIGN(4); + +	__image_copy_end = .; +  	__bss_start = .; -	.bss : { *(.bss) } +	.bss : { *(.bss*) }  	__bss_end = .;  	_end = .; diff --git a/arch/arm/cpu/arm920t/start.S b/arch/arm/cpu/arm920t/start.S index 2864d128c..62500250e 100644 --- a/arch/arm/cpu/arm920t/start.S +++ b/arch/arm/cpu/arm920t/start.S @@ -73,7 +73,11 @@ _fiq:			.word fiq  .globl _TEXT_BASE  _TEXT_BASE: +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE) +	.word	CONFIG_SPL_TEXT_BASE +#else  	.word	CONFIG_SYS_TEXT_BASE +#endif  /*   * These are defined in the board-specific linker script. @@ -85,6 +89,10 @@ _TEXT_BASE:  _bss_start_ofs:  	.word __bss_start - _start +.globl _image_copy_end_ofs +_image_copy_end_ofs: +	.word __image_copy_end - _start +  .globl _bss_end_ofs  _bss_end_ofs:  	.word __bss_end - _start @@ -187,29 +195,24 @@ copyex:  /*------------------------------------------------------------------------------*/  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  	.globl	relocate_code  relocate_code: -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  	adr	r0, _start -	cmp	r0, r6 -	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy_loop */ -	ldr	r3, _bss_start_ofs +	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -218,7 +221,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ diff --git a/arch/arm/cpu/arm925t/start.S b/arch/arm/cpu/arm925t/start.S index 827fee249..021e2418d 100644 --- a/arch/arm/cpu/arm925t/start.S +++ b/arch/arm/cpu/arm925t/start.S @@ -79,7 +79,11 @@ _fiq:			.word fiq  .globl _TEXT_BASE  _TEXT_BASE: +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE) +	.word	CONFIG_SPL_TEXT_BASE +#else  	.word	CONFIG_SYS_TEXT_BASE +#endif  /*   * These are defined in the board-specific linker script. @@ -91,6 +95,10 @@ _TEXT_BASE:  _bss_start_ofs:  	.word __bss_start - _start +.globl _image_copy_end_ofs +_image_copy_end_ofs: +	.word __image_copy_end - _start +  .globl _bss_end_ofs  _bss_end_ofs:  	.word __bss_end - _start @@ -177,29 +185,24 @@ poll1:  /*------------------------------------------------------------------------------*/  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  	.globl	relocate_code  relocate_code: -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  	adr	r0, _start -	cmp	r0, r6 -	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy_loop */ -	ldr	r3, _bss_start_ofs +	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -208,7 +211,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ diff --git a/arch/arm/cpu/arm926ejs/config.mk b/arch/arm/cpu/arm926ejs/config.mk index 6a3a1bb35..f0e31d180 100644 --- a/arch/arm/cpu/arm926ejs/config.mk +++ b/arch/arm/cpu/arm926ejs/config.mk @@ -33,7 +33,11 @@ PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-mali  PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT)  ifneq ($(CONFIG_IMX_CONFIG),) - +ifdef CONFIG_SPL +ifdef CONFIG_SPL_BUILD +ALL-y	+= $(OBJTREE)/SPL +endif +else  ALL-y	+= $(obj)u-boot.imx - +endif  endif diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c b/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c index fdac73cfa..bc2d69c85 100644 --- a/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +++ b/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c @@ -46,17 +46,17 @@ static uint32_t dram_vals[] = {  	0x00000000, 0x00000000, 0x00010101, 0x01010101,  	0x000f0f01, 0x0f02020a, 0x00000000, 0x00010101,  	0x00000100, 0x00000100, 0x00000000, 0x00000002, -	0x01010000, 0x05060302, 0x06005003, 0x0a0000c8, -	0x02009c40, 0x0000030c, 0x0036a609, 0x031a0612, +	0x01010000, 0x07080403, 0x06005003, 0x0a0000c8, +	0x02009c40, 0x0002030c, 0x0036a609, 0x031a0612,  	0x02030202, 0x00c8001c, 0x00000000, 0x00000000,  	0x00012100, 0xffff0303, 0x00012100, 0xffff0303,  	0x00012100, 0xffff0303, 0x00012100, 0xffff0303,  	0x00000003, 0x00000000, 0x00000000, 0x00000000,  	0x00000000, 0x00000000, 0x00000000, 0x00000000,  	0x00000000, 0x00000000, 0x00000612, 0x01000F02, -	0x06120612, 0x00000200, 0x00020007, 0xf5014b27, -	0xf5014b27, 0xf5014b27, 0xf5014b27, 0x07000300, -	0x07000300, 0x07000300, 0x07000300, 0x00000006, +	0x06120612, 0x00000200, 0x00020007, 0xf4004a27, +	0xf4004a27, 0xf4004a27, 0xf4004a27, 0x07000300, +	0x07000300, 0x07400300, 0x07400300, 0x00000005,  	0x00000000, 0x00000000, 0x01000000, 0x01020408,  	0x08040201, 0x000f1133, 0x00000000, 0x00001f04,  	0x00001f04, 0x00001f04, 0x00001f04, 0x00001f04, @@ -77,14 +77,14 @@ static uint32_t dram_vals[] = {  	0x00000000, 0x00000000, 0x00000000, 0x00000000,  	0x00000000, 0x00000000, 0x00000000, 0x00000000,  	0x00000000, 0x00000000, 0x00000000, 0x00000000, -	0x00000000, 0x00000000, 0x00010000, 0x00020304, -	0x00000004, 0x00000000, 0x00000000, 0x00000000, +	0x00000000, 0x00000000, 0x00010000, 0x00030404, +	0x00000003, 0x00000000, 0x00000000, 0x00000000,  	0x00000000, 0x00000000, 0x00000000, 0x01010000,  	0x01000000, 0x03030000, 0x00010303, 0x01020202,  	0x00000000, 0x02040303, 0x21002103, 0x00061200, -	0x06120612, 0x04320432, 0x04320432, 0x00040004, +	0x06120612, 0x04420442, 0x04420442, 0x00040004,  	0x00040004, 0x00000000, 0x00000000, 0x00000000, -	0x00000000, 0x00010001 +	0x00000000, 0xffffffff  /*   * i.MX23 DDR at 133MHz diff --git a/arch/arm/cpu/arm926ejs/mxs/start.S b/arch/arm/cpu/arm926ejs/mxs/start.S index 373e6d8d7..bf54423ce 100644 --- a/arch/arm/cpu/arm926ejs/mxs/start.S +++ b/arch/arm/cpu/arm926ejs/mxs/start.S @@ -119,7 +119,11 @@ fiq:  .globl _TEXT_BASE  _TEXT_BASE: +#ifdef CONFIG_SPL_TEXT_BASE +	.word	CONFIG_SPL_TEXT_BASE +#else  	.word	CONFIG_SYS_TEXT_BASE +#endif  /*   * These are defined in the board-specific linker script. diff --git a/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds b/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds index 67b204e44..673c725ab 100644 --- a/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds +++ b/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds @@ -37,8 +37,8 @@ SECTIONS  	. = ALIGN(4);  	.text	:  	{ -		arch/arm/cpu/arm926ejs/mxs/start.o	(.text) -		*(.text) +		arch/arm/cpu/arm926ejs/mxs/start.o	(.text*) +		*(.text*)  	}  	. = ALIGN(4); @@ -46,7 +46,7 @@ SECTIONS  	. = ALIGN(4);  	.data : { -		*(.data) +		*(.data*)  	}  	. = ALIGN(4); diff --git a/arch/arm/cpu/arm926ejs/omap/timer.c b/arch/arm/cpu/arm926ejs/omap/timer.c index 34ec7b2b1..16530b03b 100644 --- a/arch/arm/cpu/arm926ejs/omap/timer.c +++ b/arch/arm/cpu/arm926ejs/omap/timer.c @@ -36,11 +36,14 @@   */  #include <common.h> +#include <asm/io.h> -#define TIMER_LOAD_VAL 0xffffffff +#define TIMER_CLOCK	(CONFIG_SYS_CLK_FREQ / (2 << CONFIG_SYS_PTV)) +#define TIMER_LOAD_VAL	0xffffffff  /* macro to read the 32 bit timer */ -#define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+8)) +#define READ_TIMER	readl(CONFIG_SYS_TIMERBASE+8) \ +			/ (TIMER_CLOCK / CONFIG_SYS_HZ)  DECLARE_GLOBAL_DATA_PTR; @@ -114,7 +117,8 @@ ulong get_timer_masked (void)  		 * (TLV-now) amount of time after passing though -1  		 * nts = new "advancing time stamp"...it could also roll and cause problems.  		 */ -		timestamp += lastdec + TIMER_LOAD_VAL - now; +		timestamp += lastdec + (TIMER_LOAD_VAL / (TIMER_CLOCK / +					CONFIG_SYS_HZ)) - now;  	}  	lastdec = now; @@ -160,8 +164,5 @@ unsigned long long get_ticks(void)   */  ulong get_tbclk (void)  { -	ulong tbclk; - -	tbclk = CONFIG_SYS_HZ; -	return tbclk; +	return CONFIG_SYS_HZ;  } diff --git a/arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds b/arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds index 740591759..967a135b3 100644 --- a/arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds +++ b/arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds @@ -37,8 +37,8 @@ SECTIONS  	. = ALIGN(4);  	.text	:  	{ -		arch/arm/cpu/arm926ejs/spear/start.o	(.text) -		*(.text) +		arch/arm/cpu/arm926ejs/spear/start.o	(.text*) +		*(.text*)  	}  	. = ALIGN(4); @@ -46,7 +46,7 @@ SECTIONS  	. = ALIGN(4);  	.data : { -		*(.data) +		*(.data*)  	}  	. = ALIGN(4); diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S index f5d15828d..4c5671109 100644 --- a/arch/arm/cpu/arm926ejs/start.S +++ b/arch/arm/cpu/arm926ejs/start.S @@ -120,15 +120,11 @@ _fiq:  .globl _TEXT_BASE  _TEXT_BASE: -#ifdef CONFIG_NAND_SPL /* deprecated, use instead CONFIG_SPL_BUILD */ -	.word	CONFIG_SYS_TEXT_BASE -#else -#ifdef CONFIG_SPL_BUILD +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)  	.word	CONFIG_SPL_TEXT_BASE  #else  	.word	CONFIG_SYS_TEXT_BASE  #endif -#endif  /*   * These are defined in the board-specific linker script. @@ -140,6 +136,10 @@ _TEXT_BASE:  _bss_start_ofs:  	.word __bss_start - _start +.globl _image_copy_end_ofs +_image_copy_end_ofs: +	.word __image_copy_end - _start +  .globl _bss_end_ofs  _bss_end_ofs:  	.word __bss_end - _start @@ -148,12 +148,6 @@ _bss_end_ofs:  _end_ofs:  	.word _end - _start -#ifdef CONFIG_NAND_U_BOOT -.globl _end -_end: -	.word __bss_end -#endif -  #ifdef CONFIG_USE_IRQ  /* IRQ stack memory (calculated at run-time) */  .globl IRQ_STACK_START @@ -196,32 +190,25 @@ reset:  /*------------------------------------------------------------------------------*/ -#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_NAND_SPL)  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  	.globl	relocate_code  relocate_code: -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  	adr	r0, _start -	sub	r9, r6, r0		/* r9 <- relocation offset */ -	cmp	r0, r6 -	moveq	r9, #0			/* no relocation. offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy loop */ -	ldr	r3, _bss_start_ofs +	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -230,7 +217,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ @@ -270,6 +256,8 @@ relocate_done:  	bx	lr +#ifndef CONFIG_SPL_BUILD +  _rel_dyn_start_ofs:  	.word __rel_dyn_start - _start  _rel_dyn_end_ofs: diff --git a/arch/arm/cpu/arm946es/start.S b/arch/arm/cpu/arm946es/start.S index 9dec35b55..9c2b70db0 100644 --- a/arch/arm/cpu/arm946es/start.S +++ b/arch/arm/cpu/arm946es/start.S @@ -89,7 +89,11 @@ _vectors_end:  .globl _TEXT_BASE  _TEXT_BASE: +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE) +	.word	CONFIG_SPL_TEXT_BASE +#else  	.word	CONFIG_SYS_TEXT_BASE +#endif  /*   * These are defined in the board-specific linker script. @@ -101,6 +105,10 @@ _TEXT_BASE:  _bss_start_ofs:  	.word __bss_start - _start +.globl _image_copy_end_ofs +_image_copy_end_ofs: +	.word __image_copy_end - _start +  .globl _bss_end_ofs  _bss_end_ofs:  	.word __bss_end - _start @@ -152,29 +160,24 @@ reset:  /*------------------------------------------------------------------------------*/  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  	.globl	relocate_code  relocate_code: -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  	adr	r0, _start -	cmp	r0, r6 -	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy_loop */ -	ldr	r3, _bss_start_ofs +	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -183,7 +186,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ diff --git a/arch/arm/cpu/arm_intcm/start.S b/arch/arm/cpu/arm_intcm/start.S index 04d08458f..5e8c5289f 100644 --- a/arch/arm/cpu/arm_intcm/start.S +++ b/arch/arm/cpu/arm_intcm/start.S @@ -85,7 +85,11 @@ _fiq:  .globl _TEXT_BASE  _TEXT_BASE: -	.word	CONFIG_SYS_TEXT_BASE /* address of _start in the linked image */ +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE) +	.word	CONFIG_SPL_TEXT_BASE +#else +	.word	CONFIG_SYS_TEXT_BASE +#endif  /*   * These are defined in the board-specific linker script. @@ -97,6 +101,10 @@ _TEXT_BASE:  _bss_start_ofs:  	.word __bss_start - _start +.globl _image_copy_end_ofs +_image_copy_end_ofs: +	.word __image_copy_end - _start +  .globl _bss_end_ofs  _bss_end_ofs:  	.word __bss_end - _start @@ -148,29 +156,24 @@ reset:  /*------------------------------------------------------------------------------*/  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  	.globl	relocate_code  relocate_code: -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  	adr	r0, _start -	cmp	r0, r6 -	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy_loop */ -	ldr	r3, _bss_start_ofs +	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -179,7 +182,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ diff --git a/arch/arm/cpu/armv7/am33xx/clock_am33xx.c b/arch/arm/cpu/armv7/am33xx/clock_am33xx.c index afc0d9205..a1efc7520 100644 --- a/arch/arm/cpu/armv7/am33xx/clock_am33xx.c +++ b/arch/arm/cpu/armv7/am33xx/clock_am33xx.c @@ -195,6 +195,11 @@ static void enable_per_clocks(void)  	while (readl(&cmper->mmc0clkctrl) != PRCM_MOD_EN)  		; +	/* MMC1 */ +	writel(PRCM_MOD_EN, &cmper->mmc1clkctrl); +	while (readl(&cmper->mmc1clkctrl) != PRCM_MOD_EN) +		; +  	/* i2c0 */  	writel(PRCM_MOD_EN, &cmwkup->wkup_i2c0ctrl);  	while (readl(&cmwkup->wkup_i2c0ctrl) != PRCM_MOD_EN) diff --git a/arch/arm/cpu/armv7/am33xx/elm.c b/arch/arm/cpu/armv7/am33xx/elm.c index 9eed23d75..41df61295 100644 --- a/arch/arm/cpu/armv7/am33xx/elm.c +++ b/arch/arm/cpu/armv7/am33xx/elm.c @@ -33,7 +33,7 @@  #include <asm/io.h>  #include <asm/errno.h>  #include <asm/arch/cpu.h> -#include <asm/arch/omap_gpmc.h> +#include <asm/omap_gpmc.h>  #include <asm/arch/elm.h>  #define ELM_DEFAULT_POLY (0) diff --git a/arch/arm/cpu/armv7/config.mk b/arch/arm/cpu/armv7/config.mk index 9c3e2f3ce..56b805377 100644 --- a/arch/arm/cpu/armv7/config.mk +++ b/arch/arm/cpu/armv7/config.mk @@ -40,5 +40,11 @@ PF_NO_UNALIGNED := $(call cc-option, -mno-unaligned-access,)  PLATFORM_NO_UNALIGNED := $(PF_NO_UNALIGNED)  ifneq ($(CONFIG_IMX_CONFIG),) +ifdef CONFIG_SPL +ifdef CONFIG_SPL_BUILD +ALL-y	+= $(OBJTREE)/SPL +endif +else  ALL-y	+= $(obj)u-boot.imx  endif +endif diff --git a/arch/arm/cpu/armv7/exynos/clock.c b/arch/arm/cpu/armv7/exynos/clock.c index 956427c9e..223660aab 100644 --- a/arch/arm/cpu/armv7/exynos/clock.c +++ b/arch/arm/cpu/armv7/exynos/clock.c @@ -27,6 +27,49 @@  #include <asm/arch/clk.h>  #include <asm/arch/periph.h> +/* * + * This structure is to store the src bit, div bit and prediv bit + * positions of the peripheral clocks of the src and div registers + */ +struct clk_bit_info { +	int8_t src_bit; +	int8_t div_bit; +	int8_t prediv_bit; +}; + +/* src_bit div_bit prediv_bit */ +static struct clk_bit_info clk_bit_info[PERIPH_ID_COUNT] = { +	{0,	0,	-1}, +	{4,	4,	-1}, +	{8,	8,	-1}, +	{12,	12,	-1}, +	{0,	0,	8}, +	{4,	16,	24}, +	{8,	0,	8}, +	{12,	16,	24}, +	{-1,	-1,	-1}, +	{16,	0,	8}, +	{20,	16,	24}, +	{24,	0,	8}, +	{0,	0,	4}, +	{4,	12,	16}, +	{-1,	-1,	-1}, +	{-1,	-1,	-1}, +	{-1,	24,	0}, +	{-1,	24,	0}, +	{-1,	24,	0}, +	{-1,	24,	0}, +	{-1,	24,	0}, +	{-1,	24,	0}, +	{-1,	24,	0}, +	{-1,	24,	0}, +	{24,	0,	-1}, +	{24,	0,	-1}, +	{24,	0,	-1}, +	{24,	0,	-1}, +	{24,	0,	-1}, +}; +  /* Epll Clock division values to achive different frequency output */  static struct set_epll_con_val exynos5_epll_div[] = {  	{ 192000000, 0, 48, 3, 1, 0 }, @@ -201,6 +244,107 @@ static unsigned long exynos5_get_pll_clk(int pllreg)  	return fout;  } +static unsigned long exynos5_get_periph_rate(int peripheral) +{ +	struct clk_bit_info *bit_info = &clk_bit_info[peripheral]; +	unsigned long sclk, sub_clk; +	unsigned int src, div, sub_div; +	struct exynos5_clock *clk = +			(struct exynos5_clock *)samsung_get_base_clock(); + +	switch (peripheral) { +	case PERIPH_ID_UART0: +	case PERIPH_ID_UART1: +	case PERIPH_ID_UART2: +	case PERIPH_ID_UART3: +		src = readl(&clk->src_peric0); +		div = readl(&clk->div_peric0); +		break; +	case PERIPH_ID_PWM0: +	case PERIPH_ID_PWM1: +	case PERIPH_ID_PWM2: +	case PERIPH_ID_PWM3: +	case PERIPH_ID_PWM4: +		src = readl(&clk->src_peric0); +		div = readl(&clk->div_peric3); +		break; +	case PERIPH_ID_SPI0: +	case PERIPH_ID_SPI1: +		src = readl(&clk->src_peric1); +		div = readl(&clk->div_peric1); +		break; +	case PERIPH_ID_SPI2: +		src = readl(&clk->src_peric1); +		div = readl(&clk->div_peric2); +		break; +	case PERIPH_ID_SPI3: +	case PERIPH_ID_SPI4: +		src = readl(&clk->sclk_src_isp); +		div = readl(&clk->sclk_div_isp); +		break; +	case PERIPH_ID_SDMMC0: +	case PERIPH_ID_SDMMC1: +	case PERIPH_ID_SDMMC2: +	case PERIPH_ID_SDMMC3: +		src = readl(&clk->src_fsys); +		div = readl(&clk->div_fsys1); +		break; +	case PERIPH_ID_I2C0: +	case PERIPH_ID_I2C1: +	case PERIPH_ID_I2C2: +	case PERIPH_ID_I2C3: +	case PERIPH_ID_I2C4: +	case PERIPH_ID_I2C5: +	case PERIPH_ID_I2C6: +	case PERIPH_ID_I2C7: +		sclk = exynos5_get_pll_clk(MPLL); +		sub_div = ((readl(&clk->div_top1) >> bit_info->div_bit) +								& 0x7) + 1; +		div = ((readl(&clk->div_top0) >> bit_info->prediv_bit) +								& 0x7) + 1; +		return (sclk / sub_div) / div; +	default: +		debug("%s: invalid peripheral %d", __func__, peripheral); +		return -1; +	}; + +	src = (src >> bit_info->src_bit) & 0xf; + +	switch (src) { +	case EXYNOS_SRC_MPLL: +		sclk = exynos5_get_pll_clk(MPLL); +		break; +	case EXYNOS_SRC_EPLL: +		sclk = exynos5_get_pll_clk(EPLL); +		break; +	case EXYNOS_SRC_VPLL: +		sclk = exynos5_get_pll_clk(VPLL); +		break; +	default: +		return 0; +	} + +	/* Ratio clock division for this peripheral */ +	sub_div = (div >> bit_info->div_bit) & 0xf; +	sub_clk = sclk / (sub_div + 1); + +	/* Pre-ratio clock division for SDMMC0 and 2 */ +	if (peripheral == PERIPH_ID_SDMMC0 || peripheral == PERIPH_ID_SDMMC2) { +		div = (div >> bit_info->prediv_bit) & 0xff; +		return sub_clk / (div + 1); +	} + +	return sub_clk; +} + +unsigned long clock_get_periph_rate(int peripheral) +{ +	if (cpu_is_exynos5()) +		return exynos5_get_periph_rate(peripheral); +	else +		return 0; +} +  /* exynos4: return ARM clock frequency */  static unsigned long exynos4_get_arm_clk(void)  { @@ -324,27 +468,6 @@ static unsigned long exynos4x12_get_pwm_clk(void)  	return pclk;  } -/* exynos5: return pwm clock frequency */ -static unsigned long exynos5_get_pwm_clk(void) -{ -	struct exynos5_clock *clk = -		(struct exynos5_clock *)samsung_get_base_clock(); -	unsigned long pclk, sclk; -	unsigned int ratio; - -	/* -	 * CLK_DIV_PERIC3 -	 * PWM_RATIO [3:0] -	 */ -	ratio = readl(&clk->div_peric3); -	ratio = ratio & 0xf; -	sclk = get_pll_clk(MPLL); - -	pclk = sclk / (ratio + 1); - -	return pclk; -} -  /* exynos4: return uart clock frequency */  static unsigned long exynos4_get_uart_clk(int dev_index)  { @@ -1210,7 +1333,7 @@ unsigned long get_i2c_clk(void)  unsigned long get_pwm_clk(void)  {  	if (cpu_is_exynos5()) -		return exynos5_get_pwm_clk(); +		return clock_get_periph_rate(PERIPH_ID_PWM0);  	else {  		if (proid_is_exynos4412())  			return exynos4x12_get_pwm_clk(); diff --git a/arch/arm/cpu/armv7/exynos/soc.c b/arch/arm/cpu/armv7/exynos/soc.c index ab65b8d3a..e948e4c63 100644 --- a/arch/arm/cpu/armv7/exynos/soc.c +++ b/arch/arm/cpu/armv7/exynos/soc.c @@ -23,6 +23,14 @@  #include <common.h>  #include <asm/io.h> +#include <asm/system.h> + +enum l2_cache_params { +	CACHE_TAG_RAM_SETUP = (1 << 9), +	CACHE_DATA_RAM_SETUP = (1 << 5), +	CACHE_TAG_RAM_LATENCY = (2 << 6), +	CACHE_DATA_RAM_LATENCY = (2 << 0) +};  void reset_cpu(ulong addr)  { @@ -36,3 +44,31 @@ void enable_caches(void)  	dcache_enable();  }  #endif + +#ifndef CONFIG_SYS_L2CACHE_OFF +/* + * Set L2 cache parameters + */ +static void exynos5_set_l2cache_params(void) +{ +	unsigned int val = 0; + +	asm volatile("mrc p15, 1, %0, c9, c0, 2\n" : "=r"(val)); + +	val |= CACHE_TAG_RAM_SETUP | +		CACHE_DATA_RAM_SETUP | +		CACHE_TAG_RAM_LATENCY | +		CACHE_DATA_RAM_LATENCY; + +	asm volatile("mcr p15, 1, %0, c9, c0, 2\n" : : "r"(val)); +} + +/* + * Sets L2 cache related parameters before enabling data cache + */ +void v7_outer_cache_enable(void) +{ +	if (cpu_is_exynos5()) +		exynos5_set_l2cache_params(); +} +#endif diff --git a/arch/arm/cpu/armv7/mx5/lowlevel_init.S b/arch/arm/cpu/armv7/mx5/lowlevel_init.S index 6d9396a97..dfce0ca83 100644 --- a/arch/arm/cpu/armv7/mx5/lowlevel_init.S +++ b/arch/arm/cpu/armv7/mx5/lowlevel_init.S @@ -309,8 +309,7 @@ setup_pll_func:          ldr r0, =CCM_BASE_ADDR          ldr r1, =0x00015154          str r1, [r0, #CLKCTL_CBCMR] -        ldr r1, =0x02888945 -        orr r1, r1, #(1 << 16) +        ldr r1, =0x02898945          str r1, [r0, #CLKCTL_CBCDR]          /* make sure change is effective */  1:      ldr r1, [r0, #CLKCTL_CDHIPR] @@ -321,10 +320,7 @@ setup_pll_func:  	/* Switch peripheral to PLL2 */  	ldr r0, =CCM_BASE_ADDR -	ldr r1, =0x00808145 -	orr r1, r1, #(2 << 10) -	orr r1, r1, #(0 << 16) -	orr r1, r1, #(1 << 19) +	ldr r1, =0x00888945  	str r1, [r0, #CLKCTL_CBCDR]  	ldr r1, =0x00016154 diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c index 193ba1240..2ea8ca3bd 100644 --- a/arch/arm/cpu/armv7/mx6/soc.c +++ b/arch/arm/cpu/armv7/mx6/soc.c @@ -61,6 +61,18 @@ u32 get_cpu_rev(void)  	return (type << 12) | (reg + 0x10);  } +#ifdef CONFIG_REVISION_TAG +u32 __weak get_board_rev(void) +{ +	u32 cpurev = get_cpu_rev(); +	u32 type = ((cpurev >> 12) & 0xff); +	if (type == MXC_CPU_MX6SOLO) +		cpurev = (MXC_CPU_MX6DL) << 12 | (cpurev & 0xFFF); + +	return cpurev; +} +#endif +  void init_aips(void)  {  	struct aipstz_regs *aips1, *aips2; diff --git a/arch/arm/cpu/armv7/omap-common/clocks-common.c b/arch/arm/cpu/armv7/omap-common/clocks-common.c index 9ed18995e..2b955c7c0 100644 --- a/arch/arm/cpu/armv7/omap-common/clocks-common.c +++ b/arch/arm/cpu/armv7/omap-common/clocks-common.c @@ -612,7 +612,7 @@ void freq_update_core(void)  	/*  	 * Putting EMIF in HW_AUTO is seen to be causing issues with -	 * EMIF clocks and the master DLL. Put EMIF in SW_WKUP +	 * EMIF clocks and the master DLL. Keep EMIF in SW_WKUP  	 * in OMAP5430 ES1.0 silicon  	 */  	if (omap_rev != OMAP5430_ES1_0) { @@ -659,7 +659,7 @@ void setup_clocks_for_console(void)  			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<  			MODULE_CLKCTRL_MODULEMODE_SHIFT); -	clrsetbits_le32((*prcm)->cm_l4per_uart3_clkctrl, +	clrsetbits_le32((*prcm)->cm_l4per_uart4_clkctrl,  			MODULE_CLKCTRL_MODULEMODE_MASK,  			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<  			MODULE_CLKCTRL_MODULEMODE_SHIFT); diff --git a/arch/arm/cpu/armv7/omap-common/emif-common.c b/arch/arm/cpu/armv7/omap-common/emif-common.c index 9eb1279d4..cdb443972 100644 --- a/arch/arm/cpu/armv7/omap-common/emif-common.c +++ b/arch/arm/cpu/armv7/omap-common/emif-common.c @@ -655,20 +655,27 @@ static u32 get_ddr_phy_ctrl_1(u32 freq, u8 RL)  	return phy;  } -static u32 get_emif_mem_size(struct emif_device_details *devices) +static u32 get_emif_mem_size(u32 base)  {  	u32 size_mbytes = 0, temp; +	struct emif_device_details dev_details; +	struct lpddr2_device_details cs0_dev_details, cs1_dev_details; +	u32 emif_nr = emif_num(base); -	if (!devices) -		return 0; +	emif_reset_phy(base); +	dev_details.cs0_device_details = emif_get_device_details(emif_nr, CS0, +						&cs0_dev_details); +	dev_details.cs1_device_details = emif_get_device_details(emif_nr, CS1, +						&cs1_dev_details); +	emif_reset_phy(base); -	if (devices->cs0_device_details) { -		temp = devices->cs0_device_details->density; +	if (dev_details.cs0_device_details) { +		temp = dev_details.cs0_device_details->density;  		size_mbytes += lpddr2_density_2_size_in_mbytes[temp];  	} -	if (devices->cs1_device_details) { -		temp = devices->cs1_device_details->density; +	if (dev_details.cs1_device_details) { +		temp = dev_details.cs1_device_details->density;  		size_mbytes += lpddr2_density_2_size_in_mbytes[temp];  	}  	/* convert to bytes */ @@ -1040,13 +1047,9 @@ static void do_sdram_init(u32 base)  	/* Return if no devices on this EMIF */  	if (!dev_details.cs0_device_details &&  	    !dev_details.cs1_device_details) { -		emif_sizes[emif_nr - 1] = 0;  		return;  	} -	if (!in_sdram) -		emif_sizes[emif_nr - 1] = get_emif_mem_size(&dev_details); -  	/*  	 * Get device timings:  	 * - Default timings specified by JESD209-2 if @@ -1108,8 +1111,8 @@ void dmm_init(u32 base)  	mapped_size = 0;  	section_cnt = 3;  	sys_addr = CONFIG_SYS_SDRAM_BASE; -	emif1_size = emif_sizes[0]; -	emif2_size = emif_sizes[1]; +	emif1_size = get_emif_mem_size(EMIF1_BASE); +	emif2_size = get_emif_mem_size(EMIF2_BASE);  	debug("emif1_size 0x%x emif2_size 0x%x\n", emif1_size, emif2_size);  	if (!emif1_size && !emif2_size) diff --git a/arch/arm/cpu/armv7/omap-common/lowlevel_init.S b/arch/arm/cpu/armv7/omap-common/lowlevel_init.S index b933fe843..90b3c8aea 100644 --- a/arch/arm/cpu/armv7/omap-common/lowlevel_init.S +++ b/arch/arm/cpu/armv7/omap-common/lowlevel_init.S @@ -60,10 +60,14 @@ ENTRY(save_boot_params)  	ldr	r3, =boot_params  	strb	r2, [r3, #BOOT_DEVICE_OFFSET]	@ spl_boot_device <- r1 -	/* boot mode is passed only for devices that can raw/fat mode */ -	cmp	r2, #BOOT_DEVICE_XIP +	/* +	 * boot mode is only valid for device that can be raw or FAT booted. +	 * in other cases it may be fatal to look.  While platforms differ +	 * in the values used for each MMC slot, they are contiguous. +	 */ +	cmp	r2, #MMC_BOOT_DEVICES_START  	blt	2f -	cmp	r2, #BOOT_DEVICE_MMC2 +	cmp	r2, #MMC_BOOT_DEVICES_END  	bgt	2f  	/* Store the boot mode (raw/FAT) in omap_bootmode */  	ldr	r2, [r0, #DEV_DESC_PTR_OFFSET]	@ get the device descriptor ptr diff --git a/arch/arm/cpu/armv7/omap-common/u-boot-spl.lds b/arch/arm/cpu/armv7/omap-common/u-boot-spl.lds index efae381bd..bd218c07d 100644 --- a/arch/arm/cpu/armv7/omap-common/u-boot-spl.lds +++ b/arch/arm/cpu/armv7/omap-common/u-boot-spl.lds @@ -38,7 +38,7 @@ SECTIONS  	.text      :  	{  		__start = .; -		arch/arm/cpu/armv7/start.o	(.text) +		arch/arm/cpu/armv7/start.o	(.text*)  		*(.text*)  	} >.sram diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index c6d9a425a..b72fadc25 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -328,14 +328,25 @@ void abort(void)   *****************************************************************************/  static int do_switch_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])  { -	if (argc != 2) +	if (argc < 2 || argc > 3)  		goto usage; -	if (strncmp(argv[1], "hw", 2) == 0) -		omap_nand_switch_ecc(1); -	else if (strncmp(argv[1], "sw", 2) == 0) -		omap_nand_switch_ecc(0); -	else + +	if (strncmp(argv[1], "hw", 2) == 0) { +		if (argc == 2) { +			omap_nand_switch_ecc(1, 1); +		} else { +			if (strncmp(argv[2], "hamming", 7) == 0) +				omap_nand_switch_ecc(1, 1); +			else if (strncmp(argv[2], "bch8", 4) == 0) +				omap_nand_switch_ecc(1, 8); +			else +				goto usage; +		} +	} else if (strncmp(argv[1], "sw", 2) == 0) { +		omap_nand_switch_ecc(0, 0); +	} else {  		goto usage; +	}  	return 0; @@ -345,9 +356,13 @@ usage:  }  U_BOOT_CMD( -	nandecc, 2, 1,	do_switch_ecc, +	nandecc, 3, 1,	do_switch_ecc,  	"switch OMAP3 NAND ECC calculation algorithm", -	"[hw/sw] - Switch between NAND hardware (hw) or software (sw) ecc algorithm" +	"hw [hamming|bch8] - Switch between NAND hardware 1-bit hamming and" +	" 8-bit BCH\n" +	"                           ecc calculation (second parameter may" +	" be omitted).\n" +	"nandecc sw               - Switch to NAND software ecc algorithm."  );  #endif /* CONFIG_NAND_OMAP_GPMC & !CONFIG_SPL_BUILD */ diff --git a/arch/arm/cpu/armv7/omap4/emif.c b/arch/arm/cpu/armv7/omap4/emif.c index ca4823dd7..53f60635b 100644 --- a/arch/arm/cpu/armv7/omap4/emif.c +++ b/arch/arm/cpu/armv7/omap4/emif.c @@ -33,7 +33,6 @@  #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS  u32 *const T_num = (u32 *)OMAP4_SRAM_SCRATCH_EMIF_T_NUM;  u32 *const T_den = (u32 *)OMAP4_SRAM_SCRATCH_EMIF_T_DEN; -u32 *const emif_sizes = (u32 *)OMAP4_SRAM_SCRATCH_EMIF_SIZE;  #endif  #ifdef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS diff --git a/arch/arm/cpu/armv7/omap4/hw_data.c b/arch/arm/cpu/armv7/omap4/hw_data.c index 7551b9861..04977b4f2 100644 --- a/arch/arm/cpu/armv7/omap4/hw_data.c +++ b/arch/arm/cpu/armv7/omap4/hw_data.c @@ -216,14 +216,14 @@ struct dplls omap4460_dplls = {  struct pmic_data twl6030_4430es1 = {  	.base_offset = PHOENIX_SMPS_BASE_VOLT_STD_MODE_UV, -	.step = 12660, /* 10 mV represented in uV */ +	.step = 12660, /* 12.66 mV represented in uV */  	/* The code starts at 1 not 0 */  	.start_code = 1,  };  struct pmic_data twl6030 = {  	.base_offset = PHOENIX_SMPS_BASE_VOLT_STD_MODE_WITH_OFFSET_UV, -	.step = 12660, /* 10 mV represented in uV */ +	.step = 12660, /* 12.66 mV represented in uV */  	/* The code starts at 1 not 0 */  	.start_code = 1,  }; @@ -271,11 +271,11 @@ struct vcores_data omap4460_volts = {  	.core.value = 1200,  	.core.addr = SMPS_REG_ADDR_VCORE1, -	.core.pmic = &tps62361, +	.core.pmic = &twl6030,  	.mm.value = 1200,  	.mm.addr = SMPS_REG_ADDR_VCORE2, -	.mm.pmic = &tps62361, +	.mm.pmic = &twl6030,  };  /* diff --git a/arch/arm/cpu/armv7/omap5/emif.c b/arch/arm/cpu/armv7/omap5/emif.c index 8019ffe3d..3f37abdf8 100644 --- a/arch/arm/cpu/armv7/omap5/emif.c +++ b/arch/arm/cpu/armv7/omap5/emif.c @@ -34,7 +34,6 @@  #define print_timing_reg(reg) debug(#reg" - 0x%08x\n", (reg))  static u32 *const T_num = (u32 *)OMAP5_SRAM_SCRATCH_EMIF_T_NUM;  static u32 *const T_den = (u32 *)OMAP5_SRAM_SCRATCH_EMIF_T_DEN; -static u32 *const emif_sizes = (u32 *)OMAP5_SRAM_SCRATCH_EMIF_SIZE;  #endif  #ifdef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS diff --git a/arch/arm/cpu/armv7/s5p-common/pwm.c b/arch/arm/cpu/armv7/s5p-common/pwm.c index 44d7bc360..6f401b8d9 100644 --- a/arch/arm/cpu/armv7/s5p-common/pwm.c +++ b/arch/arm/cpu/armv7/s5p-common/pwm.c @@ -70,7 +70,7 @@ static unsigned long pwm_calc_tin(int pwm_id, unsigned long freq)  	return tin_parent_rate / 16;  } -#define NS_IN_HZ (1000000000UL) +#define NS_IN_SEC 1000000000UL  int pwm_config(int pwm_id, int duty_ns, int period_ns)  { @@ -79,7 +79,7 @@ int pwm_config(int pwm_id, int duty_ns, int period_ns)  	unsigned int offset;  	unsigned long tin_rate;  	unsigned long tin_ns; -	unsigned long period; +	unsigned long frequency;  	unsigned long tcon;  	unsigned long tcnt;  	unsigned long tcmp; @@ -89,34 +89,24 @@ int pwm_config(int pwm_id, int duty_ns, int period_ns)  	 * fact that anything faster than 1GHz is easily representable  	 * by 32bits.  	 */ -	if (period_ns > NS_IN_HZ || duty_ns > NS_IN_HZ) +	if (period_ns > NS_IN_SEC || duty_ns > NS_IN_SEC || period_ns == 0)  		return -ERANGE;  	if (duty_ns > period_ns)  		return -EINVAL; -	period = NS_IN_HZ / period_ns; +	frequency = NS_IN_SEC / period_ns;  	/* Check to see if we are changing the clock rate of the PWM */ -	tin_rate = pwm_calc_tin(pwm_id, period); +	tin_rate = pwm_calc_tin(pwm_id, frequency); -	tin_ns = NS_IN_HZ / tin_rate; +	tin_ns = NS_IN_SEC / tin_rate;  	tcnt = period_ns / tin_ns;  	/* Note, counters count down */  	tcmp = duty_ns / tin_ns;  	tcmp = tcnt - tcmp; -	/* -	 * the pwm hw only checks the compare register after a decrement, -	 * so the pin never toggles if tcmp = tcnt -	 */ -	if (tcmp == tcnt) -		tcmp--; - -	if (tcmp < 0) -		tcmp = 0; -  	/* Update the PWM register block. */  	offset = pwm_id * 3;  	if (pwm_id < 4) { @@ -143,7 +133,7 @@ int pwm_init(int pwm_id, int div, int invert)  	u32 val;  	const struct s5p_timer *pwm =  			(struct s5p_timer *)samsung_get_base_timer(); -	unsigned long timer_rate_hz; +	unsigned long ticks_per_period;  	unsigned int offset, prescaler;  	/* @@ -167,14 +157,24 @@ int pwm_init(int pwm_id, int div, int invert)  	val |= (div & 0xf) << MUX_DIV_SHIFT(pwm_id);  	writel(val, &pwm->tcfg1); -	timer_rate_hz = get_pwm_clk() / ((prescaler + 1) * -			(div + 1)); +	if (pwm_id == 4) { +		/* +		 * TODO(sjg): Use this as a countdown timer for now. We count +		 * down from the maximum value to 0, then reset. +		 */ +		ticks_per_period = -1UL; +	} else { +		const unsigned long pwm_hz = 1000; +		unsigned long timer_rate_hz = get_pwm_clk() / +			((prescaler + 1) * (1 << div)); -	timer_rate_hz = timer_rate_hz / CONFIG_SYS_HZ; +		ticks_per_period = timer_rate_hz / pwm_hz; +	}  	/* set count value */  	offset = pwm_id * 3; -	writel(timer_rate_hz, &pwm->tcntb0 + offset); + +	writel(ticks_per_period, &pwm->tcntb0 + offset);  	val = readl(&pwm->tcon) & ~(0xf << TCON_OFFSET(pwm_id));  	if (invert && (pwm_id < 4)) diff --git a/arch/arm/cpu/armv7/s5p-common/timer.c b/arch/arm/cpu/armv7/s5p-common/timer.c index e78c716d3..6a0fa5862 100644 --- a/arch/arm/cpu/armv7/s5p-common/timer.c +++ b/arch/arm/cpu/armv7/s5p-common/timer.c @@ -39,13 +39,33 @@ static inline struct s5p_timer *s5p_get_base_timer(void)  	return (struct s5p_timer *)samsung_get_base_timer();  } +/** + * Read the countdown timer. + * + * This operates at 1MHz and counts downwards. It will wrap about every + * hour (2^32 microseconds). + * + * @return current value of timer + */ +static unsigned long timer_get_us_down(void) +{ +	struct s5p_timer *const timer = s5p_get_base_timer(); + +	return readl(&timer->tcnto4); +} +  int timer_init(void)  {  	/* PWM Timer 4 */ -	pwm_init(4, MUX_DIV_2, 0); -	pwm_config(4, 0, 0); +	pwm_init(4, MUX_DIV_4, 0); +	pwm_config(4, 100000, 100000);  	pwm_enable(4); +	/* Use this as the current monotonic time in us */ +	gd->arch.timer_reset_value = 0; + +	/* Use this as the last timer value we saw */ +	gd->arch.lastinc = timer_get_us_down();  	reset_timer_masked();  	return 0; @@ -56,48 +76,43 @@ int timer_init(void)   */  unsigned long get_timer(unsigned long base)  { -	return get_timer_masked() - base; +	ulong now = timer_get_us_down(); + +	/* +	 * Increment the time by the amount elapsed since the last read. +	 * The timer may have wrapped around, but it makes no difference to +	 * our arithmetic here. +	 */ +	gd->arch.timer_reset_value += gd->arch.lastinc - now; +	gd->arch.lastinc = now; + +	/* Divide by 1000 to convert from us to ms */ +	return gd->arch.timer_reset_value / 1000 - base;  } -/* delay x useconds */ -void __udelay(unsigned long usec) +unsigned long timer_get_us(void)  { -	struct s5p_timer *const timer = s5p_get_base_timer(); -	unsigned long tmo, tmp, count_value; +	static unsigned long base_time_us; -	count_value = readl(&timer->tcntb4); +	struct s5p_timer *const timer = +		(struct s5p_timer *)samsung_get_base_timer(); +	unsigned long now_downward_us = readl(&timer->tcnto4); -	if (usec >= 1000) { -		/* -		 * if "big" number, spread normalization -		 * to seconds -		 * 1. start to normalize for usec to ticks per sec -		 * 2. find number of "ticks" to wait to achieve target -		 * 3. finish normalize. -		 */ -		tmo = usec / 1000; -		tmo *= (CONFIG_SYS_HZ * count_value); -		tmo /= 1000; -	} else { -		/* else small number, don't kill it prior to HZ multiply */ -		tmo = usec * CONFIG_SYS_HZ * count_value; -		tmo /= (1000 * 1000); -	} +	if (!base_time_us) +		base_time_us = now_downward_us; -	/* get current timestamp */ -	tmp = get_current_tick(); +	/* Note that this timer counts downward. */ +	return base_time_us - now_downward_us; +} -	/* if setting this fordward will roll time stamp */ -	/* reset "advancing" timestamp to 0, set lastinc value */ -	/* else, set advancing stamp wake up time */ -	if ((tmo + tmp + 1) < tmp) -		reset_timer_masked(); -	else -		tmo += tmp; +/* delay x useconds */ +void __udelay(unsigned long usec) +{ +	unsigned long count_value; -	/* loop till event */ -	while (get_current_tick() < tmo) -		;	/* nop */ +	count_value = timer_get_us_down(); +	while ((int)(count_value - timer_get_us_down()) < (int)usec) +		;  }  void reset_timer_masked(void) @@ -109,30 +124,6 @@ void reset_timer_masked(void)  	gd->arch.tbl = 0;  } -unsigned long get_timer_masked(void) -{ -	struct s5p_timer *const timer = s5p_get_base_timer(); -	unsigned long count_value = readl(&timer->tcntb4); - -	return get_current_tick() / count_value; -} - -unsigned long get_current_tick(void) -{ -	struct s5p_timer *const timer = s5p_get_base_timer(); -	unsigned long now = readl(&timer->tcnto4); -	unsigned long count_value = readl(&timer->tcntb4); - -	if (gd->arch.lastinc >= now) -		gd->arch.tbl += gd->arch.lastinc - now; -	else -		gd->arch.tbl += gd->arch.lastinc + count_value - now; - -	gd->arch.lastinc = now; - -	return gd->arch.tbl; -} -  /*   * This function is derived from PowerPC code (read timebase as long long).   * On ARM it just returns the timer value. diff --git a/arch/arm/cpu/armv7/socfpga/u-boot-spl.lds b/arch/arm/cpu/armv7/socfpga/u-boot-spl.lds index 79cc93cb5..15f8c01a9 100644 --- a/arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +++ b/arch/arm/cpu/armv7/socfpga/u-boot-spl.lds @@ -27,7 +27,7 @@ SECTIONS  	. = ALIGN(4);  	.text	:  	{ -		arch/arm/cpu/armv7/start.o	(.text) +		arch/arm/cpu/armv7/start.o	(.text*)  		*(.text*)  	} >.sdram diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 36a4c3cfd..64008ba6c 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -81,7 +81,11 @@ _end_vect:  .globl _TEXT_BASE  _TEXT_BASE: +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE) +	.word	CONFIG_SPL_TEXT_BASE +#else  	.word	CONFIG_SYS_TEXT_BASE +#endif  /*   * These are defined in the board-specific linker script. @@ -90,9 +94,9 @@ _TEXT_BASE:  _bss_start_ofs:  	.word __bss_start - _start -.global	_image_copy_end_ofs +.globl _image_copy_end_ofs  _image_copy_end_ofs: -	.word 	__image_copy_end - _start +	.word __image_copy_end - _start  .globl _bss_end_ofs  _bss_end_ofs: @@ -161,28 +165,23 @@ reset:  #ifndef CONFIG_SPL_BUILD  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  ENTRY(relocate_code) -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  	adr	r0, _start -	cmp	r0, r6 -	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy_loop */  	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -190,7 +189,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ diff --git a/arch/arm/cpu/ixp/start.S b/arch/arm/cpu/ixp/start.S index b7259645e..69ef8aa61 100644 --- a/arch/arm/cpu/ixp/start.S +++ b/arch/arm/cpu/ixp/start.S @@ -98,7 +98,11 @@ _fiq:			.word fiq  .globl _TEXT_BASE  _TEXT_BASE: +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE) +	.word	CONFIG_SPL_TEXT_BASE +#else  	.word	CONFIG_SYS_TEXT_BASE +#endif  /*   * These are defined in the board-specific linker script. @@ -110,6 +114,10 @@ _TEXT_BASE:  _bss_start_ofs:  	.word __bss_start - _start +.globl _image_copy_end_ofs +_image_copy_end_ofs: +	.word __image_copy_end - _start +  .globl _bss_end_ofs  _bss_end_ofs:  	.word __bss_end - _start @@ -250,29 +258,24 @@ reset:  /*------------------------------------------------------------------------------*/  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  	.globl	relocate_code  relocate_code: -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  	adr	r0, _start -	cmp	r0, r6 -	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy_loop */ -	ldr	r3, _bss_start_ofs +	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -281,7 +284,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ diff --git a/arch/arm/cpu/ixp/u-boot.lds b/arch/arm/cpu/ixp/u-boot.lds index 8345b5503..388a67f10 100644 --- a/arch/arm/cpu/ixp/u-boot.lds +++ b/arch/arm/cpu/ixp/u-boot.lds @@ -54,6 +54,8 @@ SECTIONS  	. = ALIGN(4); +	__image_copy_end = .; +  	.rel.dyn : {  		__rel_dyn_start = .;  		*(.rel*) diff --git a/arch/arm/cpu/pxa/start.S b/arch/arm/cpu/pxa/start.S index 456a7836d..3e07c7c35 100644 --- a/arch/arm/cpu/pxa/start.S +++ b/arch/arm/cpu/pxa/start.S @@ -102,7 +102,7 @@ _end_vect:  .globl _TEXT_BASE  _TEXT_BASE: -#ifdef	CONFIG_SPL_BUILD +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)  	.word	CONFIG_SPL_TEXT_BASE  #else  	.word	CONFIG_SYS_TEXT_BASE @@ -118,6 +118,10 @@ _TEXT_BASE:  _bss_start_ofs:  	.word __bss_start - _start +.globl _image_copy_end_ofs +_image_copy_end_ofs: +	.word __image_copy_end - _start +  .globl _bss_end_ofs  _bss_end_ofs:  	.word __bss_end - _start @@ -169,17 +173,13 @@ reset:  /*------------------------------------------------------------------------------*/  #ifndef CONFIG_SPL_BUILD  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  	.globl	relocate_code  relocate_code: -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  /* Disable the Dcache RAM lock for stack now */  #ifdef	CONFIG_CPU_PXA25X @@ -189,16 +189,15 @@ relocate_code:  #endif  	adr	r0, _start -	cmp	r0, r6 -	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy_loop */ -	ldr	r3, _bss_start_ofs +	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -207,7 +206,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ diff --git a/arch/arm/cpu/s3c44b0/start.S b/arch/arm/cpu/s3c44b0/start.S index c09617708..7361aa268 100644 --- a/arch/arm/cpu/s3c44b0/start.S +++ b/arch/arm/cpu/s3c44b0/start.S @@ -64,7 +64,11 @@ _start:	b       reset  .globl _TEXT_BASE  _TEXT_BASE: +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE) +	.word	CONFIG_SPL_TEXT_BASE +#else  	.word	CONFIG_SYS_TEXT_BASE +#endif  /*   * These are defined in the board-specific linker script. @@ -76,6 +80,10 @@ _TEXT_BASE:  _bss_start_ofs:  	.word __bss_start - _start +.globl _image_copy_end_ofs +_image_copy_end_ofs: +	.word __image_copy_end - _start +  .globl _bss_end_ofs  _bss_end_ofs:  	.word __bss_end - _start @@ -133,29 +141,24 @@ reset:  /*------------------------------------------------------------------------------*/  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  	.globl	relocate_code  relocate_code: -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  	adr	r0, _start -	cmp	r0, r6 -	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy_loop */ -	ldr	r3, _bss_start_ofs +	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -164,7 +167,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ diff --git a/arch/arm/cpu/sa1100/start.S b/arch/arm/cpu/sa1100/start.S index 4bf6f5fe9..8a2eafd6a 100644 --- a/arch/arm/cpu/sa1100/start.S +++ b/arch/arm/cpu/sa1100/start.S @@ -74,7 +74,11 @@ _fiq:			.word fiq  .globl _TEXT_BASE  _TEXT_BASE: +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE) +	.word	CONFIG_SPL_TEXT_BASE +#else  	.word	CONFIG_SYS_TEXT_BASE +#endif  /*   * These are defined in the board-specific linker script. @@ -86,6 +90,10 @@ _TEXT_BASE:  _bss_start_ofs:  	.word __bss_start - _start +.globl _image_copy_end_ofs +_image_copy_end_ofs: +	.word __image_copy_end - _start +  .globl _bss_end_ofs  _bss_end_ofs:  	.word __bss_end - _start @@ -137,29 +145,24 @@ reset:  /*------------------------------------------------------------------------------*/  /* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. + * void relocate_code(addr_moni)   * + * This function relocates the monitor code.   */  	.globl	relocate_code  relocate_code: -	mov	r4, r0	/* save addr_sp */ -	mov	r5, r1	/* save addr of gd */ -	mov	r6, r2	/* save addr of destination */ +	mov	r6, r0	/* save addr of destination */  	adr	r0, _start -	cmp	r0, r6 -	moveq	r9, #0		/* no relocation. relocation offset(r9) = 0 */ +	subs	r9, r6, r0		/* r9 <- relocation offset */  	beq	relocate_done		/* skip relocation */  	mov	r1, r6			/* r1 <- scratch for copy_loop */ -	ldr	r3, _bss_start_ofs +	ldr	r3, _image_copy_end_ofs  	add	r2, r0, r3		/* r2 <- source end address	    */  copy_loop: -	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */ -	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */ +	ldmia	r0!, {r10-r11}		/* copy from source address [r0]    */ +	stmia	r1!, {r10-r11}		/* copy to   target address [r1]    */  	cmp	r0, r2			/* until source end address [r2]    */  	blo	copy_loop @@ -168,7 +171,6 @@ copy_loop:  	 * fix .rel.dyn relocations  	 */  	ldr	r0, _TEXT_BASE		/* r0 <- Text base */ -	sub	r9, r6, r0		/* r9 <- relocation offset */  	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */  	add	r10, r10, r0		/* r10 <- sym table in FLASH */  	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */ |