/** * @brief read and clear GPE0_STS * @return GPE0_STS register */ u64 reset_gpe0_status(void) { u32 reg_h, reg_l; reg_l = read_pmbase32(GPE0_STS); reg_h = read_pmbase32(GPE0_STS + 4); /* set status bits are cleared by writing 1 to them */ write_pmbase32(GPE0_STS, reg_l); write_pmbase32(GPE0_STS + 4, reg_h); return (((u64)reg_h) << 32) | reg_l; }
/** * @brief read and clear TCOx_STS * @return TCOx_STS registers */ u32 reset_tco_status(void) { u32 reg32; reg32 = read_pmbase32(TCO1_STS); /* * set status bits are cleared by writing 1 to them, but don't * clear BOOT_STS before SECOND_TO_STS. */ write_pmbase32(TCO1_STS, reg32 & ~BOOT_STS); if (reg32 & BOOT_STS) write_pmbase32(TCO1_STS, BOOT_STS); return reg32; }
static u8 mainboard_smi_ec(void) { u8 src; #if CONFIG(ELOG_GSMI) static int battery_critical_logged; #endif ec_kbc_write_cmd(0x56); src = ec_kbc_read_ob(); printk(BIOS_DEBUG, "mainboard_smi_ec src: %x\n", src); switch (src) { case EC_BATTERY_CRITICAL: #if CONFIG(ELOG_GSMI) if (!battery_critical_logged) elog_add_event_byte(ELOG_TYPE_EC_EVENT, EC_EVENT_BATTERY_CRITICAL); battery_critical_logged = 1; #endif break; case EC_LID_CLOSE: printk(BIOS_DEBUG, "LID CLOSED, SHUTDOWN\n"); #if CONFIG(ELOG_GSMI) elog_add_event_byte(ELOG_TYPE_EC_EVENT, EC_EVENT_LID_CLOSED); #endif /* Go to S5 */ write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) | (0xf << 10)); break; } return src; }
void gpe0_mask(u32 clr, u32 set) { u32 gpe0 = read_pmbase32(GPE0_EN); gpe0 &= ~clr; gpe0 |= set; write_pmbase32(GPE0_EN, gpe0); }
/** * @brief read and clear SMI_STS * @return SMI_STS register */ u32 reset_smi_status(void) { u32 reg32; reg32 = read_pmbase32(SMI_STS); /* set status bits are cleared by writing 1 to them */ write_pmbase32(SMI_STS, reg32); return reg32; }
void mainboard_smi_gpi(u32 gpi_sts) { printk(BIOS_DEBUG, "mainboard_smi_gpi: %x\n", gpi_sts); if (gpi_sts & (1 << EC_SMI_GPI)) { /* Process all pending events from EC */ while (mainboard_smi_ec() != EC_NO_EVENT); } else if (gpi_sts & (1 << EC_LID_GPI)) { printk(BIOS_DEBUG, "LID CLOSED, SHUTDOWN\n"); #if CONFIG(ELOG_GSMI) elog_add_event_byte(ELOG_TYPE_EC_EVENT, EC_EVENT_LID_CLOSED); #endif /* Go to S5 */ write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) | (0xf << 10)); } }
static u8 mainboard_smi_ec(void) { u8 cmd = google_chromeec_get_event(); #if CONFIG(ELOG_GSMI) /* Log this event */ if (cmd) elog_add_event_byte(ELOG_TYPE_EC_EVENT, cmd); #endif switch (cmd) { case EC_HOST_EVENT_LID_CLOSED: printk(BIOS_DEBUG, "LID CLOSED, SHUTDOWN\n"); /* Go to S5 */ write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) | (0xf << 10)); break; } return cmd; }