From patchwork Thu Dec 6 00:46:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 204085 X-Patchwork-Delegate: trini@ti.com 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 A4E572C00EC for ; Thu, 6 Dec 2012 11:52:28 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 663544A1EF; Thu, 6 Dec 2012 01:52:05 +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 OaId1WffR7lw; Thu, 6 Dec 2012 01:52:05 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BC7E14A189; Thu, 6 Dec 2012 01:50:45 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4A8514A142 for ; Thu, 6 Dec 2012 01:50: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 b4qKyfEPzjlD for ; Thu, 6 Dec 2012 01:50:30 +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 mail-vb0-f74.google.com (mail-vb0-f74.google.com [209.85.212.74]) by theia.denx.de (Postfix) with ESMTPS id 53BA14A13D for ; Thu, 6 Dec 2012 01:50:17 +0100 (CET) Received: by mail-vb0-f74.google.com with SMTP id s24so640598vbi.3 for ; Wed, 05 Dec 2012 16:50:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=WUCZqFmeNmmTMYugT77iSxxpBS0Eyw8Y5L4tr6hM6Z4=; b=WcqeqJoo9Cs3mq+nUXCsCk+WbXbL1a7HTYE8eQYDZWSYjE0wuy4eARO2fh3T/gXeXV wiIezZujHaO+OCNHKf9Fp0nCbER0ujRDEhUMzvw63698juiDXCF1voxXi5xqwxlmyY5Z g49iloabg2zqGIaS2E+AxEimOwVDjYLkF6ETJW5Tccdp5SFw6rHytng3E25DNiuxA/Ij 5zk7P3ycqztk2X4EL4u0x3B6W2uiFN3ddAWXwRk0jHqgCFXCOfVhkwiQ1mv+acztNmAC yTzV/KfcVpzUVyaIcv2wrlGitZrTCZolg2srIrBhZpUUwZIeMOXDnM2/wJqa4f+jo8lP +4vw== Received: by 10.236.81.107 with SMTP id l71mr12424437yhe.18.1354755015915; Wed, 05 Dec 2012 16:50:15 -0800 (PST) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id r6si522459yhc.7.2012.12.05.16.50.15 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 05 Dec 2012 16:50:15 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by wpzn3.hot.corp.google.com (Postfix) with ESMTP id A09E5100047; Wed, 5 Dec 2012 16:50:15 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 82012160A46; Wed, 5 Dec 2012 16:50:15 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Wed, 5 Dec 2012 16:46:42 -0800 Message-Id: <1354754807-21449-16-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1354754807-21449-1-git-send-email-sjg@chromium.org> References: <1354754807-21449-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQnhsKPzuUpll8gOOKVylfUW8nXIZAd2gnU0Sa71Ef8sgUWeRycy9C89H98JkVYZgN/AWSK5NGeVm0J0aZBflRYrf0fEEuqYy8rvoKrzw/GLv1tmqqFPETqozLFc2zep9fKq0ShOhWPKkxhc/y5q+JL9baMKurF7Gve0ERunMImXnEPTgPM8KcmTpzvVYBiGEkzb0EUE Cc: Tom Rini , Vadim Bendebury Subject: [U-Boot] [PATCH v3 15/20] Add console command to access io space registers 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 From: Vadim Bendebury Provide u-boot console functions to access IO space registers. A no thrills implementation, accessing one register at a time. For example: boot > iod 80 0080: 00000094 boot > iod.w 80 0080: 0094 boot > iod.b 80 0080: 94 boot > iow.b 0x80 12 boot > iod 0x80 0080: 00000012 Signed-off-by: Vadim Bendebury Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/Makefile | 1 + common/cmd_io.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++ include/command.h | 8 ++-- include/config_cmd_all.h | 1 + 4 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 common/cmd_io.c diff --git a/common/Makefile b/common/Makefile index dcab027..1c5d623 100644 --- a/common/Makefile +++ b/common/Makefile @@ -120,6 +120,7 @@ COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o COBJS-$(CONFIG_ID_EEPROM) += cmd_mac.o COBJS-$(CONFIG_CMD_MD5SUM) += cmd_md5sum.o COBJS-$(CONFIG_CMD_MEMORY) += cmd_mem.o +COBJS-$(CONFIG_CMD_IO) += cmd_io.o COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o COBJS-$(CONFIG_MII) += miiphyutil.o COBJS-$(CONFIG_CMD_MII) += miiphyutil.o diff --git a/common/cmd_io.c b/common/cmd_io.c new file mode 100644 index 0000000..6450cb5 --- /dev/null +++ b/common/cmd_io.c @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2012 The Chromium OS Authors. + * + * 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 + */ + +/* + * IO space access commands. + */ + +#include +#include +#include + +/* + * IO Display + * + * Syntax: + * iod{.b, .w, .l} {addr} + */ +int do_io_iod(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + ulong addr; + int size; + + if (argc != 2) + return CMD_RET_USAGE; + + size = cmd_get_data_size(argv[0], 4); + if (size < 0) + return 1; + + addr = simple_strtoul(argv[1], NULL, 16); + + printf("%04x: ", (u16) addr); + + if (size == 4) + printf("%08x\n", inl(addr)); + else if (size == 2) + printf("%04x\n", inw(addr)); + else + printf("%02x\n", inb(addr)); + + return 0; +} + +int do_io_iow(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + ulong addr, size, val; + + if (argc != 3) + return CMD_RET_USAGE; + + size = cmd_get_data_size(argv[0], 4); + if (size < 0) + return 1; + + addr = simple_strtoul(argv[1], NULL, 16); + val = simple_strtoul(argv[2], NULL, 16); + + if (size == 4) + outl((u32) val, addr); + else if (size == 2) + outw((u16) val, addr); + else + outb((u8) val, addr); + + return 0; +} + +/**************************************************/ +U_BOOT_CMD(iod, 2, 0, do_io_iod, + "IO space display", "[.b, .w, .l] address [# of objects]"); + +U_BOOT_CMD(iow, 3, 0, do_io_iow, + "IO space modify (auto-incrementing address)", + "[.b, .w, .l] address"); diff --git a/include/command.h b/include/command.h index 10bc260..476e7cf 100644 --- a/include/command.h +++ b/include/command.h @@ -89,10 +89,10 @@ extern int cmd_auto_complete(const char *const prompt, char *buf, int *np, int * */ #if defined(CONFIG_CMD_MEMORY) \ - || defined(CONFIG_CMD_I2C) \ - || defined(CONFIG_CMD_ITEST) \ - || defined(CONFIG_CMD_PCI) \ - || defined(CONFIG_CMD_PORTIO) + || defined(CONFIG_CMD_I2C) \ + || defined(CONFIG_CMD_ITEST) \ + || defined(CONFIG_CMD_PCI) \ + || defined(CONFIG_CMD_PORTIO) #define CMD_DATA_SIZE extern int cmd_get_data_size(char* arg, int default_size); #endif diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index 124d51f..e82f642 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -48,6 +48,7 @@ #define CONFIG_CMD_IMI /* iminfo */ #define CONFIG_CMD_IMLS /* List all found images */ #define CONFIG_CMD_IMMAP /* IMMR dump support */ +#define CONFIG_CMD_IO /* Access to X86 IO space */ #define CONFIG_CMD_IRQ /* irqinfo */ #define CONFIG_CMD_ITEST /* Integer (and string) test */ #define CONFIG_CMD_JFFS2 /* JFFS2 Support */