From patchwork Mon Aug 22 21:37:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Jarrige X-Patchwork-Id: 110996 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 14D80B6F72 for ; Tue, 23 Aug 2011 07:38:55 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B917828090; Mon, 22 Aug 2011 23:38:53 +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 yEuauWg8UlOE; Mon, 22 Aug 2011 23:38:53 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A9FFA2807D; Mon, 22 Aug 2011 23:38:51 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C65A52807D for ; Mon, 22 Aug 2011 23:38:47 +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 02gIUpXQ1EQP for ; Mon, 22 Aug 2011 23:38:45 +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 mo5.mail-out.ovh.net (10.mo5.mail-out.ovh.net [46.105.52.148]) by theia.denx.de (Postfix) with ESMTP id A34612807C for ; Mon, 22 Aug 2011 23:38:44 +0200 (CEST) Received: from mail183.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with SMTP id 72FBE10000E8 for ; Mon, 22 Aug 2011 23:31:20 +0200 (CEST) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 22 Aug 2011 23:30:52 +0200 Received: from 85-218-50-42.dclient.lsne.ch (HELO shuttle2.etheralp.ch) (85.218.50.42) by ns0.ovh.net with SMTP; 22 Aug 2011 23:30:51 +0200 Received: from localhost ([127.0.0.1] helo=shuttle2.etheralp.ch) by shuttle2.etheralp.ch with esmtp (Exim 4.72) (envelope-from ) id 1QvcBi-0007JK-M1; Mon, 22 Aug 2011 23:37:42 +0200 X-Ovh-Mailout: 178.32.228.5 (mo5.mail-out.ovh.net) To: u-boot@lists.denx.de From: Eric Jarrige Date: Mon, 22 Aug 2011 23:37:42 +0200 Message-ID: <20110822213742.28083.69514.stgit@shuttle2.etheralp.ch> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Ovh-Tracer-Id: 14594759017569992095 X-Ovh-Remote: 85.218.50.42 (85-218-50-42.dclient.lsne.ch) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfedvledrtdduucetggdotefuucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm Cc: dzu@lists.denx.de, Ben Warren Subject: [U-Boot] [PATCH] add dm9000 eeprom read/write command 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 Signed-off-by: Eric Jarrige Signed-off-by: Stefano Babic CC: Ben Warren --- README | 1 + common/Makefile | 1 + common/cmd_dm9000ee.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 0 deletions(-) create mode 100644 common/cmd_dm9000ee.c diff --git a/README b/README index 0886987..c6981bf 100644 --- a/README +++ b/README @@ -707,6 +707,7 @@ The following options need to be configured: CONFIG_CMD_DATE * support for RTC, date/time... CONFIG_CMD_DHCP * DHCP support CONFIG_CMD_DIAG * Diagnostics + CONFIG_CMD_DM9000EE DM9000 external EEPROM support CONFIG_CMD_DS4510 * ds4510 I2C gpio commands CONFIG_CMD_DS4510_INFO * ds4510 I2C info command CONFIG_CMD_DS4510_MEM * ds4510 I2C eeprom/sram commansd diff --git a/common/Makefile b/common/Makefile index d662468..d22cbac 100644 --- a/common/Makefile +++ b/common/Makefile @@ -81,6 +81,7 @@ ifdef CONFIG_POST COBJS-$(CONFIG_CMD_DIAG) += cmd_diag.o endif COBJS-$(CONFIG_CMD_DISPLAY) += cmd_display.o +COBJS-$(CONFIG_CMD_DM9000EE) += cmd_dm9000ee.o COBJS-$(CONFIG_CMD_DTT) += cmd_dtt.o COBJS-$(CONFIG_CMD_ECHO) += cmd_echo.o COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += cmd_eeprom.o diff --git a/common/cmd_dm9000ee.c b/common/cmd_dm9000ee.c new file mode 100644 index 0000000..0d53c70 --- /dev/null +++ b/common/cmd_dm9000ee.c @@ -0,0 +1,84 @@ +/* + * (C) Copyright 2008-2011 Armadeus Project + * (C) Copyright 2007 + * Stefano Babic, DENX Software Engineering, sbabic@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include +#include + +#if (!defined(CONFIG_DM9000_NO_SROM) && defined(CONFIG_DRIVER_DM9000)) + +static int do_read_dm9000_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[]) +{ + unsigned int i; + u8 data[2]; + + for (i = 0; i < 0x40; i++) { + if (!(i % 0x10)) + printf("\n%08x:", i); + dm9000_read_srom_word(i, data); + printf(" %02x%02x", data[1], data[0]); + } + printf("\n"); + return 0; +} + +static int do_write_dm9000_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[]) +{ + unsigned long offset, value; + + if (argc < 4) + return cmd_usage(cmdtp); + + strict_strtoul(argv[2], 16, &offset); + strict_strtoul(argv[3], 16, &value); + if (offset > 0x40) { + printf("Wrong offset : 0x%lx\n", offset); + return cmd_usage(cmdtp); + } + dm9000_write_srom_word(offset, value); + return 0; +} + +int do_dm9000_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + if (argc < 2) + return cmd_usage(cmdtp); + + if (strcmp(argv[1], "read") == 0) + return do_read_dm9000_eeprom(cmdtp, flag, argc, argv); + else if (strcmp(argv[1], "write") == 0) + return do_write_dm9000_eeprom(cmdtp, flag, argc, argv); + else + return cmd_usage(cmdtp); +} + +U_BOOT_CMD(dm9000ee, 4, 1, do_dm9000_eeprom, + "Read/Write eeprom connected to Ethernet Controller", + "\ndm9000ee write \n" + "\tdm9000ee read \n" + "\tword:\t\t00-02 : MAC Address\n" + "\t\t\t03-07 : DM9000 Configuration\n" "\t\t\t08-63 : User data"); +#endif /* !CONFIG_DM9000_NO_SROM && CONFIG_DRIVER_DM9000 */