public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: meghanelogal <megha.i.nelogal@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] tools/intel_reg_write:Adding lib calls for CHT/VLV
Date: Thu, 19 Feb 2015 11:35:37 +0200	[thread overview]
Message-ID: <20150219093537.GE11371@intel.com> (raw)
In-Reply-To: <1424329137-29013-1-git-send-email-megha.i.nelogal@intel.com>

On Thu, Feb 19, 2015 at 12:28:57PM +0530, meghanelogal wrote:
> From: meghanelogal <megha.i.nelogal@intel.com>
> 
> Calling the library functions for reg read and write
> 
> Signed-off-by: meghanelogal <megha.i.nelogal@intel.com>

Nak. The 0x180000 offset is only needed for display registers, so this
change would break everything else. If you really want to avoid having
to add the offset in your brain, you could add a new command line
option for it.

> ---
>  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

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

      reply	other threads:[~2015-02-19  9:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-19  6:58 [PATCH] tools/intel_reg_write:Adding lib calls for CHT/VLV meghanelogal
2015-02-19  9:35 ` Ville Syrjälä [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150219093537.GE11371@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=megha.i.nelogal@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox