Remove lpc implementation, use safer kernel Ec system
This commit is contained in:
parent
291223ea20
commit
d1ec9f4cff
62
lpc.c
62
lpc.c
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
@ -16,8 +16,6 @@
|
||||||
#include <linux/pci_ids.h>
|
#include <linux/pci_ids.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
#include "lpc.c"
|
|
||||||
|
|
||||||
struct system76_data {
|
struct system76_data {
|
||||||
struct acpi_device * acpi_dev;
|
struct acpi_device * acpi_dev;
|
||||||
struct led_classdev ap_led;
|
struct led_classdev ap_led;
|
||||||
|
|
@ -265,17 +263,13 @@ static int system76_add(struct acpi_device *acpi_dev) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable camera toggle
|
// Probe EC devices
|
||||||
struct Lpc lpc = lpc_new();
|
u8 d = 0;
|
||||||
if (lpc_cmd(&lpc, 0xA8, 1000000)) {
|
err = ec_transaction(0xA8, NULL, 0, &d, 1);
|
||||||
u8 data = 0;
|
if(err) {
|
||||||
if (lpc_read(&lpc, &data, 1000000)) {
|
printk("system76-coreboot: failed to probe EC devices: %d\n", err);
|
||||||
printk("system76-coreboot: EC devices: 0x%x\n", data);
|
|
||||||
} else {
|
|
||||||
printk("system76-coreboot: failed to read EC devices\n");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
printk("system76-coreboot: failed to probe EC devices\n");
|
printk("system76-coreboot: EC devices: 0x%x\n", d);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue