Enable PNP devices by default, attempt to send/receive data from touchpad
This commit is contained in:
@ -5,6 +5,9 @@
|
||||
|
||||
#include <ec/kbc.h>
|
||||
|
||||
extern bool kbc_first;
|
||||
extern bool kbc_second;
|
||||
|
||||
void kbc_init(void);
|
||||
bool kbc_scancode(struct Kbc * kbc, uint16_t key, bool pressed);
|
||||
void kbc_event(struct Kbc * kbc);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <board/kbc.h>
|
||||
#include <board/kbscan.h>
|
||||
#include <board/keymap.h>
|
||||
#include <ec/ps2.h>
|
||||
|
||||
void kbc_init(void) {
|
||||
// Disable interrupts
|
||||
@ -15,9 +16,9 @@ void kbc_init(void) {
|
||||
// System flag
|
||||
static bool kbc_system = false;
|
||||
// Enable first port - TODO
|
||||
static bool kbc_first = false;
|
||||
bool kbc_first = false;
|
||||
// Enable second port - TODO
|
||||
static bool kbc_second = false;
|
||||
bool kbc_second = false;
|
||||
// Translate from scancode set 2 to scancode set 1
|
||||
// for basically no good reason
|
||||
static bool kbc_translate = true;
|
||||
@ -243,7 +244,7 @@ void kbc_event(struct Kbc * kbc) {
|
||||
case KBC_STATE_SECOND_PORT_INPUT:
|
||||
printf(" write second port input\n");
|
||||
state = KBC_STATE_NORMAL;
|
||||
// TODO: mouse commands (write to touchpad?)
|
||||
ps2_write(&PS2_3, &data, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user