Enable PNP devices by default, attempt to send/receive data from touchpad

This commit is contained in:
Jeremy Soller
2019-11-15 16:47:56 -07:00
parent 512e52a408
commit 7614873b19
5 changed files with 124 additions and 6 deletions

View File

@ -79,6 +79,42 @@ void ac_adapter() {
last = new;
}
volatile uint8_t __xdata __at(0x1200) IHIOA;
volatile uint8_t __xdata __at(0x1201) IHD;
volatile uint8_t __xdata __at(0x1204) IBMAE;
volatile uint8_t __xdata __at(0x1205) IBCTL;
void e2ci_write(uint8_t port, uint8_t data) {
while (IBCTL & ((1 << 2) | (1 << 1))) {}
IHIOA = port;
IHD = data;
IBMAE = 1;
IBCTL = 1;
while (IBCTL & (1 << 2)) {}
IBMAE = 0;
IBCTL = 0;
}
void pnp_write(uint8_t reg, uint8_t data) {
e2ci_write(0x2E, reg);
e2ci_write(0x2F, data);
}
void pnp_enable() {
printf("Enable PNP devices\n");
// Enable KBC keyboard
pnp_write(0x07, 0x06);
pnp_write(0x30, 0x01);
// Enable KBC mouse
pnp_write(0x07, 0x05);
pnp_write(0x30, 0x01);
// Enable SWUC
pnp_write(0x07, 0x04);
pnp_write(0x30, 0x01);
}
void power_button() {
static struct Gpio __code PCH_DPWROK_EC = GPIO(A, 3);
static struct Gpio __code PCH_PWROK_EC = GPIO(A, 4);
@ -209,6 +245,9 @@ void power_button() {
if (value) break;
delay_ms(1);
}
// enable pnp devices
pnp_enable();
} else {
printf("Disabling power\n");
@ -275,9 +314,21 @@ void power_button() {
last = new;
}
// void touchpad_event(struct Ps2 * ps2) {
// //TODO
// }
void touchpad_event(struct Ps2 * ps2) {
if (kbc_second) {
*(ps2->control) = 0x07;
} else {
*(ps2->control) = 0x01;
}
uint8_t status = *(ps2->status);
*(ps2->status) = status;
if (status & (1 << 3)) {
uint8_t data = *(ps2->data);
printf("touchpad: %02X\n", data);
kbc_mouse(&KBC, data, 1000);
}
}
struct Gpio __code LED_SSD_N = GPIO(G, 6);
struct Gpio __code LED_AIRPLANE_N = GPIO(G, 6);