From patchwork Thu Nov 4 10:15:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bernstein, Michael" X-Patchwork-Id: 71990 Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id 35B0B12A81E3 for ; Thu, 4 Nov 2010 11:17:37 +0100 (CET) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id 139103335217 for ; Thu, 4 Nov 2010 11:17:37 +0100 (CET) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.17) for (single-drop); Thu, 04 Nov 2010 11:17:37 +0100 (CET) Received: from murder ([192.168.8.180]) by backend2 (Cyrus v2.2.12) with LMTPA; Thu, 04 Nov 2010 11:15:33 +0100 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend1.mail.m-online.net (Cyrus v2.2.12) with LMTPA; Thu, 04 Nov 2010 11:15:32 +0100 Received: from scanner-3.m-online.net (unknown [192.168.6.168]) by mail.m-online.net (Postfix) with ESMTP id A929B1C0020A; Thu, 4 Nov 2010 11:15:32 +0100 (CET) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-3.m-online.net (Postfix) with ESMTP id 8650847A4FF; Thu, 4 Nov 2010 11:15:30 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 840D1280B3; Thu, 4 Nov 2010 11:15:28 +0100 (CET) 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 StPrIyvqMj8A; Thu, 4 Nov 2010 11:15:28 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E9DA2280B8; Thu, 4 Nov 2010 11:15:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0D698280B1 for ; Thu, 4 Nov 2010 11:15:19 +0100 (CET) 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 8A7IX5TMk+GR for ; Thu, 4 Nov 2010 11:15:17 +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 cwaremx01.controlware.de (cwaremx01.controlware.de [193.22.120.74]) by theia.denx.de (Postfix) with ESMTPS id 081DA280AB for ; Thu, 4 Nov 2010 11:15:15 +0100 (CET) Received: from cwaremx01.controlware.de (localhost.localdomain [127.0.0.1]) by localhost (Email Security Appliance) with SMTP id 55306101E47C_CD283C2B for ; Thu, 4 Nov 2010 09:58:26 +0000 (GMT) Received: from ntexfe1.controlware.de (unknown [172.16.60.160]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "owa.controlware.de", Issuer "ntsubca" (not verified)) by cwaremx01.controlware.de (Sophos Email Appliance) with ESMTP id DFE55102D5FE_CD283BFF for ; Thu, 4 Nov 2010 09:58:23 +0000 (GMT) Received: from NTEXCCR.controlware.de ([172.16.60.171]) by ntexfe1.controlware.de ([172.16.60.160]) with mapi; Thu, 4 Nov 2010 11:15:11 +0100 From: "Bernstein, Michael" To: "U-Boot Mailingliste (u-boot@lists.denx.de)" Date: Thu, 4 Nov 2010 11:15:09 +0100 Thread-Topic: [PATCH 2/2] use MAC from environment and add support for new NET_MULTI api in ethernet driver of KS8695 Thread-Index: Act8CSk8/avc8exwRzeWV0x3ul9B5w== Message-ID: Accept-Language: de-DE Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: de-DE MIME-Version: 1.0 Subject: [U-Boot] [PATCH 2/2] use MAC from environment and add support for new NET_MULTI api in ethernet driver of KS8695 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Virus-Scanned: by amavisd-new at m-online.net Hello, Add support for the new NET MULTI api in the ethernet driver of the KS8695. Signed-off-by: Michael Bernstein --- -- diff --unified --recursive --new-file u-boot-2009.11/drivers/net/ks8695eth.c u-boot-2009.11.new/drivers/net/ks8695eth.c --- u-boot-2009.11/drivers/net/ks8695eth.c 2010-02-09 16:16:18.000000000 +0100 +++ u-boot-2009.11.new/drivers/net/ks8695eth.c 2010-03-01 15:36:56.000000000 +0100 @@ -29,6 +29,26 @@ /****************************************************************************/ /* + * some defines to allow switching between NET_MULTI and old API + */ +#if defined(CONFIG_NET_MULTI) +#define KS8695_ETH_RESET ks8695_eth_reset +#define KS8695_ETH_HALT ks8695_eth_halt +#define KS8695_ETH_INIT ks8695_eth_init +#define KS8695_ETH_RX ks8695_eth_rx +#define KS8695_ETH_SEND ks8695_eth_send +#define KS8695_DRIVERNAME "KS8695" +#else +#define KS8695_ETH_RESET eth_reset +#define KS8695_ETH_HALT eth_halt +#define KS8695_ETH_INIT eth_init +#define KS8695_ETH_RX eth_rx +#define KS8695_ETH_SEND eth_send +#endif + +/****************************************************************************/ + +/* * Hardware register access to the KS8695 LAN ethernet port * (well, it is the 4 port switch really). */ @@ -103,7 +123,7 @@ /****************************************************************************/ -void eth_reset(bd_t *bd) +void KS8695_ETH_RESET(bd_t *bd) { int i; @@ -159,28 +179,28 @@ /****************************************************************************/ -int eth_init(bd_t *bd) +int KS8695_ETH_INIT(bd_t *bd) { debug ("%s(%d): eth_init()\n", __FILE__, __LINE__); - eth_reset(bd); + KS8695_ETH_RESET(bd); return 0; } /****************************************************************************/ -void eth_halt(void) +void KS8695_ETH_HALT(void) { debug ("%s(%d): eth_halt()\n", __FILE__, __LINE__); /* Reset the ethernet engines */ - ks8695_write(KS8695_LAN_DMA_TX, 0x80000000); - ks8695_write(KS8695_LAN_DMA_RX, 0x80000000); +/* ks8695_write(KS8695_LAN_DMA_TX, 0x80000000); */ +/* ks8695_write(KS8695_LAN_DMA_RX, 0x80000000); */ } /****************************************************************************/ -int eth_rx(void) +int KS8695_ETH_RX(void) { volatile struct ks8695_rxdesc *dp; int i, len = 0; @@ -203,7 +223,7 @@ /****************************************************************************/ -int eth_send(volatile void *packet, int len) +int KS8695_ETH_SEND(volatile void *packet, int len) { volatile struct ks8695_txdesc *dp; static int next = 0; @@ -230,3 +250,72 @@ return len; } + +/****************************************************************************/ + +#ifdef CONFIG_NET_MULTI + +static void ks8695_halt(struct eth_device *dev) +{ + KS8695_ETH_HALT(); +} + +static int ks8695_init(struct eth_device *dev, bd_t * bd) +{ + return KS8695_ETH_INIT(bd); +} + +static int ks8695_recv(struct eth_device *dev) +{ + int i; + + i = KS8695_ETH_RX(); + return i; +} + +static int ks8695_send(struct eth_device *dev, volatile void *packet, int length) +{ + KS8695_ETH_SEND(packet, length); + return 0; +} + +static void ks8695_get_enetaddr(struct eth_device *dev) +{ + int i; + + ks8695_getmac(); /* load MAC to eth_mac */ + for (i = 0; i < 6; i++) { + dev->enetaddr[i] = eth_mac[i]; + } +} + +int ks8695_initialize(void) +{ + struct eth_device *dev; + + dev = malloc(sizeof(*dev)); + if (!dev) { + free(dev); + return 0; + } + else { + memset(dev, 0, sizeof(*dev)); + + dev->iobase = KS8695_IO_BASE; + dev->priv = NULL; + dev->init = ks8695_init; + dev->halt = ks8695_halt; + dev->send = ks8695_send; + dev->recv = ks8695_recv; + + /* Load MAC address from EEPROM */ + ks8695_get_enetaddr(dev); + + sprintf(dev->name, "%s", KS8695_DRIVERNAME); + + eth_register(dev); + return 0; + } +} + +#endif