]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Initial cleanup of Davinci Ethernet driver
authorBen Warren <biggerbadderben@gmail.com>
Tue, 28 Apr 2009 06:19:10 +0000 (23:19 -0700)
committerBen Warren <biggerbadderben@gmail.com>
Mon, 15 Jun 2009 07:13:54 +0000 (00:13 -0700)
 Removed pointless #ifdefs
 Moved functions around in file in preparation for switch to newer API

Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
drivers/net/davinci_emac.c

index f6f81df6cafa3f70f98956ac7b34c63b6142d163..f5cec0547c7e59b6dd702b307999f4181eb95fbd 100644 (file)
 #include <miiphy.h>
 #include <asm/arch/emac_defs.h>
 
-#ifdef CONFIG_DRIVER_TI_EMAC
-
-#ifdef CONFIG_CMD_NET
-
 unsigned int   emac_dbg = 0;
 #define debug_emac(fmt,args...)        if (emac_dbg) printf(fmt,##args)
 
@@ -291,77 +287,6 @@ int davinci_eth_miiphy_initialize(bd_t *bis)
 }
 #endif
 
-/*
- * This function initializes the emac hardware. It does NOT initialize
- * EMAC modules power or pin multiplexors, that is done by board_init()
- * much earlier in bootup process. Returns 1 on success, 0 otherwise.
- */
-static int davinci_eth_hw_init(void)
-{
-       u_int32_t       phy_id;
-       u_int16_t       tmp;
-       int             i;
-
-       davinci_eth_mdio_enable();
-
-       for (i = 0; i < 256; i++) {
-               if (adap_mdio->ALIVE)
-                       break;
-               udelay(10);
-       }
-
-       if (i >= 256) {
-               printf("No ETH PHY detected!!!\n");
-               return(0);
-       }
-
-       /* Find if a PHY is connected and get it's address */
-       if (!davinci_eth_phy_detect())
-               return(0);
-
-       /* Get PHY ID and initialize phy_ops for a detected PHY */
-       if (!davinci_eth_phy_read(active_phy_addr, PHY_PHYIDR1, &tmp)) {
-               active_phy_addr = 0xff;
-               return(0);
-       }
-
-       phy_id = (tmp << 16) & 0xffff0000;
-
-       if (!davinci_eth_phy_read(active_phy_addr, PHY_PHYIDR2, &tmp)) {
-               active_phy_addr = 0xff;
-               return(0);
-       }
-
-       phy_id |= tmp & 0x0000ffff;
-
-       switch (phy_id) {
-               case PHY_LXT972:
-                       sprintf(phy.name, "LXT972 @ 0x%02x", active_phy_addr);
-                       phy.init = lxt972_init_phy;
-                       phy.is_phy_connected = lxt972_is_phy_connected;
-                       phy.get_link_speed = lxt972_get_link_speed;
-                       phy.auto_negotiate = lxt972_auto_negotiate;
-                       break;
-               case PHY_DP83848:
-                       sprintf(phy.name, "DP83848 @ 0x%02x", active_phy_addr);
-                       phy.init = dp83848_init_phy;
-                       phy.is_phy_connected = dp83848_is_phy_connected;
-                       phy.get_link_speed = dp83848_get_link_speed;
-                       phy.auto_negotiate = dp83848_auto_negotiate;
-                       break;
-               default:
-                       sprintf(phy.name, "GENERIC @ 0x%02x", active_phy_addr);
-                       phy.init = gen_init_phy;
-                       phy.is_phy_connected = gen_is_phy_connected;
-                       phy.get_link_speed = gen_get_link_speed;
-                       phy.auto_negotiate = gen_auto_negotiate;
-       }
-
-       printf("Ethernet PHY: %s\n", phy.name);
-
-       return(1);
-}
-
 
 /* Eth device open */
 static int davinci_eth_open(void)
@@ -650,6 +575,73 @@ static int davinci_eth_rcv_packet (void)
        return (0);
 }
 
-#endif /* CONFIG_CMD_NET */
+/*
+ * This function initializes the emac hardware. It does NOT initialize
+ * EMAC modules power or pin multiplexors, that is done by board_init()
+ * much earlier in bootup process. Returns 1 on success, 0 otherwise.
+ */
+static int davinci_eth_hw_init(void)
+{
+       u_int32_t       phy_id;
+       u_int16_t       tmp;
+       int             i;
+
+       davinci_eth_mdio_enable();
+
+       for (i = 0; i < 256; i++) {
+               if (adap_mdio->ALIVE)
+                       break;
+               udelay(10);
+       }
+
+       if (i >= 256) {
+               printf("No ETH PHY detected!!!\n");
+               return(0);
+       }
+
+       /* Find if a PHY is connected and get it's address */
+       if (!davinci_eth_phy_detect())
+               return(0);
+
+       /* Get PHY ID and initialize phy_ops for a detected PHY */
+       if (!davinci_eth_phy_read(active_phy_addr, PHY_PHYIDR1, &tmp)) {
+               active_phy_addr = 0xff;
+               return(0);
+       }
 
-#endif /* CONFIG_DRIVER_TI_EMAC */
+       phy_id = (tmp << 16) & 0xffff0000;
+
+       if (!davinci_eth_phy_read(active_phy_addr, PHY_PHYIDR2, &tmp)) {
+               active_phy_addr = 0xff;
+               return(0);
+       }
+
+       phy_id |= tmp & 0x0000ffff;
+
+       switch (phy_id) {
+               case PHY_LXT972:
+                       sprintf(phy.name, "LXT972 @ 0x%02x", active_phy_addr);
+                       phy.init = lxt972_init_phy;
+                       phy.is_phy_connected = lxt972_is_phy_connected;
+                       phy.get_link_speed = lxt972_get_link_speed;
+                       phy.auto_negotiate = lxt972_auto_negotiate;
+                       break;
+               case PHY_DP83848:
+                       sprintf(phy.name, "DP83848 @ 0x%02x", active_phy_addr);
+                       phy.init = dp83848_init_phy;
+                       phy.is_phy_connected = dp83848_is_phy_connected;
+                       phy.get_link_speed = dp83848_get_link_speed;
+                       phy.auto_negotiate = dp83848_auto_negotiate;
+                       break;
+               default:
+                       sprintf(phy.name, "GENERIC @ 0x%02x", active_phy_addr);
+                       phy.init = gen_init_phy;
+                       phy.is_phy_connected = gen_is_phy_connected;
+                       phy.get_link_speed = gen_get_link_speed;
+                       phy.auto_negotiate = gen_auto_negotiate;
+       }
+
+       printf("Ethernet PHY: %s\n", phy.name);
+
+       return(1);
+}