1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright 2019 Google LLC
4 /*
5  * Taken from coreboot file of the same name
6  */
7 
8 #ifndef VARIANT_EC_H
9 #define VARIANT_EC_H
10 
11 #include "variant_gpio.h"
12 #include <ec_commands.h>
13 
14 #define MAINBOARD_EC_SCI_EVENTS \
15 	(EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED)        |\
16 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN)          |\
17 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_CONNECTED)      |\
18 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_DISCONNECTED)   |\
19 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_LOW)       |\
20 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_CRITICAL)  |\
21 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY)           |\
22 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_STATUS)    |\
23 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_THRESHOLD) |\
24 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_THROTTLE_START)    |\
25 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_THROTTLE_STOP)     |\
26 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_USB_CHARGER)       |\
27 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_MKBP)              |\
28 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU)            |\
29 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_MODE_CHANGE))
30 
31 #define MAINBOARD_EC_SMI_EVENTS \
32 	(EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED))
33 
34 /* EC can wake from S5 with lid or power button */
35 #define MAINBOARD_EC_S5_WAKE_EVENTS \
36 	(EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN)     |\
37 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON))
38 
39 /* EC can wake from S3 with lid or power button or key press */
40 #define MAINBOARD_EC_S3_WAKE_EVENTS \
41 	(MAINBOARD_EC_S5_WAKE_EVENTS |\
42 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEY_PRESSED))
43 
44 #define MAINBOARD_EC_S0IX_WAKE_EVENTS	(MAINBOARD_EC_S3_WAKE_EVENTS)
45 
46 /* Log EC wake events plus EC shutdown events */
47 #define MAINBOARD_EC_LOG_EVENTS \
48 	(EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_SHUTDOWN) | \
49 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_SHUTDOWN) | \
50 	 EC_HOST_EVENT_MASK(EC_HOST_EVENT_PANIC))
51 
52 /*
53  * ACPI related definitions for ASL code.
54  */
55 
56 /* Enable EC backed ALS device in ACPI */
57 #define EC_ENABLE_ALS_DEVICE
58 
59 /* Enable EC backed PD MCU device in ACPI */
60 #define EC_ENABLE_PD_MCU_DEVICE
61 
62 /* Enable LID switch and provide wake pin for EC */
63 #define EC_ENABLE_LID_SWITCH
64 #define EC_ENABLE_WAKE_PIN	GPE_EC_WAKE
65 
66 #define EC_ENABLE_TBMC_DEVICE
67 
68 #define SIO_EC_MEMMAP_ENABLE     /* EC Memory Map Resources */
69 #define SIO_EC_HOST_ENABLE       /* EC Host Interface Resources */
70 #define SIO_EC_ENABLE_PS2K       /* Enable PS/2 Keyboard */
71 
72 /* Enable EC backed Keyboard Backlight in ACPI */
73 #define EC_ENABLE_KEYBOARD_BACKLIGHT
74 
75 #endif
76