xref: /linux/drivers/gpu/drm/xe/xe_mmio.h (revision 53597deca0e38c30e6cd4ba2114fa42d2bcd85bb)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2021-2023 Intel Corporation
4  */
5 
6 #ifndef _XE_MMIO_H_
7 #define _XE_MMIO_H_
8 
9 #include "xe_mmio_types.h"
10 
11 struct xe_device;
12 struct xe_reg;
13 
14 int xe_mmio_probe_early(struct xe_device *xe);
15 int xe_mmio_probe_tiles(struct xe_device *xe);
16 
17 void xe_mmio_init(struct xe_mmio *mmio, struct xe_tile *tile, void __iomem *ptr, u32 size);
18 
19 u8 xe_mmio_read8(struct xe_mmio *mmio, struct xe_reg reg);
20 void xe_mmio_write8(struct xe_mmio *mmio, struct xe_reg reg, u8 val);
21 u16 xe_mmio_read16(struct xe_mmio *mmio, struct xe_reg reg);
22 void xe_mmio_write32(struct xe_mmio *mmio, struct xe_reg reg, u32 val);
23 u32 xe_mmio_read32(struct xe_mmio *mmio, struct xe_reg reg);
24 u32 xe_mmio_rmw32(struct xe_mmio *mmio, struct xe_reg reg, u32 clr, u32 set);
25 int xe_mmio_write32_and_verify(struct xe_mmio *mmio, struct xe_reg reg, u32 val, u32 mask, u32 eval);
26 bool xe_mmio_in_range(const struct xe_mmio *mmio, const struct xe_mmio_range *range, struct xe_reg reg);
27 
28 u64 xe_mmio_read64_2x32(struct xe_mmio *mmio, struct xe_reg reg);
29 int xe_mmio_wait32(struct xe_mmio *mmio, struct xe_reg reg, u32 mask, u32 val,
30 		   u32 timeout_us, u32 *out_val, bool atomic);
31 int xe_mmio_wait32_not(struct xe_mmio *mmio, struct xe_reg reg, u32 mask,
32 		       u32 val, u32 timeout_us, u32 *out_val, bool atomic);
33 
34 static inline u32 xe_mmio_adjusted_addr(const struct xe_mmio *mmio, u32 addr)
35 {
36 	if (addr < mmio->adj_limit)
37 		addr += mmio->adj_offset;
38 	return addr;
39 }
40 
41 #ifdef CONFIG_PCI_IOV
42 void xe_mmio_init_vf_view(struct xe_mmio *mmio, const struct xe_mmio *base, unsigned int vfid);
43 #endif
44 
45 #endif
46