All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 1/9] lib: Change IOSF SB devfn to 0.0
@ 2015-03-23 13:14 ville.syrjala
  2015-03-23 13:14 ` [PATCH i-g-t 2/9] lib: Allow 32bit addresses for IOSF-SB registers ville.syrjala
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ville.syrjala @ 2015-03-23 13:14 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

The devfn field in the IOSF SB messages is only relevant when there's a
real PCI bus or some other multifunction device behind a single port.
Otherwise the port number itself is enough to uniquely identify the
target. In fact some IOSF SB targets reject the access when devfn is not
0.0 (eg. GPIO_NC on BYT).

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/intel_iosf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/intel_iosf.c b/lib/intel_iosf.c
index 27134a0..01577cd 100644
--- a/lib/intel_iosf.c
+++ b/lib/intel_iosf.c
@@ -28,7 +28,7 @@ static int vlv_sideband_rw(uint32_t port, uint8_t opcode, uint32_t addr,
 
 	bar = 0;
 	be = 0xf;
-	devfn = 16;
+	devfn = 0;
 
 	cmd = (devfn << IOSF_DEVFN_SHIFT) | (opcode << IOSF_OPCODE_SHIFT) |
 		(port << IOSF_PORT_SHIFT) | (be << IOSF_BYTE_ENABLES_SHIFT) |
-- 
2.0.5

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

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

* [PATCH i-g-t 2/9] lib: Allow 32bit addresses for IOSF-SB registers
  2015-03-23 13:14 [PATCH i-g-t 1/9] lib: Change IOSF SB devfn to 0.0 ville.syrjala
@ 2015-03-23 13:14 ` ville.syrjala
  2015-03-23 13:14 ` [PATCH i-g-t 3/9] toos/intel_iosf_sb_*: Fix DPIO IOSF SB port number ville.syrjala
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ville.syrjala @ 2015-03-23 13:14 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/intel_io.h   | 8 ++++----
 lib/intel_iosf.c | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/intel_io.h b/lib/intel_io.h
index 8293353..04aa3fd 100644
--- a/lib/intel_io.h
+++ b/lib/intel_io.h
@@ -53,10 +53,10 @@ void intel_flisdsi_reg_write(uint32_t reg, uint32_t val);
 uint32_t intel_iosf_sb_read(uint32_t port, uint32_t reg);
 void intel_iosf_sb_write(uint32_t port, uint32_t reg, uint32_t val);
 
-int intel_punit_read(uint8_t addr, uint32_t *val);
-int intel_punit_write(uint8_t addr, uint32_t val);
-int intel_nc_read(uint8_t addr, uint32_t *val);
-int intel_nc_write(uint8_t addr, uint32_t val);
+int intel_punit_read(uint32_t addr, uint32_t *val);
+int intel_punit_write(uint32_t addr, uint32_t val);
+int intel_nc_read(uint32_t addr, uint32_t *val);
+int intel_nc_write(uint32_t addr, uint32_t val);
 
 /* register maps from intel_reg_map.c */
 #ifndef __GTK_DOC_IGNORE__
diff --git a/lib/intel_iosf.c b/lib/intel_iosf.c
index 01577cd..df1cdc0 100644
--- a/lib/intel_iosf.c
+++ b/lib/intel_iosf.c
@@ -73,7 +73,7 @@ static int vlv_sideband_rw(uint32_t port, uint8_t opcode, uint32_t addr,
  * Returns:
  * 0 when the register access succeeded, negative errno code on failure.
  */
-int intel_punit_read(uint8_t addr, uint32_t *val)
+int intel_punit_read(uint32_t addr, uint32_t *val)
 {
 	return vlv_sideband_rw(IOSF_PORT_PUNIT, SB_CRRDDA_NP, addr, val);
 }
@@ -88,7 +88,7 @@ int intel_punit_read(uint8_t addr, uint32_t *val)
  * Returns:
  * 0 when the register access succeeded, negative errno code on failure.
  */
-int intel_punit_write(uint8_t addr, uint32_t val)
+int intel_punit_write(uint32_t addr, uint32_t val)
 {
 	return vlv_sideband_rw(IOSF_PORT_PUNIT, SB_CRWRDA_NP, addr, &val);
 }
@@ -103,7 +103,7 @@ int intel_punit_write(uint8_t addr, uint32_t val)
  * Returns:
  * 0 when the register access succeeded, negative errno code on failure.
  */
-int intel_nc_read(uint8_t addr, uint32_t *val)
+int intel_nc_read(uint32_t addr, uint32_t *val)
 {
 	return vlv_sideband_rw(IOSF_PORT_NC, SB_CRRDDA_NP, addr, val);
 }
@@ -118,7 +118,7 @@ int intel_nc_read(uint8_t addr, uint32_t *val)
  * Returns:
  * 0 when the register access succeeded, negative errno code on failure.
  */
-int intel_nc_write(uint8_t addr, uint32_t val)
+int intel_nc_write(uint32_t addr, uint32_t val)
 {
 	return vlv_sideband_rw(IOSF_PORT_NC, SB_CRWRDA_NP, addr, &val);
 }
-- 
2.0.5

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

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

* [PATCH i-g-t 3/9] toos/intel_iosf_sb_*: Fix DPIO IOSF SB port number
  2015-03-23 13:14 [PATCH i-g-t 1/9] lib: Change IOSF SB devfn to 0.0 ville.syrjala
  2015-03-23 13:14 ` [PATCH i-g-t 2/9] lib: Allow 32bit addresses for IOSF-SB registers ville.syrjala
@ 2015-03-23 13:14 ` ville.syrjala
  2015-03-23 13:14 ` [PATCH i-g-t 4/9] tools: Remove intel_dpio_{read, write} tools ville.syrjala
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ville.syrjala @ 2015-03-23 13:14 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

The correct port is 0x12, not 0x13 which is actually GPIO_NC.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tools/intel_iosf_sb_read.c  | 2 +-
 tools/intel_iosf_sb_write.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/intel_iosf_sb_read.c b/tools/intel_iosf_sb_read.c
index 8f35e50..03bf007 100644
--- a/tools/intel_iosf_sb_read.c
+++ b/tools/intel_iosf_sb_read.c
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
 	else if (!strcasecmp(argv[1], "nc"))
 		port = 0x11;
 	else if (!strcasecmp(argv[1], "dpio"))
-		port = 0x13;
+		port = 0x12;
 	else if (!strcasecmp(argv[1], "gpio_nc"))
 		port = 0x13;
 	else if (!strcasecmp(argv[1], "cck"))
diff --git a/tools/intel_iosf_sb_write.c b/tools/intel_iosf_sb_write.c
index 8d06380..13c738f 100644
--- a/tools/intel_iosf_sb_write.c
+++ b/tools/intel_iosf_sb_write.c
@@ -54,7 +54,7 @@ int main(int argc, char** argv)
 	else if (!strcasecmp(argv[1], "nc"))
 		port = 0x11;
 	else if (!strcasecmp(argv[1], "dpio"))
-		port = 0x13;
+		port = 0x12;
 	else if (!strcasecmp(argv[1], "gpio_nc"))
 		port = 0x13;
 	else if (!strcasecmp(argv[1], "cck"))
-- 
2.0.5

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

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

* [PATCH i-g-t 4/9] tools: Remove intel_dpio_{read, write} tools
  2015-03-23 13:14 [PATCH i-g-t 1/9] lib: Change IOSF SB devfn to 0.0 ville.syrjala
  2015-03-23 13:14 ` [PATCH i-g-t 2/9] lib: Allow 32bit addresses for IOSF-SB registers ville.syrjala
  2015-03-23 13:14 ` [PATCH i-g-t 3/9] toos/intel_iosf_sb_*: Fix DPIO IOSF SB port number ville.syrjala
@ 2015-03-23 13:14 ` ville.syrjala
  2015-03-23 13:14 ` [PATCH i-g-t 5/9] tools/intel_iosf_sb_*: Replace if ladder with an array and bsearch() ville.syrjala
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ville.syrjala @ 2015-03-23 13:14 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

intel_dpio_{read,write} as redundant as intel_iosf_sb_{read,write}
handle the same task.

The difference between the tools was the opcode used to read/write the
registers, but with DPIO both opcodes work just fine, so there's no need
for both sets of tools.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tools/Makefile.sources   |  2 --
 tools/intel_dpio_read.c  | 69 -----------------------------------------------
 tools/intel_dpio_write.c | 70 ------------------------------------------------
 3 files changed, 141 deletions(-)
 delete mode 100644 tools/intel_dpio_read.c
 delete mode 100644 tools/intel_dpio_write.c

diff --git a/tools/Makefile.sources b/tools/Makefile.sources
index b16af8a..44b9e9c 100644
--- a/tools/Makefile.sources
+++ b/tools/Makefile.sources
@@ -9,8 +9,6 @@ bin_PROGRAMS = 				\
 	intel_bios_dumper 		\
 	intel_bios_reader 		\
 	intel_display_poller		\
-	intel_dpio_read			\
-	intel_dpio_write		\
 	intel_dump_decode 		\
 	intel_error_decode 		\
 	intel_forcewaked		\
diff --git a/tools/intel_dpio_read.c b/tools/intel_dpio_read.c
deleted file mode 100644
index 20561d2..0000000
--- a/tools/intel_dpio_read.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright © 2012 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *		Vijay Purushothaman <vijay.a.purushothaman@intel.com>
- *
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <err.h>
-#include <string.h>
-#include "intel_io.h"
-#include "intel_chipset.h"
-
-static void usage(char *cmdname)
-{
-	printf("Warning : This program will work only on Valleyview\n");
-	printf("Usage: %s [addr]\n", cmdname);
-	printf("\t addr : in 0xXXXX format\n");
-}
-
-int main(int argc, char** argv)
-{
-	int ret = 0;
-	uint32_t reg, val;
-	char *cmdname = strdup(argv[0]);
-	struct pci_device *dev = intel_get_pci_device();
-
-	if (argc != 2 || !(IS_VALLEYVIEW(dev->device_id) || IS_CHERRYVIEW(dev->device_id))) {
-		usage(cmdname);
-		ret = 1;
-		goto out;
-	}
-
-	sscanf(argv[1], "0x%x", &reg);
-
-	intel_register_access_init(dev, 0);
-
-	val = intel_dpio_reg_read(reg, 0);
-
-	printf("0x%04x : 0x%08x\n", reg, val);
-
-	intel_register_access_fini();
-
-out:
-	free(cmdname);
-	return ret;
-}
diff --git a/tools/intel_dpio_write.c b/tools/intel_dpio_write.c
deleted file mode 100644
index 45cc95f..0000000
--- a/tools/intel_dpio_write.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright © 2012 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *		Vijay Purushothaman <vijay.a.purushothaman@intel.com>
- *
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <err.h>
-#include <string.h>
-#include "intel_io.h"
-#include "intel_chipset.h"
-
-static void usage(char *cmdname)
-{
-	printf("Warning : This program will work only on Valleyview\n");
-	printf("Usage: %s [addr] [val]\n", cmdname);
-	printf("\t addr : in 0xXXXX format\n");
-}
-
-int main(int argc, char** argv)
-{
-	int ret = 0;
-	uint32_t reg, val;
-	char *cmdname = strdup(argv[0]);
-	struct pci_device *dev = intel_get_pci_device();
-
-	if (argc != 3 || !(IS_VALLEYVIEW(dev->device_id) || IS_CHERRYVIEW(dev->device_id))) {
-		usage(cmdname);
-		ret = 1;
-		goto out;
-	}
-
-	sscanf(argv[1], "0x%x", &reg);
-	sscanf(argv[2], "0x%x", &val);
-
-	intel_register_access_init(dev, 0);
-
-	printf("Value before: 0x%08x\n", intel_dpio_reg_read(reg, 0));
-	intel_dpio_reg_write(reg, val, 0);
-	printf("Value after: 0x%08x\n", intel_dpio_reg_read(reg, 0));
-
-	intel_register_access_fini();
-
-out:
-	free(cmdname);
-	return ret;
-}
-- 
2.0.5

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

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

* [PATCH i-g-t 5/9] tools/intel_iosf_sb_*: Replace if ladder with an array and bsearch()
  2015-03-23 13:14 [PATCH i-g-t 1/9] lib: Change IOSF SB devfn to 0.0 ville.syrjala
                   ` (2 preceding siblings ...)
  2015-03-23 13:14 ` [PATCH i-g-t 4/9] tools: Remove intel_dpio_{read, write} tools ville.syrjala
@ 2015-03-23 13:14 ` ville.syrjala
  2015-03-23 13:14 ` [PATCH i-g-t 6/9] tools/intel_iosf_sb_*: Use getopt() to parse the options ville.syrjala
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ville.syrjala @ 2015-03-23 13:14 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace the silly strcasecmp() if ladder with and array that maps the
unit names to port numbers. And keep the thing sorted so we can do
the lookup with bsearch() for extra speed :)

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tools/intel_iosf_sb_read.c  | 59 ++++++++++++++++++++++++++++++---------------
 tools/intel_iosf_sb_write.c | 59 ++++++++++++++++++++++++++++++---------------
 2 files changed, 78 insertions(+), 40 deletions(-)

diff --git a/tools/intel_iosf_sb_read.c b/tools/intel_iosf_sb_read.c
index 03bf007..51b0d11 100644
--- a/tools/intel_iosf_sb_read.c
+++ b/tools/intel_iosf_sb_read.c
@@ -29,6 +29,44 @@
 #include <string.h>
 #include "intel_io.h"
 #include "intel_chipset.h"
+#include "drmtest.h"
+
+/* keep sorted by name for bsearch() */
+static const struct iosf_sb_port {
+	const char *name;
+	uint8_t port;
+} iosf_sb_ports[] = {
+	{ "bunit",   0x03, },
+	{ "cck",     0x14, },
+	{ "ccu",     0xa9, },
+	{ "dpio",    0x12, },
+	{ "dpio2",   0x1a, },
+	{ "flisdsi", 0x1b, },
+	{ "gpio_nc", 0x13, },
+	{ "nc",      0x11, },
+	{ "punit",   0x04, },
+};
+
+static int iosf_sb_port_compare(const void *a, const void *b)
+{
+	const char *name = a;
+	const struct iosf_sb_port *p = b;
+
+	return strcasecmp(name, p->name);
+}
+
+static int iosf_sb_port_parse(const char *name)
+{
+	const struct iosf_sb_port *p;
+
+	p = bsearch(name, iosf_sb_ports, ARRAY_SIZE(iosf_sb_ports),
+		    sizeof(iosf_sb_ports[0]),
+		    iosf_sb_port_compare);
+	if (p)
+		return p->port;
+
+	return strtoul(name, NULL, 16);
+}
 
 static void usage(const char *name)
 {
@@ -48,26 +86,7 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
-	if (!strcasecmp(argv[1], "bunit"))
-		port = 0x03;
-	else if (!strcasecmp(argv[1], "punit"))
-		port = 0x04;
-	else if (!strcasecmp(argv[1], "nc"))
-		port = 0x11;
-	else if (!strcasecmp(argv[1], "dpio"))
-		port = 0x12;
-	else if (!strcasecmp(argv[1], "gpio_nc"))
-		port = 0x13;
-	else if (!strcasecmp(argv[1], "cck"))
-		port = 0x14;
-	else if (!strcasecmp(argv[1], "ccu"))
-		port = 0xa9;
-	else if (!strcasecmp(argv[1], "dpio2"))
-		port = 0x1a;
-	else if (!strcasecmp(argv[1], "flisdsi"))
-		port = 0x1b;
-	else
-		port = strtoul(argv[1], NULL, 16);
+	port = iosf_sb_port_parse(argv[1]);
 
 	reg = strtoul(argv[2], NULL, 16);
 
diff --git a/tools/intel_iosf_sb_write.c b/tools/intel_iosf_sb_write.c
index 13c738f..f6aa8f1 100644
--- a/tools/intel_iosf_sb_write.c
+++ b/tools/intel_iosf_sb_write.c
@@ -28,6 +28,44 @@
 #include <string.h>
 #include "intel_io.h"
 #include "intel_chipset.h"
+#include "drmtest.h"
+
+/* keep sorted by name for bsearch() */
+static const struct iosf_sb_port {
+	const char *name;
+	uint8_t port;
+} iosf_sb_ports[] = {
+	{ "bunit",   0x03, },
+	{ "cck",     0x14, },
+	{ "ccu",     0xa9, },
+	{ "dpio",    0x12, },
+	{ "dpio2",   0x1a, },
+	{ "flisdsi", 0x1b, },
+	{ "gpio_nc", 0x13, },
+	{ "nc",      0x11, },
+	{ "punit",   0x04, },
+};
+
+static int iosf_sb_port_compare(const void *a, const void *b)
+{
+	const char *name = a;
+	const struct iosf_sb_port *p = b;
+
+	return strcasecmp(name, p->name);
+}
+
+static int iosf_sb_port_parse(const char *name)
+{
+	const struct iosf_sb_port *p;
+
+	p = bsearch(name, iosf_sb_ports, ARRAY_SIZE(iosf_sb_ports),
+		    sizeof(iosf_sb_ports[0]),
+		    iosf_sb_port_compare);
+	if (p)
+		return p->port;
+
+	return strtoul(name, NULL, 16);
+}
 
 static void usage(const char *name)
 {
@@ -47,26 +85,7 @@ int main(int argc, char** argv)
 		return 1;
 	}
 
-	if (!strcasecmp(argv[1], "bunit"))
-		port = 0x03;
-	else if (!strcasecmp(argv[1], "punit"))
-		port = 0x04;
-	else if (!strcasecmp(argv[1], "nc"))
-		port = 0x11;
-	else if (!strcasecmp(argv[1], "dpio"))
-		port = 0x12;
-	else if (!strcasecmp(argv[1], "gpio_nc"))
-		port = 0x13;
-	else if (!strcasecmp(argv[1], "cck"))
-		port = 0x14;
-	else if (!strcasecmp(argv[1], "ccu"))
-		port = 0xa9;
-	else if (!strcasecmp(argv[1], "dpio2"))
-		port = 0x1a;
-	else if (!strcasecmp(argv[1], "flisdsi"))
-		port = 0x1b;
-	else
-		port = strtoul(argv[1], NULL, 16);
+	port = iosf_sb_port_parse(argv[1]);
 
 	reg = strtoul(argv[2], NULL, 16);
 	val = strtoul(argv[3], NULL, 16);
-- 
2.0.5

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

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

* [PATCH i-g-t 6/9] tools/intel_iosf_sb_*: Use getopt() to parse the options
  2015-03-23 13:14 [PATCH i-g-t 1/9] lib: Change IOSF SB devfn to 0.0 ville.syrjala
                   ` (3 preceding siblings ...)
  2015-03-23 13:14 ` [PATCH i-g-t 5/9] tools/intel_iosf_sb_*: Replace if ladder with an array and bsearch() ville.syrjala
@ 2015-03-23 13:14 ` ville.syrjala
  2015-03-23 13:14 ` [PATCH i-g-t 7/9] tools/intel_iosf_sb_*: Support reading/writing multiple registers at once ville.syrjala
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ville.syrjala @ 2015-03-23 13:14 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

I want to add some command line options so switch to getopt() to make
that easier.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tools/intel_iosf_sb_read.c  | 45 ++++++++++++++++++++++++++++++++-------
 tools/intel_iosf_sb_write.c | 51 ++++++++++++++++++++++++++++++++++++---------
 2 files changed, 78 insertions(+), 18 deletions(-)

diff --git a/tools/intel_iosf_sb_read.c b/tools/intel_iosf_sb_read.c
index 51b0d11..abe7fb5 100644
--- a/tools/intel_iosf_sb_read.c
+++ b/tools/intel_iosf_sb_read.c
@@ -70,30 +70,59 @@ static int iosf_sb_port_parse(const char *name)
 
 static void usage(const char *name)
 {
-	printf("Warning : This program will work only on Valleyview\n"
-	       "Usage: %s <port> <reg>\n"
-	       "\t port/reg : in 0xXXXX format\n",
-	       name);
+	int i;
+
+	printf("Warning : This program will work only on Valleyview/Cherryview\n"
+	       "Usage: %s [-h] [--] <port> <reg>\n"
+	       "\t -h : Show this help text\n"
+	       "\t <port> : ", name);
+	for (i = 0; i < ARRAY_SIZE(iosf_sb_ports); i++)
+		printf("%s,", iosf_sb_ports[i].name);
+	printf(" or in hex\n"
+	       "\t <reg> : in hex\n");
 }
 
 int main(int argc, char *argv[])
 {
 	uint32_t port, reg, val;
 	struct pci_device *dev = intel_get_pci_device();
+	int i, nregs;
+	const char *name;
 
-	if (argc != 3 || !(IS_VALLEYVIEW(dev->device_id) || IS_CHERRYVIEW(dev->device_id))) {
+	if (!IS_VALLEYVIEW(dev->device_id) &&
+	    !IS_CHERRYVIEW(dev->device_id)) {
 		usage(argv[0]);
 		return 1;
 	}
 
-	port = iosf_sb_port_parse(argv[1]);
+	for (;;) {
+		int c = getopt(argc, argv, "h");
+
+		if (c == -1)
+			break;
+
+		switch (c) {
+		case 'h':
+			usage(argv[0]);
+			return 0;
+		}
+	}
+
+	nregs = argc - optind;
+	if (nregs < 1) {
+		usage(argv[0]);
+		return 2;
+	}
 
-	reg = strtoul(argv[2], NULL, 16);
+	i = optind;
+	name = argv[i++];
+	port = iosf_sb_port_parse(name);
 
 	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, argv[1], reg, val);
+	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 f6aa8f1..d0ba4d3 100644
--- a/tools/intel_iosf_sb_write.c
+++ b/tools/intel_iosf_sb_write.c
@@ -69,36 +69,67 @@ static int iosf_sb_port_parse(const char *name)
 
 static void usage(const char *name)
 {
-	printf("Warning : This program will work only on Valleyview\n"
-	       "Usage: %s <port> <reg> <val>\n"
-	       "\t port/reg/val : in 0xXXXX format\n",
-	       name);
+	int i;
+
+	printf("Warning : This program will work only on Valleyview/Cherryview\n"
+	       "Usage: %s [-h] [--] <port> <reg> <val>\n"
+	       "\t -h : Show this help text\n"
+	       "\t <port> : ", name);
+	for (i = 0; i < ARRAY_SIZE(iosf_sb_ports); i++)
+		printf("%s,", iosf_sb_ports[i].name);
+	printf(" or in hex\n"
+	       "\t <reg> : in hex\n"
+	       "\t <val> : in hex\n");
 }
 
 int main(int argc, char** argv)
 {
 	uint32_t port, reg, val, tmp;
 	struct pci_device *dev = intel_get_pci_device();
+	int i, nregs;
+	const char *name;
 
-	if (argc != 4 || !(IS_VALLEYVIEW(dev->device_id) || IS_CHERRYVIEW(dev->device_id))) {
+	if (!IS_VALLEYVIEW(dev->device_id) &&
+	    !IS_CHERRYVIEW(dev->device_id)) {
 		usage(argv[0]);
 		return 1;
 	}
 
-	port = iosf_sb_port_parse(argv[1]);
+	for (;;) {
+		int c = getopt(argc, argv, "h");
+
+		if (c == -1)
+			break;
+
+		switch (c) {
+		case 'h':
+			usage(argv[0]);
+			return 0;
+		}
+	}
+
+	nregs = argc - optind;
+	if (nregs < 2) {
+		usage(argv[0]);
+		return 2;
+	}
+
+	i = optind;
+	name = argv[i++];
+	port = iosf_sb_port_parse(name);
 
-	reg = strtoul(argv[2], NULL, 16);
-	val = strtoul(argv[3], NULL, 16);
+	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, argv[1], reg, tmp);
+	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, argv[1], reg, tmp);
+	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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH i-g-t 7/9] tools/intel_iosf_sb_*: Support reading/writing multiple registers at once
  2015-03-23 13:14 [PATCH i-g-t 1/9] lib: Change IOSF SB devfn to 0.0 ville.syrjala
                   ` (4 preceding siblings ...)
  2015-03-23 13:14 ` [PATCH i-g-t 6/9] tools/intel_iosf_sb_*: Use getopt() to parse the options ville.syrjala
@ 2015-03-23 13:14 ` ville.syrjala
  2015-03-23 13:14 ` [PATCH i-g-t 8/9] tools/intel_iosf_sb_read: Add -c command line option like intel_reg_read ville.syrjala
  2015-03-23 13:14 ` [PATCH i-g-t 9/9] tools/intel_iosf_sb_read: Support different register strides ville.syrjala
  7 siblings, 0 replies; 9+ messages in thread
From: ville.syrjala @ 2015-03-23 13:14 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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@linux.intel.com>
---
 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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH i-g-t 8/9] tools/intel_iosf_sb_read: Add -c command line option like intel_reg_read
  2015-03-23 13:14 [PATCH i-g-t 1/9] lib: Change IOSF SB devfn to 0.0 ville.syrjala
                   ` (5 preceding siblings ...)
  2015-03-23 13:14 ` [PATCH i-g-t 7/9] tools/intel_iosf_sb_*: Support reading/writing multiple registers at once ville.syrjala
@ 2015-03-23 13:14 ` ville.syrjala
  2015-03-23 13:14 ` [PATCH i-g-t 9/9] tools/intel_iosf_sb_read: Support different register strides ville.syrjala
  7 siblings, 0 replies; 9+ messages in thread
From: ville.syrjala @ 2015-03-23 13:14 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a command line option '-c <count>' that can be used to read set of
consecutive registers without having to specify the offset for each of
them.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tools/intel_iosf_sb_read.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/tools/intel_iosf_sb_read.c b/tools/intel_iosf_sb_read.c
index 48a22be..2b0704a 100644
--- a/tools/intel_iosf_sb_read.c
+++ b/tools/intel_iosf_sb_read.c
@@ -73,8 +73,9 @@ static void usage(const char *name)
 	int i;
 
 	printf("Warning : This program will work only on Valleyview/Cherryview\n"
-	       "Usage: %s [-h] [--] <port> <reg> [<reg> ...]\n"
+	       "Usage: %s [-h] [-c <count>] [--] <port> <reg> [<reg> ...]\n"
 	       "\t -h : Show this help text\n"
+	       "\t -c <count> : how many consecutive registers to read\n"
 	       "\t <port> : ", name);
 	for (i = 0; i < ARRAY_SIZE(iosf_sb_ports); i++)
 		printf("%s,", iosf_sb_ports[i].name);
@@ -86,7 +87,7 @@ int main(int argc, char *argv[])
 {
 	uint32_t port, reg, val;
 	struct pci_device *dev = intel_get_pci_device();
-	int i, nregs;
+	int i, nregs, count = 1;
 	const char *name;
 
 	if (!IS_VALLEYVIEW(dev->device_id) &&
@@ -105,6 +106,13 @@ int main(int argc, char *argv[])
 		case 'h':
 			usage(argv[0]);
 			return 0;
+		case 'c':
+			count = strtol(optarg, NULL, 0);
+			if (count < 1) {
+				usage(argv[0]);
+				return 3;
+			}
+			break;
 		}
 	}
 
@@ -121,10 +129,15 @@ int main(int argc, char *argv[])
 	intel_register_access_init(dev, 0);
 
 	for (; i < argc; i++) {
+		int j;
+
 		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 (j = 0; j < count; j++) {
+			val = intel_iosf_sb_read(port, reg);
+			printf("0x%02x(%s)/0x%04x : 0x%08x\n", port, name, reg, val);
+			reg += 4;
+		}
 	}
 
 	intel_register_access_fini();
-- 
2.0.5

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

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

* [PATCH i-g-t 9/9] tools/intel_iosf_sb_read: Support different register strides
  2015-03-23 13:14 [PATCH i-g-t 1/9] lib: Change IOSF SB devfn to 0.0 ville.syrjala
                   ` (6 preceding siblings ...)
  2015-03-23 13:14 ` [PATCH i-g-t 8/9] tools/intel_iosf_sb_read: Add -c command line option like intel_reg_read ville.syrjala
@ 2015-03-23 13:14 ` ville.syrjala
  7 siblings, 0 replies; 9+ messages in thread
From: ville.syrjala @ 2015-03-23 13:14 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Some IOSF SB units ogranize their registers in a pecualiar way. Even
though the registers are 32 bits wide, the register offsets only
increment by one when going from one register to the next. Correctly
deal with this when dumping several consecutive registers.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tools/intel_iosf_sb_read.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/tools/intel_iosf_sb_read.c b/tools/intel_iosf_sb_read.c
index 2b0704a..f188cda 100644
--- a/tools/intel_iosf_sb_read.c
+++ b/tools/intel_iosf_sb_read.c
@@ -35,16 +35,17 @@
 static const struct iosf_sb_port {
 	const char *name;
 	uint8_t port;
+	uint8_t reg_stride;
 } iosf_sb_ports[] = {
-	{ "bunit",   0x03, },
-	{ "cck",     0x14, },
-	{ "ccu",     0xa9, },
-	{ "dpio",    0x12, },
-	{ "dpio2",   0x1a, },
-	{ "flisdsi", 0x1b, },
-	{ "gpio_nc", 0x13, },
-	{ "nc",      0x11, },
-	{ "punit",   0x04, },
+	{ "bunit",   0x03, 1, },
+	{ "cck",     0x14, 1, },
+	{ "ccu",     0xa9, 4, },
+	{ "dpio",    0x12, 4, },
+	{ "dpio2",   0x1a, 4, },
+	{ "flisdsi", 0x1b, 1, },
+	{ "gpio_nc", 0x13, 4, },
+	{ "nc",      0x11, 4, },
+	{ "punit",   0x04, 1, },
 };
 
 static int iosf_sb_port_compare(const void *a, const void *b)
@@ -55,16 +56,19 @@ static int iosf_sb_port_compare(const void *a, const void *b)
 	return strcasecmp(name, p->name);
 }
 
-static int iosf_sb_port_parse(const char *name)
+static int iosf_sb_port_parse(const char *name, int *reg_stride)
 {
 	const struct iosf_sb_port *p;
 
 	p = bsearch(name, iosf_sb_ports, ARRAY_SIZE(iosf_sb_ports),
 		    sizeof(iosf_sb_ports[0]),
 		    iosf_sb_port_compare);
-	if (p)
+	if (p) {
+		*reg_stride = p->reg_stride;
 		return p->port;
+	}
 
+	*reg_stride = 4;
 	return strtoul(name, NULL, 16);
 }
 
@@ -87,7 +91,7 @@ int main(int argc, char *argv[])
 {
 	uint32_t port, reg, val;
 	struct pci_device *dev = intel_get_pci_device();
-	int i, nregs, count = 1;
+	int i, nregs, count = 1, reg_stride;
 	const char *name;
 
 	if (!IS_VALLEYVIEW(dev->device_id) &&
@@ -124,7 +128,7 @@ int main(int argc, char *argv[])
 
 	i = optind;
 	name = argv[i++];
-	port = iosf_sb_port_parse(name);
+	port = iosf_sb_port_parse(name, &reg_stride);
 
 	intel_register_access_init(dev, 0);
 
@@ -136,7 +140,7 @@ int main(int argc, char *argv[])
 		for (j = 0; j < count; j++) {
 			val = intel_iosf_sb_read(port, reg);
 			printf("0x%02x(%s)/0x%04x : 0x%08x\n", port, name, reg, val);
-			reg += 4;
+			reg += reg_stride;
 		}
 	}
 
-- 
2.0.5

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

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

end of thread, other threads:[~2015-03-23 13:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-23 13:14 [PATCH i-g-t 1/9] lib: Change IOSF SB devfn to 0.0 ville.syrjala
2015-03-23 13:14 ` [PATCH i-g-t 2/9] lib: Allow 32bit addresses for IOSF-SB registers ville.syrjala
2015-03-23 13:14 ` [PATCH i-g-t 3/9] toos/intel_iosf_sb_*: Fix DPIO IOSF SB port number ville.syrjala
2015-03-23 13:14 ` [PATCH i-g-t 4/9] tools: Remove intel_dpio_{read, write} tools ville.syrjala
2015-03-23 13:14 ` [PATCH i-g-t 5/9] tools/intel_iosf_sb_*: Replace if ladder with an array and bsearch() ville.syrjala
2015-03-23 13:14 ` [PATCH i-g-t 6/9] tools/intel_iosf_sb_*: Use getopt() to parse the options ville.syrjala
2015-03-23 13:14 ` [PATCH i-g-t 7/9] tools/intel_iosf_sb_*: Support reading/writing multiple registers at once ville.syrjala
2015-03-23 13:14 ` [PATCH i-g-t 8/9] tools/intel_iosf_sb_read: Add -c command line option like intel_reg_read ville.syrjala
2015-03-23 13:14 ` [PATCH i-g-t 9/9] tools/intel_iosf_sb_read: Support different register strides ville.syrjala

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.