Skip to contentSkip to conversation

Add SPL support for SoCFGPA

PATCH Superseded dinguyen at opensource.altera.com 6 participants 83 messages Jan 14, 2015 – Feb 24, 2015

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Add SPL support for SoCFGPA

From: Dinh Nguyen <[email protected]>

Hello,

This patchset adds all the SPL code that is necessary to support the SoCFPGA platform. With this patch series, one should be able to configure the SDRAM controller and run u-boot.

I have pushed a branch to git://git.rocketboards.org/u-boot-socfpga-next.git
socfpga_for_next_spl_v1 for testing and reviewing.

Thanks,
Dinh

Dinh Nguyen (22):
arm: socfpga: spl: Add main sdram code
arm: socfpga: enable saveenv to mmc partition
arm: socfpga: Add sdram initialization code
arm: socfpga: spl: Add SRAM section
arm: socfpga: spl: put SPL in sram
arm: socfpga: add functions to bring sdram, timer, and uart out of
reset
arm: socfpga: spl: enable sdram, timer and uart
arm: socfpga: spl: Add call to timer_init
arm: socfpga: spl: allow bootrom to enable IOs after warm reset
arm: socfpga: spl: add sdram init and calibration
arm: socfpga: spl: printout sdram size
arm: socfpga: spl: Use common lowlevel_init
arm: socfpga: spl: Add s_init
arm: socfpga: spl: update lowlevel_init
arm: socfpga: spl: add relocate_stack_to_sdram to lowlevel_init.S
arm: socfpga: spl: add the stack in OCRAM
arm: socfpga: spl: add CONFIG_SPL_STACK to socfpga_common.h
arm: socfpga: add sdram stack to SPL
arm: socfpga: spl: set SPL_MALLOC_SIZE
arm: socfpga: spl: add a malloc section in sram
arm: socfpga: spl: Add SDRAM check
arm: socfpga: spl: update pll_config for dev kit

 arch/arm/cpu/armv7/Makefile                        |    2 +-
 arch/arm/cpu/armv7/socfpga/Makefile                |    4 +-
 arch/arm/cpu/armv7/socfpga/config.mk               |    3 +-
 arch/arm/cpu/armv7/socfpga/lowlevel_init.S         |   89 +-
 arch/arm/cpu/armv7/socfpga/reset_manager.c         |   24 +
 arch/arm/cpu/armv7/socfpga/s_init.c                |   49 +
 arch/arm/cpu/armv7/socfpga/sdram.c                 | 1311 ++++
 arch/arm/cpu/armv7/socfpga/spl.c                   |   33 +
 arch/arm/cpu/armv7/socfpga/system_manager.c        |    9 +
 arch/arm/cpu/armv7/socfpga/u-boot-spl.lds          |   29 +-
 arch/arm/include/asm/arch-socfpga/reset_manager.h  |   37 +
 arch/arm/include/asm/arch-socfpga/sdram.h          |  434 ++
 arch/arm/include/asm/arch-socfpga/system_manager.h |   20 +-
 board/altera/socfpga/Makefile                      |    1 +
 board/altera/socfpga/pll_config.h                  |    8 +-
 board/altera/socfpga/sdram/Makefile                |   12 +
 board/altera/socfpga/sdram/sdram_config.h          |  100 +
 board/altera/socfpga/sdram/sdram_io.h              |   44 +
 board/altera/socfpga/sdram/sequencer.c             | 7993 ++++++++++++++++++++
 board/altera/socfpga/sdram/sequencer.h             |  504 ++
 board/altera/socfpga/sdram/sequencer_auto.h        |  216 +
 .../altera/socfpga/sdram/sequencer_auto_ac_init.c  |   88 +
 .../socfpga/sdram/sequencer_auto_inst_init.c       |  273 +
 board/altera/socfpga/sdram/sequencer_defines.h     |  154 +
 board/altera/socfpga/sdram/system.h                |   15 +
 include/configs/socfpga_common.h                   |   16 +-
 include/configs/socfpga_cyclone5.h                 |    1 +
 27 files changed, 11422 insertions(+), 47 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/socfpga/s_init.c
 create mode 100644 arch/arm/cpu/armv7/socfpga/sdram.c
 create mode 100644 arch/arm/include/asm/arch-socfpga/sdram.h
 create mode 100644 board/altera/socfpga/sdram/Makefile
 create mode 100644 board/altera/socfpga/sdram/sdram_config.h
 create mode 100644 board/altera/socfpga/sdram/sdram_io.h
 create mode 100644 board/altera/socfpga/sdram/sequencer.c
 create mode 100644 board/altera/socfpga/sdram/sequencer.h
 create mode 100644 board/altera/socfpga/sdram/sequencer_auto.h
 create mode 100644 board/altera/socfpga/sdram/sequencer_auto_ac_init.c
 create mode 100644 board/altera/socfpga/sdram/sequencer_auto_inst_init.c
 create mode 100644 board/altera/socfpga/sdram/sequencer_defines.h
 create mode 100644 board/altera/socfpga/sdram/system.h
Signature · 1 line
2.2.1
#1 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

From: Dinh Nguyen <[email protected]>

This adds the code to configure the SDRAM controller that is found in the SoCFGPA Cyclone5 and Arria5 platforms.

---
 arch/arm/cpu/armv7/socfpga/config.mk               |    3 +-
 board/altera/socfpga/Makefile                      |    1 +
 board/altera/socfpga/sdram/Makefile                |   12 +
 board/altera/socfpga/sdram/sdram_config.h          |  100 +
 board/altera/socfpga/sdram/sdram_io.h              |   44 +
 board/altera/socfpga/sdram/sequencer.c             | 7993 ++++++++++++++++++++
 board/altera/socfpga/sdram/sequencer.h             |  504 ++
 board/altera/socfpga/sdram/sequencer_auto.h        |  216 +
 .../altera/socfpga/sdram/sequencer_auto_ac_init.c  |   88 +
 .../socfpga/sdram/sequencer_auto_inst_init.c       |  273 +
 board/altera/socfpga/sdram/sequencer_defines.h     |  154 +
 board/altera/socfpga/sdram/system.h                |   15 +
 12 files changed, 9402 insertions(+), 1 deletion(-)
 create mode 100644 board/altera/socfpga/sdram/Makefile
 create mode 100644 board/altera/socfpga/sdram/sdram_config.h
 create mode 100644 board/altera/socfpga/sdram/sdram_io.h
 create mode 100644 board/altera/socfpga/sdram/sequencer.c
 create mode 100644 board/altera/socfpga/sdram/sequencer.h
 create mode 100644 board/altera/socfpga/sdram/sequencer_auto.h
 create mode 100644 board/altera/socfpga/sdram/sequencer_auto_ac_init.c
 create mode 100644 board/altera/socfpga/sdram/sequencer_auto_inst_init.c
 create mode 100644 board/altera/socfpga/sdram/sequencer_defines.h
 create mode 100644 board/altera/socfpga/sdram/system.h
arch/arm/cpu/armv7/socfpga/config.mk +2 -1
index 2a99c72..8113dc2 100644
@@ -8,4 +8,5 @@ ALL-y	+= u-boot.img
 endif
 
 # Added for handoff support
-PLATFORM_RELFLAGS += -Iboard/$(VENDOR)/$(BOARD)
+PLATFORM_RELFLAGS += -Iboard/$(VENDOR)/$(BOARD) \
+-Iboard/$(VENDOR)/$(BOARD)/sdram
board/altera/socfpga/Makefile +1 -0
index 44baa00..72f5d70 100644
@@ -8,3 +8,4 @@
 
 obj-y	:= socfpga_cyclone5.o
 obj-$(CONFIG_SPL_BUILD) += pinmux_config.o iocsr_config.o
+obj-$(CONFIG_SPL_BUILD) += sdram/
board/altera/socfpga/sdram/Makefile new file +12 -0
new file mode 100644
index 0000000..bcab43f
@@ -0,0 +1,12 @@
+#
+# (C) Copyright 2000-2003
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2010, Thomas Chou <[email protected]>
+# Copyright (C) 2014 Altera Corporation <www.altera.com>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-$(CONFIG_SPL_BUILD):= sequencer.o sequencer_auto_ac_init.o \
+			  sequencer_auto_inst_init.o
board/altera/socfpga/sdram/sdram_config.h new file +100 -0

100 lines not on this page · raw message

board/altera/socfpga/sdram/sdram_io.h new file +44 -0

44 lines not on this page · raw message

board/altera/socfpga/sdram/sequencer.c new file +7993 -0

2,834 lines not on this page · raw message

board/altera/socfpga/sdram/sequencer.h new file +504 -0

504 lines not on this page · raw message

board/altera/socfpga/sdram/sequencer_auto.h new file +216 -0

216 lines not on this page · raw message

board/altera/socfpga/sdram/sequencer_auto_ac_init.c new file +88 -0

88 lines not on this page · raw message

board/altera/socfpga/sdram/sequencer_auto_inst_init.c new file +273 -0

273 lines not on this page · raw message

board/altera/socfpga/sdram/sequencer_defines.h new file +154 -0

154 lines not on this page · raw message

board/altera/socfpga/sdram/system.h new file +15 -0
new file mode 100644
index 0000000..6ba5915

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.2.1

Part of the diff is not shown here. View the raw message.

#2 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

Quoted 1 line · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Hi!

Quoted 11 lines

This adds the code to configure the SDRAM controller that is found in the SoCFGPA Cyclone5 and Arria5 platforms.

---
 arch/arm/cpu/armv7/socfpga/config.mk               |    3 +-
 board/altera/socfpga/Makefile                      |    1 +
 board/altera/socfpga/sdram/Makefile                |   12 +
 board/altera/socfpga/sdram/sdram_config.h          |  100 +
 board/altera/socfpga/sdram/sdram_io.h              |   44 +
 board/altera/socfpga/sdram/sequencer.c             | 7993

A general remark: SDRAM stuff should most likely reside in drivers/ddr/ , don't you think so ?

Quoted 18 lines

++++++++++++++++++++ board/altera/socfpga/sdram/sequencer.h |
504 ++

 board/altera/socfpga/sdram/sequencer_auto.h        |  216 +
 .../altera/socfpga/sdram/sequencer_auto_ac_init.c  |   88 +
 .../socfpga/sdram/sequencer_auto_inst_init.c       |  273 +
 board/altera/socfpga/sdram/sequencer_defines.h     |  154 +
 board/altera/socfpga/sdram/system.h                |   15 +
 12 files changed, 9402 insertions(+), 1 deletion(-)
 create mode 100644 board/altera/socfpga/sdram/Makefile
 create mode 100644 board/altera/socfpga/sdram/sdram_config.h
 create mode 100644 board/altera/socfpga/sdram/sdram_io.h
 create mode 100644 board/altera/socfpga/sdram/sequencer.c
 create mode 100644 board/altera/socfpga/sdram/sequencer.h
 create mode 100644 board/altera/socfpga/sdram/sequencer_auto.h
 create mode 100644 board/altera/socfpga/sdram/sequencer_auto_ac_init.c
 create mode 100644 board/altera/socfpga/sdram/sequencer_auto_inst_init.c
 create mode 100644 board/altera/socfpga/sdram/sequencer_defines.h
 create mode 100644 board/altera/socfpga/sdram/system.h

[...]

board/altera/socfpga/sdram/sdram_io.h line 4

Quoted 10 lines
(quoted diff) +0 -0

b/board/altera/socfpga/sdram/sdram_io.h new file mode 100644 index 0000000..f24308d

board/altera/socfpga/sdram/sdram_io.h new file +4 -0
@@ -0,0 +1,44 @@
+/*
+ * Copyright Altera Corporation (C) 2012-2014. All rights reserved
+ *
+ * SPDX-License-Identifier:    BSD-3-Clause

Any chance we can get these files under GPL-2.0+ ? It's not a showstopper, but it'd be nice :)

board/altera/socfpga/sdram/sdram_io.h line 10

Quoted 6 lines
board/altera/socfpga/sdram/sdram_io.h new file +6 -0
+ */
+
+#include <asm/io.h>
+
+#ifdef CONFIG_SPL_SERIAL_SUPPORT
+#define HPS_HW_SERIAL_SUPPORT

Are these redundant definitions really needed ?

board/altera/socfpga/sdram/sdram_io.h line 13

Quoted 3 lines
board/altera/socfpga/sdram/sdram_io.h new file +3 -0
+#endif
+
+#define	HPS_SDR_BASE		SOCFPGA_SDR_ADDRESS

This here as well, just use SOCFPGA_SDR_ADDRESS in the code. Besides, it'd be nice to consistently use <space> after #define keyword.

board/altera/socfpga/sdram/sdram_io.h line 21

Quoted 8 lines
board/altera/socfpga/sdram/sdram_io.h new file +8 -0
+#define MGR_SELECT_MASK		0xf8000
+
+#define APB_BASE_SCC_MGR	SDR_PHYGRP_SCCGRP_ADDRESS
+#define APB_BASE_PHY_MGR	SDR_PHYGRP_PHYMGRGRP_ADDRESS
+#define APB_BASE_RW_MGR		SDR_PHYGRP_RWMGRGRP_ADDRESS
+#define APB_BASE_DATA_MGR	SDR_PHYGRP_DATAMGRGRP_ADDRESS
+#define APB_BASE_REG_FILE	SDR_PHYGRP_REGFILEGRP_ADDRESS
+#define APB_BASE_MMR		SDR_CTRLGRP_ADDRESS

More redundancy here.

Quoted 5 lines
board/altera/socfpga/sdram/sdram_io.h new file +5 -0
+#define __AVL_TO_APB(ADDR) \
+	((((ADDR) & MGR_SELECT_MASK) == (BASE_PHY_MGR))  ? \
+	(APB_BASE_PHY_MGR)  | (((ADDR) >> (14-6)) & (0x1<<6))  | \
+	((ADDR) & 0x3f) : \
+	(((ADDR) & MGR_SELECT_MASK) == (BASE_RW_MGR))   ? \

board/altera/socfpga/sdram/sdram_io.h line 37

Quoted 10 lines
board/altera/socfpga/sdram/sdram_io.h new file +10 -0
+	(APB_BASE_RW_MGR)   | ((ADDR) & 0x1fff) : \
+	(((ADDR) & MGR_SELECT_MASK) == (BASE_DATA_MGR)) ? \
+	(APB_BASE_DATA_MGR) | ((ADDR) & 0x7ff) : \
+	(((ADDR) & MGR_SELECT_MASK) == (BASE_SCC_MGR))  ? \
+	(APB_BASE_SCC_MGR)  | ((ADDR) & 0xfff) : \
+	(((ADDR) & MGR_SELECT_MASK) == (BASE_REG_FILE)) ? \
+	(APB_BASE_REG_FILE) | ((ADDR) & 0x7ff) : \
+	(((ADDR) & MGR_SELECT_MASK) == (BASE_MMR))      ? \
+	(APB_BASE_MMR)      | ((ADDR) & 0xfff) : -1)
+

This stuff here should be a function, to get a proper typechecking on it.

board/altera/socfpga/sdram/sdram_io.h line 43

Quoted 6 lines
board/altera/socfpga/sdram/sdram_io.h new file +6 -0
+#define IOWR_32DIRECT(BASE, OFFSET, DATA) \
+	writel(DATA, HPS_SDR_BASE + __AVL_TO_APB((uint32_t)((BASE) + \
+	(OFFSET))))
+
+#define IORD_32DIRECT(BASE, OFFSET) \
+	readl(HPS_SDR_BASE + __AVL_TO_APB((uint32_t)((BASE) + (OFFSET))))

OK, these macros look really questionable. You might want to make them into a function too, but before you do so, I'd rather suggest you rethink this entire _AVL_TO_APB usage and make this entire section more readable. The code is really confusing here.

Quoted 44 lines
board/altera/socfpga/sdram/sdram_io.h new file +1 -0
+
(quoted diff) +0 -0

b/board/altera/socfpga/sdram/sequencer.c new file mode 100644 index 0000000..c0ba0e5

board/altera/socfpga/sdram/sequencer.c new file +19 -0
@@ -0,0 +1,7993 @@
+/*
+ * Copyright Altera Corporation (C) 2012-2014. All rights reserved
+ *
+ * SPDX-License-Identifier:    BSD-3-Clause
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/sdram.h>
+#include "sdram_io.h"
+#include "sequencer.h"
+#include "sequencer_auto.h"
+#include "sequencer_defines.h"
+#include "system.h"
+
+static void scc_mgr_load_dqs_for_write_group(uint32_t write_group);
+static void rw_mgr_mem_dll_lock_wait(void);
+
+/*************************************************************************

***** +
**************************************************************************
**** + ** NOTE: Special Rules for Globale Variables
** + **
** + ** All global variables that are explicitly initialized
(including ** + ** explicitly initialized to zero), are only
initialized once, during ** + ** configuration time, and not again
on reset. This means that they ** + ** preserve their current
contents across resets, which is needed for some ** + ** special cases
involving communication with external modules. In ** + **
addition, this avoids paying the price to have the memory initialized, ** + ** even for zeroed data, provided it is explicitly set to zero in the code, ** + ** and doesn't rely on implicit initialization.

            ** +

**************************************************************************
**** +
**************************************************************************
****/ +

board/altera/socfpga/sdram/sequencer.c line 40

Quoted 7 lines
board/altera/socfpga/sdram/sequencer.c new file +7 -0
+#if ARRIAV
+/*
+ * Temporary workaround to place the initial stack pointer at a safe
+ * offset from end
+ */
+#define STRINGIFY(s)		STRINGIFY_STR(s)
+#define STRINGIFY_STR(s)	#s

There's already a macro named __stringify(), no need to duplicate it here.

Quoted 3 lines
board/altera/socfpga/sdram/sequencer.c new file +3 -0
+asm(".global __alt_stack_pointer");
+asm("__alt_stack_pointer = " STRINGIFY(STACK_POINTER));
+#endif

[...]

board/altera/socfpga/sdram/sequencer.c line 133

Quoted 10 lines
board/altera/socfpga/sdram/sequencer.c new file +6 -0
+/* For HPS running on actual hardware */
+
+#define DLEVEL 0
+#ifdef HPS_HW_SERIAL_SUPPORT
+/*
+ * space around comma is required for varargs macro to remove comma if

args + * is empty
+ */

board/altera/socfpga/sdram/sequencer.c new file +2 -0
+#define DPRINT(level, fmt, args...)	if (DLEVEL >= (level)) \
+					printf("SEQ.C: " fmt "\n" , ## args)

This could just use __FILE__ instead of hard-coding seq.c (which is not even the filename anymore) .

Quoted 1 line

+#define IPRINT(fmt, args...) printf("SEQ.C: " fmt "\n" , ##

args)

board/altera/socfpga/sdram/sequencer.c line 146

Quoted 12 lines
board/altera/socfpga/sdram/sequencer.c new file +12 -0
+#else
+#define DPRINT(level, fmt, args...)
+#define IPRINT(fmt, args...)
+#endif
+#define BFM_GBL_SET(field, value)
+#define BFM_GBL_GET(field)		((long unsigned int)0)
+#define BFM_STAGE(stage)
+#define BFM_INC_VFIFO
+#define COV(label)
+
+#define TRACE_FUNC(fmt, args...) \
+	DPRINT(1, "%s[%d]: " fmt, __func__, __LINE__ , ## args)

I suspect you can use debug() or debug_cond() macro to avoid re-implementing the entire debug infrastructure here ;-)
[...]

board/altera/socfpga/sdram/sequencer.c line 243

Quoted 6 lines
board/altera/socfpga/sdram/sequencer.c new file +6 -0
+void wait_di_buffer(void)
+{
+	if (debug_data->di_report.cur_samples == NUM_DI_SAMPLE)	{
+		debug_data->di_report.flags |= DI_REPORT_FLAGS_READY;
+		while (debug_data->di_report.cur_samples != 0)
+			;

Please get rid of such endless loops, since the platform might get stuck forever in them.

Quoted 3 lines
board/altera/socfpga/sdram/sequencer.c new file +3 -0
+		debug_data->di_report.flags = 0;
+	}
+}

[...]

Quoted 9 lines
(quoted diff) +0 -0

b/board/altera/socfpga/sdram/sequencer.h new file mode 100644 index 0000000..ce4c7bf

board/altera/socfpga/sdram/sequencer.h new file +3 -0
@@ -0,0 +1,504 @@
+/*
+ * Copyright Altera Corporation (C) 2012-2014. All rights reserved
+ *

board/altera/socfpga/sdram/sequencer.h line 13

Quoted 10 lines
board/altera/socfpga/sdram/sequencer.h new file +10 -0
+ * SPDX-License-Identifier:    BSD-3-Clause
+ */
+
+#ifndef _SEQUENCER_H_
+#define _SEQUENCER_H_
+
+extern int32_t inst_rom_init_size;
+extern uint32_t inst_rom_init[];
+extern uint32_t ac_rom_init_size;
+extern uint32_t ac_rom_init[];

Extern variables usually mean the code is not well contained. You might want to review whether making these variables visible globally is really needed or not.

Quoted 3 lines
board/altera/socfpga/sdram/sequencer.h new file +2 -0
+#if ENABLE_ASSERT
+#define ERR_IE_TEXT "Internal Error: Sub-system: %s, File: %s, Line:

%d\n%s%s"

This might just use debug_cond() in some way, no ?

board/altera/socfpga/sdram/sequencer.h line 19

Quoted 3 lines
board/altera/socfpga/sdram/sequencer.h new file +2 -0
+extern void err_report_internal_error(const char *description,
+	const char *module, const char *file, int line);

In case of functions, the extern is really not needed. Just define the prototype without the extern keyword.

board/altera/socfpga/sdram/sequencer.h line 30

Quoted 10 lines
board/altera/socfpga/sdram/sequencer.h new file +10 -0
+#define ALTERA_INTERNAL_ERROR(string) \
+	{err_report_internal_error(string, "SEQ", __FILE__, __LINE__); \
+	exit(-1); }
+
+#define ALTERA_ASSERT(condition) \
+	if (!(condition)) {\
+		ALTERA_INTERNAL_ERROR(#condition); }
+#define ALTERA_INFO_ASSERT(condition, text) \
+	if (!(condition)) {\
+		ALTERA_INTERNAL_ERROR(text); }

Oh wow, debug_cond() would help, really ;-)

Quoted 4 lines
board/altera/socfpga/sdram/sequencer.h new file +4 -0
+#else
+
+#define ALTERA_ASSERT(condition)
+#define ALTERA_INFO_ASSERT(condition, text)

[...]

Quoted 15 lines
board/altera/socfpga/sdram/sequencer.h new file +10 -0
+
+#if LRDIMM
+/* USER RTT_NOM: bits {4,3,2} of the SPD = bits {9,6,2} of the MR */
+#define LRDIMM_SPD_MR_RTT_NOM(spd_byte)                              \
+	((((spd_byte) & (1 << 4)) << (9-4))                       \
+	| (((spd_byte) & (1 << 3)) << (6-3))                         \
+	| (((spd_byte) & (1 << 2)) << (2-2)))
+
+/* USER RTT_DRV: bits {1,0} of the SPD = bits {5,1} of the MR */
+#define LRDIMM_SPD_MR_RTT_DRV(spd_byte)                                  

\ + ((((spd_byte) & (1 << 1)) << (5-1)) \

board/altera/socfpga/sdram/sequencer.h new file +4 -0
+	| (((spd_byte) & (1 << 0)) << (1-0)))
+
+/* USER RTT_WR: bits {7,6} of the SPD = bits {10,9} of the MR */
+#define LRDIMM_SPD_MR_RTT_WR(spd_byte)                                   
Quoted 1 line

\ + (((spd_byte) & (3 << 6)) << (9-6))

We already have multiple SPD parsers in U-Boot (git grep 'spd' should give you an idea , for example see common/ddr_spd.c ). Could that be used to replace your SPD code ? I might be wrong here, so please correct me if I am ... :)

board/altera/socfpga/sdram/sequencer.h line 87

Quoted 10 lines
board/altera/socfpga/sdram/sequencer.h new file +10 -0
+#endif /* LRDIMM */
+#endif /* DDR3 */
+
+#define RW_MGR_MEM_NUMBER_OF_RANKS	1
+#define NUM_SHADOW_REGS			1
+
+#define RW_MGR_LOAD_CNTR_0		(BASE_RW_MGR + 0x0800)
+#define RW_MGR_LOAD_CNTR_1		(BASE_RW_MGR + 0x0804)
+#define RW_MGR_LOAD_CNTR_2		(BASE_RW_MGR + 0x0808)
+#define RW_MGR_LOAD_CNTR_3		(BASE_RW_MGR + 0x080C)

Can you please rework these register definitions to struct-based ones?

[...]

Thank you for all the work you put into this !

Best regards,
Marek Vasut

#3 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

Hi!

Quoted 9 lines

board/altera/socfpga/sdram/sequencer.c line 243

Quoted 6 lines
board/altera/socfpga/sdram/sequencer.c new file +6 -0
+void wait_di_buffer(void)
+{
+	if (debug_data->di_report.cur_samples == NUM_DI_SAMPLE)	{
+		debug_data->di_report.flags |= DI_REPORT_FLAGS_READY;
+		while (debug_data->di_report.cur_samples != 0)
+			;

Please get rid of such endless loops, since the platform might get stuck forever in them.

What would you propose in case of timeout? Message on serial console and reboot?

Endless loop should trigger watchdog, anyway, no?

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#4 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

Quoted 1 line · Pavel Machek

Hi!

Hi!

Quoted 10 lines
Quoted 9 lines

board/altera/socfpga/sdram/sequencer.c line 243

Quoted 6 lines
board/altera/socfpga/sdram/sequencer.c new file +6 -0
+void wait_di_buffer(void)
+{
+	if (debug_data->di_report.cur_samples == NUM_DI_SAMPLE)	{
+		debug_data->di_report.flags |= DI_REPORT_FLAGS_READY;
+		while (debug_data->di_report.cur_samples != 0)
+			;

Please get rid of such endless loops, since the platform might get stuck forever in them.

Quoted 2 lines

What would you propose in case of timeout? Message on serial console and reboot?

Yes, reboot and try again would work I suspect.

Quoted 1 line

Endless loop should trigger watchdog, anyway, no?

If and only if the WDT is enabled, which is not necessarily the case.

Best regards,
Marek Vasut

#5 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

Quoted 15 lines · Marek Vasut
Quoted 1 line · Pavel Machek

Hi!

Hi!

Quoted 10 lines
Quoted 9 lines

board/altera/socfpga/sdram/sequencer.c line 243

Quoted 6 lines
board/altera/socfpga/sdram/sequencer.c new file +6 -0
+void wait_di_buffer(void)
+{
+	if (debug_data->di_report.cur_samples == NUM_DI_SAMPLE)	{
+		debug_data->di_report.flags |= DI_REPORT_FLAGS_READY;
+		while (debug_data->di_report.cur_samples != 0)
+			;

Please get rid of such endless loops, since the platform might get stuck forever in them.

Quoted 8 lines
Quoted 2 lines

What would you propose in case of timeout? Message on serial console and reboot?

Yes, reboot and try again would work I suspect.

Quoted 1 line

Endless loop should trigger watchdog, anyway, no?

If and only if the WDT is enabled, which is not necessarily the case.

Reasonable solution for SPL woul be "always enable the wdt", then. Probably less overhead than adding timeouts to all the loops...
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#6 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

In reply to Marek Vasut
Quoted 18 lines · Marek Vasut
Quoted 1 line · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Hi!

Quoted 11 lines

This adds the code to configure the SDRAM controller that is found in the SoCFGPA Cyclone5 and Arria5 platforms.

---
 arch/arm/cpu/armv7/socfpga/config.mk               |    3 +-
 board/altera/socfpga/Makefile                      |    1 +
 board/altera/socfpga/sdram/Makefile                |   12 +
 board/altera/socfpga/sdram/sdram_config.h          |  100 +
 board/altera/socfpga/sdram/sdram_io.h              |   44 +
 board/altera/socfpga/sdram/sequencer.c             | 7993
Quoted 2 lines

A general remark: SDRAM stuff should most likely reside in drivers/ddr/ , don't you think so ?

Yes, I suppose. Move it to drivers/ddr/altera?

Quoted 5 lines
Quoted 5 lines

++++++++++++++++++++ board/altera/socfpga/sdram/sequencer.h |
504 ++

 board/altera/socfpga/sdram/sequencer_auto.h        |  216 +
 .../altera/socfpga/sdram/sequencer_auto_ac_init.c  |   88 +

<snip>

Quoted 9 lines

board/altera/socfpga/sdram/sdram_config.h line 4

Quoted 5 lines
board/altera/socfpga/sdram/sdram_config.h new file +4 -0
@@ -0,0 +1,44 @@
+/*
+ * Copyright Altera Corporation (C) 2012-2014. All rights reserved
+ *
+ * SPDX-License-Identifier:    BSD-3-Clause

Any chance we can get these files under GPL-2.0+ ? It's not a showstopper, but it'd be nice :)

Quoted 8 lines

board/altera/socfpga/sdram/sdram_io.h line 10

Quoted 6 lines
board/altera/socfpga/sdram/sdram_io.h new file +6 -0
+ */
+
+#include <asm/io.h>
+
+#ifdef CONFIG_SPL_SERIAL_SUPPORT
+#define HPS_HW_SERIAL_SUPPORT

Are these redundant definitions really needed ?

Probably not, but I can check again.

Quoted 8 lines

board/altera/socfpga/sdram/sdram_io.h line 13

Quoted 4 lines
board/altera/socfpga/sdram/sdram_io.h new file +3 -0
+#endif
+
+#define	HPS_SDR_BASE		SOCFPGA_SDR_ADDRESS

This here as well, just use SOCFPGA_SDR_ADDRESS in the code. Besides, it'd be nice to consistently use <space> after #define keyword.

Quoted 10 lines

board/altera/socfpga/sdram/sdram_io.h line 21

Quoted 8 lines
board/altera/socfpga/sdram/sdram_io.h new file +8 -0
+#define MGR_SELECT_MASK		0xf8000
+
+#define APB_BASE_SCC_MGR	SDR_PHYGRP_SCCGRP_ADDRESS
+#define APB_BASE_PHY_MGR	SDR_PHYGRP_PHYMGRGRP_ADDRESS
+#define APB_BASE_RW_MGR		SDR_PHYGRP_RWMGRGRP_ADDRESS
+#define APB_BASE_DATA_MGR	SDR_PHYGRP_DATAMGRGRP_ADDRESS
+#define APB_BASE_REG_FILE	SDR_PHYGRP_REGFILEGRP_ADDRESS
+#define APB_BASE_MMR		SDR_CTRLGRP_ADDRESS

More redundancy here.

Will fix in v2.

Quoted 10 lines
Quoted 10 lines
board/altera/socfpga/sdram/sdram_io.h new file +9 -0
+#define __AVL_TO_APB(ADDR) \
+	((((ADDR) & MGR_SELECT_MASK) == (BASE_PHY_MGR))  ? \
+	(APB_BASE_PHY_MGR)  | (((ADDR) >> (14-6)) & (0x1<<6))  | \
+	((ADDR) & 0x3f) : \
+	(((ADDR) & MGR_SELECT_MASK) == (BASE_RW_MGR))   ? \
+	(APB_BASE_RW_MGR)   | ((ADDR) & 0x1fff) : \
+	(((ADDR) & MGR_SELECT_MASK) == (BASE_DATA_MGR)) ? \
+	(APB_BASE_DATA_MGR) | ((ADDR) & 0x7ff) : \
+	(((ADDR) & MGR_SELECT_MASK) == (BASE_SCC_MGR))  ? \
Quoted 8 lines

board/altera/socfpga/sdram/sdram_io.h line 37

Quoted 6 lines
board/altera/socfpga/sdram/sdram_io.h new file +6 -0
+	(APB_BASE_SCC_MGR)  | ((ADDR) & 0xfff) : \
+	(((ADDR) & MGR_SELECT_MASK) == (BASE_REG_FILE)) ? \
+	(APB_BASE_REG_FILE) | ((ADDR) & 0x7ff) : \
+	(((ADDR) & MGR_SELECT_MASK) == (BASE_MMR))      ? \
+	(APB_BASE_MMR)      | ((ADDR) & 0xfff) : -1)
+

This stuff here should be a function, to get a proper typechecking on it.

Ok.

Quoted 13 lines

board/altera/socfpga/sdram/sdram_io.h line 43

Quoted 7 lines
board/altera/socfpga/sdram/sdram_io.h new file +6 -0
+#define IOWR_32DIRECT(BASE, OFFSET, DATA) \
+	writel(DATA, HPS_SDR_BASE + __AVL_TO_APB((uint32_t)((BASE) + \
+	(OFFSET))))
+
+#define IORD_32DIRECT(BASE, OFFSET) \
+	readl(HPS_SDR_BASE + __AVL_TO_APB((uint32_t)((BASE) + (OFFSET))))

OK, these macros look really questionable. You might want to make them into a function too, but before you do so, I'd rather suggest you rethink this entire _AVL_TO_APB usage and make this entire section more readable. The code is really confusing here.

Will look to fix in V2.

Quoted 45 lines
Quoted 45 lines
(quoted diff) +1 -0
+
(quoted diff) +0 -0

b/board/altera/socfpga/sdram/sequencer.c new file mode 100644 index 0000000..c0ba0e5

board/altera/socfpga/sdram/sequencer.c new file +19 -0
@@ -0,0 +1,7993 @@
+/*
+ * Copyright Altera Corporation (C) 2012-2014. All rights reserved
+ *
+ * SPDX-License-Identifier:    BSD-3-Clause
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/sdram.h>
+#include "sdram_io.h"
+#include "sequencer.h"
+#include "sequencer_auto.h"
+#include "sequencer_defines.h"
+#include "system.h"
+
+static void scc_mgr_load_dqs_for_write_group(uint32_t write_group);
+static void rw_mgr_mem_dll_lock_wait(void);
+
+/*************************************************************************

***** +
**************************************************************************
**** + ** NOTE: Special Rules for Globale Variables
** + **
** + ** All global variables that are explicitly initialized
(including ** + ** explicitly initialized to zero), are only
initialized once, during ** + ** configuration time, and not again
on reset. This means that they ** + ** preserve their current
contents across resets, which is needed for some ** + ** special cases
involving communication with external modules. In ** + **
addition, this avoids paying the price to have the memory initialized, ** + ** even for zeroed data, provided it is explicitly set to zero in the code, ** + ** and doesn't rely on implicit initialization.

            ** +

**************************************************************************
**** +
**************************************************************************
****/ +
+#if ARRIAV

Quoted 8 lines

board/altera/socfpga/sdram/sequencer.c line 40

Quoted 6 lines
board/altera/socfpga/sdram/sequencer.c new file +6 -0
+/*
+ * Temporary workaround to place the initial stack pointer at a safe
+ * offset from end
+ */
+#define STRINGIFY(s)		STRINGIFY_STR(s)
+#define STRINGIFY_STR(s)	#s

There's already a macro named __stringify(), no need to duplicate it here.

Ok.

Quoted 7 lines
Quoted 4 lines
board/altera/socfpga/sdram/sequencer.c new file +3 -0
+asm(".global __alt_stack_pointer");
+asm("__alt_stack_pointer = " STRINGIFY(STACK_POINTER));
+#endif

[...]

Quoted 13 lines

board/altera/socfpga/sdram/sequencer.c line 133

Quoted 10 lines
board/altera/socfpga/sdram/sequencer.c new file +6 -0
+/* For HPS running on actual hardware */
+
+#define DLEVEL 0
+#ifdef HPS_HW_SERIAL_SUPPORT
+/*
+ * space around comma is required for varargs macro to remove comma if

args + * is empty
+ */

board/altera/socfpga/sdram/sequencer.c new file +2 -0
+#define DPRINT(level, fmt, args...)	if (DLEVEL >= (level)) \
+					printf("SEQ.C: " fmt "\n" , ## args)

This could just use __FILE__ instead of hard-coding seq.c (which is not even the filename anymore) .

Ok..

Quoted 18 lines
Quoted 2 lines

+#define IPRINT(fmt, args...) printf("SEQ.C: " fmt "\n" , ##

args)

board/altera/socfpga/sdram/sequencer.c line 146

Quoted 12 lines
board/altera/socfpga/sdram/sequencer.c new file +12 -0
+#else
+#define DPRINT(level, fmt, args...)
+#define IPRINT(fmt, args...)
+#endif
+#define BFM_GBL_SET(field, value)
+#define BFM_GBL_GET(field)		((long unsigned int)0)
+#define BFM_STAGE(stage)
+#define BFM_INC_VFIFO
+#define COV(label)
+
+#define TRACE_FUNC(fmt, args...) \
+	DPRINT(1, "%s[%d]: " fmt, __func__, __LINE__ , ## args)

I suspect you can use debug() or debug_cond() macro to avoid re-implementing the entire debug infrastructure here ;-)

Will fix up in V2.

Quoted 33 lines

[...]

board/altera/socfpga/sdram/sequencer.c line 243

Quoted 6 lines
board/altera/socfpga/sdram/sequencer.c new file +6 -0
+void wait_di_buffer(void)
+{
+	if (debug_data->di_report.cur_samples == NUM_DI_SAMPLE)	{
+		debug_data->di_report.flags |= DI_REPORT_FLAGS_READY;
+		while (debug_data->di_report.cur_samples != 0)
+			;

Please get rid of such endless loops, since the platform might get stuck forever in them.

Quoted 3 lines
board/altera/socfpga/sdram/sequencer.c new file +3 -0
+		debug_data->di_report.flags = 0;
+	}
+}

[...]

Quoted 15 lines
(quoted diff) +0 -0

b/board/altera/socfpga/sdram/sequencer.h new file mode 100644 index 0000000..ce4c7bf

board/altera/socfpga/sdram/sequencer.h new file +9 -0
@@ -0,0 +1,504 @@
+/*
+ * Copyright Altera Corporation (C) 2012-2014. All rights reserved
+ *
+ * SPDX-License-Identifier:    BSD-3-Clause
+ */
+
+#ifndef _SEQUENCER_H_
+#define _SEQUENCER_H_
+
Quoted 8 lines

board/altera/socfpga/sdram/sequencer.h line 13

Quoted 4 lines
board/altera/socfpga/sdram/sequencer.h new file +4 -0
+extern int32_t inst_rom_init_size;
+extern uint32_t inst_rom_init[];
+extern uint32_t ac_rom_init_size;
+extern uint32_t ac_rom_init[];

Extern variables usually mean the code is not well contained. You might want to review whether making these variables visible globally is really needed or not.

Will fix up in V2.

Quoted 6 lines
Quoted 4 lines
board/altera/socfpga/sdram/sequencer.h new file +2 -0
+#if ENABLE_ASSERT
+#define ERR_IE_TEXT "Internal Error: Sub-system: %s, File: %s, Line:

%d\n%s%s"

This might just use debug_cond() in some way, no ?

Probably...

Quoted 7 lines

board/altera/socfpga/sdram/sequencer.h line 19

Quoted 4 lines
board/altera/socfpga/sdram/sequencer.h new file +2 -0
+extern void err_report_internal_error(const char *description,
+	const char *module, const char *file, int line);

In case of functions, the extern is really not needed. Just define the prototype without the extern keyword.

Ok.

Quoted 13 lines

board/altera/socfpga/sdram/sequencer.h line 30

Quoted 11 lines
board/altera/socfpga/sdram/sequencer.h new file +10 -0
+#define ALTERA_INTERNAL_ERROR(string) \
+	{err_report_internal_error(string, "SEQ", __FILE__, __LINE__); \
+	exit(-1); }
+
+#define ALTERA_ASSERT(condition) \
+	if (!(condition)) {\
+		ALTERA_INTERNAL_ERROR(#condition); }
+#define ALTERA_INFO_ASSERT(condition, text) \
+	if (!(condition)) {\
+		ALTERA_INTERNAL_ERROR(text); }

Oh wow, debug_cond() would help, really ;-)

Ok..

Quoted 20 lines
Quoted 5 lines
board/altera/socfpga/sdram/sequencer.h new file +4 -0
+#else
+
+#define ALTERA_ASSERT(condition)
+#define ALTERA_INFO_ASSERT(condition, text)

[...]

Quoted 12 lines
board/altera/socfpga/sdram/sequencer.h new file +10 -0
+
+#if LRDIMM
+/* USER RTT_NOM: bits {4,3,2} of the SPD = bits {9,6,2} of the MR */
+#define LRDIMM_SPD_MR_RTT_NOM(spd_byte)                              \
+	((((spd_byte) & (1 << 4)) << (9-4))                       \
+	| (((spd_byte) & (1 << 3)) << (6-3))                         \
+	| (((spd_byte) & (1 << 2)) << (2-2)))
+
+/* USER RTT_DRV: bits {1,0} of the SPD = bits {5,1} of the MR */
+#define LRDIMM_SPD_MR_RTT_DRV(spd_byte)                                  

\ + ((((spd_byte) & (1 << 1)) << (5-1)) \

board/altera/socfpga/sdram/sequencer.h new file +1 -0
+	| (((spd_byte) & (1 << 0)) << (1-0)))
Quoted 8 lines
Quoted 4 lines
board/altera/socfpga/sdram/sequencer.h new file +3 -0
+
+/* USER RTT_WR: bits {7,6} of the SPD = bits {10,9} of the MR */
+#define LRDIMM_SPD_MR_RTT_WR(spd_byte)                                   

\ + (((spd_byte) & (3 << 6)) << (9-6))

We already have multiple SPD parsers in U-Boot (git grep 'spd' should give you an idea , for example see common/ddr_spd.c ). Could that be used to replace your SPD code ? I might be wrong here, so please correct me if I am ... :)

Ok..

Quoted 13 lines

board/altera/socfpga/sdram/sequencer.h line 87

Quoted 11 lines
board/altera/socfpga/sdram/sequencer.h new file +10 -0
+#endif /* LRDIMM */
+#endif /* DDR3 */
+
+#define RW_MGR_MEM_NUMBER_OF_RANKS	1
+#define NUM_SHADOW_REGS			1
+
+#define RW_MGR_LOAD_CNTR_0		(BASE_RW_MGR + 0x0800)
+#define RW_MGR_LOAD_CNTR_1		(BASE_RW_MGR + 0x0804)
+#define RW_MGR_LOAD_CNTR_2		(BASE_RW_MGR + 0x0808)
+#define RW_MGR_LOAD_CNTR_3		(BASE_RW_MGR + 0x080C)

Can you please rework these register definitions to struct-based ones?

Ok..

Quoted 5 lines

[...]

Thank you for all the work you put into this !

Really appreciate all the comments.

Dinh

#7 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

Quoted 19 lines · Dinh Nguyen
Quoted 18 lines · Marek Vasut
Quoted 1 line · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Hi!

Quoted 11 lines

This adds the code to configure the SDRAM controller that is found in the SoCFGPA Cyclone5 and Arria5 platforms.

---
  arch/arm/cpu/armv7/socfpga/config.mk               |    3 +-
  board/altera/socfpga/Makefile                      |    1 +
  board/altera/socfpga/sdram/Makefile                |   12 +
  board/altera/socfpga/sdram/sdram_config.h          |  100 +
  board/altera/socfpga/sdram/sdram_io.h              |   44 +
  board/altera/socfpga/sdram/sequencer.c             | 7993
Quoted 4 lines
Quoted 2 lines

A general remark: SDRAM stuff should most likely reside in drivers/ddr/ , don't you think so ?

Yes, I suppose. Move it to drivers/ddr/altera?

Yes, this looks reasonable.

Thanks,
Stefan

#8 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

In reply to dinguyen at opensource.altera.com

Hi!

Quoted 17 lines

From: Dinh Nguyen <[email protected]>

This adds the code to configure the SDRAM controller that is found in the SoCFGPA Cyclone5 and Arria5 platforms.

+/******************************************************************************
+ ******************************************************************************

+ ** NOTE: Special Rules for Globale Variables                                **
+ **                                                                          **
+ ** All global variables that are explicitly initialized (including          **
+ ** explicitly initialized to zero), are only initialized once, during       **
+ ** configuration time, and not again on reset.  This means that they        **
+ ** preserve their current contents across resets, which is needed for some  **
+ ** special cases involving communication with external modules.  In         **
+ ** addition, this avoids paying the price to have the memory initialized,   **
Quoted 4 lines

+ ** even for zeroed data, provided it is explicitly set to zero in the code, **
+ ** and doesn't rely on implicit initialization. **
+ ******************************************************************************
+ ******************************************************************************/

Comment coding style, please?

And they not globale variables.

But more importantly: is it good idea? What state is shared over reset? What are the special cases this is needed for?

What happens, when kernel corrupts that state?

Quoted 11 lines

+/*
+ * case:56390
+ * VFIFO_CONTROL_WIDTH_PER_DQS is the number of VFIFOs actually instantiated
+ * per DQS. This is always one except:
+ * AV QDRII where it is 2 for x18 and x18w2, and 4 for x36 and x36w2
+ * RLDRAMII x36 and x36w2 where it is 2.
+ * In 12.0sp1 we set this to 4 for all of the special cases above to
+ * keep it simple.
+ * In 12.0sp2 or 12.1 this should get moved to generation and unified with
+ * the same constant used in the phy mgr
+ */

Does case: refer to something public?

board/altera/socfpga/sdram/sequencer.c line 883

Quoted 10 lines
board/altera/socfpga/sdram/sequencer.c new file +10 -0
+/*
+ * Given a rank, select the set of shadow registers that is responsible
+ * for the delays of such rank, so that subsequent SCC updates will
+ * go to those shadow registers.
+ */
+void select_shadow_regs_for_update(uint32_t rank, uint32_t group,
+	uint32_t update_scan_chains)
+{
+#if USE_SHADOW_REGS
+	uint32_t rank_one_hot = (0xFF & (1 << rank));

Does this need to be configurable?

Best regards,

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#9 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

In reply to dinguyen at opensource.altera.com

Hi!

Quoted 1 line

+#if ENABLE_BRINGUP_DEBUGGING

Could we get rid of this for initial merge?

board/altera/socfpga/sdram/sequencer.c line 415

Quoted 4 lines
board/altera/socfpga/sdram/sequencer.c new file +4 -0
+static inline void reg_file_set_sub_stage(uint32_t set_sub_stage)
+{
+	/* Read the current group and stage */
+	uint32_t cur_stage_group = IORD_32DIRECT(REG_FILE_CUR_STAGE, 0);

Could normal u-boot memory access macros be used here?

Thanks,

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#10 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

Quoted 5 lines · Pavel Machek

Hi!

Quoted 1 line

+#if ENABLE_BRINGUP_DEBUGGING

Could we get rid of this for initial merge?

Yeah, it can be removed.

Quoted 8 lines

board/altera/socfpga/sdram/sequencer.c line 415

Quoted 5 lines
board/altera/socfpga/sdram/sequencer.c new file +4 -0
+static inline void reg_file_set_sub_stage(uint32_t set_sub_stage)
+{
+	/* Read the current group and stage */
+	uint32_t cur_stage_group = IORD_32DIRECT(REG_FILE_CUR_STAGE, 0);

Could normal u-boot memory access macros be used here?

I'll look..

Dinh

#11 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

Quoted 12 lines · Dinh Nguyen
Quoted 5 lines · Pavel Machek

Hi!

Quoted 1 line

+#if ENABLE_BRINGUP_DEBUGGING

Could we get rid of this for initial merge?

Yeah, it can be removed.

Quoted 1 line
Quoted 8 lines
Quoted 7 lines

board/altera/socfpga/sdram/sequencer.c line 415

Quoted 4 lines
board/altera/socfpga/sdram/sequencer.c new file +4 -0
+static inline void reg_file_set_sub_stage(uint32_t set_sub_stage)
+{
+	/* Read the current group and stage */
+	uint32_t cur_stage_group = IORD_32DIRECT(REG_FILE_CUR_STAGE, 0);

Could normal u-boot memory access macros be used here?

I'll look..

Actually, I'm reworking this whole IORD_* that uses the AVL_TO_APB to a function. This was already commented by Marek.

Dinh

#12 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

Quoted 17 lines · Dinh Nguyen
Quoted 16 lines · Dinh Nguyen
Quoted 5 lines · Pavel Machek

Hi!

Quoted 1 line

+#if ENABLE_BRINGUP_DEBUGGING

Could we get rid of this for initial merge?

Yeah, it can be removed.

Quoted 6 lines

board/altera/socfpga/sdram/sequencer.c line 415

Quoted 4 lines
board/altera/socfpga/sdram/sequencer.c new file +4 -0
+static inline void reg_file_set_sub_stage(uint32_t set_sub_stage)
+{
+	/* Read the current group and stage */
+	uint32_t cur_stage_group = IORD_32DIRECT(REG_FILE_CUR_STAGE, 0);

Could normal u-boot memory access macros be used here?

Quoted 4 lines
Quoted 1 line

I'll look..

Actually, I'm reworking this whole IORD_* that uses the AVL_TO_APB to a function. This was already commented by Marek.

If this can be switched to regular readl()/writel() stuff, then please do so, since that'd be much less confusing.

Best regards,
Marek Vasut

#13 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

Quoted 18 lines · Marek Vasut
Quoted 17 lines · Dinh Nguyen
Quoted 16 lines · Dinh Nguyen
Quoted 5 lines · Pavel Machek

Hi!

Quoted 1 line

+#if ENABLE_BRINGUP_DEBUGGING

Could we get rid of this for initial merge?

Yeah, it can be removed.

Quoted 6 lines

board/altera/socfpga/sdram/sequencer.c line 415

Quoted 4 lines
board/altera/socfpga/sdram/sequencer.c new file +4 -0
+static inline void reg_file_set_sub_stage(uint32_t set_sub_stage)
+{
+	/* Read the current group and stage */
+	uint32_t cur_stage_group = IORD_32DIRECT(REG_FILE_CUR_STAGE, 0);

Could normal u-boot memory access macros be used here?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I'll look..

Actually, I'm reworking this whole IORD_* that uses the AVL_TO_APB to a function. This was already commented by Marek.

If this can be switched to regular readl()/writel() stuff, then please do so, since that'd be much less confusing.

Yes, that is what I've done.

Dinh

#14 lore raw

PATCH 1/22 arm: socfpga: spl: Add main sdram code

Quoted 21 lines · Dinh Nguyen
Quoted 20 lines · Marek Vasut
Quoted 19 lines · Dinh Nguyen
Quoted 17 lines · Dinh Nguyen
Quoted 5 lines · Pavel Machek

Hi!

Quoted 1 line

+#if ENABLE_BRINGUP_DEBUGGING

Could we get rid of this for initial merge?

Yeah, it can be removed.

Quoted 6 lines

board/altera/socfpga/sdram/sequencer.c line 415

Quoted 4 lines
board/altera/socfpga/sdram/sequencer.c new file +4 -0
+static inline void reg_file_set_sub_stage(uint32_t set_sub_stage)
+{
+	/* Read the current group and stage */
+	uint32_t cur_stage_group = IORD_32DIRECT(REG_FILE_CUR_STAGE, 0);

Could normal u-boot memory access macros be used here?

I'll look..

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Actually, I'm reworking this whole IORD_* that uses the AVL_TO_APB to a function. This was already commented by Marek.

If this can be switched to regular readl()/writel() stuff, then please do so, since that'd be much less confusing.

Yes, that is what I've done.

Thank you :) Looking forward to reviewing the V2 of the patches !

Best regards,
Marek Vasut

#15 lore raw

PATCH 2/22 arm: socfpga: enable saveenv to mmc partition

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Cc Marek Vasut <[email protected]>
Cc Tom Rini <[email protected]>
Cc Pavel Machek <[email protected]>
---
 include/configs/socfpga_common.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
include/configs/socfpga_common.h +4 -1
index 6b1f967..673377b 100644
@@ -281,9 +281,12 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
 #define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
 #define CONFIG_SYS_CONSOLE_ENV_OVERWRITE
-#define CONFIG_ENV_IS_NOWHERE
 #define CONFIG_ENV_SIZE			4096
 
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV		0/* device 0 */
+#define CONFIG_ENV_OFFSET		512/* just after the MBR */
+
 /*
  * SPL
  *
Signature · 1 line
2.2.1
#16 lore raw

PATCH 2/22 arm: socfpga: enable saveenv to mmc partition

Quoted 15 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Cc Marek Vasut <[email protected]>
Cc Tom Rini <[email protected]>
Cc Pavel Machek <[email protected]>
---
 include/configs/socfpga_common.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/include/configs/socfpga_common.h index 6b1f967..673377b 100644

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 287

Quoted 8 lines
include/configs/socfpga_common.h +2 -1
@@ -281,9 +281,12 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
 #define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
 #define CONFIG_SYS_CONSOLE_ENV_OVERWRITE
-#define CONFIG_ENV_IS_NOWHERE
 #define CONFIG_ENV_SIZE			4096
 
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV		0/* device 0 */

Hi!

Please at least put a TAB between the number and the comment, so that the code looks tidy and readable.

It would also be nice to split the SPL stuff and "generic" stuff into separate patch (series), since this would allow generic stuff like this patch to go in first.

Thanks!

Best regards,
Marek Vasut

#17 lore raw

PATCH 2/22 arm: socfpga: enable saveenv to mmc partition

In reply to dinguyen at opensource.altera.com

Hi!

Quoted 15 lines

From: Dinh Nguyen <[email protected]>

Cc Marek Vasut <[email protected]>
Cc Tom Rini <[email protected]>
Cc Pavel Machek <[email protected]>
---
 include/configs/socfpga_common.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
include/configs/socfpga_common.h +0 -0
index 6b1f967..673377b 100644

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 289

Quoted 10 lines
include/configs/socfpga_common.h +4 -1
@@ -281,9 +281,12 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
 #define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
 #define CONFIG_SYS_CONSOLE_ENV_OVERWRITE
-#define CONFIG_ENV_IS_NOWHERE
 #define CONFIG_ENV_SIZE			4096
 
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV		0/* device 0 */
+#define CONFIG_ENV_OFFSET		512/* just after the MBR */
+

Would it make sense to make environment bigger (64K?) at this point, and enabling the redundant environment option, so that one bad block does not bring the whole device down?

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#18 lore raw

PATCH 2/22 arm: socfpga: enable saveenv to mmc partition

Quoted 1 line · Pavel Machek

Hi!

Hi!

Quoted 25 lines
Quoted 25 lines

From: Dinh Nguyen <[email protected]>

Cc Marek Vasut <[email protected]>
Cc Tom Rini <[email protected]>
Cc Pavel Machek <[email protected]>

---

 include/configs/socfpga_common.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/include/configs/socfpga_common.h index 6b1f967..673377b 100644

include/configs/socfpga_common.h +0 -1
@@ -281,9 +281,12 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
 #define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
 #define CONFIG_SYS_CONSOLE_ENV_OVERWRITE
 
-#define CONFIG_ENV_IS_NOWHERE
 
 #define CONFIG_ENV_SIZE			4096
 
Quoted 8 lines

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 289

Quoted 4 lines
include/configs/socfpga_common.h +4 -0
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV		0/* device 0 */
+#define CONFIG_ENV_OFFSET		512/* just after the MBR */
+

Would it make sense to make environment bigger (64K?) at this point, and enabling the redundant environment option, so that one bad block does not bring the whole device down?

Do you think you'll ever have more than a 4KiB of text data in the env ? I can see a reason for some 16 KiB environment, but that's the ceiling.

Usually, the env only has to be a few KiB and it's size has to be multiple of the underlying device's erase block. But in case of SD card, there are no explicit erase blocks exported to the user, all is hidden by the controller in the SD card and gives an illusion of a device which has 512b blocks and the user doesn't care for bad block management. Since the controller in the card does the bad block management and wear leveling/relocation of blocks, it also means that in case the controller did fail to provide the block which contains env, the whole card would already be in a very bad state.

Best regards,
Marek Vasut

#19 lore raw

PATCH 2/22 arm: socfpga: enable saveenv to mmc partition

Quoted 24 lines · Marek Vasut
Quoted 14 lines · Pavel Machek
Quoted 14 lines
(quoted diff) +0 -0

b/include/configs/socfpga_common.h index 6b1f967..673377b 100644

include/configs/socfpga_common.h +0 -1
@@ -281,9 +281,12 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 
  #define CONFIG_SYS_CONSOLE_IS_IN_ENV
  #define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
  #define CONFIG_SYS_CONSOLE_ENV_OVERWRITE
 
-#define CONFIG_ENV_IS_NOWHERE
 
  #define CONFIG_ENV_SIZE			4096
 
Quoted 8 lines

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 289

Quoted 4 lines
include/configs/socfpga_common.h +4 -0
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV		0/* device 0 */
+#define CONFIG_ENV_OFFSET		512/* just after the MBR */
+

Would it make sense to make environment bigger (64K?) at this point, and enabling the redundant environment option, so that one bad block does not bring the whole device down?

Quoted 1 line

Do you think you'll ever have more than a 4KiB of text data in the env ?

I have used bigger environment in some cases.

Quoted 1 line

I can see a reason for some 16 KiB environment, but that's the ceiling.

Then lets switch to at least 8KiB please.

Pavel, would be 8KiB enough for your project?

Quoted 8 lines

Usually, the env only has to be a few KiB and it's size has to be multiple of the underlying device's erase block. But in case of SD card, there are no explicit erase blocks exported to the user, all is hidden by the controller in the SD card and gives an illusion of a device which has 512b blocks and the user doesn't care for bad block management. Since the controller in the card does the bad block management and wear leveling/relocation of blocks, it also means that in case the controller did fail to provide the block which contains env, the whole card would already be in a very bad state.

Right. Nevertheless it makes sense to support the redundant envrionment (at least from my point of view), regardless of the device the evironment is stored in. Thinking for example about power-supply failure (power-cut) while writing into the one envrionment version.

Thanks,
Stefan

#20 lore raw

PATCH 2/22 arm: socfpga: enable saveenv to mmc partition

On Friday, January 16, 2015 at 05:50:18 AM, Stefan Roese wrote:

Hi!

Quoted 24 lines
Quoted 5 lines
Quoted 3 lines

Would it make sense to make environment bigger (64K?) at this point, and enabling the redundant environment option, so that one bad block does not bring the whole device down?

Do you think you'll ever have more than a 4KiB of text data in the env ?

I have used bigger environment in some cases.

Quoted 1 line

I can see a reason for some 16 KiB environment, but that's the ceiling.

Then lets switch to at least 8KiB please.

Pavel, would be 8KiB enough for your project?

Quoted 9 lines

Usually, the env only has to be a few KiB and it's size has to be multiple of the underlying device's erase block. But in case of SD card, there are no explicit erase blocks exported to the user, all is hidden by the controller in the SD card and gives an illusion of a device which has 512b blocks and the user doesn't care for bad block management. Since the controller in the card does the bad block management and wear leveling/relocation of blocks, it also means that in case the controller did fail to provide the block which contains env, the whole card would already be in a very bad state.

Quoted 4 lines

Right. Nevertheless it makes sense to support the redundant envrionment (at least from my point of view), regardless of the device the evironment is stored in. Thinking for example about power-supply failure (power-cut) while writing into the one envrionment version.

That's a fine idea, you're right :)

Best regards,
Marek Vasut

#21 lore raw

PATCH 2/22 arm: socfpga: enable saveenv to mmc partition

In reply to Marek Vasut

Hi!

Quoted 13 lines
Quoted 4 lines
Quoted 4 lines

-#define CONFIG_ENV_IS_NOWHERE

#define CONFIG_ENV_SIZE 4096

Quoted 8 lines

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 289

Quoted 4 lines
include/configs/socfpga_common.h +4 -0
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV		0/* device 0 */
+#define CONFIG_ENV_OFFSET		512/* just after the MBR */
+

Would it make sense to make environment bigger (64K?) at this point, and enabling the redundant environment option, so that one bad block does not bring the whole device down?

Quoted 3 lines

Do you think you'll ever have more than a 4KiB of text data in the env ? I can see a reason for some 16 KiB environment, but that's the ceiling.

We have hit 4KiB size already, and I believe we are over 8KiB, even. wagabuibui loads a lot of small files from flash.

So if 16KiB is acceptable, lets do that.

Quoted 5 lines

Usually, the env only has to be a few KiB and it's size has to be multiple of the underlying device's erase block. But in case of SD card, there are no explicit erase blocks exported to the user, all is hidden by the controller in the SD card and gives an illusion of a device which has 512b blocks and

Allocation unit is usually 2, 4, 6, 8, 12 or 16 MiB on recent flash cards. It is field in uSD card structure somewhere. We could choose 24MiB, to have GCD, but... see:

https://wiki.linaro.org/WorkingGroups/KernelArchived/Projects/FlashCardSurvey

Quoted 4 lines

the user doesn't care for bad block management. Since the controller in the card does the bad block management and wear leveling/relocation of blocks, it also means that in case the controller did fail to provide the block which contains env, the whole card would already be in a very bad state.

Bad block management means you don't get errors during write, but you can still get errors during read.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#22 lore raw

PATCH 2/22 arm: socfpga: enable saveenv to mmc partition

Quoted 18 lines · Pavel Machek

Hi!

Quoted 16 lines
Quoted 4 lines
Quoted 4 lines

-#define CONFIG_ENV_IS_NOWHERE

#define CONFIG_ENV_SIZE 4096

Quoted 8 lines

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 289

Quoted 4 lines
include/configs/socfpga_common.h +4 -0
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV		0/* device 0 */
+#define CONFIG_ENV_OFFSET		512/* just after the MBR */
+

Would it make sense to make environment bigger (64K?) at this point, and enabling the redundant environment option, so that one bad block does not bring the whole device down?

Do you think you'll ever have more than a 4KiB of text data in the env ? I can see a reason for some 16 KiB environment, but that's the

Quoted 6 lines
Quoted 1 line

ceiling.

We have hit 4KiB size already, and I believe we are over 8KiB, even. wagabuibui loads a lot of small files from flash.

So if 16KiB is acceptable, lets do that.

16KiB is fine by me, though I'm not quite sure how you managed to stuff 8KiB full of env ;-)

Quoted 7 lines
Quoted 6 lines

Usually, the env only has to be a few KiB and it's size has to be multiple of the underlying device's erase block. But in case of SD card, there are no explicit erase blocks exported to the user, all is hidden by the controller in the SD card and gives an illusion of a device which has 512b
blocks and

Quoted 6 lines

Allocation unit is usually 2, 4, 6, 8, 12 or 16 MiB on recent flash cards. It is field in uSD card structure somewhere. We could choose 24MiB, to have GCD, but... see:

https://wiki.linaro.org/WorkingGroups/KernelArchived/Projects/FlashCardSurv
ey

OK, this is even more precise. Thanks for the link.

Quoted 8 lines
Quoted 5 lines

the user doesn't care for bad block management. Since the controller in the card does the bad block management and wear leveling/relocation of blocks, it also means that in case the controller did fail to provide the block which contains env, the whole card would already be in a very bad state.

Bad block management means you don't get errors during write, but you can still get errors during read.

That in fact depends on the BBM implementation, but in case you get error during read, it's usually a game over kind of situation. But I agree.

Best regards,
Marek Vasut

#23 lore raw

PATCH 3/22 arm: socfpga: Add sdram initialization code

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add SDRAM initialization for the SOCFPGA platform.

---
 arch/arm/cpu/armv7/socfpga/Makefile       |    2 +-
 arch/arm/cpu/armv7/socfpga/sdram.c        | 1311 +++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-socfpga/sdram.h |  434 ++++++++++
 include/configs/socfpga_cyclone5.h        |    1 +
 4 files changed, 1747 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/socfpga/sdram.c
 create mode 100644 arch/arm/include/asm/arch-socfpga/sdram.h
arch/arm/cpu/armv7/socfpga/Makefile +1 -1
index 8b6e108..9bd649d 100644
@@ -9,5 +9,5 @@
 
 obj-y	:= lowlevel_init.o
 obj-y	+= misc.o timer.o reset_manager.o system_manager.o clock_manager.o \
-	   fpga_manager.o
+	   fpga_manager.o sdram.o
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o scan_manager.o
arch/arm/cpu/armv7/socfpga/sdram.c new file +1311 -0

1,311 lines not on this page · raw message

arch/arm/include/asm/arch-socfpga/sdram.h new file +434 -0

434 lines not on this page · raw message

include/configs/socfpga_cyclone5.h +1 -0
index c3d958c..5dce54a 100644
@@ -10,6 +10,7 @@
 #include "../../board/altera/socfpga/pinmux_config.h"
 #include "../../board/altera/socfpga/iocsr_config.h"
 #include "../../board/altera/socfpga/pll_config.h"
+#include "../../board/altera/socfpga/sdram/sdram_config.h"
 
 /* U-Boot Commands */
 #define CONFIG_SYS_NO_FLASH
Signature · 1 line
2.2.1
#24 lore raw

PATCH 3/22 arm: socfpga: Add sdram initialization code

Quoted 5 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add SDRAM initialization for the SOCFPGA platform.

Quoted 9 lines
---
 arch/arm/cpu/armv7/socfpga/Makefile       |    2 +-
 arch/arm/cpu/armv7/socfpga/sdram.c        | 1311
+++++++++++++++++++++++++++++ arch/arm/include/asm/arch-socfpga/sdram.h | 
434 ++++++++++
 include/configs/socfpga_cyclone5.h        |    1 +
 4 files changed, 1747 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/socfpga/sdram.c
 create mode 100644 arch/arm/include/asm/arch-socfpga/sdram.h

Hi!

I suspect the same comments as for patch 02/22 apply here, so we can discuss them there :)

Best regards,
Marek Vasut

#25 lore raw

PATCH 4/22 arm: socfpga: spl: Add SRAM section

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add a section of SRAM to the SPL linker file.

---
 arch/arm/cpu/armv7/socfpga/u-boot-spl.lds | 2 ++
 include/configs/socfpga_common.h          | 1 +
 2 files changed, 3 insertions(+)
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +2 -0
index 569fa41..a868a36 100644
@@ -5,6 +5,8 @@
  */
 
 MEMORY { .sdram : ORIGIN = (0), LENGTH = (0xffffffff) }
+MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
+		LENGTH = CONFIG_SPL_MAX_SIZE }
 
 OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
 OUTPUT_ARCH(arm)
include/configs/socfpga_common.h +1 -0
index 673377b..0c87faa 100644
@@ -304,6 +304,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INIT_RAM_ADDR
 #define CONFIG_SYS_SPL_MALLOC_START	CONFIG_SYS_INIT_SP_ADDR
 #define CONFIG_SYS_SPL_MALLOC_SIZE	(5 * 1024)
+#define CONFIG_SPL_MAX_SIZE		(64 * 1024)
 
 #define CHUNKSZ_CRC32			(1 * 1024)	/* FIXME: ewww */
 #define CONFIG_CRC32_VERIFY
Signature · 1 line
2.2.1
#26 lore raw

PATCH 4/22 arm: socfpga: spl: Add SRAM section

Quoted 5 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add a section of SRAM to the SPL linker file.

Hi!

There's a generic SPL linker script at ./arch/arm/cpu/u-boot-spl.lds , would it be possible to use the generic one and zap the socfpga-specific one please ?

Best regards,
Marek Vasut

#27 lore raw

PATCH 4/22 arm: socfpga: spl: Add SRAM section

In reply to dinguyen at opensource.altera.com

Hi!

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 307

Quoted 9 lines
include/configs/socfpga_common.h +1 -0
index 673377b..0c87faa 100644
@@ -304,6 +304,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INIT_RAM_ADDR
 #define CONFIG_SYS_SPL_MALLOC_START	CONFIG_SYS_INIT_SP_ADDR
 #define CONFIG_SYS_SPL_MALLOC_SIZE	(5 * 1024)
+#define CONFIG_SPL_MAX_SIZE		(64 * 1024)

Is 64KiB right maximum size? IIRC, SPL image has to include headers...

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#28 lore raw

PATCH 5/22 arm: socfpga: spl: put SPL in sram

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Update SPL linker file to use SRAM.

---
 arch/arm/cpu/armv7/socfpga/u-boot-spl.lds | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +4 -4
index a868a36..730d154 100644
@@ -21,13 +21,13 @@ SECTIONS
 		*(.vectors)
 		arch/arm/cpu/armv7/start.o	(.text*)
 		*(.text*)
-	} >.sdram
+	} >.sram
 
 	. = ALIGN(4);
-	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } >.sdram
+	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } >.sram
 
 	. = ALIGN(4);
-	.data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sdram
+	.data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
 
 	. = ALIGN(4);
 	__image_copy_end = .;
@@ -43,5 +43,5 @@ SECTIONS
 		*(.bss*)
 		. = ALIGN(4);
 		__bss_end = .;
-	} >.sdram
+	} >.sram
 }
Signature · 1 line
2.2.1
#30 lore raw

PATCH 6/22 arm: socfpga: add functions to bring sdram, timer, and uart out of reset

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

These functions will be needed for use by the SPL for enabling the console and sdram initialization.

---
 arch/arm/cpu/armv7/socfpga/reset_manager.c        | 24 +++++++++++++++++++++++
 arch/arm/include/asm/arch-socfpga/reset_manager.h |  6 ++++++
 2 files changed, 30 insertions(+)
arch/arm/cpu/armv7/socfpga/reset_manager.c +24 -0
index 25921e7..45b352b 100644
@@ -113,3 +113,27 @@ void socfpga_spim_enable(void)
 	clrbits_le32(reset, (1 << RSTMGR_PERMODRST_SPIM0_LSB) |
 		     (1 << RSTMGR_PERMODRST_SPIM1_LSB));
 }
+
+/* Bring UART0 out of reset. */
+void socfpga_uart0_enable(void)
+{
+	const void *reset = &reset_manager_base->per_mod_reset;
+
+	clrbits_le32(reset, 1 << RSTMGR_PERMODRST_UART0_LSB);
+}
+
+/* Bring SDRAM controller out of reset. */
+void socfpga_sdram_enable(void)
+{
+	const void *reset = &reset_manager_base->per_mod_reset;
+
+	clrbits_le32(reset, 1 << RSTMGR_PERMODRST_SDR_LSB);
+}
+
+/* Bring OSC1 timer out of reset. */
+void socfpga_osc1timer_enable(void)
+{
+	const void *reset = &reset_manager_base->per_mod_reset;
+
+	clrbits_le32(reset, 1 << RSTMGR_PERMODRST_OSC1TIMER0_LSB);
+}
arch/arm/include/asm/arch-socfpga/reset_manager.h +6 -0
index 034135b..d63a285 100644
@@ -15,6 +15,9 @@ void socfpga_bridges_reset(int enable);
 void socfpga_emac_reset(int enable);
 void socfpga_watchdog_reset(void);
 void socfpga_spim_enable(void);
+void socfpga_uart0_enable(void);
+void socfpga_sdram_enable(void);
+void socfpga_osc1timer_enable(void);
 
 struct socfpga_reset_manager {
 	u32	status;
@@ -36,7 +39,10 @@ struct socfpga_reset_manager {
 #define RSTMGR_PERMODRST_EMAC0_LSB	0
 #define RSTMGR_PERMODRST_EMAC1_LSB	1
 #define RSTMGR_PERMODRST_L4WD0_LSB	6
+#define RSTMGR_PERMODRST_OSC1TIMER0_LSB	8
+#define RSTMGR_PERMODRST_UART0_LSB	16
 #define RSTMGR_PERMODRST_SPIM0_LSB	18
 #define RSTMGR_PERMODRST_SPIM1_LSB	19
+#define RSTMGR_PERMODRST_SDR_LSB	29
 
 #endif /* _RESET_MANAGER_H_ */
Signature · 1 line
2.2.1
#32 lore raw

PATCH 6/22 arm: socfpga: add functions to bring sdram, timer, and uart out of reset

In reply to dinguyen at opensource.altera.com
Quoted 6 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

These functions will be needed for use by the SPL for enabling the console and sdram initialization.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#33 lore raw

PATCH 7/22 arm: socfpga: spl: enable sdram, timer and uart

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 arch/arm/cpu/armv7/socfpga/spl.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/cpu/armv7/socfpga/spl.c +4 -0
index bd9f338..b123336 100644
@@ -145,6 +145,10 @@ void spl_board_init(void)
 	/* freeze all IO banks */
 	sys_mgr_frzctrl_freeze_req();
 
+	socfpga_sdram_enable();
+	socfpga_uart0_enable();
+	socfpga_osc1timer_enable();
+
 	debug("Reconfigure Clock Manager\n");
 	/* reconfigure the PLLs */
 	cm_basic_init(&cm_default_cfg);
Signature · 1 line
2.2.1
#34 lore raw

PATCH 7/22 arm: socfpga: spl: enable sdram, timer and uart

Quoted 1 line · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Commit message would not hurt here, but the Subject is already pretty clear about the purpose, so it's not a showstopper. It'd be nice to have though.

Quoted 1 line
Quoted 9 lines
---
 arch/arm/cpu/armv7/socfpga/spl.c | 4 ++++
 1 file changed, 4 insertions(+)
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/spl.c index bd9f338..b123336 100644

arch/arm/cpu/armv7/socfpga/spl.c void spl_board_init(void) · line 154

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/spl.c +4 -0
@@ -145,6 +145,10 @@ void spl_board_init(void)
 	/* freeze all IO banks */
 	sys_mgr_frzctrl_freeze_req();
 
+	socfpga_sdram_enable();
+	socfpga_uart0_enable();
+	socfpga_osc1timer_enable();
+
 	debug("Reconfigure Clock Manager\n");
 	/* reconfigure the PLLs */
 	cm_basic_init(&cm_default_cfg);

Best regards,
Marek Vasut

#36 lore raw

PATCH 8/22 arm: socfpga: spl: Add call to timer_init

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 arch/arm/cpu/armv7/socfpga/spl.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/cpu/armv7/socfpga/spl.c +2 -0
index b123336..bc6f8dd 100644
@@ -149,6 +149,8 @@ void spl_board_init(void)
 	socfpga_uart0_enable();
 	socfpga_osc1timer_enable();
 
+	timer_init();
+
 	debug("Reconfigure Clock Manager\n");
 	/* reconfigure the PLLs */
 	cm_basic_init(&cm_default_cfg);
Signature · 1 line
2.2.1
#37 lore raw

PATCH 8/22 arm: socfpga: spl: Add call to timer_init

Quoted 3 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

You might want to check common/spl/spl.c , which implements most of the standard SPL init procedure. It even includes the call to timer_init() there in board_init_r() . I wonder if you really need to call it here one more time. Do you ?

Best regards,
Marek Vasut

#38 lore raw

PATCH 8/22 arm: socfpga: spl: Add call to timer_init

Quoted 11 lines · Marek Vasut
Quoted 3 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

You might want to check common/spl/spl.c , which implements most of the standard SPL init procedure. It even includes the call to timer_init() there in board_init_r() . I wonder if you really need to call it here one more time. Do you ?

Your logic makes sense, but I think this timer_init() call in spl_board_init() is needed. The reason is that we are releasing the timer from reset in spl_board_init, and timer_init is getting called before spl_board_init. If I take out this timer_init, the SPL doesn't work so well.

Dinh

#39 lore raw

PATCH 9/22 arm: socfpga: spl: allow bootrom to enable IOs after warm reset

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 arch/arm/cpu/armv7/socfpga/spl.c                   | 3 +++
 arch/arm/cpu/armv7/socfpga/system_manager.c        | 9 +++++++++
 arch/arm/include/asm/arch-socfpga/system_manager.h | 1 +
 3 files changed, 13 insertions(+)
arch/arm/cpu/armv7/socfpga/spl.c +3 -0
index bc6f8dd..9ef2983 100644
@@ -155,6 +155,9 @@ void spl_board_init(void)
 	/* reconfigure the PLLs */
 	cm_basic_init(&cm_default_cfg);
 
+	/* Enable bootrom to configure IOs. */
+	sysmgr_enable_warmrstcfgio();
+
 	/* configure the IOCSR / IO buffer settings */
 	if (scan_mgr_configure_iocsr())
 		hang();
arch/arm/cpu/armv7/socfpga/system_manager.c +9 -0
index 11f7bad..8126e0d 100644
@@ -66,3 +66,12 @@ void sysmgr_pinmux_init(void)
 
 	populate_sysmgr_fpgaintf_module();
 }
+
+/*
+ * This bit allows the bootrom to configure the IOs after a warm reset.
+ */
+void sysmgr_enable_warmrstcfgio(void)
+{
+	setbits_le32(&sysmgr_regs->romcodegrp_ctrl,
+		     SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO);
+}
arch/arm/include/asm/arch-socfpga/system_manager.h +1 -0
index 071ec4f..51d9815 100644
@@ -10,6 +10,7 @@
 #ifndef __ASSEMBLY__
 
 void sysmgr_pinmux_init(void);
+void sysmgr_enable_warmrstcfgio(void);
 
 /* declaration for handoff table type */
 extern unsigned long sys_mgr_init_table[CONFIG_HPS_PINMUX_NUM];
Signature · 1 line
2.2.1
#41 lore raw

PATCH 9/22 arm: socfpga: spl: allow bootrom to enable IOs after warm reset

In reply to dinguyen at opensource.altera.com
Quoted 3 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

...Actually, you can merge this with 7/10, I guess. One 2000 lines patch + twenty 10 line patches is not "interesting" form of series :-).

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#42 lore raw

PATCH 9/22 arm: socfpga: spl: allow bootrom to enable IOs after warm reset

Quoted 9 lines · Pavel Machek
Quoted 3 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

...Actually, you can merge this with 7/10, I guess. One 2000 lines patch + twenty 10 line patches is not "interesting" form of series

I'd be much happier to see the series split properly and re-posted. Or at least please repost those parts of the series which can go in immediatelly, so the progress isn't entirely blocked by the large patches. Can you please do that ?

Best regards,
Marek Vasut

#43 lore raw

PATCH 10/22 arm: socfpga: spl: add sdram init and calibration

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add a call to checkboard along with sdram intilialization and calibration.

---
 arch/arm/cpu/armv7/socfpga/spl.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/cpu/armv7/socfpga/spl.c +10 -0
index 9ef2983..9481fd5 100644
@@ -16,6 +16,7 @@
 #include <asm/arch/freeze_controller.h>
 #include <asm/arch/clock_manager.h>
 #include <asm/arch/scan_manager.h>
+#include <asm/arch/sdram.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -175,4 +176,13 @@ void spl_board_init(void)
 
 	/* enable console uart printing */
 	preloader_console_init();
+
+	checkboard();
+
+	if (sdram_mmr_init_full(0xffffffff) != 0)
+		hang();
+	puts("SDRAM: Calibrating PHY\n");
+	/* SDRAM calibration */
+	if (sdram_calibration_full() == 0)
+		hang();
 }
Signature · 1 line
2.2.1
#44 lore raw

PATCH 10/22 arm: socfpga: spl: add sdram init and calibration

Quoted 22 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add a call to checkboard along with sdram intilialization and calibration.

---
 arch/arm/cpu/armv7/socfpga/spl.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/spl.c index 9ef2983..9481fd5 100644

arch/arm/cpu/armv7/socfpga/spl.c +1 -0
@@ -16,6 +16,7 @@
 #include <asm/arch/freeze_controller.h>
 #include <asm/arch/clock_manager.h>
 #include <asm/arch/scan_manager.h>
+#include <asm/arch/sdram.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 

arch/arm/cpu/armv7/socfpga/spl.c void spl_board_init(void) · line 183

Quoted 8 lines
arch/arm/cpu/armv7/socfpga/spl.c +5 -0
@@ -175,4 +176,13 @@ void spl_board_init(void)
 
 	/* enable console uart printing */
 	preloader_console_init();
+
+	checkboard();
+
+	if (sdram_mmr_init_full(0xffffffff) != 0)
+		hang();

You might want to print some debug output in case this fails, to inform the user that things have gone awry. Please correct me if the sdram_mmr_init_full() already does print it.

Thanks!

arch/arm/cpu/armv7/socfpga/spl.c void spl_board_init(void) · line 188

Quoted 5 lines
arch/arm/cpu/armv7/socfpga/spl.c +4 -0
+	puts("SDRAM: Calibrating PHY\n");
+	/* SDRAM calibration */
+	if (sdram_calibration_full() == 0)
+		hang();
 }

Best regards,
Marek Vasut

#45 lore raw

PATCH 10/22 arm: socfpga: spl: add sdram init and calibration

In reply to dinguyen at opensource.altera.com
Quoted 7 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add a call to checkboard along with sdram intilialization and calibration.

arch/arm/cpu/armv7/socfpga/spl.c +0 -0
 	/* enable console uart printing */
 	preloader_console_init();

arch/arm/cpu/armv7/socfpga/spl.c void spl_board_init(void) · line 188

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/spl.c +9 -0
+
+	checkboard();
+
+	if (sdram_mmr_init_full(0xffffffff) != 0)
+		hang();
+	puts("SDRAM: Calibrating PHY\n");
+	/* SDRAM calibration */
+	if (sdram_calibration_full() == 0)
+		hang();
 }

You might want to standartize on "== 0" ok, "< 0" errno returned....
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#46 lore raw

PATCH 11/22 arm: socfpga: spl: printout sdram size

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 arch/arm/cpu/armv7/socfpga/spl.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/cpu/armv7/socfpga/spl.c +4 -0
index 9481fd5..16ca8b0 100644
@@ -55,6 +55,7 @@ u32 spl_boot_device(void)
  */
 void spl_board_init(void)
 {
+	unsigned long sdram_size;
 #ifndef CONFIG_SOCFPGA_VIRTUAL_TARGET
 	cm_config_t cm_default_cfg = {
 		/* main group */
@@ -185,4 +186,7 @@ void spl_board_init(void)
 	/* SDRAM calibration */
 	if (sdram_calibration_full() == 0)
 		hang();
+
+	sdram_size = sdram_calculate_size();
+	printf("SDRAM: %ld MiB\n", (sdram_size >> 20));
 }
Signature · 1 line
2.2.1
#47 lore raw

PATCH 11/22 arm: socfpga: spl: printout sdram size

Quoted 20 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 arch/arm/cpu/armv7/socfpga/spl.c | 4 ++++
 1 file changed, 4 insertions(+)
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/spl.c index 9481fd5..16ca8b0 100644

arch/arm/cpu/armv7/socfpga/spl.c +1 -0
@@ -55,6 +55,7 @@ u32 spl_boot_device(void)
  */
 void spl_board_init(void)
 {
+	unsigned long sdram_size;
 #ifndef CONFIG_SOCFPGA_VIRTUAL_TARGET
 	cm_config_t cm_default_cfg = {
 		/* main group */

arch/arm/cpu/armv7/socfpga/spl.c void spl_board_init(void) · line 191

Quoted 6 lines
arch/arm/cpu/armv7/socfpga/spl.c +3 -0
@@ -185,4 +186,7 @@ void spl_board_init(void)
 	/* SDRAM calibration */
 	if (sdram_calibration_full() == 0)
 		hang();
+
+	sdram_size = sdram_calculate_size();
+	printf("SDRAM: %ld MiB\n", (sdram_size >> 20));

Hi!

This will be printed by the "big" U-Boot as well, so you might want to turn this into a debug() ?

arch/arm/cpu/armv7/socfpga/spl.c void spl_board_init(void) · line 192

Quoted 1 line
arch/arm/cpu/armv7/socfpga/spl.c +0 -0
 }

Best regards,
Marek Vasut

#48 lore raw

PATCH 12/22 arm: socfpga: spl: Use common lowlevel_init

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

For SoCFGPA, use the common ARMv7 lowlevel_init.

---
 arch/arm/cpu/armv7/Makefile                | 2 +-
 arch/arm/cpu/armv7/socfpga/lowlevel_init.S | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)
arch/arm/cpu/armv7/Makefile +1 -1
index 409e6f5..d0434b1 100644
@@ -12,7 +12,7 @@ obj-y	+= cache_v7.o
 obj-y	+= cpu.o
 obj-y	+= syslib.o
 
-ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_MX6)$(CONFIG_TI81XX)$(CONFIG_AT91FAMILY)$(CONFIG_SUNXI),)
+ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_MX6)$(CONFIG_TI81XX)$(CONFIG_AT91FAMILY)$(CONFIG_SUNXI)$(CONFIG_SOCFPGA),)
 ifneq ($(CONFIG_SKIP_LOWLEVEL_INIT),y)
 obj-y	+= lowlevel_init.o
 endif
arch/arm/cpu/armv7/socfpga/lowlevel_init.S +0 -4
index 2f2e9fc..f251f07 100644
@@ -14,10 +14,6 @@ save_boot_params:
 	bx	lr
 
 
-/* Set up the platform, once the cpu has been initialized */
-.globl lowlevel_init
-lowlevel_init:
-
 	/* Remap */
 #ifdef CONFIG_SPL_BUILD
 	/*
Signature · 1 line
2.2.1
#49 lore raw

PATCH 12/22 arm: socfpga: spl: Use common lowlevel_init

Quoted 32 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

For SoCFGPA, use the common ARMv7 lowlevel_init.

---
 arch/arm/cpu/armv7/Makefile                | 2 +-
 arch/arm/cpu/armv7/socfpga/lowlevel_init.S | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)
arch/arm/cpu/armv7/Makefile +0 -1
index 409e6f5..d0434b1 100644
@@ -12,7 +12,7 @@ obj-y	+= cache_v7.o
 obj-y	+= cpu.o
 obj-y	+= syslib.o
 
-ifneq

($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CON FIG_TEGRA)$(CONFIG_MX6)$(CONFIG_TI81XX)$(CONFIG_AT91FAMILY)$(CONFIG_SUNXI), ) +ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CON FIG_TEGRA)$(CONFIG_MX6)$(CONFIG_TI81XX)$(CONFIG_AT91FAMILY)$(CONFIG_SUNXI)$ (CONFIG_SOCFPGA),) ifneq ($(CONFIG_SKIP_LOWLEVEL_INIT),y)
obj-y += lowlevel_init.o
endif

(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/lowlevel_init.S index 2f2e9fc..f251f07 100644

arch/arm/cpu/armv7/socfpga/lowlevel_init.S save_boot_params: · line 20

Quoted 7 lines
arch/arm/cpu/armv7/socfpga/lowlevel_init.S +0 -4
@@ -14,10 +14,6 @@ save_boot_params:
 	bx	lr
 
 
-/* Set up the platform, once the cpu has been initialized */
-.globl lowlevel_init
-lowlevel_init:
-

You want to remove the whole lowlevel_init.S file , since what you removed here is only the symbol, not the whole function body. The function body is this stuff below here and it's now both unreachable code and useless as well :)

Otherwise this is cool, thanks!

arch/arm/cpu/armv7/socfpga/lowlevel_init.S save_boot_params: · line 19

Quoted 3 lines
arch/arm/cpu/armv7/socfpga/lowlevel_init.S +0 -0
 	/* Remap */
 #ifdef CONFIG_SPL_BUILD
 	/*

Best regards,
Marek Vasut

#50 lore raw

PATCH 13/22 arm: socfpga: spl: Add s_init

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

s_init will map SDRAM to 0x0.

---
 arch/arm/cpu/armv7/socfpga/Makefile                |  2 +-
 arch/arm/cpu/armv7/socfpga/s_init.c                | 49 ++++++++++++++++++++++
 arch/arm/include/asm/arch-socfpga/system_manager.h | 10 +++++
 3 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/socfpga/s_init.c
arch/arm/cpu/armv7/socfpga/Makefile +1 -1
index 9bd649d..c51c292 100644
@@ -8,6 +8,6 @@
 #
 
 obj-y	:= lowlevel_init.o
-obj-y	+= misc.o timer.o reset_manager.o system_manager.o clock_manager.o \
+obj-y	+= s_init.o misc.o timer.o reset_manager.o system_manager.o clock_manager.o \
 	   fpga_manager.o sdram.o
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o scan_manager.o
arch/arm/cpu/armv7/socfpga/s_init.c new file +49 -0

49 lines not on this page · raw message

arch/arm/include/asm/arch-socfpga/system_manager.h +10 -0
index 51d9815..10659f7 100644
@@ -144,4 +144,14 @@ struct socfpga_system_manager {
 #define SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB			2
 #define SYSMGR_EMACGRP_CTRL_PHYSEL_MASK			0x3
 
+/*
+ * SCU Non-secure Access Control
+ */
+#define SOCFPGA_SCU_SNSAC	(SOCFPGA_MPUSCU_ADDRESS + 0x54)
+/*
+ * L2 PL-310
+ * for configuring L2 address filtering start address in assembly.
+ */
+#define SOCFPGA_MPUL2_ADRFLTR_START			(0xC00)
+
 #endif /* _SYSTEM_MANAGER_H_ */
Signature · 1 line
2.2.1
#51 lore raw

PATCH 13/22 arm: socfpga: spl: Add s_init

Quoted 5 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

s_init will map SDRAM to 0x0.

Hi!

[...]

Quoted 15 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +15 -0
+void s_init(void)
+{
+#ifdef CONFIG_SPL_BUILD
+	struct socfpga_system_manager *sysmgr_regs =
+		(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+	unsigned long reg;
+	/*
+	 * First C code to run. Clear fake OCRAM ECC first as SBE
+	 * and DBE might triggered during power on
+	 */
+	reg = readl(&sysmgr_regs->eccgrp_ocram);
+	if (reg & SYSMGR_ECC_OCRAM_SERR)
+		writel(SYSMGR_ECC_OCRAM_SERR | SYSMGR_ECC_OCRAM_EN,
+			&sysmgr_regs->eccgrp_ocram);
+	if (reg & SYSMGR_ECC_OCRAM_DERR)

arch/arm/cpu/armv7/socfpga/s_init.c line 43

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +10 -0
+		writel(SYSMGR_ECC_OCRAM_DERR  | SYSMGR_ECC_OCRAM_EN,
+			&sysmgr_regs->eccgrp_ocram);
+#else
+	/*
+	 * Private components security
+	 * U-Boot : configure private timer, global timer and cpu
+	 * component access as non secure for kernel stage (as required
+	 * by kernel)
+	 */
+	setbits_le32(SOCFPGA_SCU_SNSAC, 0xfff);

We do this in socfpga/misc.c in arch_early_init_r() already. You should consolidate this code so we don't have it twice I think.

arch/arm/cpu/armv7/socfpga/s_init.c line 48

Quoted 5 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +5 -0
+
+#endif	/* CONFIG_SPL_BUILD */
+
+	/* Configure the L2 controller to make SDRAM start at 0	*/
+	writel(0x1, (SOCFPGA_MPUL2_ADDRESS + SOCFPGA_MPUL2_ADRFLTR_START));

This as well.

Quoted 9 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +1 -0
+}
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-socfpga/system_manager.h index 51d9815..10659f7 100644

arch/arm/include/asm/arch-socfpga/system_manager.h +0 -0
@@ -144,4 +144,14 @@ struct socfpga_system_manager {
 #define SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB			2
 #define SYSMGR_EMACGRP_CTRL_PHYSEL_MASK			0x3

arch/arm/include/asm/arch-socfpga/system_manager.h struct socfpga_system_manager { · line 155

Quoted 10 lines
arch/arm/include/asm/arch-socfpga/system_manager.h +9 -0
 
+/*
+ * SCU Non-secure Access Control
+ */
+#define SOCFPGA_SCU_SNSAC	(SOCFPGA_MPUSCU_ADDRESS + 0x54)
+/*
+ * L2 PL-310
+ * for configuring L2 address filtering start address in assembly.
+ */
+#define SOCFPGA_MPUL2_ADRFLTR_START			(0xC00)

I think this is not needed if you use the code from misc.c , since these registers are already defined there.

Quoted 1 line
arch/arm/include/asm/arch-socfpga/system_manager.h +0 -0
 #endif /* _SYSTEM_MANAGER_H_ */
#52 lore raw

PATCH 13/22 arm: socfpga: spl: Add s_init

Quoted 32 lines · Marek Vasut
Quoted 5 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

s_init will map SDRAM to 0x0.

Hi!

[...]

Quoted 20 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +20 -0
+void s_init(void)
+{
+#ifdef CONFIG_SPL_BUILD
+	struct socfpga_system_manager *sysmgr_regs =
+		(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+	unsigned long reg;
+	/*
+	 * First C code to run. Clear fake OCRAM ECC first as SBE
+	 * and DBE might triggered during power on
+	 */
+	reg = readl(&sysmgr_regs->eccgrp_ocram);
+	if (reg & SYSMGR_ECC_OCRAM_SERR)
+		writel(SYSMGR_ECC_OCRAM_SERR | SYSMGR_ECC_OCRAM_EN,
+			&sysmgr_regs->eccgrp_ocram);
+	if (reg & SYSMGR_ECC_OCRAM_DERR)
+		writel(SYSMGR_ECC_OCRAM_DERR  | SYSMGR_ECC_OCRAM_EN,
+			&sysmgr_regs->eccgrp_ocram);
+#else
+	/*
+	 * Private components security
Quoted 8 lines

arch/arm/cpu/armv7/socfpga/s_init.c line 43

Quoted 5 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +5 -0
+	 * U-Boot : configure private timer, global timer and cpu
+	 * component access as non secure for kernel stage (as required
+	 * by kernel)
+	 */
+	setbits_le32(SOCFPGA_SCU_SNSAC, 0xfff);

We do this in socfpga/misc.c in arch_early_init_r() already. You should consolidate this code so we don't have it twice I think.

Yes, this can be removed.

Quoted 9 lines

arch/arm/cpu/armv7/socfpga/s_init.c line 48

Quoted 6 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +5 -0
+
+#endif	/* CONFIG_SPL_BUILD */
+
+	/* Configure the L2 controller to make SDRAM start at 0	*/
+	writel(0x1, (SOCFPGA_MPUL2_ADDRESS + SOCFPGA_MPUL2_ADRFLTR_START));

This as well.

This call has to stay because we want to map the SDRAM to 0x0 in the SPL. The call in arch_early_init_r() is in u-boot, and thus is too late.

Quoted 10 lines
Quoted 10 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +1 -0
+}
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-socfpga/system_manager.h index 51d9815..10659f7 100644

arch/arm/include/asm/arch-socfpga/system_manager.h +0 -0
@@ -144,4 +144,14 @@ struct socfpga_system_manager {
 #define SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB			2
 #define SYSMGR_EMACGRP_CTRL_PHYSEL_MASK			0x3
 
Quoted 13 lines

arch/arm/include/asm/arch-socfpga/system_manager.h struct socfpga_system_manager { · line 155

Quoted 9 lines
arch/arm/include/asm/arch-socfpga/system_manager.h +9 -0
+/*
+ * SCU Non-secure Access Control
+ */
+#define SOCFPGA_SCU_SNSAC	(SOCFPGA_MPUSCU_ADDRESS + 0x54)
+/*
+ * L2 PL-310
+ * for configuring L2 address filtering start address in assembly.
+ */
+#define SOCFPGA_MPUL2_ADRFLTR_START			(0xC00)

I think this is not needed if you use the code from misc.c , since these registers are already defined there.

Yes, I can remove this and use the mappings already defined.

Thanks,
Dinh

#53 lore raw

PATCH 13/22 arm: socfpga: spl: Add s_init

Quoted 1 line · Dinh Nguyen

On 01/14/2015 05:54 PM, Marek Vasut wrote:

[...]

Quoted 11 lines
Quoted 10 lines

arch/arm/cpu/armv7/socfpga/s_init.c line 43

Quoted 7 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +7 -0
+	/*
+	 * Private components security
+	 * U-Boot : configure private timer, global timer and cpu
+	 * component access as non secure for kernel stage (as required
+	 * by kernel)
+	 */
+	setbits_le32(SOCFPGA_SCU_SNSAC, 0xfff);

We do this in socfpga/misc.c in arch_early_init_r() already. You should consolidate this code so we don't have it twice I think.

Quoted 1 line

Yes, this can be removed.

Hi! Please use whichever place you think is better.

Quoted 10 lines
Quoted 7 lines

arch/arm/cpu/armv7/socfpga/s_init.c line 48

Quoted 5 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +5 -0
+
+#endif	/* CONFIG_SPL_BUILD */
+
+	/* Configure the L2 controller to make SDRAM start at 0	*/
+	writel(0x1, (SOCFPGA_MPUL2_ADDRESS + SOCFPGA_MPUL2_ADRFLTR_START));

This as well.

This call has to stay because we want to map the SDRAM to 0x0 in the SPL. The call in arch_early_init_r() is in u-boot, and thus is too late.

Roger, but please remove the other invocation once the SPL is in place. OK?

[...]

Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
arch/arm/include/asm/arch-socfpga/system_manager.h +4 -0
+/*
+ * SCU Non-secure Access Control
+ */
+#define SOCFPGA_SCU_SNSAC	(SOCFPGA_MPUSCU_ADDRESS + 0x54)
Quoted 8 lines

arch/arm/include/asm/arch-socfpga/system_manager.h struct socfpga_system_manager { · line 155

Quoted 5 lines
arch/arm/include/asm/arch-socfpga/system_manager.h +5 -0
+/*
+ * L2 PL-310
+ * for configuring L2 address filtering start address in assembly.
+ */
+#define SOCFPGA_MPUL2_ADRFLTR_START			(0xC00)

I think this is not needed if you use the code from misc.c , since these registers are already defined there.

Quoted 1 line

Yes, I can remove this and use the mappings already defined.

Please do :)

Thank you!

#54 lore raw

PATCH 13/22 arm: socfpga: spl: Add s_init

Quoted 28 lines · Marek Vasut
Quoted 1 line · Dinh Nguyen

On 01/14/2015 05:54 PM, Marek Vasut wrote:

[...]

Quoted 11 lines
Quoted 10 lines

arch/arm/cpu/armv7/socfpga/s_init.c line 43

Quoted 7 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +7 -0
+	/*
+	 * Private components security
+	 * U-Boot : configure private timer, global timer and cpu
+	 * component access as non secure for kernel stage (as required
+	 * by kernel)
+	 */
+	setbits_le32(SOCFPGA_SCU_SNSAC, 0xfff);

We do this in socfpga/misc.c in arch_early_init_r() already. You should consolidate this code so we don't have it twice I think.

Quoted 1 line

Yes, this can be removed.

Hi! Please use whichever place you think is better.

Quoted 8 lines
Quoted 7 lines

arch/arm/cpu/armv7/socfpga/s_init.c line 48

Quoted 5 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +5 -0
+
+#endif	/* CONFIG_SPL_BUILD */
+
+	/* Configure the L2 controller to make SDRAM start at 0	*/
+	writel(0x1, (SOCFPGA_MPUL2_ADDRESS + SOCFPGA_MPUL2_ADRFLTR_START));

This as well.

Quoted 4 lines
Quoted 2 lines

This call has to stay because we want to map the SDRAM to 0x0 in the SPL. The call in arch_early_init_r() is in u-boot, and thus is too late.

Roger, but please remove the other invocation once the SPL is in place. OK?

Yes, I can remove it in the series?

Thanks,
Dinh

#55 lore raw

PATCH 13/22 arm: socfpga: spl: Add s_init

On Monday, February 09, 2015 at 05:50:34 PM, Dinh Nguyen wrote:

Hi!

[...]

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

arch/arm/cpu/armv7/socfpga/s_init.c

Quoted 5 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +5 -0
+
+#endif	/* CONFIG_SPL_BUILD */
+
+	/* Configure the L2 controller to make SDRAM start at 0	*/
+	writel(0x1, (SOCFPGA_MPUL2_ADDRESS + 

SOCFPGA_MPUL2_ADRFLTR_START));

Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

This as well.

This call has to stay because we want to map the SDRAM to 0x0 in the SPL. The call in arch_early_init_r() is in u-boot, and thus is too late.

Roger, but please remove the other invocation once the SPL is in place. OK?

Yes, I can remove it in the series?

Roger, thank you.

Please address Simon's email too :)

Best regards,
Marek Vasut

#56 lore raw

PATCH 13/22 arm: socfpga: spl: Add s_init

In reply to Dinh Nguyen

Hi,

Quoted 53 lines · Dinh Nguyen
Quoted 32 lines · Marek Vasut
Quoted 5 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

s_init will map SDRAM to 0x0.

Hi!

[...]

Quoted 20 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +20 -0
+void s_init(void)
+{
+#ifdef CONFIG_SPL_BUILD
+    struct socfpga_system_manager *sysmgr_regs =
+            (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+    unsigned long reg;
+    /*
+     * First C code to run. Clear fake OCRAM ECC first as SBE
+     * and DBE might triggered during power on
+     */
+    reg = readl(&sysmgr_regs->eccgrp_ocram);
+    if (reg & SYSMGR_ECC_OCRAM_SERR)
+            writel(SYSMGR_ECC_OCRAM_SERR | SYSMGR_ECC_OCRAM_EN,
+                    &sysmgr_regs->eccgrp_ocram);
+    if (reg & SYSMGR_ECC_OCRAM_DERR)
+            writel(SYSMGR_ECC_OCRAM_DERR  | SYSMGR_ECC_OCRAM_EN,
+                    &sysmgr_regs->eccgrp_ocram);
+#else
+    /*
+     * Private components security
Quoted 8 lines

arch/arm/cpu/armv7/socfpga/s_init.c line 43

Quoted 5 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +5 -0
+     * U-Boot : configure private timer, global timer and cpu
+     * component access as non secure for kernel stage (as required
+     * by kernel)
+     */
+    setbits_le32(SOCFPGA_SCU_SNSAC, 0xfff);

We do this in socfpga/misc.c in arch_early_init_r() already. You should consolidate this code so we don't have it twice I think.

Yes, this can be removed.

Quoted 9 lines

arch/arm/cpu/armv7/socfpga/s_init.c line 48

Quoted 6 lines
arch/arm/cpu/armv7/socfpga/s_init.c new file +5 -0
+
+#endif      /* CONFIG_SPL_BUILD */
+
+    /* Configure the L2 controller to make SDRAM start at 0 */
+    writel(0x1, (SOCFPGA_MPUL2_ADDRESS + SOCFPGA_MPUL2_ADRFLTR_START));

This as well.

Quoted 2 lines

This call has to stay because we want to map the SDRAM to 0x0 in the SPL. The call in arch_early_init_r() is in u-boot, and thus is too late.

Can it be done in SPL's board_init_f()?

See these two patches for background.

http://patchwork.ozlabs.org/patch/432861/
http://patchwork.ozlabs.org/patch/423789/

[snip]

Regards,
Simon

#57 lore raw

PATCH 14/22 arm: socfpga: spl: update lowlevel_init

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add code to handle status of the bsel.

---
 arch/arm/cpu/armv7/socfpga/lowlevel_init.S         | 61 ++++++++++++----------
 arch/arm/cpu/armv7/socfpga/spl.c                   |  2 +
 arch/arm/include/asm/arch-socfpga/reset_manager.h  | 31 +++++++++++
 arch/arm/include/asm/arch-socfpga/system_manager.h |  9 +++-
 4 files changed, 73 insertions(+), 30 deletions(-)
arch/arm/cpu/armv7/socfpga/lowlevel_init.S +33 -28
index f251f07..ee3c9fa 100644
@@ -6,44 +6,49 @@
 
 #include <config.h>
 #include <version.h>
+#include <linux/linkage.h>
+#include <asm-offsets.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/arch/system_manager.h>
 
 /* Save the parameter pass in by previous boot loader */
 .global save_boot_params
 save_boot_params:
 	/* no parameter to save */
-	bx	lr
-
 
-	/* 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]
+	 * If BSEL is zero, then the bootrom has not
+         * handed any information to preloader.
+         */
+	ldr	r9,=SYSMGR_BOOTINFO
+	ldr 	r9, [r9]
+	and	r9, r9, #SYSMGR_BOOTINFO_BSEL_MASK
+	cmp	r9, #0
+	bne	bsel_non_zero
+	ldr	r4, =rst_mgr_status
+	ldr	r5, =RSTMGR_COLDRST_MASK
+	str	r5, [r4]
+	b	bsel_zero
 
-	/* Private components security */
+bsel_non_zero:
+	/* get the reset manager status register passed by BootROM */
+	add	r5, r0,#0x38
+	ldr	r4, =rst_mgr_status
+	ldr	r5, [r5]
+	str	r5, [r4]
 
+bsel_zero:
 	/*
-	 * U-Boot : configure private timer, global timer and cpu
-	 * component access as non secure for kernel stage (as required
-	 * by kernel)
+	 * Initialize the early stack point on OCRAM. This is to avoid OCRAM
+	 * false double bit error as OCRAM always ready in 64 bit manner
 	 */
-	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]
+	ldr	r1, =(CONFIG_SYS_INIT_SP_ADDR)	/* start of temporary SP */
+	sub	r0, r1, #GD_SIZE	/* start of mem init */
+	mov	r2, #0x00000000		/* prepare zero to mem init */
+clrsp:	cmp	r0, r1			/* while not at end of BSS */
+	strlo	r2, [r0]		/* clear 32-bit BSS word */
+	addlo	r0, r0, #4		/* move to next */
+	blo	clrsp
 #endif	/* #ifdef CONFIG_SPL_BUILD */
-	mov	pc, lr
+	bx	lr
arch/arm/cpu/armv7/socfpga/spl.c +2 -0
index 16ca8b0..bf5b682 100644
@@ -20,6 +20,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+u32 rst_mgr_status;
+
 #define MAIN_VCO_BASE (					\
 	(CONFIG_HPS_MAINPLLGRP_VCO_DENOM <<		\
 		CLKMGR_MAINPLLGRP_VCO_DENOM_OFFSET) |	\
arch/arm/include/asm/arch-socfpga/reset_manager.h +31 -0
index d63a285..9b3f279 100644
@@ -7,6 +7,7 @@
 #ifndef	_RESET_MANAGER_H_
 #define	_RESET_MANAGER_H_
 
+#ifndef __ASSEMBLY__
 void reset_cpu(ulong addr);
 void reset_deassert_peripherals_handoff(void);
 
@@ -29,6 +30,7 @@ struct socfpga_reset_manager {
 	u32	per2_mod_reset;
 	u32	brg_mod_reset;
 };
+#endif /* __ASSEMBLY__ */
 
 #if defined(CONFIG_SOCFPGA_VIRTUAL_TARGET)
 #define RSTMGR_CTRL_SWWARMRSTREQ_LSB 2
@@ -45,4 +47,33 @@ struct socfpga_reset_manager {
 #define RSTMGR_PERMODRST_SPIM1_LSB	19
 #define RSTMGR_PERMODRST_SDR_LSB	29
 
+#define RSTMGR_STAT_L4WD1RST_MASK 0x00008000
+#define RSTMGR_STAT_L4WD0RST_MASK 0x00004000
+#define RSTMGR_STAT_MPUWD1RST_MASK 0x00002000
+#define RSTMGR_STAT_MPUWD0RST_MASK 0x00001000
+#define RSTMGR_STAT_SWWARMRST_MASK 0x00000400
+#define RSTMGR_STAT_FPGAWARMRST_MASK 0x00000200
+#define RSTMGR_STAT_NRSTPINRST_MASK 0x00000100
+#define RSTMGR_STAT_SWCOLDRST_MASK 0x00000010
+#define RSTMGR_STAT_CONFIGIOCOLDRST_MASK 0x00000008
+#define RSTMGR_STAT_FPGACOLDRST_MASK 0x00000004
+#define RSTMGR_STAT_NPORPINRST_MASK 0x00000002
+#define RSTMGR_STAT_PORVOLTRST_MASK 0x00000001
+
+#define RSTMGR_WARMRST_MASK	(\
+	RSTMGR_STAT_L4WD1RST_MASK | \
+	RSTMGR_STAT_L4WD0RST_MASK | \
+	RSTMGR_STAT_MPUWD1RST_MASK | \
+	RSTMGR_STAT_MPUWD0RST_MASK | \
+	RSTMGR_STAT_SWWARMRST_MASK | \
+	RSTMGR_STAT_FPGAWARMRST_MASK | \
+	RSTMGR_STAT_NRSTPINRST_MASK)
+#define RSTMGR_COLDRST_MASK	(\
+	RSTMGR_STAT_SWCOLDRST_MASK | \
+	RSTMGR_STAT_CONFIGIOCOLDRST_MASK | \
+	RSTMGR_STAT_FPGACOLDRST_MASK | \
+	RSTMGR_STAT_NPORPINRST_MASK | \
+	RSTMGR_STAT_PORVOLTRST_MASK)
+
+
 #endif /* _RESET_MANAGER_H_ */
arch/arm/include/asm/arch-socfpga/system_manager.h +7 -2
index 10659f7..01ce2e2 100644
@@ -15,8 +15,6 @@ void sysmgr_enable_warmrstcfgio(void);
 /* declaration for handoff table type */
 extern unsigned long sys_mgr_init_table[CONFIG_HPS_PINMUX_NUM];
 
-#endif
-
 struct socfpga_system_manager {
 	/* System Manager Module */
 	u32	siliconid1;			/* 0x00 */
@@ -118,6 +116,8 @@ struct socfpga_system_manager {
 	u32	spim0usefpga;			/* 0x738 */
 };
 
+#endif /* __ASSEMBLY__ */
+
 #define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGPINMUX	(1 << 0)
 #define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO	(1 << 1)
 #define SYSMGR_ECC_OCRAM_EN	(1 << 0)
@@ -154,4 +154,9 @@ struct socfpga_system_manager {
  */
 #define SOCFPGA_MPUL2_ADRFLTR_START			(0xC00)
 
+#define SYSMGR_BOOTINFO			(SOCFPGA_SYSMGR_ADDRESS + 0x14)
+#define SYSMGR_BOOTINFO_CSEL_LSB 	3
+#define SYSMGR_BOOTINFO_CSEL_MASK	0x18
+#define SYSMGR_BOOTINFO_BSEL_MASK	0x7
+
 #endif /* _SYSTEM_MANAGER_H_ */
Signature · 1 line
2.2.1
#58 lore raw

PATCH 14/22 arm: socfpga: spl: update lowlevel_init

Quoted 3 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add code to handle status of the bsel.

Hi!

Can this code be implemented in C instead of ASM please?

btw. the function that's implemented in asm is save_boot_params, not lowlevel_init ;-)

[...]

Best regards,
Marek Vasut

#59 lore raw

PATCH 15/22 arm: socfpga: spl: add relocate_stack_to_sdram to lowlevel_init.S

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add a function to relocate the stack from OCRAM to SDRAM.

---
 arch/arm/cpu/armv7/socfpga/lowlevel_init.S | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
arch/arm/cpu/armv7/socfpga/lowlevel_init.S +24 -0
index ee3c9fa..9ae8e3c 100644
@@ -52,3 +52,27 @@ clrsp:	cmp	r0, r1			/* while not at end of BSS */
 	blo	clrsp
 #endif	/* #ifdef CONFIG_SPL_BUILD */
 	bx	lr
+
+#ifdef CONFIG_SPL_BUILD
+ENTRY(relocate_stack_to_sdram)
+	PUSH	{r4-r11, lr}		/* save registers per AAPCS */
+
+	mov	r0, sp			/* [r0] source address */
+	ldr	r2, =__stack_start	/* [r2] source end address */
+	sub	r3, r2, r0
+	ldr	r4, =__sdram_stack_start
+	sub	r1, r4, r3		/* [r1] target address */
+	mov	r5, r1			/* [r5] new sp within SDRAM */
+
+relocate_loop1:
+	ldmia	r0!, {r3}
+	stmia	r1!, {r3}
+	cmp	r0, r2
+	blo	relocate_loop1
+
+	/* assign SP to new address within SDRAM now */
+	mov	sp, r5
+
+	POP	{r4-r11, pc}
+ENDPROC(relocate_stack_to_sdram)
+#endif /* CONFIG_SPL_BUILD */
Signature · 1 line
2.2.1
#60 lore raw

PATCH 15/22 arm: socfpga: spl: add relocate_stack_to_sdram to lowlevel_init.S

Quoted 3 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add a function to relocate the stack from OCRAM to SDRAM.

Hi,

is this functionality really needed ? There's like 128 KiB of OCRAM on SoCFPGA, which should be plenty, right? If moving the stack to SDRAM is really needed, then you might want to use the common stack relocation code (see relocate_code() function). Also, you should thoroughly describe the reason in the commit message, in this case it's really important.

Best regards,
Marek Vasut

#61 lore raw

PATCH 15/22 arm: socfpga: spl: add relocate_stack_to_sdram to lowlevel_init.S

Hi Marek,

Quoted 9 lines · Marek Vasut
Quoted 3 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add a function to relocate the stack from OCRAM to SDRAM.

Hi,

is this functionality really needed ? There's like 128 KiB of OCRAM on SoCFPGA,

On cyclone5 and arria5, there is only 64KiB.

Quoted 4 lines

which should be plenty, right? If moving the stack to SDRAM is really needed, then you might want to use the common stack relocation code (see relocate_code() function). Also, you should thoroughly describe the reason in the commit message, in this case it's really important.

I'll update in v2.
Thanks,
Dinh

#62 lore raw

PATCH 15/22 arm: socfpga: spl: add relocate_stack_to_sdram to lowlevel_init.S

Quoted 1 line · Dinh Nguyen

Hi Marek,

Hi Dinh,

Quoted 7 lines · Marek Vasut
Quoted 6 lines

On Wednesday, January 14, 2015 at 05:40:55 PM,
dinguyen at opensource.altera.com

Quoted 2 lines · wrote:

From: Dinh Nguyen <[email protected]>

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Add a function to relocate the stack from OCRAM to SDRAM.

Hi,

is this functionality really needed ? There's like 128 KiB of OCRAM on SoCFPGA,

On cyclone5 and arria5, there is only 64KiB.

Ooops, sorry, my bad. You're right. But that is still boatload of memory, given that the SPL will use some hundreds of bytes for the stack under normal conditions.

Quoted 6 lines
Quoted 4 lines

which should be plenty, right? If moving the stack to SDRAM is really needed, then you might want to use the common stack relocation code (see relocate_code() function). Also, you should thoroughly describe the reason in the commit message, in this case it's really important.

I'll update in v2.

So uh, what's the reason for moving the stack into the SDRAM anyway please ?

Best regards,
Marek Vasut

#63 lore raw

PATCH 15/22 arm: socfpga: spl: add relocate_stack_to_sdram to lowlevel_init.S

Quoted 25 lines · Marek Vasut
Quoted 1 line · Dinh Nguyen

Hi Marek,

Hi Dinh,

Quoted 7 lines · Marek Vasut
Quoted 6 lines

On Wednesday, January 14, 2015 at 05:40:55 PM,
dinguyen at opensource.altera.com

Quoted 2 lines · wrote:

From: Dinh Nguyen <[email protected]>

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Add a function to relocate the stack from OCRAM to SDRAM.

Hi,

is this functionality really needed ? There's like 128 KiB of OCRAM on SoCFPGA,

On cyclone5 and arria5, there is only 64KiB.

Ooops, sorry, my bad. You're right. But that is still boatload of memory, given that the SPL will use some hundreds of bytes for the stack under normal conditions.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

which should be plenty, right? If moving the stack to SDRAM is really needed, then you might want to use the common stack relocation code (see relocate_code() function). Also, you should thoroughly describe the reason in the commit message, in this case it's really important.

I'll update in v2.

So uh, what's the reason for moving the stack into the SDRAM anyway please ?

I think this is needed to be able to support SPL_FAT_LOAD.

Dinh

#64 lore raw

PATCH 15/22 arm: socfpga: spl: add relocate_stack_to_sdram to lowlevel_init.S

On Friday, January 16, 2015 at 01:07:55 AM, Dinh Nguyen wrote:

Hi!

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

which should be plenty, right? If moving the stack to SDRAM is really needed, then you might want to use the common stack relocation code (see relocate_code() function). Also, you should thoroughly describe the reason in the commit message, in this case it's really important.

I'll update in v2.

So uh, what's the reason for moving the stack into the SDRAM anyway please ?

I think this is needed to be able to support SPL_FAT_LOAD.

Loading from FAT shouldn't consume that much stack. I think you should be able to use JTAG debugger and trace the stack utilisation in the functions defined in files under fs/fat/ , which should give you some idea how much the FAT loading consumes. In case there really is some spike in the stack utilization, such spike should be identified and fixed instead.

I also believe that in case we manage to avoid moving the stack to SDRAM, we avoid a lot of code which is possibly fragile and that's always nice.

Would you please be able to look into this stack utilization issue in more depth ?

Thank you!

Best regards,
Marek Vasut

#65 lore raw

PATCH 16/22 arm: socfpga: spl: add the stack in OCRAM

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Allocate a stack in the OCRAM for the SPL to use.

---
 arch/arm/cpu/armv7/socfpga/u-boot-spl.lds | 7 +++++++
 include/configs/socfpga_common.h          | 1 +
 2 files changed, 8 insertions(+)
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +7 -0
index 730d154..7c7f59c 100644
@@ -44,4 +44,11 @@ SECTIONS
 		. = ALIGN(4);
 		__bss_end = .;
 	} >.sram
+
+	.stack :
+	{
+		. = . + CONFIG_SPL_STACK_SIZE;
+		. = ALIGN(8);
+		__stack_start = .;
+	} >.sram
 }
include/configs/socfpga_common.h +1 -0
index 0c87faa..90ca031 100644
@@ -305,6 +305,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SYS_SPL_MALLOC_START	CONFIG_SYS_INIT_SP_ADDR
 #define CONFIG_SYS_SPL_MALLOC_SIZE	(5 * 1024)
 #define CONFIG_SPL_MAX_SIZE		(64 * 1024)
+#define CONFIG_SPL_STACK_SIZE		0x1000
 
 #define CHUNKSZ_CRC32			(1 * 1024)	/* FIXME: ewww */
 #define CONFIG_CRC32_VERIFY
Signature · 1 line
2.2.1
#66 lore raw

PATCH 16/22 arm: socfpga: spl: add the stack in OCRAM

Quoted 9 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Allocate a stack in the OCRAM for the SPL to use.

---
 arch/arm/cpu/armv7/socfpga/u-boot-spl.lds | 7 +++++++
 include/configs/socfpga_common.h          | 1 +
 2 files changed, 8 insertions(+)

Hi!

You really don't need 4KiB stack in SDRAM, do you ? The OCRAM should be plenty for this purpose.

Best regards,
Marek Vasut

#67 lore raw

PATCH 17/22 arm: socfpga: spl: add CONFIG_SPL_STACK to socfpga_common.h

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 include/configs/socfpga_common.h | 5 +++++
 1 file changed, 5 insertions(+)
include/configs/socfpga_common.h +5 -0
index 90ca031..6bcb013 100644
@@ -318,6 +318,11 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SPL_WATCHDOG_SUPPORT
 #define CONFIG_SPL_SERIAL_SUPPORT
 
+/*
+ * Stack setup
+ */
+#define CONFIG_SPL_STACK		CONFIG_SYS_INIT_SP_ADDR
+
 #ifdef CONFIG_SPL_BUILD
 #undef CONFIG_PARTITIONS
 #endif
Signature · 1 line
2.2.1
#68 lore raw

PATCH 17/22 arm: socfpga: spl: add CONFIG_SPL_STACK to socfpga_common.h

Quoted 12 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 include/configs/socfpga_common.h | 5 +++++
 1 file changed, 5 insertions(+)
(quoted diff) +0 -0

b/include/configs/socfpga_common.h index 90ca031..6bcb013 100644

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 324

Quoted 7 lines
include/configs/socfpga_common.h +4 -0
@@ -318,6 +318,11 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SPL_WATCHDOG_SUPPORT
 #define CONFIG_SPL_SERIAL_SUPPORT
 
+/*
+ * Stack setup
+ */
+#define CONFIG_SPL_STACK		CONFIG_SYS_INIT_SP_ADDR

Best regards,
Marek Vasut

#70 lore raw

PATCH 18/22 arm: socfpga: add sdram stack to SPL

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Add a stack in the SDRAM to be able to use SPL_FAT_LOAD in later stages of the SPL.

---
 arch/arm/cpu/armv7/socfpga/u-boot-spl.lds | 7 +++++++
 include/configs/socfpga_common.h          | 1 +
 2 files changed, 8 insertions(+)
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +7 -0
index 7c7f59c..739f3f1 100644
@@ -51,4 +51,11 @@ SECTIONS
 		. = ALIGN(8);
 		__stack_start = .;
 	} >.sram
+
+	.sdram_stack :
+	{
+		__sdram_stack_end = .;
+		. = . + CONFIG_SPL_SDRAM_STACK_SIZE;
+		__sdram_stack_start = .;
+	} >.sdram
 }
include/configs/socfpga_common.h +1 -0
index 6bcb013..4b98378 100644
@@ -322,6 +322,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
  * Stack setup
  */
 #define CONFIG_SPL_STACK		CONFIG_SYS_INIT_SP_ADDR
+#define CONFIG_SPL_SDRAM_STACK_SIZE	(128 * 1024)
 
 #ifdef CONFIG_SPL_BUILD
 #undef CONFIG_PARTITIONS
Signature · 1 line
2.2.1
#71 lore raw

PATCH 19/22 arm: socfpga: spl: set SPL_MALLOC_SIZE

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 include/configs/socfpga_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/configs/socfpga_common.h +1 -1
index 4b98378..29d02d6 100644
@@ -303,7 +303,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SPL_RAM_DEVICE
 #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INIT_RAM_ADDR
 #define CONFIG_SYS_SPL_MALLOC_START	CONFIG_SYS_INIT_SP_ADDR
-#define CONFIG_SYS_SPL_MALLOC_SIZE	(5 * 1024)
+#define CONFIG_SYS_SPL_MALLOC_SIZE	256
 #define CONFIG_SPL_MAX_SIZE		(64 * 1024)
 #define CONFIG_SPL_STACK_SIZE		0x1000
 
Signature · 1 line
2.2.1
#72 lore raw

PATCH 19/22 arm: socfpga: spl: set SPL_MALLOC_SIZE

Quoted 1 line · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Hi!

You didn't set the MALLOC_SIZE, you changed it. But the commit message doesn't describe the reason for doing so, so please fix that.

Thanks!

Quoted 10 lines
---
 include/configs/socfpga_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/include/configs/socfpga_common.h index 4b98378..29d02d6 100644

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 308

Quoted 7 lines
include/configs/socfpga_common.h +1 -1
@@ -303,7 +303,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SPL_RAM_DEVICE
 #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INIT_RAM_ADDR
 #define CONFIG_SYS_SPL_MALLOC_START	CONFIG_SYS_INIT_SP_ADDR
-#define CONFIG_SYS_SPL_MALLOC_SIZE	(5 * 1024)
+#define CONFIG_SYS_SPL_MALLOC_SIZE	256
 #define CONFIG_SPL_MAX_SIZE		(64 * 1024)
 #define CONFIG_SPL_STACK_SIZE		0x1000

Best regards,
Marek Vasut

#73 lore raw

PATCH 20/22 arm: socfpga: spl: add a malloc section in sram

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 arch/arm/cpu/armv7/socfpga/u-boot-spl.lds | 7 +++++++
 include/configs/socfpga_common.h          | 1 +
 2 files changed, 8 insertions(+)
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +7 -0
index 739f3f1..f87e951 100644
@@ -45,6 +45,13 @@ SECTIONS
 		__bss_end = .;
 	} >.sram
 
+	.malloc :
+	{
+		. = . + CONFIG_SPL_MALLOC_SIZE;
+		. = ALIGN(8);
+		__malloc_start = .;
+	} >.sram
+
 	.stack :
 	{
 		. = . + CONFIG_SPL_STACK_SIZE;
include/configs/socfpga_common.h +1 -0
index 29d02d6..6185d12 100644
@@ -306,6 +306,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SYS_SPL_MALLOC_SIZE	256
 #define CONFIG_SPL_MAX_SIZE		(64 * 1024)
 #define CONFIG_SPL_STACK_SIZE		0x1000
+#define CONFIG_SPL_MALLOC_SIZE		(5 * 1024)
 
 #define CHUNKSZ_CRC32			(1 * 1024)	/* FIXME: ewww */
 #define CONFIG_CRC32_VERIFY
Signature · 1 line
2.2.1
#74 lore raw

PATCH 20/22 arm: socfpga: spl: add a malloc section in sram

Quoted 13 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 arch/arm/cpu/armv7/socfpga/u-boot-spl.lds | 7 +++++++
 include/configs/socfpga_common.h          | 1 +
 2 files changed, 8 insertions(+)
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/u-boot-spl.lds index 739f3f1..f87e951 100644

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds SECTIONS · line 53

Quoted 9 lines
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +6 -0
@@ -45,6 +45,13 @@ SECTIONS
 		__bss_end = .;
 	} >.sram
 
+	.malloc :
+	{
+		. = . + CONFIG_SPL_MALLOC_SIZE;
+		. = ALIGN(8);
+		__malloc_start = .;
+	} >.sram

The Malloc area should be handled by the common SPL linker script I believe. Can you switch to the common linker script please ?

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 309

Quoted 12 lines
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -0
 	.stack :
 	{
 		. = . + CONFIG_SPL_STACK_SIZE;
(quoted diff) +0 -0

b/include/configs/socfpga_common.h index 29d02d6..6185d12 100644

include/configs/socfpga_common.h +1 -0
@@ -306,6 +306,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SYS_SPL_MALLOC_SIZE	256
 #define CONFIG_SPL_MAX_SIZE		(64 * 1024)
 #define CONFIG_SPL_STACK_SIZE		0x1000
+#define CONFIG_SPL_MALLOC_SIZE		(5 * 1024)

This is some a dangling part of the patch I suspect ? The previous patch changed CONFIG_SYS_SPL_MALLOC_SIZE, now you're adding CONFIG_(without _SYS)_SPL_MALLOC_SIZE . Somehow this is strange.

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 312

Quoted 2 lines
include/configs/socfpga_common.h +0 -0
 #define CHUNKSZ_CRC32			(1 * 1024)	/* FIXME: ewww */
 #define CONFIG_CRC32_VERIFY

Best regards,
Marek Vasut

#75 lore raw

PATCH 21/22 arm: socfpga: spl: Add SDRAM check

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 arch/arm/cpu/armv7/socfpga/spl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/cpu/armv7/socfpga/spl.c +8 -0
index bf5b682..f0ef6b1 100644
@@ -191,4 +191,12 @@ void spl_board_init(void)
 
 	sdram_size = sdram_calculate_size();
 	printf("SDRAM: %ld MiB\n", (sdram_size >> 20));
+
+	/* Sanity check ensure correct SDRAM size specified */
+	puts("SDRAM: Ensuring specified SDRAM size is correct ...");
+	if (get_ram_size(0, sdram_size) != sdram_size) {
+		puts("failed\n");
+		hang();
+	}
+	puts("passed\n");
 }
Signature · 1 line
2.2.1
#76 lore raw

PATCH 21/22 arm: socfpga: spl: Add SDRAM check

Quoted 12 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 arch/arm/cpu/armv7/socfpga/spl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/spl.c index bf5b682..f0ef6b1 100644

arch/arm/cpu/armv7/socfpga/spl.c void spl_board_init(void) · line 198

Quoted 8 lines
arch/arm/cpu/armv7/socfpga/spl.c +5 -0
@@ -191,4 +191,12 @@ void spl_board_init(void)
 
 	sdram_size = sdram_calculate_size();
 	printf("SDRAM: %ld MiB\n", (sdram_size >> 20));
+
+	/* Sanity check ensure correct SDRAM size specified */
+	puts("SDRAM: Ensuring specified SDRAM size is correct ...");
+	if (get_ram_size(0, sdram_size) != sdram_size) {
+		puts("failed\n");

Hi,

you might want to be more verbose about what failed here, possibly include __FILE__ , __func__ and __LINE__ to help identify the problem.

Thanks!

arch/arm/cpu/armv7/socfpga/spl.c void spl_board_init(void) · line 202

Quoted 4 lines
arch/arm/cpu/armv7/socfpga/spl.c +3 -0
+		hang();
+	}
+	puts("passed\n");
 }

Best regards,
Marek Vasut

#77 lore raw

PATCH 21/22 arm: socfpga: spl: Add SDRAM check

Quoted 25 lines · Marek Vasut
Quoted 12 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

---
 arch/arm/cpu/armv7/socfpga/spl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/spl.c index bf5b682..f0ef6b1 100644

arch/arm/cpu/armv7/socfpga/spl.c void spl_board_init(void) · line 198

Quoted 8 lines
arch/arm/cpu/armv7/socfpga/spl.c +5 -0
@@ -191,4 +191,12 @@ void spl_board_init(void)
 
 	sdram_size = sdram_calculate_size();
 	printf("SDRAM: %ld MiB\n", (sdram_size >> 20));
+
+	/* Sanity check ensure correct SDRAM size specified */
+	puts("SDRAM: Ensuring specified SDRAM size is correct ...");
+	if (get_ram_size(0, sdram_size) != sdram_size) {
+		puts("failed\n");

Hi,

Quoted 2 lines

you might want to be more verbose about what failed here, possibly include __FILE__ , __func__ and __LINE__ to help identify the problem.

Actually, I'd be against adding file/func/line. This should be easy enough to grep, and we don't normally print that.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#78 lore raw

PATCH 21/22 arm: socfpga: spl: Add SDRAM check

Quoted 30 lines · Pavel Machek
Quoted 29 lines · Marek Vasut

On Wednesday, January 14, 2015 at 05:41:01 PM,
dinguyen at opensource.altera.com

Quoted 13 lines · wrote:

From: Dinh Nguyen <[email protected]>

---

 arch/arm/cpu/armv7/socfpga/spl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/spl.c index bf5b682..f0ef6b1 100644

arch/arm/cpu/armv7/socfpga/spl.c void spl_board_init(void) · line 199

Quoted 9 lines
arch/arm/cpu/armv7/socfpga/spl.c +5 -0
@@ -191,4 +191,12 @@ void spl_board_init(void)
 
 	sdram_size = sdram_calculate_size();
 	printf("SDRAM: %ld MiB\n", (sdram_size >> 20));
 
+
+	/* Sanity check ensure correct SDRAM size specified */
+	puts("SDRAM: Ensuring specified SDRAM size is correct ...");
+	if (get_ram_size(0, sdram_size) != sdram_size) {
+		puts("failed\n");

Hi,

Quoted 5 lines
Quoted 2 lines

you might want to be more verbose about what failed here, possibly include __FILE__ , __func__ and __LINE__ to help identify the problem.

Actually, I'd be against adding file/func/line. This should be easy enough to grep, and we don't normally print that.

In case you have those in place, there's nothing to grep for, you just go straight to the particular point in that particular file. But if there's some kind of a more unique error message than "failed" (which gives ~1500 hits in recent U-Boot source), I'd be content with it.

Best regards,
Marek Vasut

#79 lore raw

PATCH 22/22 arm: socfpga: spl: update pll_config for dev kit

In reply to dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

This sets the CPU clocks to 925MHz and DDR to 400MHz.

---
 board/altera/socfpga/pll_config.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
board/altera/socfpga/pll_config.h +4 -4
index f0f59a9..3992ff7 100644
@@ -12,13 +12,13 @@
 /* PLL configuration data */
 /* Main PLL */
 #define CONFIG_HPS_MAINPLLGRP_VCO_DENOM			(0)
-#define CONFIG_HPS_MAINPLLGRP_VCO_NUMER			(63)
+#define CONFIG_HPS_MAINPLLGRP_VCO_NUMER			(73)
 #define CONFIG_HPS_MAINPLLGRP_MPUCLK_CNT		(0)
 #define CONFIG_HPS_MAINPLLGRP_MAINCLK_CNT		(0)
 #define CONFIG_HPS_MAINPLLGRP_DBGATCLK_CNT		(0)
-#define CONFIG_HPS_MAINPLLGRP_MAINQSPICLK_CNT		(3)
-#define CONFIG_HPS_MAINPLLGRP_MAINNANDSDMMCCLK_CNT	(3)
-#define CONFIG_HPS_MAINPLLGRP_CFGS2FUSER0CLK_CNT	(12)
+#define CONFIG_HPS_MAINPLLGRP_MAINQSPICLK_CNT		(4)
+#define CONFIG_HPS_MAINPLLGRP_MAINNANDSDMMCCLK_CNT	(0)
+#define CONFIG_HPS_MAINPLLGRP_CFGS2FUSER0CLK_CNT	(14)
 #define CONFIG_HPS_MAINPLLGRP_MAINDIV_L3MPCLK		(1)
 #define CONFIG_HPS_MAINPLLGRP_MAINDIV_L3SPCLK		(1)
 #define CONFIG_HPS_MAINPLLGRP_MAINDIV_L4MPCLK		(1)
Signature · 1 line
2.2.1
#80 lore raw

PATCH 22/22 arm: socfpga: spl: update pll_config for dev kit

Quoted 5 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

This sets the CPU clocks to 925MHz and DDR to 400MHz.

Hi!

Is this based on the Arria V patchset I sent just before the end of the year or is this based on u-boot master please ?

Thanks for the SPL patchset, it's really useful :) It'll need some cleanup, so please keep at it ! Also, please give others a few days to react before sending a V2.

Thank you! :)

Best regards,
Marek Vasut

#81 lore raw

cover Add SPL support for SoCFGPA

In reply to dinguyen at opensource.altera.com
Quoted 11 lines · dinguyen at opensource.altera.com

From: Dinh Nguyen <[email protected]>

Hello,

This patchset adds all the SPL code that is necessary to support the SoCFPGA platform. With this patch series, one should be able to configure the SDRAM controller and run u-boot.

I have pushed a branch to
git://git.rocketboards.org/u-boot-socfpga-next.git socfpga_for_next_spl_v1 for testing and reviewing.

Hi!

this is really extra cool, well done, good job ! :-)

Best regards,
Marek Vasut

#82 lore raw

cover Add SPL support for SoCFGPA

In reply to dinguyen at opensource.altera.com

Hi!

Quoted 6 lines

This patchset adds all the SPL code that is necessary to support the SoCFPGA platform. With this patch series, one should be able to configure the SDRAM controller and run u-boot.

I have pushed a branch to git://git.rocketboards.org/u-boot-socfpga-next.git
socfpga_for_next_spl_v1 for testing and reviewing.

Hooray \_O_/ !

Thanks a lot for doing this.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html