From patchwork Wed Feb 25 00:02:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 443284 X-Patchwork-Delegate: sjg@chromium.org 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 E8B941400DD for ; Wed, 25 Feb 2015 11:06:53 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9CC834B5B9; Wed, 25 Feb 2015 01:06:28 +0100 (CET) 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 2yN7Tmccw_S7; Wed, 25 Feb 2015 01:06:28 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A38034B62C; Wed, 25 Feb 2015 01:06:09 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 99EBA4A050 for ; Wed, 25 Feb 2015 01:04:44 +0100 (CET) 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 e-VoyapRbBHc for ; Wed, 25 Feb 2015 01:04:44 +0100 (CET) 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 ni.com (skprod2.natinst.com [130.164.80.23]) by theia.denx.de (Postfix) with ESMTPS id 204E84A02F for ; Wed, 25 Feb 2015 01:04:32 +0100 (CET) Received: from us-aus-mgwout2.amer.corp.natinst.com (nb-chan1-1338.natinst.com [130.164.19.134]) by us-aus-skprod2.natinst.com (8.15.0.59/8.15.0.59) with ESMTP id t1P04URF021398; Tue, 24 Feb 2015 18:04:30 -0600 Received: from linux-xvxi.natinst.com ([130.164.14.198]) by us-aus-mgwout2.amer.corp.natinst.com (Lotus Domino Release 8.5.3FP6) with ESMTP id 2015022418042983-383817 ; Tue, 24 Feb 2015 18:04:29 -0600 From: Joe Hershberger To: u-boot@lists.denx.de Date: Tue, 24 Feb 2015 18:02:22 -0600 Message-Id: <1424822552-4366-14-git-send-email-joe.hershberger@ni.com> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <1424822552-4366-1-git-send-email-joe.hershberger@ni.com> References: <1423618233-11397-1-git-send-email-joe.hershberger@ni.com> <1424822552-4366-1-git-send-email-joe.hershberger@ni.com> X-MIMETrack: Itemize by SMTP Server on US-AUS-MGWOut2/AUS/H/NIC(Release 8.5.3FP6|November 21, 2013) at 02/24/2015 06:04:29 PM, Serialize by Router on US-AUS-MGWOut2/AUS/H/NIC(Release 8.5.3FP6|November 21, 2013) at 02/24/2015 06:04:29 PM, Serialize complete at 02/24/2015 06:04:29 PM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2015-02-24_06:, , signatures=0 Cc: Tom Rini , Joe Hershberger Subject: [U-Boot] [RFC PATCH v4 13/23] sandbox: eth: Add network support to sandbox X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add basic network support to sandbox which includes a network driver. Signed-off-by: Joe Hershberger Reviewed-by: Simon Glass --- Changes in v4: -Cleaned up sandbox EXTRA_ENV define -Moved config to Kconfig Changes in v3: -Added 2 more ethaddr to sandbox -Print which device in the debug write hwaddr Changes in v2: -Change printfs to debug in sandbox driver -Remove unused priv struct for sandbox driver arch/sandbox/Kconfig | 9 +++++ arch/sandbox/dts/sandbox.dts | 4 +++ board/sandbox/README.sandbox | 4 +-- drivers/net/Kconfig | 18 ++++++++++ drivers/net/Makefile | 1 + drivers/net/sandbox.c | 84 ++++++++++++++++++++++++++++++++++++++++++++ include/configs/sandbox.h | 16 +++++---- 7 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 drivers/net/sandbox.c diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index 2098b9c..186b58d 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -34,4 +34,13 @@ config DM_I2C config DM_TEST default y +config NET + default y + +config NETDEVICES + default y + +config DM_ETH + default y + endmenu diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts index 9ce31bf..36b3bd8 100644 --- a/arch/sandbox/dts/sandbox.dts +++ b/arch/sandbox/dts/sandbox.dts @@ -181,4 +181,8 @@ }; }; + eth@10002000 { + compatible = "sandbox,eth"; + reg = <0x10002000 0x1000>; + }; }; diff --git a/board/sandbox/README.sandbox b/board/sandbox/README.sandbox index 3c0df17..c1f5f7e 100644 --- a/board/sandbox/README.sandbox +++ b/board/sandbox/README.sandbox @@ -173,16 +173,16 @@ U-Boot sandbox supports these emulations: - Chrome OS EC - GPIO - Host filesystem (access files on the host from within U-Boot) +- I2C - Keyboard (Chrome OS) - LCD +- Network - Serial (for console only) - Sound (incomplete - see sandbox_sdl_sound_init() for details) - SPI - SPI flash - TPM (Trusted Platform Module) -Notable omissions are networking and I2C. - A wide range of commands is implemented. Filesystems which use a block device are supported. diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index bdd0f05..b08746a 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -3,3 +3,21 @@ config DM_ETH depends on DM help Enable driver model for Ethernet. + +menuconfig NETDEVICES + bool "Network device support" + depends on NET + help + You must select Y to enable any network device support + Generally if you have any networking support this is a given + + If unsure, say Y + +if NETDEVICES + +config ETH_SANDBOX + depends on DM_ETH && SANDBOX + default y + bool "Sandbox: Mocked Ethernet driver" + +endif # NETDEVICES diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 46c4ac6..15dc431 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -50,6 +50,7 @@ obj-$(CONFIG_NS8382X) += ns8382x.o obj-$(CONFIG_PCNET) += pcnet.o obj-$(CONFIG_RTL8139) += rtl8139.o obj-$(CONFIG_RTL8169) += rtl8169.o +obj-$(CONFIG_ETH_SANDBOX) += sandbox.o obj-$(CONFIG_SH_ETHER) += sh_eth.o obj-$(CONFIG_SMC91111) += smc91111.o obj-$(CONFIG_SMC911X) += smc911x.o diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c new file mode 100644 index 0000000..834e02a --- /dev/null +++ b/drivers/net/sandbox.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2015 National Instruments + * + * (C) Copyright 2015 + * Joe Hershberger + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static int sb_eth_start(struct udevice *dev) +{ + debug("eth_sandbox: Start\n"); + + return 0; +} + +static int sb_eth_send(struct udevice *dev, void *packet, int length) +{ + debug("eth_sandbox: Send packet %d\n", length); + + return 0; +} + +static int sb_eth_recv(struct udevice *dev) +{ + return 0; +} + +static void sb_eth_stop(struct udevice *dev) +{ + debug("eth_sandbox: Stop\n"); +} + +static int sb_eth_write_hwaddr(struct udevice *dev) +{ + struct eth_pdata *pdata = dev_get_platdata(dev); + + debug("eth_sandbox %s: Write HW ADDR - %pM\n", dev->name, + pdata->enetaddr); + return 0; +} + +static const struct eth_ops sb_eth_ops = { + .start = sb_eth_start, + .send = sb_eth_send, + .recv = sb_eth_recv, + .stop = sb_eth_stop, + .write_hwaddr = sb_eth_write_hwaddr, +}; + +static int sb_eth_remove(struct udevice *dev) +{ + return 0; +} + +static int sb_eth_ofdata_to_platdata(struct udevice *dev) +{ + struct eth_pdata *pdata = dev_get_platdata(dev); + + pdata->iobase = dev_get_addr(dev); + return 0; +} + +static const struct udevice_id sb_eth_ids[] = { + { .compatible = "sandbox,eth" }, + { } +}; + +U_BOOT_DRIVER(eth_sandbox) = { + .name = "eth_sandbox", + .id = UCLASS_ETH, + .of_match = sb_eth_ids, + .ofdata_to_platdata = sb_eth_ofdata_to_platdata, + .remove = sb_eth_remove, + .ops = &sb_eth_ops, + .platdata_auto_alloc_size = sizeof(struct eth_pdata), +}; diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index febbfb6..664b984 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -126,9 +126,6 @@ /* include default commands */ #include -/* We don't have networking support yet */ -#undef CONFIG_CMD_NET -#undef CONFIG_CMD_NFS #define CONFIG_CMD_HASH #define CONFIG_HASH_VERIFY @@ -165,16 +162,23 @@ #define CONFIG_KEYBOARD -#define CONFIG_EXTRA_ENV_SETTINGS "stdin=serial,cros-ec-keyb\0" \ +#define SANDBOX_SERIAL_SETTINGS "stdin=serial,cros-ec-keyb\0" \ "stdout=serial,lcd\0" \ "stderr=serial,lcd\0" #else - -#define CONFIG_EXTRA_ENV_SETTINGS "stdin=serial\0" \ +#define SANDBOX_SERIAL_SETTINGS "stdin=serial\0" \ "stdout=serial,lcd\0" \ "stderr=serial,lcd\0" #endif +#define SANDBOX_ETH_SETTINGS "ethaddr=00:00:11:22:33:44\0" \ + "eth1addr=00:00:11:22:33:45\0" \ + "eth2addr=00:00:11:22:33:46\0" \ + "ipaddr=1.2.3.4\0" + +#define CONFIG_EXTRA_ENV_SETTINGS SANDBOX_SERIAL_SETTINGS \ + SANDBOX_ETH_SETTINGS + #define CONFIG_GZIP_COMPRESSED #define CONFIG_BZIP2 #define CONFIG_LZO