
Add basic network support to sandbox which includes a network driver.
Signed-off-by: Joe Hershberger joe.hershberger@ni.com ---
arch/sandbox/dts/sandbox.dts | 4 ++ drivers/net/Makefile | 2 + drivers/net/sandbox.c | 91 ++++++++++++++++++++++++++++++++++++++++++++ include/configs/sandbox.h | 14 ++++--- 4 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 drivers/net/sandbox.c
diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts index 11748ae..a1d3199 100644 --- a/arch/sandbox/dts/sandbox.dts +++ b/arch/sandbox/dts/sandbox.dts @@ -174,4 +174,8 @@ }; };
+ eth@10002000 { + compatible = "sandbox,eth"; + reg = <0x10002000 0x1000>; + }; }; diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 46c4ac6..2659a8a 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -50,6 +50,8 @@ 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_ETH_SANDBOX_RAW) += sandbox-raw.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..e1ee69b --- /dev/null +++ b/drivers/net/sandbox.c @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2015 National Instruments + * + * (C) Copyright 2015 + * Joe Hershberger joe.hershberger@ni.com + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <dm.h> +#include <fdtdec.h> +#include <malloc.h> +#include <net.h> + +DECLARE_GLOBAL_DATA_PTR; + +struct eth_sandbox_priv { + void *device; + int sd; +}; + +int sb_eth_init(struct udevice *dev, bd_t *bis) +{ + printf("eth_sandbox: Init\n"); + + return 0; +} + +int sb_eth_send(struct udevice *dev, void *packet, int length) +{ + printf("eth_sandbox: Send packet %d\n", length); + + return 0; +#endif +} + +int sb_eth_recv(struct udevice *dev) +{ + return 0; +} + +void sb_eth_halt(struct udevice *dev) +{ + printf("eth_sandbox: Halt\n"); +} + +int sb_eth_write_hwaddr(struct udevice *dev) +{ + printf("eth_sandbox: Write HW ADDR\n"); + return 0; +} + +static const struct eth_ops eth_sandbox_ops = { + .init = sb_eth_init, + .send = sb_eth_send, + .recv = sb_eth_recv, + .halt = sb_eth_halt, + .write_hwaddr = sb_eth_write_hwaddr, +}; + +static int eth_sandbox_remove(struct udevice *dev) +{ + return 0; +} + +#ifdef CONFIG_OF_CONTROL +static int sandbox_eth_ofdata_to_platdata(struct udevice *dev) +{ + struct eth_pdata *pdata = dev->platdata; + + pdata->iobase = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg"); + return 0; +} + +static const struct udevice_id sandbox_eth_ids[] = { + { .compatible = "sandbox,eth" }, + { } +}; +#endif + +U_BOOT_DRIVER(eth_sandbox) = { + .name = "eth_sandbox", + .id = UCLASS_ETH, + .of_match = of_match_ptr(sandbox_eth_ids), + .ofdata_to_platdata = of_match_ptr(sandbox_eth_ofdata_to_platdata), + .remove = eth_sandbox_remove, + .ops = ð_sandbox_ops, + .priv_auto_alloc_size = sizeof(struct eth_sandbox_priv), + .platdata_auto_alloc_size = sizeof(struct eth_pdata), +}; diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 657f751..67bfc52 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -143,9 +143,9 @@ /* include default commands */ #include <config_cmd_default.h>
-/* We don't have networking support yet */ -#undef CONFIG_CMD_NET -#undef CONFIG_CMD_NFS +#define CONFIG_DM_ETH +#define CONFIG_ETH_SANDBOX +#define CONFIG_CMD_PING
#define CONFIG_CMD_HASH #define CONFIG_HASH_VERIFY @@ -188,12 +188,16 @@
#define CONFIG_EXTRA_ENV_SETTINGS "stdin=serial,cros-ec-keyb\0" \ "stdout=serial,lcd\0" \ - "stderr=serial,lcd\0" + "stderr=serial,lcd\0" \ + "ethaddr=00:00:11:22:33:44\0" \ + "ipaddr=1.2.3.4\0" #else
#define CONFIG_EXTRA_ENV_SETTINGS "stdin=serial\0" \ "stdout=serial,lcd\0" \ - "stderr=serial,lcd\0" + "stderr=serial,lcd\0" \ + "ethaddr=00:00:11:22:33:44\0" \ + "ipaddr=1.2.3.4\0" #endif
#define CONFIG_GZIP_COMPRESSED