From 08e9a4f812bb8d55bae2f4bf148eaa67c39d5ba1 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Thu, 22 Jul 2021 13:54:38 +0200 Subject: [PATCH] ec/purism: Remove copied code from system76 This code is identical except for some renaming. Change-Id: I93795a6087ce0daca27c0d5038a1febd6ca9c775 Signed-off-by: Arthur Heymans Reviewed-on: https://review.coreboot.org/c/coreboot/+/56522 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier --- src/ec/purism/librem-ec/Makefile.inc | 4 +- src/ec/purism/librem-ec/librem_ec.c | 61 ---------------------------- 2 files changed, 2 insertions(+), 63 deletions(-) delete mode 100644 src/ec/purism/librem-ec/librem_ec.c diff --git a/src/ec/purism/librem-ec/Makefile.inc b/src/ec/purism/librem-ec/Makefile.inc index c3b66196d6..a3d55532df 100644 --- a/src/ec/purism/librem-ec/Makefile.inc +++ b/src/ec/purism/librem-ec/Makefile.inc @@ -1,6 +1,6 @@ ifeq ($(CONFIG_EC_LIBREM_EC),y) -all-y += librem_ec.c -smm-$(CONFIG_DEBUG_SMI) += librem_ec.c +all-y += ../../system76/ec/system76_ec.c +smm-$(CONFIG_DEBUG_SMI) += ../../system76/ec/system76_ec.c endif diff --git a/src/ec/purism/librem-ec/librem_ec.c b/src/ec/purism/librem-ec/librem_ec.c deleted file mode 100644 index 6615f83ef6..0000000000 --- a/src/ec/purism/librem-ec/librem_ec.c +++ /dev/null @@ -1,61 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#include -#include -#include - -// This is the command region for Librem EC firmware. It must be -// enabled for LPC in the mainboard. -#define LIBREM_EC_BASE 0x0E00 -#define LIBREM_EC_SIZE 256 - -#define REG_CMD 0 -#define REG_RESULT 1 - -// When command register is 0, command is complete -#define CMD_FINISHED 0 - -// Print command. Registers are unique for each command -#define CMD_PRINT 4 -#define CMD_PRINT_REG_FLAGS 2 -#define CMD_PRINT_REG_LEN 3 -#define CMD_PRINT_REG_DATA 4 - -static inline uint8_t system76_ec_read(uint8_t addr) -{ - return inb(LIBREM_EC_BASE + (uint16_t)addr); -} - -static inline void system76_ec_write(uint8_t addr, uint8_t data) -{ - outb(data, LIBREM_EC_BASE + (uint16_t)addr); -} - -void system76_ec_init(void) -{ - // Clear entire command region - for (int i = 0; i < LIBREM_EC_SIZE; i++) - system76_ec_write((uint8_t)i, 0); -} - -void system76_ec_flush(void) -{ - system76_ec_write(REG_CMD, CMD_PRINT); - - // Wait for command completion, for up to 10 milliseconds, with a - // test period of 1 microsecond - wait_us(10000, system76_ec_read(REG_CMD) == CMD_FINISHED); - - system76_ec_write(CMD_PRINT_REG_LEN, 0); -} - -void system76_ec_print(uint8_t byte) -{ - uint8_t len = system76_ec_read(CMD_PRINT_REG_LEN); - system76_ec_write(CMD_PRINT_REG_DATA + len, byte); - system76_ec_write(CMD_PRINT_REG_LEN, len + 1); - - // If we hit the end of the buffer, or were given a newline, flush - if (byte == '\n' || len >= (LIBREM_EC_SIZE - CMD_PRINT_REG_DATA)) - system76_ec_flush(); -}