From: meghanelogal <megha.i.nelo...@intel.com>

Calling the library functions for reg read and write

Signed-off-by: meghanelogal <megha.i.nelo...@intel.com>
---
 tools/intel_reg_write.c |   28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/tools/intel_reg_write.c b/tools/intel_reg_write.c
index ff4e561..8ac29e4 100644
--- a/tools/intel_reg_write.c
+++ b/tools/intel_reg_write.c
@@ -34,9 +34,7 @@
 
 int main(int argc, char** argv)
 {
-       uint32_t reg, value;
-       volatile uint32_t *ptr;
-
+       uint32_t reg = 0, value, initial_value, final_value;
        if (argc < 3) {
                printf("Usage: %s addr value\n", argv[0]);
                printf("  WARNING: This is dangerous to you and your system's 
health.\n");
@@ -45,13 +43,29 @@ int main(int argc, char** argv)
        }
 
        intel_register_access_init(intel_get_pci_device(), 0);
+
        sscanf(argv[1], "0x%x", &reg);
        sscanf(argv[2], "0x%x", &value);
-       ptr = (volatile uint32_t *)((volatile char *)mmio + reg);
 
-       printf("Value before: 0x%X\n", *ptr);
-       *ptr = value;
-       printf("Value after: 0x%X\n", *ptr);
+       struct pci_device *dev = intel_get_pci_device();
+       if (IS_VALLEYVIEW(dev->device_id) || IS_CHERRYVIEW(dev->device_id))
+               initial_value = intel_register_read(reg+0x180000);
+       else
+               initial_value = intel_register_read(reg);
+
+       printf("Value before: 0x%X\n", initial_value);
+
+       if (IS_VALLEYVIEW(dev->device_id) || IS_CHERRYVIEW(dev->device_id))
+               intel_register_write(reg+0x180000, value);
+       else
+               intel_register_write(reg, value);
+
+       if (IS_VALLEYVIEW(dev->device_id) || IS_CHERRYVIEW(dev->device_id))
+               final_value = intel_register_read(reg+0x180000);
+       else
+               final_value = intel_register_read(reg);
+
+       printf("Value after: 0x%X\n", final_value);
 
        intel_register_access_fini();
        return 0;
-- 
1.7.9.5

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

Reply via email to