From patchwork Wed Mar 7 12:03:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Virdi X-Patchwork-Id: 145215 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id E3C12B6EF1 for ; Wed, 7 Mar 2012 23:06:16 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 57BA22810B; Wed, 7 Mar 2012 13:05:41 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oGlgzQ3vwzfU; Wed, 7 Mar 2012 13:05:41 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1249A2810C; Wed, 7 Mar 2012 13:05:06 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 54EED280AA for ; Wed, 7 Mar 2012 13:05:00 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mtHkS9K1djTo for ; Wed, 7 Mar 2012 13:04:59 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from eu1sys200aog120.obsmtp.com (eu1sys200aog120.obsmtp.com [207.126.144.149]) by theia.denx.de (Postfix) with ESMTPS id ED7BA280CC for ; Wed, 7 Mar 2012 13:04:42 +0100 (CET) Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob120.postini.com ([207.126.147.11]) with SMTP ID DSNKT1dO0TCLflUJ7ogVxt0+GZxi6UV7ZBH4@postini.com; Wed, 07 Mar 2012 12:04:44 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 007D2E6; Wed, 7 Mar 2012 11:56:05 +0000 (GMT) Received: from Webmail-ap.st.com (eapex1hubcas2.st.com [10.80.176.10]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 0CAB7FA7; Wed, 7 Mar 2012 12:04:31 +0000 (GMT) Received: from localhost (10.199.7.86) by Webmail-ap.st.com (10.80.176.7) with Microsoft SMTP Server (TLS) id 8.3.192.1; Wed, 7 Mar 2012 20:04:02 +0800 From: Amit Virdi To: Date: Wed, 7 Mar 2012 17:33:55 +0530 Message-ID: <1331121854-20494-7-git-send-email-amit.virdi@st.com> X-Mailer: git-send-email 1.7.2.2 In-Reply-To: <1331121854-20494-1-git-send-email-amit.virdi@st.com> References: <1331121854-20494-1-git-send-email-amit.virdi@st.com> MIME-Version: 1.0 Cc: Amit Virdi , sr@denx.de, spear-devel@list.st.com Subject: [U-Boot] [PATCH 06/25] SPEAr: Add interface information in initialization X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Vipin Kumar 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 Signed-off-by: Amit Virdi --- board/spear/spear300/spear300.c | 11 ++++++++--- board/spear/spear310/spear310.c | 23 +++++++++++++---------- board/spear/spear320/spear320.c | 22 ++++++++++++++++++---- board/spear/spear600/spear600.c | 14 +++++++++++--- drivers/net/designware.c | 10 +++++++++- drivers/net/designware.h | 1 + include/netdev.h | 2 +- 7 files changed, 61 insertions(+), 22 deletions(-) diff --git a/board/spear/spear300/spear300.c b/board/spear/spear300/spear300.c index 3f7ccb8..bf3bbc5 100644 --- a/board/spear/spear300/spear300.c +++ b/board/spear/spear300/spear300.c @@ -22,6 +22,7 @@ */ #include +#include #include #include #include @@ -61,9 +62,13 @@ int board_nand_init(struct nand_chip *nand) 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; } diff --git a/board/spear/spear310/spear310.c b/board/spear/spear310/spear310.c index f74bbac..107b34b 100644 --- a/board/spear/spear310/spear310.c +++ b/board/spear/spear310/spear310.c @@ -23,6 +23,7 @@ */ #include +#include #include #include #include @@ -65,25 +66,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; } diff --git a/board/spear/spear320/spear320.c b/board/spear/spear320/spear320.c index adddfd1..ffe11ad 100644 --- a/board/spear/spear320/spear320.c +++ b/board/spear/spear320/spear320.c @@ -23,6 +23,7 @@ */ #include +#include #include #include #include @@ -31,8 +32,18 @@ #include #include +#define PLGPIO_SEL_36 0xb3000028 +#define PLGPIO_IO_36 0xb3000038 + +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); } @@ -63,14 +74,17 @@ int board_nand_init(struct nand_chip *nand) 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; } diff --git a/board/spear/spear600/spear600.c b/board/spear/spear600/spear600.c index 5a32b7f..f592233 100644 --- a/board/spear/spear600/spear600.c +++ b/board/spear/spear600/spear600.c @@ -22,6 +22,7 @@ */ #include +#include #include #include #include @@ -56,9 +57,16 @@ int board_nand_init(struct nand_chip *nand) 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; } diff --git a/drivers/net/designware.c b/drivers/net/designware.c index e8e669b..e263022 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -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; @@ -532,7 +539,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; @@ -566,6 +573,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; diff --git a/drivers/net/designware.h b/drivers/net/designware.h index abf729d..40020bf 100644 --- a/drivers/net/designware.h +++ b/drivers/net/designware.h @@ -234,6 +234,7 @@ struct dmamacdescr { struct dw_eth_dev { u32 address; + u32 interface; u32 speed; u32 duplex; u32 tx_currdescnum; diff --git a/include/netdev.h b/include/netdev.h index b0c21d5..bad1eaf 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -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);