From patchwork Thu Jun 30 14:02:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 102763 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 8722BB6F53 for ; Fri, 1 Jul 2011 00:03:03 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 07AAF281A9; Thu, 30 Jun 2011 16:03:02 +0200 (CEST) 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 5xTdl3XD57gk; Thu, 30 Jun 2011 16:03:01 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 69ABF281AA; Thu, 30 Jun 2011 16:03:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4023B281AA for ; Thu, 30 Jun 2011 16:02:59 +0200 (CEST) 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 6DUn4xsE5wiu for ; Thu, 30 Jun 2011 16:02:57 +0200 (CEST) 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 com-exc-01.comelit.it (mail.comelit.it [217.56.59.218]) by theia.denx.de (Postfix) with ESMTP id 29859281A9 for ; Thu, 30 Jun 2011 16:02:55 +0200 (CEST) Received: from mail pickup service by com-exc-01.comelit.it with Microsoft SMTPSVC; Thu, 30 Jun 2011 16:02:53 +0200 Received: from wallace.comelit.it ([172.20.0.21]) by com-exc-01.comelit.it with Microsoft SMTPSVC(6.0.3790.4675); Thu, 30 Jun 2011 16:02:52 +0200 From: Luca Ceresoli To: helmut.raiger@hale.at Date: Thu, 30 Jun 2011 16:02:41 +0200 PrevMsgId: <1309442561-9213-1-git-send-email-luca.ceresoli@comelit.it> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <4E0C80AF.7040707@comelit.it> References: <4E0C80AF.7040707@comelit.it> X-OriginalArrivalTime: 30 Jun 2011 14:02:52.0802 (UTC) FILETIME=[674CEE20:01CC372E] X-TM-AS-Product-Ver: SMEX-8.6.0.1168-6.500.1024-18230.005 X-TM-AS-Result: No--13.072600-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-1C0F171DCB26A292946DE3540F3F7688: Internal Message-ID: Cc: u-boot@lists.denx.de, Luca Ceresoli Subject: [U-Boot] [PATCH RFC] smc911x: enable mii commands 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 Signed-off-by: Luca Ceresoli --- This patch is my implementation of the same functionality that Helmut's patch implements. I'm sending it as a reference for him to look at the error checking code and possibly merge it into his own patch. drivers/net/smc911x.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-) diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index aeafeba..d946fd4 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -82,6 +82,42 @@ static int smc911x_miiphy_write(struct eth_device *dev, return 0; } +static int smc911x_miiphy_read_byname(char *devname, unsigned char addr, + unsigned char reg, unsigned short *value) +{ + struct eth_device *dev; + + if (devname == NULL) + return -1; + + dev = eth_get_dev_by_name(devname); + + if (dev == NULL) { + printf(DRIVERNAME ": device %s not found\n", devname); + return -1; + } + + return smc911x_miiphy_read(dev, addr, reg, value); +} + +static int smc911x_miiphy_write_byname(char *devname, unsigned char addr, + unsigned char reg, unsigned short value) +{ + struct eth_device *dev; + + if (devname == NULL) + return -1; + + dev = eth_get_dev_by_name(devname); + + if (dev == NULL) { + printf(DRIVERNAME ": device %s not found\n", devname); + return -1; + } + + return smc911x_miiphy_write(dev, addr, reg, value); +} + static int smc911x_phy_reset(struct eth_device *dev) { u32 reg; @@ -273,5 +309,10 @@ int smc911x_initialize(u8 dev_num, int base_addr) sprintf(dev->name, "%s-%hu", DRIVERNAME, dev_num); eth_register(dev); + +#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) + miiphy_register(dev->name, smc911x_miiphy_read_byname, smc911x_miiphy_write_byname); +#endif + return 1; }