forked from u-boot/u-boot
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add minimal support for Altera's SOCFPGA Cyclone 5 hardware. Signed-off-by: Dinh Nguyen <[email protected]> Signed-off-by: Chin Liang See <[email protected]> Signed-off-by: Pavel Machek <[email protected]> Reviewed-by: Marek Vasut <[email protected]> Acked-by: Tom Trini <[email protected]> Cc: Wolfgang Denx <[email protected]> Cc: Albert Aribaud <[email protected]> Cc: Stefan Roese <[email protected]> ---- v8: Remove no_return attribute for reset_cpu Based on v2012.10-rc2
- Loading branch information
1 parent
1acc555
commit 7775440
Showing
16 changed files
with
901 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -781,6 +781,11 @@ Nagendra T S <[email protected]> | |
|
||
am3517_crane ARM ARMV7 (AM35x SoC) | ||
|
||
Dinh Nguyen <[email protected]> | ||
Chin Liang See <[email protected]> | ||
|
||
socfpga socfpga_cyclone5 | ||
|
||
Sandeep Paulraj <[email protected]> | ||
|
||
davinci_dm355evm ARM926EJS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# | ||
# (C) Copyright 2000-2003 | ||
# Wolfgang Denk, DENX Software Engineering, [email protected]. | ||
# | ||
# Copyright (C) 2012 Altera Corporation <www.altera.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 $(TOPDIR)/config.mk | ||
|
||
LIB = $(obj)lib$(SOC).o | ||
|
||
SOBJS := lowlevel_init.o | ||
COBJS-y := misc.o timer.o | ||
COBJS-$(CONFIG_SPL_BUILD) += spl.o | ||
|
||
COBJS := $(COBJS-y) | ||
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) | ||
OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS)) | ||
|
||
all: $(obj).depend $(LIB) | ||
|
||
$(LIB): $(OBJS) | ||
$(call cmd_link_o_target, $(OBJS)) | ||
|
||
######################################################################### | ||
|
||
# defines $(obj).depend target | ||
include $(SRCTREE)/rules.mk | ||
|
||
sinclude $(obj).depend | ||
|
||
######################################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# | ||
# Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ | ||
# | ||
# 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 "as is" WITHOUT ANY WARRANTY of any | ||
# kind, whether express or implied; without even the implied warranty | ||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
ifndef CONFIG_SPL_BUILD | ||
ALL-y += $(obj)u-boot.img | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (C) 2012 Altera Corporation <www.altera.com> | ||
* | ||
* 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, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <config.h> | ||
#include <version.h> | ||
|
||
/* Save the parameter pass in by previous boot loader */ | ||
.global save_boot_params | ||
save_boot_params: | ||
/* save the parameter here */ | ||
|
||
/* | ||
* Setup stack for exception, which is located | ||
* at the end of on-chip RAM. We don't expect exception prior to | ||
* relocation and if that happens, we won't worry -- it will overide | ||
* global data region as the code will goto reset. After relocation, | ||
* this region won't be used by other part of program. | ||
* Hence it is safe. | ||
*/ | ||
ldr r0, =(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) | ||
ldr r1, =IRQ_STACK_START_IN | ||
str r0, [r1] | ||
|
||
bx lr | ||
|
||
|
||
/* Set up the platform, once the cpu has been initialized */ | ||
.globl lowlevel_init | ||
lowlevel_init: | ||
|
||
/* Remap */ | ||
#ifdef CONFIG_SPL_BUILD | ||
/* | ||
* SPL : configure the remap (L3 NIC-301 GPV) | ||
* so the on-chip RAM at lower memory instead ROM. | ||
*/ | ||
ldr r0, =SOCFPGA_L3REGS_ADDRESS | ||
mov r1, #0x19 | ||
str r1, [r0] | ||
#else | ||
/* | ||
* U-Boot : configure the remap (L3 NIC-301 GPV) | ||
* so the SDRAM at lower memory instead on-chip RAM. | ||
*/ | ||
ldr r0, =SOCFPGA_L3REGS_ADDRESS | ||
mov r1, #0x2 | ||
str r1, [r0] | ||
|
||
/* Private components security */ | ||
|
||
/* | ||
* U-Boot : configure private timer, global timer and cpu | ||
* component access as non secure for kernel stage (as required | ||
* by kernel) | ||
*/ | ||
mrc p15,4,r0,c15,c0,0 | ||
add r1, r0, #0x54 | ||
ldr r2, [r1] | ||
orr r2, r2, #0xff | ||
orr r2, r2, #0xf00 | ||
str r2, [r1] | ||
#endif /* #ifdef CONFIG_SPL_BUILD */ | ||
mov pc, lr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (C) 2012 Altera Corporation <www.altera.com> | ||
* | ||
* 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, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <common.h> | ||
#include <asm/io.h> | ||
#include <asm/arch/reset_manager.h> | ||
|
||
DECLARE_GLOBAL_DATA_PTR; | ||
|
||
static const struct socfpga_reset_manager *reset_manager_base = | ||
(void *)SOCFPGA_RSTMGR_ADDRESS; | ||
|
||
/* | ||
* Write the reset manager register to cause reset | ||
*/ | ||
void reset_cpu(ulong addr) | ||
{ | ||
/* request a warm reset */ | ||
writel(RSTMGR_CTRL_SWWARMRSTREQ_LSB, &reset_manager_base->ctrl); | ||
/* | ||
* infinite loop here as watchdog will trigger and reset | ||
* the processor | ||
*/ | ||
while (1) | ||
; | ||
} | ||
|
||
/* | ||
* Release peripherals from reset based on handoff | ||
*/ | ||
void reset_deassert_peripherals_handoff(void) | ||
{ | ||
writel(0, &reset_manager_base->per_mod_reset); | ||
} | ||
|
||
int dram_init(void) | ||
{ | ||
gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (C) 2012 Altera Corporation <www.altera.com> | ||
* | ||
* 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, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <common.h> | ||
#include <asm/io.h> | ||
#include <asm/u-boot.h> | ||
#include <asm/utils.h> | ||
#include <version.h> | ||
#include <image.h> | ||
#include <malloc.h> | ||
#include <asm/arch/reset_manager.h> | ||
#include <spl.h> | ||
|
||
DECLARE_GLOBAL_DATA_PTR; | ||
|
||
u32 spl_boot_device(void) | ||
{ | ||
return BOOT_DEVICE_RAM; | ||
} | ||
|
||
/* | ||
* Board initialization after bss clearance | ||
*/ | ||
void spl_board_init(void) | ||
{ | ||
/* init timer for enabling delay function */ | ||
timer_init(); | ||
|
||
/* de-assert reset for peripherals and bridges based on handoff */ | ||
reset_deassert_peripherals_handoff(); | ||
|
||
/* enable console uart printing */ | ||
preloader_console_init(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright (C) 2012 Altera Corporation <www.altera.com> | ||
* | ||
* 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, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <common.h> | ||
#include <asm/io.h> | ||
#include <asm/arch/timer.h> | ||
|
||
DECLARE_GLOBAL_DATA_PTR; | ||
|
||
static const struct socfpga_timer *timer_base = (void *)CONFIG_SYS_TIMERBASE; | ||
|
||
/* | ||
* Timer initialization | ||
*/ | ||
int timer_init(void) | ||
{ | ||
writel(TIMER_LOAD_VAL, &timer_base->load_val); | ||
writel(TIMER_LOAD_VAL, &timer_base->curr_val); | ||
writel(readl(&timer_base->ctrl) | 0x3, &timer_base->ctrl); | ||
return 0; | ||
} | ||
|
||
static u32 read_timer(void) | ||
{ | ||
return readl(&timer_base->curr_val); | ||
} | ||
|
||
/* | ||
* Delay x useconds | ||
*/ | ||
void __udelay(unsigned long usec) | ||
{ | ||
unsigned long now, last; | ||
/* | ||
* get the tmo value based on timer clock speed | ||
* tmo = delay required / period of timer clock | ||
*/ | ||
long tmo = usec * CONFIG_TIMER_CLOCK_KHZ / 1000; | ||
|
||
last = read_timer(); | ||
while (tmo > 0) { | ||
now = read_timer(); | ||
if (last >= now) | ||
/* normal mode (non roll) */ | ||
tmo -= last - now; | ||
else | ||
/* we have overflow of the count down timer */ | ||
tmo -= TIMER_LOAD_VAL - last + now; | ||
last = now; | ||
} | ||
} | ||
|
||
/* | ||
* Get the timer value | ||
*/ | ||
ulong get_timer(ulong base) | ||
{ | ||
return get_timer_masked() - base; | ||
} | ||
|
||
/* | ||
* Timer : get the time difference | ||
* Unit of tick is based on the CONFIG_SYS_HZ | ||
*/ | ||
ulong get_timer_masked(void) | ||
{ | ||
/* current tick value */ | ||
ulong now = read_timer() / (CONFIG_TIMER_CLOCK_KHZ/CONFIG_SYS_HZ); | ||
if (gd->lastinc >= now) { | ||
/* normal mode (non roll) */ | ||
/* move stamp forward with absolute diff ticks */ | ||
gd->tbl += gd->lastinc - now; | ||
} else { | ||
/* we have overflow of the count down timer */ | ||
gd->tbl += TIMER_LOAD_VAL - gd->lastinc + now; | ||
} | ||
gd->lastinc = now; | ||
return gd->tbl; | ||
} | ||
|
||
/* | ||
* Reset the timer | ||
*/ | ||
void reset_timer(void) | ||
{ | ||
/* capture current decrementer value time */ | ||
gd->lastinc = read_timer() / (CONFIG_TIMER_CLOCK_KHZ/CONFIG_SYS_HZ); | ||
/* start "advancing" time stamp from 0 */ | ||
gd->tbl = 0; | ||
} |
Oops, something went wrong.