1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2022 Intel Corporation
4  */
5 
6 #ifndef __INTEL_DMC_REGS_H__
7 #define __INTEL_DMC_REGS_H__
8 
9 #include "i915_reg_defs.h"
10 
11 #define DMC_PROGRAM(addr, i)	_MMIO((addr) + (i) * 4)
12 #define DMC_SSP_BASE_ADDR_GEN9	0x00002FC0
13 
14 #define _ADLP_PIPEDMC_REG_MMIO_BASE_A	0x5f000
15 #define _TGL_PIPEDMC_REG_MMIO_BASE_A	0x92000
16 
17 #define __PIPEDMC_REG_MMIO_BASE(i915, dmc_id) \
18 	((DISPLAY_VER(i915) >= 13 ? _ADLP_PIPEDMC_REG_MMIO_BASE_A : \
19 				    _TGL_PIPEDMC_REG_MMIO_BASE_A) + \
20 	 0x400 * ((dmc_id) - 1))
21 
22 #define __DMC_REG_MMIO_BASE		0x8f000
23 
24 #define _DMC_REG_MMIO_BASE(i915, dmc_id) \
25 	((dmc_id) == DMC_FW_MAIN ? __DMC_REG_MMIO_BASE : \
26 				   __PIPEDMC_REG_MMIO_BASE(i915, dmc_id))
27 
28 #define _DMC_REG(i915, dmc_id, reg) \
29 	((reg) - __DMC_REG_MMIO_BASE + _DMC_REG_MMIO_BASE(i915, dmc_id))
30 
31 #define _DMC_EVT_HTP_0			0x8f004
32 
33 #define DMC_EVT_HTP(i915, dmc_id, handler) \
34 	_MMIO(_DMC_REG(i915, dmc_id, _DMC_EVT_HTP_0) + 4 * (handler))
35 
36 #define _DMC_EVT_CTL_0			0x8f034
37 
38 #define DMC_EVT_CTL(i915, dmc_id, handler) \
39 	_MMIO(_DMC_REG(i915, dmc_id, _DMC_EVT_CTL_0) + 4 * (handler))
40 
41 #define DMC_EVT_CTL_ENABLE		REG_BIT(31)
42 #define DMC_EVT_CTL_RECURRING		REG_BIT(30)
43 #define DMC_EVT_CTL_TYPE_MASK		REG_GENMASK(17, 16)
44 #define DMC_EVT_CTL_TYPE_LEVEL_0	0
45 #define DMC_EVT_CTL_TYPE_LEVEL_1	1
46 #define DMC_EVT_CTL_TYPE_EDGE_1_0	2
47 #define DMC_EVT_CTL_TYPE_EDGE_0_1	3
48 
49 #define DMC_EVT_CTL_EVENT_ID_MASK	REG_GENMASK(15, 8)
50 #define DMC_EVT_CTL_EVENT_ID_FALSE	0x01
51 /* An event handler scheduled to run at a 1 kHz frequency. */
52 #define DMC_EVT_CTL_EVENT_ID_CLK_MSEC	0xbf
53 
54 #define DMC_HTP_ADDR_SKL	0x00500034
55 #define DMC_SSP_BASE		_MMIO(0x8F074)
56 #define DMC_HTP_SKL		_MMIO(0x8F004)
57 #define DMC_LAST_WRITE		_MMIO(0x8F034)
58 #define DMC_LAST_WRITE_VALUE	0xc003b400
59 #define DMC_MMIO_START_RANGE	0x80000
60 #define DMC_MMIO_END_RANGE     0x8FFFF
61 #define DMC_V1_MMIO_START_RANGE		0x80000
62 #define TGL_MAIN_MMIO_START		0x8F000
63 #define TGL_MAIN_MMIO_END		0x8FFFF
64 #define _TGL_PIPEA_MMIO_START		0x92000
65 #define _TGL_PIPEA_MMIO_END		0x93FFF
66 #define _TGL_PIPEB_MMIO_START		0x96000
67 #define _TGL_PIPEB_MMIO_END		0x97FFF
68 #define ADLP_PIPE_MMIO_START		0x5F000
69 #define ADLP_PIPE_MMIO_END		0x5FFFF
70 
71 #define TGL_PIPE_MMIO_START(dmc_id)	_PICK_EVEN(((dmc_id) - 1), _TGL_PIPEA_MMIO_START,\
72 					      _TGL_PIPEB_MMIO_START)
73 
74 #define TGL_PIPE_MMIO_END(dmc_id)	_PICK_EVEN(((dmc_id) - 1), _TGL_PIPEA_MMIO_END,\
75 					      _TGL_PIPEB_MMIO_END)
76 
77 #define SKL_DMC_DC3_DC5_COUNT	_MMIO(0x80030)
78 #define SKL_DMC_DC5_DC6_COUNT	_MMIO(0x8002C)
79 #define BXT_DMC_DC3_DC5_COUNT	_MMIO(0x80038)
80 #define TGL_DMC_DEBUG_DC5_COUNT	_MMIO(0x101084)
81 #define TGL_DMC_DEBUG_DC6_COUNT	_MMIO(0x101088)
82 #define DG1_DMC_DEBUG_DC5_COUNT	_MMIO(0x134154)
83 
84 #define TGL_DMC_DEBUG3		_MMIO(0x101090)
85 #define DG1_DMC_DEBUG3		_MMIO(0x13415c)
86 
87 #endif /* __INTEL_DMC_REGS_H__ */
88