From: Ben Warren <biggerbadderben@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/3][Net][ARM] Initial cleanup of Davinci Ethernet driver
Date: Tue, 28 Apr 2009 10:12:12 -0700 [thread overview]
Message-ID: <1240938733-3121-3-git-send-email-biggerbadderben@gmail.com> (raw)
In-Reply-To: <1240938733-3121-2-git-send-email-biggerbadderben@gmail.com>
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/dm644x_emac.c | 146 +++++++++++++++++++++------------------------
1 files changed, 69 insertions(+), 77 deletions(-)
diff --git a/drivers/net/dm644x_emac.c b/drivers/net/dm644x_emac.c
index f6f81df..f5cec05 100644
--- a/drivers/net/dm644x_emac.c
+++ b/drivers/net/dm644x_emac.c
@@ -42,10 +42,6 @@
#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);
+}
--
1.5.6.3
next prev parent reply other threads:[~2009-04-28 17:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-28 17:12 [U-Boot] [PATCH 0/3][Net][ARM] Davinci Ethernet driver cleanup Ben Warren
2009-04-28 17:12 ` [U-Boot] [PATCH 1/3][Net][ARM] Moved Davinci Ethernet driver to drivers/net Ben Warren
2009-04-28 17:12 ` Ben Warren [this message]
2009-04-28 17:12 ` [U-Boot] [PATCH 3/3][Net][ARM] Switched dm644x_emac Ethernet driver to use newer API Ben Warren
2009-04-29 20:13 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-29 20:29 ` Ben Warren
2009-04-29 20:49 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-29 22:11 ` Ben Warren
2009-04-29 23:19 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-30 4:28 ` David Brownell
2009-04-28 19:54 ` [U-Boot] [PATCH 1/3][Net][ARM] Moved Davinci Ethernet driver to drivers/net David Brownell
2009-04-28 20:04 ` Ben Warren
2009-04-29 23:32 ` [U-Boot] [PATCH 0/3][Net][ARM] Davinci Ethernet driver cleanup David Brownell
2009-04-29 23:38 ` Ben Warren
2009-04-30 5:59 ` Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <C9D59C82B94F474B872F2092A87F26148147B6A3@dlee07.ent.ti.com>
2009-05-12 17:43 ` Ben Warren
2009-05-12 18:28 ` Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1240938733-3121-3-git-send-email-biggerbadderben@gmail.com \
--to=biggerbadderben@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox