[U-Boot-Users] [PATCH 3/3] QE IO - Add pario command

David Saada David.Saada at ecitele.com
Mon Mar 31 14:28:32 CEST 2008


This patch fragment includes commands for reading and writing parallel
I/O ports (pario command). 

Signed-off-by: David Saada <david.saada at ecitele.com>

common/cmd_pario.c |   85
+++++++++++++++++++++++++++++++++++++++++++++++++++
common/Makefile      |    1 
2 files changed, 86 insertions(+)
create mode 100644 common/cmd_pario.c

--- a/common/Makefile	2008-03-28 01:49:12.000000000 +0200
+++ b/common/Makefile	2008-03-30 15:59:57.944754000 +0300
@@ -81,6 +81,7 @@ COBJS-$(CONFIG_CMD_NET) += cmd_net.o
 COBJS-y += cmd_nvedit.o
 COBJS-y += cmd_onenand.o
 COBJS-$(CONFIG_CMD_OTP) += cmd_otp.o
+COBJS-$(CONFIG_CMD_PARIO) += cmd_pario.o
 ifdef CONFIG_PCI
 COBJS-$(CONFIG_CMD_PCI) += cmd_pci.o
 endif
0a1,85
--- /dev/null	2008-03-30 10:13:32.378222985 +0300
+++ b/common/cmd_pario.c	2008-03-30 16:00:43.124433000 +0300
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2008 ECI Telecommunication.
+ *
+ * (C) Copyright 2008 David Saada <david.saada at ecitele.com>
+ *
+ * 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 <common.h>
+#include <command.h>
+#include <ioports.h>
+
+int do_pario (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	char op;
+	int	port, pin, data;
+	static char	last_op;
+	static int last_port, last_pin, last_data;
+
+	/*
+	 * We use the last specified parameters, unless new ones are
+	 * entered.
+	 */
+	op = last_op;
+	port = last_port;
+	pin = last_pin;
+	data = last_data;
+
+	if ((flag & CMD_FLAG_REPEAT) == 0) {
+		op = argv[1][0];
+
+		if (argc >= 3)
+			port = simple_strtoul (argv[2], NULL, 10);
+		if (argc >= 4)
+			pin = simple_strtoul (argv[3], NULL, 10);
+		if (argc >= 5)
+			data = simple_strtoul (argv[4], NULL, 10);
+	}
+
+	if (op == 'r') {
+		qe_read_iopin(port ,pin ,&data);
+		printf("%d\n", data);
+	} else if (op == 'w') {
+		qe_write_iopin(port ,pin ,data);
+	} else {
+		printf("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+
+	/*
+	 * Save the parameters for repeats.
+	 */
+	last_op = op;
+	last_port = port;
+	last_pin = pin;
+	last_data = data;
+
+	return 0;
+}
+
+/***************************************************/
+
+U_BOOT_CMD(
+	pario,	5,	1,	do_pario,
+	"pario     - Parallel I/O utility commands\n",
+	"read   <port> <pin>        - read from port <port> pin <pin>\n"
+	"pario write  <port> <pin> <data> - write to port  <port> pin
<pin>\n"
+);
+




More information about the U-Boot mailing list