coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
system76_ec.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <arch/io.h>
4 #include <console/system76_ec.h>
5 #include <timer.h>
6 
7 // This is the command region for System76 EC firmware. It must be
8 // enabled for LPC in the mainboard.
9 #define SYSTEM76_EC_BASE 0x0E00
10 #define SYSTEM76_EC_SIZE 256
11 
12 #define REG_CMD 0
13 #define REG_RESULT 1
14 
15 // When command register is 0, command is complete
16 #define CMD_FINISHED 0
17 
18 // Print command. Registers are unique for each command
19 #define CMD_PRINT 4
20 #define CMD_PRINT_REG_FLAGS 2
21 #define CMD_PRINT_REG_LEN 3
22 #define CMD_PRINT_REG_DATA 4
23 
25 {
26  return inb(SYSTEM76_EC_BASE + (uint16_t)addr);
27 }
28 
29 static inline void system76_ec_write(uint8_t addr, uint8_t data)
30 {
32 }
33 
34 void system76_ec_init(void)
35 {
36  // Clear entire command region
37  for (int i = 0; i < SYSTEM76_EC_SIZE; i++)
39 }
40 
42 {
44 
45  // Wait for command completion, for up to 10 milliseconds, with a
46  // test period of 1 microsecond
48 
50 }
51 
53 {
57 
58  // If we hit the end of the buffer, or were given a newline, flush
59  if (byte == '\n' || len >= (SYSTEM76_EC_SIZE - CMD_PRINT_REG_DATA))
61 }
static u32 addr
Definition: cirrus.c:14
u8 inb(u16 port)
void outb(u8 val, u16 port)
#define wait_us(timeout_us, condition)
Definition: timer.h:198
unsigned short uint16_t
Definition: stdint.h:11
unsigned char uint8_t
Definition: stdint.h:8
#define CMD_PRINT_REG_DATA
Definition: system76_ec.c:22
#define SYSTEM76_EC_BASE
Definition: system76_ec.c:9
void system76_ec_print(uint8_t byte)
Definition: system76_ec.c:52
#define CMD_FINISHED
Definition: system76_ec.c:16
#define CMD_PRINT_REG_LEN
Definition: system76_ec.c:21
#define SYSTEM76_EC_SIZE
Definition: system76_ec.c:10
static uint8_t system76_ec_read(uint8_t addr)
Definition: system76_ec.c:24
#define REG_CMD
Definition: system76_ec.c:12
static void system76_ec_write(uint8_t addr, uint8_t data)
Definition: system76_ec.c:29
void system76_ec_init(void)
Definition: system76_ec.c:34
#define CMD_PRINT
Definition: system76_ec.c:19
void system76_ec_flush(void)
Definition: system76_ec.c:41