1 /* 2 * Copyright (c) 2015 National Instruments 3 * 4 * (C) Copyright 2015 5 * Joe Hershberger <joe.hershberger@ni.com> 6 * 7 * SPDX-License-Identifier: GPL-2.0 8 */ 9 10 #include <common.h> 11 #include <dm.h> 12 #include <malloc.h> 13 #include <net.h> 14 15 DECLARE_GLOBAL_DATA_PTR; 16 17 static int sb_eth_start(struct udevice *dev) 18 { 19 debug("eth_sandbox: Start\n"); 20 21 return 0; 22 } 23 24 static int sb_eth_send(struct udevice *dev, void *packet, int length) 25 { 26 debug("eth_sandbox: Send packet %d\n", length); 27 28 return 0; 29 } 30 31 static int sb_eth_recv(struct udevice *dev, uchar **packetp) 32 { 33 return 0; 34 } 35 36 static void sb_eth_stop(struct udevice *dev) 37 { 38 debug("eth_sandbox: Stop\n"); 39 } 40 41 static int sb_eth_write_hwaddr(struct udevice *dev) 42 { 43 struct eth_pdata *pdata = dev_get_platdata(dev); 44 45 debug("eth_sandbox %s: Write HW ADDR - %pM\n", dev->name, 46 pdata->enetaddr); 47 return 0; 48 } 49 50 static const struct eth_ops sb_eth_ops = { 51 .start = sb_eth_start, 52 .send = sb_eth_send, 53 .recv = sb_eth_recv, 54 .stop = sb_eth_stop, 55 .write_hwaddr = sb_eth_write_hwaddr, 56 }; 57 58 static int sb_eth_remove(struct udevice *dev) 59 { 60 return 0; 61 } 62 63 static int sb_eth_ofdata_to_platdata(struct udevice *dev) 64 { 65 struct eth_pdata *pdata = dev_get_platdata(dev); 66 67 pdata->iobase = dev_get_addr(dev); 68 return 0; 69 } 70 71 static const struct udevice_id sb_eth_ids[] = { 72 { .compatible = "sandbox,eth" }, 73 { } 74 }; 75 76 U_BOOT_DRIVER(eth_sandbox) = { 77 .name = "eth_sandbox", 78 .id = UCLASS_ETH, 79 .of_match = sb_eth_ids, 80 .ofdata_to_platdata = sb_eth_ofdata_to_platdata, 81 .remove = sb_eth_remove, 82 .ops = &sb_eth_ops, 83 .platdata_auto_alloc_size = sizeof(struct eth_pdata), 84 }; 85