From patchwork Thu Jan 26 22:21:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 138089 X-Patchwork-Delegate: sbabic@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 9B96A1007D5 for ; Fri, 27 Jan 2012 11:22:58 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3C3012808A; Fri, 27 Jan 2012 01:22:56 +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 2YnE7leRER1Q; Fri, 27 Jan 2012 01:22:55 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AFB8C28088; Fri, 27 Jan 2012 01:22:53 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D2D2E2808A for ; Thu, 26 Jan 2012 23:28:31 +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 Dl6d48IOf7Nv for ; Thu, 26 Jan 2012 23:28:30 +0100 (CET) X-Greylist: delayed 400 seconds by postgrey-1.27 at theia; Thu, 26 Jan 2012 23:28:29 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 oproxy4-pub.bluehost.com (oproxy4-pub.bluehost.com [69.89.21.11]) by theia.denx.de (Postfix) with SMTP id 6662828088 for ; Thu, 26 Jan 2012 23:28:29 +0100 (CET) Received: (qmail 13102 invoked by uid 0); 26 Jan 2012 22:21:48 -0000 Received: from unknown (HELO box284.bluehost.com) (69.89.31.84) by cpoproxy1.bluehost.com with SMTP; 26 Jan 2012 22:21:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=boundarydevices.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=B8g8C0US4MHXl6n/YwGnVcpjNPojJy++hO2SlF1hUxY=; b=dGxvtc3g1z6TGlww3ykmP6mq8jMPvbalzSKqhPCVSOpi3AJ9QcY2DkfhDlraeWnb87Sn863D8P1MX0S5zW/sboJm17F6mw0oo2WNigny1231OEzq3J2CCvet1fSjTm1z; Received: from [70.96.116.236] (helo=officeserver-2) by box284.bluehost.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1RqXhT-0002zi-3t; Thu, 26 Jan 2012 15:21:47 -0700 Received: from tkisky by officeserver-2 with local (Exim 4.76) (envelope-from ) id 1RqXhf-00032q-Lb; Thu, 26 Jan 2012 15:21:59 -0700 From: Troy Kisky To: dirk.behme@googlemail.com Date: Thu, 26 Jan 2012 15:21:43 -0700 Message-Id: <1327616505-11669-2-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1327616505-11669-1-git-send-email-troy.kisky@boundarydevices.com> References: <1327616505-11669-1-git-send-email-troy.kisky@boundarydevices.com> X-Identified-User: {1412:box284.bluehost.com:boundar4:boundarydevices.com} {sentby:smtp auth 70.96.116.236 authed with troy.kisky@boundarydevices.com} X-Mailman-Approved-At: Fri, 27 Jan 2012 01:22:52 +0100 Cc: u-boot@lists.denx.de, jason.hui@linaro.org, r49496@freescale.com Subject: [U-Boot] [PATCH 2/4] net: fec_mxc: add PHYLIB support 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Troy Kisky --- drivers/net/fec_mxc.c | 35 ++++++++++++++++++++++++++++++----- drivers/net/fec_mxc.h | 1 + 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 3fffe79..4d7a38d 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -371,6 +371,20 @@ static int fec_set_hwaddr(struct eth_device *dev) return 0; } +static void fec_eth_phy_config(struct eth_device *dev) +{ +#ifdef CONFIG_PHYLIB + struct fec_priv *fec = (struct fec_priv *)dev->priv; + struct phy_device *phydev; + + phydev = phy_connect(miiphy_get_dev_by_name(dev->name), + fec->phy_id, dev, PHY_INTERFACE_MODE_RGMII); + fec->phydev = phydev; + if (phydev) + phy_config(phydev); +#endif +} + /** * Start the FEC engine * @param[in] dev Our device to handle @@ -427,9 +441,19 @@ static int fec_open(struct eth_device *edev) } #endif - miiphy_wait_aneg(edev); - speed = miiphy_speed(edev->name, fec->phy_id); - miiphy_duplex(edev->name, fec->phy_id); + if (fec->phydev) { + /* Start up the PHY */ +#ifdef CONFIG_PHYLIB + phy_startup(fec->phydev); +#endif + speed = fec->phydev->speed; + } else { + miiphy_wait_aneg(edev); + speed = miiphy_speed(edev->name, fec->phy_id); + miiphy_duplex(edev->name, fec->phy_id); + } + + #ifdef CONFIG_MX6Q { u32 ecr = readl(&fec->eth->ecntrl) & ~FEC_ECNTRL_SPEED; @@ -556,7 +580,7 @@ static int fec_init(struct eth_device *dev, bd_t* bd) fec_tbd_init(fec); - if (fec->xcv_type != SEVENWIRE) + if (!fec->phydev && fec->xcv_type != SEVENWIRE) miiphy_restart_aneg(dev); fec_open(dev); @@ -842,7 +866,8 @@ static int fec_probe(bd_t *bd, int dev_id, int phy_id, uint32_t base_addr) debug("got MAC address from fuse: %pM\n", ethaddr); memcpy(edev->enetaddr, ethaddr, 6); } - + /* Configure phy */ + fec_eth_phy_config(edev); return ret; err3: diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h index 1d6ab06..36125b5 100644 --- a/drivers/net/fec_mxc.h +++ b/drivers/net/fec_mxc.h @@ -286,6 +286,7 @@ struct fec_priv { void *base_ptr; int dev_id; int phy_id; + struct phy_device *phydev; int (*mii_postcall)(int); };