| 1 |
|
| 2 |
|
| 3 |
#include <arch/io.h> |
| 4 |
#include <device/pci_ops.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <cpu/x86/smm.h> |
| 7 |
#include <ec/acpi/ec.h> |
| 8 |
#include <ec/lenovo/h8/h8.h> |
| 9 |
#include <southbridge/intel/lynxpoint/pch.h> |
| 10 |
|
| 11 |
#define GPE_EC_SCI 1 |
| 12 |
#define GPE_EC_WAKE 13 |
| 13 |
|
| 14 |
static void mainboard_smi_handle_ec_sci(void) |
| 15 |
{ |
| 16 |
u8 status = inb(EC_SC); |
| 17 |
u8 event; |
| 18 |
|
| 19 |
if (!(status & EC_SCI_EVT)) |
| 20 |
return; |
| 21 |
|
| 22 |
event = ec_query(); |
| 23 |
printk(BIOS_DEBUG, "EC event %#02x\n", event); |
| 24 |
} |
| 25 |
|
| 26 |
void mainboard_smi_gpi(u32 gpi_sts) |
| 27 |
{ |
| 28 |
if (gpi_sts & (1 << GPE_EC_SCI)) |
| 29 |
mainboard_smi_handle_ec_sci(); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
#define GPI_DISABLE 0x00 |
| 34 |
#define GPI_IS_SMI 0x01 |
| 35 |
#define GPI_IS_SCI 0x02 |
| 36 |
#define GPI_IS_NMI 0x03 |
| 37 |
|
| 38 |
static void gpi_route_interrupt(u8 gpi, u8 mode) |
| 39 |
{ |
| 40 |
u32 gpi_rout; |
| 41 |
|
| 42 |
gpi_rout = pci_read_config32(PCI_DEV(0, 0x1f, 0), GPIO_ROUT); |
| 43 |
gpi_rout &= ~(3 << (2 * gpi)); |
| 44 |
gpi_rout |= ((mode & 3) << (2 * gpi)); |
| 45 |
pci_write_config32(PCI_DEV(0, 0x1f, 0), GPIO_ROUT, gpi_rout); |
| 46 |
} |
| 47 |
|
| 48 |
int mainboard_smi_apmc(u8 data) |
| 49 |
{ |
| 50 |
switch (data) { |
| 51 |
case APM_CNT_ACPI_ENABLE: |
| 52 |
|
| 53 |
ec_set_ports(0x1604, 0x1600); |
| 54 |
|
| 55 |
gpi_route_interrupt(GPE_EC_SCI, GPI_IS_SCI); |
| 56 |
|
| 57 |
ec_write(0x80, 0x01); |
| 58 |
break; |
| 59 |
case APM_CNT_ACPI_DISABLE: |
| 60 |
|
| 61 |
|
| 62 |
ec_set_ports(0x66, 0x62); |
| 63 |
|
| 64 |
gpi_route_interrupt(GPE_EC_SCI, GPI_IS_SMI); |
| 65 |
|
| 66 |
ec_write(0x80, 0x01); |
| 67 |
break; |
| 68 |
default: |
| 69 |
break; |
| 70 |
} |
| 71 |
return 0; |
| 72 |
} |
| 73 |
|
| 74 |
void mainboard_smi_sleep(u8 slp_typ) |
| 75 |
{ |
| 76 |
if (slp_typ == 3) { |
| 77 |
u8 ec_wake = ec_read(0x32); |
| 78 |
|
| 79 |
|
| 80 |
if (ec_wake & 0x14) { |
| 81 |
|
| 82 |
gpi_route_interrupt(GPE_EC_WAKE, GPI_IS_SCI); |
| 83 |
} |
| 84 |
} |
| 85 |
} |