]> git.sur5r.net Git - u-boot/blobdiff - drivers/net/sandbox.c
clk: Add Actions Semi OWL clock support
[u-boot] / drivers / net / sandbox.c
index e239ff44479d07cbd04d3906c46646bae2f3c9c1..b34712bd06f1f490111d36ddf2435e24747ea26e 100644 (file)
@@ -1,16 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * 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>
+#include <asm/test.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -30,6 +30,7 @@ struct eth_sandbox_priv {
 };
 
 static bool disabled[8] = {false};
+static bool skip_timeout;
 
 /*
  * sandbox_eth_disable_response()
@@ -42,14 +43,25 @@ void sandbox_eth_disable_response(int index, bool disable)
        disabled[index] = disable;
 }
 
+/*
+ * sandbox_eth_skip_timeout()
+ *
+ * When the first packet read is attempted, fast-forward time
+ */
+void sandbox_eth_skip_timeout(void)
+{
+       skip_timeout = true;
+}
+
 static int sb_eth_start(struct udevice *dev)
 {
        struct eth_sandbox_priv *priv = dev_get_priv(dev);
 
        debug("eth_sandbox: Start\n");
 
-       fdtdec_get_byte_array(gd->fdt_blob, dev->of_offset, "fake-host-hwaddr",
-                             priv->fake_host_hwaddr, ARP_HLEN);
+       fdtdec_get_byte_array(gd->fdt_blob, dev_of_offset(dev),
+                             "fake-host-hwaddr", priv->fake_host_hwaddr,
+                             ARP_HLEN);
        priv->recv_packet_buffer = net_rx_packets[0];
        return 0;
 }
@@ -140,10 +152,15 @@ static int sb_eth_send(struct udevice *dev, void *packet, int length)
        return 0;
 }
 
-static int sb_eth_recv(struct udevice *dev, uchar **packetp)
+static int sb_eth_recv(struct udevice *dev, int flags, uchar **packetp)
 {
        struct eth_sandbox_priv *priv = dev_get_priv(dev);
 
+       if (skip_timeout) {
+               sandbox_timer_add_offset(11000UL);
+               skip_timeout = false;
+       }
+
        if (priv->recv_packet_length) {
                int lcl_recv_packet_length = priv->recv_packet_length;
 
@@ -187,7 +204,7 @@ static int sb_eth_ofdata_to_platdata(struct udevice *dev)
 {
        struct eth_pdata *pdata = dev_get_platdata(dev);
 
-       pdata->iobase = dev_get_addr(dev);
+       pdata->iobase = devfdt_get_addr(dev);
        return 0;
 }