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