5 func LenovoEC(ctx Context
) {
6 ap
:= Create(ctx
, "acpi/platform.asl")
11 sbGPE
:= GuessECGPE(ctx
)
15 sbGPE
= SouthBridge
.EncodeGPE(1)
18 SouthBridge
.NeedRouteGPIOManually()
20 GPE
= SouthBridge
.DecodeGPE(sbGPE
)
24 SouthBridge
.EnableGPE(wakeGPE
)
25 SouthBridge
.EnableGPE(GPE
)
27 GPEDefine
:= DSDTDefine
{
28 Key
: "THINKPAD_EC_GPE",
31 GPEDefine
.Value
= fmt
.Sprintf("%d", sbGPE
)
33 GPEDefine
.Comment
= "FIXME: Check this"
36 DSDTDefines
= append(DSDTDefines
,
38 Key
: "EC_LENOVO_H8_ME_WORKAROUND",
46 /* ME may not be up yet. */
49 Return(Package() {0, 0})
54 \_SB.PCI0.LPCB.EC.RADI(0)
58 si
:= Create(ctx
, "acpi/superio.asl")
62 si
.WriteString("#include <drivers/pc80/pc/ps2_controller.asl>\n")
64 /* FIXME:XX Move this to ec/lenovo. */
65 smi
:= Create(ctx
, "smihandler.c")
68 AddSMMFile("smihandler.c", "")
73 #include <console/console.h>
74 #include <cpu/x86/smm.h>
75 #include <ec/acpi/ec.h>
76 #include <ec/lenovo/h8/h8.h>
78 #include <` + SouthBridge
.GetGPIOHeader() + ">\n\n")
81 smi
.WriteString("/* FIXME: check this */\n")
83 fmt
.Fprintf(smi
, "#define GPE_EC_SCI %d\n", GPE
)
85 smi
.WriteString("/* FIXME: check this */\n")
86 fmt
.Fprintf(smi
, "#define GPE_EC_WAKE %d\n", wakeGPE
)
89 static void mainboard_smm_init(void)
91 printk(BIOS_DEBUG, "initializing SMI\n");
92 /* Enable 0x1600/0x1600 register pair */
93 ec_set_bit(0x00, 0x05);
96 int mainboard_io_trap_handler(int smif)
98 static int smm_initialized;
100 if (!smm_initialized) {
101 mainboard_smm_init();
108 static void mainboard_smi_handle_ec_sci(void)
110 u8 status = inb(EC_SC);
113 if (!(status & EC_SCI_EVT))
117 printk(BIOS_DEBUG, "EC event %#02x\n", event);
120 void mainboard_smi_gpi(u32 gpi_sts)
122 if (gpi_sts & (1 << GPE_EC_SCI))
123 mainboard_smi_handle_ec_sci();
126 int mainboard_smi_apmc(u8 data)
129 case APM_CNT_ACPI_ENABLE:
130 /* use 0x1600/0x1604 to prevent races with userspace */
131 ec_set_ports(0x1604, 0x1600);
132 /* route EC_SCI to SCI */
133 gpi_route_interrupt(GPE_EC_SCI, GPI_IS_SCI);
134 /* discard all events, and enable attention */
135 ec_write(0x80, 0x01);
137 case APM_CNT_ACPI_DISABLE:
138 /* we have to use port 0x62/0x66, as 0x1600/0x1604 doesn't
139 provide a EC query function */
140 ec_set_ports(0x66, 0x62);
141 /* route EC_SCI to SMI */
142 gpi_route_interrupt(GPE_EC_SCI, GPI_IS_SMI);
143 /* discard all events, and enable attention */
144 ec_write(0x80, 0x01);
152 void mainboard_smi_sleep(u8 slp_typ)
155 u8 ec_wake = ec_read(0x32);
156 /* If EC wake events are enabled, enable wake on EC WAKE GPE. */
157 if (ec_wake & 0x14) {
158 /* Redirect EC WAKE GPE to SCI. */
159 gpi_route_interrupt(GPE_EC_WAKE, GPI_IS_SCI);
165 ec
:= Create(ctx
, "acpi/ec.asl")
169 ec
.WriteString("#include <ec/lenovo/h8/acpi/ec.asl>\n")
171 KconfigBool
["EC_LENOVO_PMH7"] = true
172 KconfigBool
["EC_LENOVO_H8"] = true
175 Chip
: "ec/lenovo/pmh7",
176 Registers
: map[string]string{
177 "backlight_enable": "0x01",
178 "dock_event_enable": "0x01",
180 Children
: []DevTreeNode
{
191 ecs
:= ctx
.InfoSource
.GetEC()
193 Chip
: "ec/lenovo/h8",
194 Children
: []DevTreeNode
{
200 IOs
: map[uint16]uint16{
208 Comment
: "FIXME: has_keyboard_backlight, has_power_management_beeps, has_uwb",
209 Registers
: map[string]string{
210 "config0": FormatHex8(ecs
[0]),
211 "config1": FormatHex8(ecs
[1]),
212 "config2": FormatHex8(ecs
[2]),
213 "config3": FormatHex8(ecs
[3]),
214 "beepmask0": FormatHex8(ecs
[4]),
215 "beepmask1": FormatHex8(ecs
[5]),
218 for i
:= 0; i
< 0x10; i
++ {
219 if ecs
[0x10+i
] != 0 {
220 h8
.Registers
[fmt
.Sprintf("event%x_enable", i
)] = FormatHex8(ecs
[0x10+i
])
225 eeprom
:= DevTreeNode
{
226 Chip
: "drivers/i2c/at24rf08c",
227 Comment
: "eeprom, 8 virtual devices, same chip",
228 Children
: []DevTreeNode
{
263 PutChip("smbus", eeprom
)