]> git.sur5r.net Git - u-boot/commitdiff
SPEAr: Add interface information in initialization
authorVipin Kumar <vipin.kumar@st.com>
Mon, 7 May 2012 07:36:44 +0000 (13:06 +0530)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Sat, 7 Jul 2012 12:07:40 +0000 (14:07 +0200)
Few Designware peripheral registers need to be modified based on the
ethernet interface selected by the board. This patch supports interface
information in ethernet driver

Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
Signed-off-by: Amit Virdi <amit.virdi@st.com>
Signed-off-by: Stefan Roese <sr@denx.de>
board/spear/spear300/spear300.c
board/spear/spear310/spear310.c
board/spear/spear320/spear320.c
board/spear/spear600/spear600.c
drivers/net/designware.c
drivers/net/designware.h
include/netdev.h

index 2283ad5ddbcc924494c89aa3f3db6e719afcb553..f809c2dc917f44be8b7190964c44ae3cb5e81c30 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <common.h>
+#include <miiphy.h>
 #include <netdev.h>
 #include <nand.h>
 #include <asm/io.h>
@@ -64,9 +65,13 @@ void board_nand_init()
 
 int board_eth_init(bd_t *bis)
 {
+       int ret = 0;
+
 #if defined(CONFIG_DESIGNWARE_ETH)
-       return designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY);
-#else
-       return -1;
+       u32 interface = PHY_INTERFACE_MODE_MII;
+       if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY,
+                               interface) >= 0)
+               ret++;
 #endif
+       return ret;
 }
index c0e68299944e7e2663f8add6683b836b92bde59d..8609a5910f012339618e192ba2713ea28aea0d5c 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <common.h>
+#include <miiphy.h>
 #include <netdev.h>
 #include <nand.h>
 #include <asm/io.h>
@@ -68,25 +69,27 @@ int board_eth_init(bd_t *bis)
        int ret = 0;
 
 #if defined(CONFIG_DESIGNWARE_ETH)
-       if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY) < 0)
-               ret += -1;
+       u32 interface = PHY_INTERFACE_MODE_MII;
+       if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY,
+                               interface) >= 0)
+               ret++;
 #endif
 #if defined(CONFIG_MACB)
        if (macb_eth_initialize(0, (void *)CONFIG_SYS_MACB0_BASE,
-                               CONFIG_MACB0_PHY) < 0)
-               ret += -1;
+                               CONFIG_MACB0_PHY) >= 0)
+               ret++;
 
        if (macb_eth_initialize(1, (void *)CONFIG_SYS_MACB1_BASE,
-                               CONFIG_MACB1_PHY) < 0)
-               ret += -1;
+                               CONFIG_MACB1_PHY) >= 0)
+               ret++;
 
        if (macb_eth_initialize(2, (void *)CONFIG_SYS_MACB2_BASE,
-                               CONFIG_MACB2_PHY) < 0)
-               ret += -1;
+                               CONFIG_MACB2_PHY) >= 0)
+               ret++;
 
        if (macb_eth_initialize(3, (void *)CONFIG_SYS_MACB3_BASE,
-                               CONFIG_MACB3_PHY) < 0)
-               ret += -1;
+                               CONFIG_MACB3_PHY) >= 0)
+               ret++;
 #endif
        return ret;
 }
index e101888e044d839932b39d7d56ee2610752533bc..54a2e1003ce44c0acb7ef542d35153ad556507e3 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <common.h>
+#include <miiphy.h>
 #include <netdev.h>
 #include <nand.h>
 #include <asm/io.h>
 #include <asm/arch/spr_defs.h>
 #include <asm/arch/spr_misc.h>
 
+#define PLGPIO_SEL_36  0xb3000028
+#define PLGPIO_IO_36   0xb3000038
+
 static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
 
+static void spear_phy_reset(void)
+{
+       writel(0x10, PLGPIO_IO_36);
+       writel(0x10, PLGPIO_SEL_36);
+}
+
 int board_init(void)
 {
+       spear_phy_reset();
        return spear_board_init(MACH_TYPE_SPEAR320);
 }
 
@@ -67,14 +78,17 @@ void board_nand_init()
 int board_eth_init(bd_t *bis)
 {
        int ret = 0;
+
 #if defined(CONFIG_DESIGNWARE_ETH)
-       if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY) < 0)
-               ret += -1;
+       u32 interface = PHY_INTERFACE_MODE_MII;
+       if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY,
+                               interface) >= 0)
+               ret++;
 #endif
 #if defined(CONFIG_MACB)
        if (macb_eth_initialize(0, (void *)CONFIG_SYS_MACB0_BASE,
-                               CONFIG_MACB0_PHY) < 0)
-               ret += -1;
+                               CONFIG_MACB0_PHY) >= 0)
+               ret++;
 #endif
        return ret;
 }
index d18d313b298fc750a76c2d4229b62d19b89c27ef..814f9ccb6b2aeb71030ee305dfded1dea93a68f1 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <common.h>
+#include <miiphy.h>
 #include <netdev.h>
 #include <nand.h>
 #include <asm/io.h>
@@ -59,9 +60,16 @@ void board_nand_init()
 
 int board_eth_init(bd_t *bis)
 {
+       int ret = 0;
+
 #if defined(CONFIG_DESIGNWARE_ETH)
-       return designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY);
-#else
-       return -1;
+       u32 interface = PHY_INTERFACE_MODE_MII;
+#if defined(CONFIG_DW_AUTONEG)
+       interface = PHY_INTERFACE_MODE_GMII;
+#endif
+       if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY,
+                               interface) >= 0)
+               ret++;
 #endif
+       return ret;
 }
index 9b17db41f60b24353eb02d842a3907a7828e86c9..8f22e00ddd88885ed0260db1d0d41b45e2becdc3 100644 (file)
@@ -171,6 +171,13 @@ static int dw_eth_init(struct eth_device *dev, bd_t *bis)
        if (priv->speed != SPEED_1000M)
                conf |= MII_PORTSELECT;
 
+       if ((priv->interface != PHY_INTERFACE_MODE_MII) &&
+               (priv->interface != PHY_INTERFACE_MODE_GMII)) {
+
+               if (priv->speed == SPEED_100M)
+                       conf |= FES_100;
+       }
+
        if (priv->duplex == FULL_DUPLEX)
                conf |= FULLDPLXMODE;
 
@@ -531,7 +538,7 @@ static int dw_mii_write(const char *devname, u8 addr, u8 reg, u16 val)
 }
 #endif
 
-int designware_initialize(u32 id, ulong base_addr, u32 phy_addr)
+int designware_initialize(u32 id, ulong base_addr, u32 phy_addr, u32 interface)
 {
        struct eth_device *dev;
        struct dw_eth_dev *priv;
@@ -565,6 +572,7 @@ int designware_initialize(u32 id, ulong base_addr, u32 phy_addr)
                        DW_DMA_BASE_OFFSET);
        priv->address = phy_addr;
        priv->phy_configured = 0;
+       priv->interface = interface;
 
        if (mac_reset(dev) < 0)
                return -1;
index abf729d57dd42e227649cef39c79840ab854506f..40020bf26b8f6f4092d19920b9dc0c08ab0a1fbe 100644 (file)
@@ -234,6 +234,7 @@ struct dmamacdescr {
 
 struct dw_eth_dev {
        u32 address;
+       u32 interface;
        u32 speed;
        u32 duplex;
        u32 tx_currdescnum;
index 4724717d99a58d94e411a39cbfbdb677717d3dc0..d1aaf0cd2d0637b597a55c49e746d9fba1b9fd19 100644 (file)
@@ -52,7 +52,7 @@ int calxedaxgmac_initialize(u32 id, ulong base_addr);
 int cs8900_initialize(u8 dev_num, int base_addr);
 int davinci_emac_initialize(void);
 int dc21x4x_initialize(bd_t *bis);
-int designware_initialize(u32 id, ulong base_addr, u32 phy_addr);
+int designware_initialize(u32 id, ulong base_addr, u32 phy_addr, u32 interface);
 int dm9000_initialize(bd_t *bis);
 int dnet_eth_initialize(int id, void *regs, unsigned int phy_addr);
 int e1000_initialize(bd_t *bis);