1 /*
2  * Copyright (c) 2020 ITE Corporation. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #ifndef CHIP_CHIPREGS_H
7 #define CHIP_CHIPREGS_H
8 
9 #include <sys/util.h>
10 
11 #define EC_REG_BASE_ADDR 0x00f00000
12 
13 #ifndef FALSE
14 #define FALSE   0
15 #endif
16 
17 /* TRUE can be defined as !FALSE but defining
18  * it as 1 allows it to fit into a bitfield.
19  */
20 #ifndef TRUE
21 #define TRUE    1
22 #endif
23 
24 #ifdef _ASMLANGUAGE
25 #define ECREG(x)        x
26 #else
27 
28 /*
29  * Macros for hardware registers access.
30  */
31 #define ECREG(x)		(*((volatile unsigned char *)(x)))
32 #define ECREG_u16(x)		(*((volatile unsigned short *)(x)))
33 #define ECREG_u32(x)		(*((volatile unsigned long  *)(x)))
34 
35 /*
36  * MASK operation macros
37  */
38 #define SET_MASK(reg, bit_mask)			((reg) |= (bit_mask))
39 #define CLEAR_MASK(reg, bit_mask)		((reg) &= (~(bit_mask)))
40 #define IS_MASK_SET(reg, bit_mask)		(((reg) & (bit_mask)) != 0)
41 #endif /* _ASMLANGUAGE */
42 
43 #ifndef REG_BASE_ADDR
44 #define REG_BASE_ADDR				EC_REG_BASE_ADDR
45 #endif
46 
47 /**
48  * (10XXh) Shared Memory Flash Interface Bridge (SMFI)
49  */
50 
51 /* FBIU Configuration */
52 #define FBCFG			ECREG(EC_REG_BASE_ADDR + 0x1000)
53 #define SSMC			BIT(7)
54 
55 /* Flash Programming Configuration Register*/
56 #define FPCFG			ECREG(EC_REG_BASE_ADDR + 0x1001)
57 
58 /* Memory Zone Configuration */
59 #define MZCFG			ECREG(EC_REG_BASE_ADDR + 0x1002)
60 
61 /* State Memory Zone Configuration */
62 #define SMZCFG			ECREG(EC_REG_BASE_ADDR + 0x1003)
63 
64 /* Flash EC Code Banking Select Register */
65 #define FECBSR			ECREG(EC_REG_BASE_ADDR + 0x1005)
66 
67 /* Flash Memory Size Select Registe */
68 #define FMSSR			ECREG(EC_REG_BASE_ADDR + 0x1007)
69 
70 /* Flash Memory Pre-Scale */
71 #define FMPSR			ECREG(EC_REG_BASE_ADDR + 0x1010)
72 
73 /* Shared Memory EC Control and Status */
74 #define SMECCS			ECREG(EC_REG_BASE_ADDR + 0x1020)
75 #define HOSTWA			BIT(5)
76 #define LKPRR			BIT(2)
77 
78 /* Shared Memory Host Semaphore */
79 #define SMHSR			ECREG(EC_REG_BASE_ADDR + 0x1022)
80 
81 /* FWH Flash ID Register */
82 #define FWHFIDR			ECREG(EC_REG_BASE_ADDR + 0x1030)
83 
84 /* Flash Control Register 1 */
85 #define FLHCTRL1R		ECREG(EC_REG_BASE_ADDR + 0x1031)
86 
87 /* SPI Flash Read Mode
88  * 11b: Uses “Fast Read Dual Input/Output (DIOFR)” cycle (instruction = BBh)
89  * 10b: Uses “Fast Read Dual Output (DOFR)” cycle (instruction = 3Bh)
90  * 01b: Uses “Fast Read (FREAD)” cycle (instruction = 0Bh)
91  * 00b: Uses “Read” cycle (instruction = 03h)
92  */
93 #define SPIFR1			BIT(5)
94 #define SPIFR0			BIT(4)
95 /* Serial Wait 1T */
96 #define LFSW1T			BIT(3)
97 
98 /* Flash Control Register 2 */
99 #define FLHCTRL2R		ECREG(EC_REG_BASE_ADDR + 0x1032)
100 
101 /* 256 bytes cache */
102 #define DCACHE			ECREG(EC_REG_BASE_ADDR + 0x1033)
103 
104 /* uC Control Register */
105 #define UCCTRLR			ECREG(EC_REG_BASE_ADDR + 0x1034)
106 
107 /* Host Control 2 Register */
108 #define HCTRL2R			ECREG(EC_REG_BASE_ADDR + 0x1036)
109 
110 /* HSPI Control 2 Register */
111 #define HSPICTRL2R		ECREG(EC_REG_BASE_ADDR + 0x1039)
112 
113 /* HSPI */
114 #define HSPICTRL3R		ECREG(EC_REG_BASE_ADDR + 0x103A)
115 
116 /* EC-Indirect Memory Address Register 0 */
117 #define ECINDAR0		ECREG(EC_REG_BASE_ADDR + 0x103B)
118 
119 /* EC-Indirect Memory Address Register 1 */
120 #define ECINDAR1		ECREG(EC_REG_BASE_ADDR + 0x103C)
121 
122 /* EC-Indirect Memory Address Register 2 */
123 #define ECINDAR2		ECREG(EC_REG_BASE_ADDR + 0x103D)
124 
125 /* EC-Indirect Memory Address Register 3 */
126 #define ECINDAR3		ECREG(EC_REG_BASE_ADDR + 0x103E)
127 
128 /* EC-Indirect Memory Data Register */
129 #define ECINDDR			ECREG(EC_REG_BASE_ADDR + 0x103F)
130 
131 /* Scratch SRAM 0 Address Low Byte Register */
132 #define SCRA0L			ECREG(EC_REG_BASE_ADDR + 0x1040)
133 
134 /* Scratch SRAM 0 Address Middle Byte Register */
135 #define SCRA0M			ECREG(EC_REG_BASE_ADDR + 0x1041)
136 
137 /* Scratch SRAM 0 Address High Byte Register */
138 #define SCRA0H			ECREG(EC_REG_BASE_ADDR + 0x1042)
139 
140 /* Scratch SRAM 1 Address Low Byte Register */
141 #define SCRA1L			ECREG(EC_REG_BASE_ADDR + 0x1043)
142 
143 /* Scratch SRAM 1 Address Middle Byte Register */
144 #define SCRA1M			ECREG(EC_REG_BASE_ADDR + 0x1044)
145 
146 /* Scratch SRAM 1 Address High Byte Register */
147 #define SCRA1H			ECREG(EC_REG_BASE_ADDR + 0x1045)
148 
149 /* Scratch SRAM 2 Address Low Byte Register */
150 #define SCRA2L			ECREG(EC_REG_BASE_ADDR + 0x1046)
151 
152 /* Scratch SRAM 2 Address Middle Byte Register */
153 #define SCRA2M			ECREG(EC_REG_BASE_ADDR + 0x1047)
154 
155 /* Scratch SRAM 2 Address High Byte Register */
156 #define SCRA2H			ECREG(EC_REG_BASE_ADDR + 0x1048)
157 
158 /* Scratch SRAM 3 Address Low Byte Register */
159 #define SCRA3L			ECREG(EC_REG_BASE_ADDR + 0x1049)
160 
161 /* Scratch SRAM 3 Address Middle Byte Register */
162 #define SCRA3M			ECREG(EC_REG_BASE_ADDR + 0x104A)
163 
164 /* Scratch SRAM 3 Address High Byte Register */
165 #define SCRA3H			ECREG(EC_REG_BASE_ADDR + 0x104B)
166 
167 /* Scratch SRAM 4 Address Low Byte Register */
168 #define SCRA4L			ECREG(EC_REG_BASE_ADDR + 0x104C)
169 
170 /* Scratch SRAM 4 Address Middle Byte Register */
171 #define SCRA4M			ECREG(EC_REG_BASE_ADDR + 0x104D)
172 
173 /* Scratch SRAM 4 Address High Byte Register */
174 #define SCRA4H			ECREG(EC_REG_BASE_ADDR + 0x104E)
175 
176 /* Protect 0 Base Addr Register 0 */
177 #define P0BA0R			ECREG(EC_REG_BASE_ADDR + 0x104F)
178 
179 /* Protect 0 Base Addr Register 1 */
180 #define P0BA1R			ECREG(EC_REG_BASE_ADDR + 0x1050)
181 
182 /* Protect 0 Size Register */
183 #define P0ZR			ECREG(EC_REG_BASE_ADDR + 0x1051)
184 
185 /* Protect 1 Base Addr Register 0 */
186 #define P1BA0R			ECREG(EC_REG_BASE_ADDR + 0x1052)
187 
188 /* Protect 1 Base Addr Register 1 */
189 #define P1BA1R			ECREG(EC_REG_BASE_ADDR + 0x1053)
190 
191 /* Protect 1 Size Register */
192 #define P1ZR			ECREG(EC_REG_BASE_ADDR + 0x1054)
193 
194 /* Deferred SPI Instruction */
195 #define DSINST			ECREG(EC_REG_BASE_ADDR + 0x1055)
196 
197 /* Deferred SPI Address */
198 #define DSADR1			ECREG(EC_REG_BASE_ADDR + 0x1056)
199 
200 /* Deferred SPI Address */
201 #define DSADR2			ECREG(EC_REG_BASE_ADDR + 0x1057)
202 
203 /* Host Instruction Control 1 */
204 #define HINSTC1			ECREG(EC_REG_BASE_ADDR + 0x1058)
205 #define DISSV			BIT(3)
206 #define DISS			BIT(2)
207 #define ENDPI			BIT(1)
208 #define ENDEI			BIT(0)
209 
210 /* Host Instruction Control 2 */
211 #define HINSTC2			ECREG(EC_REG_BASE_ADDR + 0x1059)
212 #define DISEID8			BIT(3)
213 #define DISEID7			BIT(2)
214 #define DISEI52			BIT(1)
215 #define DISEI20			BIT(0)
216 
217 /* Host RAM Window Control */
218 #define HRAMWC			ECREG(EC_REG_BASE_ADDR + 0x105A)
219 /* Window 0 enabled */
220 #define WINDOW0EN		BIT(0)
221 /* Window 1 enabled */
222 #define WINDOW1EN		BIT(1)
223 /* 0 : H2RAM-HLPC selected, 1 : H2RAM-HSPI selected */
224 #define H2RAMS			BIT(4)
225 
226 /* Host RAM Winodw 0 Base Address */
227 #define HRAMW0BA		ECREG(EC_REG_BASE_ADDR + 0x105B)
228 /* Host RAM Window 1 Base Address */
229 #define HRAMW1BA		ECREG(EC_REG_BASE_ADDR + 0x105C)
230 /* Host RAM Window 0 Access Allow Size */
231 #define HRAMW0AAS		ECREG(EC_REG_BASE_ADDR + 0x105D)
232 /* Host RAM Window 1 Access Allow Size */
233 #define HRAMW1AAS		ECREG(EC_REG_BASE_ADDR + 0x105E)
234 #define HOSTRAMSIZE16BYTE	0x00
235 #define HOSTRAMSIZE32BYTE	0x01
236 #define HOSTRAMSIZE64BYTE	0x02
237 #define HOSTRAMSIZE128BYTE	0x03
238 #define HOSTRAMSIZE256BYTE	0x04
239 #define HOSTRAMSIZE512BYTE	0x05
240 #define HOSTRAMSIZE1024BYTE	0x06
241 #define HOSTRAMSIZE2048BYTE	0x07
242 
243 #define CHECK64KSRAM		ECREG(EC_REG_BASE_ADDR + 0x1060)
244 #define CRC_HBYTE		ECREG(EC_REG_BASE_ADDR + 0x1061)
245 #define CRC_LBYTE		ECREG(EC_REG_BASE_ADDR + 0x1062)
246 #define FLHCTRL3R		ECREG(EC_REG_BASE_ADDR + 0x1063)
247 #define FLHCTRL4R		ECREG(EC_REG_BASE_ADDR + 0x1064)
248 #define P2BA0R			ECREG(EC_REG_BASE_ADDR + 0x1070)
249 #define P2BA1R			ECREG(EC_REG_BASE_ADDR + 0x1071)
250 #define P2ZR			ECREG(EC_REG_BASE_ADDR + 0x1072)
251 #define P3BA0R			ECREG(EC_REG_BASE_ADDR + 0x1073)
252 #define P3BA1R			ECREG(EC_REG_BASE_ADDR + 0x1074)
253 #define P3ZR			ECREG(EC_REG_BASE_ADDR + 0x1075)
254 #define HRAMW2BA		ECREG(EC_REG_BASE_ADDR + 0x1076)
255 #define HRAMW3BA		ECREG(EC_REG_BASE_ADDR + 0x1077)
256 #define HRAMW2AAS		ECREG(EC_REG_BASE_ADDR + 0x1078)
257 #define HRAMW3AAS		ECREG(EC_REG_BASE_ADDR + 0x1079)
258 #define H2RAMECSIE		ECREG(EC_REG_BASE_ADDR + 0x107A)
259 #define H2RAMECSA		ECREG(EC_REG_BASE_ADDR + 0x107B)
260 #define H2RAMHSS		ECREG(EC_REG_BASE_ADDR + 0x107C)
261 #define HPADR			ECREG(EC_REG_BASE_ADDR + 0x107E)
262 #define STCDMACR		ECREG(EC_REG_BASE_ADDR + 0x1080)
263 #define SCRA5L			ECREG(EC_REG_BASE_ADDR + 0x1081)
264 #define SCRA5M			ECREG(EC_REG_BASE_ADDR + 0x1082)
265 #define SCRA5H			ECREG(EC_REG_BASE_ADDR + 0x1083)
266 #define SCRA6L			ECREG(EC_REG_BASE_ADDR + 0x1084)
267 #define SCRA6M			ECREG(EC_REG_BASE_ADDR + 0x1085)
268 #define SCRA6H			ECREG(EC_REG_BASE_ADDR + 0x1086)
269 #define SCRA7L			ECREG(EC_REG_BASE_ADDR + 0x1087)
270 #define SCRA7M			ECREG(EC_REG_BASE_ADDR + 0x1088)
271 #define SCRA7H			ECREG(EC_REG_BASE_ADDR + 0x1089)
272 #define SCRA8L			ECREG(EC_REG_BASE_ADDR + 0x108A)
273 #define SCRA8M			ECREG(EC_REG_BASE_ADDR + 0x108B)
274 #define SCRA8H			ECREG(EC_REG_BASE_ADDR + 0x108C)
275 #define SCRA9L			ECREG(EC_REG_BASE_ADDR + 0x108D)
276 #define SCRA9M			ECREG(EC_REG_BASE_ADDR + 0x108E)
277 #define SCRA9H			ECREG(EC_REG_BASE_ADDR + 0x108F)
278 #define SCRA10L			ECREG(EC_REG_BASE_ADDR + 0x1090)
279 #define SCRA10M			ECREG(EC_REG_BASE_ADDR + 0x1091)
280 #define SCRA10H			ECREG(EC_REG_BASE_ADDR + 0x1092)
281 #define SCRA11L			ECREG(EC_REG_BASE_ADDR + 0x1093)
282 #define SCRA11M			ECREG(EC_REG_BASE_ADDR + 0x1094)
283 #define SCRA11H			ECREG(EC_REG_BASE_ADDR + 0x1095)
284 #define SCRA12L			ECREG(EC_REG_BASE_ADDR + 0x1096)
285 #define SCRA12M			ECREG(EC_REG_BASE_ADDR + 0x1097)
286 #define SCRA12H			ECREG(EC_REG_BASE_ADDR + 0x1098)
287 #define ROMARL			ECREG(EC_REG_BASE_ADDR + 0x1099)
288 #define ROMARM			ECREG(EC_REG_BASE_ADDR + 0x109A)
289 #define ROMARH			ECREG(EC_REG_BASE_ADDR + 0x109B)
290 #define SEMBARL			ECREG(EC_REG_BASE_ADDR + 0x109C)
291 #define SEMBARM			ECREG(EC_REG_BASE_ADDR + 0x109D)
292 #define SEMBARH			ECREG(EC_REG_BASE_ADDR + 0x109E)
293 #define SCRATH_SRAM		0x08
294 
295 /* --- General Control (GCTRL) --- */
296 #define IT8XXX2_GCTRL_BASE      0x00F02000
297 #define IT8XXX2_GCTRL_EIDSR     ECREG(IT8XXX2_GCTRL_BASE + 0x31)
298 
299 /**
300  *
301  * (11xxh) Interrupt controller (INTC)
302  *
303  */
304 #define ISR0			ECREG(EC_REG_BASE_ADDR + 0x3F00)
305 #define ISR1			ECREG(EC_REG_BASE_ADDR + 0x3F01)
306 #define ISR2			ECREG(EC_REG_BASE_ADDR + 0x3F02)
307 #define ISR3			ECREG(EC_REG_BASE_ADDR + 0x3F03)
308 #define ISR4			ECREG(EC_REG_BASE_ADDR + 0x3F14)
309 #define ISR5			ECREG(EC_REG_BASE_ADDR + 0x3F18)
310 #define ISR6			ECREG(EC_REG_BASE_ADDR + 0x3F1C)
311 #define ISR7			ECREG(EC_REG_BASE_ADDR + 0x3F20)
312 #define ISR8			ECREG(EC_REG_BASE_ADDR + 0x3F24)
313 #define ISR9			ECREG(EC_REG_BASE_ADDR + 0x3F28)
314 #define ISR10			ECREG(EC_REG_BASE_ADDR + 0x3F2C)
315 #define ISR11			ECREG(EC_REG_BASE_ADDR + 0x3F30)
316 #define ISR12			ECREG(EC_REG_BASE_ADDR + 0x3F34)
317 #define ISR13			ECREG(EC_REG_BASE_ADDR + 0x3F38)
318 #define ISR14			ECREG(EC_REG_BASE_ADDR + 0x3F3C)
319 #define ISR15			ECREG(EC_REG_BASE_ADDR + 0x3F40)
320 #define ISR16			ECREG(EC_REG_BASE_ADDR + 0x3F44)
321 #define ISR17			ECREG(EC_REG_BASE_ADDR + 0x3F48)
322 #define ISR18			ECREG(EC_REG_BASE_ADDR + 0x3F4C)
323 #define ISR19			ECREG(EC_REG_BASE_ADDR + 0x3F50)
324 #define ISR20			ECREG(EC_REG_BASE_ADDR + 0x3F54)
325 #define ISR21			ECREG(EC_REG_BASE_ADDR + 0x3F58)
326 #define ISR22			ECREG(EC_REG_BASE_ADDR + 0x3F5C)
327 #define ISR23			ECREG(EC_REG_BASE_ADDR + 0x3F90)
328 
329 #define IER0			ECREG(EC_REG_BASE_ADDR + 0x3F04)
330 #define IER1			ECREG(EC_REG_BASE_ADDR + 0x3F05)
331 #define IER2			ECREG(EC_REG_BASE_ADDR + 0x3F06)
332 #define IER3			ECREG(EC_REG_BASE_ADDR + 0x3F07)
333 #define IER4			ECREG(EC_REG_BASE_ADDR + 0x3F15)
334 #define IER5			ECREG(EC_REG_BASE_ADDR + 0x3F19)
335 #define IER6			ECREG(EC_REG_BASE_ADDR + 0x3F1D)
336 #define IER7			ECREG(EC_REG_BASE_ADDR + 0x3F21)
337 #define IER8			ECREG(EC_REG_BASE_ADDR + 0x3F25)
338 #define IER9			ECREG(EC_REG_BASE_ADDR + 0x3F29)
339 #define IER10			ECREG(EC_REG_BASE_ADDR + 0x3F2D)
340 #define IER11			ECREG(EC_REG_BASE_ADDR + 0x3F31)
341 #define IER12			ECREG(EC_REG_BASE_ADDR + 0x3F35)
342 #define IER13			ECREG(EC_REG_BASE_ADDR + 0x3F39)
343 #define IER14			ECREG(EC_REG_BASE_ADDR + 0x3F3D)
344 #define IER15			ECREG(EC_REG_BASE_ADDR + 0x3F41)
345 #define IER16			ECREG(EC_REG_BASE_ADDR + 0x3F45)
346 #define IER17			ECREG(EC_REG_BASE_ADDR + 0x3F49)
347 #define IER18			ECREG(EC_REG_BASE_ADDR + 0x3F4D)
348 #define IER19			ECREG(EC_REG_BASE_ADDR + 0x3F51)
349 #define IER20			ECREG(EC_REG_BASE_ADDR + 0x3F55)
350 #define IER21			ECREG(EC_REG_BASE_ADDR + 0x3F59)
351 #define IER22			ECREG(EC_REG_BASE_ADDR + 0x3F5D)
352 #define IER23			ECREG(EC_REG_BASE_ADDR + 0x3F91)
353 
354 #define IELMR0			ECREG(EC_REG_BASE_ADDR + 0x3F08)
355 #define IELMR1			ECREG(EC_REG_BASE_ADDR + 0x3F09)
356 #define IELMR2			ECREG(EC_REG_BASE_ADDR + 0x3F0A)
357 #define IELMR3			ECREG(EC_REG_BASE_ADDR + 0x3F0B)
358 #define IELMR4			ECREG(EC_REG_BASE_ADDR + 0x3F16)
359 #define IELMR5			ECREG(EC_REG_BASE_ADDR + 0x3F1A)
360 #define IELMR6			ECREG(EC_REG_BASE_ADDR + 0x3F1E)
361 #define IELMR7			ECREG(EC_REG_BASE_ADDR + 0x3F22)
362 #define IELMR8			ECREG(EC_REG_BASE_ADDR + 0x3F26)
363 #define IELMR9			ECREG(EC_REG_BASE_ADDR + 0x3F2A)
364 #define IELMR10			ECREG(EC_REG_BASE_ADDR + 0x3F2E)
365 #define IELMR11			ECREG(EC_REG_BASE_ADDR + 0x3F32)
366 #define IELMR12			ECREG(EC_REG_BASE_ADDR + 0x3F36)
367 #define IELMR13			ECREG(EC_REG_BASE_ADDR + 0x3F3A)
368 #define IELMR14			ECREG(EC_REG_BASE_ADDR + 0x3F3E)
369 #define IELMR15			ECREG(EC_REG_BASE_ADDR + 0x3F42)
370 #define IELMR16			ECREG(EC_REG_BASE_ADDR + 0x3F46)
371 #define IELMR17			ECREG(EC_REG_BASE_ADDR + 0x3F4A)
372 #define IELMR18			ECREG(EC_REG_BASE_ADDR + 0x3F4E)
373 #define IELMR19			ECREG(EC_REG_BASE_ADDR + 0x3F52)
374 #define IELMR20			ECREG(EC_REG_BASE_ADDR + 0x3F56)
375 #define IELMR21			ECREG(EC_REG_BASE_ADDR + 0x3F5A)
376 #define IELMR22			ECREG(EC_REG_BASE_ADDR + 0x3F5E)
377 #define IELMR23			ECREG(EC_REG_BASE_ADDR + 0x3F92)
378 
379 #define IPOLR0			ECREG(EC_REG_BASE_ADDR + 0x3F0C)
380 #define IPOLR1			ECREG(EC_REG_BASE_ADDR + 0x3F0D)
381 #define IPOLR2			ECREG(EC_REG_BASE_ADDR + 0x3F0E)
382 #define IPOLR3			ECREG(EC_REG_BASE_ADDR + 0x3F0F)
383 #define IPOLR4			ECREG(EC_REG_BASE_ADDR + 0x3F17)
384 #define IPOLR5			ECREG(EC_REG_BASE_ADDR + 0x3F1B)
385 #define IPOLR6			ECREG(EC_REG_BASE_ADDR + 0x3F1F)
386 #define IPOLR7			ECREG(EC_REG_BASE_ADDR + 0x3F23)
387 #define IPOLR8			ECREG(EC_REG_BASE_ADDR + 0x3F27)
388 #define IPOLR9			ECREG(EC_REG_BASE_ADDR + 0x3F2B)
389 #define IPOLR10			ECREG(EC_REG_BASE_ADDR + 0x3F2F)
390 #define IPOLR11			ECREG(EC_REG_BASE_ADDR + 0x3F33)
391 #define IPOLR12			ECREG(EC_REG_BASE_ADDR + 0x3F37)
392 #define IPOLR13			ECREG(EC_REG_BASE_ADDR + 0x3F3B)
393 #define IPOLR14			ECREG(EC_REG_BASE_ADDR + 0x3F3F)
394 #define IPOLR15			ECREG(EC_REG_BASE_ADDR + 0x3F43)
395 #define IPOLR16			ECREG(EC_REG_BASE_ADDR + 0x3F47)
396 #define IPOLR17			ECREG(EC_REG_BASE_ADDR + 0x3F4B)
397 #define IPOLR18			ECREG(EC_REG_BASE_ADDR + 0x3F4F)
398 #define IPOLR19			ECREG(EC_REG_BASE_ADDR + 0x3F53)
399 #define IPOLR20			ECREG(EC_REG_BASE_ADDR + 0x3F57)
400 #define IPOLR21			ECREG(EC_REG_BASE_ADDR + 0x3F5B)
401 #define IPOLR22			ECREG(EC_REG_BASE_ADDR + 0x3F5F)
402 #define IPOLR23			ECREG(EC_REG_BASE_ADDR + 0x3F93)
403 
404 #define IVECT			ECREG(EC_REG_BASE_ADDR + 0x3F10)
405 
406 /**
407  *
408  * (12xxh) EC Access to ost Controlled Modules (EC2I Bridge)
409  *
410  */
411 #define IHIOA			ECREG(EC_REG_BASE_ADDR + 0x1200)
412 #define IHD			ECREG(EC_REG_BASE_ADDR + 0x1201)
413 #define LSIOHA			ECREG(EC_REG_BASE_ADDR + 0x1202)
414 #define SIOLV			ECREG(EC_REG_BASE_ADDR + 0x1203)
415 #define IBMAE			ECREG(EC_REG_BASE_ADDR + 0x1204)
416 #define IBCTL			ECREG(EC_REG_BASE_ADDR + 0x1205)
417 
418 /* Lock Super I/O Host Access Register */
419 #define LKCFG			BIT(0)
420 
421 /* Super I/O Access Lock Violation Register */
422 #define CFGLV			BIT(0)
423 
424 /* EC to I-Bus Modules Access Enable Register */
425 #define SWUCAE			BIT(2)
426 #define CFGAE			BIT(0)
427 
428 /* I-Bus Control Register */
429 #define CWIB			BIT(2)
430 #define CRIB			BIT(1)
431 #define CSAE			BIT(0)
432 
433 /**
434  *
435  * (13xxh) Keyboard Controller (KBC)
436  *
437  */
438 #define KBHICR			ECREG(EC_REG_BASE_ADDR + 0x1300)
439 #define KBIRQR			ECREG(EC_REG_BASE_ADDR + 0x1302)
440 #define KBHISR			ECREG(EC_REG_BASE_ADDR + 0x1304)
441 #define KBHIKDOR		ECREG(EC_REG_BASE_ADDR + 0x1306)
442 #define KBHIMDOR		ECREG(EC_REG_BASE_ADDR + 0x1308)
443 #define KBHIDIR			ECREG(EC_REG_BASE_ADDR + 0x130A)
444 
445 /* KBC Host Interface Control Register*/
446 #define PM1ICIE			BIT(6)
447 #define PM1OCIE			BIT(5)
448 #define PM1HIE			BIT(4)
449 #define IBFCIE			BIT(3)
450 #define OBECIE			BIT(2)
451 #define OBFMIE			BIT(1)
452 #define OBFKIE			BIT(0)
453 
454 /* KBC Interrupt Control Register */
455 #define IRQNP			BIT(6)
456 #define IRQ11B			BIT(2)
457 #define IRQ12B			BIT(1)
458 #define IRQ1B			BIT(0)
459 
460 /* KBC Host Interface Keyboard/Mouse Status Register */
461 #define PARE			BIT(7)
462 #define GTIM			BIT(6)
463 #define AOBF			BIT(5)
464 #define KEYL			BIT(4)
465 #define C_D			BIT(3)
466 #define SYSF			BIT(2)
467 #define IBF			BIT(1)
468 #define OBF			BIT(0)
469 
470 /**
471  *
472  * (14xxh) System Wake-Up Control (SWUC)
473  *
474  */
475 #define SWCTL1			ECREG(EC_REG_BASE_ADDR + 0x1400)
476 #define SWCTL2			ECREG(EC_REG_BASE_ADDR + 0x1402)
477 #define SWCTL3			ECREG(EC_REG_BASE_ADDR + 0x1404)
478 #define SWCBALR			ECREG(EC_REG_BASE_ADDR + 0x1408)
479 #define SWCBAHR			ECREG(EC_REG_BASE_ADDR + 0x140A)
480 #define SWCIER			ECREG(EC_REG_BASE_ADDR + 0x140C)
481 #define SWCHSTR			ECREG(EC_REG_BASE_ADDR + 0x140E)
482 #define SWCHIER			ECREG(EC_REG_BASE_ADDR + 0x1410)
483 
484 /**
485  *
486  * (14XXh) ISO14443 PICC Register
487  *
488  */
489 #define PICC_BASE_ADDR		(EC_REG_BASE_ADDR + 0x1400)
490 #define PATQA0SR		ECREG(EC_REG_BASE_ADDR + 0x1400)
491 #define PATQA1SR		ECREG(EC_REG_BASE_ADDR + 0x1401)
492 #define PSAKSR			ECREG(EC_REG_BASE_ADDR + 0x1402)
493 #define PTRRR			ECREG(EC_REG_BASE_ADDR + 0x1403)
494 #define PFDTA1R			ECREG(EC_REG_BASE_ADDR + 0x141E)
495 #define PFDTA2R			ECREG(EC_REG_BASE_ADDR + 0x141F)
496 #define PACCR			ECREG(EC_REG_BASE_ADDR + 0x1404)
497 #define PIR			ECREG(EC_REG_BASE_ADDR + 0x1405)
498 #define PICC_HF_ENABLE		BIT(5)
499 #define PICC_HF_DISABLE		BIT(4)
500 #define PICC_DATA_ERROR		BIT(3)
501 #define PICC_RX_DONE		BIT(2)
502 #define PICC_TX_DONE		BIT(1)
503 #define PICC_ANTI_COLL_DONE	BIT(0)
504 #define PIMR			ECREG(EC_REG_BASE_ADDR + 0x1406)
505 #define PMCR			ECREG(EC_REG_BASE_ADDR + 0x1407)
506 #define PTXCR			ECREG(EC_REG_BASE_ADDR + 0x1408)
507 #define PRAMBA0R		ECREG(EC_REG_BASE_ADDR + 0x140A)
508 #define PRAMBA1R		ECREG(EC_REG_BASE_ADDR + 0x140B)
509 #define PTSR			ECREG(EC_REG_BASE_ADDR + 0x140C)
510 #define PRTC0R			ECREG(EC_REG_BASE_ADDR + 0x140E)
511 #define PRTC1R			ECREG(EC_REG_BASE_ADDR + 0x140F)
512 #define PUID0R			ECREG(EC_REG_BASE_ADDR + 0x1410)
513 #define PUID0R_ADDR		(PICC_BASE_ADDR + 0x10)
514 #define PUID1R			ECREG(EC_REG_BASE_ADDR + 0x1411)
515 #define PUID2R			ECREG(EC_REG_BASE_ADDR + 0x1412)
516 #define PUID3R			ECREG(EC_REG_BASE_ADDR + 0x1413)
517 #define PUID4R			ECREG(EC_REG_BASE_ADDR + 0x1414)
518 #define PUID5R			ECREG(EC_REG_BASE_ADDR + 0x1415)
519 #define PUID6R			ECREG(EC_REG_BASE_ADDR + 0x1416)
520 #define PUID7R			ECREG(EC_REG_BASE_ADDR + 0x1417)
521 #define PUID8R			ECREG(EC_REG_BASE_ADDR + 0x1418)
522 #define PUID9R			ECREG(EC_REG_BASE_ADDR + 0x1419)
523 #define PDER			ECREG(EC_REG_BASE_ADDR + 0x141A)
524 #define PRC0R			ECREG(EC_REG_BASE_ADDR + 0x141C)
525 #define PRC1R			ECREG(EC_REG_BASE_ADDR + 0x141D)
526 
527 /**
528  *
529  * (15xxh) Power Management Channel (PMC)
530  *
531  */
532 /* PM1 */
533 #define PM1STS			ECREG(EC_REG_BASE_ADDR + 0x1500)
534 #define PM1DO			ECREG(EC_REG_BASE_ADDR + 0x1501)
535 #define PM1DOSCI		ECREG(EC_REG_BASE_ADDR + 0x1502)
536 #define PM1DOSMI		ECREG(EC_REG_BASE_ADDR + 0x1503)
537 #define PM1DI			ECREG(EC_REG_BASE_ADDR + 0x1504)
538 #define PM1DISCI		ECREG(EC_REG_BASE_ADDR + 0x1505)
539 #define PM1CTL			ECREG(EC_REG_BASE_ADDR + 0x1506)
540 #define PM1IC			ECREG(EC_REG_BASE_ADDR + 0x1507)
541 #define PM1IE			ECREG(EC_REG_BASE_ADDR + 0x1508)
542 /* PM2 */
543 #define PM2STS			ECREG(EC_REG_BASE_ADDR + 0x1510)
544 #define PM2DO			ECREG(EC_REG_BASE_ADDR + 0x1511)
545 #define PM2DOSCI		ECREG(EC_REG_BASE_ADDR + 0x1512)
546 #define PM2DOSMI		ECREG(EC_REG_BASE_ADDR + 0x1513)
547 #define PM2DI			ECREG(EC_REG_BASE_ADDR + 0x1514)
548 #define PM2DISCI		ECREG(EC_REG_BASE_ADDR + 0x1515)
549 #define PM2CTL			ECREG(EC_REG_BASE_ADDR + 0x1516)
550 #define PM2IC			ECREG(EC_REG_BASE_ADDR + 0x1517)
551 #define PM2IE			ECREG(EC_REG_BASE_ADDR + 0x1518)
552 /* Mailbox */
553 #define MBXCTRL			ECREG(EC_REG_BASE_ADDR + 0x1519)
554 /* 16-byte PMC2EX Mailbox 0 ~ Mailbox 15 */
555 #define MBXEC_00		ECREG(EC_REG_BASE_ADDR + 0x15F0)
556 #define MBXEC_01		ECREG(EC_REG_BASE_ADDR + 0x15F1)
557 #define MBXEC_02		ECREG(EC_REG_BASE_ADDR + 0x15F2)
558 #define MBXEC_03		ECREG(EC_REG_BASE_ADDR + 0x15F3)
559 #define MBXEC_04		ECREG(EC_REG_BASE_ADDR + 0x15F4)
560 #define MBXEC_05		ECREG(EC_REG_BASE_ADDR + 0x15F5)
561 #define MBXEC_06		ECREG(EC_REG_BASE_ADDR + 0x15F6)
562 #define MBXEC_07		ECREG(EC_REG_BASE_ADDR + 0x15F7)
563 #define MBXEC_08		ECREG(EC_REG_BASE_ADDR + 0x15F8)
564 #define MBXEC_09		ECREG(EC_REG_BASE_ADDR + 0x15F9)
565 #define MBXEC_10		ECREG(EC_REG_BASE_ADDR + 0x15FA)
566 #define MBXEC_11		ECREG(EC_REG_BASE_ADDR + 0x15FB)
567 #define MBXEC_12		ECREG(EC_REG_BASE_ADDR + 0x15FC)
568 #define MBXEC_13		ECREG(EC_REG_BASE_ADDR + 0x15FD)
569 #define MBXEC_14		ECREG(EC_REG_BASE_ADDR + 0x15FE)
570 #define MBXEC_15		ECREG(EC_REG_BASE_ADDR + 0x15FF)
571 #define PM3STS			ECREG(EC_REG_BASE_ADDR + 0x1520)
572 #define PM3DO			ECREG(EC_REG_BASE_ADDR + 0x1521)
573 #define PM3DI			ECREG(EC_REG_BASE_ADDR + 0x1522)
574 #define PM3CTL			ECREG(EC_REG_BASE_ADDR + 0x1523)
575 #define PM3IC			ECREG(EC_REG_BASE_ADDR + 0x1524)
576 #define PM3IE			ECREG(EC_REG_BASE_ADDR + 0x1525)
577 #define PM4STS			ECREG(EC_REG_BASE_ADDR + 0x1530)
578 #define PM4DO			ECREG(EC_REG_BASE_ADDR + 0x1531)
579 #define PM4DI			ECREG(EC_REG_BASE_ADDR + 0x1532)
580 #define PM4CTL			ECREG(EC_REG_BASE_ADDR + 0x1533)
581 #define PM4IC			ECREG(EC_REG_BASE_ADDR + 0x1534)
582 #define PM4IE			ECREG(EC_REG_BASE_ADDR + 0x1535)
583 #define PM5STS			ECREG(EC_REG_BASE_ADDR + 0x1540)
584 #define PM5DO			ECREG(EC_REG_BASE_ADDR + 0x1541)
585 #define PM5DI			ECREG(EC_REG_BASE_ADDR + 0x1542)
586 #define PM5CTL			ECREG(EC_REG_BASE_ADDR + 0x1543)
587 #define PM5IC			ECREG(EC_REG_BASE_ADDR + 0x1544)
588 #define PM5IE			ECREG(EC_REG_BASE_ADDR + 0x1545)
589 
590 /* PM Status Register */
591 #define SMIEVT			BIT(6)
592 #define SCIEVT			BIT(5)
593 #define BURST			BIT(4)
594 #define P_C_D			BIT(3)
595 #define P_IBF			BIT(1)
596 #define P_OBF			BIT(0)
597 
598 /* PM Control */
599 #define APM			BIT(7)
600 #define SCINP			BIT(6)
601 #define OBEIE			BIT(1)
602 #define IBFIE			BIT(0)
603 
604 /* PM Interrupt Control */
605 #define SMINP			BIT(6)
606 #define SCIB			BIT(2)
607 #define SMIB			BIT(1)
608 #define IRQB			BIT(0)
609 
610 /* PM Interrupt Enable */
611 #define HWSMIEN			BIT(5)
612 #define HWSCIEN			BIT(4)
613 #define HWIRQEN			BIT(3)
614 #define SMIEN			BIT(2)
615 #define SCIEN			BIT(1)
616 #define IRQEN			BIT(0)
617 
618 /* PM Interrupt Enable */
619 #define MBXEN			BIT(7)
620 
621 /**
622  *
623  * (16XXh) General Purpose I/O Control Register
624  *
625  */
626 /* GPIO data register */
627 #define GCR			ECREG(EC_REG_BASE_ADDR + 0x1600)
628 #define GFLE			BIT(7)
629 #define WUI7EN			BIT(6)
630 #define WUI6EN			BIT(5)
631 #define LPCRSTEN_GPB7		BIT(2)
632 #define LPCRSTEN_GPD2		BIT(1)
633 
634 #define GCR1			ECREG(EC_REG_BASE_ADDR + 0x16F0)
635 #define SPICTRL_0		BIT(4)
636 #define SPICTRL_1		BIT(5)
637 #define SSSPIBP			BIT(6)
638 #define SPICTRL_2		BIT(7)
639 
640 #define GCR2			ECREG(EC_REG_BASE_ADDR + 0x16F1)
641 #define CK32OE			BIT(6)
642 #define SMB3E			BIT(5)
643 #define PECIE			BIT(4)
644 
645 #define GCR3			ECREG(EC_REG_BASE_ADDR + 0x16F2)
646 #define GCR4			ECREG(EC_REG_BASE_ADDR + 0x16F3)
647 #define GCR5			ECREG(EC_REG_BASE_ADDR + 0x16F4)
648 #define GCR6			ECREG(EC_REG_BASE_ADDR + 0x16F5)
649 #define GCR7			ECREG(EC_REG_BASE_ADDR + 0x16F6)
650 #define GCR8			ECREG(EC_REG_BASE_ADDR + 0x16F7)
651 #define GCR9			ECREG(EC_REG_BASE_ADDR + 0x16F8)
652 #define GCR10			ECREG(EC_REG_BASE_ADDR + 0x16F9)
653 #define GCR11			ECREG(EC_REG_BASE_ADDR + 0x16FA)
654 #define GCR12			ECREG(EC_REG_BASE_ADDR + 0x16FB)
655 #define GCR13			ECREG(EC_REG_BASE_ADDR + 0x16FC)
656 #define GCR14			ECREG(EC_REG_BASE_ADDR + 0x16FD)
657 #define GCR15			ECREG(EC_REG_BASE_ADDR + 0x16FE)
658 #define GCR16			ECREG(EC_REG_BASE_ADDR + 0x16E0)
659 #define GCR17			ECREG(EC_REG_BASE_ADDR + 0x16E1)
660 #define GCR18			ECREG(EC_REG_BASE_ADDR + 0x16E2)
661 #define GCR19			ECREG(EC_REG_BASE_ADDR + 0x16E4)
662 #define GCR20			ECREG(EC_REG_BASE_ADDR + 0x16E5)
663 #define GCR21			ECREG(EC_REG_BASE_ADDR + 0x16E6)
664 
665 /*
666  * TODO: use pinmux driver to enable uart function so we can remove these
667  * registers' declaration.
668  */
669 /* GPIO control register */
670 #define GPCRB0			ECREG(EC_REG_BASE_ADDR + 0x1618)
671 #define GPCRB1			ECREG(EC_REG_BASE_ADDR + 0x1619)
672 #define GPCRD5			ECREG(EC_REG_BASE_ADDR + 0x162D)
673 #define GPCRE5			ECREG(EC_REG_BASE_ADDR + 0x1635)
674 #define GPCRF3			ECREG(EC_REG_BASE_ADDR + 0x163B)
675 #define GPCRF4			ECREG(EC_REG_BASE_ADDR + 0x163C)
676 #define GPCRF5			ECREG(EC_REG_BASE_ADDR + 0x163D)
677 #define GPCRH1			ECREG(EC_REG_BASE_ADDR + 0x1649)
678 #define GPCRH2			ECREG(EC_REG_BASE_ADDR + 0x164A)
679 #define GPCRI7			ECREG(EC_REG_BASE_ADDR + 0x1657)
680 
681 /* Port Data Mirror Register */
682 #define GPDMRA			ECREG(EC_REG_BASE_ADDR + 0x1661)
683 #define GPDMRB			ECREG(EC_REG_BASE_ADDR + 0x1662)
684 #define GPDMRC			ECREG(EC_REG_BASE_ADDR + 0x1663)
685 #define GPDMRD			ECREG(EC_REG_BASE_ADDR + 0x1664)
686 #define GPDMRE			ECREG(EC_REG_BASE_ADDR + 0x1665)
687 #define GPDMRF			ECREG(EC_REG_BASE_ADDR + 0x1666)
688 #define GPDMRG			ECREG(EC_REG_BASE_ADDR + 0x1667)
689 #define GPDMRH			ECREG(EC_REG_BASE_ADDR + 0x1668)
690 #define GPDMRI			ECREG(EC_REG_BASE_ADDR + 0x1669)
691 #define GPDMRJ			ECREG(EC_REG_BASE_ADDR + 0x166A)
692 #define GPDMRM			ECREG(EC_REG_BASE_ADDR + 0x166D)
693 
694 #define GPCR_PORT_PIN_MODE_INPUT    BIT(7)
695 #define GPCR_PORT_PIN_MODE_OUTPUT   BIT(6)
696 #define GPCR_PORT_PIN_MODE_PULLUP   BIT(2)
697 #define GPCR_PORT_PIN_MODE_PULLDOWN BIT(1)
698 
699 /**
700  *
701  * (17XXh) PS/2 Interface Register
702  *
703  */
704 #define PSCTL1			ECREG(EC_REG_BASE_ADDR + 0x1700)
705 #define PSCTL2			ECREG(EC_REG_BASE_ADDR + 0x1701)
706 #define PSCTL3			ECREG(EC_REG_BASE_ADDR + 0x1702)
707 #define PSINT1			ECREG(EC_REG_BASE_ADDR + 0x1704)
708 #define PSINT2			ECREG(EC_REG_BASE_ADDR + 0x1705)
709 #define PSINT3			ECREG(EC_REG_BASE_ADDR + 0x1706)
710 #define PSSTS1			ECREG(EC_REG_BASE_ADDR + 0x1708)
711 #define PSSTS2			ECREG(EC_REG_BASE_ADDR + 0x1709)
712 #define PSSTS3			ECREG(EC_REG_BASE_ADDR + 0x170A)
713 #define PSDAT1			ECREG(EC_REG_BASE_ADDR + 0x170C)
714 #define PSDAT2			ECREG(EC_REG_BASE_ADDR + 0x170D)
715 #define PSDAT3			ECREG(EC_REG_BASE_ADDR + 0x170E)
716 
717 /* PS/2 Control Register */
718 #define DCEN			BIT(4)
719 #define TRMS			BIT(3)
720 #define PSHE			BIT(2)
721 #define CCLK			BIT(1)
722 #define CDAT			BIT(0)
723 
724 /* PS/2 Interrupt Control Register */
725 #define TDIE			BIT(2)
726 #define SIE			BIT(1)
727 #define SMIE			BIT(0)
728 
729 /* PS/2 Status Register */
730 #define FER			BIT(5)
731 #define PER			BIT(4)
732 #define TDS			BIT(3)
733 #define SS			BIT(2)
734 #define CLS			BIT(1)
735 #define DLS			BIT(0)
736 
737 /*
738  * IT8XXX2 register structure size/offset checking macro function to mitigate
739  * the risk of unexpected compiling results.
740  */
741 #define IT8XXX2_REG_SIZE_CHECK(reg_def, size) \
742 	BUILD_ASSERT(sizeof(struct reg_def) == size, \
743 		"Failed in size check of register structure!")
744 #define IT8XXX2_REG_OFFSET_CHECK(reg_def, member, offset) \
745 	BUILD_ASSERT(offsetof(struct reg_def, member) == offset, \
746 		"Failed in offset check of register structure member!")
747 
748 /**
749  *
750  * (18xxh) PWM & SmartAuto Fan Control (PWM)
751  *
752  */
753 #ifndef __ASSEMBLER__
754 struct pwm_it8xxx2_regs {
755 	/* 0x000: Channel0 Clock Prescaler */
756 	volatile uint8_t C0CPRS;
757 	/* 0x001: Cycle Time0 */
758 	volatile uint8_t CTR;
759 	/* 0x002~0x00A: Reserved1 */
760 	volatile uint8_t Reserved1[9];
761 	/* 0x00B: Prescaler Clock Frequency Select */
762 	volatile uint8_t PCFSR;
763 	/* 0x00C~0x00F: Reserved2 */
764 	volatile uint8_t Reserved2[4];
765 	/* 0x010: Cycle Time1 MSB */
766 	volatile uint8_t CTR1M;
767 	/* 0x011~0x022: Reserved3 */
768 	volatile uint8_t Reserved3[18];
769 	/* 0x023: PWM Clock Control */
770 	volatile uint8_t ZTIER;
771 	/* 0x024~0x026: Reserved4 */
772 	volatile uint8_t Reserved4[3];
773 	/* 0x027: Channel4 Clock Prescaler */
774 	volatile uint8_t C4CPRS;
775 	/* 0x028: Channel4 Clock Prescaler MSB */
776 	volatile uint8_t C4MCPRS;
777 	/* 0x029~0x02A: Reserved5 */
778 	volatile uint8_t Reserved5[2];
779 	/* 0x02B: Channel6 Clock Prescaler */
780 	volatile uint8_t C6CPRS;
781 	/* 0x02C: Channel6 Clock Prescaler MSB */
782 	volatile uint8_t C6MCPRS;
783 	/* 0x02D: Channel7 Clock Prescaler */
784 	volatile uint8_t C7CPRS;
785 	/* 0x02E: Channel7 Clock Prescaler MSB */
786 	volatile uint8_t C7MCPRS;
787 	/* 0x02F~0x040: Reserved6 */
788 	volatile uint8_t reserved6[18];
789 	/* 0x041: Cycle Time1 */
790 	volatile uint8_t CTR1;
791 	/* 0x042: Cycle Time2 */
792 	volatile uint8_t CTR2;
793 	/* 0x043: Cycle Time3 */
794 	volatile uint8_t CTR3;
795 };
796 #endif /* !__ASSEMBLER__ */
797 
798 /* PWM register fields */
799 /* 0x023: PWM Clock Control */
800 #define IT8XXX2_PWM_PCCE		BIT(1)
801 
802 /**
803  *
804  * (19xxh) Analog to Digital converter (ADC)
805  *
806  */
807 #define ADCECR			ECREG(EC_REG_BASE_ADDR + 0x1901)
808 #define ADCCSR			ECREG(EC_REG_BASE_ADDR + 0x1902)
809 #define ADCGC0R			ECREG(EC_REG_BASE_ADDR + 0x1903)
810 #define ADCGC1R			ECREG(EC_REG_BASE_ADDR + 0x1904)
811 #define ADCCXC_BASE		(EC_REG_BASE_ADDR + 0x1905)
812 #define ADCCXC0R(ch)		ECREG(ADCCxC_BASE + ((ch) * 2))
813 #define ADCCXC1R(ch)		ECREG(ADCCxC_BASE + 1 + ((ch) * 2))
814 #define ADCDMALBAR		ECREG(EC_REG_BASE_ADDR + 0x190D)
815 #define ADCDMAHBAR		ECREG(EC_REG_BASE_ADDR + 0x190E)
816 #define ADCDMABLR		ECREG(EC_REG_BASE_ADDR + 0x190F)
817 #define ADCDLR			ECREG(EC_REG_BASE_ADDR + 0x1910)
818 #define ADCIMR			ECREG(EC_REG_BASE_ADDR + 0x1911)
819 #define ADCISR			ECREG(EC_REG_BASE_ADDR + 0x1912)
820 #define ADCCxS_BASE		(EC_REG_BASE_ADDR + 0x1950)
821 #define ADCCXD0R(ch)		ECREG(ADCCxS_BASE0 + ((ch) * 2))
822 #define ADCCXD1R(ch)		ECREG(ADCCxS_BASE + 1 + ((ch) * 2))
823 
824 /* ADC Status Register */
825 #define FIRHIACC		BIT(7)
826 #define AINITB			BIT(3)
827 #define ADCPS			BIT(2)
828 #define DOVE			BIT(1)
829 #define EOCE			BIT(0)
830 
831 /* ADC Configuration Register */
832 #define DFILEN			BIT(5)
833 #define INTECEN			BIT(2)
834 #define ADCEN			BIT(0)
835 
836 /* Voltage Channel Control Register */
837 #define DATVAL			BIT(7)
838 #define INTDVEN			BIT(5)
839 
840 /* Calibration Data Control Register */
841 #define AHCE			BIT(7)
842 #define HCDATVAL		BIT(5)
843 #define GCDATVAL		BIT(4)
844 #define VHSCKE			BIT(1)
845 #define GECKE			BIT(0)
846 
847 /**
848  *
849  * (1Axxh) Real Time Clock (RTC)
850  *
851  */
852 #define SECREG			ECREG(EC_REG_BASE_ADDR + 0x1A00)
853 #define SECA1REG		ECREG(EC_REG_BASE_ADDR + 0x1A01)
854 #define MINREG			ECREG(EC_REG_BASE_ADDR + 0x1A02)
855 #define MINA1REG		ECREG(EC_REG_BASE_ADDR + 0x1A03)
856 #define HRREG			ECREG(EC_REG_BASE_ADDR + 0x1A04)
857 #define HRA1REG			ECREG(EC_REG_BASE_ADDR + 0x1A05)
858 #define DOWREG			ECREG(EC_REG_BASE_ADDR + 0x1A06)
859 #define DOMREG			ECREG(EC_REG_BASE_ADDR + 0x1A07)
860 #define MONREG			ECREG(EC_REG_BASE_ADDR + 0x1A08)
861 #define YRREG			ECREG(EC_REG_BASE_ADDR + 0x1A09)
862 #define CTLREGA			ECREG(EC_REG_BASE_ADDR + 0x1A0A)
863 #define CTLREGB			ECREG(EC_REG_BASE_ADDR + 0x1A0B)
864 #define CTLREGC			ECREG(EC_REG_BASE_ADDR + 0x1A0C)
865 #define DOMA1REG		ECREG(EC_REG_BASE_ADDR + 0x1A0D)
866 #define MONA1REG		ECREG(EC_REG_BASE_ADDR + 0x1A0E)
867 #define SECA2REG		ECREG(EC_REG_BASE_ADDR + 0x1A0F)
868 #define MINA2REG		ECREG(EC_REG_BASE_ADDR + 0x1A10)
869 #define HRA2REG			ECREG(EC_REG_BASE_ADDR + 0x1A11)
870 #define DOMA2REG		ECREG(EC_REG_BASE_ADDR + 0x1A12)
871 #define MONA2REG		ECREG(EC_REG_BASE_ADDR + 0x1A13)
872 #define PORSREGA		ECREG(EC_REG_BASE_ADDR + 0x1A14)
873 #define PORSREGB		ECREG(EC_REG_BASE_ADDR + 0x1A15)
874 
875 /* --- Wake-Up Control (WUC) --- */
876 #define IT8XXX2_WUC_BASE   0x00F01B00
877 
878 /* TODO: should a defined interface for configuring wake-up interrupts */
879 #define IT8XXX2_WUC_WUEMR1 (IT8XXX2_WUC_BASE + 0x00)
880 #define IT8XXX2_WUC_WUEMR3 (IT8XXX2_WUC_BASE + 0x02)
881 #define IT8XXX2_WUC_WUEMR5 (IT8XXX2_WUC_BASE + 0x0c)
882 #define IT8XXX2_WUC_WUESR1 (IT8XXX2_WUC_BASE + 0x04)
883 #define IT8XXX2_WUC_WUESR3 (IT8XXX2_WUC_BASE + 0x06)
884 #define IT8XXX2_WUC_WUESR5 (IT8XXX2_WUC_BASE + 0x0d)
885 #define IT8XXX2_WUC_WUENR3 (IT8XXX2_WUC_BASE + 0x0a)
886 #define IT8XXX2_WUC_WUBEMR1 (IT8XXX2_WUC_BASE + 0x3c)
887 #define IT8XXX2_WUC_WUBEMR5 (IT8XXX2_WUC_BASE + 0x0f)
888 
889 /**
890  *
891  * (1Cxxh) SMBus Interface (SMB)
892  *
893  */
894 #define HOSTA_A			ECREG(EC_REG_BASE_ADDR + 0x1C40)
895 #define HOSTA_B			ECREG(EC_REG_BASE_ADDR + 0x1C80)
896 #define HOSTA_C			ECREG(EC_REG_BASE_ADDR + 0x1CC0)
897 #define HOSTA_BDS		BIT(7)
898 #define HOSTA_TMOE		BIT(6)
899 #define HOSTA_NACK		BIT(5)
900 #define HOSTA_FAIL		BIT(4)
901 #define HOSTA_BSER		BIT(3)
902 #define HOSTA_DVER		BIT(2)
903 #define HOSTA_FINTR		BIT(1)
904 #define HOSTA_HOBY		BIT(0)
905 #define HOSTA_ANY_ERROR		(HOSTA_DVER | HOSTA_BSER | \
906 				HOSTA_FAIL | HOSTA_NACK | HOSTA_TMOE)
907 #define HOSTA_NEXT_BYTE		HOSTA_BDS
908 #define HOSTA_ALL_WC_BIT		(HOSTA_FINTR | \
909 				HOSTA_ANY_ERROR | HOSTA_BDS)
910 
911 #define HOCTL_A			ECREG(EC_REG_BASE_ADDR + 0x1C41)
912 #define HOCTL_B			ECREG(EC_REG_BASE_ADDR + 0x1C81)
913 #define HOCTL_C			ECREG(EC_REG_BASE_ADDR + 0x1CC1)
914 #define HOCTL_PEC_EN		BIT(7)
915 #define HOCTL_SRT		BIT(6)
916 #define HOCTL_LABY		BIT(5)
917 #define HOCTL_SMCD2		BIT(4)
918 #define HOCTL_SMCD1		BIT(3)
919 #define HOCTL_SMCD0		BIT(2)
920 #define HOCTL_KILL		BIT(1)
921 #define HOCTL_INTREN		BIT(0)
922 
923 #define HOCMD_A			ECREG(EC_REG_BASE_ADDR + 0x1C42)
924 #define HOCMD_B			ECREG(EC_REG_BASE_ADDR + 0x1C82)
925 #define HOCMD_C			ECREG(EC_REG_BASE_ADDR + 0x1CC2)
926 #define TRASLA_A		ECREG(EC_REG_BASE_ADDR + 0x1C43)
927 #define TRASLA_B		ECREG(EC_REG_BASE_ADDR + 0x1C83)
928 #define TRASLA_C		ECREG(EC_REG_BASE_ADDR + 0x1CC3)
929 #define D0REG_A			ECREG(EC_REG_BASE_ADDR + 0x1C44)
930 #define D0REG_B			ECREG(EC_REG_BASE_ADDR + 0x1C84)
931 #define D0REG_C			ECREG(EC_REG_BASE_ADDR + 0x1CC4)
932 #define D1REG_A			ECREG(EC_REG_BASE_ADDR + 0x1C45)
933 #define D1REG_B			ECREG(EC_REG_BASE_ADDR + 0x1C85)
934 #define D1REG_C			ECREG(EC_REG_BASE_ADDR + 0x1CC5)
935 #define HOBDB_A			ECREG(EC_REG_BASE_ADDR + 0x1C46)
936 #define HOBDB_B			ECREG(EC_REG_BASE_ADDR + 0x1C86)
937 #define HOBDB_C			ECREG(EC_REG_BASE_ADDR + 0x1CC6)
938 #define PECERC_A		ECREG(EC_REG_BASE_ADDR + 0x1C47)
939 #define PECERC_B		ECREG(EC_REG_BASE_ADDR + 0x1C87)
940 #define PECERC_C		ECREG(EC_REG_BASE_ADDR + 0x1CC7)
941 #define RESLADR_A		ECREG(EC_REG_BASE_ADDR + 0x1C48)
942 #define RESLADR_B		ECREG(EC_REG_BASE_ADDR + 0x1C88)
943 #define RESLADR_2_A		ECREG(EC_REG_BASE_ADDR + 0x1C51)
944 #define RESLADR_2_B		ECREG(EC_REG_BASE_ADDR + 0x1C91)
945 #define SLDA_A			ECREG(EC_REG_BASE_ADDR + 0x1C49)
946 #define SLDA_B			ECREG(EC_REG_BASE_ADDR + 0x1C89)
947 #define SMBPCTL_A		ECREG(EC_REG_BASE_ADDR + 0x1C4A)
948 #define SMBPCTL_B		ECREG(EC_REG_BASE_ADDR + 0x1C8A)
949 #define SMBPCTL_C		ECREG(EC_REG_BASE_ADDR + 0x1CCA)
950 #define SLSTA_A			ECREG(EC_REG_BASE_ADDR + 0x1C4B)
951 #define SLSTA_B			ECREG(EC_REG_BASE_ADDR + 0x1C8B)
952 #define INT81			BIT(7)
953 #define BIS			BIT(6)
954 #define SPDS			BIT(5)
955 #define MSLA2			BIT(4)
956 #define RCS			BIT(3)
957 #define STS			BIT(2)
958 #define SDS			BIT(1)
959 #define HONOST			BIT(0)
960 
961 #define SICR_A			ECREG(EC_REG_BASE_ADDR + 0x1C4C)
962 #define SICR_B			ECREG(EC_REG_BASE_ADDR + 0x1C8C)
963 #define NDADR_A			ECREG(EC_REG_BASE_ADDR + 0x1C4D)
964 #define NDADR_B			ECREG(EC_REG_BASE_ADDR + 0x1C8D)
965 #define NDLB_A			ECREG(EC_REG_BASE_ADDR + 0x1C4E)
966 #define NDLB_B			ECREG(EC_REG_BASE_ADDR + 0x1C8E)
967 #define NDHB_A			ECREG(EC_REG_BASE_ADDR + 0x1C4F)
968 #define NDHB_B			ECREG(EC_REG_BASE_ADDR + 0x1C8F)
969 #define HOCTL2_A		ECREG(EC_REG_BASE_ADDR + 0x1C50)
970 #define HOCTL2_B		ECREG(EC_REG_BASE_ADDR + 0x1C90)
971 #define HOCTL2_C		ECREG(EC_REG_BASE_ADDR + 0x1CD0)
972 #define SMB4P7USL		ECREG(EC_REG_BASE_ADDR + 0x1C00)
973 #define SMB4P0USH		ECREG(EC_REG_BASE_ADDR + 0x1C01)
974 #define SMB300NS		ECREG(EC_REG_BASE_ADDR + 0x1C02)
975 #define SMB250NS		ECREG(EC_REG_BASE_ADDR + 0x1C03)
976 #define SMB25MS			ECREG(EC_REG_BASE_ADDR + 0x1C04)
977 #define SMB45P3USL		ECREG(EC_REG_BASE_ADDR + 0x1C05)
978 #define SMB45P3USH		ECREG(EC_REG_BASE_ADDR + 0x1C06)
979 #define SMB4P7A4P0H		ECREG(EC_REG_BASE_ADDR + 0x1C07)
980 #define SLVISEL			ECREG(EC_REG_BASE_ADDR + 0x1C08)
981 #define SCLKTS_A		ECREG(EC_REG_BASE_ADDR + 0x1C09)
982 #define SCLKTS_B		ECREG(EC_REG_BASE_ADDR + 0x1C0A)
983 #define SCLKTS_C		ECREG(EC_REG_BASE_ADDR + 0x1C0B)
984 #define SMBFFCTRL1		ECREG(EC_REG_BASE_ADDR + 0x1C0D)
985 #define SMBFFSTS1		ECREG(EC_REG_BASE_ADDR + 0x1C0E)
986 #define SMBFFCTRL2		ECREG(EC_REG_BASE_ADDR + 0x1C0F)
987 #define SMBFFSTS2		ECREG(EC_REG_BASE_ADDR + 0x1C10)
988 #define CHSEF			ECREG(EC_REG_BASE_ADDR + 0x1C11)
989 #define HOCTL3_A		ECREG(EC_REG_BASE_ADDR + 0x1C52)
990 #define HOCTL3_B		ECREG(EC_REG_BASE_ADDR + 0x1C92)
991 #define HOCTL3_C		ECREG(EC_REG_BASE_ADDR + 0x1CD2)
992 #define MCODE_A			ECREG(EC_REG_BASE_ADDR + 0x1C53)
993 #define MCODE_B			ECREG(EC_REG_BASE_ADDR + 0x1C93)
994 #define MCODE_C			ECREG(EC_REG_BASE_ADDR + 0x1CD3)
995 
996 /**
997  *
998  * (1Dxxh) Keyboard Matrix Scan control (KBS)
999  *
1000  */
1001 #define KSOL			ECREG(EC_REG_BASE_ADDR + 0x1D00)
1002 #define KSOH1			ECREG(EC_REG_BASE_ADDR + 0x1D01)
1003 #define KSOCTRL			ECREG(EC_REG_BASE_ADDR + 0x1D02)
1004 #define KSOH2			ECREG(EC_REG_BASE_ADDR + 0x1D03)
1005 #define KSI			ECREG(EC_REG_BASE_ADDR + 0x1D04)
1006 #define KSICTRL			ECREG(EC_REG_BASE_ADDR + 0x1D05)
1007 #define KSIGCTRL		ECREG(EC_REG_BASE_ADDR + 0x1D06)
1008 #define KSIGOEN			ECREG(EC_REG_BASE_ADDR + 0x1D07)
1009 #define KSIGDAT			ECREG(EC_REG_BASE_ADDR + 0x1D08)
1010 #define KSIGDMRR		ECREG(EC_REG_BASE_ADDR + 0x1D09)
1011 #define KSOHGCTRL		ECREG(EC_REG_BASE_ADDR + 0x1D0A)
1012 #define KSOHGOEN		ECREG(EC_REG_BASE_ADDR + 0x1D0B)
1013 #define KSOHGDMRR		ECREG(EC_REG_BASE_ADDR + 0x1D0C)
1014 #define KSOLGCTRL		ECREG(EC_REG_BASE_ADDR + 0x1D0D)
1015 #define KSOLGOEN		ECREG(EC_REG_BASE_ADDR + 0x1D0E)
1016 #define KSOLGDMRR		ECREG(EC_REG_BASE_ADDR + 0x1D0F)
1017 #define KSO0LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D10)
1018 #define KSO1LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D11)
1019 #define KSO2LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D12)
1020 #define KSO3LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D13)
1021 #define KSO4LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D14)
1022 #define KSO5LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D15)
1023 #define KSO6LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D16)
1024 #define KSO7LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D17)
1025 #define KSO8LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D18)
1026 #define KSO9LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D19)
1027 #define KSO10LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D1A)
1028 #define KSO11LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D1B)
1029 #define KSO12LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D1C)
1030 #define KSO13LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D1D)
1031 #define KSO14LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D1E)
1032 #define KSO15LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D1F)
1033 #define KSO16LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D20)
1034 #define KSO17LSDR		ECREG(EC_REG_BASE_ADDR + 0x1D21)
1035 #define SDC1R			ECREG(EC_REG_BASE_ADDR + 0x1D22)
1036 #define SDEN			BIT(7)
1037 #define INTSDVEN		BIT(5)
1038 
1039 /* BIT2 ~ BIT0  Scan loop select */
1040 #define SLS_00_ROUND		0x00
1041 #define SLS_02_ROUND		0x01
1042 #define SLS_03_ROUND		0x02
1043 #define SLS_04_ROUND		0x03
1044 #define SLS_05_ROUND		0x04
1045 #define SLS_06_ROUND		0x05
1046 #define SLS_07_ROUND		0x06
1047 #define SLS_08_ROUND		0x07
1048 
1049 #define SDC2R			ECREG(EC_REG_BASE_ADDR + 0x1D23)
1050 #define KSOPCS1			BIT(7)
1051 #define KSOPCS0			BIT(6)
1052 
1053 /* BIT3 ~ BIT0  Wait KSO high delay */
1054 #define WKSOHDLY_23US		0x00
1055 #define WKSOHDLY_31US		0x01
1056 #define WKSOHDLY_39US		0x02
1057 #define WKSOHDLY_47US		0x03
1058 #define WKSOHDLY_55US		0x04
1059 #define WKSOHDLY_63US		0x05
1060 #define WKSOHDLY_71US		0x06
1061 #define WKSOHDLY_79US		0x07
1062 #define WKSOHDLY_87US		0x08
1063 #define WKSOHDLY_95US		0x09
1064 
1065 #define SDC3R			ECREG(EC_REG_BASE_ADDR + 0x1D24)
1066 
1067 /* BIT7 ~ BIT4  Wait KSO low delay */
1068 #define WKSOLDLY_11US		(0x00 << 4)
1069 #define WKSOLDLY_13US		(0x01 << 4)
1070 #define WKSOLDLY_15US		(0x02 << 4)
1071 #define WKSOLDLY_17US		(0x03 << 4)
1072 #define WKSOLDLY_19US		(0x04 << 4)
1073 #define WKSOLDLY_21US		(0x05 << 4)
1074 #define WKSOLDLY_23US		(0x06 << 4)
1075 #define WKSOLDLY_25US		(0x07 << 4)
1076 #define WKSOLDLY_27US		(0x08 << 4)
1077 #define WKSOLDLY_29US		(0x09 << 4)
1078 
1079 /* BIT3 ~ BIT0  Spacing delay between rounds */
1080 #define SDLYBR_00MS		0x00
1081 #define SDLYBR_01MS		0x01
1082 #define SDLYBR_02MS		0x02
1083 #define SDLYBR_03MS		0x03
1084 #define SDLYBR_04MS		0x04
1085 #define SDLYBR_05MS		0x05
1086 #define SDLYBR_06MS		0x06
1087 #define SDLYBR_07MS		0x07
1088 #define SDLYBR_08MS		0x08
1089 #define SDLYBR_09MS		0x09
1090 #define SDLYBR_10MS		0x0A
1091 #define SDLYBR_11MS		0x0B
1092 #define SDLYBR_12MS		0x0C
1093 #define SDLYBR_13MS		0x0D
1094 #define SDLYBR_14MS		0x0E
1095 #define SDLYBR_15MS		0x0F
1096 
1097 #define SDSR			ECREG(EC_REG_BASE_ADDR + 0x1D25)
1098 #define SDV			BIT(0)
1099 
1100 /* Keyboard Scan Out Control Register */
1101 #define KSOPU			BIT(2)
1102 #define KSOOD			BIT(0)
1103 
1104 /* Keyboard Scan In Control Register */
1105 #define KSIPU			BIT(2)
1106 
1107 /**
1108  *
1109  * (1Exxh) EC Clock and Power Management controller (ECPM)
1110  *
1111  */
1112 #define CGCTRL1R		ECREG(EC_REG_BASE_ADDR + 0x1E01)
1113 #define CGCTRL2R		ECREG(EC_REG_BASE_ADDR + 0x1E02)
1114 #define CGCTRL3R		ECREG(EC_REG_BASE_ADDR + 0x1E05)
1115 #define PLLCTRL			ECREG(EC_REG_BASE_ADDR + 0x1E03)
1116 #define AUTOCG			ECREG(EC_REG_BASE_ADDR + 0x1E04)
1117 #define PLLFREQR		ECREG(EC_REG_BASE_ADDR + 0x1E06)
1118 #define PLLSSCR			ECREG(EC_REG_BASE_ADDR + 0x1E07)
1119 #define PLLCSS			ECREG(EC_REG_BASE_ADDR + 0x1E08)
1120 #define CGCTRL4R		ECREG(EC_REG_BASE_ADDR + 0x1E09)
1121 #define EC_1E00			ECREG(EC_REG_BASE_ADDR + 0x1E00)
1122 #define ECPM_PDCTRL1R		ECREG(EC_REG_BASE_ADDR + 0x1E01)
1123 #define EC_1E03			ECREG(EC_REG_BASE_ADDR + 0x1E03)
1124 #define EC_1E06			ECREG(EC_REG_BASE_ADDR + 0x1E06)
1125 #define LDOCTR			ECREG(EC_REG_BASE_ADDR + 0x1E0A)
1126 #define PLLSTCR			ECREG(EC_REG_BASE_ADDR + 0x1E0B)
1127 #define SCDCR0			ECREG(EC_REG_BASE_ADDR + 0x1E0C)
1128 #define SCDCR1			ECREG(EC_REG_BASE_ADDR + 0x1E0D)
1129 #define SCDCR2			ECREG(EC_REG_BASE_ADDR + 0x1E0E)
1130 #define SCDCR3			ECREG(EC_REG_BASE_ADDR + 0x1E0F)
1131 #define CGCTRL5R		ECREG(EC_REG_BASE_ADDR + 0x1E13)
1132 #define LOWFREQ			ECREG(EC_REG_BASE_ADDR + 0x1E19)
1133 
1134 /**
1135  *
1136  * (1Fxxh) External Timer & External Watchdog (ETWD)
1137  *
1138  */
1139 #ifndef __ASSEMBLER__
1140 struct wdt_it8xxx2_regs {
1141 	/* 0x000: Reserved1 */
1142 	volatile uint8_t reserved1;
1143 	/* 0x001: External Timer1/WDT Configuration */
1144 	volatile uint8_t ETWCFG;
1145 	/* 0x002: External Timer1 Prescaler */
1146 	volatile uint8_t ET1PSR;
1147 	/* 0x003: External Timer1 Counter High Byte */
1148 	volatile uint8_t ET1CNTLHR;
1149 	/* 0x004: External Timer1 Counter Low Byte */
1150 	volatile uint8_t ET1CNTLLR;
1151 	/* 0x005: External Timer1/WDT Control */
1152 	volatile uint8_t ETWCTRL;
1153 	/* 0x006: External WDT Counter Low Byte */
1154 	volatile uint8_t EWDCNTLR;
1155 	/* 0x007: External WDT Key */
1156 	volatile uint8_t EWDKEYR;
1157 	/* 0x008: Reserved2 */
1158 	volatile uint8_t reserved2;
1159 	/* 0x009: External WDT Counter High Byte */
1160 	volatile uint8_t EWDCNTHR;
1161 	/* 0x00A: External Timer2 Prescaler */
1162 	volatile uint8_t ET2PSR;
1163 	/* 0x00B: External Timer2 Counter High Byte */
1164 	volatile uint8_t ET2CNTLHR;
1165 	/* 0x00C: External Timer2 Counter Low Byte */
1166 	volatile uint8_t ET2CNTLLR;
1167 	/* 0x00D: Reserved3 */
1168 	volatile uint8_t reserved3;
1169 	/* 0x00E: External Timer2 Counter High Byte2 */
1170 	volatile uint8_t ET2CNTLH2R;
1171 	/* 0x00F~0x03F: Reserved4 */
1172 	volatile uint8_t reserved4[49];
1173 	/* 0x040: External Timer1 Counter Observation Low Byte */
1174 	volatile uint8_t ET1CNTOLR;
1175 	/* 0x041: External Timer1 Counter Observation High Byte */
1176 	volatile uint8_t ET1CNTOHR;
1177 	/* 0x042~0x043: Reserved5 */
1178 	volatile uint8_t reserved5[2];
1179 	/* 0x044: External Timer1 Counter Observation Low Byte */
1180 	volatile uint8_t ET2CNTOLR;
1181 	/* 0x045: External Timer1 Counter Observation High Byte */
1182 	volatile uint8_t ET2CNTOHR;
1183 	/* 0x046: External Timer1 Counter Observation High Byte2 */
1184 	volatile uint8_t ET2CNTOH2R;
1185 	/* 0x047~0x05F: Reserved6 */
1186 	volatile uint8_t reserved6[25];
1187 	/* 0x060: External WDT Counter Observation Low Byte */
1188 	volatile uint8_t EWDCNTOLR;
1189 	/* 0x061: External WDT Counter Observation High Byte */
1190 	volatile uint8_t EWDCNTOHR;
1191 };
1192 #endif /* !__ASSEMBLER__ */
1193 
1194 /* WDT register fields */
1195 /* 0x001: External Timer1/WDT Configuration */
1196 #define IT8XXX2_WDT_EWDKEYEN		BIT(5)
1197 #define IT8XXX2_WDT_EWDSRC		BIT(4)
1198 #define IT8XXX2_WDT_LEWDCNTL		BIT(3)
1199 #define IT8XXX2_WDT_LET1CNTL		BIT(2)
1200 #define IT8XXX2_WDT_LET1PS		BIT(1)
1201 #define IT8XXX2_WDT_LETWCFG		BIT(0)
1202 /* 0x002: External Timer1 Prescaler */
1203 #define IT8XXX2_WDT_ETPS_32P768_KHZ	0x00
1204 #define IT8XXX2_WDT_ETPS_1P024_KHZ	0x01
1205 #define IT8XXX2_WDT_ETPS_32_HZ		0x02
1206 /* 0x005: External Timer1/WDT Control */
1207 #define IT8XXX2_WDT_EWDSCEN		BIT(5)
1208 #define IT8XXX2_WDT_EWDSCMS		BIT(4)
1209 #define IT8XXX2_WDT_ET2TC		BIT(3)
1210 #define IT8XXX2_WDT_ET2RST		BIT(2)
1211 #define IT8XXX2_WDT_ET1TC		BIT(1)
1212 #define IT8XXX2_WDT_ET1RST		BIT(0)
1213 
1214 /* External Timer register fields */
1215 /* External Timer 3~8 control */
1216 #define IT8XXX2_EXT_ETXRST		BIT(1)
1217 #define IT8XXX2_EXT_ETXEN		BIT(0)
1218 
1219 /* Control external timer3~8 */
1220 #define IT8XXX2_EXT_TIMER_BASE  DT_REG_ADDR(DT_NODELABEL(timer))  /*0x00F01F10*/
1221 #define IT8XXX2_EXT_CTRLX(n)    ECREG(IT8XXX2_EXT_TIMER_BASE + (n << 3))
1222 #define IT8XXX2_EXT_PSRX(n)     ECREG(IT8XXX2_EXT_TIMER_BASE + 0x01 + (n << 3))
1223 #define IT8XXX2_EXT_CNTX(n)     ECREG_u32(IT8XXX2_EXT_TIMER_BASE + 0x04 + \
1224 					(n << 3))
1225 #define IT8XXX2_EXT_CNTOX(n)    ECREG_u32(IT8XXX2_EXT_TIMER_BASE + 0x38 + \
1226 					(n << 2))
1227 
1228 /* Free run timer configurations */
1229 #define FREE_RUN_TIMER          EXT_TIMER_4
1230 #define FREE_RUN_TIMER_IRQ      DT_IRQ_BY_IDX(DT_NODELABEL(timer), 1, irq)
1231 /* Free run timer configurations */
1232 #define FREE_RUN_TIMER_FLAG     DT_IRQ_BY_IDX(DT_NODELABEL(timer), 1, flags)
1233 /* Free run timer max count is 36.4 hr (base on clock source 32768Hz) */
1234 #define FREE_RUN_TIMER_MAX_CNT  0xFFFFFFFFUL
1235 
1236 #ifndef __ASSEMBLER__
1237 enum ext_clk_src_sel {
1238 	EXT_PSR_32P768K = 0,
1239 	EXT_PSR_1P024K,
1240 	EXT_PSR_32,
1241 	EXT_PSR_8M,
1242 };
1243 /*
1244  * 24-bit timers: external timer 3, 5, and 7
1245  * 32-bit timers: external timer 4, 6, and 8
1246  */
1247 enum ext_timer_idx {
1248 	EXT_TIMER_3 = 0,	/* Event timer */
1249 	EXT_TIMER_4,		/* Free run timer */
1250 	EXT_TIMER_5,
1251 	EXT_TIMER_6,
1252 	EXT_TIMER_7,
1253 	EXT_TIMER_8,
1254 };
1255 #endif
1256 
1257 /**
1258  *
1259  * Observation external timer
1260  *
1261  */
1262 #define ET3CNTOLR		ECREG(EC_REG_BASE_ADDR + 0x1F48)
1263 #define ET3CNTOHR		ECREG(EC_REG_BASE_ADDR + 0x1F49)
1264 #define ET3CNTOH2R		ECREG(EC_REG_BASE_ADDR + 0x1F4A)
1265 #define ET4CNTOLR		ECREG(EC_REG_BASE_ADDR + 0x1F4C)
1266 #define ET4CNTOHR		ECREG(EC_REG_BASE_ADDR + 0x1F4D)
1267 #define ET4CNTOH2R		ECREG(EC_REG_BASE_ADDR + 0x1F4E)
1268 #define ET4CNTOH3R		ECREG(EC_REG_BASE_ADDR + 0x1F4F)
1269 #define ET5CNTOLR		ECREG(EC_REG_BASE_ADDR + 0x1F50)
1270 #define ET5CNTOHR		ECREG(EC_REG_BASE_ADDR + 0x1F51)
1271 #define ET5CNTOH2R		ECREG(EC_REG_BASE_ADDR + 0x1F52)
1272 #define ET6CNTOLR		ECREG(EC_REG_BASE_ADDR + 0x1F54)
1273 #define ET6CNTOHR		ECREG(EC_REG_BASE_ADDR + 0x1F55)
1274 #define ET6CNTOH2R		ECREG(EC_REG_BASE_ADDR + 0x1F56)
1275 #define ET6CNTOH3R		ECREG(EC_REG_BASE_ADDR + 0x1F57)
1276 #define ET7CNTOLR		ECREG(EC_REG_BASE_ADDR + 0x1F58)
1277 #define ET7CNTOHR		ECREG(EC_REG_BASE_ADDR + 0x1F59)
1278 #define ET7CNTOH2R		ECREG(EC_REG_BASE_ADDR + 0x1F5A)
1279 #define ET8CNTOLR		ECREG(EC_REG_BASE_ADDR + 0x1F5C)
1280 #define ET8CNTOHR		ECREG(EC_REG_BASE_ADDR + 0x1F5D)
1281 #define ET8CNTOH2R		ECREG(EC_REG_BASE_ADDR + 0x1F5E)
1282 #define ET8CNTOH3R		ECREG(EC_REG_BASE_ADDR + 0x1F5F)
1283 
1284 #define ETXCNTOR(x)		(ECREG_u32(EC_REG_BASE_ADDR\
1285 					+ 0x1F40 + (x - 1) * 4))
1286 
1287 #define ETPS_32_768_KHZ		0x00
1288 #define ETPS_1_024_KHZ		0x01
1289 #define ETPS_32_HZ		0x02
1290 #define ETPS_8_MHZ		0x03
1291 #define ET_3_8_TC		BIT(2)
1292 #define ET_3_8_RST		BIT(1)
1293 #define ET_3_8_EN		BIT(0)
1294 
1295 /**
1296  *
1297  * (20xxh) General Control (GCTRL)
1298  *
1299  */
1300 #define ECHIPID1		ECREG(EC_REG_BASE_ADDR + 0x2000)
1301 #define ECHIPID2		ECREG(EC_REG_BASE_ADDR + 0x2001)
1302 #define ECHIPVER		ECREG(EC_REG_BASE_ADDR + 0x2002)
1303 #define IDR			ECREG(EC_REG_BASE_ADDR + 0x2004)
1304 #define RSTS			ECREG(EC_REG_BASE_ADDR + 0x2006)
1305 #define RSTC1			ECREG(EC_REG_BASE_ADDR + 0x2007)
1306 #define RSMFI			BIT(7)
1307 #define RINTC			BIT(6)
1308 #define REC2I			BIT(5)
1309 #define RKBC			BIT(4)
1310 #define RSWUC			BIT(3)
1311 #define RPMC			BIT(2)
1312 #define RGPIO			BIT(1)
1313 #define RPWM			BIT(0)
1314 #define RSTC2			ECREG(EC_REG_BASE_ADDR + 0x2008)
1315 #define RADC			BIT(7)
1316 #define RDAC			BIT(6)
1317 #define RWUC			BIT(5)
1318 #define RKBS			BIT(4)
1319 #define REGPC			BIT(2)
1320 #define RCIR			BIT(1)
1321 #define RSTC3			ECREG(EC_REG_BASE_ADDR + 0x2009)
1322 #define RPS23			BIT(6)
1323 #define RPS22			BIT(5)
1324 #define RPS21			BIT(4)
1325 #define RSMBD			BIT(3)
1326 #define RSMBC			BIT(2)
1327 #define RSMBB			BIT(1)
1328 #define RSMBA			BIT(0)
1329 /*the same time and writing 0111b is reserved.*/
1330 #define RSTC4			ECREG(EC_REG_BASE_ADDR + 0x2011)
1331 #define RPECI			BIT(4)
1332 #define RTMR			BIT(3)
1333 #define RUART2			BIT(2)
1334 #define RUART1			BIT(1)
1335 #define RSPI			BIT(0)
1336 
1337 #define BADRSEL			ECREG(EC_REG_BASE_ADDR + 0x200A)
1338 #define WNCKR			ECREG(EC_REG_BASE_ADDR + 0x200B)
1339 #define OSCTRL			ECREG(EC_REG_BASE_ADDR + 0x200C)
1340 #define SPCTRL1			ECREG(EC_REG_BASE_ADDR + 0x200D)
1341 #define RSTCH			ECREG(EC_REG_BASE_ADDR + 0x200E)
1342 #define GENIRQ			ECREG(EC_REG_BASE_ADDR + 0x200F)
1343 #define RSTDMMC			ECREG(EC_REG_BASE_ADDR + 0x2010)
1344 #define SPECTRL2		ECREG(EC_REG_BASE_ADDR + 0x2012)
1345 #define SPECTRL3		ECREG(EC_REG_BASE_ADDR + 0x2016)
1346 #define PI2ECH			ECREG(EC_REG_BASE_ADDR + 0x2014)
1347 #define PI2ECL			ECREG(EC_REG_BASE_ADDR + 0x2015)
1348 #define BINTADDR0R		ECREG(EC_REG_BASE_ADDR + 0x2019)
1349 #define BINTADDR1R		ECREG(EC_REG_BASE_ADDR + 0x201A)
1350 #define BINTCTRLR		ECREG(EC_REG_BASE_ADDR + 0x201B)
1351 #define SPCTRL4			ECREG(EC_REG_BASE_ADDR + 0x201C)
1352 #define SHA1HASHCTRLR		ECREG(EC_REG_BASE_ADDR + 0x202D)
1353 #define SHA1HBADDR		ECREG(EC_REG_BASE_ADDR + 0x202E)
1354 #define MCCR			ECREG(EC_REG_BASE_ADDR + 0x2030)
1355 #define EIDSR			ECREG(EC_REG_BASE_ADDR + 0x2031)
1356 #define PMER1			ECREG(EC_REG_BASE_ADDR + 0x2032)
1357 #define PMER2			ECREG(EC_REG_BASE_ADDR + 0x2033)
1358 #define FRR0			ECREG(EC_REG_BASE_ADDR + 0x2034)
1359 #define FRR1			ECREG(EC_REG_BASE_ADDR + 0x2035)
1360 #define FRR2			ECREG(EC_REG_BASE_ADDR + 0x2036)
1361 #define MCCR1			ECREG(EC_REG_BASE_ADDR + 0x203E)
1362 #define IVTBAR			ECREG(EC_REG_BASE_ADDR + 0x2041)
1363 #define DMMYR			ECREG(EC_REG_BASE_ADDR + 0x2045)
1364 #define PWMENR			ECREG(EC_REG_BASE_ADDR + 0x204A)
1365 #define PDSCR1			ECREG(EC_REG_BASE_ADDR + 0x204C)
1366 #define PDSCR2			ECREG(EC_REG_BASE_ADDR + 0x204D)
1367 #define PDSCR3			ECREG(EC_REG_BASE_ADDR + 0x204E)
1368 #define PDSCR4			ECREG(EC_REG_BASE_ADDR + 0x204F)
1369 #define PDSCR5			ECREG(EC_REG_BASE_ADDR + 0x2050)
1370 #define PDSCR6			ECREG(EC_REG_BASE_ADDR + 0x2051)
1371 #define PDSCR7			ECREG(EC_REG_BASE_ADDR + 0x2052)
1372 #define DRI_6_25		(0x00)
1373 #define DRI_7_50		(0x01)
1374 #define DRI_8_75		(0x02)
1375 #define DRI_10_00		(0x03)
1376 #define DRI_GPIOB0(x)		((x) << 6)
1377 #define DRI_GPIOA6(x)		((x) << 4)
1378 #define DRI_GPIOA5(x)		((x) << 2)
1379 #define DRI_GPIOA4(x)		((x) << 0)
1380 #define DRI_GPIOB4(x)		((x) << 6)
1381 #define DRI_GPIOB3(x)		((x) << 4)
1382 #define DRI_GPIOB2(x)		((x) << 2)
1383 #define DRI_GPIOB1(x)		((x) << 0)
1384 #define DRI_GPIOB5(x)		((x) << 0)
1385 #define DRI_GPIOC3(x)		((x) << 4)
1386 #define DRI_GPIOC2(x)		((x) << 2)
1387 #define DRI_GPIOC1(x)		((x) << 0)
1388 #define DRI_GPIOC7(x)		((x) << 4)
1389 #define DRI_GPIOC6(x)		((x) << 2)
1390 #define DRI_GPIOC5(x)		((x) << 0)
1391 #define DRI_GPIOD5(x)		((x) << 6)
1392 #define DRI_GPIOD4(x)		((x) << 4)
1393 #define DRI_GPIOD3(x)		((x) << 2)
1394 #define DRI_GPIOD2(x)		((x) << 0)
1395 #define DRI_GPIOD7(x)		((x) << 2)
1396 #define PMER5			ECREG(EC_REG_BASE_ADDR + 0x2057)
1397 #define PIECR0			ECREG(EC_REG_BASE_ADDR + 0x205A)
1398 #define PIECR1			ECREG(EC_REG_BASE_ADDR + 0x205B)
1399 #define PIECR2			ECREG(EC_REG_BASE_ADDR + 0x205C)
1400 #define PIECR3			ECREG(EC_REG_BASE_ADDR + 0x205D)
1401 #define INTOSC			ECREG(EC_REG_BASE_ADDR + 0x205E)
1402 
1403 /**
1404  *
1405  * (21xxh) External GPIO Controller (EGPC)
1406  *
1407  */
1408 #define EADDR			ECREG(EC_REG_BASE_ADDR + 0x2100)
1409 #define EDAT			ECREG(EC_REG_BASE_ADDR + 0x2101)
1410 #define ECNT			ECREG(EC_REG_BASE_ADDR + 0x2102)
1411 #define ESTS			ECREG(EC_REG_BASE_ADDR + 0x2103)
1412 
1413 /**
1414  *
1415  * (23xxh) Consumer IR (CIR)
1416  *
1417  */
1418 #define C0DR			ECREG(EC_REG_BASE_ADDR + 0x2300)
1419 #define C0MSTCR			ECREG(EC_REG_BASE_ADDR + 0x2301)
1420 #define CIR_CTXSEL		BIT(7)
1421 #define CIR_CRXSEL		BIT(6)
1422 #define CIR_ILSEL		BIT(5)
1423 #define CIR_ILE			BIT(4)
1424 #define CIR_FIFOTL1		BIT(3)
1425 #define CIR_FIFOTL0		BIT(2)
1426 #define CIR_FIFOCLR		BIT(1)
1427 #define CIR_RESET		BIT(0)
1428 #define C0IER			ECREG(EC_REG_BASE_ADDR + 0x2302)
1429 #define C0IIR			ECREG(EC_REG_BASE_ADDR + 0x2303)
1430 #define C0CFR			ECREG(EC_REG_BASE_ADDR + 0x2304)
1431 #define C0RCR			ECREG(EC_REG_BASE_ADDR + 0x2305)
1432 #define CIR_RXEN		BIT(7)
1433 #define CIR_RDWOS		BIT(5)
1434 #define CIR_RXEND		BIT(4)
1435 #define CIR_RXACT		BIT(3)
1436 #define CIR_RXDCR2		BIT(2)
1437 #define CIR_RXDCR1		BIT(1)
1438 #define CIR_RXDCR0		BIT(0)
1439 #define C0TCR			ECREG(EC_REG_BASE_ADDR + 0x2306)
1440 #define C0SCK			ECREG(EC_REG_BASE_ADDR + 0x2307)
1441 #define DLLOCK			BIT(7)
1442 #define BRCM2			BIT(6)
1443 #define BRCM1			BIT(5)
1444 #define BRCM0			BIT(4)
1445 #define DLLTE			BIT(3)
1446 #define DLL1P8E			BIT(2)
1447 #define TXDCKG			BIT(1)
1448 #define SCKS			BIT(0)
1449 #define C0BDLR			ECREG(EC_REG_BASE_ADDR + 0x2308)
1450 #define C0BDHR			ECREG(EC_REG_BASE_ADDR + 0x2309)
1451 #define C0TFSR			ECREG(EC_REG_BASE_ADDR + 0x230A)
1452 #define C0RFSR			ECREG(EC_REG_BASE_ADDR + 0x230B)
1453 #define C0WCSSR			ECREG(EC_REG_BASE_ADDR + 0x230C)
1454 #define C0WCL			ECREG(EC_REG_BASE_ADDR + 0x230D)
1455 #define C0WCR			ECREG(EC_REG_BASE_ADDR + 0x230E)
1456 #define C0WPS			ECREG(EC_REG_BASE_ADDR + 0x230F)
1457 #define CSCRR			ECREG(EC_REG_BASE_ADDR + 0x2310)
1458 
1459 /**
1460  *
1461  * (25xxh) Debugger (DBGR)
1462  *
1463  */
1464 #define BKA1L			ECREG(EC_REG_BASE_ADDR + 0x2510)
1465 #define BKA1M			ECREG(EC_REG_BASE_ADDR + 0x2511)
1466 #define BKA1H			ECREG(EC_REG_BASE_ADDR + 0x2512)
1467 #define BKA2L			ECREG(EC_REG_BASE_ADDR + 0x2513)
1468 #define BKA2M			ECREG(EC_REG_BASE_ADDR + 0x2514)
1469 #define BKA2H			ECREG(EC_REG_BASE_ADDR + 0x2515)
1470 #define BKA3L			ECREG(EC_REG_BASE_ADDR + 0x2516)
1471 #define BKA3M			ECREG(EC_REG_BASE_ADDR + 0x2517)
1472 #define BKA3H			ECREG(EC_REG_BASE_ADDR + 0x2518)
1473 
1474 /**
1475  *
1476  * (26xxh) Serial Peripheral Interface (SSPI)
1477  *
1478  */
1479 #define SPI_BASE_ADDR		(EC_REG_BASE_ADDR + 0x2600)
1480 #define SPIDATA			ECREG(EC_REG_BASE_ADDR + 0x2600)
1481 #define SPICTRL1		ECREG(EC_REG_BASE_ADDR + 0x2601)
1482 #define CHPOL			BIT(7)
1483 #define CLPOL			BIT(6)
1484 #define CLPHS			BIT(5)
1485 #define SCKFREQ2		BIT(4)
1486 #define SCKFREQ1		BIT(3)
1487 #define SCKFREQ0		BIT(2)
1488 #define NTREN			BIT(1)
1489 #define WIRECH0			BIT(0)
1490 #define SPICTRL2		ECREG(EC_REG_BASE_ADDR + 0x2602)
1491 #define HBANK			BIT(7)
1492 #define DEVBUSYPOL		BIT(6)
1493 #define BYTEWIDTH2		BIT(5)
1494 #define BYTEWIDTH1		BIT(4)
1495 #define BYTEWIDTH0		BIT(3)
1496 #define CHRW			BIT(2)
1497 #define BLKSEL			BIT(1)
1498 #define WIRECH1			BIT(0)
1499 #define SPISTS			ECREG(EC_REG_BASE_ADDR + 0x2603)
1500 #define WAITBUSYSTART		BIT(7)
1501 #define DEVBUSY			BIT(6)
1502 #define TRANEND			BIT(5)
1503 #define CH0START		BIT(4)
1504 #define CH1START		BIT(3)
1505 #define TRANIP			BIT(2)
1506 #define TRANENDIF		BIT(1)
1507 #define SPIBUSY			BIT(0)
1508 #define SPICTRL3		ECREG(EC_REG_BASE_ADDR + 0x2604)
1509 #define CMDQAUTOMODE		BIT(5)
1510 #define DEVBUSYMODE		BIT(3)
1511 #define CSPOLSEL		BIT(2)
1512 #define CHPOL1			BIT(1)
1513 #define BUSYNOCLK		BIT(0)
1514 #define CH0CMDADDRLB		ECREG(EC_REG_BASE_ADDR + 0x2605)
1515 #define CH0CMDADDRHB		ECREG(EC_REG_BASE_ADDR + 0x2606)
1516 #define CH0CMDADDRHB2		ECREG(EC_REG_BASE_ADDR + 0x2621)
1517 #define DMATCNTLB		ECREG(EC_REG_BASE_ADDR + 0x2607)
1518 #define DMATCNTHB		ECREG(EC_REG_BASE_ADDR + 0x2608)
1519 #define SPIWRCMDL		ECREG(EC_REG_BASE_ADDR + 0x2609)
1520 #define CH0DMARDLB		ECREG(EC_REG_BASE_ADDR + 0x260A)
1521 #define CH0DMARDHB		ECREG(EC_REG_BASE_ADDR + 0x260B)
1522 #define INTSTS			ECREG(EC_REG_BASE_ADDR + 0x260C)
1523 #define CH2CMDQEND		(BIT(5) | BIT(6))
1524 #define CH1CMDQEND		BIT(6)
1525 #define CH0CMDQEND		BIT(5)
1526 #define SPICMDQENDMASK		BIT(4)
1527 #define SPIRING1FI		BIT(2)
1528 #define SPIRING0FI		BIT(1)
1529 #define SPICMDQEND		BIT(0)
1530 #define SPICTRL5		ECREG(EC_REG_BASE_ADDR + 0x260D)
1531 #define CH2SELCMDQ		BIT(6)
1532 #define CH1SELCMDQ		BIT(5)
1533 #define CH0SELCMDQ		BIT(4)
1534 #define CMDQMODE		BIT(0)
1535 #define CH0WRMEMADDRLB		ECREG(EC_REG_BASE_ADDR + 0x260E)
1536 #define CH0WRMEMADDRHB		ECREG(EC_REG_BASE_ADDR + 0x260F)
1537 #define CH0WRMEMADDRHB2		ECREG(EC_REG_BASE_ADDR + 0x2623)
1538 #define CMDQINVPR		ECREG(EC_REG_BASE_ADDR + 0x2610)
1539 #define CH0WTSR			ECREG(EC_REG_BASE_ADDR + 0x2611)
1540 #define CH1CMDADDRLB		ECREG(EC_REG_BASE_ADDR + 0x2612)
1541 #define CH1CMDADDRHB		ECREG(EC_REG_BASE_ADDR + 0x2613)
1542 #define CH1WRMEMADDRLB		ECREG(EC_REG_BASE_ADDR + 0x2614)
1543 #define CH1WRMEMADDRHB		ECREG(EC_REG_BASE_ADDR + 0x2615)
1544 #define CH1WTSR			ECREG(EC_REG_BASE_ADDR + 0x2616)
1545 #define CH1DMARDLB		ECREG(EC_REG_BASE_ADDR + 0x2617)
1546 #define CH1DMARDHB		ECREG(EC_REG_BASE_ADDR + 0x2618)
1547 #define CH2CMDADDRLB		ECREG(EC_REG_BASE_ADDR + 0x2619)
1548 #define CH2CMDADDRHB		ECREG(EC_REG_BASE_ADDR + 0x261A)
1549 #define CH2WRMEMADDRLB		ECREG(EC_REG_BASE_ADDR + 0x261B)
1550 #define CH2WRMEMADDRHB		ECREG(EC_REG_BASE_ADDR + 0x261C)
1551 #define CH2WTSR			ECREG(EC_REG_BASE_ADDR + 0x261D)
1552 #define CH2DMARDLB		ECREG(EC_REG_BASE_ADDR + 0x261E)
1553 #define CH2DMARDHB		ECREG(EC_REG_BASE_ADDR + 0x261F)
1554 #define SPICTRL6		ECREG(EC_REG_BASE_ADDR + 0x2620)
1555 #define CH2START		BIT(3)
1556 #define WIRECH2			BIT(0)
1557 
1558 /**
1559  *
1560  * (27xxh) Extern Serial Port (UART1)
1561  *
1562  */
1563 #define REG_UART1_BASE		(EC_REG_BASE_ADDR + 0x2700)
1564 #define UART1_RBR		ECREG(REG_UART1_BASE + 0x00)
1565 #define UART1_IER		ECREG(REG_UART1_BASE + 0x01)
1566 #define UART1_IIR		ECREG(REG_UART1_BASE + 0x02)
1567 #define UART1_LCR		ECREG(REG_UART1_BASE + 0x03)
1568 #define UART1_MCR		ECREG(REG_UART1_BASE + 0x04)
1569 #define UART1_LSR		ECREG(REG_UART1_BASE + 0x05)
1570 #define UART1_MSR		ECREG(REG_UART1_BASE + 0x06)
1571 #define UART1_SCR		ECREG(REG_UART1_BASE + 0x07)
1572 #define UART1_ECSPMR		ECREG(REG_UART1_BASE + 0x08)
1573 #define UART1_SPPR		ECREG(REG_UART1_BASE + 0x09)
1574 #define UART1_UTBR		ECREG(REG_UART1_BASE + 0x00)
1575 #define UART1_UFCR		ECREG(REG_UART1_BASE + 0x02)
1576 #define UART1_UMSR		ECREG(REG_UART1_BASE + 0x06)
1577 #define UART1_USCR		ECREG(REG_UART1_BASE + 0x07)
1578 
1579 /**
1580  *
1581  * (28xxh) Extern Serial Port (UART2)
1582  *
1583  */
1584 #define REG_UART2_BASE		(EC_REG_BASE_ADDR + 0x2800)
1585 #define UART2_RBR		ECREG(REG_UART2_BASE + 0x00)
1586 #define UART2_IER		ECREG(REG_UART2_BASE + 0x01)
1587 #define UART2_IIR		ECREG(REG_UART2_BASE + 0x02)
1588 #define UART2_LCR		ECREG(REG_UART2_BASE + 0x03)
1589 #define UART2_MCR		ECREG(REG_UART2_BASE + 0x04)
1590 #define UART2_LSR		ECREG(REG_UART2_BASE + 0x05)
1591 #define UART2_MSR		ECREG(REG_UART2_BASE + 0x06)
1592 #define UART2_SCR		ECREG(REG_UART2_BASE + 0x07)
1593 #define UART2_ECSPMR		ECREG(REG_UART2_BASE + 0x08)
1594 #define UART2_UTBR		ECREG(REG_UART2_BASE + 0x00)
1595 #define UART2_UFCR		ECREG(REG_UART2_BASE + 0x02)
1596 #define UART2_UMSR		ECREG(REG_UART2_BASE + 0x06)
1597 #define UART2_USCR		ECREG(REG_UART2_BASE + 0x07)
1598 
1599 /**
1600  *
1601  * (29xxh) 8 Bit Timer (TMR)
1602  *
1603  */
1604 #define PRSC			ECREG(EC_REG_BASE_ADDR + 0x2900)
1605 #define GCSMS			ECREG(EC_REG_BASE_ADDR + 0x2901)
1606 #define CTR_A0			ECREG(EC_REG_BASE_ADDR + 0x2902)
1607 #define CTR_A1			ECREG(EC_REG_BASE_ADDR + 0x2903)
1608 #define CTR_B0			ECREG(EC_REG_BASE_ADDR + 0x2904)
1609 #define CTR_B1			ECREG(EC_REG_BASE_ADDR + 0x2905)
1610 #define DCR_A0			ECREG(EC_REG_BASE_ADDR + 0x2906)
1611 #define DCR_A1			ECREG(EC_REG_BASE_ADDR + 0x2907)
1612 #define DCR_B0			ECREG(EC_REG_BASE_ADDR + 0x2908)
1613 #define DCR_B1			ECREG(EC_REG_BASE_ADDR + 0x2909)
1614 #define CCGSR			ECREG(EC_REG_BASE_ADDR + 0x290A)
1615 #define TMRCE			ECREG(EC_REG_BASE_ADDR + 0x290B)
1616 #define TMEIE			ECREG(EC_REG_BASE_ADDR + 0x290C)
1617 
1618 /**
1619  *
1620  * (2Cxxh) Platform Environment Control Interface (PECI)
1621  *
1622  */
1623 #define HOSTAR			ECREG(EC_REG_BASE_ADDR + 0x2C00)
1624 #define TEMPERR			BIT(7)
1625 #define BUSERR			BIT(6)
1626 #define EXTERR			BIT(5)
1627 #define WR_FCS_ERR		BIT(3)
1628 #define RD_FCS_ERR		BIT(2)
1629 #define FINISH			BIT(1)
1630 #define HOBY			BIT(0)
1631 #define HOCTLR			ECREG(EC_REG_BASE_ADDR + 0x2C01)
1632 #define FIFOCLR			BIT(5)
1633 #define FCSERR_ABT		BIT(4)
1634 #define PECIHEN			BIT(3)
1635 #define CONCTRL			BIT(2)
1636 #define AWFCS_EN		BIT(1)
1637 #define PECISTART		BIT(0)
1638 #define HOCMDR			ECREG(EC_REG_BASE_ADDR + 0x2C02)
1639 #define HOTRADDR		ECREG(EC_REG_BASE_ADDR + 0x2C03)
1640 #define HOWRLR			ECREG(EC_REG_BASE_ADDR + 0x2C04)
1641 #define HORDLR			ECREG(EC_REG_BASE_ADDR + 0x2C05)
1642 #define HOWRDR			ECREG(EC_REG_BASE_ADDR + 0x2C06)
1643 #define HORDDR			ECREG(EC_REG_BASE_ADDR + 0x2C07)
1644 #define HOCTL2R			ECREG(EC_REG_BASE_ADDR + 0x2C08)
1645 #define RWFCSV			ECREG(EC_REG_BASE_ADDR + 0x2C09)
1646 #define RRFCSV			ECREG(EC_REG_BASE_ADDR + 0x2C0A)
1647 #define WFCSV			ECREG(EC_REG_BASE_ADDR + 0x2C0B)
1648 #define RFCSV			ECREG(EC_REG_BASE_ADDR + 0x2C0C)
1649 #define AWFCSV			ECREG(EC_REG_BASE_ADDR + 0x2C0D)
1650 #define PADCTLR			ECREG(EC_REG_BASE_ADDR + 0x2C0E)
1651 
1652 /**
1653  *
1654  * (2Dxxh) I2C/JTAG
1655  *
1656  */
1657 #define CLOCK_CGCTRL5R		(REG_BASE_ADDR + 0x1E13)
1658 #define CLK_C_MEMS_MIC		0x40
1659 #define CLK_C_ADC		0x20
1660 #define CLK_C_SPI_SLAVE		0x10
1661 #define CLK_C_HF		0x08
1662 #define CLK_C_USB		0x04
1663 #define CLK_C_UART		0x02
1664 #define CLK_C_SSPI		0x01
1665 #define CLK_C_ALL		0x7F
1666 #define GCTRL_BASE_ADDR		(REG_BASE_ADDR + 0x2000)
1667 #define GCTRL_PMER1		(GCTRL_BASE_ADDR + 0x32)
1668 #define GCTRL_PMER2		(GCTRL_BASE_ADDR + 0x33)
1669 #define PADIE0			(GCTRL_BASE_ADDR + 0x5A)
1670 #define PADIE1			(GCTRL_BASE_ADDR + 0x5B)
1671 #define PADIE2			(GCTRL_BASE_ADDR + 0x5C)
1672 #define PADIE3			(GCTRL_BASE_ADDR + 0x5D)
1673 
1674 /**
1675  *
1676  * (2Exxh) Consumer Electronics Control (CEC)
1677  *
1678  */
1679 #define CECDR			ECREG(EC_REG_BASE_ADDR + 0x2E00)
1680 #define CECFSTS			ECREG(EC_REG_BASE_ADDR + 0x2E01)
1681 #define CECDLA			ECREG(EC_REG_BASE_ADDR + 0x2E02)
1682 #define CECCTRL			ECREG(EC_REG_BASE_ADDR + 0x2E03)
1683 #define CECSTS			ECREG(EC_REG_BASE_ADDR + 0x2E04)
1684 #define CECIE			ECREG(EC_REG_BASE_ADDR + 0x2E05)
1685 #define CECOPSTS		ECREG(EC_REG_BASE_ADDR + 0x2E06)
1686 #define CECCRH			ECREG(EC_REG_BASE_ADDR + 0x2E07)
1687 
1688 /**
1689  *
1690  * (3Cxxh) Crypto Engine
1691  *
1692  */
1693 
1694 #define CE_CTRL_1ST		ECREG(EC_REG_BASE_ADDR + 0x3C00)
1695 #define CE_RNG			ECREG(EC_REG_BASE_ADDR + 0x3C20)
1696 
1697 
1698 /* Shared Memory Flash Interface Bridge (SMFI) registers */
1699 
1700 #ifndef __ASSEMBLER__
1701 struct flash_it8xxx2_regs {
1702 	volatile uint8_t reserved1[59];
1703 	/* 0x3B: EC-Indirect memory address 0 */
1704 	volatile uint8_t SMFI_ECINDAR0;
1705 	/* 0x3C: EC-Indirect memory address 1 */
1706 	volatile uint8_t SMFI_ECINDAR1;
1707 	/* 0x3D: EC-Indirect memory address 2 */
1708 	volatile uint8_t SMFI_ECINDAR2;
1709 	/* 0x3E: EC-Indirect memory address 3 */
1710 	volatile uint8_t SMFI_ECINDAR3;
1711 	/* 0x3F: EC-Indirect memory data */
1712 	volatile uint8_t SMFI_ECINDDR;
1713 	/* 0x40: Scratch SRAM 0 address low byte */
1714 	volatile uint8_t SMFI_SCAR0L;
1715 	/* 0x41: Scratch SRAM 0 address middle byte */
1716 	volatile uint8_t SMFI_SCAR0M;
1717 	/* 0x42: Scratch SRAM 0 address high byte */
1718 	volatile uint8_t SMFI_SCAR0H;
1719 	volatile uint8_t reserved2[95];
1720 	/* 0xA2: Flash control 6 */
1721 	volatile uint8_t SMFI_FLHCTRL6R;
1722 };
1723 #endif /* !__ASSEMBLER__ */
1724 
1725 /* SMFI register fields */
1726 
1727 /* EC-Indirect read internal flash */
1728 #define EC_INDIRECT_READ_INTERNAL_FLASH BIT(6)
1729 /* Enable EC-indirect page program command */
1730 #define IT8XXX2_SMFI_MASK_ECINDPP BIT(3)
1731 /* Scratch SRAM 0 address(BIT(19)) */
1732 #define IT8XXX2_SMFI_SC0A19 BIT(7)
1733 /* Scratch SRAM enable */
1734 #define IT8XXX2_SMFI_SCAR0H_ENABLE BIT(3)
1735 
1736 /* --- GPIO --- */
1737 #define IT8XXX2_GPIO_BASE  0x00F01600
1738 #define IT8XXX2_GPIO2_BASE 0x00F03E00
1739 
1740 #define IT8XXX2_GPIO_GCR        ECREG(IT8XXX2_GPIO_BASE + 0x00)
1741 
1742 #define IT8XXX2_GPIO_GCRX(offset) ECREG(IT8XXX2_GPIO_BASE + (offset))
1743 #define IT8XXX2_GPIO_GCR25_OFFSET 0xd1
1744 #define IT8XXX2_GPIO_GCR26_OFFSET 0xd2
1745 #define IT8XXX2_GPIO_GCR27_OFFSET 0xd3
1746 #define IT8XXX2_GPIO_GCR28_OFFSET 0xd4
1747 #define IT8XXX2_GPIO_GCR31_OFFSET 0xd5
1748 #define IT8XXX2_GPIO_GCR32_OFFSET 0xd6
1749 #define IT8XXX2_GPIO_GCR33_OFFSET 0xd7
1750 #define IT8XXX2_GPIO_GCR19_OFFSET 0xe4
1751 #define IT8XXX2_GPIO_GCR20_OFFSET 0xe5
1752 #define IT8XXX2_GPIO_GCR21_OFFSET 0xe6
1753 #define IT8XXX2_GPIO_GCR22_OFFSET 0xe7
1754 #define IT8XXX2_GPIO_GCR23_OFFSET 0xe8
1755 #define IT8XXX2_GPIO_GCR24_OFFSET 0xe9
1756 #define IT8XXX2_GPIO_GCR30_OFFSET 0xed
1757 #define IT8XXX2_GPIO_GCR29_OFFSET 0xee
1758 /* TODO: correct GRCx to GCRx */
1759 #define IT8XXX2_GPIO_GRC1       ECREG(IT8XXX2_GPIO_BASE + 0xF0)
1760 #define IT8XXX2_GPIO_GRC21      ECREG(IT8XXX2_GPIO_BASE + 0xE6)
1761 
1762 #define IT8XXX2_GPIO_GPCRP0     ECREG(IT8XXX2_GPIO2_BASE + 0x18)
1763 #define IT8XXX2_GPIO_GPCRP1     ECREG(IT8XXX2_GPIO2_BASE + 0x19)
1764 
1765 /* Analog to Digital Converter (ADC) */
1766 
1767 #ifndef __ASSEMBLER__
1768 struct adc_it8xxx2_regs {
1769 	volatile uint8_t ADCSTS;
1770 	volatile uint8_t ADCCFG;
1771 	volatile uint8_t ADCCTL;
1772 	volatile uint8_t ADCGCR;
1773 	volatile uint8_t VCH0CTL;
1774 	volatile uint8_t KDCTL;
1775 	volatile uint8_t reserved1[18];
1776 	volatile uint8_t VCH0DATL;
1777 	volatile uint8_t VCH0DATM;
1778 	volatile uint8_t reserved2[42];
1779 	volatile uint8_t ADCDVSTS;
1780 };
1781 #endif /* !__ASSEMBLER__ */
1782 
1783 /* ADC conversion time select 1 */
1784 #define IT8XXX2_ADC_ADCCTS1			BIT(7)
1785 /* Analog accuracy initialization */
1786 #define IT8XXX2_ADC_AINITB			BIT(3)
1787 /* ADC conversion time select 0 */
1788 #define IT8XXX2_ADC_ADCCTS0			BIT(5)
1789 /* ADC module enable */
1790 #define IT8XXX2_ADC_ADCEN			BIT(0)
1791 /* ADC data buffer keep enable */
1792 #define IT8XXX2_ADC_DBKEN			BIT(7)
1793 /* W/C data valid flag */
1794 #define IT8XXX2_ADC_DATVAL			BIT(7)
1795 /* Data valid interrupt of adc */
1796 #define IT8XXX2_ADC_INTDVEN			BIT(5)
1797 /* Automatic hardware calibration enable */
1798 #define IT8XXX2_ADC_AHCE			BIT(7)
1799 
1800 /*
1801  * Clock and Power Management (ECPM)
1802  */
1803 #define IT83XX_ECPM_BASE  0x00F01E00
1804 
1805 #define IT83XX_ECPM_CGCTRL4R_OFF 0x09
1806 
1807 #define CGC_OFFSET_SMBF		((IT83XX_ECPM_CGCTRL4R_OFF << 8) | 0x80)
1808 #define CGC_OFFSET_SMBE		((IT83XX_ECPM_CGCTRL4R_OFF << 8) | 0x40)
1809 #define CGC_OFFSET_SMBD		((IT83XX_ECPM_CGCTRL4R_OFF << 8) | 0x20)
1810 #define CGC_OFFSET_SMBC		((IT83XX_ECPM_CGCTRL4R_OFF << 8) | 0x10)
1811 #define CGC_OFFSET_SMBB		((IT83XX_ECPM_CGCTRL4R_OFF << 8) | 0x08)
1812 #define CGC_OFFSET_SMBA		((IT83XX_ECPM_CGCTRL4R_OFF << 8) | 0x04)
1813 
1814 /* TODO: rename IT83XX_ECPM_BASE to IT8XXX2_ECPM_BASE */
1815 #define IT8XXX2_ECPM_PLLCTRL    ECREG(IT83XX_ECPM_BASE + 0x03)
1816 #ifndef __ASSEMBLER__
1817 enum chip_pll_mode {
1818 	CHIP_PLL_DOZE = 0,
1819 	CHIP_PLL_SLEEP = 1,
1820 	CHIP_PLL_DEEP_DOZE = 3,
1821 };
1822 #endif
1823 #define IT8XXX2_ECPM_AUTOCG     ECREG(IT83XX_ECPM_BASE + 0x04)
1824 #define IT8XXX2_ECPM_CGCTRL3R   ECREG(IT83XX_ECPM_BASE + 0x05)
1825 #define IT8XXX2_ECPM_PLLFREQR   ECREG(IT83XX_ECPM_BASE + 0x06)
1826 #define IT8XXX2_ECPM_PLLCSS     ECREG(IT83XX_ECPM_BASE + 0x08)
1827 #define IT8XXX2_ECPM_SCDCR0     ECREG(IT83XX_ECPM_BASE + 0x0c)
1828 #define IT8XXX2_ECPM_SCDCR1     ECREG(IT83XX_ECPM_BASE + 0x0d)
1829 #define IT8XXX2_ECPM_SCDCR2     ECREG(IT83XX_ECPM_BASE + 0x0e)
1830 #define IT8XXX2_ECPM_SCDCR3     ECREG(IT83XX_ECPM_BASE + 0x0f)
1831 #define IT8XXX2_ECPM_SCDCR4     ECREG(IT83XX_ECPM_BASE + 0x10)
1832 
1833 /*
1834  * The count number of the counter for 25 ms register.
1835  * The 25 ms register is calculated by (count number *1.024 kHz).
1836  */
1837 
1838 #define I2C_CLK_LOW_TIMEOUT		255 /* ~=249 ms */
1839 
1840 /* SMBus/I2C Interface (SMB/I2C) */
1841 #define IT83XX_SMB_BASE		0x00F01C00
1842 #define IT83XX_SMB_4P7USL		ECREG(IT83XX_SMB_BASE+0x00)
1843 #define IT83XX_SMB_4P0USL		ECREG(IT83XX_SMB_BASE+0x01)
1844 #define IT83XX_SMB_300NS		ECREG(IT83XX_SMB_BASE+0x02)
1845 #define IT83XX_SMB_250NS		ECREG(IT83XX_SMB_BASE+0x03)
1846 #define IT83XX_SMB_25MS			ECREG(IT83XX_SMB_BASE+0x04)
1847 #define IT83XX_SMB_45P3USL		ECREG(IT83XX_SMB_BASE+0x05)
1848 #define IT83XX_SMB_45P3USH		ECREG(IT83XX_SMB_BASE+0x06)
1849 #define IT83XX_SMB_4P7A4P0H		ECREG(IT83XX_SMB_BASE+0x07)
1850 #define IT83XX_SMB_SLVISELR		ECREG(IT83XX_SMB_BASE+0x08)
1851 #define IT83XX_SMB_SCLKTS(ch)	ECREG(IT83XX_SMB_BASE+0x09+ch)
1852 #define IT83XX_SMB_CHSEF		ECREG(IT83XX_SMB_BASE+0x11)
1853 #define IT83XX_SMB_CHSAB		ECREG(IT83XX_SMB_BASE+0x20)
1854 #define IT83XX_SMB_CHSCD		ECREG(IT83XX_SMB_BASE+0x21)
1855 #define IT83XX_SMB_HOSTA(base)	ECREG(base+0x00)
1856 #define IT83XX_SMB_HOCTL(base)	ECREG(base+0x01)
1857 #define IT83XX_SMB_HOCMD(base)	ECREG(base+0x02)
1858 #define IT83XX_SMB_TRASLA(base)	ECREG(base+0x03)
1859 #define IT83XX_SMB_D0REG(base)	ECREG(base+0x04)
1860 #define IT83XX_SMB_D1REG(base)	ECREG(base+0x05)
1861 #define IT83XX_SMB_HOBDB(base)	ECREG(base+0x06)
1862 #define IT83XX_SMB_PECERC(base)	ECREG(base+0x07)
1863 #define IT83XX_SMB_SMBPCTL(base)	ECREG(base+0x0A)
1864 #define IT83XX_SMB_HOCTL2(base)	ECREG(base+0x10)
1865 
1866 /**
1867  * Enhanced SMBus/I2C Interface
1868  * Ch_D: 0x00F03680, Ch_E: 0x00F03500, Ch_F: 0x00F03580
1869  * Ch_D: ch = 0x03, Ch_E: ch = 0x00, Ch_F: ch = 0x01
1870  */
1871 #define IT83XX_I2C_DRR(base)		ECREG(base+0x00)
1872 #define IT83XX_I2C_PSR(base)		ECREG(base+0x01)
1873 #define IT83XX_I2C_HSPR(base)		ECREG(base+0x02)
1874 #define IT83XX_I2C_STR(base)		ECREG(base+0x03)
1875 #define IT83XX_I2C_DHTR(base)		ECREG(base+0x04)
1876 #define IT83XX_I2C_TOR(base)		ECREG(base+0x05)
1877 #define IT83XX_I2C_DTR(base)		ECREG(base+0x08)
1878 #define IT83XX_I2C_CTR(base)		ECREG(base+0x09)
1879 #define IT83XX_I2C_CTR1(base)		ECREG(base+0x0A)
1880 #define IT83XX_I2C_BYTE_CNT_L(base)	ECREG(base+0x0C)
1881 #define IT83XX_I2C_IRQ_ST(base)		ECREG(base+0x0D)
1882 #define IT83XX_I2C_IDR(base)		ECREG(base+0x06)
1883 #define IT83XX_I2C_TOS(base)		ECREG(base+0x07)
1884 #define IT83XX_I2C_IDR2(base)		ECREG(base+0x1F)
1885 #define IT83XX_I2C_RAMHA(base)		ECREG(base+0x23)
1886 #define IT83XX_I2C_RAMLA(base)		ECREG(base+0x24)
1887 #define IT83XX_I2C_RAMHA2(base)		ECREG(base+0x2B)
1888 #define IT83XX_I2C_RAMLA2(base)		ECREG(base+0x2C)
1889 #define IT83XX_I2C_CMD_ADDH(base)	ECREG(base+0x25)
1890 #define IT83XX_I2C_CMD_ADDL(base)	ECREG(base+0x26)
1891 #define IT83XX_I2C_RAMH2A(base)		ECREG(base+0x50)
1892 #define IT83XX_I2C_CMD_ADDH2(base)	ECREG(base+0x52)
1893 
1894 /* --- General Control (GCTRL) --- */
1895 #define IT83XX_GCTRL_BASE 0x00F02000
1896 
1897 #ifdef IT83XX_CHIP_ID_3BYTES
1898 #define IT83XX_GCTRL_CHIPID1         ECREG(IT83XX_GCTRL_BASE + 0x85)
1899 #define IT83XX_GCTRL_CHIPID2         ECREG(IT83XX_GCTRL_BASE + 0x86)
1900 #define IT83XX_GCTRL_CHIPID3         ECREG(IT83XX_GCTRL_BASE + 0x87)
1901 #else
1902 #define IT83XX_GCTRL_CHIPID1         ECREG(IT83XX_GCTRL_BASE + 0x00)
1903 #define IT83XX_GCTRL_CHIPID2         ECREG(IT83XX_GCTRL_BASE + 0x01)
1904 #endif
1905 #define IT83XX_GCTRL_CHIPVER         ECREG(IT83XX_GCTRL_BASE + 0x02)
1906 #define IT83XX_GCTRL_DBGROS          ECREG(IT83XX_GCTRL_BASE + 0x03)
1907 #define IT83XX_SMB_DBGR                    BIT(0)
1908 
1909 /*
1910  * Writing 00h to this register and the CPU program counter will be paused
1911  * until the next low to high transition of the 65.536 clock.
1912  */
1913 #define IT83XX_GCTRL_WNCKR           ECREG(IT83XX_GCTRL_BASE + 0x0B)
1914 #define IT83XX_GCTRL_RSTS            ECREG(IT83XX_GCTRL_BASE + 0x06)
1915 #define IT83XX_GCTRL_BADRSEL         ECREG(IT83XX_GCTRL_BASE + 0x0A)
1916 #define IT83XX_GCTRL_SPCTRL1         ECREG(IT83XX_GCTRL_BASE + 0x0D)
1917 #define IT83XX_GCTRL_RSTDMMC         ECREG(IT83XX_GCTRL_BASE + 0x10)
1918 #define IT83XX_GCTRL_RSTC4           ECREG(IT83XX_GCTRL_BASE + 0x11)
1919 #define IT83XX_GCTRL_SPCTRL4         ECREG(IT83XX_GCTRL_BASE + 0x1C)
1920 #define IT83XX_GCTRL_MCCR3           ECREG(IT83XX_GCTRL_BASE + 0x20)
1921 #define IT83XX_GCTRL_SPISLVPFE             BIT(6)
1922 #define IT83XX_GCTRL_RSTC5           ECREG(IT83XX_GCTRL_BASE + 0x21)
1923 #define IT83XX_GCTRL_MCCR            ECREG(IT83XX_GCTRL_BASE + 0x30)
1924 #define IT83XX_GCTRL_ICACHE_RESET          BIT(4)
1925 #define IT83XX_GCTRL_PMER1           ECREG(IT83XX_GCTRL_BASE + 0x32)
1926 #define IT83XX_GCTRL_PMER2           ECREG(IT83XX_GCTRL_BASE + 0x33)
1927 #define IT83XX_GCTRL_EPLR            ECREG(IT83XX_GCTRL_BASE + 0x37)
1928 #define IT83XX_GCTRL_EPLR_ENABLE           BIT(0)
1929 #define IT83XX_GCTRL_IVTBAR          ECREG(IT83XX_GCTRL_BASE + 0x41)
1930 #define IT83XX_GCTRL_MCCR2           ECREG(IT83XX_GCTRL_BASE + 0x44)
1931 #define IT83XX_GCTRL_PIN_MUX0        ECREG(IT83XX_GCTRL_BASE + 0x46)
1932 #define IT83XX_DLM14_ENABLE                BIT(5)
1933 #define IT83XX_GCTRL_SSCR            ECREG(IT83XX_GCTRL_BASE + 0x4A)
1934 #define IT83XX_GCTRL_ETWDUARTCR      ECREG(IT83XX_GCTRL_BASE + 0x4B)
1935 #define IT83XX_GCTRL_WMCR            ECREG(IT83XX_GCTRL_BASE + 0x4C)
1936 #define IT83XX_GCTRL_H2ROFSR         ECREG(IT83XX_GCTRL_BASE + 0x53)
1937 /* bit[0] = 0 or 1 : disable or enable ETWD hardware reset */
1938 #define ETWD_HW_RST_EN                     BIT(0)
1939 #define IT83XX_GCTRL_RVILMCR0        ECREG(IT83XX_GCTRL_BASE + 0x5D)
1940 #define ILMCR_ILM0_ENABLE                  BIT(0)
1941 #define ILMCR_ILM2_ENABLE                  BIT(2)
1942 #define IT83XX_GCTRL_EWPR0PFH(i)     ECREG(IT83XX_GCTRL_BASE + 0x60 + i)
1943 #define IT83XX_GCTRL_EWPR0PFD(i)     ECREG(IT83XX_GCTRL_BASE + 0xA0 + i)
1944 #define IT83XX_GCTRL_EWPR0PFEC(i)    ECREG(IT83XX_GCTRL_BASE + 0xC0 + i)
1945 
1946 /* Serial Peripheral Interface (SPI) */
1947 #define IT83XX_SPI_BASE  0x00F03A00
1948 
1949 #define IT83XX_SPI_SPISGCR           ECREG(IT83XX_SPI_BASE + 0x00)
1950 #define IT83XX_SPI_SPISCEN                 BIT(0)
1951 #define IT83XX_SPI_TXRXFAR           ECREG(IT83XX_SPI_BASE + 0x01)
1952 #define IT83XX_SPI_CPURXF2A                BIT(4)
1953 #define IT83XX_SPI_CPURXF1A                BIT(3)
1954 #define IT83XX_SPI_CPUTFA                  BIT(1)
1955 #define IT83XX_SPI_TXFCR             ECREG(IT83XX_SPI_BASE + 0x02)
1956 #define IT83XX_SPI_TXFCMR                  BIT(2)
1957 #define IT83XX_SPI_TXFR                    BIT(1)
1958 #define IT83XX_SPI_TXFS                    BIT(0)
1959 #define IT83XX_SPI_GCR2              ECREG(IT83XX_SPI_BASE + 0x03)
1960 #define IT83XX_SPI_RXF2OC                  BIT(4)
1961 #define IT83XX_SPI_RXF1OC                  BIT(3)
1962 #define IT83XX_SPI_RXFAR                   BIT(0)
1963 #define IT83XX_SPI_IMR               ECREG(IT83XX_SPI_BASE + 0x04)
1964 #define IT83XX_SPI_RX_FIFO_FULL            BIT(7)
1965 #define IT83XX_SPI_RX_REACH                BIT(5)
1966 #define IT83XX_SPI_EDIM                    BIT(2)
1967 #define IT83XX_SPI_ISR               ECREG(IT83XX_SPI_BASE + 0x05)
1968 #define IT83XX_SPI_TXFSR             ECREG(IT83XX_SPI_BASE + 0x06)
1969 #define IT83XX_SPI_ENDDETECTINT            BIT(2)
1970 #define IT83XX_SPI_RXFSR             ECREG(IT83XX_SPI_BASE + 0x07)
1971 #define IT83XX_SPI_RXFFSM                  (BIT(4) | BIT(3))
1972 #define IT83XX_SPI_RXF2FS                  BIT(2)
1973 #define IT83XX_SPI_RXF1FS                  BIT(1)
1974 #ifdef CHIP_VARIANT_IT83202BX
1975 #define IT83XX_SPI_SPISRDR           ECREG(IT83XX_SPI_BASE + 0x08)
1976 #else
1977 #define IT83XX_SPI_SPISRDR           ECREG(IT83XX_SPI_BASE + 0x0b)
1978 #endif
1979 #define IT83XX_SPI_CPUWTFDB0         ECREG_u32(IT83XX_SPI_BASE + 0x08)
1980 #define IT83XX_SPI_FCR               ECREG(IT83XX_SPI_BASE + 0x09)
1981 #define IT83XX_SPI_SPISRTXF                BIT(2)
1982 #define IT83XX_SPI_RXFR                    BIT(1)
1983 #define IT83XX_SPI_RXFCMR                  BIT(0)
1984 #define IT83XX_SPI_RXFRDRB0          ECREG_u32(IT83XX_SPI_BASE + 0x0C)
1985 #define IT83XX_SPI_FTCB0R            ECREG(IT83XX_SPI_BASE + 0x18)
1986 #define IT83XX_SPI_FTCB1R            ECREG(IT83XX_SPI_BASE + 0x19)
1987 #define IT83XX_SPI_TCCB0             ECREG(IT83XX_SPI_BASE + 0x1A)
1988 #define IT83XX_SPI_TCCB1             ECREG(IT83XX_SPI_BASE + 0x1B)
1989 #define IT83XX_SPI_HPR2              ECREG(IT83XX_SPI_BASE + 0x1E)
1990 #define IT83XX_SPI_EMMCBMR           ECREG(IT83XX_SPI_BASE + 0x21)
1991 #define IT83XX_SPI_EMMCABM                 BIT(1) /* eMMC Alternative Boot Mode */
1992 #define IT83XX_SPI_RX_VLISMR         ECREG(IT83XX_SPI_BASE + 0x26)
1993 #define IT83XX_SPI_RVLIM                   BIT(0)
1994 #define IT83XX_SPI_RX_VLISR          ECREG(IT83XX_SPI_BASE + 0x27)
1995 #define IT83XX_SPI_RVLI                    BIT(0)
1996 
1997 /**
1998  *
1999  * (20xxh) General Control (GCTRL) registers
2000  *
2001  */
2002 #ifndef __ASSEMBLER__
2003 struct gctrl_it8xxx2_regs {
2004 	/* 0x00-0x01: Reserved1 */
2005 	volatile uint8_t reserved1[2];
2006 	/* 0x02: Chip Version */
2007 	volatile uint8_t GCTRL_ECHIPVER;
2008 	/* 0x03-0x05: Reserved2 */
2009 	volatile uint8_t reserved2[3];
2010 	/* 0x06: Reset Status */
2011 	volatile uint8_t GCTRL_RSTS;
2012 	/* 0x07-0x1B: Reserved3 */
2013 	volatile uint8_t reserved3[21];
2014 	/* 0x1C: Special Control 4 */
2015 	volatile uint8_t GCTRL_SPCTRL4;
2016 	/* 0x1D-0x1F: Reserved4 */
2017 	volatile uint8_t reserved4[3];
2018 	/* 0x20: Memory Controller Configuration 3 */
2019 	volatile uint8_t GCTRL_MCCR3;
2020 	/* 0x21: Reset Control 5 */
2021 	volatile uint8_t GCTRL_RSTC5;
2022 	/* 0x22-0x2F: Reserved5 */
2023 	volatile uint8_t reserved5[14];
2024 	/* 0x30: Memory Controller Configuration */
2025 	volatile uint8_t GCTRL_MCCR;
2026 	/* 0x31: Externel ILM/DLM Size */
2027 	volatile uint8_t GCTRL_EIDSR;
2028 	/* 0x32-0x36: Reserved6 */
2029 	volatile uint8_t reserved6[5];
2030 	/* 0x37: Eflash Protect Lock */
2031 	volatile uint8_t GCTRL_EPLR;
2032 	/* 0x38-0x40: Reserved7 */
2033 	volatile uint8_t reserved7[9];
2034 	/* 0x41: Interrupt Vector Table Base Address */
2035 	volatile uint8_t GCTRL_IVTBAR;
2036 	/* 0x42-0x43: Reserved8 */
2037 	volatile uint8_t reserved8[2];
2038 	/* 0x44: Memory Controller Configuration 2 */
2039 	volatile uint8_t GCTRL_MCCR2;
2040 	/* 0x45: Reserved9 */
2041 	volatile uint8_t reserved9;
2042 	/* 0x46: Pin Multi-function Enable 3 */
2043 	volatile uint8_t GCTRL_PMER3;
2044 	/* 0x47-0x4A: Reserved10 */
2045 	volatile uint8_t reserved10[4];
2046 	/* 0x4B: ETWD and UART Control */
2047 	volatile uint8_t GCTRL_ETWDUARTCR;
2048 	/* 0x4C: Wakeup MCU Control */
2049 	volatile uint8_t GCTRL_WMCR;
2050 	/* 0x4D-0x84: Reserved11 */
2051 	volatile uint8_t reserved11[56];
2052 	/* 0x85: Chip ID Byte 1 */
2053 	volatile uint8_t GCTRL_ECHIPID1;
2054 	/* 0x86: Chip ID Byte 2 */
2055 	volatile uint8_t GCTRL_ECHIPID2;
2056 	/* 0x87: Chip ID Byte 3 */
2057 	volatile uint8_t GCTRL_ECHIPID3;
2058 };
2059 #endif /* !__ASSEMBLER__ */
2060 
2061 /* GCTRL register fields */
2062 /* 0x06: Reset Status */
2063 #define IT8XXX2_GCTRL_LRS		(BIT(1) | BIT(0))
2064 #define IT8XXX2_GCTRL_IWDTR		BIT(1)
2065 /* 0x1C: Special Control 4 */
2066 #define IT8XXX2_GCTRL_LRSIWR		BIT(2)
2067 #define IT8XXX2_GCTRL_LRSIPWRSWTR	BIT(1)
2068 #define IT8XXX2_GCTRL_LRSIPGWR		BIT(0)
2069 /* 0x4B: ETWD and UART Control */
2070 #define IT8XXX2_GCTRL_ETWD_HW_RST_EN	BIT(0)
2071 
2072 #endif /* CHIP_CHIPREGS_H */
2073