Remove lpc implementation, use safer kernel Ec system

This commit is contained in:
Jeremy Soller 2019-04-24 16:25:43 -06:00
parent 291223ea20
commit d1ec9f4cff
2 changed files with 6 additions and 74 deletions

62
lpc.c
View File

@ -1,62 +0,0 @@
struct Lpc {
u16 data_port;
u16 cmd_port;
};
static struct Lpc lpc_new(void) {
struct Lpc lpc = {
.data_port = 0x62,
.cmd_port = 0x66,
};
return lpc;
}
static u8 lpc_sts(struct Lpc * lpc) {
return inb(lpc->cmd_port);
}
static bool lpc_can_read(struct Lpc * lpc) {
return (lpc_sts(lpc) & 1) == 1;
}
static int lpc_wait_read(struct Lpc * lpc, int timeout) {
while (! lpc_can_read(lpc) && timeout > 0) {
timeout -= 1;
}
return timeout;
}
static bool lpc_can_write(struct Lpc * lpc) {
return (lpc_sts(lpc) & 2) == 0;
}
static int lpc_wait_write(struct Lpc * lpc, int timeout) {
while (! lpc_can_write(lpc) && timeout > 0) {
timeout -= 1;
}
return timeout;
}
static int lpc_cmd(struct Lpc * lpc, u8 data, int timeout) {
timeout = lpc_wait_write(lpc, timeout);
if (timeout > 0) {
outb(lpc->cmd_port, data);
}
return timeout;
}
static int lpc_read(struct Lpc * lpc, u8 * data, int timeout) {
timeout = lpc_wait_read(lpc, timeout);
if (timeout > 0) {
*data = inb(lpc->data_port);
}
return timeout;
}
static int lpc_write(struct Lpc * lpc, u8 data, int timeout) {
timeout = lpc_wait_write(lpc, timeout);
if (timeout > 0) {
outb(lpc->data_port, data);
}
return timeout;
}

View File

@ -16,8 +16,6 @@
#include <linux/pci_ids.h>
#include <linux/types.h>
#include "lpc.c"
struct system76_data {
struct acpi_device * acpi_dev;
struct led_classdev ap_led;
@ -265,17 +263,13 @@ static int system76_add(struct acpi_device *acpi_dev) {
}
}
// Enable camera toggle
struct Lpc lpc = lpc_new();
if (lpc_cmd(&lpc, 0xA8, 1000000)) {
u8 data = 0;
if (lpc_read(&lpc, &data, 1000000)) {
printk("system76-coreboot: EC devices: 0x%x\n", data);
// Probe EC devices
u8 d = 0;
err = ec_transaction(0xA8, NULL, 0, &d, 1);
if(err) {
printk("system76-coreboot: failed to probe EC devices: %d\n", err);
} else {
printk("system76-coreboot: failed to read EC devices\n");
}
} else {
printk("system76-coreboot: failed to probe EC devices\n");
printk("system76-coreboot: EC devices: 0x%x\n", d);
}
return 0;