public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] gpio: Expand cmd_gpio functionality and script friendliness
@ 2011-08-10  6:27 Joe Hershberger
  2011-08-11  1:33 ` Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Hershberger @ 2011-08-10  6:27 UTC (permalink / raw)
  To: u-boot

Add quiet parameter to cmd_gpio for use when part of a script
Enable repeat... especially useful when used with input and toggle
Add "outstate" command that will return and print the state of an output

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Cc: Joe Hershberger <joe.hershberger@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
 common/cmd_gpio.c |   39 ++++++++++++++++++++++++---------------
 1 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/common/cmd_gpio.c b/common/cmd_gpio.c
index 9cc790a..0acb93e 100644
--- a/common/cmd_gpio.c
+++ b/common/cmd_gpio.c
@@ -20,6 +20,7 @@ enum gpio_cmd {
 	GPIO_SET,
 	GPIO_CLEAR,
 	GPIO_TOGGLE,
+	GPIO_OUTSTATE,
 };
 
 static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
@@ -27,7 +28,7 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	int gpio;
 	enum gpio_cmd sub_cmd;
 	ulong value;
-	const char *str_cmd, *str_gpio;
+	const char *str_cmd, *str_gpio, *str_quiet = "0";
 
 #ifdef gpio_status
 	if (argc == 2 && !strcmp(argv[1], "status")) {
@@ -36,18 +37,22 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 #endif
 
-	if (argc != 3)
+	if (argc != 3 && argc != 4)
  show_usage:
 		return cmd_usage(cmdtp);
+
 	str_cmd = argv[1];
 	str_gpio = argv[2];
+	if (argc == 4)
+		str_quiet = argv[3];
 
 	/* parse the behavior */
 	switch (*str_cmd) {
-		case 'i': sub_cmd = GPIO_INPUT;  break;
-		case 's': sub_cmd = GPIO_SET;    break;
-		case 'c': sub_cmd = GPIO_CLEAR;  break;
-		case 't': sub_cmd = GPIO_TOGGLE; break;
+		case 'i': sub_cmd = GPIO_INPUT;    break;
+		case 's': sub_cmd = GPIO_SET;      break;
+		case 'c': sub_cmd = GPIO_CLEAR;    break;
+		case 't': sub_cmd = GPIO_TOGGLE;   break;
+		case 'o': sub_cmd = GPIO_OUTSTATE; break;
 		default:  goto show_usage;
 	}
 
@@ -68,22 +73,26 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		value = gpio_get_value(gpio);
 	} else {
 		switch (sub_cmd) {
-			case GPIO_SET:    value = 1; break;
-			case GPIO_CLEAR:  value = 0; break;
-			case GPIO_TOGGLE: value = !gpio_get_value(gpio); break;
+			case GPIO_SET:      value = 1; break;
+			case GPIO_CLEAR:    value = 0; break;
+			case GPIO_TOGGLE:   value = !gpio_get_value(gpio); break;
+			case GPIO_OUTSTATE: value = gpio_get_value(gpio); break;
 			default:          goto show_usage;
 		}
 		gpio_direction_output(gpio, value);
 	}
-	printf("gpio: pin %s (gpio %i) value is %lu\n",
-		str_gpio, gpio, value);
+
+	if (*str_quiet == '0')
+		printf("gpio: pin %s (gpio %i) value is %lu\n",
+			str_gpio, gpio, value);
 
 	gpio_free(gpio);
 
 	return value;
 }
 
-U_BOOT_CMD(gpio, 3, 0, do_gpio,
-	"input/set/clear/toggle gpio pins",
-	"<input|set|clear|toggle> <pin>\n"
-	"    - input/set/clear/toggle the specified pin");
+U_BOOT_CMD(gpio, 4, 1, do_gpio,
+	"input/set/clear/toggle/outstate gpio pins",
+	"<input|set|clear|toggle|outstate> <pin> [quiet]\n"
+	"    - input/set/clear/toggle/outstate the specified pin\n"
+	"    - quiet: if 1, do not print");
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] gpio: Expand cmd_gpio functionality and script friendliness
  2011-08-10  6:27 [U-Boot] [PATCH] gpio: Expand cmd_gpio functionality and script friendliness Joe Hershberger
@ 2011-08-11  1:33 ` Mike Frysinger
  2011-08-11  2:07   ` Joe Hershberger
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2011-08-11  1:33 UTC (permalink / raw)
  To: u-boot

On Wednesday, August 10, 2011 02:27:42 Joe Hershberger wrote:
> Add quiet parameter to cmd_gpio for use when part of a script
> Enable repeat... especially useful when used with input and toggle
> Add "outstate" command that will return and print the state of an output

a similar patch was posted somewhat recently but was declined.  please see the 
archive for more info.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110810/8285a5cf/attachment.pgp 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] gpio: Expand cmd_gpio functionality and script friendliness
  2011-08-11  1:33 ` Mike Frysinger
@ 2011-08-11  2:07   ` Joe Hershberger
  2011-08-11  3:44     ` Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Hershberger @ 2011-08-11  2:07 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Wed, Aug 10, 2011 at 8:33 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Wednesday, August 10, 2011 02:27:42 Joe Hershberger wrote:
>> Add quiet parameter to cmd_gpio for use when part of a script
>> Enable repeat... especially useful when used with input and toggle
>> Add "outstate" command that will return and print the state of an output
>
> a similar patch was posted somewhat recently but was declined. ?please see the
> archive for more info.

I attempted to locate what you are referring to, but had no luck.  I
saw nothing that referenced "cmd_gpio" that was similar.  Any clues
about what aspects were rejected so I'll have a better idea what to
search for?  Possibly who rejected it?

Thanks,
-Joe

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] gpio: Expand cmd_gpio functionality and script friendliness
  2011-08-11  2:07   ` Joe Hershberger
@ 2011-08-11  3:44     ` Mike Frysinger
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2011-08-11  3:44 UTC (permalink / raw)
  To: u-boot

On Wednesday, August 10, 2011 22:07:28 Joe Hershberger wrote:
> On Wed, Aug 10, 2011 at 8:33 PM, Mike Frysinger wrote:
> > On Wednesday, August 10, 2011 02:27:42 Joe Hershberger wrote:
> >> Add quiet parameter to cmd_gpio for use when part of a script
> >> Enable repeat... especially useful when used with input and toggle
> >> Add "outstate" command that will return and print the state of an output
> > 
> > a similar patch was posted somewhat recently but was declined.  please
> > see the archive for more info.
> 
> I attempted to locate what you are referring to, but had no luck.  I
> saw nothing that referenced "cmd_gpio" that was similar.  Any clues
> about what aspects were rejected so I'll have a better idea what to
> search for?  Possibly who rejected it?

[U-Boot] [RFC] gpio command: return value on write, additional actions
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110810/329651bb/attachment.pgp 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-11  3:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-10  6:27 [U-Boot] [PATCH] gpio: Expand cmd_gpio functionality and script friendliness Joe Hershberger
2011-08-11  1:33 ` Mike Frysinger
2011-08-11  2:07   ` Joe Hershberger
2011-08-11  3:44     ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox