blob: 6014c4855cab1f6ca91ccc5bc1317a738b9a5516 [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 */
Jani Nikulaa734ac22015-04-28 13:31:30 +030035extern void *igt_global_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
Chris Wilson83884e92017-03-21 17:16:03 +000039int intel_register_access_init(struct pci_device *pci_dev, int safe, int fd);
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);
Jani Nikula23b7f082015-04-28 11:52:42 +030046uint16_t INREG16(uint32_t reg);
47uint8_t INREG8(uint32_t reg);
Daniel Vetter95e89f02014-03-22 22:41:28 +010048void OUTREG(uint32_t reg, uint32_t val);
Jani Nikula23b7f082015-04-28 11:52:42 +030049void OUTREG16(uint32_t reg, uint16_t val);
50void OUTREG8(uint32_t reg, uint8_t val);
Daniel Vetterbff22f72014-03-22 19:21:26 +010051
52/* sideband access functions from intel_iosf.c */
Chon Ming Lee0b67c0c2013-12-04 20:44:33 +080053uint32_t intel_dpio_reg_read(uint32_t reg, int phy);
54void intel_dpio_reg_write(uint32_t reg, uint32_t val, int phy);
Imre Deaka6eaa292014-05-18 23:37:56 +030055uint32_t intel_flisdsi_reg_read(uint32_t reg);
56void intel_flisdsi_reg_write(uint32_t reg, uint32_t val);
Ville Syrjälä71874f42014-06-10 21:28:10 +030057uint32_t intel_iosf_sb_read(uint32_t port, uint32_t reg);
58void intel_iosf_sb_write(uint32_t port, uint32_t reg, uint32_t val);
Ben Widawskycac8f8b2011-07-28 13:40:19 -070059
Ville Syrjäläac28ece2015-03-16 13:36:50 +020060int intel_punit_read(uint32_t addr, uint32_t *val);
61int intel_punit_write(uint32_t addr, uint32_t val);
62int intel_nc_read(uint32_t addr, uint32_t *val);
63int intel_nc_write(uint32_t addr, uint32_t val);
Jesse Barnes25339592013-04-16 13:14:58 -070064
Daniel Vetterbff22f72014-03-22 19:21:26 +010065/* register maps from intel_reg_map.c */
Daniel Vetter95e89f02014-03-22 22:41:28 +010066#ifndef __GTK_DOC_IGNORE__
67
Ben Widawskyabd70382011-07-28 13:42:45 -070068#define INTEL_RANGE_RSVD (0<<0) /* Shouldn't be read or written */
69#define INTEL_RANGE_READ (1<<0)
70#define INTEL_RANGE_WRITE (1<<1)
71#define INTEL_RANGE_RW (INTEL_RANGE_READ | INTEL_RANGE_WRITE)
72#define INTEL_RANGE_END (1<<31)
73
74struct intel_register_range {
75 uint32_t base;
76 uint32_t size;
77 uint32_t flags;
78};
79
80struct intel_register_map {
81 struct intel_register_range *map;
82 uint32_t top;
83 uint32_t alignment_mask;
84};
85struct intel_register_map intel_get_register_map(uint32_t devid);
Oscar Mateo5032e7b2013-11-12 11:50:42 +000086struct 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 +010087#endif /* __GTK_DOC_IGNORE__ */
Ben Widawskyabd70382011-07-28 13:42:45 -070088
Chris Wilsonfa6c2752012-02-20 22:53:26 +000089#endif /* INTEL_GPU_TOOLS_H */