1 /*
2  * Copyright (c) 2023 Intel Corporation
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef _PM_REGS_H_
8 #define _PM_REGS_H_
9 
10 #include "sedi_soc_regs.h"
11 
12 #ifndef BIT
13 #define BIT(x)	(1U << (x))
14 #endif
15 
16 /* PMU Registers */
17 #define PMU_SRAM_PG_EN			(SEDI_PMU_BASE + 0x0)
18 #define PMU_SRAM_PWR_STATUS		(SEDI_PMU_BASE + 0xF60)
19 #define PMU_SRAM_DEEPSLEEP		(SEDI_PMU_BASE + 0xF38)
20 #define PMU_PMC_HOST_RST_CTL		(SEDI_PMU_BASE + 0xF20)
21 #define PMU_SW_PG_REQ			(SEDI_PMU_BASE + 0xF14)
22 #define PMU_PMC_PG_WAKE			(SEDI_PMU_BASE + 0xF18)
23 #define PMU_INTERNAL_PCE		(SEDI_PMU_BASE + 0xF30)
24 #define PMU_D3_STATUS			(SEDI_PMU_BASE + 0x100)
25 #define PMU_GPIO_WAKE_MASK0		(SEDI_PMU_BASE + 0x250)
26 #define PMU_GPIO_WAKE_MASK1		(SEDI_PMU_BASE + 0x254)
27 #define PMU_HOST_RST_B			BIT(0)
28 #define PMU_PCE_SHADOW_MASK		0x1F
29 #define PMU_PCE_PG_ALLOWED		BIT(4)
30 #define PMU_PCE_CHANGE_MASK		BIT(9)
31 #define PMU_PCE_CHANGE_DETECTED		BIT(8)
32 #define PMU_PCE_PMCRE			BIT(0)
33 #define PMU_SW_PG_REQ_B_VAL		BIT(0)
34 #define PMU_SW_PG_REQ_B_RISE		BIT(1)
35 #define PMU_SW_PG_REQ_B_FALL		BIT(2)
36 #define PMU_PMC_PG_WAKE_VAL		BIT(0)
37 #define PMU_PMC_PG_WAKE_RISE		BIT(1)
38 #define PMU_PMC_PG_WAKE_FALL		BIT(2)
39 #define PMU_PCE_PG_ALLOWED		BIT(4)
40 #define PMU_D0I3_ENABLE_MASK		BIT(23)
41 #define PMU_D3_BIT_SET			BIT(16)
42 #define PMU_D3_BIT_RISING_EDGE_STATUS	BIT(17)
43 #define PMU_D3_BIT_FALLING_EDGE_STATUS	BIT(18)
44 #define PMU_D3_BIT_RISING_EDGE_MASK	BIT(19)
45 #define PMU_D3_BIT_FALLING_EDGE_MASK	BIT(20)
46 #define PMU_BME_BIT_SET			BIT(24)
47 #define PMU_BME_BIT_RISING_EDGE_STATUS	BIT(25)
48 #define PMU_BME_BIT_FALLING_EDGE_STATUS	BIT(26)
49 #define PMU_BME_BIT_RISING_EDGE_MASK	BIT(27)
50 #define PMU_BME_BIT_FALLING_EDGE_MASK	BIT(28)
51 
52 #define PMU_ISH_FABRIC_CNT		(SEDI_PMU_BASE + 0x18)
53 #define PMU_PGCB_CLKGATE_CTRL		(SEDI_PMU_BASE + 0x54)
54 
55 #define PMU_VNN_REQ			(SEDI_PMU_BASE + 0x3c)
56 #define VNN_REQ_IPC_HOST_WRITE		BIT(3)
57 
58 #define PMU_VNN_REQ_ACK			(SEDI_PMU_BASE + 0x40)
59 #define PMU_VNN_REQ_ACK_STATUS		BIT(0)
60 
61 #define PMU_VNNAON_RED			(SEDI_PMU_BASE + 0x58)
62 
63 #define PMU_RST_PREP			(SEDI_PMU_BASE + 0x5c)
64 #define PMU_RST_PREP_GET		BIT(0)
65 #define PMU_RST_PREP_AVAIL		BIT(1)
66 #define PMU_RST_PREP_INT_MASK		BIT(31)
67 
68 #define VNN_ID_DMA0			4
69 #define VNN_ID_DMA(chan)		(VNN_ID_DMA0 + chan)
70 
71 #define PMU_MASK_EVENT			(SEDI_PMU_BASE + 0x10)
72 #define PMU_MASK_EVENT_BIT_GPIO(pin)	BIT(pin)
73 #define PMU_MASK_EVENT_BIT_HPET		BIT(16)
74 #define PMU_MASK_EVENT_BIT_IPC		BIT(17)
75 #define PMU_MASK_EVENT_BIT_D3		BIT(18)
76 #define PMU_MASK_EVENT_BIT_DMA		BIT(19)
77 #define PMU_MASK_EVENT_BIT_I2C0		BIT(20)
78 #define PMU_MASK_EVENT_BIT_I2C1		BIT(21)
79 #define PMU_MASK_EVENT_BIT_SPI		BIT(22)
80 #define PMU_MASK_EVENT_BIT_UART		BIT(23)
81 #define PMU_MASK_EVENT_BIT_ALL		(0xffffffff)
82 
83 #define PMU_RF_ROM_PWR_CTRL		(SEDI_PMU_BASE + 0x30)
84 
85 #define PMU_LDO_CTRL			(SEDI_PMU_BASE + 0x44)
86 #define PMU_LDO_ENABLE_BIT		BIT(0)
87 #define PMU_LDO_RETENTION_BIT		BIT(1)
88 #define PMU_LDO_CALIBRATION_BIT		BIT(2)
89 #define PMU_LDO_READY_BIT		BIT(3)
90 
91 /* CCU Registers */
92 #define CCU_TCG_EN			(SEDI_CCU_BASE + 0x0)
93 #define CCU_BCG_EN			(SEDI_CCU_BASE + 0x4)
94 #define CCU_WDT_CD			(SEDI_CCU_BASE + 0x7c)
95 #define CCU_RST_HST			(SEDI_CCU_BASE + 0x3c)
96 #define CCU_TCG_ENABLE			(SEDI_CCU_BASE + 0x40)
97 #define CCU_BCG_ENABLE			(SEDI_CCU_BASE + 0x44)
98 #define CCU_BCG_MIA			(SEDI_CCU_BASE + 0x4)
99 #define CCU_BCG_UART			(SEDI_CCU_BASE + 0x8)
100 #define CCU_BCG_I2C			(SEDI_CCU_BASE + 0xc)
101 #define CCU_BCG_SPI			(SEDI_CCU_BASE + 0x10)
102 #define CCU_BCG_GPIO			(SEDI_CCU_BASE + 0x14)
103 #define CCU_BCG_DMA			(SEDI_CCU_BASE + 0x28)
104 #define CCU_AONCG_EN			(SEDI_CCU_BASE + 0xdc)
105 #define CCU_BCG_BIT_MIA			BIT(0)
106 #define CCU_BCG_BIT_DMA			BIT(1)
107 #define CCU_BCG_BIT_I2C0		BIT(2)
108 #define CCU_BCG_BIT_I2C1		BIT(3)
109 #define CCU_BCG_BIT_SPI			BIT(4)
110 #define CCU_BCG_BIT_SRAM		BIT(5)
111 #define CCU_BCG_BIT_HPET		BIT(6)
112 #define CCU_BCG_BIT_UART		BIT(7)
113 #define CCU_BCG_BIT_GPIO		BIT(8)
114 #define CCU_BCG_BIT_I2C2		BIT(9)
115 #define CCU_BCG_BIT_SPI2		BIT(10)
116 #define CCU_BCG_BIT_ALL			(0x7ff)
117 
118 #define CCU_SW_RST			BIT(0)
119 #define CCU_WDT_RST			BIT(1)
120 #define CCU_MIASS_RST			BIT(2)
121 #define CCU_SRECC_RST			BIT(3)
122 
123 /* MISC registers */
124 #define MISC_REG_BASE			SEDI_MISC_BASE
125 #define DMA_REG_BASE			SEDI_DMA_0_REG_BASE
126 #define DMA_MISC_OFFSET			0x1000
127 #define DMA_MISC_BASE			(DMA_REG_BASE + DMA_MISC_OFFSET)
128 #define MISC_CHID_CFG_REG		(DMA_MISC_BASE + 0x400)
129 #define MISC_DMA_CTL_REG(ch)		(DMA_MISC_BASE + (4 * (ch)))
130 #define MISC_SRC_FILLIN_DMA(ch)		(DMA_MISC_BASE + 0x100 + (4 * (ch)))
131 #define MISC_DST_FILLIN_DMA(ch)		(DMA_MISC_BASE + 0x200 + (4 * (ch)))
132 #define MISC_ISH_ECC_ERR_SRESP		(DMA_MISC_BASE + 0x404)
133 #define MISC_ISH_RTC_COUNTER0		(MISC_REG_BASE + 0x70)
134 #define MISC_ISH_RTC_COUNTER1		(MISC_REG_BASE + 0x74)
135 
136 /* DMA registers */
137 #define DMA_CH_REGS_SIZE		0x58
138 #define DMA_CLR_BLOCK_REG		(DMA_REG_BASE + 0x340)
139 #define DMA_CLR_ERR_REG			(DMA_REG_BASE + 0x358)
140 #define DMA_EN_REG_ADDR			(DMA_REG_BASE + 0x3A0)
141 #define DMA_EN_REG			(DMA_EN_REG_ADDR)
142 #define DMA_CFG_REG			(DMA_REG_BASE + 0x398)
143 #define DMA_PSIZE_01			(DMA_REG_BASE + 0x400)
144 #define DMA_PSIZE_CHAN0_SIZE		512
145 #define DMA_PSIZE_CHAN0_OFFSET		0
146 #define DMA_PSIZE_CHAN1_SIZE		128
147 #define DMA_PSIZE_CHAN1_OFFSET		13
148 #define DMA_PSIZE_UPDATE		BIT(26)
149 #define DMA_MAX_CHANNEL			4
150 #define DMA_SAR(chan)			(chan + 0x000)
151 #define DMA_DAR(chan)			(chan + 0x008)
152 #define DMA_LLP(chan)			(chan + 0x010)
153 #define DMA_CTL_LOW(chan)		(chan + 0x018)
154 #define DMA_CTL_HIGH(chan)		(chan + 0x018 + 0x4)
155 #define DMA_CTL_INT_ENABLE		BIT(0)
156 #define DMA_CTL_DST_TR_WIDTH_SHIFT	1
157 #define DMA_CTL_SRC_TR_WIDTH_SHIFT	4
158 #define DMA_CTL_DINC_SHIFT		7
159 #define DMA_CTL_SINC_SHIFT		9
160 #define DMA_CTL_ADDR_INC		0
161 #define DMA_CTL_DEST_MSIZE_SHIFT	11
162 #define DMA_CTL_SRC_MSIZE_SHIFT		14
163 #define DMA_CTL_TT_FC_SHIFT		20
164 #define DMA_CTL_TT_FC_M2M_DMAC		0
165 #define DMA_ENABLE			BIT(0)
166 #define DMA_CH_EN_BIT(n)		BIT(n)
167 #define DMA_CH_EN_WE_BIT(n)		BIT(8 + (n))
168 #define DMA_MAX_BLOCK_SIZE		(4096)
169 #define SRC_TR_WIDTH			2
170 #define SRC_BURST_SIZE			3
171 #define DEST_TR_WIDTH			2
172 #define DEST_BURST_SIZE			3
173 
174 /* GPIO Registers */
175 #define ISH_GPIO_BASE			SEDI_GPIO_0_REG_BASE
176 #define ISH_GPIO_GCCR			(ISH_GPIO_BASE + 0x000)
177 #define ISH_GPIO_GPLR			(ISH_GPIO_BASE + 0x004)
178 #define ISH_GPIO_GPDR			(ISH_GPIO_BASE + 0x01C)
179 #define ISH_GPIO_GPSR			(ISH_GPIO_BASE + 0x034)
180 #define ISH_GPIO_GPCR			(ISH_GPIO_BASE + 0x04C)
181 #define ISH_GPIO_GRER			(ISH_GPIO_BASE + 0x064)
182 #define ISH_GPIO_GFER			(ISH_GPIO_BASE + 0x07C)
183 #define ISH_GPIO_GFBR			(ISH_GPIO_BASE + 0x094)
184 #define ISH_GPIO_GIMR			(ISH_GPIO_BASE + 0x0AC)
185 #define ISH_GPIO_GISR			(ISH_GPIO_BASE + 0x0C4)
186 #define ISH_GPIO_GWMR			(ISH_GPIO_BASE + 0x100)
187 #define ISH_GPIO_GWSR			(ISH_GPIO_BASE + 0x118)
188 #define ISH_GPIO_GSEC			(ISH_GPIO_BASE + 0x130)
189 
190 /* SRAM control registers */
191 #define ISH_SRAM_CTRL_BASE		0x10500000
192 #define ISH_SRAM_CTRL_CSFGR		(ISH_SRAM_CTRL_BASE + 0x00)
193 #define ISH_SRAM_CTRL_INTR		(ISH_SRAM_CTRL_BASE + 0x04)
194 #define ISH_SRAM_CTRL_INTR_MASK		(ISH_SRAM_CTRL_BASE + 0x08)
195 #define ISH_SRAM_CTRL_ERASE_CTRL	(ISH_SRAM_CTRL_BASE + 0x0c)
196 #define ISH_SRAM_CTRL_ERASE_ADDR	(ISH_SRAM_CTRL_BASE + 0x10)
197 #define ISH_SRAM_CTRL_BANK_STATUS	(ISH_SRAM_CTRL_BASE + 0x2c)
198 
199 /* WDT (Watchdog Timer) Registers */
200 #define ISH_WDT_BASE			SEDI_WATCHDOG_0_REG_BASE
201 #define WDT_CONTROL			(ISH_WDT_BASE + 0x0)
202 #define WDT_RELOAD			(ISH_WDT_BASE + 0x4)
203 #define WDT_VALUES			(ISH_WDT_BASE + 0x8)
204 #define WDT_CONTROL_ENABLE_BIT		BIT(17)
205 
206 #define ISH_RST_REG			(IPC_HOST_BASE + 0x10000 + 0x44)
207 #define IPC_PIMR_CIM_SEC		(IPC_HOST_BASE + 0x10000 + 0x10)
208 #define IPC_UMA_RANGE_LOWER_1		(IPC_HOST_BASE + 0x384)
209 #define IPC_ISH2HOST_DOORBELL_ADDR	(IPC_HOST_BASE + 0x54)
210 
211 #define LAPIC_SPUR			(SEDI_LAPIC_BASE + 0x00F0)
212 #define LAPIC_EOI			(SEDI_LAPIC_BASE + 0x00B0)
213 #define LAPIC_SPUR_RESET		0xFF
214 #define LAPIC_ENABLE			0x100
215 
216 #define IOAPIC_NUM_RTES 64
217 
218 #define SEDI_VEC_RESET_PREP		112
219 #define SEDI_VEC_PMU2IOAPIC		113
220 #define SEDI_VEC_PCIEDEV		114
221 
222 /* SRAM memory definitions */
223 #define CONFIG_RAM_BASE			0xFF200000
224 #define CONFIG_RAM_SIZE			0x000A0000
225 #define CONFIG_RAM_BANK_SIZE		0x00010000
226 #define CONFIG_RAM_BANKS		(CONFIG_RAM_SIZE / CONFIG_RAM_BANK_SIZE)
227 #define CONFIG_RAM_BANK_MASK		0xFFFFF
228 #define CONFIG_RAM_BANK_TILE_MASK	(CONFIG_RAM_BANK_MASK)
229 
230 #define AON_SP_RESERVED (8)
231 
232 /* AON memory definitions */
233 #define CONFIG_AON_RAM_BASE		0xFF800000
234 #define CONFIG_AON_RAM_SIZE		0x00002000
235 #define CONFIG_AON_PERSISTENT_SIZE	0x180
236 #define CONFIG_AON_PERSISTENT_BASE	(CONFIG_AON_RAM_BASE    \
237 					 + CONFIG_AON_RAM_SIZE  \
238 					 - CONFIG_AON_PERSISTENT_SIZE)
239 
240 #endif
241