Skip to contentSkip to conversation

ARM: Add Altera SOCFPGA Cyclone5

PATCH Superseded dinguyen at altera.com 8 participants 43 messages Aug 16, 2012 – Sep 3, 2012

Subsystems (3)

v1 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

From: Dinh Nguyen <[email protected]>

Add minimal support for Altera's SOCFPGA Cyclone 5 hardware.

---
 MAINTAINERS                                        |    5 +
 Makefile                                           |    2 +-
 arch/arm/cpu/armv7/socfpga/Makefile                |   51 +++++
 arch/arm/cpu/armv7/socfpga/lowlevel_init.S         |   79 +++++++
 arch/arm/cpu/armv7/socfpga/reset_manager.c         |   45 ++++
 arch/arm/cpu/armv7/socfpga/sdram.c                 |   26 +++
 arch/arm/cpu/armv7/socfpga/spl.c                   |  182 +++++++++++++++
 arch/arm/cpu/armv7/socfpga/timer.c                 |  118 ++++++++++
 arch/arm/cpu/armv7/socfpga/u-boot-spl.lds          |   60 +++++
 arch/arm/include/asm/arch-socfpga/reset_manager.h  |   37 +++
 .../include/asm/arch-socfpga/socfpga_base_addrs.h  |   27 +++
 arch/arm/include/asm/arch-socfpga/socfpga_spl.h    |   30 +++
 board/altera/socfpga_cyclone5/Makefile             |   50 ++++
 board/altera/socfpga_cyclone5/socfpga_cyclone5.c   |   97 ++++++++
 boards.cfg                                         |    1 +
 include/configs/socfpga_cyclone5.h                 |  240 ++++++++++++++++++++
 16 files changed, 1049 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/socfpga/Makefile
 create mode 100644 arch/arm/cpu/armv7/socfpga/lowlevel_init.S
 create mode 100644 arch/arm/cpu/armv7/socfpga/reset_manager.c
 create mode 100644 arch/arm/cpu/armv7/socfpga/sdram.c
 create mode 100644 arch/arm/cpu/armv7/socfpga/spl.c
 create mode 100644 arch/arm/cpu/armv7/socfpga/timer.c
 create mode 100644 arch/arm/cpu/armv7/socfpga/u-boot-spl.lds
 create mode 100644 arch/arm/include/asm/arch-socfpga/reset_config.h
 create mode 100644 arch/arm/include/asm/arch-socfpga/reset_manager.h
 create mode 100644 arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h
 create mode 100644 arch/arm/include/asm/arch-socfpga/socfpga_spl.h
 create mode 100644 board/altera/socfpga_cyclone5/Makefile
 create mode 100644 board/altera/socfpga_cyclone5/socfpga_cyclone5.c
 create mode 100644 include/configs/socfpga_cyclone5.h
MAINTAINERS +5 -0
index c5a6f2f..df48dea 100644
@@ -765,6 +765,11 @@ Nagendra T S  <[email protected]>
 
    am3517_crane    ARM ARMV7 (AM35x SoC)
 
+Dinh Nguyen <[email protected]>
+Chin Liang See <[email protected]>
+
+	socfpga		socfpga_cyclone5
+
 Kyungmin Park <[email protected]>
 
 	apollon		ARM1136EJS
Makefile +1 -1
index 5ce5cc3..12aa372 100644
@@ -369,7 +369,7 @@ BOARD_SIZE_CHECK =
 endif
 
 # Always append ALL so that arch config.mk's can add custom ones
-ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
+ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)u-boot.img $(obj)System.map
 
 ALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin
 ALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin
arch/arm/cpu/armv7/socfpga/Makefile new file +51 -0

51 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/lowlevel_init.S new file +79 -0

79 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/reset_manager.c new file +45 -0

45 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/sdram.c new file +26 -0
new file mode 100644
index 0000000..6714983
@@ -0,0 +1,26 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int dram_init(void)
+{
+	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	return 0;
+}
arch/arm/cpu/armv7/socfpga/spl.c new file +182 -0

182 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/timer.c new file +118 -0

118 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds new file +60 -0

60 lines not on this page · raw message

arch/arm/include/asm/arch-socfpga/reset_config.h new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/arm/include/asm/arch-socfpga/reset_manager.h new file +37 -0
new file mode 100644
index 0000000..d9d2c1c
@@ -0,0 +1,37 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef	_RESET_MANAGER_H_
+#define	_RESET_MANAGER_H_
+
+void reset_cpu(ulong addr);
+void reset_deassert_peripherals_handoff(void);
+
+struct socfpga_reset_manager {
+	u32	padding1;
+	u32	ctrl;
+	u32	padding2;
+	u32	padding3;
+	u32	mpu_mod_reset;
+	u32	per_mod_reset;
+	u32	per2_mod_reset;
+	u32	brg_mod_reset;
+};
+
+#define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
+
+#endif /* _RESET_MANAGER_H_ */
arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h new file +27 -0
new file mode 100644
index 0000000..f353eb2
@@ -0,0 +1,27 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SOCFPGA_BASE_ADDRS_H_
+#define _SOCFPGA_BASE_ADDRS_H_
+
+#define SOCFPGA_L3REGS_ADDRESS 0xff800000
+#define SOCFPGA_UART0_ADDRESS 0xffc02000
+#define SOCFPGA_UART1_ADDRESS 0xffc03000
+#define SOCFPGA_OSC1TIMER0_ADDRESS 0xffd00000
+#define SOCFPGA_RSTMGR_ADDRESS 0xffd05000
+
+#endif /* _SOCFPGA_BASE_ADDRS_H_ */
arch/arm/include/asm/arch-socfpga/socfpga_spl.h new file +30 -0
new file mode 100644
index 0000000..ee4b6d3
@@ -0,0 +1,30 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef	_SOCPFGA_SPL_H_
+#define	_SOCPFGA_SPL_H_
+
+struct spl_image_info {
+	const char *name;
+	u8 os;
+	u32 load_addr;
+	u32 entry_point;
+	u32 size;
+	u32 crc;
+};
+
+#endif /* _SOCPFGA_SPL_H_ */
board/altera/socfpga_cyclone5/Makefile new file +50 -0

50 lines not on this page · raw message

board/altera/socfpga_cyclone5/socfpga_cyclone5.c new file +97 -0

97 lines not on this page · raw message

boards.cfg +1 -0
index fdb84ad..1b5c860 100644
@@ -261,6 +261,7 @@ seaboard                     arm         armv7       seaboard            nvidia
 ventana                      arm         armv7       ventana             nvidia         tegra2
 whistler                     arm         armv7       whistler            nvidia         tegra2
 u8500_href                   arm         armv7       u8500               st-ericsson    u8500
+socfpga_cyclone5              arm         armv7      socfpga_cyclone5    altera		    socfpga
 actux1_4_16                  arm         ixp         actux1              -              -           actux1:FLASH2X2
 actux1_4_32                  arm         ixp         actux1              -              -           actux1:FLASH2X2,RAM_32MB
 actux1_8_16                  arm         ixp         actux1              -              -           actux1:FLASH1X8
include/configs/socfpga_cyclone5.h new file +240 -0

240 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi!

Quoted 3 lines

From: Dinh Nguyen <[email protected]>

Add minimal support for Altera's SOCFPGA Cyclone 5 hardware.

Albert, it seems you should be one merging this...? (Am I right?) Is there anything we need to fix? Was it too late?

Thanks,
Pavel

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

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to dinguyen at altera.com

Dear dinguyen at altera.com,

Quoted 6 lines

From: Dinh Nguyen <[email protected]>

Add minimal support for Altera's SOCFPGA Cyclone 5 hardware.

[...]

Please CC albert with new arches.

Quoted 11 lines
Makefile +1 -1
index 5ce5cc3..12aa372 100644
@@ -369,7 +369,7 @@ BOARD_SIZE_CHECK =
 endif
 
 # Always append ALL so that arch config.mk's can add custom ones
-ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
+ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)u-boot.img

$(obj)System.map

This won't slide

Quoted 2 lines

ALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin ALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin

[...]

Quoted 10 lines
Makefile +10 -0
+/*
+ * Write the reset manager register to cause reset
+ */
+void reset_cpu(ulong addr)
+{
+	/* request a warm reset */
+	writel(RSTMGR_CTRL_SWWARMRSTREQ_LSB, &reset_manager_base->ctrl);
+	/* infinite loop here as watchdog will trigger and reset
+	 * the processor */
+	while (1)

Makefile

Quoted 10 lines
Makefile +10 -0
+		;
+}
+
+/*
+ * Release peripherals from reset based on handoff
+ */
+void reset_deassert_peripherals_handoff(void)
+{
+	unsigned int val = 0;
+	writel(val, &reset_manager_base->per_mod_reset);

writel(0, ...

Quoted 23 lines
Makefile +1 -0
+}
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/sdram.c new file mode 100644 index 0000000..6714983

arch/arm/cpu/armv7/socfpga/sdram.c new file +16 -0
@@ -0,0 +1,26 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */

arch/arm/cpu/armv7/socfpga/sdram.c line 26

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/sdram.c new file +10 -0
+
+#include <common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int dram_init(void)
+{
+	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	return 0;
+}

Can all this be concentrated into single file (reset, sdram, etc. all those small functions).

Quoted 81 lines
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/spl.c new file mode 100644 index 0000000..7bd1e2f

arch/arm/cpu/armv7/socfpga/spl.c new file +52 -0
@@ -0,0 +1,182 @@
+ /*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/u-boot.h>
+#include <asm/utils.h>
+#include <asm/arch/socfpga_spl.h>
+#include <version.h>
+#include <image.h>
+#include <malloc.h>
+#include <asm/arch/reset_manager.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static u32 *boot_params_ptr;
+static struct spl_image_info spl_image;
+
+extern void __malloc_start, __malloc_end, __stack_start;
+
+/* Define global data structure pointer to it */
+static gd_t gdata __attribute__ ((section(".data")));
+
+/*
+ * Error action
+ */
+inline void hang(void)
+{
+	puts("### ERROR ### Please RESET the board ###\n");
+	for (;;)
+		;
+}
+
+/*
+ * Read the mkimage signature to extract info such as entry point.
+ * The header is generated by tools/mkimage
+ */
+static unsigned long spl_parse_image_header(const struct image_header

*header) +{

arch/arm/cpu/armv7/socfpga/spl.c new file +22 -0
+	/* checking for mkimage signature */
+	if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) {
+		/* Valid image. Extract information out of header */
+		spl_image.size = __be32_to_cpu(header->ih_size);
+		spl_image.entry_point = __be32_to_cpu(header->ih_load);
+		spl_image.load_addr = __be32_to_cpu(header->ih_load);
+		spl_image.os = header->ih_os;
+		spl_image.name = (const char *)&header->ih_name;
+		spl_image.crc = __be32_to_cpu(header->ih_dcrc);
+		debug("Subsequent boot image info\n");
+		debug("   Image Name:   %.*s\n", IH_NMLEN, spl_image.name);
+		debug("   Data Size:    %d\n", spl_image.size);
+		debug("   Load Address: 0x%x\n", spl_image.load_addr);
+		debug("   Entry Point:  0x%X\n", spl_image.entry_point);
+	} else {
+		/* Not a valid image as mkimage signature not found */
+		printf("Error : mkimage signature not found - ih_magic = %x\n",
+			header->ih_magic);
+		return 1;
+	}
+
+	/* Checking image type. Do any customize stuff per image type here */

arch/arm/cpu/armv7/socfpga/spl.c line 85

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/spl.c new file +10 -0
+	switch (spl_image.os) {
+	case IH_OS_U_BOOT:
+		debug("   Image Type:   U-Boot\n");
+		break;
+	default:
+		printf("   Image Type:   Unknown (%d)\n", spl_image.os);
+		;
+	}
+	return 0;
+}

I think I don't even wanna know what's the purpose here :-)

[...]

#3 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Quoted 20 lines · Marek Vasut

Dear dinguyen at altera.com,

Quoted 6 lines

From: Dinh Nguyen <[email protected]>

Add minimal support for Altera's SOCFPGA Cyclone 5 hardware.

[...]

Please CC albert with new arches.

Quoted 7 lines
Makefile +0 -0
index 5ce5cc3..12aa372 100644
@@ -369,7 +369,7 @@ BOARD_SIZE_CHECK =
 endif
 
Quoted 6 lines
Quoted 4 lines
Makefile +1 -1
 # Always append ALL so that arch config.mk's can add custom ones
-ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
+ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)u-boot.img

$(obj)System.map

This won't slide

You can place this into arch/arm/cpu/armv7/socfpga/config.mk (see am33xx/config.mk or any of the others) for examples.

[snip]

Quoted 85 lines
Quoted 85 lines
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/spl.c new file mode 100644 index 0000000..7bd1e2f

arch/arm/cpu/armv7/socfpga/spl.c new file +52 -0
@@ -0,0 +1,182 @@
+ /*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/u-boot.h>
+#include <asm/utils.h>
+#include <asm/arch/socfpga_spl.h>
+#include <version.h>
+#include <image.h>
+#include <malloc.h>
+#include <asm/arch/reset_manager.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static u32 *boot_params_ptr;
+static struct spl_image_info spl_image;
+
+extern void __malloc_start, __malloc_end, __stack_start;
+
+/* Define global data structure pointer to it */
+static gd_t gdata __attribute__ ((section(".data")));
+
+/*
+ * Error action
+ */
+inline void hang(void)
+{
+	puts("### ERROR ### Please RESET the board ###\n");
+	for (;;)
+		;
+}
+
+/*
+ * Read the mkimage signature to extract info such as entry point.
+ * The header is generated by tools/mkimage
+ */
+static unsigned long spl_parse_image_header(const struct image_header

*header) +{

arch/arm/cpu/armv7/socfpga/spl.c new file +26 -0
+	/* checking for mkimage signature */
+	if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) {
+		/* Valid image. Extract information out of header */
+		spl_image.size = __be32_to_cpu(header->ih_size);
+		spl_image.entry_point = __be32_to_cpu(header->ih_load);
+		spl_image.load_addr = __be32_to_cpu(header->ih_load);
+		spl_image.os = header->ih_os;
+		spl_image.name = (const char *)&header->ih_name;
+		spl_image.crc = __be32_to_cpu(header->ih_dcrc);
+		debug("Subsequent boot image info\n");
+		debug("   Image Name:   %.*s\n", IH_NMLEN, spl_image.name);
+		debug("   Data Size:    %d\n", spl_image.size);
+		debug("   Load Address: 0x%x\n", spl_image.load_addr);
+		debug("   Entry Point:  0x%X\n", spl_image.entry_point);
+	} else {
+		/* Not a valid image as mkimage signature not found */
+		printf("Error : mkimage signature not found - ih_magic = %x\n",
+			header->ih_magic);
+		return 1;
+	}
+
+	/* Checking image type. Do any customize stuff per image type here */
+	switch (spl_image.os) {
+	case IH_OS_U_BOOT:
+		debug("   Image Type:   U-Boot\n");
+		break;
Quoted 8 lines

arch/arm/cpu/armv7/socfpga/spl.c line 85

Quoted 6 lines
arch/arm/cpu/armv7/socfpga/spl.c new file +6 -0
+	default:
+		printf("   Image Type:   Unknown (%d)\n", spl_image.os);
+		;
+	}
+	return 0;
+}

I think I don't even wanna know what's the purpose here :-)

It's the omap-common/spl.c code with the bits for IH_OS_LINUX taken out :) Can you please re-do your series on top of the SPL series I just posted that provides a common SPL framework? Thanks!

Signature · 1 line
Tom
#4 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi!

Quoted 14 lines
Quoted 7 lines
Quoted 7 lines
Makefile +0 -0
index 5ce5cc3..12aa372 100644
@@ -369,7 +369,7 @@ BOARD_SIZE_CHECK =
 endif
 
Quoted 6 lines
Quoted 4 lines
Makefile +1 -1
 # Always append ALL so that arch config.mk's can add custom ones
-ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
+ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)u-boot.img

$(obj)System.map

This won't slide

Quoted 2 lines

You can place this into arch/arm/cpu/armv7/socfpga/config.mk (see am33xx/config.mk or any of the others) for examples.

Thanks.

Quoted 37 lines
Quoted 28 lines
Quoted 28 lines

+static unsigned long spl_parse_image_header(const struct image_header *header) +{

Makefile +26 -0
+	/* checking for mkimage signature */
+	if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) {
+		/* Valid image. Extract information out of header */
+		spl_image.size = __be32_to_cpu(header->ih_size);
+		spl_image.entry_point = __be32_to_cpu(header->ih_load);
+		spl_image.load_addr = __be32_to_cpu(header->ih_load);
+		spl_image.os = header->ih_os;
+		spl_image.name = (const char *)&header->ih_name;
+		spl_image.crc = __be32_to_cpu(header->ih_dcrc);
+		debug("Subsequent boot image info\n");
+		debug("   Image Name:   %.*s\n", IH_NMLEN, spl_image.name);
+		debug("   Data Size:    %d\n", spl_image.size);
+		debug("   Load Address: 0x%x\n", spl_image.load_addr);
+		debug("   Entry Point:  0x%X\n", spl_image.entry_point);
+	} else {
+		/* Not a valid image as mkimage signature not found */
+		printf("Error : mkimage signature not found - ih_magic = %x\n",
+			header->ih_magic);
+		return 1;
+	}
+
+	/* Checking image type. Do any customize stuff per image type here */
+	switch (spl_image.os) {
+	case IH_OS_U_BOOT:
+		debug("   Image Type:   U-Boot\n");
+		break;
Quoted 8 lines

Makefile

Quoted 6 lines
Makefile +6 -0
+	default:
+		printf("   Image Type:   Unknown (%d)\n", spl_image.os);
+		;
+	}
+	return 0;
+}

I think I don't even wanna know what's the purpose here :-)

Quoted 3 lines

It's the omap-common/spl.c code with the bits for IH_OS_LINUX taken out :) Can you please re-do your series on top of the SPL series I just posted that provides a common SPL framework? Thanks!

I'll take a look. OTOH, ammount of code duplication here is quite low, and redoing it on top of SPL series will mean delaying merge, right?
Pavel

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

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi Pavel,

Quoted 37 lines · Pavel Machek
Quoted 37 lines
Quoted 36 lines
Quoted 24 lines

+static unsigned long spl_parse_image_header(const struct image_header *header) +{

arch/arm/cpu/armv7/socfpga/spl.c new file +22 -0
+	/* checking for mkimage signature */
+	if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) {
+		/* Valid image. Extract information out of header */
+		spl_image.size = __be32_to_cpu(header->ih_size);
+		spl_image.entry_point = __be32_to_cpu(header->ih_load);
+		spl_image.load_addr = __be32_to_cpu(header->ih_load);
+		spl_image.os = header->ih_os;
+		spl_image.name = (const char *)&header->ih_name;
+		spl_image.crc = __be32_to_cpu(header->ih_dcrc);
+		debug("Subsequent boot image info\n");
+		debug("   Image Name:   %.*s\n", IH_NMLEN, spl_image.name);
+		debug("   Data Size:    %d\n", spl_image.size);
+		debug("   Load Address: 0x%x\n", spl_image.load_addr);
+		debug("   Entry Point:  0x%X\n", spl_image.entry_point);
+	} else {
+		/* Not a valid image as mkimage signature not found */
+		printf("Error : mkimage signature not found - ih_magic = %x\n",
+			header->ih_magic);
+		return 1;
+	}
+
+	/* Checking image type. Do any customize stuff per image type here */

arch/arm/cpu/armv7/socfpga/spl.c line 85

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/spl.c new file +10 -0
+	switch (spl_image.os) {
+	case IH_OS_U_BOOT:
+		debug("   Image Type:   U-Boot\n");
+		break;
+	default:
+		printf("   Image Type:   Unknown (%d)\n", spl_image.os);
+		;
+	}
+	return 0;
+}

I think I don't even wanna know what's the purpose here :-)

Quoted 6 lines
Quoted 3 lines

It's the omap-common/spl.c code with the bits for IH_OS_LINUX taken out :) Can you please re-do your series on top of the SPL series I just posted that provides a common SPL framework? Thanks!

I'll take a look. OTOH, ammount of code duplication here is quite low, and redoing it on top of SPL series will mean delaying merge, right?

Yes, that might happen. But we learned in the past that if we don't try to do such code consolidations right from the beginning, it won't happen at all (most of the time). So I'm also in favor of using the common SPL framework now. Please take a look at Tom Rini's v3 series:

http://www.mail-archive.com/u-boot at lists.denx.de/msg91405.html

I also based my powerpc SPL NOR flash booting series on it:

http://www.mail-archive.com/u-boot at lists.denx.de/msg91443.html

Thanks,
Stefan

#6 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi!

Quoted 7 lines
Quoted 2 lines

I'll take a look. OTOH, ammount of code duplication here is quite low, and redoing it on top of SPL series will mean delaying merge, right?

Yes, that might happen. But we learned in the past that if we don't try to do such code consolidations right from the beginning, it won't happen at all (most of the time). So I'm also in favor of using the common SPL framework now. Please take a look at Tom Rini's v3 series:

No problem, it really looks much better on top of Tom's patches.

Pavel

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

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi Pavel,

Quoted 11 lines · Pavel Machek

Hi!

Quoted 7 lines
Quoted 2 lines

I'll take a look. OTOH, ammount of code duplication here is quite low, and redoing it on top of SPL series will mean delaying merge, right?

Yes, that might happen. But we learned in the past that if we don't try to do such code consolidations right from the beginning, it won't happen at all (most of the time). So I'm also in favor of using the common SPL framework now. Please take a look at Tom Rini's v3 series:

No problem, it really looks much better on top of Tom's patches.

Great. Thanks for the extra work.

Cheers,
Stefan

#8 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to Pavel Machek

On 08/23/2012 03:43 AM, Pavel Machek wrote:

[snip]

Quoted 6 lines
Quoted 3 lines

It's the omap-common/spl.c code with the bits for IH_OS_LINUX taken out :) Can you please re-do your series on top of the SPL series I just posted that provides a common SPL framework? Thanks!

I'll take a look. OTOH, ammount of code duplication here is quite low, and redoing it on top of SPL series will mean delaying merge, right?

My hope is that since I got the SPL patches posted in time we can get them in for v2012.10 so no, this will only help your chances :)

Signature · 1 line
Tom
#9 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi!

Quoted 10 lines

[snip]

Quoted 6 lines
Quoted 3 lines

It's the omap-common/spl.c code with the bits for IH_OS_LINUX taken out :) Can you please re-do your series on top of the SPL series I just posted that provides a common SPL framework? Thanks!

I'll take a look. OTOH, ammount of code duplication here is quite low, and redoing it on top of SPL series will mean delaying merge, right?

My hope is that since I got the SPL patches posted in time we can get them in for v2012.10 so no, this will only help your chances :)

Ok, but how do I get them applied?

I tried applying them over:

commit e66443fdb5355e68cfdbbdd37248c4b7eb4968f5

Author: Scott Wood <[email protected]>
Date:   Tue Aug 14 01:44:29 2012 +0000

Makefile: fix HAVE_VENDOR_COMMON_LIB

Commit 8b5a02640adf77301f943e8754992c50df004e8a ("Makefile:
cosmetic:
optimize usage of LIBS-y") broke the build of boards that have a board
vendor "common" directory, by introducing a space between "LIBS-" and
"y".

and am getting errors:

|index b314ed7..d8ade27 100644
|--- a/common/spl/spl.c
|+++ b/common/spl/spl.c

--------------------------
File to patch: ^C

Is there git to pull? One big patch for easier application?

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/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to Tom Rini
Quoted 7 lines · Tom Rini

On 08/23/2012 03:43 AM, Pavel Machek wrote:

[snip]

Quoted 4 lines
Quoted 3 lines

It's the omap-common/spl.c code with the bits for IH_OS_LINUX taken out :) Can you please re-do your series on top of the SPL series I just posted that provides a common SPL framework? Thanks!

Quoted 5 lines
Quoted 2 lines

I'll take a look. OTOH, ammount of code duplication here is quite low, and redoing it on top of SPL series will mean delaying merge, right?

My hope is that since I got the SPL patches posted in time we can get them in for v2012.10 so no, this will only help your chances :)

Got it. I pulled Stefan's version -- he seems to have your changes as a git tree. I merged altera code into that, and with these quick hacks on top of that, it boots. Good sign :-).

arch/arm/cpu/armv7/socfpga/spl.c +1 -22
index 7bd1e2f..74ac8e6 100644
@@ -33,7 +33,7 @@ static struct spl_image_info spl_image;
 extern void __malloc_start, __malloc_end, __stack_start;
 
 /* Define global data structure pointer to it */
-static gd_t gdata __attribute__ ((section(".data")));
+gd_t gdata __attribute__ ((section(".data")));
 
 /*
  * Error action
@@ -134,27 +134,6 @@ static void spl_console_init(void)
 }
 
 /*
- * Board initialization prior bss clearance
- * Do note below concerns when inserting your function here.
- * Please refer to README for more details.
-
- * Initialized global data (data segment) is read-only. Do not attempt
-	to write it.
-
- * Do not use any uninitialized global data (or implicitely initialized
-	as zero data - BSS segment) at all - this is undefined, initiali-
-	zation is performed later (when relocating to RAM).
-
- * Stack space is very limited. Avoid big data buffers or things like
-	that.
- */
-void board_init_f(ulong dummy)
-{
-	/* Will clear bss then jump back to function board_init_r */
-	relocate_code((ulong) &__stack_start, &gdata, CONFIG_SPL_TEXT_BASE);
-}
-
-/*
  * Board initialization after bss clearance
  */
 void board_init_r(gd_t *id, ulong dummy)
arch/arm/lib/Makefile +1 -1
index c892f82..9db93d8 100644
@@ -45,7 +45,7 @@ COBJS-y	+= reset.o
 SOBJS-$(CONFIG_USE_ARCH_MEMSET) += memset.o
 SOBJS-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
 else
-COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
+COBJS-y += spl.o
 endif
 
 COBJS-y	+= cache.o
arch/arm/lib/spl.c +2 -1
index 2d1f47a..8c8806e 100644
@@ -41,8 +41,9 @@ extern char __bss_start[], __bss_end__[];
  */
 void __weak board_init_f(ulong dummy)
 {
+  extern void __stack_start;
 	/* Set the stack pointer. */
-	asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK));
+	asm volatile("mov sp, %0\n" : : "r"(&__stack_start));
 
 	/* Clear the BSS. */
 	memset(__bss_start, 0, __bss_end__ - __bss_start);
include/configs/socfpga_cyclone5.h +1 -0
index 29aa9da..ac52e57 100644
@@ -109,6 +109,7 @@
 #define CONFIG_DOS_PARTITION            1
 
 #ifdef CONFIG_SPL_BUILD
+#define CONFIG_SPL_FRAMEWORK
 #undef CONFIG_PARTITIONS
 #endif
 
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#11 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to Tom Rini

Hi!

Quoted 10 lines

[snip]

Quoted 6 lines
Quoted 3 lines

It's the omap-common/spl.c code with the bits for IH_OS_LINUX taken out :) Can you please re-do your series on top of the SPL series I just posted that provides a common SPL framework? Thanks!

I'll take a look. OTOH, ammount of code duplication here is quite low, and redoing it on top of SPL series will mean delaying merge, right?

My hope is that since I got the SPL patches posted in time we can get them in for v2012.10 so no, this will only help your chances :)

Hopefully.

Some observations:

Not sure what to do with CONFIG_SPL_STACK: altera was just using symbol from linker script. Is there way to keep it like that? I'd hate to invent magic constant.

Same issue with CONFIG_SYS_SPL_MALLOC_START... I was doing:

        /* setup MALLOC after clocks going faster */
	mem_malloc_init((ulong) &__malloc_start,
					(&__malloc_end -
	&__malloc_start));

I guess defines allow me to keep my definition. Good.

spl_parse_image_header(): We have "modern" system, we'd prefer not to do

                /* Signature not found - assume u-boot.bin */

...but to hang in that case, in order not to jump to random code.

Ok, I should have something publishable, soon ;-).
Pavel

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

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Quoted 13 lines · Pavel Machek

Hi!

Quoted 10 lines

[snip]

Quoted 6 lines
Quoted 3 lines

It's the omap-common/spl.c code with the bits for IH_OS_LINUX taken out :) Can you please re-do your series on top of the SPL series I just posted that provides a common SPL framework? Thanks!

I'll take a look. OTOH, ammount of code duplication here is quite low, and redoing it on top of SPL series will mean delaying merge, right?

My hope is that since I got the SPL patches posted in time we can get them in for v2012.10 so no, this will only help your chances :)

Quoted 7 lines

Hopefully.

Some observations:

Not sure what to do with CONFIG_SPL_STACK: altera was just using symbol from linker script. Is there way to keep it like that? I'd hate to invent magic constant.

Well, lets think about this. Previously, everyone has been saying "use this spot in SRAM" or "use this spot in DRAM (which has been setup previously)". But I think you should be able to do
#define CONFIG_SPL_STACK __linker_symbol and be done with it.

Quoted 8 lines

Same issue with CONFIG_SYS_SPL_MALLOC_START... I was doing:

        /* setup MALLOC after clocks going faster */
	mem_malloc_init((ulong) &__malloc_start,
					(&__malloc_end -
	&__malloc_start));

I guess defines allow me to keep my definition. Good.

Should be fine, yes.

Quoted 6 lines

spl_parse_image_header(): We have "modern" system, we'd prefer not to do

                /* Signature not found - assume u-boot.bin */

...but to hang in that case, in order not to jump to random code.

Ok, I should have something publishable, soon ;-).

The only reason I like the assumption idea is that I've already seen at least one distribution ship new MLO (based on SPL) and u-boot.bin rather than u-boot.img for their beagleboard images.

Signature · 1 line
Tom
#13 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi!

Quoted 10 lines
Quoted 5 lines

Some observations:

Not sure what to do with CONFIG_SPL_STACK: altera was just using symbol from linker script. Is there way to keep it like that? I'd hate to invent magic constant.

Well, lets think about this. Previously, everyone has been saying "use this spot in SRAM" or "use this spot in DRAM (which has been setup previously)". But I think you should be able to do
#define CONFIG_SPL_STACK __linker_symbol and be done with it.

Yes, that seems to do the trick... if it is acceptable.

Pavel

commit 2cc99bcf39dc90ec4f43b949b8db75d5b019c92f

Author: Pavel <[email protected]>
Date:   Wed Aug 29 14:04:47 2012 +0200

Use CONFIG_SPL_START as suggested by Tom Rini.

arch/arm/cpu/armv7/socfpga/spl.c +0 -2
index ca5f4cf..88f809d 100644
@@ -27,8 +27,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-extern void __malloc_start, __malloc_end, __stack_start;
-
 /*
  * Console Initialization
  */
arch/arm/include/asm/arch-socfpga/spl.h +27 -0
index 68ceec6..43efa67 100644
@@ -1 +1,28 @@
+/*
+ *  Copyright (C) 2012 Pavel Machek <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SOCFPGA_SPL_H_
+#define _SOCFPGA_SPL_H_
+
+/* Symbols from linker script */
+extern void __malloc_start, __malloc_end, __stack_start;
+
+#define CONFIG_SPL_STACK (&__stack_start)
+
 #define BOOT_DEVICE_RAM 1
+
+#endif
arch/arm/lib/spl.c +1 -2
index 8c8806e..2d1f47a 100644
@@ -41,9 +41,8 @@ extern char __bss_start[], __bss_end__[];
  */
 void __weak board_init_f(ulong dummy)
 {
-  extern void __stack_start;
 	/* Set the stack pointer. */
-	asm volatile("mov sp, %0\n" : : "r"(&__stack_start));
+	asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK));
 
 	/* Clear the BSS. */
 	memset(__bss_start, 0, __bss_end__ - __bss_start);
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#14 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to Tom Rini

Hi!

Quoted 10 lines

[snip]

Quoted 6 lines
Quoted 3 lines

It's the omap-common/spl.c code with the bits for IH_OS_LINUX taken out :) Can you please re-do your series on top of the SPL series I just posted that provides a common SPL framework? Thanks!

I'll take a look. OTOH, ammount of code duplication here is quite low, and redoing it on top of SPL series will mean delaying merge, right?

My hope is that since I got the SPL patches posted in time we can get them in for v2012.10 so no, this will only help your chances :)

Ok, this is promissed patch for comments. socfpga spl.c now got reasonably smaller. It is on top of

http://github.com/trini/u-boot WIP/spl-improvements

Now... can I leave spl_ram_load_image() where it is? Probably add some #ifdef?

Dinh, does this look acceptable to you? Could we switch to absolute addresses for stack/heap in the SPL?

Thanks,

Pavel

MAINTAINERS +5 -0
index c5a6f2f..df48dea 100644
@@ -765,6 +765,11 @@ Nagendra T S  <[email protected]>
 
    am3517_crane    ARM ARMV7 (AM35x SoC)
 
+Dinh Nguyen <[email protected]>
+Chin Liang See <[email protected]>
+
+	socfpga		socfpga_cyclone5
+
 Kyungmin Park <[email protected]>
 
 	apollon		ARM1136EJS
arch/arm/cpu/armv7/socfpga/Makefile new file +51 -0

51 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/config.mk new file +16 -0
new file mode 100644
index 0000000..b72ed1e
@@ -0,0 +1,16 @@
+#
+# Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed "as is" WITHOUT ANY WARRANTY of any
+# kind, whether express or implied; without even the implied warranty
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+ifndef CONFIG_SPL_BUILD
+ALL-y	+= $(obj)u-boot.img
+endif
arch/arm/cpu/armv7/socfpga/lowlevel_init.S new file +79 -0

79 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/misc.c new file +54 -0

54 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/spl.c new file +69 -0

69 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/timer.c new file +149 -0

149 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds new file +60 -0

60 lines not on this page · raw message

arch/arm/include/asm/arch-socfpga/reset_config.h new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/arm/include/asm/arch-socfpga/reset_manager.h new file +37 -0
new file mode 100644
index 0000000..d9d2c1c
@@ -0,0 +1,37 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef	_RESET_MANAGER_H_
+#define	_RESET_MANAGER_H_
+
+void reset_cpu(ulong addr);
+void reset_deassert_peripherals_handoff(void);
+
+struct socfpga_reset_manager {
+	u32	padding1;
+	u32	ctrl;
+	u32	padding2;
+	u32	padding3;
+	u32	mpu_mod_reset;
+	u32	per_mod_reset;
+	u32	per2_mod_reset;
+	u32	brg_mod_reset;
+};
+
+#define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
+
+#endif /* _RESET_MANAGER_H_ */
arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h new file +27 -0
new file mode 100644
index 0000000..f353eb2
@@ -0,0 +1,27 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SOCFPGA_BASE_ADDRS_H_
+#define _SOCFPGA_BASE_ADDRS_H_
+
+#define SOCFPGA_L3REGS_ADDRESS 0xff800000
+#define SOCFPGA_UART0_ADDRESS 0xffc02000
+#define SOCFPGA_UART1_ADDRESS 0xffc03000
+#define SOCFPGA_OSC1TIMER0_ADDRESS 0xffd00000
+#define SOCFPGA_RSTMGR_ADDRESS 0xffd05000
+
+#endif /* _SOCFPGA_BASE_ADDRS_H_ */
arch/arm/include/asm/arch-socfpga/spl.h new file +1 -0
new file mode 100644
index 0000000..68ceec6
@@ -0,0 +1 @@
+#define BOOT_DEVICE_RAM 1
arch/arm/include/asm/arch-socfpga/timer.h new file +29 -0
new file mode 100644
index 0000000..830c94a
@@ -0,0 +1,29 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SOCFPGA_TIMER_H_
+#define _SOCFPGA_TIMER_H_
+
+struct socfpga_timer {
+	u32	load_val;
+	u32	curr_val;
+	u32	ctrl;
+	u32	eoi;
+	u32	int_stat;
+};
+
+#endif
arch/arm/lib/spl.c +2 -1
index 2d1f47a..8c8806e 100644
@@ -41,8 +41,9 @@ extern char __bss_start[], __bss_end__[];
  */
 void __weak board_init_f(ulong dummy)
 {
+  extern void __stack_start;
 	/* Set the stack pointer. */
-	asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK));
+	asm volatile("mov sp, %0\n" : : "r"(&__stack_start));
 
 	/* Clear the BSS. */
 	memset(__bss_start, 0, __bss_end__ - __bss_start);
board/altera/socfpga_cyclone5/Makefile new file +50 -0

50 lines not on this page · raw message

board/altera/socfpga_cyclone5/socfpga_cyclone5.c new file +97 -0

97 lines not on this page · raw message

boards.cfg +1 -0
index fdb84ad..1b5c860 100644
@@ -261,6 +261,7 @@ seaboard                     arm         armv7       seaboard            nvidia
 ventana                      arm         armv7       ventana             nvidia         tegra2
 whistler                     arm         armv7       whistler            nvidia         tegra2
 u8500_href                   arm         armv7       u8500               st-ericsson    u8500
+socfpga_cyclone5              arm         armv7      socfpga_cyclone5    altera		    socfpga
 actux1_4_16                  arm         ixp         actux1              -              -           actux1:FLASH2X2
 actux1_4_32                  arm         ixp         actux1              -              -           actux1:FLASH2X2,RAM_32MB
 actux1_8_16                  arm         ixp         actux1              -              -           actux1:FLASH1X8
common/spl/spl.c +19 -0
index eaea1c8..b87df65 100644
@@ -78,6 +78,7 @@ void spl_parse_image_header(const struct image_header *header)
 	u32 header_size = sizeof(struct image_header);
 
 	if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) {
+		/* Valid image. Extract information out of header */
 		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
 		spl_image.entry_point = __be32_to_cpu(header->ih_load);
 		/* Load including the header */
@@ -115,6 +116,21 @@ static void __noreturn jump_to_image_no_args(void)
 	image_entry((u32 *)boot_params_ptr_addr);
 }
 
+static void spl_ram_load_image(void)
+{
+	u32 err;
+	const struct image_header *header;
+
+	/* get the header */
+	/* it will point to a address defined by handoff which
+	will tell where the image located inside the flash. For now,
+	it will temporary fixed to address pointed by U-Boot */
+	header = (struct image_header *)
+		(CONFIG_SYS_TEXT_BASE -	sizeof(struct image_header));
+
+	spl_parse_image_header(header);
+}
+
 void board_init_r(gd_t *dummy1, ulong dummy2)
 {
 	u32 boot_device;
@@ -132,6 +148,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	boot_device = spl_boot_device();
 	debug("boot device - %d\n", boot_device);
 	switch (boot_device) {
+	case BOOT_DEVICE_RAM:
+		spl_ram_load_image();
+		break;
 #ifdef CONFIG_SPL_MMC_SUPPORT
 	case BOOT_DEVICE_MMC1:
 	case BOOT_DEVICE_MMC2:
include/common.h +3 -1
index 55025c0..469a3af 100644
@@ -704,7 +704,9 @@ void	external_interrupt (struct pt_regs *);
 void	irq_install_handler(int, interrupt_handler_t *, void *);
 void	irq_free_handler   (int);
 void	reset_timer	   (void);
-ulong	get_timer	   (ulong base);
+ulong	get_timer(ulong base);
+void	reset_timer_count(void);
+ulong	get_timer_count(ulong base);
 void	enable_interrupts  (void);
 int	disable_interrupts (void);
 
include/configs/socfpga_cyclone5.h new file +242 -0

242 lines not on this page · raw message

spl/Makefile +1 -0
index f96c08e4..d757448 100644
@@ -58,6 +58,7 @@ LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o
 LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o
 LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o
 LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/memory.o
+LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o
 
 ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#15 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Quoted 7 lines · Pavel Machek

Hi!

Quoted 5 lines

[snip]

Quoted 4 lines
Quoted 3 lines

It's the omap-common/spl.c code with the bits for IH_OS_LINUX taken out :) Can you please re-do your series on top of the SPL series I just posted that provides a common SPL framework? Thanks!

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I'll take a look. OTOH, ammount of code duplication here is quite low, and redoing it on top of SPL series will mean delaying merge, right?

My hope is that since I got the SPL patches posted in time we can get them in for v2012.10 so no, this will only help your chances :)

Ok, this is promissed patch for comments. socfpga spl.c now got reasonably smaller. It is on top of

Looks good overall. I don't see asm/arch/spl.h but that's where you could put the extern for __stack_start and then define CONFIG_SPL_STACK to &__stack_start.

Quoted 4 lines

http://github.com/trini/u-boot WIP/spl-improvements

Now... can I leave spl_ram_load_image() where it is? Probably add some #ifdef?

Yeah, I think that's OK to start with, we can move things more later if needed.

Quoted 3 lines

Dinh, does this look acceptable to you? Could we switch to absolute addresses for stack/heap in the SPL?

[snip]

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

Quoted 12 lines
arch/arm/cpu/armv7/socfpga/spl.c new file +12 -0
+/*
+ * Console Initialization
+ */
+static void spl_console_init(void)
+{
+	gd->flags |= GD_FLG_RELOC;
+	gd->baudrate = CONFIG_BAUDRATE;
+
+	/* serial communications setup */
+	serial_init();
+	gd->have_console = 1;
+}

Looks like preloader_console_init :)

Quoted 13 lines
arch/arm/cpu/armv7/socfpga/spl.c new file +13 -0
+
+u32 spl_boot_device(void)
+{
+	return BOOT_DEVICE_RAM;
+}
+
+/*
+ * Board initialization after bss clearance
+ */
+void spl_board_init(void)
+{
+	/* init timer for enabling delay function */
+	timer_init();

arch/arm/cpu/armv7/socfpga/spl.c line 66

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/spl.c new file +10 -0
+
+	/* de-assert reset for peripherals and bridges based on handoff */
+	reset_deassert_peripherals_handoff();
+
+	/* enable console uart printing */
+	spl_console_init();
+
+	/* setup MALLOC after clocks going faster */
+	mem_malloc_init((ulong) &__malloc_start,
+			(&__malloc_end - &__malloc_start));

Shouldn't need this, should already be called before you get to spl_board_init.

[snip]

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds

Quoted 1 line
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -0

You should setup MEMORY declarations like the other u-boot-spl linker scripts do so we get build-time confirmation that we haven't exceeded our size limitations.

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds line 59

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +10 -0
+	. = . + 4;
+	. = ALIGN(8);
+	__malloc_start = .;
+	. = . + CONFIG_SPL_MALLOC_SIZE;
+	__malloc_end = .;
+
+	. = . + 4;
+	. = . + CONFIG_SPL_STACK_SIZE;
+	. = ALIGN(8);
+	__stack_start = .;

Do you really need to do . = . + 4 and then align statements?

[snip]

spl/Makefile LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o · line 64

Quoted 13 lines
spl/Makefile +1 -0
index f96c08e4..d757448 100644
@@ -58,6 +58,7 @@ LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o
 LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o
 LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o
 LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/memory.o
+LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o
 
 ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o

Er? There's already a line for lib/libgeneric.o

Quoted 1 line
#16 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi!

Quoted 6 lines
Quoted 2 lines

Ok, this is promissed patch for comments. socfpga spl.c now got reasonably smaller. It is on top of

Looks good overall. I don't see asm/arch/spl.h but that's where you could put the extern for __stack_start and then define CONFIG_SPL_STACK to &__stack_start.

Yep, that works, thanks!

Quoted 7 lines
Quoted 4 lines

http://github.com/trini/u-boot WIP/spl-improvements

Now... can I leave spl_ram_load_image() where it is? Probably add some #ifdef?

Yeah, I think that's OK to start with, we can move things more later if needed.

Cool.

Quoted 3 lines
Quoted 1 line

+static void spl_console_init(void)

Looks like preloader_console_init :)

And works the same, too. Shared. Thanks!

Quoted 6 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+	/* setup MALLOC after clocks going faster */
+	mem_malloc_init((ulong) &__malloc_start,
+			(&__malloc_end - &__malloc_start));

Shouldn't need this, should already be called before you get to spl_board_init.

Yep, I set up CONFIG_SYS_... and it seems to work.

Quoted 6 lines

[snip]

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds

Quoted 1 line
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -0

You should setup MEMORY declarations like the other u-boot-spl linker scripts do so we get build-time confirmation that we haven't exceeded our size limitations.

Ok, I'll do that as a next step.

Quoted 4 lines
Quoted 4 lines
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +4 -0
+	. = . + 4;
+	. = ALIGN(8);
+	__malloc_start = .;
+	. = . + CONFIG_SPL_MALLOC_SIZE;
Quoted 8 lines

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds

Quoted 6 lines
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +6 -0
+	__malloc_end = .;
+
+	. = . + 4;
+	. = . + CONFIG_SPL_STACK_SIZE;
+	. = ALIGN(8);
+	__stack_start = .;

Do you really need to do . = . + 4 and then align statements?

Probably not. Removed.

Quoted 3 lines
Quoted 1 line

+LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o

q
Er? There's already a line for lib/libgeneric.o

Sorry. Deleted.

Thanks,
Pavel

arch/arm/cpu/armv7/socfpga/spl.c +0 -4
index c12e339..bf03333 100644
@@ -46,9 +46,5 @@ void spl_board_init(void)
 	/* enable console uart printing */
 	preloader_console_init();
 
-	/* setup MALLOC after clocks going faster */
-	mem_malloc_init((ulong) &__malloc_start,
-			(&__malloc_end - &__malloc_start));
-
 	puts("SPL Boot\n");
 }
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -2
index de74341..2c90753 100644
@@ -47,13 +47,11 @@ SECTIONS
 		__bss_end__ = .;
 	}
 
-	. = . + 4;
 	. = ALIGN(8);
 	__malloc_start = .;
 	. = . + CONFIG_SPL_MALLOC_SIZE;
 	__malloc_end = .;
 
-	. = . + 4;
 	. = . + CONFIG_SPL_STACK_SIZE;
 	. = ALIGN(8);
 	__stack_start = .;
arch/arm/include/asm/arch-socfpga/spl.h +2 -0
index 43efa67..c9e5f50 100644
@@ -22,6 +22,8 @@
 extern void __malloc_start, __malloc_end, __stack_start;
 
 #define CONFIG_SPL_STACK (&__stack_start)
+#define CONFIG_SYS_SPL_MALLOC_START (&__malloc_start)
+#define CONFIG_SYS_SPL_MALLOC_SIZE (&__malloc_end - &__malloc_start)
 
 #define BOOT_DEVICE_RAM 1
 
common/spl/spl.c +0 -1
index b87df65..5adbf0e 100644
@@ -118,7 +118,6 @@ static void __noreturn jump_to_image_no_args(void)
 
 static void spl_ram_load_image(void)
 {
-	u32 err;
 	const struct image_header *header;
 
 	/* get the header */
spl/Makefile +0 -1
index d757448..f96c08e4 100644
@@ -58,7 +58,6 @@ LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o
 LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o
 LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o
 LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/memory.o
-LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o
 
 ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#17 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to Tom Rini

Hi!

Quoted 5 lines

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds

Quoted 1 line
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -0

You should setup MEMORY declarations like the other u-boot-spl linker scripts do so we get build-time confirmation that we haven't exceeded our size limitations.

Hmm, I tried, but I don't know socfpga memory layout by heart.

Dinh, can you help here?

Thanks,
Pavel

arch/arm/cpu/armv7/omap-common/u-boot-spl.lds +3 -3
index 8867e06..1d8efb2 100644
@@ -37,9 +37,9 @@ SECTIONS
 {
 	.text      :
 	{
-	__start = .;
-	  arch/arm/cpu/armv7/start.o	(.text)
-	  *(.text*)
+		__start = .;
+		arch/arm/cpu/armv7/start.o	(.text)
+		*(.text*)
 	} >.sram
 
 	. = ALIGN(4);
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +6 -4
index 2c90753..7cd409c 100644
@@ -15,6 +15,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+MEMORY { .sdram : ORIGIN = (0), LENGTH = (0xffffffff) }
+
 OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
 OUTPUT_ARCH(arm)
 ENTRY(_start)
@@ -27,13 +29,13 @@ SECTIONS
 	{
 		arch/arm/cpu/armv7/start.o	(.text)
 		*(.text*)
-	}
+	} >.sdram
 
 	. = ALIGN(4);
-	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
+	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } >.sdram
 
 	. = ALIGN(4);
-	.data : { *(SORT_BY_ALIGNMENT(.data*)) }
+	.data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sdram
 
 	. = ALIGN(4);
 	__image_copy_end = .;
@@ -45,7 +47,7 @@ SECTIONS
 		*(.bss*)
 		. = ALIGN(4);
 		__bss_end__ = .;
-	}
+	} >.sdram
 
 	. = ALIGN(8);
 	__malloc_start = .;
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 1/1 ARM: Add Altera SOCFPGA Cyclone5

Quoted 11 lines · Pavel Machek

Hi!

Quoted 5 lines

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds

Quoted 1 line
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -0

You should setup MEMORY declarations like the other u-boot-spl linker scripts do so we get build-time confirmation that we haven't exceeded our size limitations.

Hmm, I tried, but I don't know socfpga memory layout by heart.

Dinh, can you help here?

I think once you get the answers you should be able to re-post the series cleanly and depend on my v5 (or v6) branch. Thanks!

Signature · 1 line
Tom
#19 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi!

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds

Quoted 1 line
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -0

You should setup MEMORY declarations like the other u-boot-spl linker scripts do so we get build-time confirmation that we haven't exceeded our size limitations.

Quoted 6 lines
Quoted 3 lines

Hmm, I tried, but I don't know socfpga memory layout by heart.

Dinh, can you help here?

I think once you get the answers you should be able to re-post the series cleanly and depend on my v5 (or v6) branch. Thanks!

Ok, figuring the .lds might be tricky. But... that's mostly additional (safety) feature. Would it be possible to merge it without that and add it later?

Port to v5 of the patch should not be a problem.

For the record and review, current version of patch is here.

Pavel

MAINTAINERS +5 -0
index c5a6f2f..df48dea 100644
@@ -765,6 +765,11 @@ Nagendra T S  <[email protected]>
 
    am3517_crane    ARM ARMV7 (AM35x SoC)
 
+Dinh Nguyen <[email protected]>
+Chin Liang See <[email protected]>
+
+	socfpga		socfpga_cyclone5
+
 Kyungmin Park <[email protected]>
 
 	apollon		ARM1136EJS
arch/arm/cpu/armv7/socfpga/Makefile new file +51 -0

51 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/config.mk new file +16 -0
new file mode 100644
index 0000000..b72ed1e
@@ -0,0 +1,16 @@
+#
+# Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed "as is" WITHOUT ANY WARRANTY of any
+# kind, whether express or implied; without even the implied warranty
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+ifndef CONFIG_SPL_BUILD
+ALL-y	+= $(obj)u-boot.img
+endif
arch/arm/cpu/armv7/socfpga/lowlevel_init.S new file +79 -0

79 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/misc.c new file +54 -0

54 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/spl.c new file +50 -0

50 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/timer.c new file +149 -0

149 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds new file +60 -0

60 lines not on this page · raw message

arch/arm/include/asm/arch-socfpga/reset_config.h new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/arm/include/asm/arch-socfpga/reset_manager.h new file +37 -0
new file mode 100644
index 0000000..d9d2c1c
@@ -0,0 +1,37 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef	_RESET_MANAGER_H_
+#define	_RESET_MANAGER_H_
+
+void reset_cpu(ulong addr);
+void reset_deassert_peripherals_handoff(void);
+
+struct socfpga_reset_manager {
+	u32	padding1;
+	u32	ctrl;
+	u32	padding2;
+	u32	padding3;
+	u32	mpu_mod_reset;
+	u32	per_mod_reset;
+	u32	per2_mod_reset;
+	u32	brg_mod_reset;
+};
+
+#define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
+
+#endif /* _RESET_MANAGER_H_ */
arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h new file +27 -0
new file mode 100644
index 0000000..f353eb2
@@ -0,0 +1,27 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SOCFPGA_BASE_ADDRS_H_
+#define _SOCFPGA_BASE_ADDRS_H_
+
+#define SOCFPGA_L3REGS_ADDRESS 0xff800000
+#define SOCFPGA_UART0_ADDRESS 0xffc02000
+#define SOCFPGA_UART1_ADDRESS 0xffc03000
+#define SOCFPGA_OSC1TIMER0_ADDRESS 0xffd00000
+#define SOCFPGA_RSTMGR_ADDRESS 0xffd05000
+
+#endif /* _SOCFPGA_BASE_ADDRS_H_ */
arch/arm/include/asm/arch-socfpga/spl.h new file +30 -0
new file mode 100644
index 0000000..c9e5f50
@@ -0,0 +1,30 @@
+/*
+ *  Copyright (C) 2012 Pavel Machek <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SOCFPGA_SPL_H_
+#define _SOCFPGA_SPL_H_
+
+/* Symbols from linker script */
+extern void __malloc_start, __malloc_end, __stack_start;
+
+#define CONFIG_SPL_STACK (&__stack_start)
+#define CONFIG_SYS_SPL_MALLOC_START (&__malloc_start)
+#define CONFIG_SYS_SPL_MALLOC_SIZE (&__malloc_end - &__malloc_start)
+
+#define BOOT_DEVICE_RAM 1
+
+#endif
arch/arm/include/asm/arch-socfpga/timer.h new file +29 -0
new file mode 100644
index 0000000..830c94a
@@ -0,0 +1,29 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SOCFPGA_TIMER_H_
+#define _SOCFPGA_TIMER_H_
+
+struct socfpga_timer {
+	u32	load_val;
+	u32	curr_val;
+	u32	ctrl;
+	u32	eoi;
+	u32	int_stat;
+};
+
+#endif
board/altera/socfpga_cyclone5/Makefile new file +50 -0

50 lines not on this page · raw message

board/altera/socfpga_cyclone5/socfpga_cyclone5.c new file +97 -0

97 lines not on this page · raw message

boards.cfg +1 -0
index fdb84ad..1b5c860 100644
@@ -261,6 +261,7 @@ seaboard                     arm         armv7       seaboard            nvidia
 ventana                      arm         armv7       ventana             nvidia         tegra2
 whistler                     arm         armv7       whistler            nvidia         tegra2
 u8500_href                   arm         armv7       u8500               st-ericsson    u8500
+socfpga_cyclone5              arm         armv7      socfpga_cyclone5    altera		    socfpga
 actux1_4_16                  arm         ixp         actux1              -              -           actux1:FLASH2X2
 actux1_4_32                  arm         ixp         actux1              -              -           actux1:FLASH2X2,RAM_32MB
 actux1_8_16                  arm         ixp         actux1              -              -           actux1:FLASH1X8
common/spl/spl.c +18 -0
index eaea1c8..5adbf0e 100644
@@ -78,6 +78,7 @@ void spl_parse_image_header(const struct image_header *header)
 	u32 header_size = sizeof(struct image_header);
 
 	if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) {
+		/* Valid image. Extract information out of header */
 		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
 		spl_image.entry_point = __be32_to_cpu(header->ih_load);
 		/* Load including the header */
@@ -115,6 +116,20 @@ static void __noreturn jump_to_image_no_args(void)
 	image_entry((u32 *)boot_params_ptr_addr);
 }
 
+static void spl_ram_load_image(void)
+{
+	const struct image_header *header;
+
+	/* get the header */
+	/* it will point to a address defined by handoff which
+	will tell where the image located inside the flash. For now,
+	it will temporary fixed to address pointed by U-Boot */
+	header = (struct image_header *)
+		(CONFIG_SYS_TEXT_BASE -	sizeof(struct image_header));
+
+	spl_parse_image_header(header);
+}
+
 void board_init_r(gd_t *dummy1, ulong dummy2)
 {
 	u32 boot_device;
@@ -132,6 +147,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	boot_device = spl_boot_device();
 	debug("boot device - %d\n", boot_device);
 	switch (boot_device) {
+	case BOOT_DEVICE_RAM:
+		spl_ram_load_image();
+		break;
 #ifdef CONFIG_SPL_MMC_SUPPORT
 	case BOOT_DEVICE_MMC1:
 	case BOOT_DEVICE_MMC2:
include/common.h +3 -1
index 55025c0..469a3af 100644
@@ -704,7 +704,9 @@ void	external_interrupt (struct pt_regs *);
 void	irq_install_handler(int, interrupt_handler_t *, void *);
 void	irq_free_handler   (int);
 void	reset_timer	   (void);
-ulong	get_timer	   (ulong base);
+ulong	get_timer(ulong base);
+void	reset_timer_count(void);
+ulong	get_timer_count(ulong base);
 void	enable_interrupts  (void);
 int	disable_interrupts (void);
 
include/configs/socfpga_cyclone5.h new file +242 -0

242 lines not on this page · raw message

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

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Quoted 15 lines · Pavel Machek

Hi!

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds

Quoted 1 line
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -0

You should setup MEMORY declarations like the other u-boot-spl linker scripts do so we get build-time confirmation that we haven't exceeded our size limitations.

Quoted 6 lines
Quoted 3 lines

Hmm, I tried, but I don't know socfpga memory layout by heart.

Dinh, can you help here?

I think once you get the answers you should be able to re-post the series cleanly and depend on my v5 (or v6) branch. Thanks!

Quoted 7 lines

Ok, figuring the .lds might be tricky. But... that's mostly additional (safety) feature. Would it be possible to merge it without that and add it later?

Port to v5 of the patch should not be a problem.

For the record and review, current version of patch is here.

A few small comments. No need to re-post intermediate patches, just address in the next full go-round. Thanks!

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

[snip]

Quoted 4 lines
arch/arm/cpu/armv7/socfpga/spl.c +4 -0
+/*
+ * Board initialization after bss clearance
+ */
+void spl_board_init(void)

[snip]

arch/arm/cpu/armv7/socfpga/spl.c line 49

Quoted 1 line
arch/arm/cpu/armv7/socfpga/spl.c +1 -0
+	puts("SPL Boot\n");

Sure you want to keep that line? We already have a general "U-Boot SPL ..." line being printed.

[snip]

Quoted 1 line
arch/arm/include/asm/arch-socfpga/spl.h +0 -0

[snip]

arch/arm/include/asm/arch-socfpga/spl.h line 26

Quoted 3 lines
arch/arm/include/asm/arch-socfpga/spl.h +3 -0
+#define CONFIG_SPL_STACK (&__stack_start)
+#define CONFIG_SYS_SPL_MALLOC_START (&__malloc_start)
+#define CONFIG_SYS_SPL_MALLOC_SIZE (&__malloc_end - &__malloc_start)

These should be in the config file.

Quoted 1 line
board/altera/socfpga_cyclone5/socfpga_cyclone5.c +0 -0

[snip]

board/altera/socfpga_cyclone5/socfpga_cyclone5.c line 81

Quoted 9 lines
board/altera/socfpga_cyclone5/socfpga_cyclone5.c +9 -0
+/*
+ * miscellaneous platform dependent initialisations
+ */
+int misc_init_r(void)
+{
+	/* Set to "n" for not verifying the uImage */
+	setenv("verify", "n");
+	return 0;
+}

Not good to enforce policy like this. Just don't set it in the config file by default and let users do as they need.

[snip]

common/spl/spl.c void spl_parse_image_header(const struct image_header *header) · line 84

Quoted 12 lines
common/spl/spl.c +1 -0
index eaea1c8..5adbf0e 100644
@@ -78,6 +78,7 @@ void spl_parse_image_header(const struct image_header *header)
 	u32 header_size = sizeof(struct image_header);
 
 	if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) {
+		/* Valid image. Extract information out of header */
 		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
 		spl_image.entry_point = __be32_to_cpu(header->ih_load);
 		/* Load including the header */

Just an extra comment, drop please. Or split out if you feel it's really helpful. No strong opinion here other than not in the same patch as the rest.

[snip]

Quoted 5 lines
include/common.h +0 -0
index 55025c0..469a3af 100644

include/common.h void external_interrupt (struct pt_regs *); · line 711

Quoted 9 lines
include/common.h +3 -1
@@ -704,7 +704,9 @@ void	external_interrupt (struct pt_regs *);
 void	irq_install_handler(int, interrupt_handler_t *, void *);
 void	irq_free_handler   (int);
 void	reset_timer	   (void);
-ulong	get_timer	   (ulong base);
+ulong	get_timer(ulong base);
+void	reset_timer_count(void);
+ulong	get_timer_count(ulong base);
 void	enable_interrupts  (void);
 int	disable_interrupts (void);

Make the new declarations match the old, spacing wise please.

Quoted 6 lines
include/configs/socfpga_cyclone5.h new file +0 -0
new file mode 100644
index 0000000..d001cbb

[snip]

Quoted 1 line

+#undef CONFIG_USE_IRQ

[snip]

include/configs/socfpga_cyclone5.h line 86

Quoted 13 lines
include/configs/socfpga_cyclone5.h new file +13 -0
+
+/*
+ * Stack sizes
+ * The stack sizes are set up in start.S using the settings below
+ */
+/* regular stack */
+#define CONFIG_STACKSIZE		(128 << 10)
+#ifdef CONFIG_USE_IRQ
+/* IRQ stack */
+#define CONFIG_STACKSIZE_IRQ		(4 << 10)
+/* FIQ stack */
+#define CONFIG_STACKSIZE_FIQ		(4 << 10)
+#endif

Unused, please drop.

[snip]

Quoted 1 line

+#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "

This is the default now, can be dropped.

Signature · 1 line
Tom
#21 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi!

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

I think once you get the answers you should be able to re-post the series cleanly and depend on my v5 (or v6) branch. Thanks!

Ok, figuring the .lds might be tricky. But... that's mostly additional (safety) feature. Would it be possible to merge it without that and add it later?

Quoted 6 lines
Quoted 3 lines

Port to v5 of the patch should not be a problem.

For the record and review, current version of patch is here.

A few small comments. No need to re-post intermediate patches, just address in the next full go-round. Thanks!

They were mostly for synchronization with Dinh. Sorry for the noise.

Quoted 6 lines
Quoted 1 line

+void spl_board_init(void)

[snip]

arch/arm/cpu/armv7/socfpga/spl.c line 49

Quoted 1 line
arch/arm/cpu/armv7/socfpga/spl.c new file +1 -0
+	puts("SPL Boot\n");

Sure you want to keep that line? We already have a general "U-Boot SPL ..." line being printed.

Killed.

Quoted 11 lines

board/altera/socfpga_cyclone5/socfpga_cyclone5.c line 81

Quoted 8 lines

+ * miscellaneous platform dependent initialisations
+ */

board/altera/socfpga_cyclone5/socfpga_cyclone5.c new file +6 -0
+int misc_init_r(void)
+{
+	/* Set to "n" for not verifying the uImage */
+	setenv("verify", "n");
+	return 0;
+}

Not good to enforce policy like this. Just don't set it in the config file by default and let users do as they need.

Hmm. I moved it to CONFIG_EXTRA_ENV_SETTINGS as done by for eample u8500_href.h. Is that ok?

Quoted 8 lines

[snip]

Quoted 7 lines
common/spl/spl.c +0 -0
index eaea1c8..5adbf0e 100644
@@ -78,6 +78,7 @@ void spl_parse_image_header(const struct image_header *header)
 	u32 header_size = sizeof(struct image_header);
 
Quoted 9 lines

common/spl/spl.c void spl_parse_image_header(const struct image_header *header) · line 84

Quoted 5 lines
common/spl/spl.c +1 -0
 	if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) {
+		/* Valid image. Extract information out of header */
 		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
 		spl_image.entry_point = __be32_to_cpu(header->ih_load);
 		/* Load including the header */

Just an extra comment, drop please. Or split out if you feel it's really helpful. No strong opinion here other than not in the same patch as the rest.

Ok, I'll drop it, and the omap cleanup also. Not worth the merge effort.

spl_ram_load_image... will I need to create some kind of #ifdef? Or would #ifdef BOOT_DEVICE_RAM do the trick?

Quoted 17 lines

[snip]

Quoted 5 lines
include/common.h +0 -0
index 55025c0..469a3af 100644

include/common.h void external_interrupt (struct pt_regs *); · line 711

Quoted 9 lines
include/common.h +3 -1
@@ -704,7 +704,9 @@ void	external_interrupt (struct pt_regs *);
 void	irq_install_handler(int, interrupt_handler_t *, void *);
 void	irq_free_handler   (int);
 void	reset_timer	   (void);
-ulong	get_timer	   (ulong base);
+ulong	get_timer(ulong base);
+void	reset_timer_count(void);
+ulong	get_timer_count(ulong base);
 void	enable_interrupts  (void);
 int	disable_interrupts (void);

Make the new declarations match the old, spacing wise please.

Ok, but checkpatch will complain. ... .... hmm. Why do I have feeling that they are not needed at all? Removed, and things still work. Good.

Rest was fixed in obvious way. Thanks for comments!
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 1/1 ARM: Add Altera SOCFPGA Cyclone5

Quoted 12 lines · Pavel Machek
Quoted 11 lines

board/altera/socfpga_cyclone5/socfpga_cyclone5.c line 81

Quoted 8 lines

+ * miscellaneous platform dependent initialisations
+ */

board/altera/socfpga_cyclone5/socfpga_cyclone5.c new file +6 -0
+int misc_init_r(void)
+{
+	/* Set to "n" for not verifying the uImage */
+	setenv("verify", "n");
+	return 0;
+}

Not good to enforce policy like this. Just don't set it in the config file by default and let users do as they need.

Quoted 2 lines

Hmm. I moved it to CONFIG_EXTRA_ENV_SETTINGS as done by for eample u8500_href.h. Is that ok?

It defaults to no, I believe is the thing (so yes, there's a few bad examples out there including, urk, one that I own).

Quoted 18 lines
Quoted 8 lines

[snip]

Quoted 7 lines
common/spl/spl.c +0 -0
index eaea1c8..5adbf0e 100644
@@ -78,6 +78,7 @@ void spl_parse_image_header(const struct image_header *header)
 	u32 header_size = sizeof(struct image_header);
 
Quoted 9 lines

common/spl/spl.c void spl_parse_image_header(const struct image_header *header) · line 84

Quoted 5 lines
common/spl/spl.c +1 -0
 	if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) {
+		/* Valid image. Extract information out of header */
 		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
 		spl_image.entry_point = __be32_to_cpu(header->ih_load);
 		/* Load including the header */

Just an extra comment, drop please. Or split out if you feel it's really helpful. No strong opinion here other than not in the same patch as the rest.

Quoted 5 lines

Ok, I'll drop it, and the omap cleanup also. Not worth the merge effort.

spl_ram_load_image... will I need to create some kind of #ifdef? Or would #ifdef BOOT_DEVICE_RAM do the trick?

Good point, yes, we should add CONFIG_SPL_RAM_DEVICE and document it in docs/README.SPL and the toplevel README.

Signature · 1 line
Tom
#23 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Quoted 14 lines · Tom Rini
Quoted 12 lines · Pavel Machek
Quoted 11 lines

board/altera/socfpga_cyclone5/socfpga_cyclone5.c line 81

Quoted 8 lines

+ * miscellaneous platform dependent initialisations
+ */

board/altera/socfpga_cyclone5/socfpga_cyclone5.c new file +6 -0
+int misc_init_r(void)
+{
+	/* Set to "n" for not verifying the uImage */
+	setenv("verify", "n");
+	return 0;
+}

Not good to enforce policy like this. Just don't set it in the config file by default and let users do as they need.

Quoted 5 lines
Quoted 2 lines

Hmm. I moved it to CONFIG_EXTRA_ENV_SETTINGS as done by for eample u8500_href.h. Is that ok?

It defaults to no, I believe is the thing (so yes, there's a few bad examples out there including, urk, one that I own).

I take it back, yes is the default, so yes, doing CONFIG_EXTRA_ENV_SETTINGS with verify=no is correct.

Signature · 1 line
Tom
#24 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to Tom Rini

Hi!

Quoted 17 lines
Quoted 17 lines
Quoted 16 lines

common/spl/spl.c void spl_parse_image_header(const struct image_header *header) · line 84

Quoted 12 lines
common/spl/spl.c +1 -0
index eaea1c8..5adbf0e 100644
@@ -78,6 +78,7 @@ void spl_parse_image_header(const struct image_header *header)
 	u32 header_size = sizeof(struct image_header);
 
 	if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) {
+		/* Valid image. Extract information out of header */
 		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
 		spl_image.entry_point = __be32_to_cpu(header->ih_load);
 		/* Load including the header */

Just an extra comment, drop please. Or split out if you feel it's really helpful. No strong opinion here other than not in the same patch as the rest.

Quoted 8 lines
Quoted 5 lines

Ok, I'll drop it, and the omap cleanup also. Not worth the merge effort.

spl_ram_load_image... will I need to create some kind of #ifdef? Or would #ifdef BOOT_DEVICE_RAM do the trick?

Good point, yes, we should add CONFIG_SPL_RAM_DEVICE and document it in docs/README.SPL and the toplevel README.

Ok, something like this? Posting separately, maybe it makes sense to merge to your PATCH v6...?

[And mental note that HEAP_SIZE needs to be cleaned up in socfpga].

Thanks,
Pavel
commit 644da18450edd725263f3bf4a721654707a700af

Author: Pavel <[email protected]>
Date:   Thu Aug 30 20:03:42 2012 +0200

Introduce CONFIG_SPL_RAM_DEVICE, as suggested by Tom.

README +3 -0
index ddbeb1b..e782cce 100644
@@ -2636,6 +2636,9 @@ FIT uImage format:
 		CONFIG_SPL_SPI_SUPPORT
 		Support for drivers/spi/libspi.o in SPL binary
 
+		CONFIG_SPL_RAM_DEVICE
+		Support for running image already present in ram, in SPL binary 
+
 		CONFIG_SPL_LIBGENERIC_SUPPORT
 		Support for lib/libgeneric.o in SPL binary
 
common/spl/spl.c +4 -0
index 229fd01..fb96a75 100644
@@ -115,6 +115,7 @@ static void __noreturn jump_to_image_no_args(void)
 	image_entry((u32 *)boot_params_ptr_addr);
 }
 
+#ifdef CONFIG_SPL_RAM_DEVICE
 static void spl_ram_load_image(void)
 {
 	const struct image_header *header;
@@ -128,6 +129,7 @@ static void spl_ram_load_image(void)
 
 	spl_parse_image_header(header);
 }
+#endif
 
 void board_init_r(gd_t *dummy1, ulong dummy2)
 {
@@ -146,9 +148,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	boot_device = spl_boot_device();
 	debug("boot device - %d\n", boot_device);
 	switch (boot_device) {
+#ifdef CONFIG_SPL_RAM_DEVICE
 	case BOOT_DEVICE_RAM:
 		spl_ram_load_image();
 		break;
+#endif
 #ifdef CONFIG_SPL_MMC_SUPPORT
 	case BOOT_DEVICE_MMC1:
 	case BOOT_DEVICE_MMC2:
doc/README.SPL +1 -0
index e4a5ac3..2acafba 100644
@@ -66,6 +66,7 @@ CONFIG_SPL_DMA_SUPPORT (drivers/dma/libdma.o)
 CONFIG_SPL_POST_MEM_SUPPORT (post/drivers/memory.o)
 CONFIG_SPL_NAND_LOAD (drivers/mtd/nand/nand_spl_load.o)
 CONFIG_SPL_SPI_LOAD (drivers/mtd/spi/spi_spl_load.o)
+CONFIG_SPL_RAM_DEVICE (common/spl/spl.c)
 
 
 Normally CPU is assumed to be the same between the SPL and normal
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#25 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Quoted 22 lines · Pavel Machek

Hi!

Quoted 20 lines
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
common/spl/spl.c +0 -0
index eaea1c8..5adbf0e 100644
@@ -78,6 +78,7 @@ void spl_parse_image_header(const struct image_header *header)
 	u32 header_size = sizeof(struct image_header);
 
Quoted 9 lines

common/spl/spl.c void spl_parse_image_header(const struct image_header *header) · line 84

Quoted 5 lines
common/spl/spl.c +1 -0
 	if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) {
+		/* Valid image. Extract information out of header */
 		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
 		spl_image.entry_point = __be32_to_cpu(header->ih_load);
 		/* Load including the header */

Just an extra comment, drop please. Or split out if you feel it's really helpful. No strong opinion here other than not in the same patch as the rest.

Ok, I'll drop it, and the omap cleanup also. Not worth the merge effort.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

spl_ram_load_image... will I need to create some kind of #ifdef? Or would #ifdef BOOT_DEVICE_RAM do the trick?

Good point, yes, we should add CONFIG_SPL_RAM_DEVICE and document it in docs/README.SPL and the toplevel README.

Ok, something like this? Posting separately, maybe it makes sense to merge to your PATCH v6...?

Sure, just include the actual spl_ram_load_image bits as well and I'll pick it up.

Signature · 1 line
Tom
#26 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi!

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

spl_ram_load_image... will I need to create some kind of #ifdef? Or would #ifdef BOOT_DEVICE_RAM do the trick?

Good point, yes, we should add CONFIG_SPL_RAM_DEVICE and document it in docs/README.SPL and the toplevel README.

Ok, something like this? Posting separately, maybe it makes sense to merge to your PATCH v6...?

Sure, just include the actual spl_ram_load_image bits as well and I'll pick it up.

Here you go.

--

Add support for loading image from ram in SPL.

README +3 -0
index ddbeb1b..e782cce 100644
@@ -2636,6 +2636,9 @@ FIT uImage format:
 		CONFIG_SPL_SPI_SUPPORT
 		Support for drivers/spi/libspi.o in SPL binary
 
+		CONFIG_SPL_RAM_DEVICE
+		Support for running image already present in ram, in SPL binary 
+
 		CONFIG_SPL_LIBGENERIC_SUPPORT
 		Support for lib/libgeneric.o in SPL binary
 
common/spl/spl.c +21 -0
index eaea1c8..fb96a75 100644
@@ -115,6 +115,22 @@ static void __noreturn jump_to_image_no_args(void)
 	image_entry((u32 *)boot_params_ptr_addr);
 }
 
+#ifdef CONFIG_SPL_RAM_DEVICE
+static void spl_ram_load_image(void)
+{
+	const struct image_header *header;
+
+	/* get the header */
+	/* it will point to a address defined by handoff which
+	will tell where the image located inside the flash. For now,
+	it will temporary fixed to address pointed by U-Boot */
+	header = (struct image_header *)
+		(CONFIG_SYS_TEXT_BASE -	sizeof(struct image_header));
+
+	spl_parse_image_header(header);
+}
+#endif
+
 void board_init_r(gd_t *dummy1, ulong dummy2)
 {
 	u32 boot_device;
@@ -132,6 +148,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	boot_device = spl_boot_device();
 	debug("boot device - %d\n", boot_device);
 	switch (boot_device) {
+#ifdef CONFIG_SPL_RAM_DEVICE
+	case BOOT_DEVICE_RAM:
+		spl_ram_load_image();
+		break;
+#endif
 #ifdef CONFIG_SPL_MMC_SUPPORT
 	case BOOT_DEVICE_MMC1:
 	case BOOT_DEVICE_MMC2:
doc/README.SPL +1 -0
index e4a5ac3..2acafba 100644
@@ -66,6 +66,7 @@ CONFIG_SPL_DMA_SUPPORT (drivers/dma/libdma.o)
 CONFIG_SPL_POST_MEM_SUPPORT (post/drivers/memory.o)
 CONFIG_SPL_NAND_LOAD (drivers/mtd/nand/nand_spl_load.o)
 CONFIG_SPL_SPI_LOAD (drivers/mtd/spi/spi_spl_load.o)
+CONFIG_SPL_RAM_DEVICE (common/spl/spl.c)
 
 
 Normally CPU is assumed to be the same between the SPL and normal
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#27 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Quoted 8 lines · Pavel Machek

Hi!

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

spl_ram_load_image... will I need to create some kind of #ifdef? Or would #ifdef BOOT_DEVICE_RAM do the trick?

Good point, yes, we should add CONFIG_SPL_RAM_DEVICE and document it in docs/README.SPL and the toplevel README.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Ok, something like this? Posting separately, maybe it makes sense to merge to your PATCH v6...?

Sure, just include the actual spl_ram_load_image bits as well and I'll pick it up.

Here you go.

With the multi-line comment fixed up, queued for my v6.

Signature · 1 line
Tom
#28 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi Tom,

Quoted 13 lines · Tom Rini
Quoted 6 lines · Pavel Machek

Hi!

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

spl_ram_load_image... will I need to create some kind of #ifdef? Or would #ifdef BOOT_DEVICE_RAM do the trick?

Good point, yes, we should add CONFIG_SPL_RAM_DEVICE and document

it in

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

docs/README.SPL and the toplevel README.

Ok, something like this? Posting separately, maybe it makes sense to merge to your PATCH v6...?

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Sure, just include the actual spl_ram_load_image bits as well and I'll pick it up.

Here you go.

With the multi-line comment fixed up, queued for my v6.

Do you need me to send a fresh version with all the fixes?

Thanks,
Dinh

Quoted 4 lines

--
Tom

#29 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Quoted 24 lines · Dinh Nguyen

Hi Tom,

On Thu, Aug 30, 2012 at 4:25 PM, Tom Rini <[email protected] <mailto:[email protected]>> wrote:

On Thu, Aug 30, 2012 at 10:42:11PM +0200, Pavel Machek wrote:
> Hi!
>
> > >>> spl_ram_load_image... will I need to create some kind of #ifdef? Or
> > >>> would #ifdef BOOT_DEVICE_RAM do the trick?
> > >>
> > >> Good point, yes, we should add CONFIG_SPL_RAM_DEVICE and document it in
> > >> docs/README.SPL and the toplevel README.
> > >
> > > Ok, something like this? Posting separately, maybe it makes sense to
> > > merge to your PATCH v6...?
> >
> > Sure, just include the actual spl_ram_load_image bits as well and I'll
> > pick it up.
>

Quoted 6 lines

> Here you go.

With the multi-line comment fixed up, queued for my v6.

Do you need me to send a fresh version with all the fixes?

With all of the review comments addressed, a fresh series on top of my v6 is something I would do my best to get pulled in for the next release.

Signature · 1 line
Tom
#30 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to Pavel Machek
Quoted 4 lines · Pavel Machek

+++ b/common/spl/spl.c

common/spl/spl.c +0 -0
@@ -115,6 +115,22 @@ static void __noreturn jump_to_image_no_args(void)
 	image_entry((u32 *)boot_params_ptr_addr);
 }

common/spl/spl.c static void __noreturn jump_to_image_no_args(void) · line 126

Quoted 10 lines
common/spl/spl.c +9 -0
 
+#ifdef CONFIG_SPL_RAM_DEVICE
+static void spl_ram_load_image(void)
+{
+	const struct image_header *header;
+
+	/* get the header */
+	/* it will point to a address defined by handoff which
+	will tell where the image located inside the flash. For now,
+	it will temporary fixed to address pointed by U-Boot */

Please use the proper multi-line comment style:

	/*
	 * ...
	 */

Thanks,
Stefan

#31 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to Tom Rini
Quoted 9 lines · Tom Rini
Quoted 8 lines · Pavel Machek

Hi!

Quoted 5 lines

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds

Quoted 1 line
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -0

You should setup MEMORY declarations like the other u-boot-spl linker scripts do so we get build-time confirmation that we haven't exceeded our size limitations.

Quoted 6 lines
Quoted 3 lines

Hmm, I tried, but I don't know socfpga memory layout by heart.

Dinh, can you help here?

I think once you get the answers you should be able to re-post the series cleanly and depend on my v5 (or v6) branch. Thanks!

Porting it to your v5 was easy :-). Newer patch for review is attached.

I took oportunity to cleanup whitespace in arch/arm/cpu/armv7/omap-common/u-boot-spl.lds. Perhaps someone can merge that...

Thanks,
Pavel

commit a7ecaa40d9a02e84ac81da8f49d48595d7f342ad

Author: Pavel <[email protected]>
Date:   Thu Aug 30 01:28:00 2012 +0200

Add changes for socfpga

MAINTAINERS +5 -0
index c5a6f2f..df48dea 100644
@@ -765,6 +765,11 @@ Nagendra T S  <[email protected]>
 
    am3517_crane    ARM ARMV7 (AM35x SoC)
 
+Dinh Nguyen <[email protected]>
+Chin Liang See <[email protected]>
+
+	socfpga		socfpga_cyclone5
+
 Kyungmin Park <[email protected]>
 
 	apollon		ARM1136EJS
arch/arm/cpu/armv7/omap-common/u-boot-spl.lds +3 -3
index 8867e06..1d8efb2 100644
@@ -37,9 +37,9 @@ SECTIONS
 {
 	.text      :
 	{
-	__start = .;
-	  arch/arm/cpu/armv7/start.o	(.text)
-	  *(.text*)
+		__start = .;
+		arch/arm/cpu/armv7/start.o	(.text)
+		*(.text*)
 	} >.sram
 
 	. = ALIGN(4);
arch/arm/cpu/armv7/socfpga/Makefile new file +51 -0

51 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/config.mk new file +16 -0
new file mode 100644
index 0000000..b72ed1e
@@ -0,0 +1,16 @@
+#
+# Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed "as is" WITHOUT ANY WARRANTY of any
+# kind, whether express or implied; without even the implied warranty
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+ifndef CONFIG_SPL_BUILD
+ALL-y	+= $(obj)u-boot.img
+endif
arch/arm/cpu/armv7/socfpga/lowlevel_init.S new file +79 -0

79 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/misc.c new file +54 -0

54 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/spl.c new file +50 -0

50 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/timer.c new file +149 -0

149 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds new file +60 -0

60 lines not on this page · raw message

arch/arm/include/asm/arch-socfpga/reset_manager.h new file +37 -0
new file mode 100644
index 0000000..d9d2c1c
@@ -0,0 +1,37 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef	_RESET_MANAGER_H_
+#define	_RESET_MANAGER_H_
+
+void reset_cpu(ulong addr);
+void reset_deassert_peripherals_handoff(void);
+
+struct socfpga_reset_manager {
+	u32	padding1;
+	u32	ctrl;
+	u32	padding2;
+	u32	padding3;
+	u32	mpu_mod_reset;
+	u32	per_mod_reset;
+	u32	per2_mod_reset;
+	u32	brg_mod_reset;
+};
+
+#define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
+
+#endif /* _RESET_MANAGER_H_ */
arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h new file +27 -0
new file mode 100644
index 0000000..f353eb2
@@ -0,0 +1,27 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SOCFPGA_BASE_ADDRS_H_
+#define _SOCFPGA_BASE_ADDRS_H_
+
+#define SOCFPGA_L3REGS_ADDRESS 0xff800000
+#define SOCFPGA_UART0_ADDRESS 0xffc02000
+#define SOCFPGA_UART1_ADDRESS 0xffc03000
+#define SOCFPGA_OSC1TIMER0_ADDRESS 0xffd00000
+#define SOCFPGA_RSTMGR_ADDRESS 0xffd05000
+
+#endif /* _SOCFPGA_BASE_ADDRS_H_ */
arch/arm/include/asm/arch-socfpga/spl.h new file +30 -0
new file mode 100644
index 0000000..c9e5f50
@@ -0,0 +1,30 @@
+/*
+ *  Copyright (C) 2012 Pavel Machek <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SOCFPGA_SPL_H_
+#define _SOCFPGA_SPL_H_
+
+/* Symbols from linker script */
+extern void __malloc_start, __malloc_end, __stack_start;
+
+#define CONFIG_SPL_STACK (&__stack_start)
+#define CONFIG_SYS_SPL_MALLOC_START (&__malloc_start)
+#define CONFIG_SYS_SPL_MALLOC_SIZE (&__malloc_end - &__malloc_start)
+
+#define BOOT_DEVICE_RAM 1
+
+#endif
arch/arm/include/asm/arch-socfpga/timer.h new file +29 -0
new file mode 100644
index 0000000..830c94a
@@ -0,0 +1,29 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SOCFPGA_TIMER_H_
+#define _SOCFPGA_TIMER_H_
+
+struct socfpga_timer {
+	u32	load_val;
+	u32	curr_val;
+	u32	ctrl;
+	u32	eoi;
+	u32	int_stat;
+};
+
+#endif
board/altera/socfpga_cyclone5/Makefile new file +50 -0

50 lines not on this page · raw message

board/altera/socfpga_cyclone5/socfpga_cyclone5.c new file +97 -0

97 lines not on this page · raw message

boards.cfg +1 -0
index fdb84ad..1b5c860 100644
@@ -261,6 +261,7 @@ seaboard                     arm         armv7       seaboard            nvidia
 ventana                      arm         armv7       ventana             nvidia         tegra2
 whistler                     arm         armv7       whistler            nvidia         tegra2
 u8500_href                   arm         armv7       u8500               st-ericsson    u8500
+socfpga_cyclone5              arm         armv7      socfpga_cyclone5    altera		    socfpga
 actux1_4_16                  arm         ixp         actux1              -              -           actux1:FLASH2X2
 actux1_4_32                  arm         ixp         actux1              -              -           actux1:FLASH2X2,RAM_32MB
 actux1_8_16                  arm         ixp         actux1              -              -           actux1:FLASH1X8
common/spl/spl.c +18 -0
index 7b5656a..e90146e 100644
@@ -76,6 +76,7 @@ void spl_parse_image_header(const struct image_header *header)
 	u32 header_size = sizeof(struct image_header);
 
 	if (image_get_magic(header) == IH_MAGIC) {
+		/* Valid image. Extract information out of header */
 		if (spl_image.flags & SPL_COPY_PAYLOAD_ONLY) {
 			/*
 			 * On some system (e.g. powerpc), the load-address and
@@ -125,6 +126,20 @@ static void __noreturn jump_to_image_no_args(void)
 	image_entry((u32 *)boot_params_ptr_addr);
 }
 
+static void spl_ram_load_image(void)
+{
+	const struct image_header *header;
+
+	/* get the header */
+	/* it will point to a address defined by handoff which
+	will tell where the image located inside the flash. For now,
+	it will temporary fixed to address pointed by U-Boot */
+	header = (struct image_header *)
+		(CONFIG_SYS_TEXT_BASE -	sizeof(struct image_header));
+
+	spl_parse_image_header(header);
+}
+
 void board_init_r(gd_t *dummy1, ulong dummy2)
 {
 	u32 boot_device;
@@ -142,6 +157,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	boot_device = spl_boot_device();
 	debug("boot device - %d\n", boot_device);
 	switch (boot_device) {
+	case BOOT_DEVICE_RAM:
+		spl_ram_load_image();
+		break;
 #ifdef CONFIG_SPL_MMC_SUPPORT
 	case BOOT_DEVICE_MMC1:
 	case BOOT_DEVICE_MMC2:
include/common.h +3 -1
index 55025c0..469a3af 100644
@@ -704,7 +704,9 @@ void	external_interrupt (struct pt_regs *);
 void	irq_install_handler(int, interrupt_handler_t *, void *);
 void	irq_free_handler   (int);
 void	reset_timer	   (void);
-ulong	get_timer	   (ulong base);
+ulong	get_timer(ulong base);
+void	reset_timer_count(void);
+ulong	get_timer_count(ulong base);
 void	enable_interrupts  (void);
 int	disable_interrupts (void);
 
include/configs/socfpga_cyclone5.h new file +242 -0

242 lines not on this page · raw message

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

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Dear Pavel Machek,

Minor ramblings below :)

Quoted 15 lines · Tom Rini
Quoted 14 lines · Pavel Machek
Quoted 12 lines

Hi!

Quoted 6 lines

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds

Quoted 2 lines
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -0

You should setup MEMORY declarations like the other u-boot-spl linker scripts do so we get build-time confirmation that we haven't exceeded our size limitations.

Hmm, I tried, but I don't know socfpga memory layout by heart.

Dinh, can you help here?

Quoted 8 lines
Quoted 2 lines

I think once you get the answers you should be able to re-post the series cleanly and depend on my v5 (or v6) branch. Thanks!

Porting it to your v5 was easy :-). Newer patch for review is attached.

I took oportunity to cleanup whitespace in arch/arm/cpu/armv7/omap-common/u-boot-spl.lds. Perhaps someone can merge that...

Argh ... what about using git send-email for the patch submission please?

NOTE: I really have a great deal of respect for Pavel, so i do have trouble stepping on him properly during the patch review ;-)

Quoted 31 lines

Thanks,
Pavel

commit a7ecaa40d9a02e84ac81da8f49d48595d7f342ad

Author: Pavel <[email protected]>
Date:   Thu Aug 30 01:28:00 2012 +0200

Add changes for socfpga

MAINTAINERS +5 -0
index c5a6f2f..df48dea 100644
@@ -765,6 +765,11 @@ Nagendra T S  <[email protected]>
 
    am3517_crane    ARM ARMV7 (AM35x SoC)
 
+Dinh Nguyen <[email protected]>
+Chin Liang See <[email protected]>
+
+	socfpga		socfpga_cyclone5
+
 Kyungmin Park <[email protected]>
 
 	apollon		ARM1136EJS
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/omap-common/u-boot-spl.lds index 8867e06..1d8efb2 100644

arch/arm/cpu/armv7/omap-common/u-boot-spl.lds SECTIONS · line 43

Quoted 10 lines
arch/arm/cpu/armv7/omap-common/u-boot-spl.lds +3 -3
@@ -37,9 +37,9 @@ SECTIONS
 {
 	.text      :
 	{
-	__start = .;
-	  arch/arm/cpu/armv7/start.o	(.text)
-	  *(.text*)
+		__start = .;
+		arch/arm/cpu/armv7/start.o	(.text)
+		*(.text*)
 	} >.sram

Maybe the cleanup should simply be split into separate patch?

Quoted 112 lines
arch/arm/cpu/armv7/omap-common/u-boot-spl.lds +0 -0
 	. = ALIGN(4);
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/Makefile new file mode 100644 index 0000000..376a4bd

arch/arm/cpu/armv7/socfpga/Makefile new file +51 -0
@@ -0,0 +1,51 @@
+#
+# (C) Copyright 2000-2003
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# Copyright (C) 2012 Altera Corporation <www.altera.com>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+
+include $(TOPDIR)/config.mk
+
+LIB	=  $(obj)lib$(SOC).o
+
+SOBJS	:= lowlevel_init.o
+COBJS-y	:= misc.o timer.o
+COBJS-$(CONFIG_SPL_BUILD) += spl.o
+
+COBJS	:= $(COBJS-y)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+
+all:	 $(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/config.mk new file mode 100644 index 0000000..b72ed1e

arch/arm/cpu/armv7/socfpga/config.mk new file +16 -0
@@ -0,0 +1,16 @@
+#
+# Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed "as is" WITHOUT ANY WARRANTY of any
+# kind, whether express or implied; without even the implied warranty
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+ifndef CONFIG_SPL_BUILD
+ALL-y	+= $(obj)u-boot.img
+endif
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/lowlevel_init.S new file mode 100644 index 0000000..815073e

arch/arm/cpu/armv7/socfpga/lowlevel_init.S new file +26 -0
@@ -0,0 +1,79 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <version.h>
+
+/* Save the parameter pass in by previous boot loader */
+.global save_boot_params
+save_boot_params:
+	/* save the parameter here */
+
+	/*

arch/arm/cpu/armv7/socfpga/lowlevel_init.S line 36

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/lowlevel_init.S new file +10 -0
+	 * Setup stack for exception, which is located
+	 * at the end of on-chip RAM. We don't expect exception prior to
+	 * relocation and if that happens, we won't worry -- it will overide
+	 * global data region as the code will goto reset. After relocation,
+	 * this region won't be used by other part of program.
+	 * Hence it is safe.
+	 */
+	ldr	r0, =CONFIG_SYS_INIT_RAM_ADDR
+	ldr	r1, =CONFIG_SYS_INIT_RAM_SIZE
+	add	r0, r0, r1

Won't the preprocessor compute (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) for you? Then you'd only have to do one LDR and no ADD instruction, saving two ticks of CPU :-)

Quoted 68 lines
arch/arm/cpu/armv7/socfpga/lowlevel_init.S new file +43 -0
+	ldr	r1, =IRQ_STACK_START_IN
+	str	r0, [r1]
+
+	bx	lr
+
+
+/* Set up the platform, once the cpu has been initialized */
+.globl lowlevel_init
+lowlevel_init:
+
+	/* Remap */
+#ifdef CONFIG_SPL_BUILD
+	/*
+	 * SPL : configure the remap (L3 NIC-301 GPV)
+	 * so the on-chip RAM at lower memory instead ROM.
+	 */
+	ldr	r0, =SOCFPGA_L3REGS_ADDRESS
+	mov	r1, #0x19
+	str	r1, [r0]
+#else
+	/*
+	 * U-Boot : configure the remap (L3 NIC-301 GPV)
+	 * so the SDRAM at lower memory instead on-chip RAM.
+	 */
+	ldr	r0, =SOCFPGA_L3REGS_ADDRESS
+	mov	r1, #0x2
+	str	r1, [r0]
+
+	/* Private components security */
+
+	/*
+	 * U-Boot : configure private timer, global timer and cpu
+	 * component access as non secure for kernel stage (as required
+	 * by kernel)
+	 */
+	mrc	p15,4,r0,c15,c0,0
+	add	r1, r0, #0x54
+	ldr	r2, [r1]
+	orr	r2, r2, #0xff
+	orr	r2, r2, #0xf00
+	str	r2, [r1]
+#endif	/* #ifdef CONFIG_SPL_BUILD */
+	mov	pc, lr
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/misc.c new file mode 100644 index 0000000..b906701

arch/arm/cpu/armv7/socfpga/misc.c new file +19 -0
@@ -0,0 +1,54 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <common.h>
+#include <asm/io.h>

arch/arm/cpu/armv7/socfpga/misc.c line 29

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/misc.c new file +10 -0
+#include <asm/arch/reset_manager.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct socfpga_reset_manager *reset_manager_base =
+		(void *)SOCFPGA_RSTMGR_ADDRESS;
+
+/*
+ * Write the reset manager register to cause reset
+ */

You might want to add __attribute__((noreturn)) to this function :-)

Quoted 11 lines
arch/arm/cpu/armv7/socfpga/misc.c new file +11 -0
+void reset_cpu(ulong addr)
+{
+	/* request a warm reset */
+	writel(RSTMGR_CTRL_SWWARMRSTREQ_LSB, &reset_manager_base->ctrl);
+	/*
+	 * infinite loop here as watchdog will trigger and reset
+	 * the processor
+	 */
+	while (1)
+		;
+}

[...]

Quoted 31 lines
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/timer.c new file mode 100644 index 0000000..28da4d0

arch/arm/cpu/armv7/socfpga/timer.c new file +24 -0
@@ -0,0 +1,149 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/timer.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct socfpga_timer *timer_base = (void

*)CONFIG_SYS_TIMERBASE; +

arch/arm/cpu/armv7/socfpga/timer.c line 33

Quoted 8 lines
arch/arm/cpu/armv7/socfpga/timer.c new file +8 -0
+/*
+ * Timer initialization
+ */
+int timer_init(void)
+{
+	writel(TIMER_LOAD_VAL, &timer_base->load_val);
+	writel(TIMER_LOAD_VAL, &timer_base->curr_val);
+	writel((readl((&timer_base->ctrl)) | 0x3),

I think you should stick to programming in C here, not ((((LISP)))), so try cutting down on the ((braces)) :-)

btw. what's this 0x3 magic constant ?

Quoted 3 lines
arch/arm/cpu/armv7/socfpga/timer.c new file +3 -0
+		(&timer_base->ctrl));
+	return 0;
+}

[...]

Quoted 9 lines
arch/arm/cpu/armv7/socfpga/timer.c new file +9 -0
+#include <common.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/io.h>
+
+#include <netdev.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void show_boot_progress(int progress)

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

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/timer.c new file +10 -0
+{
+	debug("Boot reached stage %d\n", progress);
+}
+
+static inline void delay(unsigned long loops)
+{
+	__asm__ volatile ("1:\n"
+		"subs %0, %1, #1\n"
+		"bne 1b" : "=r" (loops) : "0" (loops));
+}

Am I flat blind or is this not used here?
[...]

All in all, the code is nice.

#33 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi!

Quoted 5 lines
Quoted 3 lines

I took oportunity to cleanup whitespace in arch/arm/cpu/armv7/omap-common/u-boot-spl.lds. Perhaps someone can merge that...

Argh ... what about using git send-email for the patch submission please?

I'm not supposed to submit patches here, these are just requests for review ;-).

Quoted 2 lines

NOTE: I really have a great deal of respect for Pavel, so i do have trouble stepping on him properly during the patch review ;-)

;-).

Quoted 7 lines

arch/arm/cpu/armv7/socfpga/lowlevel_init.S line 36

Quoted 3 lines
arch/arm/cpu/armv7/socfpga/lowlevel_init.S new file +3 -0
+	ldr	r0, =CONFIG_SYS_INIT_RAM_ADDR
+	ldr	r1, =CONFIG_SYS_INIT_RAM_SIZE
+	add	r0, r0, r1

Won't the preprocessor compute (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) for you? Then you'd only have to do one LDR and no ADD instruction, saving two ticks of CPU :-)

:-). And opportunity for me to try my luck at arm assembly. Does this look correct?

        ldr     r0, =(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE)
        ldr     r1, =IRQ_STACK_START_IN
        str     r0, [r1]

bx lr

Quoted 8 lines

arch/arm/cpu/armv7/socfpga/misc.c line 29

Quoted 6 lines
arch/arm/cpu/armv7/socfpga/misc.c new file +6 -0
+static const struct socfpga_reset_manager *reset_manager_base =
+		(void *)SOCFPGA_RSTMGR_ADDRESS;
+
+/*
+ * Write the reset manager register to cause reset
+ */

You might want to add __attribute__((noreturn)) to this function :-)

Hmm... I guess that should go to the central header file? No need to sprinkle it all through the C files. (Done).

Quoted 6 lines

arch/arm/cpu/armv7/socfpga/timer.c line 33

Quoted 3 lines
arch/arm/cpu/armv7/socfpga/timer.c new file +3 -0
+	writel(TIMER_LOAD_VAL, &timer_base->load_val);
+	writel(TIMER_LOAD_VAL, &timer_base->curr_val);
+	writel((readl((&timer_base->ctrl)) | 0x3),

I think you should stick to programming in C here, not ((((LISP)))), so try cutting down on the ((braces)) :-)

Some braces have been harmed by creation of this patch.

Quoted 1 line

btw. what's this 0x3 magic constant ?

Dinh has to help here :-(.

Quoted 8 lines

board/altera/socfpga_cyclone5/socfpga_cyclone5.c line 36

Quoted 6 lines
board/altera/socfpga_cyclone5/socfpga_cyclone5.c new file +6 -0
+static inline void delay(unsigned long loops)
+{
+	__asm__ volatile ("1:\n"
+		"subs %0, %1, #1\n"
+		"bne 1b" : "=r" (loops) : "0" (loops));
+}

Am I flat blind or is this not used here?

Killed, thanks. Lets see what the compiler thinks.

Pavel

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

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Dear Pavel Machek,

Quoted 26 lines

Hi!

Quoted 5 lines
Quoted 3 lines

I took oportunity to cleanup whitespace in arch/arm/cpu/armv7/omap-common/u-boot-spl.lds. Perhaps someone can merge that...

Argh ... what about using git send-email for the patch submission please?

I'm not supposed to submit patches here, these are just requests for review ;-).

Quoted 2 lines

NOTE: I really have a great deal of respect for Pavel, so i do have trouble stepping on him properly during the patch review ;-)

;-).

Quoted 7 lines

arch/arm/cpu/armv7/socfpga/lowlevel_init.S line 36

Quoted 3 lines
arch/arm/cpu/armv7/socfpga/lowlevel_init.S new file +3 -0
+	ldr	r0, =CONFIG_SYS_INIT_RAM_ADDR
+	ldr	r1, =CONFIG_SYS_INIT_RAM_SIZE
+	add	r0, r0, r1

Won't the preprocessor compute (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) for you? Then you'd only have to do one LDR and no ADD instruction, saving two ticks of CPU :-)

:
:-). And opportunity for me to try my luck at arm assembly. Does this

Quoted 7 lines

look correct?

        ldr     r0, =(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE)
        ldr     r1, =IRQ_STACK_START_IN
        str     r0, [r1]

bx lr

Yes

Quoted 12 lines
Quoted 8 lines

arch/arm/cpu/armv7/socfpga/misc.c line 29

Quoted 6 lines
arch/arm/cpu/armv7/socfpga/misc.c new file +6 -0
+static const struct socfpga_reset_manager *reset_manager_base =
+		(void *)SOCFPGA_RSTMGR_ADDRESS;
+
+/*
+ * Write the reset manager register to cause reset
+ */

You might want to add __attribute__((noreturn)) to this function :-)

Hmm... I guess that should go to the central header file? No need to sprinkle it all through the C files. (Done).

Quoted 8 lines
Quoted 6 lines

arch/arm/cpu/armv7/socfpga/timer.c line 33

Quoted 3 lines
arch/arm/cpu/armv7/socfpga/timer.c new file +3 -0
+	writel(TIMER_LOAD_VAL, &timer_base->load_val);
+	writel(TIMER_LOAD_VAL, &timer_base->curr_val);
+	writel((readl((&timer_base->ctrl)) | 0x3),

I think you should stick to programming in C here, not ((((LISP)))), so try cutting down on the ((braces)) :-)

Some braces have been harmed by creation of this patch.

At least one more pair must be killed on the above statement :)

Quoted 3 lines
Quoted 1 line

btw. what's this 0x3 magic constant ?

Dinh has to help here :-(.

Also, use setbits_le32() there instead anyway.

Quoted 9 lines
Quoted 8 lines

board/altera/socfpga_cyclone5/socfpga_cyclone5.c line 36

Quoted 6 lines
board/altera/socfpga_cyclone5/socfpga_cyclone5.c new file +6 -0
+static inline void delay(unsigned long loops)
+{
+	__asm__ volatile ("1:\n"
+		"subs %0, %1, #1\n"
+		"bne 1b" : "=r" (loops) : "0" (loops));
+}

Am I flat blind or is this not used here?

Quoted 3 lines

Killed, thanks. Lets see what the compiler thinks.

Pavel

Best regards,
Marek Vasut

#35 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Hi!

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+	writel(TIMER_LOAD_VAL, &timer_base->load_val);
+	writel(TIMER_LOAD_VAL, &timer_base->curr_val);
+	writel((readl((&timer_base->ctrl)) | 0x3),

I think you should stick to programming in C here, not ((((LISP)))), so try cutting down on the ((braces)) :-)

Some braces have been harmed by creation of this patch.

At least one more pair must be killed on the above statement :)

I removed two pairs but failed to post the patch ;-). Be sure you'll never see them again.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

btw. what's this 0x3 magic constant ?

Dinh has to help here :-(.

Also, use setbits_le32() there instead anyway.

Uff, setbits_le32 looks seriously strange. Should I do this?

Thanks for review,
Pavel

arch/arm/cpu/armv7/socfpga/timer.c +1 -1
index 79fa081..1ceb6e9 100644
@@ -30,7 +30,7 @@ int timer_init(void)
 {
 	writel(TIMER_LOAD_VAL, &timer_base->load_val);
 	writel(TIMER_LOAD_VAL, &timer_base->curr_val);
-	writel(readl(&timer_base->ctrl) | 0x3, &timer_base->ctrl);
+	setbits_le32(&timer_base->ctrl, 0x3);
 	return 0;
 }
 
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#36 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Dear Pavel Machek,

Quoted 16 lines

Hi!

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+	writel(TIMER_LOAD_VAL, &timer_base->load_val);
+	writel(TIMER_LOAD_VAL, &timer_base->curr_val);
+	writel((readl((&timer_base->ctrl)) | 0x3),

I think you should stick to programming in C here, not ((((LISP)))), so try cutting down on the ((braces)) :-)

Some braces have been harmed by creation of this patch.

At least one more pair must be killed on the above statement :)

I removed two pairs but failed to post the patch ;-). Be sure you'll never see them again.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

btw. what's this 0x3 magic constant ?

Dinh has to help here :-(.

Also, use setbits_le32() there instead anyway.

Uff, setbits_le32 looks seriously strange. Should I do this?

Yes please, that's the suggested way:

Instead of:
ret = readl()
ret |= 1 << BIT;
writel(ret, )

You do:
setbits_le32()

Quoted 3 lines

Thanks for review,

Pavel

arch/arm/cpu/armv7/socfpga/timer.c int timer_init(void) · line 35

Quoted 13 lines
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/timer.c index 79fa081..1ceb6e9 100644

arch/arm/cpu/armv7/socfpga/timer.c +1 -1
@@ -30,7 +30,7 @@ int timer_init(void)
 {
 	writel(TIMER_LOAD_VAL, &timer_base->load_val);
 	writel(TIMER_LOAD_VAL, &timer_base->curr_val);
-	writel(readl(&timer_base->ctrl) | 0x3, &timer_base->ctrl);
+	setbits_le32(&timer_base->ctrl, 0x3);
 	return 0;
 }

Best regards,
Marek Vasut

#37 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to Pavel Machek

Hi Pavel,

On the constant 0x3, its to enable the timer plus configure the timer mode to user-defined count mode. We can covert them to constant as below:

#define TIMER_ENABLE (1<<0)
#define TIMER_MODE_USERDEF (1<<1)

writel((readl((&timer_base->ctrl)) | TIMER_ENABLE | TIMER_MODE_USERDEF )

Thanks and have a nice day!

Chin Liang
Direct Line: +604 - 636 8776

-----Original Message-----
From: Pavel Machek [mailto:pavel at denx.de]
Sent: Friday, August 31, 2012 1:00 AM
To: Marek Vasut
Cc: Tom Rini; albert.u.boot at aribaud.net; ZY - u-boot; dinh.linux at gmail.com; Chin Liang See
Subject: Re: [U-Boot] [PATCHv1] ARM: Add Altera SOCFPGA Cyclone5

Hi!

Quoted 5 lines
Quoted 3 lines

I took oportunity to cleanup whitespace in arch/arm/cpu/armv7/omap-common/u-boot-spl.lds. Perhaps someone can merge that...

Argh ... what about using git send-email for the patch submission please?

I'm not supposed to submit patches here, these are just requests for review ;-).

Quoted 2 lines

NOTE: I really have a great deal of respect for Pavel, so i do have trouble stepping on him properly during the patch review ;-)

;-).

Quoted 7 lines

arch/arm/cpu/armv7/socfpga/lowlevel_init.S line 36

Quoted 3 lines
arch/arm/cpu/armv7/socfpga/lowlevel_init.S new file +3 -0
+	ldr	r0, =CONFIG_SYS_INIT_RAM_ADDR
+	ldr	r1, =CONFIG_SYS_INIT_RAM_SIZE
+	add	r0, r0, r1

Won't the preprocessor compute (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE) for you? Then you'd only have to do one LDR and no ADD instruction, saving two ticks of CPU :-)

:-). And opportunity for me to try my luck at arm assembly. Does this look correct?

        ldr     r0, =(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE)
        ldr     r1, =IRQ_STACK_START_IN
        str     r0, [r1]

bx lr

Quoted 7 lines

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

Quoted 5 lines
arch/arm/cpu/armv7/socfpga/misc.c new file +5 -0
+static const struct socfpga_reset_manager *reset_manager_base =
+		(void *)SOCFPGA_RSTMGR_ADDRESS;
+
+/*
+ * Write the reset manager register to cause reset  */

You might want to add __attribute__((noreturn)) to this function :-)

Hmm... I guess that should go to the central header file? No need to sprinkle it all through the C files. (Done).

Quoted 6 lines

arch/arm/cpu/armv7/socfpga/timer.c line 33

Quoted 3 lines
arch/arm/cpu/armv7/socfpga/timer.c new file +3 -0
+	writel(TIMER_LOAD_VAL, &timer_base->load_val);
+	writel(TIMER_LOAD_VAL, &timer_base->curr_val);
+	writel((readl((&timer_base->ctrl)) | 0x3),

I think you should stick to programming in C here, not ((((LISP)))), so try cutting down on the ((braces)) :-)

Some braces have been harmed by creation of this patch.

Quoted 1 line

btw. what's this 0x3 magic constant ?

Dinh has to help here :-(.

Quoted 6 lines

board/altera/socfpga_cyclone5/socfpga_cyclone5.c

Quoted 4 lines
board/altera/socfpga_cyclone5/socfpga_cyclone5.c new file +4 -0
+static inline void delay(unsigned long loops) {
+	__asm__ volatile ("1:\n"
+		"subs %0, %1, #1\n"
+		"bne 1b" : "=r" (loops) : "0" (loops)); }

Am I flat blind or is this not used here?

Killed, thanks. Lets see what the compiler thinks.

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 6008 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120903/95f407e3/attachment.bin>

#38 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to Pavel Machek
Quoted 14 lines · Pavel Machek
Quoted 13 lines · Tom Rini
Quoted 11 lines · Pavel Machek

Hi!

Quoted 5 lines

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds

Quoted 1 line
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -0

You should setup MEMORY declarations like the other u-boot-spl linker scripts do so we get build-time confirmation that we haven't exceeded our size limitations.

Hmm, I tried, but I don't know socfpga memory layout by heart.

Dinh, can you help here?

Quoted 8 lines
Quoted 2 lines

I think once you get the answers you should be able to re-post the series cleanly and depend on my v5 (or v6) branch. Thanks!

Porting it to your v5 was easy :-). Newer patch for review is attached.

I took oportunity to cleanup whitespace in arch/arm/cpu/armv7/omap-common/u-boot-spl.lds. Perhaps someone can merge that...

Split it out and I'll grab it for v6. Thanks! Comments sent to the other part of the thread just now.

Signature · 1 line
Tom
#39 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

Quoted 18 lines · Tom Rini
Quoted 17 lines · Pavel Machek
Quoted 15 lines · Tom Rini
Quoted 11 lines · Pavel Machek

Hi!

Quoted 5 lines

arch/arm/cpu/armv7/socfpga/u-boot-spl.lds

Quoted 1 line
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -0

You should setup MEMORY declarations like the other u-boot-spl linker scripts do so we get build-time confirmation that we haven't exceeded our size limitations.

Hmm, I tried, but I don't know socfpga memory layout by heart.

Dinh, can you help here?

I think once you get the answers you should be able to re-post the series cleanly and depend on my v5 (or v6) branch. Thanks!

Quoted 8 lines
Quoted 5 lines

Porting it to your v5 was easy :-). Newer patch for review is attached.

I took oportunity to cleanup whitespace in arch/arm/cpu/armv7/omap-common/u-boot-spl.lds. Perhaps someone can merge that...

Split it out and I'll grab it for v6. Thanks! Comments sent to the other part of the thread just now.

Here you go. Thanks!
Pavel
--

Fix whitespace in omap-common/u-boot-spl.lds.

arch/arm/cpu/armv7/omap-common/u-boot-spl.lds +3 -3
index 8867e06..1d8efb2 100644
@@ -37,9 +37,9 @@ SECTIONS
 {
 	.text      :
 	{
-	__start = .;
-	  arch/arm/cpu/armv7/start.o	(.text)
-	  *(.text*)
+		__start = .;
+		arch/arm/cpu/armv7/start.o	(.text)
+		*(.text*)
 	} >.sram
 
 	. = ALIGN(4);
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#40 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to Tom Rini
Quoted 28 lines · Tom Rini
Quoted 20 lines · Marek Vasut

Dear dinguyen at altera.com,

Quoted 6 lines

From: Dinh Nguyen <[email protected]>

Add minimal support for Altera's SOCFPGA Cyclone 5 hardware.

[...]

Please CC albert with new arches.

Quoted 7 lines
Makefile +0 -0
index 5ce5cc3..12aa372 100644
@@ -369,7 +369,7 @@ BOARD_SIZE_CHECK =
 endif
 
Quoted 6 lines
Quoted 4 lines
Makefile +1 -1
 # Always append ALL so that arch config.mk's can add custom ones
-ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
+ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)u-boot.img

$(obj)System.map

This won't slide

Quoted 2 lines

You can place this into arch/arm/cpu/armv7/socfpga/config.mk (see am33xx/config.mk or any of the others) for examples.

Thanks. This does the trick.
Pavel

commit aa0c16f34948deb16f1d64417c0ce119a721103b

Author: Pavel <[email protected]>
Date:   Thu Aug 23 12:54:51 2012 +0200

Move build of u-boot.img to config.mk from main Makefile.

Makefile +1 -1
index f12ccbe..73c8e39 100644
@@ -374,7 +374,7 @@ BOARD_SIZE_CHECK =
 endif
 
 # Always append ALL so that arch config.mk's can add custom ones
-ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)u-boot.img $(obj)System.map
+ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
 
 ALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin
 ALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin
arch/arm/cpu/armv7/socfpga/config.mk new file +16 -0
new file mode 100644
index 0000000..b72ed1e
@@ -0,0 +1,16 @@
+#
+# Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed "as is" WITHOUT ANY WARRANTY of any
+# kind, whether express or implied; without even the implied warranty
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+ifndef CONFIG_SPL_BUILD
+ALL-y	+= $(obj)u-boot.img
+endif
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#41 lore raw

PATCH 1/1 ARM: Add Altera SOCFPGA Cyclone5

In reply to Marek Vasut

Hi!

Quoted 9 lines

Review

Quoted 7 lines
(quoted diff) +7 -0
+/*
+ * Release peripherals from reset based on handoff
+ */
+void reset_deassert_peripherals_handoff(void)
+{
+	unsigned int val = 0;
+	writel(val, &reset_manager_base->per_mod_reset);

writel(0, ...

Ok.

Quoted 8 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+int dram_init(void)
+{
+	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	return 0;
+}

Can all this be concentrated into single file (reset, sdram, etc. all those small functions).

I created misc.c with those.

Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+	}
+	return 0;
+}

I think I don't even wanna know what's the purpose here :-)

Lets leave SPL for next mail :-).
Pavel

commit ae990b2c7d7ffd0d57e594ec6cdadb769dcc2a9b

Author: Pavel <[email protected]>
Date:   Thu Aug 23 12:48:59 2012 +0200

Cleanups suggested by Marek Vasut: use constant zero instead of assigning it to variable, merge reset_manager.c and sdram.c into misc.c

arch/arm/cpu/armv7/socfpga/Makefile +1 -1
index e4c1213..376a4bd 100644
@@ -29,7 +29,7 @@ include $(TOPDIR)/config.mk
 LIB	=  $(obj)lib$(SOC).o
 
 SOBJS	:= lowlevel_init.o
-COBJS-y	:= reset_manager.o sdram.o timer.o
+COBJS-y	:= misc.o timer.o
 COBJS-$(CONFIG_SPL_BUILD) += spl.o
 
 COBJS	:= $(COBJS-y)
arch/arm/cpu/armv7/socfpga/misc.c new file +52 -0

52 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/reset_manager.c deleted +0 -45

45 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/sdram.c deleted +0 -26
deleted file mode 100644
index 6714983..0000000
@@ -1,26 +0,0 @@
-/*
- *  Copyright (C) 2012 Altera Corporation <www.altera.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <common.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-int dram_init(void)
-{
-	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
-	return 0;
-}
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 1/1 ARM: Add Altera SOCFPGA Cyclone5

On Thu, Aug 23, 2012 at 12:50:28PM +0200, Pavel Machek wrote:

[snip]

arch/arm/cpu/armv7/socfpga/misc.c line 35

Quoted 6 lines
arch/arm/cpu/armv7/socfpga/misc.c new file +6 -0
+void reset_cpu(ulong addr)
+{
+	/* request a warm reset */
+	writel(RSTMGR_CTRL_SWWARMRSTREQ_LSB, &reset_manager_base->ctrl);
+	/* infinite loop here as watchdog will trigger and reset
+	 * the processor */

/*
* Is the form of a multi line comment.
* Or people get upset, sorry.
*/

:)

Things look fine, just expecting a proper v2 posting once you're able to re-base to the SPL common series. Thanks!

Signature · 1 line
Tom