From d1ec9f4cffe22afec4ac4f1c3d8d7e9410898a48 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 24 Apr 2019 16:25:43 -0600 Subject: [PATCH] Remove lpc implementation, use safer kernel Ec system --- lpc.c | 62 --------------------------------------------- system76-coreboot.c | 18 +++++-------- 2 files changed, 6 insertions(+), 74 deletions(-) delete mode 100644 lpc.c diff --git a/lpc.c b/lpc.c deleted file mode 100644 index 2698b24..0000000 --- a/lpc.c +++ /dev/null @@ -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; -} diff --git a/system76-coreboot.c b/system76-coreboot.c index 8c1f2b0..ff96e8c 100644 --- a/system76-coreboot.c +++ b/system76-coreboot.c @@ -16,8 +16,6 @@ #include #include -#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); - } else { - printk("system76-coreboot: failed to read EC devices\n"); - } + // 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 probe EC devices\n"); + printk("system76-coreboot: EC devices: 0x%x\n", d); } return 0;