blob: d56d061d5b0ab5f96c6e3bce5d31b8d4bef64c45 [file] [log] [blame]
Eric Anholtfbbf1242009-03-27 12:25:09 -07001/*
2 * Copyright © 2009 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 * Eric Anholt <eric@anholt.net>
25 *
26 */
27
Chris Wilsonfa6c2752012-02-20 22:53:26 +000028#ifndef INTEL_GPU_TOOLS_H
29#define INTEL_GPU_TOOLS_H
30
Chris Wilson95374222010-04-08 11:56:57 +010031#include <stdint.h>
Eric Anholtfbbf1242009-03-27 12:25:09 -070032#include <pciaccess.h>
Chris Wilson95374222010-04-08 11:56:57 +010033
Daniel Vetterbff22f72014-03-22 19:21:26 +010034/* register access helpers from intel_mmio.c */
Chris Wilson95374222010-04-08 11:56:57 +010035extern void *mmio;
Daniel Vetter2d4656f2014-03-22 22:23:04 +010036void intel_mmio_use_pci_bar(struct pci_device *pci_dev);
Daniel Vetter95e89f02014-03-22 22:41:28 +010037void intel_mmio_use_dump_file(char *file);
Chris Wilson95374222010-04-08 11:56:57 +010038
Ben Widawskyabd70382011-07-28 13:42:45 -070039int intel_register_access_init(struct pci_device *pci_dev, int safe);
Ben Widawskycac8f8b2011-07-28 13:40:19 -070040void intel_register_access_fini(void);
41uint32_t intel_register_read(uint32_t reg);
42void intel_register_write(uint32_t reg, uint32_t val);
Damien Lespiau6587f662013-04-29 18:57:47 +010043int intel_register_access_needs_fakewake(void);
44
Daniel Vetter95e89f02014-03-22 22:41:28 +010045uint32_t INREG(uint32_t reg);
46void OUTREG(uint32_t reg, uint32_t val);
Daniel Vetterbff22f72014-03-22 19:21:26 +010047
48/* sideband access functions from intel_iosf.c */
Chon Ming Lee0b67c0c2013-12-04 20:44:33 +080049uint32_t intel_dpio_reg_read(uint32_t reg, int phy);
50void intel_dpio_reg_write(uint32_t reg, uint32_t val, int phy);
Ben Widawskycac8f8b2011-07-28 13:40:19 -070051
Jesse Barnes25339592013-04-16 13:14:58 -070052int intel_punit_read(uint8_t addr, uint32_t *val);
Jesse Barnesd6917cf2013-04-25 14:43:03 -070053int intel_punit_write(uint8_t addr, uint32_t val);
Jesse Barnes25339592013-04-16 13:14:58 -070054int intel_nc_read(uint8_t addr, uint32_t *val);
Jesse Barnesd6917cf2013-04-25 14:43:03 -070055int intel_nc_write(uint8_t addr, uint32_t val);
Jesse Barnes25339592013-04-16 13:14:58 -070056
Daniel Vetterbff22f72014-03-22 19:21:26 +010057/* register maps from intel_reg_map.c */
Daniel Vetter95e89f02014-03-22 22:41:28 +010058#ifndef __GTK_DOC_IGNORE__
59
Ben Widawskyabd70382011-07-28 13:42:45 -070060#define INTEL_RANGE_RSVD (0<<0) /* Shouldn't be read or written */
61#define INTEL_RANGE_READ (1<<0)
62#define INTEL_RANGE_WRITE (1<<1)
63#define INTEL_RANGE_RW (INTEL_RANGE_READ | INTEL_RANGE_WRITE)
64#define INTEL_RANGE_END (1<<31)
65
66struct intel_register_range {
67 uint32_t base;
68 uint32_t size;
69 uint32_t flags;
70};
71
72struct intel_register_map {
73 struct intel_register_range *map;
74 uint32_t top;
75 uint32_t alignment_mask;
76};
77struct intel_register_map intel_get_register_map(uint32_t devid);
Oscar Mateo5032e7b2013-11-12 11:50:42 +000078struct intel_register_range *intel_get_register_range(struct intel_register_map map, uint32_t offset, uint32_t mode);
Daniel Vetter95e89f02014-03-22 22:41:28 +010079#endif /* __GTK_DOC_IGNORE__ */
Ben Widawskyabd70382011-07-28 13:42:45 -070080
Chris Wilsonfa6c2752012-02-20 22:53:26 +000081#endif /* INTEL_GPU_TOOLS_H */