diff mbox

[U-Boot,1/2] use MAC from environment and add support for new NET_MULTI api in ethernet driver of KS8695

Message ID EC8E3D9A08FBD540BB1137DDACCB0ABD995EFE8300@NTEXCCR.controlware.de
State Rejected
Headers show

Commit Message

Bernstein, Michael Nov. 4, 2010, 10:13 a.m. UTC
Hello,

Use MAC from the environment instead of read a hard coded address in the ethernet driver of the KS8695.

Signed-off-by: Michael Bernstein <Michael.Bernstein@controlware.de>

---


--

Comments

Mike Frysinger Nov. 9, 2010, 2:38 p.m. UTC | #1
On Thursday, November 04, 2010 06:13:00 Bernstein, Michael wrote:
> diff --unified --recursive --new-file
> u-boot-2009.11/drivers/net/ks8695eth.c
> u-boot-2009.11,new/drivers/net/ks8695eth.c ---
> u-boot-2009.11/drivers/net/ks8695eth.c

this is a pretty old tree.  you should be using latest mainline tree.

>  void ks8695_getmac(void)
>  {
> -       unsigned char *fp;
> -       int i;
> +       if (!eth_getenv_enetaddr("ethaddr", &eth_mac[0])) {

NAK.  drivers should not be poking the environment.  please read the 
documentation in doc/README.drivers.eth.
-mike
diff mbox

Patch

diff --unified --recursive --new-file u-boot-2009.11/drivers/net/ks8695eth.c u-boot-2009.11,new/drivers/net/ks8695eth.c
--- u-boot-2009.11/drivers/net/ks8695eth.c      2009-12-15 23:20:54.000000000 +0100
+++ u-boot-2009.11.new/drivers/net/ks8695eth.c  2010-01-22 19:52:39.000000000 +0100
@@ -82,19 +82,23 @@ 

 void ks8695_getmac(void)
 {
-       unsigned char *fp;
-       int i;
+       if (!eth_getenv_enetaddr("ethaddr", &eth_mac[0])) {
+               /* no mac in environment - fallback to old */
+               /* code which reads the mac from memory. */
+               unsigned char *fp;
+               int i;
+
+               /* Check if flash MAC is valid */
+               fp = (unsigned char *) 0x0201c000;
+               for (i = 0; (i < 6); i++) {
+                       if ((fp[i] != 0) && (fp[i] != 0xff))
+                               break;
+               }

-       /* Check if flash MAC is valid */
-       fp = (unsigned char *) 0x0201c000;
-       for (i = 0; (i < 6); i++) {
-               if ((fp[i] != 0) && (fp[i] != 0xff))
-                       break;
+               /* If we found a valid looking MAC address then use it */
+               if (i < 6)
+                       memcpy(&eth_mac[0], fp, 6);
        }
-
-       /* If we found a valid looking MAC address then use it */
-       if (i < 6)
-               memcpy(&eth_mac[0], fp, 6);
 }

 /****************************************************************************/
@@ -137,7 +141,7 @@ 
                ks8695_rx[i].addr = (uint32_t) &ks8695_bufs[(i+TXDESCS)*BUFSIZE];
                ks8695_rx[i].next = (uint32_t) &ks8695_rx[i+1];
        }
-       ks8695_rx[RXDESCS-1].ctrl |= 0x00080000;
+       ks8695_rx[RXDESCS-1].ctrl |= 0x02000000;
        ks8695_rx[RXDESCS-1].next = (uint32_t) &ks8695_rx[0];

        /* The KS8695 is pretty slow reseting the ethernets... */