From patchwork Thu Feb 17 13:46:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asen Dimov X-Patchwork-Id: 83453 X-Patchwork-Delegate: info@emk-elektronik.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 B116AB710D for ; Fri, 18 Feb 2011 00:46:31 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B3891280FE; Thu, 17 Feb 2011 14:46:28 +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 osBSZiUyZB-R; Thu, 17 Feb 2011 14:46:28 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 445B2280EA; Thu, 17 Feb 2011 14:46:26 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1ED4B280EA for ; Thu, 17 Feb 2011 14:46:24 +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 vjjpmtO8YxzU for ; Thu, 17 Feb 2011 14:46:22 +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 tserv.ronetix.at (sofia30-122.pip.digsys.bg [193.68.122.30]) by theia.denx.de (Postfix) with ESMTPS id 04CD9280E7 for ; Thu, 17 Feb 2011 14:46:20 +0100 (CET) Received: from tserv.ronetix.at (localhost.localdomain [127.0.0.1]) by tserv.ronetix.at (8.13.8/8.13.8) with ESMTP id p1HDkJmD008908; Thu, 17 Feb 2011 15:46:19 +0200 Received: (from dimov@localhost) by tserv.ronetix.at (8.13.8/8.13.8/Submit) id p1HDkIgs008907; Thu, 17 Feb 2011 15:46:18 +0200 From: Asen Dimov To: u-boot@lists.denx.de Date: Thu, 17 Feb 2011 15:46:18 +0200 Message-Id: <1297950378-8887-1-git-send-email-dimov@ronetix.at> X-Mailer: git-send-email 1.5.5.6 Subject: [U-Boot] [PATCH v2] pm9g45_v1.3: make ethernet works X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de V2: - put the PHY reset/init code on a proper place, so now in the config file PHY reset could be enabled/disabled if nRST signal is not long enough. Signed-off-by: Asen Dimov --- board/ronetix/pm9g45/pm9g45.c | 50 +++++++++++++++++++++++++++-------------- include/configs/pm9g45.h | 5 ++++ 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/board/ronetix/pm9g45/pm9g45.c b/board/ronetix/pm9g45/pm9g45.c index 79b7c9d..d9e16b9 100644 --- a/board/ronetix/pm9g45/pm9g45.c +++ b/board/ronetix/pm9g45/pm9g45.c @@ -108,23 +108,6 @@ static void pm9g45_macb_hw_init(void) /* Enable clock */ writel(1 << AT91SAM9G45_ID_EMAC, &pmc->pcer); - /* - * Disable pull-up on: - * RXDV (PA15) => PHY normal mode (not Test mode) - * ERX0 (PA12) => PHY ADDR0 - * ERX1 (PA13) => PHY ADDR1 => PHYADDR = 0x0 - * - * PHY has internal pull-down - */ - at91_set_pio_pullup(AT91_PIO_PORTA, 15, 0); - at91_set_pio_pullup(AT91_PIO_PORTA, 12, 0); - at91_set_pio_pullup(AT91_PIO_PORTA, 13, 0); - - /* Re-enable pull-up */ - at91_set_pio_pullup(AT91_PIO_PORTA, 15, 1); - at91_set_pio_pullup(AT91_PIO_PORTA, 12, 1); - at91_set_pio_pullup(AT91_PIO_PORTA, 13, 1); - at91_macb_hw_init(); } #endif @@ -174,6 +157,39 @@ void dram_init_banksize(void) #ifdef CONFIG_RESET_PHY_R void reset_phy(void) { + at91_rstc_t *rstc = (at91_rstc_t *) AT91_RSTC_BASE; + unsigned long erstl; + + /* + * Disable pull-up on: + * RXDV (PA15) => PHY normal mode (not Test mode) + * ERX0 (PA12) => PHY ADDR0 + * ERX1 (PA13) => PHY ADDR1 => PHYADDR = 0x0 + * + * PHY has internal pull-down + */ + at91_set_pio_pullup(AT91_PIO_PORTA, 15, 0); + at91_set_pio_pullup(AT91_PIO_PORTA, 12, 0); + at91_set_pio_pullup(AT91_PIO_PORTA, 13, 0); + + erstl = readl(&rstc->mr) & AT91_RSTC_MR_ERSTL_MASK; + + /* Need to reset PHY -> 500ms reset */ + writel(AT91_RSTC_KEY | AT91_RSTC_MR_ERSTL(0x0D) | + AT91_RSTC_MR_URSTEN, &rstc->mr); + writel(AT91_RSTC_KEY | AT91_RSTC_CR_EXTRST, &rstc->cr); + + /* Wait for end hardware reset */ + while (!(readl(&rstc->sr) & AT91_RSTC_SR_NRSTL)); + + /* Restore NRST value */ + writel(AT91_RSTC_KEY | erstl | AT91_RSTC_MR_URSTEN, &rstc->mr); + + /* Re-enable pull-up */ + at91_set_pio_pullup(AT91_PIO_PORTA, 15, 1); + at91_set_pio_pullup(AT91_PIO_PORTA, 12, 1); + at91_set_pio_pullup(AT91_PIO_PORTA, 13, 1); + #ifdef CONFIG_MACB /* * Initialize ethernet HW addr prior to starting Linux, diff --git a/include/configs/pm9g45.h b/include/configs/pm9g45.h index ec51ccf..4d8089f 100644 --- a/include/configs/pm9g45.h +++ b/include/configs/pm9g45.h @@ -125,6 +125,11 @@ #define CONFIG_NET_MULTI 1 #define CONFIG_NET_RETRY_COUNT 20 #define CONFIG_RESET_PHY_R 1 +#define CONFIG_MACB_SEARCH_PHY +#define CONFIG_CMD_MII +#define CONFIG_OVERWRITE_ETHADDR_ONCE +/* MAC is Organizationally Unique Identifier + 3 octects user numbers */ +#define CONFIG_ETHADDR "02:00:00:fe:ed:00" /* USB */ #define CONFIG_USB_ATMEL