summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSekhar Nori <nsekhar@ti.com>2009-03-21 18:06:41 +0530
committerJustin Waters <justin.waters@timesys.com>2009-09-09 14:03:21 -0400
commite7579b33ad625c5ccdb129f61186b7b580077527 (patch)
tree4cef57c11c39dbc2d9f836cd8cbebca638d31615
parent9717766f942a70082a66bc5c1501a9616c662258 (diff)
fix RMII support for DA850.
The EMAC driver currently hardcodes the RMII speed 100 bit. This will not work when there is a real phy connected. Tested on DA830. Signed-off-by: Sekhar Nori <nsekhar@ti.com>
-rw-r--r--cpu/arm926ejs/da8xx/ether.c34
-rw-r--r--include/asm-arm/arch-da8xx/emac_defs.h4
-rw-r--r--include/configs/da8xx_evm.h2
3 files changed, 37 insertions, 3 deletions
diff --git a/cpu/arm926ejs/da8xx/ether.c b/cpu/arm926ejs/da8xx/ether.c
index d031b3d215..8e30a57bd9 100644
--- a/cpu/arm926ejs/da8xx/ether.c
+++ b/cpu/arm926ejs/da8xx/ether.c
@@ -131,7 +131,15 @@ static volatile u_int8_t active_phy_addr = 0xff;
static int no_phy_init (int phy_addr) { return(1); }
static int no_phy_is_connected (int phy_addr) { return(1); }
-static int no_phy_get_link_status (int phy_addr) { return(1); }
+static int no_phy_get_link_status (int phy_addr)
+{
+ adap_emac->MACCONTROL = (EMAC_MACCONTROL_MIIEN_ENABLE
+ | EMAC_MACCONTROL_FULLDUPLEX_ENABLE);
+#ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
+ adap_emac->MACCONTROL |= EMAC_MACCONTROL_RMIISPEED_100;
+#endif
+ return 1;
+}
static int no_phy_auto_negotiate (int phy_addr) { return(1); }
phy_t phy = {
.init = no_phy_init,
@@ -253,8 +261,29 @@ static int gen_get_link_status(int phy_addr)
{
u_int16_t tmp;
- if (davinci_eth_phy_read(phy_addr, MII_STATUS_REG, &tmp) && (tmp & 0x04))
+ if (davinci_eth_phy_read(phy_addr, MII_STATUS_REG, &tmp)
+ && (tmp & 0x04)) {
+
+ /* Speed doesn't matter, there is no setting for it in EMAC. */
+ if (tmp & GEN_PHY_STATUS_FD_MASK) {
+ /* set EMAC for Full Duplex */
+ adap_emac->MACCONTROL = EMAC_MACCONTROL_MIIEN_ENABLE |
+ EMAC_MACCONTROL_FULLDUPLEX_ENABLE;
+ } else {
+ /*set EMAC for Half Duplex */
+ adap_emac->MACCONTROL = EMAC_MACCONTROL_MIIEN_ENABLE;
+ }
+
+#ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
+ if(tmp & GEN_PHY_STATUS_SPEED100_MASK) {
+ adap_emac->MACCONTROL |= EMAC_MACCONTROL_RMIISPEED_100;
+ } else {
+ adap_emac->MACCONTROL &= ~EMAC_MACCONTROL_RMIISPEED_100;
+ }
+#endif
+
return(1);
+ }
return(0);
}
@@ -462,7 +491,6 @@ static int davinci_eth_open(void)
adap_emac->RXUNICASTSET = 0x01;
/* Enable MII interface and Full duplex mode */
- adap_emac->MACCONTROL = (EMAC_MACCONTROL_MIIEN_ENABLE | EMAC_MACCONTROL_FULLDUPLEX_ENABLE) | EMAC_MACCONTROL_RMIISPEED_100;
/* Init MDIO & get link state */
clkdiv = (EMAC_MDIO_BUS_FREQ / EMAC_MDIO_CLOCK_FREQ) - 1;
diff --git a/include/asm-arm/arch-da8xx/emac_defs.h b/include/asm-arm/arch-da8xx/emac_defs.h
index 6fe67f2e11..676c152b66 100644
--- a/include/asm-arm/arch-da8xx/emac_defs.h
+++ b/include/asm-arm/arch-da8xx/emac_defs.h
@@ -328,4 +328,8 @@ typedef struct
int (*auto_negotiate)(int phy_addr);
} phy_t;
+/* Generic phy definitions */
+#define GEN_PHY_STATUS_SPEED100_MASK ((1 << 13) | (1 << 14))
+#define GEN_PHY_STATUS_FD_MASK ((1 << 11) | (1 << 13))
+
#endif /* _DM644X_EMAC_H_ */
diff --git a/include/configs/da8xx_evm.h b/include/configs/da8xx_evm.h
index 847fda6bfb..4659126572 100644
--- a/include/configs/da8xx_evm.h
+++ b/include/configs/da8xx_evm.h
@@ -35,12 +35,14 @@
#ifdef CONFIG_DA830_EVM
#define CONFIG_SYS_NS16550_COM1 DAVINCI_UART2_BASE /* Base address of UART2 */
#define CONFIG_SYS_NS16550_CLK clk_get(DAVINCI_UART2_CLKID) /* Input clock to NS16550 */
+#define CONFIG_DRIVER_TI_EMAC_USE_RMII
#define CONFIG_BOOTARGS "mem=32M console=ttyS2,115200n8 root=/dev/mtdblock/2 rw noinitrd ip=dhcp"
#endif
#ifdef CONFIG_DA850_EVM
#define CONFIG_SYS_NS16550_COM1 DAVINCI_UART0_BASE /* Base address of UART2 */
#define CONFIG_SYS_NS16550_CLK clk_get(DAVINCI_UART0_CLKID) /* Input clock to NS16550 */
+#undef CONFIG_DRIVER_TI_EMAC_USE_RMII
#define CONFIG_BOOTARGS "mem=32M console=ttyS0,115200n8 root=/dev/mtdblock/2 rw noinitrd ip=dhcp"
#endif