]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - doc/README.drivers.eth
sandbox: Add a simple sound driver
[karo-tx-uboot.git] / doc / README.drivers.eth
index e73e462c8c2ae5a1f53a0af419ae25e4d4ad1aab..eb83038b5dbd1880edc1e9f0cfa34f3ed6eb6a24 100644 (file)
@@ -70,6 +70,7 @@ int ape_register(bd_t *bis, int iobase)
        dev->halt = ape_halt;
        dev->send = ape_send;
        dev->recv = ape_recv;
+       dev->write_hwaddr = ape_write_hwaddr;
 
        eth_register(dev);
 
@@ -102,11 +103,12 @@ not checking its state or doing random probing.
  -----------
 
 Now that we've registered with the ethernet layer, we can start getting some
-real work done.  You will need four functions:
+real work done.  You will need five functions:
        int ape_init(struct eth_device *dev, bd_t *bis);
        int ape_send(struct eth_device *dev, volatile void *packet, int length);
        int ape_recv(struct eth_device *dev);
        int ape_halt(struct eth_device *dev);
+       int ape_write_hwaddr(struct eth_device *dev);
 
 The init function checks the hardware (probing/identifying) and gets it ready
 for send/recv operations.  You often do things here such as resetting the MAC
@@ -122,10 +124,12 @@ function can be called multiple times in a row.
 
 The recv function should process packets as long as the hardware has them
 readily available before returning.  i.e. you should drain the hardware fifo.
-The common code sets up packet buffers for you already (NetRxPackets), so there
-is no need to allocate your own.  For each packet you receive, you should call
-the NetReceive() function on it with the packet length.  So the pseudo code
-here would look something like:
+For each packet you receive, you should call the NetReceive() function on it
+along with the packet length.  The common code sets up packet buffers for you
+already in the .bss (NetRxPackets), so there should be no need to allocate your
+own.  This doesn't mean you must use the NetRxPackets array however; you're
+free to call the NetReceive() function with any buffer you wish.  So the pseudo
+code here would look something like:
 int ape_recv(struct eth_device *dev)
 {
        int length, i = 0;
@@ -145,7 +149,11 @@ int ape_recv(struct eth_device *dev)
 }
 
 The halt function should turn off / disable the hardware and place it back in
-its reset state.
+its reset state.  It can be called at any time (before any call to the related
+init function), so make sure it can handle this sort of thing.
+
+The write_hwaddr function should program the MAC address stored in dev->enetaddr
+into the Ethernet controller.
 
 So the call graph at this stage would look something like:
 some net operation (ping / tftp / whatever...)