From patchwork Thu Feb 19 06:58:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: meghanelogal X-Patchwork-Id: 5850531 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 192EFBF440 for ; Thu, 19 Feb 2015 07:02:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C984420155 for ; Thu, 19 Feb 2015 07:02:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D7C54200EC for ; Thu, 19 Feb 2015 07:02:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 05CE26E032; Wed, 18 Feb 2015 23:02:38 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id B073B6E032 for ; Wed, 18 Feb 2015 23:02:36 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 18 Feb 2015 23:02:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,607,1418112000"; d="scan'208";a="456648321" Received: from meghanelogal-2012-client-platform.iind.intel.com ([10.223.161.112]) by FMSMGA003.fm.intel.com with ESMTP; 18 Feb 2015 22:47:27 -0800 From: meghanelogal To: intel-gfx@lists.freedesktop.org Date: Thu, 19 Feb 2015 12:28:57 +0530 Message-Id: <1424329137-29013-1-git-send-email-megha.i.nelogal@intel.com> X-Mailer: git-send-email 1.7.9.5 Cc: meghanelogal Subject: [Intel-gfx] [PATCH] tools/intel_reg_write:Adding lib calls for CHT/VLV X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: meghanelogal Calling the library functions for reg read and write Signed-off-by: meghanelogal --- 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", ®); 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;