diff options
author | Joe Hershberger <joe.hershberger@ni.com> | 2015-03-22 17:09:13 -0500 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-04-18 11:11:12 -0600 |
commit | 3ea143abe957cd771582fcde33e5fb8096bd826e (patch) | |
tree | fc85425bd489063c134c0acfacaadf185cf6c7f0 /drivers | |
parent | 17591405a7b932ba0a66107645f5ff5f6f36da75 (diff) | |
download | u-boot-imx-3ea143abe957cd771582fcde33e5fb8096bd826e.zip u-boot-imx-3ea143abe957cd771582fcde33e5fb8096bd826e.tar.gz u-boot-imx-3ea143abe957cd771582fcde33e5fb8096bd826e.tar.bz2 |
sandbox: eth: Add network support to sandbox
Add basic network support to sandbox which includes a network driver.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/Kconfig | 23 | ||||
-rw-r--r-- | drivers/net/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/sandbox.c | 84 |
3 files changed, 108 insertions, 0 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 94cf099..e46e57b 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -7,3 +7,26 @@ config DM_ETH The eth_*() interface will be implemented by the UC_ETH class This is currently implemented in net/eth.c Look in include/net.h for details. + +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" + help + This driver simply responds with fake ARP replies and ping + replies that are used to verify network stack functionality + + This driver is particularly useful in the test/dm/eth.c tests + +endif # NETDEVICES diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 5a5269a..b9f5db3 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -51,6 +51,7 @@ obj-$(CONFIG_PCH_GBE) += pch_gbe.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..522990d --- /dev/null +++ b/drivers/net/sandbox.c @@ -0,0 +1,84 @@ +/* + * 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 <malloc.h> +#include <net.h> + +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, uchar **packetp) +{ + 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), +}; |