[U-Boot] [PATCHv1] ARM: Add Altera SOCFPGA Cyclone5

Marek Vasut marex at denx.de
Thu Aug 23 00:26:53 CEST 2012


Dear dinguyen at altera.com,

> From: Dinh Nguyen <dinguyen at altera.com>
> 
> Add minimal support for Altera's SOCFPGA Cyclone 5 hardware.
> 
> Signed-off-by: Dinh Nguyen <dinguyen at altera.com>
> Signed-off-by: Pavel Machek <pavel at denx.de>

[...]

Please CC albert with new arches.

> diff --git a/Makefile b/Makefile
> index 5ce5cc3..12aa372 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -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

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

> +/*
> + * Write the reset manager register to cause reset
> + */
> +void reset_cpu(ulong addr)
> +{
> +	/* request a warm reset */
> +	writel(RSTMGR_CTRL_SWWARMRSTREQ_LSB, &reset_manager_base->ctrl);
> +	/* infinite loop here as watchdog will trigger and reset
> +	 * the processor */
> +	while (1)
> +		;
> +}
> +
> +/*
> + * Release peripherals from reset based on handoff
> + */
> +void reset_deassert_peripherals_handoff(void)
> +{
> +	unsigned int val = 0;
> +	writel(val, &reset_manager_base->per_mod_reset);

writel(0, ...

> +}
> diff --git a/arch/arm/cpu/armv7/socfpga/sdram.c
> b/arch/arm/cpu/armv7/socfpga/sdram.c new file mode 100644
> index 0000000..6714983
> --- /dev/null
> +++ b/arch/arm/cpu/armv7/socfpga/sdram.c
> @@ -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;
> +}

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

> diff --git a/arch/arm/cpu/armv7/socfpga/spl.c
> b/arch/arm/cpu/armv7/socfpga/spl.c new file mode 100644
> index 0000000..7bd1e2f
> --- /dev/null
> +++ b/arch/arm/cpu/armv7/socfpga/spl.c
> @@ -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) +{
> +	/* 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;
> +	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 :-)

[...]


More information about the U-Boot mailing list