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_gt_types.h"
10
11 struct xe_device;
12 struct xe_reg;
13
14 int xe_mmio_init(struct xe_device *xe);
15 int xe_mmio_probe_tiles(struct xe_device *xe);
16
17 u8 xe_mmio_read8(struct xe_mmio *mmio, struct xe_reg reg);
18 u16 xe_mmio_read16(struct xe_mmio *mmio, struct xe_reg reg);
19 void xe_mmio_write32(struct xe_mmio *mmio, struct xe_reg reg, u32 val);
20 u32 xe_mmio_read32(struct xe_mmio *mmio, struct xe_reg reg);
21 u32 xe_mmio_rmw32(struct xe_mmio *mmio, struct xe_reg reg, u32 clr, u32 set);
22 int xe_mmio_write32_and_verify(struct xe_mmio *mmio, struct xe_reg reg, u32 val, u32 mask, u32 eval);
23 bool xe_mmio_in_range(const struct xe_mmio *mmio, const struct xe_mmio_range *range, struct xe_reg reg);
24
25 u64 xe_mmio_read64_2x32(struct xe_mmio *mmio, struct xe_reg reg);
26 int xe_mmio_wait32(struct xe_mmio *mmio, struct xe_reg reg, u32 mask, u32 val,
27 u32 timeout_us, u32 *out_val, bool atomic);
28 int xe_mmio_wait32_not(struct xe_mmio *mmio, struct xe_reg reg, u32 mask,
29 u32 val, u32 timeout_us, u32 *out_val, bool atomic);
30
xe_mmio_adjusted_addr(const struct xe_mmio * mmio,u32 addr)31 static inline u32 xe_mmio_adjusted_addr(const struct xe_mmio *mmio, u32 addr)
32 {
33 if (addr < mmio->adj_limit)
34 addr += mmio->adj_offset;
35 return addr;
36 }
37
xe_root_tile_mmio(struct xe_device * xe)38 static inline struct xe_mmio *xe_root_tile_mmio(struct xe_device *xe)
39 {
40 return &xe->tiles[0].mmio;
41 }
42
43 #endif
44