From fc520894d426aae5dc0b87aa012520fc18231e1e Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 18 Oct 2014 03:52:36 +0200 Subject: [PATCH 1/5] arm: socfpga: Move code from misc_init_r() to arch_early_init_r() Move this initialization code to proper place. The misc_init_r() function is called way too late and the platform initialization code should be executed much earlier. Signed-off-by: Marek Vasut Cc: Chin Liang See Cc: Dinh Nguyen Cc: Vince Bridgers Cc: Albert Aribaud Acked-by: Pavel Machek --- arch/arm/cpu/armv7/socfpga/misc.c | 2 +- include/configs/socfpga_common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/cpu/armv7/socfpga/misc.c b/arch/arm/cpu/armv7/socfpga/misc.c index 0eab264668..8c3e5f7cd4 100644 --- a/arch/arm/cpu/armv7/socfpga/misc.c +++ b/arch/arm/cpu/armv7/socfpga/misc.c @@ -176,7 +176,7 @@ static void socfpga_nic301_slave_ns(void) static uint32_t iswgrp_handoff[8]; -int misc_init_r(void) +int arch_early_init_r(void) { int i; for (i = 0; i < 8; i++) /* Cache initial SW setting regs */ diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h index 49504dcafb..69527985e2 100644 --- a/include/configs/socfpga_common.h +++ b/include/configs/socfpga_common.h @@ -22,7 +22,7 @@ #define CONFIG_DISPLAY_CPUINFO #define CONFIG_DISPLAY_BOARDINFO #define CONFIG_BOARD_EARLY_INIT_F -#define CONFIG_MISC_INIT_R +#define CONFIG_ARCH_EARLY_INIT_R #define CONFIG_SYS_NO_FLASH #define CONFIG_CLOCKS From 34584d190db5cfc879dea71ba345d15fe8bf348b Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Thu, 16 Oct 2014 12:25:40 +0200 Subject: [PATCH 2/5] arm: socfpga: Zap spl.h and ad-hoc related syms Switch to the common spl.h file and zap the arch/spl.h . Since the arch/spl.h contained various ad-hoc symbols, zap those symbols as well and rework the board configuration a little so it doesn't depend on them. Signed-off-by: Marek Vasut Cc: Chin Liang See Cc: Dinh Nguyen Cc: Vince Bridgers Cc: Albert Aribaud Acked-by: Pavel Machek --- arch/arm/cpu/armv7/socfpga/u-boot-spl.lds | 9 --------- arch/arm/include/asm/arch-socfpga/spl.h | 15 --------------- arch/arm/include/asm/spl.h | 2 +- include/configs/socfpga_common.h | 17 +++++++++++------ 4 files changed, 12 insertions(+), 31 deletions(-) delete mode 100644 arch/arm/include/asm/arch-socfpga/spl.h diff --git a/arch/arm/cpu/armv7/socfpga/u-boot-spl.lds b/arch/arm/cpu/armv7/socfpga/u-boot-spl.lds index db9bdad7d6..569fa418f4 100644 --- a/arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +++ b/arch/arm/cpu/armv7/socfpga/u-boot-spl.lds @@ -42,13 +42,4 @@ SECTIONS . = ALIGN(4); __bss_end = .; } >.sdram - - . = ALIGN(8); - __malloc_start = .; - . = . + CONFIG_SPL_MALLOC_SIZE; - __malloc_end = .; - - . = . + CONFIG_SPL_STACK_SIZE; - . = ALIGN(8); - __stack_start = .; } diff --git a/arch/arm/include/asm/arch-socfpga/spl.h b/arch/arm/include/asm/arch-socfpga/spl.h deleted file mode 100644 index 7e310d5a0c..0000000000 --- a/arch/arm/include/asm/arch-socfpga/spl.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) 2012 Pavel Machek - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#ifndef _SOCFPGA_SPL_H_ -#define _SOCFPGA_SPL_H_ - -/* Symbols from linker script */ -extern char __malloc_start, __malloc_end, __stack_start; - -#define BOOT_DEVICE_RAM 1 - -#endif diff --git a/arch/arm/include/asm/spl.h b/arch/arm/include/asm/spl.h index e5daf89127..8acd7cd1bd 100644 --- a/arch/arm/include/asm/spl.h +++ b/arch/arm/include/asm/spl.h @@ -7,7 +7,7 @@ #ifndef _ASM_SPL_H_ #define _ASM_SPL_H_ -#if defined(CONFIG_OMAP) || defined(CONFIG_SOCFPGA) \ +#if defined(CONFIG_OMAP) \ || defined(CONFIG_EXYNOS4) || defined(CONFIG_EXYNOS5) \ || defined(CONFIG_EXYNOS4210) /* Platform-specific defines */ diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h index 69527985e2..ef3572b73b 100644 --- a/include/configs/socfpga_common.h +++ b/include/configs/socfpga_common.h @@ -167,16 +167,21 @@ /* * SPL + * + * SRAM Memory layout: + * + * 0xFFFF_0000 ...... Start of SRAM + * 0xFFFF_xxxx ...... Top of stack (grows down) + * 0xFFFF_yyyy ...... Malloc area + * 0xFFFF_zzzz ...... Global Data + * 0xFFFF_FF00 ...... End of SRAM */ #define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_RAM_DEVICE -#define CONFIG_SPL_TEXT_BASE 0xFFFF0000 -#define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR -#define CONFIG_SPL_STACK_SIZE (4 * 1024) -#define CONFIG_SPL_MALLOC_SIZE (5 * 1024) /* FIXME */ -#define CONFIG_SYS_SPL_MALLOC_START ((unsigned long) (&__malloc_start)) -#define CONFIG_SYS_SPL_MALLOC_SIZE (&__malloc_end - &__malloc_start) +#define CONFIG_SPL_TEXT_BASE CONFIG_SYS_INIT_RAM_ADDR +#define CONFIG_SYS_SPL_MALLOC_START CONFIG_SYS_INIT_SP_ADDR +#define CONFIG_SYS_SPL_MALLOC_SIZE (5 * 1024) #define CHUNKSZ_CRC32 (1 * 1024) /* FIXME: ewww */ #define CONFIG_CRC32_VERIFY From a22a584c1f7c3fafe58be28705d7fa85ec54571c Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 22 Oct 2014 19:57:42 +0200 Subject: [PATCH 3/5] arm: socfpga: Zap CONFIG_EPHY[01]_PHY_ADDR macro This is not used anywhere, remove it. Signed-off-by: Marek Vasut Cc: Chin Liang See Acked-by: Dinh Nguyen Cc: Vince Bridgers Cc: Albert Aribaud Cc: Pavel Machek --- include/configs/socfpga_cyclone5.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/configs/socfpga_cyclone5.h b/include/configs/socfpga_cyclone5.h index 60d7e20e83..942738c138 100644 --- a/include/configs/socfpga_cyclone5.h +++ b/include/configs/socfpga_cyclone5.h @@ -55,10 +55,8 @@ #if defined(CONFIG_CMD_NET) #define CONFIG_EMAC_BASE SOCFPGA_EMAC1_ADDRESS #define CONFIG_PHY_INTERFACE_MODE PHY_INTERFACE_MODE_RGMII -#define CONFIG_EPHY0_PHY_ADDR 0 /* PHY */ -#define CONFIG_EPHY1_PHY_ADDR 4 #define CONFIG_PHY_MICREL #define CONFIG_PHY_MICREL_KSZ9021 #define CONFIG_KSZ9021_CLK_SKEW_ENV "micrel-ksz9021-clk-skew" From 686ed2c2281a3168dcc62d097f044ec1bcc6404b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= Date: Fri, 24 Oct 2014 23:39:10 +0200 Subject: [PATCH 4/5] tools/socfpgaimage.c: fix build on darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit socfpgaimage utilizes htole32 and friends, unfortunately these functions are not available on darwin. Fix it by using the cpu_to_le32 and friends defined in compiler.h as other parts in mkimage do. This patch fixes the following error: ---8<--- HOSTCC tools/socfpgaimage.o tools/socfpgaimage.c:77:22: warning: implicit declaration of function 'htole32' is invalid in C99 [-Wimplicit-function-declaration] header.validation = htole32(VALIDATION_WORD); ^ tools/socfpgaimage.c:80:22: warning: implicit declaration of function 'htole16' is invalid in C99 [-Wimplicit-function-declaration] header.length_u32 = htole16(length_bytes/4); ^ tools/socfpgaimage.c:95:6: warning: implicit declaration of function 'le32toh' is invalid in C99 [-Wimplicit-function-declaration] if (le32toh(header.validation) != VALIDATION_WORD) ^ tools/socfpgaimage.c:97:6: warning: implicit declaration of function 'le16toh' is invalid in C99 [-Wimplicit-function-declaration] if (le16toh(header.checksum) != hdr_checksum(&header)) ^ 4 warnings generated. ... HOSTLD tools/dumpimage Undefined symbols for architecture x86_64: "_htole16", referenced from: _socfpgaimage_set_header in socfpgaimage.o "_htole32", referenced from: _socfpgaimage_set_header in socfpgaimage.o "_le16toh", referenced from: _verify_buffer in socfpgaimage.o "_le32toh", referenced from: _verify_buffer in socfpgaimage.o ld: symbol(s) not found for architecture x86_64 --->8--- Signed-off-by: Andreas Bießmann Acked-by: Pavel Machek --- tools/socfpgaimage.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/socfpgaimage.c b/tools/socfpgaimage.c index 396d8a5472..917873e7b3 100644 --- a/tools/socfpgaimage.c +++ b/tools/socfpgaimage.c @@ -74,12 +74,12 @@ static uint16_t hdr_checksum(struct socfpga_header *header) static void build_header(uint8_t *buf, uint8_t version, uint8_t flags, uint16_t length_bytes) { - header.validation = htole32(VALIDATION_WORD); + header.validation = cpu_to_le32(VALIDATION_WORD); header.version = version; header.flags = flags; - header.length_u32 = htole16(length_bytes/4); + header.length_u32 = cpu_to_le16(length_bytes/4); header.zero = 0; - header.checksum = htole16(hdr_checksum(&header)); + header.checksum = cpu_to_le16(hdr_checksum(&header)); memcpy(buf, &header, sizeof(header)); } @@ -92,12 +92,12 @@ static int verify_header(const uint8_t *buf) { memcpy(&header, buf, sizeof(header)); - if (le32toh(header.validation) != VALIDATION_WORD) + if (le32_to_cpu(header.validation) != VALIDATION_WORD) return -1; - if (le16toh(header.checksum) != hdr_checksum(&header)) + if (le16_to_cpu(header.checksum) != hdr_checksum(&header)) return -1; - return le16toh(header.length_u32) * 4; + return le16_to_cpu(header.length_u32) * 4; } /* Sign the buffer and return the signed buffer size */ @@ -116,7 +116,7 @@ static int sign_buffer(uint8_t *buf, /* Calculate and apply the CRC */ calc_crc = ~pbl_crc32(0, (char *)buf, len); - *((uint32_t *)(buf + len)) = htole32(calc_crc); + *((uint32_t *)(buf + len)) = cpu_to_le32(calc_crc); if (!pad_64k) return len + 4; @@ -150,7 +150,7 @@ static int verify_buffer(const uint8_t *buf) calc_crc = ~pbl_crc32(0, (const char *)buf, len); - buf_crc = le32toh(*((uint32_t *)(buf + len))); + buf_crc = le32_to_cpu(*((uint32_t *)(buf + len))); if (buf_crc != calc_crc) { fprintf(stderr, "CRC32 does not match (%08x != %08x)\n", From 20cadbbe2e0425783855f6ae90ef82aa0db63155 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 24 Oct 2014 23:34:25 +0200 Subject: [PATCH 5/5] arm: socfpga: config: Add USB support example Add example configuration stub for the DWC2 USB controller. Signed-off-by: Marek Vasut Cc: Chin Liang See Cc: Dinh Nguyen Cc: Vince Bridgers Cc: Pavel Machek --- include/configs/socfpga_common.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h index ef3572b73b..83a1bcdfbe 100644 --- a/include/configs/socfpga_common.h +++ b/include/configs/socfpga_common.h @@ -156,6 +156,21 @@ #define CONFIG_CONS_INDEX 1 #define CONFIG_BAUDRATE 115200 +/* + * USB + */ +#ifdef CONFIG_CMD_USB +#define CONFIG_USB_DWC2 +#define CONFIG_USB_STORAGE +/* + * NOTE: User must define either of the following to select which + * of the two USB controllers available on SoCFPGA to use. + * The DWC2 driver doesn't support multiple USB controllers. + * #define CONFIG_USB_DWC2_REG_ADDR SOCFPGA_USB0_ADDRESS + * #define CONFIG_USB_DWC2_REG_ADDR SOCFPGA_USB1_ADDRESS + */ +#endif + /* * U-Boot environment */