From patchwork Tue Jun 26 11:01:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Yanok X-Patchwork-Id: 167382 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 7142E10085D for ; Tue, 26 Jun 2012 21:03:13 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B75642810A; Tue, 26 Jun 2012 13:02:15 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NRJEW9SypQuJ; Tue, 26 Jun 2012 13:02:15 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7C97928134; Tue, 26 Jun 2012 13:01:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0085B28117 for ; Tue, 26 Jun 2012 13:01:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1PJ+ci1fDf9n for ; Tue, 26 Jun 2012 13:01:36 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by theia.denx.de (Postfix) with ESMTPS id D0F81280FB for ; Tue, 26 Jun 2012 13:01:35 +0200 (CEST) Received: by mail-lb0-f172.google.com with SMTP id go11so7678663lbb.3 for ; Tue, 26 Jun 2012 04:01:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=OxgcNikduO6T1N/5WPJDnzAWxuJAWKvvTJj7xFh8hII=; b=IyDIDlajq2tsb1wDxjoCORSQx1nCf8PPwgykXz02GPSF34fj3CSx/0DTQ/BuTQuNk9 QF2Xme34xhcALlNYgA1PXK9w6QttXzUdE5wDNhpDGo5PJt7XeNve9+1i9Ceosk6sTMst FqUMiD8GvpjWtwCS/iSQbIS1zc/daXoG2L84S+py2g9dUWq0gG6pqppWLEl8bpCuRQG+ 2vdVD2rv2GCiqufft2ppx/dg45ey1BiK+LqRdTd4gXsPCTwDl65R2UYvKXg8A3Nf0U2x Myj6NDwj15FCC5KomOyUSn9Kp0opAaY/XWeoHqpfIcSGnpr1V+A1e7tDCIu99tTw3U11 O0IQ== Received: by 10.112.32.35 with SMTP id f3mr7468041lbi.47.1340708494966; Tue, 26 Jun 2012 04:01:34 -0700 (PDT) Received: from localhost.localdomain ([188.134.70.194]) by mx.google.com with ESMTPS id mo3sm76690001lab.2.2012.06.26.04.01.33 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 26 Jun 2012 04:01:34 -0700 (PDT) From: Ilya Yanok To: u-boot@lists.denx.de Date: Tue, 26 Jun 2012 15:01:25 +0400 Message-Id: <1340708486-10286-7-git-send-email-ilya.yanok@cogentembedded.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1340708486-10286-1-git-send-email-ilya.yanok@cogentembedded.com> References: <1340708486-10286-1-git-send-email-ilya.yanok@cogentembedded.com> X-Gm-Message-State: ALoCoQn3wLJymfPLyBngv4LMExN4hmOYoSKs3eAjhOmM3mMxBLVQb4jBY8p4E3jpXhL8IHNSR1RA Cc: trini@ti.com, ilya.yanok@cogentembedded.com Subject: [U-Boot] [PATCH V2 6/7] OMAP: networking support for SPL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch adds support for networking in SPL. Some devices are capable of loading SPL via network so it makes sense to load the main U-Boot binary via network too. This patch tries to use existing network code as much as possible. Unfortunately, it depends on environment which in turn depends on other code so SPL size is increased significantly. No effort was done to decouple network code and environment so far. CC: Tom Rini Signed-off-by: Ilya Yanok --- arch/arm/cpu/armv7/omap-common/Makefile | 3 ++ arch/arm/cpu/armv7/omap-common/spl.c | 5 +++ arch/arm/cpu/armv7/omap-common/spl_eth.c | 50 ++++++++++++++++++++++++++++++ arch/arm/include/asm/omap_common.h | 4 +++ common/Makefile | 6 ++++ common/cmd_nvedit.c | 6 ++-- common/env_common.c | 3 +- lib/Makefile | 10 ++++-- lib/vsprintf.c | 2 +- spl/Makefile | 3 ++ 10 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 arch/arm/cpu/armv7/omap-common/spl_eth.c diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile index 1394c3f..4945bdf 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -56,6 +56,9 @@ endif ifdef CONFIG_SPL_YMODEM_SUPPORT COBJS += spl_ymodem.o endif +ifdef CONFIG_SPL_ETH_SUPPORT +COBJS += spl_eth.o +endif endif ifndef CONFIG_SPL_BUILD diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index 4d1ac85..e7127fb 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -176,6 +176,11 @@ void board_init_r(gd_t *id, ulong dummy) spl_ymodem_load_image(); break; #endif +#ifdef CONFIG_SPL_ETH_SUPPORT + case BOOT_DEVICE_CPGMAC: + spl_eth_load_image(); + break; +#endif default: printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device); hang(); diff --git a/arch/arm/cpu/armv7/omap-common/spl_eth.c b/arch/arm/cpu/armv7/omap-common/spl_eth.c new file mode 100644 index 0000000..21d6e77 --- /dev/null +++ b/arch/arm/cpu/armv7/omap-common/spl_eth.c @@ -0,0 +1,50 @@ +/* + * (C) Copyright 2000-2004 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * (C) Copyright 2012 + * Ilya Yanok + * + * 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. + */ +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +void spl_eth_load_image(void) +{ + int rv; + + env_init(); + env_relocate(); + setenv("autoload", "yes"); + load_addr = CONFIG_SYS_TEXT_BASE - sizeof(struct image_header); + rv = eth_initialize(gd->bd); + if (rv == 0) { + printf("No Ethernet devices found\n"); + hang(); + } + rv = NetLoop(BOOTP); + if (rv < 0) { + printf("Problem booting with BOOTP\n"); + hang(); + } + spl_parse_image_header((struct image_header *)load_addr); +} diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index 4e95eee..a433836 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -69,6 +69,7 @@ void preloader_console_init(void); #define BOOT_DEVICE_MMC1 8 #define BOOT_DEVICE_MMC2 0 #define BOOT_DEVICE_UART 65 +#define BOOT_DEVICE_CPGMAC 70 #define BOOT_DEVICE_MMC2_2 0xFF #endif @@ -107,6 +108,9 @@ void spl_mmc_load_image(void); /* YMODEM SPL functions */ void spl_ymodem_load_image(void); +/* Ethernet SPL functions */ +void spl_eth_load_image(void); + #ifdef CONFIG_SPL_BOARD_INIT void spl_board_init(void); #endif diff --git a/common/Makefile b/common/Makefile index 6e23baa..15cbf43 100644 --- a/common/Makefile +++ b/common/Makefile @@ -190,6 +190,12 @@ endif ifdef CONFIG_SPL_BUILD COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += cmd_nvedit.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += command.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_common.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_nowhere.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += main.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o endif COBJS-y += console.o COBJS-y += dlmalloc.o diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index e1ccdd8..8b8a11f 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -594,7 +594,8 @@ ulong getenv_ulong(const char *name, int base, ulong default_val) return str ? simple_strtoul(str, NULL, base) : default_val; } -#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) +#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) && \ + !defined(CONFIG_SPL_BUILD) int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { printf("Saving Environment to %s...\n", env_name_spec); @@ -928,7 +929,8 @@ static cmd_tbl_t cmd_env_sub[] = { #if defined(CONFIG_CMD_RUN) U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""), #endif -#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) +#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) && \ + !defined(CONFIG_SPL_BUILD) U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""), #endif U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""), diff --git a/common/env_common.c b/common/env_common.c index c33d22d..493aff4 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -225,7 +225,8 @@ void env_relocate(void) env_reloc(); #endif if (gd->env_valid == 0) { -#if defined(CONFIG_ENV_IS_NOWHERE) /* Environment not changable */ +#if defined(CONFIG_ENV_IS_NOWHERE) || defined(CONFIG_SPL_BUILD) + /* Environment not changable */ set_default_env(NULL); #else bootstage_error(BOOTSTAGE_ID_NET_CHECKSUM); diff --git a/lib/Makefile b/lib/Makefile index 1e8478f..4395533 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -53,12 +53,18 @@ COBJS-$(CONFIG_SHA1) += sha1.o COBJS-$(CONFIG_SHA256) += sha256.o COBJS-y += strmhz.o COBJS-$(CONFIG_RBTREE) += rbtree.o -else -COBJS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += display_options.o endif ifdef CONFIG_SPL_BUILD COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += crc32.o +ifneq ($(CONFIG_SPL_SPI_FLASH_SUPPORT)$(CONFIG_SPL_NET_SUPPORT),) +COBJS-y += display_options.o +endif +COBJS-$(CONFIG_SPL_NET_SUPPORT) += errno.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += hashtable.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o +COBJS-$(CONFIG_SPL_NET_SUPPORT) += qsort.o endif COBJS-y += ctype.o COBJS-y += div64.o diff --git a/lib/vsprintf.c b/lib/vsprintf.c index e38a4b7..6bb819c 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -784,7 +784,7 @@ void panic(const char *fmt, ...) vprintf(fmt, args); putc('\n'); va_end(args); -#if defined (CONFIG_PANIC_HANG) +#if defined (CONFIG_PANIC_HANG) || defined(CONFIG_SPL_BUILD) hang(); #else udelay (100000); /* allow messages to go out */ diff --git a/spl/Makefile b/spl/Makefile index ea7d475..925e84f 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -57,6 +57,9 @@ 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_NET_SUPPORT) += net/libnet.o +LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/libnet.o +LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/libphy.o ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o