]> git.sur5r.net Git - u-boot/blobdiff - drivers/net/greth.c
Fix GCC format-security errors and convert sprintfs.
[u-boot] / drivers / net / greth.c
index 9bc8a8d1aa1543a74923f90f605684e6281cc18a..aa5d7114a5b8ddf0d164632eda0c634fa72318ac 100644 (file)
@@ -20,7 +20,7 @@
 #include <ambapp.h>
 #include <asm/leon.h>
 
-#include "greth.h"
+#include <grlib/greth.h>
 
 /* Default to 3s timeout on autonegotiation */
 #ifndef GRETH_PHY_TIMEOUT_MS
 #define GRETH_PHY_ADR_DEFAULT 0
 #endif
 
+/* Let board select which GRETH to use as network interface, set
+ * this to zero if only one GRETH is available.
+ */
+#ifndef CONFIG_SYS_GRLIB_GRETH_INDEX
+#define CONFIG_SYS_GRLIB_GRETH_INDEX 0
+#endif
+
 /* ByPass Cache when reading regs */
 #define GRETH_REGLOAD(addr)            SPARC_NOCACHE_READ(addr)
 /* Write-through cache ==> no bypassing needed on writes */
@@ -238,7 +245,7 @@ int greth_init_phy(greth_priv * dev, bd_t * bis)
        debug("GRETH PHY ADDRESS: %d\n", phyaddr);
 
        /* X msecs to ticks */
-       timeout = usec2ticks(GRETH_PHY_TIMEOUT_MS * 1000);
+       timeout = GRETH_PHY_TIMEOUT_MS * 1000;
 
        /* Get system timer0 current value
         * Total timeout is 5s
@@ -593,8 +600,12 @@ int greth_initialize(bd_t * bis)
 
        debug("Scanning for GRETH\n");
 
-       /* Find Device & IRQ via AMBA Plug&Play information */
-       if (ambapp_apb_first(VENDOR_GAISLER, GAISLER_ETHMAC, &apbdev) != 1) {
+       /* Find Device & IRQ via AMBA Plug&Play information,
+        * CONFIG_SYS_GRLIB_GRETH_INDEX select which GRETH if multiple
+        * GRETHs in system.
+        */
+       if (ambapp_apb_find(&ambapp_plb, VENDOR_GAISLER, GAISLER_ETHMAC,
+                       CONFIG_SYS_GRLIB_GRETH_INDEX, &apbdev) != 1) {
                return -1;      /* GRETH not found */
        }
 
@@ -629,9 +640,9 @@ int greth_initialize(bd_t * bis)
 
        /* Make descriptor string */
        if (greth->gbit_mac) {
-               sprintf(dev->name, "GRETH_10/100/GB");
+               strcpy(dev->name, "GRETH_10/100/GB");
        } else {
-               sprintf(dev->name, "GRETH_10/100");
+               strcpy(dev->name, "GRETH_10/100");
        }
 
        /* initiate PHY, select speed/duplex depending on connected PHY */