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; }
u8 ec_it8518_get_event(void) { u8 cmd = 0; u8 status = inb(EC_SC); if (status & SCI_EVT) { ec_write_cmd(QR_EC); cmd = ec_read_ob(); } else if ( status & SMI_EVT) { ec_kbc_write_cmd(EC_KBD_SMI_EVENT); cmd = ec_kbc_read_ob(); } return cmd; }
void parrot_ec_init(void) { printk(BIOS_DEBUG, "Parrot EC Init\n"); /* Clean up the buffers. We don't know the initial condition. */ kbc_cleanup_buffers(); /* Report EC info */ /* EC version: cmd 0x51 - returns three bytes */ ec_kbc_write_cmd(0x51); printk(BIOS_DEBUG," EC version %x.%x.%x\n", ec_kbc_read_ob(), ec_kbc_read_ob(), ec_kbc_read_ob()); /* EC Project name: cmd 0x52, 0xA0 - returns five bytes */ ec_kbc_write_cmd(0x52); ec_kbc_write_ib(0xA0); printk(BIOS_DEBUG," EC Project: %c%c%c%c%c\n", ec_kbc_read_ob(),ec_kbc_read_ob(),ec_kbc_read_ob(), ec_kbc_read_ob(), ec_kbc_read_ob()); /* Print the hardware revision */ printk(BIOS_DEBUG," Parrot Revision %x\n", parrot_rev()); /* US Keyboard */ ec_kbc_write_cmd(0x59); ec_kbc_write_ib(0xE5); /* Enable IRQ1 */ ec_kbc_write_cmd(0x59); ec_kbc_write_ib(0xD1); /* TODO - Do device detection and device maintain state (nvs) */ /* Enable Wireless and Bluetooth */ ec_kbc_write_cmd(0x45); ec_kbc_write_ib(0xAD); /* Set Wireless and Bluetooth Available */ ec_kbc_write_cmd(0x45); ec_kbc_write_ib(0xA8); /* Set Wireless and Bluetooth Enable */ ec_kbc_write_cmd(0x45); ec_kbc_write_ib(0xA2); }
/* Parrot Hardware Revision */ u8 parrot_rev(void) { ec_kbc_write_cmd(0x45); ec_kbc_write_ib(0x40); return ec_kbc_read_ob(); }