blob: a2c2e9f71e576e49910f4ca58bc71bd4a932daac [file] [log] [blame]
Jesse Barnes25339592013-04-16 13:14:58 -07001/*
2 * Copyright © 2012 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Authors:
24 * Vijay Purushothaman <vijay.a.purushothaman@intel.com>
25 *
26 */
27
28#include <unistd.h>
29#include <stdlib.h>
30#include <stdio.h>
31#include <err.h>
32#include <string.h>
33#include "intel_gpu_tools.h"
34
35static void usage(char *cmdname)
36{
37 printf("Warning : This program will work only on Valleyview\n");
38 printf("Usage: %s [addr]\n", cmdname);
39 printf("\t addr : in 0xXXXX format\n");
40}
41
42int main(int argc, char** argv)
43{
44 int ret = 0;
45 uint32_t reg, val;
46 char *cmdname = strdup(argv[0]);
47 struct pci_device *dev = intel_get_pci_device();
48
49 if (argc != 2 || !IS_VALLEYVIEW(dev->device_id)) {
50 usage(cmdname);
51 ret = 1;
52 goto out;
53 }
54
55 sscanf(argv[1], "0x%x", &reg);
56
57 intel_register_access_init(dev, 0);
58
59 ret = intel_nc_read(reg, &val);
60 if (ret)
61 fprintf(stderr, "iosf read failed: %d\n", ret);
62
63 printf("Read IOSF register: 0x%x - Value : 0x%x\n", reg, val);
64
65 intel_register_access_fini();
66
67out:
68 free(cmdname);
69 return ret;
70}