[PATCH i-g-t 7/9] tools/intel_iosf_sb_*: Support reading/writing multiple registers at once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

Allow the user to specify a list of registers to read, and register/value
pairs to write.

Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
---
 tools/intel_iosf_sb_read.c  | 13 ++++++++-----
 tools/intel_iosf_sb_write.c | 20 ++++++++++----------
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/tools/intel_iosf_sb_read.c b/tools/intel_iosf_sb_read.c
index abe7fb5..48a22be 100644
--- a/tools/intel_iosf_sb_read.c
+++ b/tools/intel_iosf_sb_read.c
@@ -73,7 +73,7 @@ static void usage(const char *name)
 	int i;
 
 	printf("Warning : This program will work only on Valleyview/Cherryview\n"
-	       "Usage: %s [-h] [--] <port> <reg>\n"
+	       "Usage: %s [-h] [--] <port> <reg> [<reg> ...]\n"
 	       "\t -h : Show this help text\n"
 	       "\t <port> : ", name);
 	for (i = 0; i < ARRAY_SIZE(iosf_sb_ports); i++)
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
 	}
 
 	for (;;) {
-		int c = getopt(argc, argv, "h");
+		int c = getopt(argc, argv, "hc:");
 
 		if (c == -1)
 			break;
@@ -120,9 +120,12 @@ int main(int argc, char *argv[])
 
 	intel_register_access_init(dev, 0);
 
-	reg = strtoul(argv[i], NULL, 16);
-	val = intel_iosf_sb_read(port, reg);
-	printf("0x%02x(%s)/0x%04x : 0x%08x\n", port, name, reg, val);
+	for (; i < argc; i++) {
+		reg = strtoul(argv[i], NULL, 16);
+
+		val = intel_iosf_sb_read(port, reg);
+		printf("0x%02x(%s)/0x%04x : 0x%08x\n", port, name, reg, val);
+	}
 
 	intel_register_access_fini();
 
diff --git a/tools/intel_iosf_sb_write.c b/tools/intel_iosf_sb_write.c
index d0ba4d3..eb6700d 100644
--- a/tools/intel_iosf_sb_write.c
+++ b/tools/intel_iosf_sb_write.c
@@ -72,7 +72,7 @@ static void usage(const char *name)
 	int i;
 
 	printf("Warning : This program will work only on Valleyview/Cherryview\n"
-	       "Usage: %s [-h] [--] <port> <reg> <val>\n"
+	       "Usage: %s [-h] [--] <port> <reg> <val> [<reg> <val> ...]\n"
 	       "\t -h : Show this help text\n"
 	       "\t <port> : ", name);
 	for (i = 0; i < ARRAY_SIZE(iosf_sb_ports); i++)
@@ -118,18 +118,18 @@ int main(int argc, char** argv)
 	name = argv[i++];
 	port = iosf_sb_port_parse(name);
 
-	reg = strtoul(argv[i], NULL, 16);
-	val = strtoul(argv[i+1], NULL, 16);
-
 	intel_register_access_init(dev, 0);
 
-	tmp = intel_iosf_sb_read(port, reg);
-	printf("0x%02x(%s)/0x%04x before : 0x%08x\n", port, name, reg, tmp);
-
-	intel_iosf_sb_write(port, reg, val);
+	for (; i < argc; i += 2) {
+		reg = strtoul(argv[i], NULL, 16);
+		val = strtoul(argv[i+1], NULL, 16);
 
-	tmp = intel_iosf_sb_read(port, reg);
-	printf("0x%02x(%s)/0x%04x after  : 0x%08x\n", port, name, reg, tmp);
+		tmp = intel_iosf_sb_read(port, reg);
+		printf("0x%02x(%s)/0x%04x before : 0x%08x\n", port, name, reg, tmp);
+		intel_iosf_sb_write(port, reg, val);
+		tmp = intel_iosf_sb_read(port, reg);
+		printf("0x%02x(%s)/0x%04x after  : 0x%08x\n", port, name, reg, tmp);
+	}
 
 	intel_register_access_fini();
 
-- 
2.0.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux